Skip to content

Commit 06bd942

Browse files
committed
misc: ft8xx: convert to gpio_dt_spec
Convert SPI usage to `struct gpio_dt_spec`. Signed-off-by: Kumar Gala <[email protected]>
1 parent a2ffdaf commit 06bd942

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

drivers/misc/ft8xx/ft8xx_drv.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ static const struct spi_dt_spec spi = SPI_DT_SPEC_INST_GET(0,
2323
0);
2424

2525
/* GPIO int line */
26-
#define IRQ_PIN DT_GPIO_PIN(NODE_ID, irq_gpios)
27-
static const struct device *int_ft8xx_dev;
26+
static const struct gpio_dt_spec irq_gpio = GPIO_DT_SPEC_INST_GET(0, irq_gpios);
2827

2928
static struct gpio_callback irq_cb_data;
3029

@@ -64,25 +63,23 @@ int ft8xx_drv_init(void)
6463
/* TODO: Verify if such entry in DTS is present.
6564
* If not, use polling mode.
6665
*/
67-
int_ft8xx_dev = device_get_binding(DT_GPIO_LABEL(NODE_ID, irq_gpios));
68-
if (!int_ft8xx_dev) {
66+
if (!device_is_ready(irq_gpio.port)) {
67+
LOG_ERR("GPIO device %s is not ready", irq_gpio.port->name);
6968
return -ENODEV;
7069
}
7170

72-
ret = gpio_pin_configure(int_ft8xx_dev, IRQ_PIN,
73-
GPIO_INPUT | DT_GPIO_FLAGS(NODE_ID, irq_gpios));
71+
ret = gpio_pin_configure_dt(&irq_gpio, GPIO_INPUT);
7472
if (ret != 0) {
7573
return ret;
7674
}
7775

78-
ret = gpio_pin_interrupt_configure(int_ft8xx_dev, IRQ_PIN,
79-
GPIO_INT_EDGE_TO_ACTIVE);
76+
ret = gpio_pin_interrupt_configure_dt(&irq_gpio, GPIO_INT_EDGE_TO_ACTIVE);
8077
if (ret != 0) {
8178
return ret;
8279
}
8380

84-
gpio_init_callback(&irq_cb_data, ft8xx_drv_irq_triggered, BIT(IRQ_PIN));
85-
gpio_add_callback(int_ft8xx_dev, &irq_cb_data);
81+
gpio_init_callback(&irq_cb_data, ft8xx_drv_irq_triggered, BIT(irq_gpio.pin));
82+
gpio_add_callback(irq_gpio.port, &irq_cb_data);
8683

8784
return 0;
8885
}

0 commit comments

Comments
 (0)