linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] leds: core: Flush scheduled work for system suspend
@ 2020-07-02  5:45 Kai-Heng Feng
  2020-07-02 20:50 ` Jacek Anaszewski
  0 siblings, 1 reply; 3+ messages in thread
From: Kai-Heng Feng @ 2020-07-02  5:45 UTC (permalink / raw)
  To: jacek.anaszewski, pavel
  Cc: anthony.wong, Kai-Heng Feng, Dan Murphy, open list:LED SUBSYSTEM,
	open list

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 flushes the work.

So flush the scheduled work to make sure LED gets turned off.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
v2:
 - Use flush_work() instead.

 drivers/leds/led-class.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 3363a6551a70..cc3929f858b6 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -173,6 +173,7 @@ void led_classdev_suspend(struct led_classdev *led_cdev)
 {
 	led_cdev->flags |= LED_SUSPENDED;
 	led_set_brightness_nopm(led_cdev, 0);
+	flush_work(&led_cdev->set_brightness_work);
 }
 EXPORT_SYMBOL_GPL(led_classdev_suspend);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] leds: core: Flush scheduled work for system suspend
  2020-07-02  5:45 [PATCH v2] leds: core: Flush scheduled work for system suspend Kai-Heng Feng
@ 2020-07-02 20:50 ` Jacek Anaszewski
  2020-07-12  8:13   ` Pavel Machek
  0 siblings, 1 reply; 3+ messages in thread
From: Jacek Anaszewski @ 2020-07-02 20:50 UTC (permalink / raw)
  To: Kai-Heng Feng, pavel
  Cc: anthony.wong, Dan Murphy, open list:LED SUBSYSTEM, open list

Hi Kai-Heng,

Thank you for the update.

On 7/2/20 7:45 AM, Kai-Heng Feng wrote:
> 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 flushes the work.
> 
> So flush the scheduled work to make sure LED gets turned off.
> 
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
> v2:
>   - Use flush_work() instead.
> 
>   drivers/leds/led-class.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
> index 3363a6551a70..cc3929f858b6 100644
> --- a/drivers/leds/led-class.c
> +++ b/drivers/leds/led-class.c
> @@ -173,6 +173,7 @@ void led_classdev_suspend(struct led_classdev *led_cdev)
>   {
>   	led_cdev->flags |= LED_SUSPENDED;
>   	led_set_brightness_nopm(led_cdev, 0);
> +	flush_work(&led_cdev->set_brightness_work);
>   }
>   EXPORT_SYMBOL_GPL(led_classdev_suspend);
>   
> 

Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>

Pavel, this needs to go to stable as well, so let's add the tag:

Fixes: 81fe8e5b73e3 ("leds: core: Add led_set_brightness_nosleep{nopm} 
functions")

-- 
Best regards,
Jacek Anaszewski

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] leds: core: Flush scheduled work for system suspend
  2020-07-02 20:50 ` Jacek Anaszewski
@ 2020-07-12  8:13   ` Pavel Machek
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Machek @ 2020-07-12  8:13 UTC (permalink / raw)
  To: Jacek Anaszewski
  Cc: Kai-Heng Feng, anthony.wong, Dan Murphy, open list:LED SUBSYSTEM,
	open list

[-- Attachment #1: Type: text/plain, Size: 603 bytes --]

Hi!

> >  EXPORT_SYMBOL_GPL(led_classdev_suspend);
> >
> 
> Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
> 
> Pavel, this needs to go to stable as well, so let's add the tag:
> 
> Fixes: 81fe8e5b73e3 ("leds: core: Add led_set_brightness_nosleep{nopm}
> functions")

Applied, and I added the tag (thanks).

Documentation says stable is for "very bad" bugs, but ... stable
maintainers ignore documenation.

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-12  8:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-02  5:45 [PATCH v2] leds: core: Flush scheduled work for system suspend Kai-Heng Feng
2020-07-02 20:50 ` Jacek Anaszewski
2020-07-12  8:13   ` Pavel Machek

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).