Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1719780 > unrolled thread

[PATCH 2/2] leds: gpio: Allow LED to retain state at shutdown

Started byAndrew Jeffery <andrew@aj.id.au>
First post2017-08-25 08:40 +0200
Last post2017-08-28 02:10 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/2] leds: gpio: Allow LED to retain state at shutdown Andrew Jeffery <andrew@aj.id.au> - 2017-08-25 08:40 +0200
    Re: [PATCH 2/2] leds: gpio: Allow LED to retain state at shutdown Pavel Machek <pavel@ucw.cz> - 2017-08-25 09:40 +0200
      Re: [PATCH 2/2] leds: gpio: Allow LED to retain state at shutdown Jacek Anaszewski <jacek.anaszewski@gmail.com> - 2017-08-27 13:10 +0200
        Re: [PATCH 2/2] leds: gpio: Allow LED to retain state at shutdown Andrew Jeffery <andrew@aj.id.au> - 2017-08-28 02:10 +0200

#1719780 — [PATCH 2/2] leds: gpio: Allow LED to retain state at shutdown

FromAndrew Jeffery <andrew@aj.id.au>
Date2017-08-25 08:40 +0200
Subject[PATCH 2/2] leds: gpio: Allow LED to retain state at shutdown
Message-ID<uigrE-xp-29@gated-at.bofh.it>
In some systems, such as BMCs, we want to retain the state of LEDs
across a reboot of the BMC whilst the host remains up.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
 drivers/leds/leds-gpio.c | 7 ++++++-
 include/linux/leds.h     | 2 ++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index e753ba93ba1e..764c31301f90 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -134,6 +134,8 @@ static int create_gpio_led(const struct gpio_led *template,
 		led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
 	if (template->panic_indicator)
 		led_dat->cdev.flags |= LED_PANIC_INDICATOR;
+	if (template->retain_state_shutdown)
+		led_dat->cdev.flags |= LED_RETAIN_AT_SHUTDOWN;
 
 	ret = gpiod_direction_output(led_dat->gpiod, state);
 	if (ret < 0)
@@ -205,6 +207,8 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
 
 		if (fwnode_property_present(child, "retain-state-suspended"))
 			led.retain_state_suspended = 1;
+		if (fwnode_property_present(child, "retain-state-shutdown"))
+			led.retain_state_shutdown = 1;
 		if (fwnode_property_present(child, "panic-indicator"))
 			led.panic_indicator = 1;
 
@@ -267,7 +271,8 @@ static void gpio_led_shutdown(struct platform_device *pdev)
 	for (i = 0; i < priv->num_leds; i++) {
 		struct gpio_led_data *led = &priv->leds[i];
 
-		gpio_led_set(&led->cdev, LED_OFF);
+		if (!(led->cdev.flags & LED_RETAIN_AT_SHUTDOWN))
+			gpio_led_set(&led->cdev, LED_OFF);
 	}
 }
 
diff --git a/include/linux/leds.h b/include/linux/leds.h
index 64c56d454f7d..bf6db4fe895b 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -49,6 +49,7 @@ struct led_classdev {
 #define LED_HW_PLUGGABLE	(1 << 19)
 #define LED_PANIC_INDICATOR	(1 << 20)
 #define LED_BRIGHT_HW_CHANGED	(1 << 21)
+#define LED_RETAIN_AT_SHUTDOWN	(1 << 22)
 
 	/* set_brightness_work / blink_timer flags, atomic, private. */
 	unsigned long		work_flags;
@@ -392,6 +393,7 @@ struct gpio_led {
 	unsigned	retain_state_suspended : 1;
 	unsigned	panic_indicator : 1;
 	unsigned	default_state : 2;
+	unsigned	retain_state_shutdown : 1;
 	/* default_state should be one of LEDS_GPIO_DEFSTATE_(ON|OFF|KEEP) */
 	struct gpio_desc *gpiod;
 };
-- 
2.11.0

[toc] | [next] | [standalone]


#1719800

FromPavel Machek <pavel@ucw.cz>
Date2017-08-25 09:40 +0200
Message-ID<uihnI-17Y-11@gated-at.bofh.it>
In reply to#1719780

[Multipart message — attachments visible in raw view] — view raw

On Fri 2017-08-25 16:05:03, Andrew Jeffery wrote:
> In some systems, such as BMCs, we want to retain the state of LEDs
> across a reboot of the BMC whilst the host remains up.

I'd spell out what BMC is...

Otherwise series looks good.

Acked-by: Pavel Machek <pavel@ucw.cz>


								Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[toc] | [prev] | [next] | [standalone]


#1720799

FromJacek Anaszewski <jacek.anaszewski@gmail.com>
Date2017-08-27 13:10 +0200
Message-ID<uj3C1-6Qj-1@gated-at.bofh.it>
In reply to#1719800
Hi Andrew,

On 08/25/2017 09:32 AM, Pavel Machek wrote:
> On Fri 2017-08-25 16:05:03, Andrew Jeffery wrote:
>> In some systems, such as BMCs, we want to retain the state of LEDs
>> across a reboot of the BMC whilst the host remains up.
> 
> I'd spell out what BMC is...

I agree with Pavel. Please give the expansion of the acronym
in both DT patch and the driver commit message.

> 
> Otherwise series looks good.
> 
> Acked-by: Pavel Machek <pavel@ucw.cz>

-- 
Best regards,
Jacek Anaszewski

[toc] | [prev] | [next] | [standalone]


#1720945

FromAndrew Jeffery <andrew@aj.id.au>
Date2017-08-28 02:10 +0200
Message-ID<ujfMS-6Gs-7@gated-at.bofh.it>
In reply to#1720799

[Multipart message — attachments visible in raw view] — view raw

Hi Jacek, Pavel

On Sun, 2017-08-27 at 13:01 +0200, Jacek Anaszewski wrote:
> Hi Andrew,
> 
> On 08/25/2017 09:32 AM, Pavel Machek wrote:
> > On Fri 2017-08-25 16:05:03, Andrew Jeffery wrote:
> > > In some systems, such as BMCs, we want to retain the state of LEDs
> > > across a reboot of the BMC whilst the host remains up.
> > 
> > I'd spell out what BMC is...
> 
> I agree with Pavel. Please give the expansion of the acronym
> in both DT patch and the driver commit message.

No worries, will reword and resend.

Thanks for the review.

Andrew

> 
> > 
> > Otherwise series looks good.
> > 
> > Acked-by: Pavel Machek <pavel@ucw.cz>
> 
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web