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);
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 {
--
2.1.4