[PATCH] led: gpio: handle GPIO_ACTIVE_LOW flag properly

FUKAUMI Naoki naoki at radxa.com
Thu Aug 29 05:43:43 CEST 2024


sorry, this patch seems to be wrong.
I'll check it again.

Best regards,

--
FUKAUMI Naoki
Radxa Computer (Shenzhen) Co., Ltd.

On 8/28/24 21:15, FUKAUMI Naoki wrote:
> invert gpio state if GPIO_ACTIVE_LOW is specified in dts.
> 
> Signed-off-by: FUKAUMI Naoki <naoki at radxa.com>
> ---
>   drivers/led/led_gpio.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/led/led_gpio.c b/drivers/led/led_gpio.c
> index ce22fb49f2a..54aa84e0726 100644
> --- a/drivers/led/led_gpio.c
> +++ b/drivers/led/led_gpio.c
> @@ -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;
>   }
>   


More information about the U-Boot mailing list