From 67b4055d5795d15049daa990570926be12d25852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Cab=C3=A9?= Date: Mon, 9 Jun 2025 21:38:14 +0200 Subject: [PATCH] drivers: gpio: rpi_pico: fix call to gpio_set_dir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensure gpio_set_dir() receives GPIO_IN or GPIO_OUT by mapping INIT_{LOW,HIGH} flags explicitly, instead of passing raw bitmasks. Signed-off-by: Benjamin Cabé --- drivers/gpio/gpio_rpi_pico.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio_rpi_pico.c b/drivers/gpio/gpio_rpi_pico.c index 7c556b9e45e..029cda4e6f4 100644 --- a/drivers/gpio/gpio_rpi_pico.c +++ b/drivers/gpio/gpio_rpi_pico.c @@ -161,11 +161,13 @@ static int gpio_rpi_configure(const struct device *dev, if (flags & GPIO_LINE_OPEN_DRAIN) { data->open_drain_mask |= BIT(pin); gpio_put(pin + offset, 0); - gpio_set_dir(pin + offset, flags & GPIO_OUTPUT_INIT_LOW); + gpio_set_dir(pin + offset, + (flags & GPIO_OUTPUT_INIT_LOW) ? GPIO_OUT : GPIO_IN); } else { data->open_drain_mask &= ~(BIT(pin)); gpio_put(pin + offset, 1); - gpio_set_dir(pin + offset, flags & GPIO_OUTPUT_INIT_HIGH); + gpio_set_dir(pin + offset, + (flags & GPIO_OUTPUT_INIT_HIGH) ? GPIO_OUT : GPIO_IN); } } else { data->single_ended_mask &= ~(BIT(pin));