Linux Power Management development
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: 0v3rdr0n3@gmail.com
Cc: linux-pm@vger.kernel.org, linux-leds@vger.kernel.org,
	samorris@lexmark.com
Subject: Re: [PATCH] leds: use QoS to control LED suspend behavior from userspace
Date: Tue, 30 Jan 2018 09:28:17 +0100	[thread overview]
Message-ID: <20180130082817.GA4136@amd> (raw)
In-Reply-To: <20180129194947.11071-1-0v3rdr0n3@gmail.com>

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

On Mon 2018-01-29 19:49:47, 0v3rdr0n3@gmail.com wrote:
> From: Samuel Morris <samorris@lexmark.com>
> 
> Signed-off-by: Samuel Morris <samorris@lexmark.com>

But... we'll really need description what this is supposed to do.

Because at least some LEDs (keyboard LEDs on PC) can't be powered on
during suspend.

Does this work for your LEDs? Do we need a way for userspace to tell
if LED supports it or not?

> @@ -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 (". No need for { } s.

> +
>  	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;
>  

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 --]

  reply	other threads:[~2018-01-30  8:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-29 19:49 [PATCH] leds: use QoS to control LED suspend behavior from userspace 0v3rdr0n3
2018-01-30  8:28 ` Pavel Machek [this message]
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

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=20180130082817.GA4136@amd \
    --to=pavel@ucw.cz \
    --cc=0v3rdr0n3@gmail.com \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=samorris@lexmark.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox