led: gpio: handle GPIO_ACTIVE_LOW flag properly
PATCH 1/1 led: gpio: handle GPIO_ACTIVE_LOW flag properly
invert gpio state if GPIO_ACTIVE_LOW is specified in dts.
Signed-off-by FUKAUMI Naoki <[email protected]>
--- drivers/led/led_gpio.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/led/led_gpio.c +5 -0
@@ -25,6 +25,8 @@ static int gpio_led_set_state(struct udevice *dev, enum led_state_t state)switch (state) {case LEDST_OFF :case LEDST_ON : +if (priv->gpio.flags &GPIOD_ACTIVE_LOW ) + state = !state;break ;case LEDST_TOGGLE : ret =dm_gpio_get_value (&priv->gpio);
@@ -50,6 +52,9 @@ static enum led_state_t gpio_led_get_state(struct udevice *dev)if (ret <0 )return ret; +if (priv->gpio.flags &GPIOD_ACTIVE_LOW ) + ret = !ret; +return ret ?LEDST_ON :LEDST_OFF ; }
Signature · 1 line
2.43.0
sorry, this patch seems to be wrong.
I'll check it again.
Best regards,
--
FUKAUMI Naoki
Radxa Computer (Shenzhen) Co., Ltd.
Quoted 30 lines · FUKAUMI Naoki
invert gpio state if
GPIO_ACTIVE_LOWis specified in dts.Signed-off-by FUKAUMI Naoki <[email protected]>--- drivers/led/led_gpio.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/led/led_gpio.c +5
-0@@ -25,6 +25,8 @@ static int gpio_led_set_state(struct udevice *dev, enum led_state_t state)switch (state) {case LEDST_OFF :case LEDST_ON : +if (priv->gpio.flags &GPIOD_ACTIVE_LOW ) + state = !state;break ;case LEDST_TOGGLE : ret =dm_gpio_get_value (&priv->gpio);@@ -50,6 +52,9 @@ static enum led_state_t gpio_led_get_state(struct udevice *dev)if (ret <0 )return ret; +if (priv->gpio.flags &GPIOD_ACTIVE_LOW ) + ret = !ret; +return ret ?LEDST_ON :LEDST_OFF ; }