summaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-pwm.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2014-04-07 00:20:18 +0200
committerBryan Wu <cooloney@gmail.com>2014-05-08 08:28:07 +0200
commitd19a8a7078a9a8e254c030bcdb6732d26cbd6c16 (patch)
tree3951de02ae3cbb710876d0436f0b24f6e26d3ed8 /drivers/leds/leds-pwm.c
parentleds: leds-pwm: convert OF parsing code to use led_pwm_add() (diff)
downloadlinux-d19a8a7078a9a8e254c030bcdb6732d26cbd6c16.tar.xz
linux-d19a8a7078a9a8e254c030bcdb6732d26cbd6c16.zip
leds: leds-pwm: implement PWM inversion
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>
Diffstat (limited to 'drivers/leds/leds-pwm.c')
-rw-r--r--drivers/leds/leds-pwm.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index 35c1c5f144dc..8bd225df14de 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -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)