Skip to content

Commit 6d8afa8

Browse files
committed
drivers: spi: smbus: allow NULL init function
Generic device API allows for NULL init function, do the same for SPI and SMBUS. Signed-off-by: Dane Wagner <[email protected]>
1 parent 49a458e commit 6d8afa8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

include/zephyr/drivers/smbus.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,10 @@ struct smbus_device_state {
449449
stats_init(&state->stats.s_hdr, STATS_SIZE_32, 4, \
450450
STATS_NAME_INIT_PARMS(smbus)); \
451451
stats_register(dev->name, &(state->stats.s_hdr)); \
452-
return init_fn(dev); \
452+
if (!is_null_no_warn(init_fn)) { \
453+
return init_fn(dev); \
454+
} \
455+
return 0; \
453456
}
454457

455458
/** @endcond */

include/zephyr/drivers/spi.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,10 @@ struct spi_device_state {
549549
stats_init(&state->stats.s_hdr, STATS_SIZE_32, 3, \
550550
STATS_NAME_INIT_PARMS(spi)); \
551551
stats_register(dev->name, &(state->stats.s_hdr)); \
552-
return init_fn(dev); \
552+
if (!is_null_no_warn(init_fn)) { \
553+
return init_fn(dev); \
554+
} \
555+
return 0; \
553556
}
554557

555558
/**

0 commit comments

Comments
 (0)