Linux-LEDs Archive on
 help / color / Atom feed
From: Kai-Heng Feng <>
	Kai-Heng Feng <>,
	Dan Murphy <>, (open list:LED SUBSYSTEM), (open list)
Subject: [PATCH] leds: core: Use blocking op for system suspend
Date: Wed,  1 Jul 2020 17:35:40 +0800
Message-ID: <> (raw)

Sometimes LED won't be turned off by LED_CORE_SUSPENDRESUME flag upon
system suspend.

led_set_brightness_nopm() uses schedule_work() to set LED brightness.
However, there's no guarantee that the scheduled work gets executed
because no one calls flush_scheduled_work().

As flush_scheduled_work() may affect other drivers' suspend routines,
take a more contained approach which uses blocking op to make sure the
LED gets turned off.

Signed-off-by: Kai-Heng Feng <>
 drivers/leds/led-core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index f1f718dbe0f8..9a5bfcd7a704 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -269,6 +269,11 @@ EXPORT_SYMBOL_GPL(led_set_brightness);
 void led_set_brightness_nopm(struct led_classdev *led_cdev,
 			      enum led_brightness value)
+	if (led_cdev->flags & LED_SUSPENDED &&
+	    !__led_set_brightness_blocking(led_cdev, value))
+		return;
 	/* Use brightness_set op if available, it is guaranteed not to sleep */
 	if (!__led_set_brightness(led_cdev, value))

             reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-01  9:35 Kai-Heng Feng [this message]
2020-07-01 21:28 ` Jacek Anaszewski
2020-07-02  5:20   ` Kai-Heng Feng

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:

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

  git send-email \ \ \ \ \ \ \ \ \

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

Linux-LEDs Archive on

Archives are clonable:
	git clone --mirror linux-leds/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-leds linux-leds/ \
	public-inbox-index linux-leds

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone