leds: call led_pwm_set() in leds-pwm to enforce default LED_OFF
authorMarkus Hofstaetter <markus.hofstaetter@ait.ac.at>
Wed, 11 Nov 2015 11:40:29 +0000 (12:40 +0100)
committerJacek Anaszewski <j.anaszewski@samsung.com>
Mon, 4 Jan 2016 08:57:36 +0000 (09:57 +0100)
Some PWMs are disabled by default or the default pin setting
does not match the LED_OFF state (e.g., active-low leds).
Hence, the driver may end up reporting 0 brightness, but
the leds are actually on using full brightness, because
it never enforces its default configuration.
So enforce it by calling led_pwm_set() after successfully
registering the device.

Tested on a Phytec phyFLEX i.MX6Q board based on kernel
v3.19.5.

Signed-off-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at>
Tested-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
drivers/leds/leds-pwm.c

index bc501930b54bab87d94b57fe69e1bde1a828a07b..410ff04682452582b35f652e238a9b4c82bc6dab 100644 (file)
@@ -124,6 +124,7 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
        ret = led_classdev_register(dev, &led_data->cdev);
        if (ret == 0) {
                priv->num_leds++;
+               led_pwm_set(&led_data->cdev, led_data->cdev.brightness);
        } else {
                dev_err(dev, "failed to register PWM led for %s: %d\n",
                        led->name, ret);