diff options
author | Alexander Shiyan <shc_work@mail.ru> | 2014-01-31 22:36:30 -0800 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2014-02-27 09:56:55 -0800 |
commit | 677d13f27e9735d3f2e8d7b8b54cbd820630638a (patch) | |
tree | 19c46845d883c6e5bdc623bb95256e1e075e97a0 /drivers/leds | |
parent | 02e9e11e24c30828a26daad04f9f165906b62efd (diff) | |
download | linux-exynos-677d13f27e9735d3f2e8d7b8b54cbd820630638a.tar.gz linux-exynos-677d13f27e9735d3f2e8d7b8b54cbd820630638a.tar.bz2 linux-exynos-677d13f27e9735d3f2e8d7b8b54cbd820630638a.zip |
leds: leds-mc13783: Use proper "max_brightness" value fo LEDs
Instead of using maximum value of 255 and shift it to appropriate
LED duty cycle, this patch introduce a helper to use proper maximum
value for each LED.
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/leds-mc13783.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/leds/leds-mc13783.c b/drivers/leds/leds-mc13783.c index 491309a9551c..b1686b441205 100644 --- a/drivers/leds/leds-mc13783.c +++ b/drivers/leds/leds-mc13783.c @@ -45,11 +45,21 @@ struct mc13xxx_leds { struct mc13xxx_led led[0]; }; +static unsigned int mc13xxx_max_brightness(int id) +{ + if (id >= MC13783_LED_MD && id <= MC13783_LED_KP) + return 0x0f; + else if (id >= MC13783_LED_R1 && id <= MC13783_LED_B3) + return 0x1f; + + return 0x3f; +} + static void mc13xxx_led_work(struct work_struct *work) { struct mc13xxx_led *led = container_of(work, struct mc13xxx_led, work); struct mc13xxx_leds *leds = led->leds; - unsigned int reg, mask, value, bank, off, shift; + unsigned int reg, bank, off, shift; switch (led->id) { case MC13783_LED_MD: @@ -57,8 +67,6 @@ static void mc13xxx_led_work(struct work_struct *work) case MC13783_LED_KP: reg = 2; shift = 9 + (led->id - MC13783_LED_MD) * 4; - mask = 0x0f; - value = led->new_brightness >> 4; break; case MC13783_LED_R1: case MC13783_LED_G1: @@ -73,16 +81,12 @@ static void mc13xxx_led_work(struct work_struct *work) bank = off / 3; reg = 3 + bank; shift = (off - bank * 3) * 5 + 6; - value = led->new_brightness >> 3; - mask = 0x1f; break; case MC13892_LED_MD: case MC13892_LED_AD: case MC13892_LED_KP: reg = (led->id - MC13892_LED_MD) / 2; shift = 3 + (led->id - MC13892_LED_MD) * 12; - mask = 0x3f; - value = led->new_brightness >> 2; break; case MC13892_LED_R: case MC13892_LED_G: @@ -91,22 +95,19 @@ static void mc13xxx_led_work(struct work_struct *work) bank = off / 2; reg = 2 + bank; shift = (off - bank * 2) * 12 + 3; - value = led->new_brightness >> 2; - mask = 0x3f; break; case MC34708_LED_R: case MC34708_LED_G: reg = 0; shift = 3 + (led->id - MC34708_LED_R) * 12; - value = led->new_brightness >> 2; - mask = 0x3f; break; default: BUG(); } mc13xxx_reg_rmw(leds->master, leds->devtype->ledctrl_base + reg, - mask << shift, value << shift); + mc13xxx_max_brightness(led->id) << shift, + led->new_brightness << shift); } static void mc13xxx_led_set(struct led_classdev *led_cdev, @@ -186,7 +187,7 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev) leds->led[i].cdev.default_trigger = trig; leds->led[i].cdev.flags = LED_CORE_SUSPENDRESUME; leds->led[i].cdev.brightness_set = mc13xxx_led_set; - leds->led[i].cdev.brightness = LED_OFF; + leds->led[i].cdev.max_brightness = mc13xxx_max_brightness(id); INIT_WORK(&leds->led[i].work, mc13xxx_led_work); |