Skip to content

Commit ff10333

Browse files
nordic-krchnordicjm
authored andcommitted
[nrf fromtree] drivers: spi: nrfx_spim: Remove explicit references to SPIM instances
Add FOREACH macro which iterates over all SPIM instances and creates device instances for each enabled instance. Signed-off-by: Krzysztof Chruściński <[email protected]> (cherry picked from commit 9d59e03)
1 parent 1b0dc55 commit ff10333

File tree

1 file changed

+3
-78
lines changed

1 file changed

+3
-78
lines changed

drivers/spi/spi_nrfx_spim.c

+3-78
Original file line numberDiff line numberDiff line change
@@ -861,82 +861,7 @@ static int spi_nrfx_init(const struct device *dev)
861861
SPIM_MEM_REGION(idx)))))), \
862862
())
863863

864-
#ifdef CONFIG_HAS_HW_NRF_SPIM0
865-
SPI_NRFX_SPIM_DEFINE(0);
866-
#endif
867-
868-
#ifdef CONFIG_HAS_HW_NRF_SPIM1
869-
SPI_NRFX_SPIM_DEFINE(1);
870-
#endif
871-
872-
#ifdef CONFIG_HAS_HW_NRF_SPIM2
873-
SPI_NRFX_SPIM_DEFINE(2);
874-
#endif
875-
876-
#ifdef CONFIG_HAS_HW_NRF_SPIM3
877-
SPI_NRFX_SPIM_DEFINE(3);
878-
#endif
879-
880-
#ifdef CONFIG_HAS_HW_NRF_SPIM4
881-
SPI_NRFX_SPIM_DEFINE(4);
882-
#endif
883-
884-
#ifdef CONFIG_HAS_HW_NRF_SPIM00
885-
SPI_NRFX_SPIM_DEFINE(00);
886-
#endif
887-
888-
#ifdef CONFIG_HAS_HW_NRF_SPIM20
889-
SPI_NRFX_SPIM_DEFINE(20);
890-
#endif
891-
892-
#ifdef CONFIG_HAS_HW_NRF_SPIM21
893-
SPI_NRFX_SPIM_DEFINE(21);
894-
#endif
895-
896-
#ifdef CONFIG_HAS_HW_NRF_SPIM22
897-
SPI_NRFX_SPIM_DEFINE(22);
898-
#endif
899-
900-
#ifdef CONFIG_HAS_HW_NRF_SPIM30
901-
SPI_NRFX_SPIM_DEFINE(30);
902-
#endif
864+
#define COND_NRF_SPIM_DEVICE(unused, prefix, i, _) \
865+
IF_ENABLED(CONFIG_HAS_HW_NRF_SPIM##prefix##i, (SPI_NRFX_SPIM_DEFINE(prefix##i);))
903866

904-
#ifdef CONFIG_HAS_HW_NRF_SPIM120
905-
SPI_NRFX_SPIM_DEFINE(120);
906-
#endif
907-
908-
#ifdef CONFIG_HAS_HW_NRF_SPIM121
909-
SPI_NRFX_SPIM_DEFINE(121);
910-
#endif
911-
912-
#ifdef CONFIG_HAS_HW_NRF_SPIM130
913-
SPI_NRFX_SPIM_DEFINE(130);
914-
#endif
915-
916-
#ifdef CONFIG_HAS_HW_NRF_SPIM131
917-
SPI_NRFX_SPIM_DEFINE(131);
918-
#endif
919-
920-
#ifdef CONFIG_HAS_HW_NRF_SPIM132
921-
SPI_NRFX_SPIM_DEFINE(132);
922-
#endif
923-
924-
#ifdef CONFIG_HAS_HW_NRF_SPIM133
925-
SPI_NRFX_SPIM_DEFINE(133);
926-
#endif
927-
928-
#ifdef CONFIG_HAS_HW_NRF_SPIM134
929-
SPI_NRFX_SPIM_DEFINE(134);
930-
#endif
931-
932-
#ifdef CONFIG_HAS_HW_NRF_SPIM135
933-
SPI_NRFX_SPIM_DEFINE(135);
934-
#endif
935-
936-
#ifdef CONFIG_HAS_HW_NRF_SPIM136
937-
SPI_NRFX_SPIM_DEFINE(136);
938-
#endif
939-
940-
#ifdef CONFIG_HAS_HW_NRF_SPIM137
941-
SPI_NRFX_SPIM_DEFINE(137);
942-
#endif
867+
NRFX_FOREACH_PRESENT(SPIM, COND_NRF_SPIM_DEVICE, (), (), _)

0 commit comments

Comments
 (0)