Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH] leds: use QoS to control LED suspend behavior from userspace
@ 2018-01-29 19:49 0v3rdr0n3
  2018-01-30  8:28 ` Pavel Machek
  2018-02-01 10:52 ` kbuild test robot
  0 siblings, 2 replies; 10+ messages in thread
From: 0v3rdr0n3 @ 2018-01-29 19:49 UTC (permalink / raw)
  To: linux-pm, linux-leds; +Cc: samorris

From: Samuel Morris <samorris@lexmark.com>

Signed-off-by: Samuel Morris <samorris@lexmark.com>
---
 drivers/leds/led-class.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index f2b0a80..9e9e265 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -20,6 +20,7 @@
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/timer.h>
+#include <linux/pm_qos.h>
 #include <uapi/linux/uleds.h>
 #include "leds.h"
 
@@ -196,6 +197,11 @@ static int led_suspend(struct device *dev)
 {
 	struct led_classdev *led_cdev = dev_get_drvdata(dev);
 
+	if(dev_pm_qos_flags(dev, PM_QOS_FLAG_NO_POWER_OFF) ==
+			PM_QOS_FLAGS_ALL) {
+		return 0;
+	}
+
 	if (led_cdev->flags & LED_CORE_SUSPENDRESUME)
 		led_classdev_suspend(led_cdev);
 
@@ -206,6 +212,11 @@ static int led_resume(struct device *dev)
 {
 	struct led_classdev *led_cdev = dev_get_drvdata(dev);
 
+	if(dev_pm_qos_flags(dev, PM_QOS_FLAG_NO_POWER_OFF) ==
+			PM_QOS_FLAGS_ALL) {
+		return 0;
+	}
+
 	if (led_cdev->flags & LED_CORE_SUSPENDRESUME)
 		led_classdev_resume(led_cdev);
 
@@ -287,6 +298,18 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
 	list_add_tail(&led_cdev->node, &leds_list);
 	up_write(&leds_list_lock);
 
+	/* Attempt to let userspace take over the policy. */
+	ret = dev_pm_qos_expose_flags(led_cdev->dev,
+			PM_QOS_FLAG_NO_POWER_OFF);
+	if (ret < 0) {
+		dev_warn(led_cdev->dev, "failed to expose pm_qos_no_poweroff\n");
+		return 0;
+	}
+
+	ret = dev_pm_qos_update_flags(led_cdev->dev,
+			PM_QOS_FLAG_NO_POWER_OFF,
+			0);
+
 	if (!led_cdev->max_brightness)
 		led_cdev->max_brightness = LED_FULL;
 
-- 
1.9.3

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

end of thread, other threads:[~2018-02-05 15:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-29 19:49 [PATCH] leds: use QoS to control LED suspend behavior from userspace 0v3rdr0n3
2018-01-30  8:28 ` Pavel Machek
2018-01-30 14:55   ` Samuel Morris
2018-02-01 21:29     ` Jacek Anaszewski
2018-02-02 15:40       ` Samuel Morris
2018-02-02 20:52         ` Jacek Anaszewski
2018-02-02 22:19           ` Samuel Morris
2018-02-04 20:01             ` Jacek Anaszewski
2018-02-05 15:22               ` Samuel Morris
2018-02-01 10:52 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox