From 17b8667197113f858cfd678bb220d3525c78a1c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Bol=C3=ADvar?= Date: Wed, 6 May 2020 10:50:36 -0700 Subject: [PATCH] dts: clean up some redundant DT checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are redundantly checking a node's status twice. Signed-off-by: Martí Bolívar Signed-off-by: Kumar Gala --- boards/arm/frdm_k64f/pinmux.c | 3 +-- boards/arm/frdm_k82f/pinmux.c | 3 +-- boards/arm/hexiwear_k64/pinmux.c | 3 +-- boards/arm/lpcxpresso54114/pinmux.c | 9 +++------ boards/arm/lpcxpresso55s16/pinmux.c | 6 ++---- boards/arm/lpcxpresso55s69/pinmux.c | 6 ++---- boards/arm/twr_ke18f/pinmux.c | 6 ++---- drivers/can/can_stm32.c | 12 ++++-------- drivers/serial/uart_stm32.c | 3 +-- soc/arm/atmel_sam0/common/atmel_sam0_dt.h | 1 - soc/arm/nxp_lpc/lpc54xxx/soc.c | 6 ++---- soc/arm/nxp_lpc/lpc55xxx/soc.c | 3 +-- 12 files changed, 20 insertions(+), 41 deletions(-) diff --git a/boards/arm/frdm_k64f/pinmux.c b/boards/arm/frdm_k64f/pinmux.c index 0ebe2c6f1a9..110bdb210e9 100644 --- a/boards/arm/frdm_k64f/pinmux.c +++ b/boards/arm/frdm_k64f/pinmux.c @@ -122,8 +122,7 @@ static int frdm_k64f_pinmux_init(struct device *dev) pinmux_pin_set(portb, 10, PORT_PCR_MUX(kPORT_PinDisabledOrAnalog)); #endif -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(ftm3)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm) pinmux_pin_set(portc, 8, PORT_PCR_MUX(kPORT_MuxAlt3)); pinmux_pin_set(portc, 9, PORT_PCR_MUX(kPORT_MuxAlt3)); #endif diff --git a/boards/arm/frdm_k82f/pinmux.c b/boards/arm/frdm_k82f/pinmux.c index 970e9ee926c..4bb9d9d2e32 100644 --- a/boards/arm/frdm_k82f/pinmux.c +++ b/boards/arm/frdm_k82f/pinmux.c @@ -33,8 +33,7 @@ static int frdm_k82f_pinmux_init(struct device *dev) device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME); #endif -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(ftm3)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm) /* Red, green, blue LEDs as PWM channels */ pinmux_pin_set(portc, 8, PORT_PCR_MUX(kPORT_MuxAlt3)); pinmux_pin_set(portc, 9, PORT_PCR_MUX(kPORT_MuxAlt3)); diff --git a/boards/arm/hexiwear_k64/pinmux.c b/boards/arm/hexiwear_k64/pinmux.c index 696c3a249c9..f2d691ca22c 100644 --- a/boards/arm/hexiwear_k64/pinmux.c +++ b/boards/arm/hexiwear_k64/pinmux.c @@ -30,8 +30,7 @@ static int hexiwear_k64_pinmux_init(struct device *dev) device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME); #endif -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(ftm3)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm) /* Red, green, blue LEDs as PWM channels */ pinmux_pin_set(portc, 8, PORT_PCR_MUX(kPORT_MuxAlt3)); pinmux_pin_set(portc, 9, PORT_PCR_MUX(kPORT_MuxAlt3)); diff --git a/boards/arm/lpcxpresso54114/pinmux.c b/boards/arm/lpcxpresso54114/pinmux.c index 9ec6966d4ea..dd7d3c276a2 100644 --- a/boards/arm/lpcxpresso54114/pinmux.c +++ b/boards/arm/lpcxpresso54114/pinmux.c @@ -23,8 +23,7 @@ static int lpcxpresso_54114_pinmux_init(struct device *dev) device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT1_NAME); #endif -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(flexcomm0)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm0), nxp_lpc_usart) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm0), nxp_lpc_usart) /* USART0 RX, TX */ const u32_t port0_pin0_config = ( IOCON_PIO_FUNC1 | @@ -108,8 +107,7 @@ static int lpcxpresso_54114_pinmux_init(struct device *dev) pinmux_pin_set(port1, 10, port1_pin10_config); #endif -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(flexcomm4)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm4), nxp_lpc_i2c) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm4), nxp_lpc_i2c) /* PORT0 PIN25 is configured as FC4_RTS_SCL_SSEL1 */ pinmux_pin_set(port0, 25, IOCON_PIO_FUNC1 | IOCON_PIO_I2CSLEW_I2C | @@ -129,8 +127,7 @@ static int lpcxpresso_54114_pinmux_init(struct device *dev) IOCON_PIO_I2CFILTER_EN); #endif -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(flexcomm5)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm5), nxp_lpc_spi) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm5), nxp_lpc_spi) /* PORT0 PIN18 is configured as FC5_TXD_SCL_MISO */ pinmux_pin_set(port0, 18, IOCON_PIO_FUNC1 | IOCON_PIO_MODE_PULLUP | diff --git a/boards/arm/lpcxpresso55s16/pinmux.c b/boards/arm/lpcxpresso55s16/pinmux.c index 6e186f09cc8..78b439c6149 100644 --- a/boards/arm/lpcxpresso55s16/pinmux.c +++ b/boards/arm/lpcxpresso55s16/pinmux.c @@ -95,8 +95,7 @@ static int lpcxpresso_55s16_pinmux_init(struct device *dev) pinmux_pin_set(port1, DT_GPIO_PIN(DT_ALIAS(led2), gpios), led2_config); #endif -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(flexcomm0)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm0), nxp_lpc_usart) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm0), nxp_lpc_usart) /* USART0 RX, TX */ const u32_t port0_pin29_config = ( IOCON_PIO_FUNC1 | @@ -118,8 +117,7 @@ static int lpcxpresso_55s16_pinmux_init(struct device *dev) pinmux_pin_set(port0, 30, port0_pin30_config); #endif -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(flexcomm4)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm4), nxp_lpc_i2c) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm4), nxp_lpc_i2c) /* PORT1 PIN20 is configured as FC4_TXD_SCL_MISO_WS */ pinmux_pin_set(port1, 20, IOCON_PIO_FUNC5 | IOCON_PIO_MODE_INACT | diff --git a/boards/arm/lpcxpresso55s69/pinmux.c b/boards/arm/lpcxpresso55s69/pinmux.c index abdfc714330..387a4e952b7 100644 --- a/boards/arm/lpcxpresso55s69/pinmux.c +++ b/boards/arm/lpcxpresso55s69/pinmux.c @@ -23,8 +23,7 @@ static int lpcxpresso_55s69_pinmux_init(struct device *dev) device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT1_NAME); #endif -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(flexcomm0)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm0), nxp_lpc_usart) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm0), nxp_lpc_usart) /* USART0 RX, TX */ const u32_t port0_pin29_config = ( IOCON_PIO_FUNC1 | @@ -89,8 +88,7 @@ static int lpcxpresso_55s69_pinmux_init(struct device *dev) pinmux_pin_set(port1, DT_GPIO_PIN(DT_ALIAS(sw2), gpios), sw2_config); #endif -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(flexcomm4)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm4), nxp_lpc_i2c) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm4), nxp_lpc_i2c) /* PORT1 PIN20 is configured as FC4_TXD_SCL_MISO_WS */ pinmux_pin_set(port1, 20, IOCON_PIO_FUNC5 | IOCON_PIO_MODE_INACT | diff --git a/boards/arm/twr_ke18f/pinmux.c b/boards/arm/twr_ke18f/pinmux.c index deb93115e88..b9f15648d37 100644 --- a/boards/arm/twr_ke18f/pinmux.c +++ b/boards/arm/twr_ke18f/pinmux.c @@ -34,8 +34,7 @@ static int twr_ke18f_pinmux_init(struct device *dev) device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME); #endif -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(ftm0)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(ftm0), nxp_kinetis_ftm_pwm) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(ftm0), nxp_kinetis_ftm_pwm) /* Tri-color LED as PWM */ pinmux_pin_set(portb, 5, PORT_PCR_MUX(kPORT_MuxAlt2)); pinmux_pin_set(portd, 15, PORT_PCR_MUX(kPORT_MuxAlt2)); @@ -47,8 +46,7 @@ static int twr_ke18f_pinmux_init(struct device *dev) pinmux_pin_set(portd, 16, PORT_PCR_MUX(kPORT_MuxAsGpio)); #endif -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(ftm3)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm) /* User LEDs as PWM */ pinmux_pin_set(portc, 10, PORT_PCR_MUX(kPORT_MuxAlt2)); pinmux_pin_set(portc, 11, PORT_PCR_MUX(kPORT_MuxAlt2)); diff --git a/drivers/can/can_stm32.c b/drivers/can/can_stm32.c index 0d0408931a3..cc2d3a48821 100644 --- a/drivers/can/can_stm32.c +++ b/drivers/can/can_stm32.c @@ -20,10 +20,8 @@ LOG_MODULE_DECLARE(can_driver, CONFIG_CAN_LOG_LEVEL); #define CAN_INIT_TIMEOUT (10 * sys_clock_hw_cycles_per_sec() / MSEC_PER_SEC) -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(can1)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(can1), st_stm32_can) && \ - DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(can2)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(can2), st_stm32_can) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(can1), st_stm32_can) && \ + DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(can2), st_stm32_can) #error Simultaneous use of CAN_1 and CAN_2 not supported yet #endif @@ -1047,8 +1045,7 @@ static const struct can_driver_api can_api_funcs = { .register_state_change_isr = can_stm32_register_state_change_isr }; -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(can1)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(can1), st_stm32_can) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(can1), st_stm32_can) static void config_can_1_irq(CAN_TypeDef *can); @@ -1137,8 +1134,7 @@ NET_DEVICE_INIT(socket_can_stm32_1, SOCKET_CAN_NAME_1, socket_can_init_1, #endif /* DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(can1)) */ -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(can2)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(can2), st_stm32_can) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(can2), st_stm32_can) static void config_can_2_irq(CAN_TypeDef *can); diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c index e9f042bdd54..4d36febe719 100644 --- a/drivers/serial/uart_stm32.c +++ b/drivers/serial/uart_stm32.c @@ -29,8 +29,7 @@ #include LOG_MODULE_REGISTER(uart_stm32); -#define HAS_LPUART_1 (DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(lpuart1)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(lpuart1), \ +#define HAS_LPUART_1 (DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(lpuart1), \ st_stm32_lpuart)) /* convenience defines */ diff --git a/soc/arm/atmel_sam0/common/atmel_sam0_dt.h b/soc/arm/atmel_sam0/common/atmel_sam0_dt.h index 06c0a9d47c3..293dfcbc1b2 100644 --- a/soc/arm/atmel_sam0/common/atmel_sam0_dt.h +++ b/soc/arm/atmel_sam0/common/atmel_sam0_dt.h @@ -37,7 +37,6 @@ /* Use to check if a sercom 'n' is enabled for a given 'compat' */ #define ATMEL_SAM0_DT_SERCOM_CHECK(n, compat) \ - DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(sercom##n)) && \ DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(sercom##n), compat) /* Common macro for use to set HCLK_FREQ_HZ */ diff --git a/soc/arm/nxp_lpc/lpc54xxx/soc.c b/soc/arm/nxp_lpc/lpc54xxx/soc.c index 7e32f7bd5b2..ed64438fd50 100644 --- a/soc/arm/nxp_lpc/lpc54xxx/soc.c +++ b/soc/arm/nxp_lpc/lpc54xxx/soc.c @@ -67,8 +67,7 @@ static ALWAYS_INLINE void clock_init(void) /* Attach 12 MHz clock to FLEXCOMM0 */ CLOCK_AttachClk(kFRO12M_to_FLEXCOMM0); -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(flexcomm4)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm4), nxp_lpc_i2c) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm4), nxp_lpc_i2c) /* attach 12 MHz clock to FLEXCOMM4 */ CLOCK_AttachClk(kFRO12M_to_FLEXCOMM4); @@ -76,8 +75,7 @@ static ALWAYS_INLINE void clock_init(void) RESET_PeripheralReset(kFC4_RST_SHIFT_RSTn); #endif -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(flexcomm5)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm5), nxp_lpc_spi) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm5), nxp_lpc_spi) /* Attach 12 MHz clock to FLEXCOMM5 */ CLOCK_AttachClk(kFRO_HF_to_FLEXCOMM5); diff --git a/soc/arm/nxp_lpc/lpc55xxx/soc.c b/soc/arm/nxp_lpc/lpc55xxx/soc.c index 85b4c6f7ea5..86b23b44d66 100644 --- a/soc/arm/nxp_lpc/lpc55xxx/soc.c +++ b/soc/arm/nxp_lpc/lpc55xxx/soc.c @@ -61,8 +61,7 @@ static ALWAYS_INLINE void clock_init(void) /* Enables the clock for the I/O controller.: Enable Clock. */ CLOCK_EnableClock(kCLOCK_Iocon); -#if DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(flexcomm4)) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm4), nxp_lpc_i2c) +#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm4), nxp_lpc_i2c) /* attach 12 MHz clock to FLEXCOMM4 */ CLOCK_AttachClk(kFRO12M_to_FLEXCOMM4);