Skip to content

Commit b38054b

Browse files
Martinhoff-makerasmellby
authored andcommitted
devicetree: fix DT_SPI_DEV_HAS_CS_GPIOS macro
This fix ensures that the implementation matches the documented behavior, where the macro return 1 when the cs-gpios property has an entry matching the reg address of the child device. This restores the behavior of the devicetree init API prior to <a60f93d742a48660882af5785fb4352f414ecd11>, which accidentally introduced this issue by relying on the `DT_SPI_DEV_HAS_CS_GPIOS` macro, which has deviated from its documented behavior ever since it was originally introduced 6 years ago. Signed-off-by: Martin Hoff <martin.hoff@silabs.com> Co-authored-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
1 parent 4e9a4e3 commit b38054b

File tree

1 file changed

+2
-1
lines changed
  • include/zephyr/devicetree

1 file changed

+2
-1
lines changed

include/zephyr/devicetree/spi.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ extern "C" {
115115
* @return 1 if spi_dev's bus node DT_BUS(spi_dev) has a chip select
116116
* pin at index DT_REG_ADDR(spi_dev), 0 otherwise
117117
*/
118-
#define DT_SPI_DEV_HAS_CS_GPIOS(spi_dev) DT_SPI_HAS_CS_GPIOS(DT_BUS(spi_dev))
118+
#define DT_SPI_DEV_HAS_CS_GPIOS(spi_dev) \
119+
DT_PROP_HAS_IDX(DT_BUS(spi_dev), cs_gpios, DT_REG_ADDR_RAW(spi_dev))
119120

120121
/**
121122
* @brief Get a SPI device's chip select GPIO controller's node identifier

0 commit comments

Comments
 (0)