@@ -635,7 +635,7 @@ static inline void i2c_xfer_stats(const struct device *dev, struct i2c_msg *msgs
635
635
/** @endcond */
636
636
637
637
/**
638
- * @brief Like DEVICE_DT_DEFINE () with I2C specifics.
638
+ * @brief Like DEVICE_DT_DEINIT_DEFINE () with I2C specifics.
639
639
*
640
640
* @details Defines a device which implements the I2C API. May
641
641
* 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
645
645
*
646
646
* @param init_fn Name of the init function of the driver. Can be `NULL`.
647
647
*
648
+ * @param deinit_fn Name of the deinit function of the driver. Can be `NULL`.
649
+ *
648
650
* @param pm PM device resources reference (NULL if device does not use PM).
649
651
*
650
652
* @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
661
663
* @param api Provides an initial pointer to the API function struct
662
664
* used by the driver. Can be NULL.
663
665
*/
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 , ...)\
666
668
Z_I2C_DEVICE_STATE_DEFINE(Z_DEVICE_DT_DEV_ID(node_id)); \
667
669
Z_I2C_INIT_FN(Z_DEVICE_DT_DEV_ID(node_id), init_fn) \
668
670
Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_ID(node_id), \
669
671
DEVICE_DT_NAME(node_id), \
670
672
&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,\
672
674
config, level, prio, api, \
673
675
&(Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_ID(node_id)).devstate), \
674
676
__VA_ARGS__)
@@ -683,12 +685,32 @@ static inline void i2c_xfer_stats(const struct device *dev, struct i2c_msg *msgs
683
685
ARG_UNUSED (num_msgs );
684
686
}
685
687
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
+ */
686
698
#define I2C_DEVICE_DT_DEFINE (node_id , init_fn , pm , data , config , level , \
687
699
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__)
690
703
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__)
692
714
693
715
/**
694
716
* @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
701
723
#define I2C_DEVICE_DT_INST_DEFINE (inst , ...) \
702
724
I2C_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
703
725
704
-
705
726
/**
706
727
* @brief Configure operation of a host controller.
707
728
*
0 commit comments