Re: [PATCH v2] leds: gpio: Set max brightness to 1
From: Dylan Van Assche
Date: Tue Dec 29 2020 - 13:13:03 EST
Hi!
Thanks for the feedback!
Indeed, this can be even more simplified with your suggestion.
I will send a new version of the patch soon.
Happy holidays!
Kind regards,
Dylan Van Assche
On Tue, 2020-12-29 at 17:04 +0100, Pavel Machek wrote:
> Hi!
>
> > GPIO LEDs only know 2 states: ON or OFF and do not have PWM
> > capabilities.
> > However, the max brightness is reported as 255.
> >
> > This patch sets the max brightness value of a GPIO controlled LED
> > to 1.
> >
> > Tested on my PinePhone 1.2.
> >
> > Signed-off-by: Dylan Van Assche <me@xxxxxxxxxxxxxxxxx>
> > ---
> > v2 drops an obsolete change in include/linux/leds.h
>
> I thought that one looked odd.
>
> > +++ b/drivers/leds/leds-gpio.c
> > @@ -96,7 +96,8 @@ static int create_gpio_led(const struct gpio_led
> > *template,
> > } else {
> > state = (template->default_state ==
> > LEDS_GPIO_DEFSTATE_ON);
> > }
> > - led_dat->cdev.brightness = state ? LED_FULL : LED_OFF;
> > + led_dat->cdev.brightness = state ? LED_ON : LED_OFF;
> > + led_dat->cdev.max_brightness = LED_ON;
>
> Would simpler version work:
>
> > + led_dat->cdev.brightness = state;
> > + led_dat->cdev.max_brightness = 1;
>
> ? Easier to understand... I'd prefer that version unless it causes
> warnings or something.
>
> Pavel