@@ -635,7 +635,7 @@ static inline void i2c_xfer_stats(const struct device *dev, struct i2c_msg *msgs
635635/** @endcond */
636636
637637/**
638- * @brief Like DEVICE_DT_DEFINE () with I2C specifics.
638+ * @brief Like DEVICE_DT_DEINIT_DEFINE () with I2C specifics.
639639 *
640640 * @details Defines a device which implements the I2C API. May
641641 * generate a custom device_state container struct and init_fn
@@ -645,6 +645,8 @@ static inline void i2c_xfer_stats(const struct device *dev, struct i2c_msg *msgs
645645 *
646646 * @param init_fn Name of the init function of the driver. Can be `NULL`.
647647 *
648+ * @param deinit_fn Name of the deinit function of the driver. Can be `NULL`.
649+ *
648650 * @param pm PM device resources reference (NULL if device does not use PM).
649651 *
650652 * @param data Pointer to the device's private data.
@@ -661,14 +663,14 @@ static inline void i2c_xfer_stats(const struct device *dev, struct i2c_msg *msgs
661663 * @param api Provides an initial pointer to the API function struct
662664 * used by the driver. Can be NULL.
663665 */
664- #define I2C_DEVICE_DT_DEFINE (node_id , init_fn , pm , data , config , level , \
665- prio , api , ...) \
666+ #define I2C_DEVICE_DT_DEINIT_DEFINE (node_id , init_fn , deinit_fn , pm , \
667+ data , config , level , prio , api , ...)\
666668 Z_I2C_DEVICE_STATE_DEFINE(Z_DEVICE_DT_DEV_ID(node_id)); \
667669 Z_I2C_INIT_FN(Z_DEVICE_DT_DEV_ID(node_id), init_fn) \
668670 Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_ID(node_id), \
669671 DEVICE_DT_NAME(node_id), \
670672 &UTIL_CAT(Z_DEVICE_DT_DEV_ID(node_id), _init), \
671- NULL , Z_DEVICE_DT_FLAGS(node_id), pm, data, \
673+ deinit_fn , Z_DEVICE_DT_FLAGS(node_id), pm, data,\
672674 config, level, prio, api, \
673675 &(Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_ID(node_id)).devstate), \
674676 __VA_ARGS__)
@@ -683,12 +685,32 @@ static inline void i2c_xfer_stats(const struct device *dev, struct i2c_msg *msgs
683685 ARG_UNUSED (num_msgs );
684686}
685687
688+ #define I2C_DEVICE_DT_DEINIT_DEFINE (node_id , init_fn , deinit_fn , pm , \
689+ data , config , level , prio , api , ...)\
690+ DEVICE_DT_DEINIT_DEFINE(node_id, init_fn, deinit_fn, pm, data, \
691+ config, level, prio, api, __VA_ARGS__)
692+
693+ #endif /* CONFIG_I2C_STATS */
694+
695+ /**
696+ * @brief Like I2C_DEVICE_DT_DEINIT_DEFINE() but without deinit_fn
697+ */
686698#define I2C_DEVICE_DT_DEFINE (node_id , init_fn , pm , data , config , level , \
687699 prio , api , ...) \
688- DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \
689- prio, api, __VA_ARGS__)
700+ I2C_DEVICE_DT_DEINIT_DEFINE(node_id, init_fn, NULL, pm, data, \
701+ config, level, prio, api, \
702+ __VA_ARGS__)
690703
691- #endif /* CONFIG_I2C_STATS */
704+ /**
705+ * @brief Like I2C_DEVICE_DT_DEINIT_DEFINE() for an instance of a DT_DRV_COMPAT compatible
706+ *
707+ * @param inst instance number. This is replaced by
708+ * <tt>DT_DRV_COMPAT(inst)</tt> in the call to I2C_DEVICE_DT_DEINIT_DEFINE().
709+ *
710+ * @param ... other parameters as expected by I2C_DEVICE_DT_DEINIT_DEFINE().
711+ */
712+ #define I2C_DEVICE_DT_INST_DEINIT_DEFINE (inst , ...) \
713+ I2C_DEVICE_DT_DEINIT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
692714
693715/**
694716 * @brief Like I2C_DEVICE_DT_DEFINE() for an instance of a DT_DRV_COMPAT compatible
@@ -701,7 +723,6 @@ static inline void i2c_xfer_stats(const struct device *dev, struct i2c_msg *msgs
701723#define I2C_DEVICE_DT_INST_DEFINE (inst , ...) \
702724 I2C_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
703725
704-
705726/**
706727 * @brief Configure operation of a host controller.
707728 *
0 commit comments