aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorTony Makkiel <tony.makkiel@daqri.com>2016-05-18 12:22:45 -0400
committerJacek Anaszewski <j.anaszewski@samsung.com>2016-06-08 05:47:06 -0400
commit7cfe749fad5158247282f2fee30773fd454029ab (patch)
tree0d3ad9db7f04c077e7ce80daf10be1de4477fc80 /drivers/leds
parentaf8c34ce6ae32addda3788d54a7e340cad22516b (diff)
leds: core: Fix brightness setting upon hardware blinking enabled
Commit 76931edd54f8 ("leds: fix brightness changing when software blinking is active") changed the semantics of led_set_brightness() which according to the documentation should disable blinking upon any brightness setting. Moreover it made it different for soft blink case, where it was possible to change blink brightness, and for hardware blink case, where setting any brightness greater than 0 was ignored. While the change itself is against the documentation claims, it was driven also by the fact that timer trigger remained active after turning blinking off. Fixing that would have required major refactoring in the led-core, led-class, and led-triggers because of cyclic dependencies. Finally, it has been decided that allowing for brightness change during blinking is beneficial as it can be accomplished without disturbing blink rhythm. The change in brightness setting semantics will not affect existing LED class drivers that implement blink_set op thanks to the LED_BLINK_SW flag introduced by this patch. The flag state will be from now on checked in led_set_brightness() which will allow to distinguish between software and hardware blink mode. In the latter case the control will be passed directly to the drivers which apply their semantics on brightness set, which is disable the blinking in case of most such drivers. New drivers will apply new semantics and just change the brightness while hardware blinking is on, if possible. The issue was smuggled by subsequent LED core improvements, which modified the code that originally introduced the problem. Fixes: f1e80c07416a ("leds: core: Add two new LED_BLINK_ flags") Signed-off-by: Tony Makkiel <tony.makkiel@daqri.com> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/led-core.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index 3495d5d6547f..3bce44893021 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -53,11 +53,12 @@ static void led_timer_function(unsigned long data)
53 53
54 if (!led_cdev->blink_delay_on || !led_cdev->blink_delay_off) { 54 if (!led_cdev->blink_delay_on || !led_cdev->blink_delay_off) {
55 led_set_brightness_nosleep(led_cdev, LED_OFF); 55 led_set_brightness_nosleep(led_cdev, LED_OFF);
56 led_cdev->flags &= ~LED_BLINK_SW;
56 return; 57 return;
57 } 58 }
58 59
59 if (led_cdev->flags & LED_BLINK_ONESHOT_STOP) { 60 if (led_cdev->flags & LED_BLINK_ONESHOT_STOP) {
60 led_cdev->flags &= ~LED_BLINK_ONESHOT_STOP; 61 led_cdev->flags &= ~(LED_BLINK_ONESHOT_STOP | LED_BLINK_SW);
61 return; 62 return;
62 } 63 }
63 64
@@ -151,6 +152,7 @@ static void led_set_software_blink(struct led_classdev *led_cdev,
151 return; 152 return;
152 } 153 }
153 154
155 led_cdev->flags |= LED_BLINK_SW;
154 mod_timer(&led_cdev->blink_timer, jiffies + 1); 156 mod_timer(&led_cdev->blink_timer, jiffies + 1);
155} 157}
156 158
@@ -219,6 +221,7 @@ void led_stop_software_blink(struct led_classdev *led_cdev)
219 del_timer_sync(&led_cdev->blink_timer); 221 del_timer_sync(&led_cdev->blink_timer);
220 led_cdev->blink_delay_on = 0; 222 led_cdev->blink_delay_on = 0;
221 led_cdev->blink_delay_off = 0; 223 led_cdev->blink_delay_off = 0;
224 led_cdev->flags &= ~LED_BLINK_SW;
222} 225}
223EXPORT_SYMBOL_GPL(led_stop_software_blink); 226EXPORT_SYMBOL_GPL(led_stop_software_blink);
224 227
@@ -226,10 +229,10 @@ void led_set_brightness(struct led_classdev *led_cdev,
226 enum led_brightness brightness) 229 enum led_brightness brightness)
227{ 230{
228 /* 231 /*
229 * In case blinking is on delay brightness setting 232 * If software blink is active, delay brightness setting
230 * until the next timer tick. 233 * until the next timer tick.
231 */ 234 */
232 if (led_cdev->blink_delay_on || led_cdev->blink_delay_off) { 235 if (led_cdev->flags & LED_BLINK_SW) {
233 /* 236 /*
234 * If we need to disable soft blinking delegate this to the 237 * If we need to disable soft blinking delegate this to the
235 * work queue task to avoid problems in case we are called 238 * work queue task to avoid problems in case we are called