@@ -657,16 +657,16 @@ struct spi_device_state {
657
657
}
658
658
/** @endcond */
659
659
660
- #define SPI_DEVICE_DT_DEFINE (node_id , init_fn , pm_device , \
661
- data_ptr , cfg_ptr , level , prio , \
662
- api_ptr , ...) \
660
+ #define SPI_DEVICE_DT_DEINIT_DEFINE (node_id , init_fn , deinit_fn , \
661
+ pm_device , data_ptr , cfg_ptr , \
662
+ level , prio , api_ptr , ...) \
663
663
Z_SPI_DEVICE_STATE_DEFINE(Z_DEVICE_DT_DEV_ID(node_id)); \
664
664
Z_SPI_INIT_FN(Z_DEVICE_DT_DEV_ID(node_id), init_fn) \
665
665
Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_ID(node_id), \
666
666
DEVICE_DT_NAME(node_id), \
667
667
&UTIL_CAT(Z_DEVICE_DT_DEV_ID(node_id), _init), \
668
- NULL , Z_DEVICE_DT_FLAGS(node_id), pm_device, \
669
- data_ptr, cfg_ptr, level, prio, \
668
+ deinit_fn , Z_DEVICE_DT_FLAGS(node_id), \
669
+ pm_device, data_ptr, cfg_ptr, level, prio, \
670
670
api_ptr, \
671
671
&(Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_ID(node_id)).devstate), \
672
672
__VA_ARGS__)
@@ -700,15 +700,17 @@ static inline void spi_transceive_stats(const struct device *dev, int error,
700
700
* @name SPI DT Device Macros
701
701
* @{
702
702
*/
703
+
703
704
/**
704
- * @brief Like DEVICE_DT_DEFINE () with SPI specifics.
705
+ * @brief Like DEVICE_DT_DEINIT_DEFINE () with SPI specifics.
705
706
*
706
707
* @details Defines a device which implements the SPI API. May
707
708
* generate a custom device_state container struct and init_fn
708
709
* wrapper when needed depending on SPI @kconfig{CONFIG_SPI_STATS}.
709
710
*
710
711
* @param node_id The devicetree node identifier.
711
712
* @param init_fn Name of the init function of the driver.
713
+ * @param deinit_fn Name of the deinit function of the driver.
712
714
* @param pm PM device resources reference (NULL if device does not use PM).
713
715
* @param data Pointer to the device's private data.
714
716
* @param config The address to the structure containing the configuration
@@ -719,16 +721,16 @@ static inline void spi_transceive_stats(const struct device *dev, int error,
719
721
* @param api Provides an initial pointer to the API function struct used by
720
722
* the driver. Can be NULL.
721
723
*/
722
- #define SPI_DEVICE_DT_DEFINE (node_id , init_fn , pm , \
723
- data , config , level , prio , \
724
- api , ...) \
724
+ #define SPI_DEVICE_DT_DEINIT_DEFINE (node_id , init_fn , deinit_fn , pm , data , \
725
+ config , level , prio , api , ...) \
725
726
Z_DEVICE_STATE_DEFINE(Z_DEVICE_DT_DEV_ID(node_id)); \
726
727
Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_ID(node_id), \
727
- DEVICE_DT_NAME(node_id), init_fn, NULL, \
728
+ DEVICE_DT_NAME(node_id), init_fn, deinit_fn, \
728
729
Z_DEVICE_DT_FLAGS(node_id), pm, data, config, \
729
730
level, prio, api, \
730
731
&Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_ID(node_id)), \
731
732
__VA_ARGS__)
733
+
732
734
/** @} */
733
735
734
736
#define SPI_STATS_RX_BYTES_INC (dev_ )
@@ -739,6 +741,40 @@ static inline void spi_transceive_stats(const struct device *dev, int error,
739
741
740
742
#endif /*CONFIG_SPI_STATS*/
741
743
744
+ /**
745
+ * @brief Like DEVICE_DT_DEINIT_DEFINE() without deinit function.
746
+ *
747
+ * @details Defines a device which implements the SPI API. May
748
+ * generate a custom device_state container struct and init_fn
749
+ * wrapper when needed depending on SPI @kconfig{CONFIG_SPI_STATS}.
750
+ *
751
+ * @param node_id The devicetree node identifier.
752
+ * @param init_fn Name of the init function of the driver.
753
+ * @param pm PM device resources reference (NULL if device does not use PM).
754
+ * @param data Pointer to the device's private data.
755
+ * @param config The address to the structure containing the configuration
756
+ * information for this instance of the driver.
757
+ * @param level The initialization level. See SYS_INIT() for details.
758
+ * @param prio Priority within the selected initialization level. See SYS_INIT()
759
+ * for details.
760
+ * @param api Provides an initial pointer to the API function struct used by
761
+ * the driver. Can be NULL.
762
+ */
763
+ #define SPI_DEVICE_DT_DEFINE (node_id , init_fn , pm , data , config , level , prio , \
764
+ api , ...) \
765
+ SPI_DEVICE_DT_DEINIT_DEFINE(node_id, init_fn, NULL, pm, data, config, \
766
+ level, prio, api, __VA_ARGS__)
767
+
768
+ /**
769
+ * @brief Like SPI_DEVICE_DT_DEINIT_DEFINE(), but uses an instance of a `DT_DRV_COMPAT`
770
+ * compatible instead of a node identifier.
771
+ *
772
+ * @param inst Instance number. The `node_id` argument to SPI_DEVICE_DT_DEINIT_DEFINE() is
773
+ * set to `DT_DRV_INST(inst)`.
774
+ * @param ... Other parameters as expected by SPI_DEVICE_DT_DEFINE().
775
+ */
776
+ #define SPI_DEVICE_DT_INST_DEINIT_DEFINE (inst , ...) \
777
+ SPI_DEVICE_DT_DEINIT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
742
778
743
779
/**
744
780
* @brief Like SPI_DEVICE_DT_DEFINE(), but uses an instance of a `DT_DRV_COMPAT`
0 commit comments