openbmc.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Eddie James <eajames@linux.ibm.com>
To: joel@jms.id.au
Cc: openbmc@lists.ozlabs.org
Subject: [PATCH linux dev-5.10 2/7] leds: leds-core: Implement the retain-state-shutdown property
Date: Thu, 16 Sep 2021 16:21:35 -0500	[thread overview]
Message-ID: <20210916212140.33915-3-eajames@linux.ibm.com> (raw)
In-Reply-To: <20210916212140.33915-1-eajames@linux.ibm.com>

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 <eajames@linux.ibm.com>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
---
 drivers/leds/led-class.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 4365c1cc4505..bc66f1035d06 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -351,10 +351,15 @@ int led_classdev_register_ext(struct device *parent,
 		if (ret < 0)
 			return ret;
 
-		if (init_data->fwnode)
+		if (init_data->fwnode) {
 			fwnode_property_read_string(init_data->fwnode,
 				"linux,default-trigger",
 				&led_cdev->default_trigger);
+
+			if (fwnode_property_present(init_data->fwnode,
+						    "retain-state-shutdown"))
+				led_cdev->flags |= LED_RETAIN_AT_SHUTDOWN;
+		}
 	} else {
 		proposed_name = led_cdev->name;
 	}
@@ -445,7 +450,8 @@ void led_classdev_unregister(struct led_classdev *led_cdev)
 	/* Stop blinking */
 	led_stop_software_blink(led_cdev);
 
-	led_set_brightness(led_cdev, LED_OFF);
+	if (!(led_cdev->flags & LED_RETAIN_AT_SHUTDOWN))
+		led_set_brightness(led_cdev, LED_OFF);
 
 	flush_work(&led_cdev->set_brightness_work);
 
-- 
2.27.0


  parent reply	other threads:[~2021-09-16 21:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-16 21:21 [PATCH linux dev-5.10 0/7] leds: Support retaining state for the PCA955x Eddie James
2021-09-16 21:21 ` [PATCH linux dev-5.10 1/7] dt-bindings: leds: Add retain-state-shutdown boolean Eddie James
2021-09-16 21:21 ` Eddie James [this message]
2021-09-16 21:21 ` [PATCH linux dev-5.10 3/7] leds: pca955x: Clean up code formatting Eddie James
2021-09-16 21:21 ` [PATCH linux dev-5.10 4/7] leds: pca955x: Add brightness_get function Eddie James
2021-09-16 21:21 ` [PATCH linux dev-5.10 5/7] leds: pca955x: Implement the default-state property Eddie James
2021-09-16 21:21 ` [PATCH linux dev-5.10 6/7] leds: pca955x: Let the core process the fwnode Eddie James
2021-09-16 21:21 ` [PATCH linux dev-5.10 7/7] leds: pca955x: Switch to i2c probe_new Eddie James
2021-09-22  2:21 ` [PATCH linux dev-5.10 0/7] leds: Support retaining state for the PCA955x Joel Stanley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210916212140.33915-3-eajames@linux.ibm.com \
    --to=eajames@linux.ibm.com \
    --cc=joel@jms.id.au \
    --cc=openbmc@lists.ozlabs.org \
    --subject='Re: [PATCH linux dev-5.10 2/7] leds: leds-core: Implement the retain-state-shutdown property' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).