Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-4.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds

Pull LED fixes from Jacek Anaszewski:

- Fix brightness setting upon hardware blinking enabled

- Handle suspend/resume in heartbeat trigger

* tag 'for-4.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds:
leds: handle suspend/resume in heartbeat trigger
leds: core: Fix brightness setting upon hardware blinking enabled

+51 -16
+2 -2
Documentation/leds/leds-class.txt
··· 74 74 however, it is better to use the API function led_blink_set(), as it 75 75 will check and implement software fallback if necessary. 76 76 77 - To turn off blinking again, use the API function led_brightness_set() 78 - as that will not just set the LED brightness but also stop any software 77 + To turn off blinking, use the API function led_brightness_set() 78 + with brightness value LED_OFF, which should stop any software 79 79 timers that may have been required for blinking. 80 80 81 81 The blink_set() function should choose a user friendly blinking value
+6 -3
drivers/leds/led-core.c
··· 53 53 54 54 if (!led_cdev->blink_delay_on || !led_cdev->blink_delay_off) { 55 55 led_set_brightness_nosleep(led_cdev, LED_OFF); 56 + led_cdev->flags &= ~LED_BLINK_SW; 56 57 return; 57 58 } 58 59 59 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 62 return; 62 63 } 63 64 ··· 152 151 return; 153 152 } 154 153 154 + led_cdev->flags |= LED_BLINK_SW; 155 155 mod_timer(&led_cdev->blink_timer, jiffies + 1); 156 156 } 157 157 ··· 221 219 del_timer_sync(&led_cdev->blink_timer); 222 220 led_cdev->blink_delay_on = 0; 223 221 led_cdev->blink_delay_off = 0; 222 + led_cdev->flags &= ~LED_BLINK_SW; 224 223 } 225 224 EXPORT_SYMBOL_GPL(led_stop_software_blink); 226 225 ··· 229 226 enum led_brightness brightness) 230 227 { 231 228 /* 232 - * In case blinking is on delay brightness setting 229 + * If software blink is active, delay brightness setting 233 230 * until the next timer tick. 234 231 */ 235 - if (led_cdev->blink_delay_on || led_cdev->blink_delay_off) { 232 + if (led_cdev->flags & LED_BLINK_SW) { 236 233 /* 237 234 * If we need to disable soft blinking delegate this to the 238 235 * work queue task to avoid problems in case we are called
+31
drivers/leds/trigger/ledtrig-heartbeat.c
··· 19 19 #include <linux/sched.h> 20 20 #include <linux/leds.h> 21 21 #include <linux/reboot.h> 22 + #include <linux/suspend.h> 22 23 #include "../leds.h" 23 24 24 25 static int panic_heartbeats; ··· 155 154 .deactivate = heartbeat_trig_deactivate, 156 155 }; 157 156 157 + static int heartbeat_pm_notifier(struct notifier_block *nb, 158 + unsigned long pm_event, void *unused) 159 + { 160 + int rc; 161 + 162 + switch (pm_event) { 163 + case PM_SUSPEND_PREPARE: 164 + case PM_HIBERNATION_PREPARE: 165 + case PM_RESTORE_PREPARE: 166 + led_trigger_unregister(&heartbeat_led_trigger); 167 + break; 168 + case PM_POST_SUSPEND: 169 + case PM_POST_HIBERNATION: 170 + case PM_POST_RESTORE: 171 + rc = led_trigger_register(&heartbeat_led_trigger); 172 + if (rc) 173 + pr_err("could not re-register heartbeat trigger\n"); 174 + break; 175 + default: 176 + break; 177 + } 178 + return NOTIFY_DONE; 179 + } 180 + 158 181 static int heartbeat_reboot_notifier(struct notifier_block *nb, 159 182 unsigned long code, void *unused) 160 183 { ··· 192 167 panic_heartbeats = 1; 193 168 return NOTIFY_DONE; 194 169 } 170 + 171 + static struct notifier_block heartbeat_pm_nb = { 172 + .notifier_call = heartbeat_pm_notifier, 173 + }; 195 174 196 175 static struct notifier_block heartbeat_reboot_nb = { 197 176 .notifier_call = heartbeat_reboot_notifier, ··· 213 184 atomic_notifier_chain_register(&panic_notifier_list, 214 185 &heartbeat_panic_nb); 215 186 register_reboot_notifier(&heartbeat_reboot_nb); 187 + register_pm_notifier(&heartbeat_pm_nb); 216 188 } 217 189 return rc; 218 190 } 219 191 220 192 static void __exit heartbeat_trig_exit(void) 221 193 { 194 + unregister_pm_notifier(&heartbeat_pm_nb); 222 195 unregister_reboot_notifier(&heartbeat_reboot_nb); 223 196 atomic_notifier_chain_unregister(&panic_notifier_list, 224 197 &heartbeat_panic_nb);
+12 -11
include/linux/leds.h
··· 42 42 #define LED_UNREGISTERING (1 << 1) 43 43 /* Upper 16 bits reflect control information */ 44 44 #define LED_CORE_SUSPENDRESUME (1 << 16) 45 - #define LED_BLINK_ONESHOT (1 << 17) 46 - #define LED_BLINK_ONESHOT_STOP (1 << 18) 47 - #define LED_BLINK_INVERT (1 << 19) 48 - #define LED_BLINK_BRIGHTNESS_CHANGE (1 << 20) 49 - #define LED_BLINK_DISABLE (1 << 21) 50 - #define LED_SYSFS_DISABLE (1 << 22) 51 - #define LED_DEV_CAP_FLASH (1 << 23) 52 - #define LED_HW_PLUGGABLE (1 << 24) 53 - #define LED_PANIC_INDICATOR (1 << 25) 45 + #define LED_BLINK_SW (1 << 17) 46 + #define LED_BLINK_ONESHOT (1 << 18) 47 + #define LED_BLINK_ONESHOT_STOP (1 << 19) 48 + #define LED_BLINK_INVERT (1 << 20) 49 + #define LED_BLINK_BRIGHTNESS_CHANGE (1 << 21) 50 + #define LED_BLINK_DISABLE (1 << 22) 51 + #define LED_SYSFS_DISABLE (1 << 23) 52 + #define LED_DEV_CAP_FLASH (1 << 24) 53 + #define LED_HW_PLUGGABLE (1 << 25) 54 + #define LED_PANIC_INDICATOR (1 << 26) 54 55 55 56 /* Set LED brightness level 56 57 * Must not sleep. Use brightness_set_blocking for drivers ··· 73 72 * and if both are zero then a sensible default should be chosen. 74 73 * The call should adjust the timings in that case and if it can't 75 74 * match the values specified exactly. 76 - * Deactivate blinking again when the brightness is set to a fixed 77 - * value via the brightness_set() callback. 75 + * Deactivate blinking again when the brightness is set to LED_OFF 76 + * via the brightness_set() callback. 78 77 */ 79 78 int (*blink_set)(struct led_classdev *led_cdev, 80 79 unsigned long *delay_on,