]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
leds: leds-pwm: implement PWM inversion
authorRussell King <rmk+kernel@arm.linux.org.uk>
Sun, 6 Apr 2014 22:20:18 +0000 (15:20 -0700)
committerBryan Wu <cooloney@gmail.com>
Thu, 8 May 2014 06:28:07 +0000 (14:28 +0800)
Some PWM outputs are wired such that the LED they're controlling is
connected to supply rather than ground.  These PWMs may not support
output inversion, or when they do, disabling the PWM may set the
PWM output low, causing a "brightness" value of zero to turn the LED
fully on.

The platform data for this driver already indicates that this was
thought about, and we have the "active_low" property there already.
However, the implementation for this is missing.

Add the trivial implementation for this feature.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
drivers/leds/leds-pwm.c

index 35c1c5f144dc87fe58a925dda04618871319b27b..8bd225df14dea3f88f505abaaa7d03d1ef0c9629 100644 (file)
@@ -69,6 +69,10 @@ static void led_pwm_set(struct led_classdev *led_cdev,
 
        duty *= brightness;
        do_div(duty, max);
+
+       if (led_dat->active_low)
+               duty = led_dat->period - duty;
+
        led_dat->duty = duty;
 
        if (led_dat->can_sleep)