Skip to content

Commit cbf4c1c

Browse files
committed
spi: Provide new device instantiation macro
Again removing the prio parameter. However, original macro does not seem to be used anywhere... Signed-off-by: Tomasz Bursztyka <[email protected]>
1 parent 8015d1a commit cbf4c1c

File tree

1 file changed

+32
-0
lines changed
  • include/zephyr/drivers

1 file changed

+32
-0
lines changed

include/zephyr/drivers/spi.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,33 @@ struct spi_device_state {
585585
&(Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_ID(node_id)).devstate), \
586586
__VA_ARGS__)
587587

588+
/**
589+
* @brief Like DEVICE_INSTANCE() with SPI specifics.
590+
*
591+
* @details Defines a device which implements the SPI API. May
592+
* generate a custom device_state container struct and init_fn
593+
* wrapper when needed depending on SPI @kconfig{CONFIG_SPI_STATS}.
594+
*
595+
* @param node_id The devicetree node identifier.
596+
* @param init_fn Name of the init function of the driver.
597+
* @param pm_device PM device resources reference (NULL if device does not use PM).
598+
* @param data_ptr Pointer to the device's private data.
599+
* @param cfg_ptr The address to the structure containing the configuration
600+
* information for this instance of the driver.
601+
* @param level The initialization level. See SYS_INIT() for details.
602+
* @param api_ptr Provides an initial pointer to the API function struct used by
603+
* the driver. Can be NULL.
604+
*/
605+
#define SPI_DEVICE_INSTANCE(node_id, init_fn, pm_device, \
606+
data_ptr, cfg_ptr, level, api_ptr) \
607+
Z_SPI_DEVICE_STATE_DEFINE(Z_DEVICE_DT_DEV_ID(node_id)); \
608+
Z_SPI_INIT_FN(Z_DEVICE_DT_DEV_ID(node_id), init_fn) \
609+
DEVICE_INSTANCE_EXTERNAL_STATE(node_id, init_fn, pm_device, \
610+
data_ptr, cfg_ptr, level, \
611+
api_ptr, \
612+
&(Z_DEVICE_STATE_NAME( \
613+
Z_DEVICE_DT_DEV_ID(node_id)).devstate))
614+
588615
static inline void spi_transceive_stats(const struct device *dev, int error,
589616
const struct spi_buf_set *tx_bufs,
590617
const struct spi_buf_set *rx_bufs)
@@ -619,6 +646,11 @@ static inline void spi_transceive_stats(const struct device *dev, int error,
619646
&Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_ID(node_id)), \
620647
__VA_ARGS__)
621648

649+
#define SPI_DEVICE_INSTANCE(node_id, init_fn, pm_device, \
650+
data_ptr, cfg_ptr, level, api_ptr) \
651+
DEVICE_INSTANCE(node_id, init_fn, pm_device, data_ptr, cfg_ptr, \
652+
level, api_ptr)
653+
622654
#define SPI_STATS_RX_BYTES_INC(dev_)
623655
#define SPI_STATS_TX_BYTES_INC(dev_)
624656
#define SPI_STATS_TRANSFER_ERROR_INC(dev_)

0 commit comments

Comments
 (0)