treewide: remove unnecessary DT GPIO/PWM flags checks
Now that the relevant APIs generalize properly for bindings without flags, we can remove some special case checks from the tree. I couldn't find any more, but I did this kind of quickly, so it's possible I missed some. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
c981323839
commit
5be0d00d41
|
@ -12,24 +12,6 @@
|
|||
#include <drivers/gpio.h>
|
||||
#include <sys/util.h>
|
||||
|
||||
/*
|
||||
* Devicetree helper macros which gets the 'flags' cell from a 'cs_gpios'
|
||||
* property on the spi bus, or returns 0 if the property has no 'flags' cell.
|
||||
*
|
||||
* Hopefully these helpers will be removed once #25827 is resolved.
|
||||
*/
|
||||
#define HAS_FLAGS(spi_dev, spi_reg) \
|
||||
DT_PHA_HAS_CELL_AT_IDX(spi_dev, cs_gpios, spi_reg, flags)
|
||||
|
||||
#define INST_SPI_DEV_CS_GPIOS_HAS_FLAGS(node) \
|
||||
HAS_FLAGS(DT_BUS(node), DT_REG_ADDR(node))
|
||||
|
||||
#define FLAGS_OR_ZERO(inst) \
|
||||
COND_CODE_1( \
|
||||
INST_SPI_DEV_CS_GPIOS_HAS_FLAGS(DT_DRV_INST(inst)), \
|
||||
(DT_INST_SPI_DEV_CS_GPIOS_FLAGS(inst)), \
|
||||
(0x0))
|
||||
|
||||
struct apa102_data {
|
||||
struct device *spi;
|
||||
struct spi_config cfg;
|
||||
|
@ -128,7 +110,8 @@ static int apa102_init(struct device *dev)
|
|||
data->cfg.cs = &data->cs_ctl;
|
||||
|
||||
gpio_pin_configure(data->cs_ctl.gpio_dev, data->cs_ctl.gpio_pin,
|
||||
GPIO_OUTPUT_INACTIVE | FLAGS_OR_ZERO(0));
|
||||
GPIO_OUTPUT_INACTIVE |
|
||||
DT_INST_SPI_DEV_CS_GPIOS_FLAGS(0));
|
||||
#endif /* DT_INST_SPI_DEV_HAS_CS_GPIOS(0) */
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -16,20 +16,10 @@
|
|||
|
||||
#define PWM_LED0_NODE DT_ALIAS(pwm_led0)
|
||||
|
||||
/*
|
||||
* Devicetree helper macro which gets the 'flags' cell from the node's
|
||||
* pwms property, or returns 0 if the property has no 'flags' cell.
|
||||
*/
|
||||
|
||||
#define FLAGS_OR_ZERO(node) \
|
||||
COND_CODE_1(DT_PHA_HAS_CELL(node, pwms, flags), \
|
||||
(DT_PWMS_FLAGS(node)), \
|
||||
(0))
|
||||
|
||||
#if DT_NODE_HAS_STATUS(PWM_LED0_NODE, okay)
|
||||
#define PWM_LABEL DT_PWMS_LABEL(PWM_LED0_NODE)
|
||||
#define PWM_CHANNEL DT_PWMS_CHANNEL(PWM_LED0_NODE)
|
||||
#define PWM_FLAGS FLAGS_OR_ZERO(PWM_LED0_NODE)
|
||||
#define PWM_FLAGS DT_PWMS_FLAGS(PWM_LED0_NODE)
|
||||
#else
|
||||
#error "Unsupported board: pwm-led0 devicetree alias is not defined"
|
||||
#define PWM_LABEL ""
|
||||
|
|
|
@ -14,16 +14,6 @@
|
|||
|
||||
#define SLEEP_TIME_MS 1
|
||||
|
||||
/*
|
||||
* Devicetree helper macro which gets the 'flags' cell from a 'gpios'
|
||||
* property, or returns 0 if the property has no 'flags' cell.
|
||||
*/
|
||||
|
||||
#define FLAGS_OR_ZERO(node) \
|
||||
COND_CODE_1(DT_PHA_HAS_CELL(node, gpios, flags), \
|
||||
(DT_GPIO_FLAGS(node, gpios)), \
|
||||
(0))
|
||||
|
||||
/*
|
||||
* Get button configuration from the devicetree sw0 alias.
|
||||
*
|
||||
|
@ -36,7 +26,7 @@
|
|||
#if DT_NODE_HAS_STATUS(SW0_NODE, okay)
|
||||
#define SW0_GPIO_LABEL DT_GPIO_LABEL(SW0_NODE, gpios)
|
||||
#define SW0_GPIO_PIN DT_GPIO_PIN(SW0_NODE, gpios)
|
||||
#define SW0_GPIO_FLAGS (GPIO_INPUT | FLAGS_OR_ZERO(SW0_NODE))
|
||||
#define SW0_GPIO_FLAGS (GPIO_INPUT | DT_GPIO_FLAGS(SW0_NODE, gpios))
|
||||
#else
|
||||
#error "Unsupported board: sw0 devicetree alias is not defined"
|
||||
#define SW0_GPIO_LABEL ""
|
||||
|
@ -107,7 +97,7 @@ void main(void)
|
|||
#if DT_NODE_HAS_STATUS(LED0_NODE, okay) && DT_NODE_HAS_PROP(LED0_NODE, gpios)
|
||||
#define LED0_GPIO_LABEL DT_GPIO_LABEL(LED0_NODE, gpios)
|
||||
#define LED0_GPIO_PIN DT_GPIO_PIN(LED0_NODE, gpios)
|
||||
#define LED0_GPIO_FLAGS (GPIO_OUTPUT | FLAGS_OR_ZERO(LED0_NODE))
|
||||
#define LED0_GPIO_FLAGS (GPIO_OUTPUT | DT_GPIO_FLAGS(LED0_NODE, gpios))
|
||||
#endif
|
||||
|
||||
#ifdef LED0_GPIO_LABEL
|
||||
|
|
|
@ -16,20 +16,10 @@
|
|||
|
||||
#define PWM_LED0_NODE DT_ALIAS(pwm_led0)
|
||||
|
||||
/*
|
||||
* Devicetree helper macro which gets the 'flags' cell from the node's
|
||||
* pwms property, or returns 0 if the property has no 'flags' cell.
|
||||
*/
|
||||
|
||||
#define FLAGS_OR_ZERO(node) \
|
||||
COND_CODE_1(DT_PHA_HAS_CELL(node, pwms, flags), \
|
||||
(DT_PWMS_FLAGS(node)), \
|
||||
(0))
|
||||
|
||||
#if DT_NODE_HAS_STATUS(PWM_LED0_NODE, okay)
|
||||
#define PWM_LABEL DT_PWMS_LABEL(PWM_LED0_NODE)
|
||||
#define PWM_CHANNEL DT_PWMS_CHANNEL(PWM_LED0_NODE)
|
||||
#define PWM_FLAGS FLAGS_OR_ZERO(PWM_LED0_NODE)
|
||||
#define PWM_FLAGS DT_PWMS_FLAGS(PWM_LED0_NODE)
|
||||
#else
|
||||
#error "Unsupported board: pwm-led0 devicetree alias is not defined"
|
||||
#define PWM_LABEL ""
|
||||
|
|
|
@ -13,16 +13,6 @@
|
|||
#include <device.h>
|
||||
#include <drivers/pwm.h>
|
||||
|
||||
/*
|
||||
* Devicetree helper macro which gets the 'flags' cell from a 'pwms'
|
||||
* property, or returns 0 if the property has no 'flags' cell.
|
||||
*/
|
||||
|
||||
#define FLAGS_OR_ZERO(node) \
|
||||
COND_CODE_1(DT_PHA_HAS_CELL(node, pwms, flags), \
|
||||
(DT_PWMS_FLAGS(node)), \
|
||||
(0))
|
||||
|
||||
/*
|
||||
* Extract devicetree configuration.
|
||||
*/
|
||||
|
@ -34,7 +24,7 @@
|
|||
#if DT_NODE_HAS_STATUS(RED_NODE, okay)
|
||||
#define RED_LABEL DT_PWMS_LABEL(RED_NODE)
|
||||
#define RED_CHANNEL DT_PWMS_CHANNEL(RED_NODE)
|
||||
#define RED_FLAGS FLAGS_OR_ZERO(RED_NODE)
|
||||
#define RED_FLAGS DT_PWMS_FLAGS(RED_NODE)
|
||||
#else
|
||||
#error "Unsupported board: red-pwm-led devicetree alias is not defined"
|
||||
#define RED_LABEL ""
|
||||
|
@ -45,7 +35,7 @@
|
|||
#if DT_NODE_HAS_STATUS(GREEN_NODE, okay)
|
||||
#define GREEN_LABEL DT_PWMS_LABEL(GREEN_NODE)
|
||||
#define GREEN_CHANNEL DT_PWMS_CHANNEL(GREEN_NODE)
|
||||
#define GREEN_FLAGS FLAGS_OR_ZERO(GREEN_NODE)
|
||||
#define GREEN_FLAGS DT_PWMS_FLAGS(GREEN_NODE)
|
||||
#else
|
||||
#error "Unsupported board: green-pwm-led devicetree alias is not defined"
|
||||
#define GREEN_LABEL ""
|
||||
|
@ -56,7 +46,7 @@
|
|||
#if DT_NODE_HAS_STATUS(BLUE_NODE, okay)
|
||||
#define BLUE_LABEL DT_PWMS_LABEL(BLUE_NODE)
|
||||
#define BLUE_CHANNEL DT_PWMS_CHANNEL(BLUE_NODE)
|
||||
#define BLUE_FLAGS FLAGS_OR_ZERO(BLUE_NODE)
|
||||
#define BLUE_FLAGS DT_PWMS_FLAGS(BLUE_NODE)
|
||||
#else
|
||||
#error "Unsupported board: blue-pwm-led devicetree alias is not defined"
|
||||
#define BLUE_LABEL ""
|
||||
|
|
|
@ -20,16 +20,6 @@
|
|||
#define LED0_NODE DT_ALIAS(led0)
|
||||
#define LED1_NODE DT_ALIAS(led1)
|
||||
|
||||
/*
|
||||
* Devicetree helper macro which gets the 'flags' cell from a 'gpios'
|
||||
* property, or returns 0 if the property has no 'flags' cell.
|
||||
*/
|
||||
|
||||
#define FLAGS_OR_ZERO(node) \
|
||||
COND_CODE_1(DT_PHA_HAS_CELL(node, gpios, flags), \
|
||||
(DT_GPIO_FLAGS(node, gpios)), \
|
||||
(0))
|
||||
|
||||
struct printk_data_t {
|
||||
void *fifo_reserved; /* 1st word reserved for use by fifo */
|
||||
uint32_t led;
|
||||
|
@ -90,7 +80,7 @@ void blink0(void)
|
|||
.gpio_dev_name = DT_GPIO_LABEL(LED0_NODE, gpios),
|
||||
.gpio_pin_name = DT_LABEL(LED0_NODE),
|
||||
.gpio_pin = DT_GPIO_PIN(LED0_NODE, gpios),
|
||||
.gpio_flags = GPIO_OUTPUT | FLAGS_OR_ZERO(LED0_NODE),
|
||||
.gpio_flags = GPIO_OUTPUT | DT_GPIO_FLAGS(LED0_NODE, gpios),
|
||||
#else
|
||||
#error "Unsupported board: led0 devicetree alias is not defined"
|
||||
#endif
|
||||
|
@ -106,7 +96,7 @@ void blink1(void)
|
|||
.gpio_dev_name = DT_GPIO_LABEL(LED1_NODE, gpios),
|
||||
.gpio_pin_name = DT_LABEL(LED1_NODE),
|
||||
.gpio_pin = DT_GPIO_PIN(LED1_NODE, gpios),
|
||||
.gpio_flags = GPIO_OUTPUT | FLAGS_OR_ZERO(LED1_NODE),
|
||||
.gpio_flags = GPIO_OUTPUT | DT_GPIO_FLAGS(LED1_NODE, gpios),
|
||||
#else
|
||||
#error "Unsupported board: led1 devicetree alias is not defined"
|
||||
#endif
|
||||
|
|
|
@ -17,17 +17,12 @@
|
|||
#define LOG_LEVEL LOG_LEVEL_DBG
|
||||
LOG_MODULE_REGISTER(main);
|
||||
|
||||
#define FLAGS_OR_ZERO(node) \
|
||||
COND_CODE_1(DT_PHA_HAS_CELL(node, gpios, flags), \
|
||||
(DT_GPIO_FLAGS(node, gpios)), \
|
||||
(0))
|
||||
|
||||
#define SW0_NODE DT_ALIAS(sw0)
|
||||
|
||||
#if DT_NODE_HAS_STATUS(SW0_NODE, okay)
|
||||
#define PORT0 DT_GPIO_LABEL(SW0_NODE, gpios)
|
||||
#define PIN0 DT_GPIO_PIN(SW0_NODE, gpios)
|
||||
#define PIN0_FLAGS FLAGS_OR_ZERO(SW0_NODE)
|
||||
#define PIN0_FLAGS DT_GPIO_FLAGS(SW0_NODE, gpios)
|
||||
#else
|
||||
#error "Unsupported board: sw0 devicetree alias is not defined"
|
||||
#define PORT0 ""
|
||||
|
@ -40,7 +35,7 @@ LOG_MODULE_REGISTER(main);
|
|||
#if DT_NODE_HAS_STATUS(SW1_NODE, okay)
|
||||
#define PORT1 DT_GPIO_LABEL(SW1_NODE, gpios)
|
||||
#define PIN1 DT_GPIO_PIN(SW1_NODE, gpios)
|
||||
#define PIN1_FLAGS FLAGS_OR_ZERO(SW1_NODE)
|
||||
#define PIN1_FLAGS DT_GPIO_FLAGS(SW1_NODE, gpios)
|
||||
#endif
|
||||
|
||||
#define SW2_NODE DT_ALIAS(sw2)
|
||||
|
@ -48,7 +43,7 @@ LOG_MODULE_REGISTER(main);
|
|||
#if DT_NODE_HAS_STATUS(SW2_NODE, okay)
|
||||
#define PORT2 DT_GPIO_LABEL(SW2_NODE, gpios)
|
||||
#define PIN2 DT_GPIO_PIN(SW2_NODE, gpios)
|
||||
#define PIN2_FLAGS FLAGS_OR_ZERO(SW2_NODE)
|
||||
#define PIN2_FLAGS DT_GPIO_FLAGS(SW2_NODE, gpios)
|
||||
#endif
|
||||
|
||||
#define SW3_NODE DT_ALIAS(sw3)
|
||||
|
@ -56,7 +51,7 @@ LOG_MODULE_REGISTER(main);
|
|||
#if DT_NODE_HAS_STATUS(SW3_NODE, okay)
|
||||
#define PORT3 DT_GPIO_LABEL(SW3_NODE, gpios)
|
||||
#define PIN3 DT_GPIO_PIN(SW3_NODE, gpios)
|
||||
#define PIN3_FLAGS FLAGS_OR_ZERO(SW3_NODE)
|
||||
#define PIN3_FLAGS DT_GPIO_FLAGS(SW3_NODE, gpios)
|
||||
#endif
|
||||
|
||||
/* Event FIFO */
|
||||
|
|
|
@ -14,17 +14,12 @@
|
|||
#define LOG_LEVEL LOG_LEVEL_DBG
|
||||
LOG_MODULE_REGISTER(main);
|
||||
|
||||
#define FLAGS_OR_ZERO(node) \
|
||||
COND_CODE_1(DT_PHA_HAS_CELL(node, gpios, flags), \
|
||||
(DT_GPIO_FLAGS(node, gpios)), \
|
||||
(0))
|
||||
|
||||
#define SW0_NODE DT_ALIAS(sw0)
|
||||
|
||||
#if DT_NODE_HAS_STATUS(SW0_NODE, okay)
|
||||
#define PORT0 DT_GPIO_LABEL(SW0_NODE, gpios)
|
||||
#define PIN0 DT_GPIO_PIN(SW0_NODE, gpios)
|
||||
#define PIN0_FLAGS FLAGS_OR_ZERO(SW0_NODE)
|
||||
#define PIN0_FLAGS DT_GPIO_FLAGS(SW0_NODE, gpios)
|
||||
#else
|
||||
#error "Unsupported board: sw0 devicetree alias is not defined"
|
||||
#define PORT0 ""
|
||||
|
@ -37,7 +32,7 @@ LOG_MODULE_REGISTER(main);
|
|||
#if DT_NODE_HAS_STATUS(SW1_NODE, okay)
|
||||
#define PORT1 DT_GPIO_LABEL(SW1_NODE, gpios)
|
||||
#define PIN1 DT_GPIO_PIN(SW1_NODE, gpios)
|
||||
#define PIN1_FLAGS FLAGS_OR_ZERO(SW1_NODE)
|
||||
#define PIN1_FLAGS DT_GPIO_FLAGS(SW1_NODE, gpios)
|
||||
#endif
|
||||
|
||||
#define SW2_NODE DT_ALIAS(sw2)
|
||||
|
@ -45,7 +40,7 @@ LOG_MODULE_REGISTER(main);
|
|||
#if DT_NODE_HAS_STATUS(SW2_NODE, okay)
|
||||
#define PORT2 DT_GPIO_LABEL(SW2_NODE, gpios)
|
||||
#define PIN2 DT_GPIO_PIN(SW2_NODE, gpios)
|
||||
#define PIN2_FLAGS FLAGS_OR_ZERO(SW2_NODE)
|
||||
#define PIN2_FLAGS DT_GPIO_FLAGS(SW2_NODE, gpios)
|
||||
#endif
|
||||
|
||||
#define SW3_NODE DT_ALIAS(sw3)
|
||||
|
@ -53,7 +48,7 @@ LOG_MODULE_REGISTER(main);
|
|||
#if DT_NODE_HAS_STATUS(SW3_NODE, okay)
|
||||
#define PORT3 DT_GPIO_LABEL(SW3_NODE, gpios)
|
||||
#define PIN3 DT_GPIO_PIN(SW3_NODE, gpios)
|
||||
#define PIN3_FLAGS FLAGS_OR_ZERO(SW3_NODE)
|
||||
#define PIN3_FLAGS DT_GPIO_FLAGS(SW3_NODE, gpios)
|
||||
#endif
|
||||
|
||||
#define LED0_NODE DT_ALIAS(led0)
|
||||
|
|
Loading…
Reference in a new issue