drivers: i3c: Check for the existence of callback before invoking
I3C callbacks are registered by upper layer. Driver layer must check if a callback is not NULL before calling it Signed-off-by: Nghia Phung <nghiap@amperecomputing.com>
This commit is contained in:
parent
90dd76bf7a
commit
caf42fbdef
1 changed files with 6 additions and 4 deletions
|
@ -553,10 +553,12 @@ static void dw_i3c_end_xfer(const struct device *dev)
|
|||
|
||||
for (j = 0; j < cmd->rx_len; j += 4) {
|
||||
rx_data = sys_read32(config->regs + RX_TX_DATA_PORT);
|
||||
/* Call write received cb for each remaining byte */
|
||||
for (k = 0; k < MIN(4, cmd->rx_len - j); k++) {
|
||||
target_cb->write_received_cb(data->target_config,
|
||||
(rx_data >> (8 * k)) & 0xff);
|
||||
if (target_cb != NULL && target_cb->write_received_cb != NULL) {
|
||||
/* Call write received cb for each remaining byte */
|
||||
for (k = 0; k < MIN(4, cmd->rx_len - j); k++) {
|
||||
target_cb->write_received_cb(data->target_config,
|
||||
(rx_data >> (8 * k)) & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue