Re: [PATCH] leds-pwm: the startup brightness can be specified

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jelle,

Thanks for the patch.

On 02/09/2017 03:00 PM, Jelle Martijn Kok wrote:
> Upto now the leds-pwm are either on or off at startup. This allows the
> dts to specify the startup brightness
> 
> Signed-off-by: Jelle Martijn Kok <jmkok@xxxxxxxxx>
> ---
>  drivers/leds/leds-pwm.c  | 5 ++++-
>  include/linux/leds_pwm.h | 1 +
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
> index a9145aa..4799f36 100644
> --- a/drivers/leds/leds-pwm.c
> +++ b/drivers/leds/leds-pwm.c
> @@ -97,7 +97,7 @@ static int led_pwm_add(struct device *dev, struct
> led_pwm_priv *priv,
>      led_data->active_low = led->active_low;
>      led_data->cdev.name = led->name;
>      led_data->cdev.default_trigger = led->default_trigger;
> -    led_data->cdev.brightness = LED_OFF;
> +    led_data->cdev.brightness = led->default_brightness;
>      led_data->cdev.max_brightness = led->max_brightness;
>      led_data->cdev.flags = LED_CORE_SUSPENDRESUME;
>  @@ -159,6 +159,9 @@ static int led_pwm_create_of(struct device *dev,
> struct led_pwm_priv *priv)
>          led.active_low = of_property_read_bool(child, "active-low");
>          of_property_read_u32(child, "max-brightness",
>                       &led.max_brightness);
> +        led.default_brightness = LED_OFF;
> +        of_property_read_u32(child, "brightness",
> +                     &led.default_brightness);

At first you would have to submit a patch for
Documentation/devicetree/bindings/leds/common.txt that would add
brightness property. The question is whether it is really needed?
You can set brightness from userspace via sysfs API.

By the way, I have a question to DT maintainers: is DT a proper
place for defining this type of configuration that can be set via
userspace scripts? Shouldn't DT describe only hardware properties and
constraints resulting from board configuration?

>           ret = led_pwm_add(dev, priv, &led, child);
>          if (ret) {
> diff --git a/include/linux/leds_pwm.h b/include/linux/leds_pwm.h
> index a65e964..7e70438 100644
> --- a/include/linux/leds_pwm.h
> +++ b/include/linux/leds_pwm.h
> @@ -11,6 +11,7 @@ struct led_pwm {
>      u8         active_low;
>      unsigned     max_brightness;
>      unsigned    pwm_period_ns;
> +    unsigned     default_brightness;
>  };
>   struct led_pwm_platform_data {

-- 
Best regards,
Jacek Anaszewski



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux