Skip to content

Commit 4190663

Browse files
Eddie Jamespavelmachek
authored andcommitted
leds: leds-core: Implement the retain-state-shutdown property
Read the retain-state-shutdown device tree property to set the existing LED_RETAIN_AT_SHUTDOWN flag. Then check the flag when unregistering, and if set, don't set the brightness to OFF. This is useful for systems that want to keep the HW state of the LED across reboots. Signed-off-by: Eddie James <[email protected]> Signed-off-by: Pavel Machek <[email protected]>
1 parent 5d823d6 commit 4190663

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/leds/led-class.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,15 @@ int led_classdev_register_ext(struct device *parent,
350350
if (ret < 0)
351351
return ret;
352352

353-
if (init_data->fwnode)
353+
if (init_data->fwnode) {
354354
fwnode_property_read_string(init_data->fwnode,
355355
"linux,default-trigger",
356356
&led_cdev->default_trigger);
357+
358+
if (fwnode_property_present(init_data->fwnode,
359+
"retain-state-shutdown"))
360+
led_cdev->flags |= LED_RETAIN_AT_SHUTDOWN;
361+
}
357362
} else {
358363
proposed_name = led_cdev->name;
359364
}
@@ -444,7 +449,8 @@ void led_classdev_unregister(struct led_classdev *led_cdev)
444449
/* Stop blinking */
445450
led_stop_software_blink(led_cdev);
446451

447-
led_set_brightness(led_cdev, LED_OFF);
452+
if (!(led_cdev->flags & LED_RETAIN_AT_SHUTDOWN))
453+
led_set_brightness(led_cdev, LED_OFF);
448454

449455
flush_work(&led_cdev->set_brightness_work);
450456

0 commit comments

Comments
 (0)