linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers/power/wakeirq: Call device_init_wakeup from dev_pm_set_wake_irq
@ 2015-09-01 14:53 Daniel Lezcano
  2015-09-01 23:58 ` Rafael J. Wysocki
  2015-09-14 13:43 ` Sudeep Holla
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Lezcano @ 2015-09-01 14:53 UTC (permalink / raw)
  To: rjw
  Cc: zhaoyang.huang, sudeep.holla, Len Brown, Pavel Machek,
	Greg Kroah-Hartman, open list:SUSPEND TO RAM, open list

The function dev_pm_set_wake_irq is typically called after device_init_wakeup.

Instead of summing a couple of call, let's call device_init_wakeup directly
from dev_pm_set_wake_irq / dev_pm_clear_wake_irq.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/base/power/wakeirq.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c
index eb6e674..287a021 100644
--- a/drivers/base/power/wakeirq.c
+++ b/drivers/base/power/wakeirq.c
@@ -60,8 +60,7 @@ static int dev_pm_attach_wake_irq(struct device *dev, int irq,
  *
  * Attach a device IO interrupt as a wake IRQ. The wake IRQ gets
  * automatically configured for wake-up from suspend  based
- * on the device specific sysfs wakeup entry. Typically called
- * during driver probe after calling device_init_wakeup().
+ * on the device specific sysfs wakeup entry.
  */
 int dev_pm_set_wake_irq(struct device *dev, int irq)
 {
@@ -75,9 +74,13 @@ int dev_pm_set_wake_irq(struct device *dev, int irq)
 	wirq->dev = dev;
 	wirq->irq = irq;
 
+	device_init_wakeup(dev, true);
+
 	err = dev_pm_attach_wake_irq(dev, irq, wirq);
-	if (err)
+	if (!err) {
 		kfree(wirq);
+		device_init_wakeup(dev, false);
+	}
 
 	return err;
 }
@@ -102,6 +105,7 @@ void dev_pm_clear_wake_irq(struct device *dev)
 	if (!wirq)
 		return;
 
+	device_init_wakeup(dev, false);
 	spin_lock_irqsave(&dev->power.lock, flags);
 	device_wakeup_detach_irq(dev);
 	dev->power.wakeirq = NULL;
-- 
1.9.1

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

* Re: [PATCH] drivers/power/wakeirq: Call device_init_wakeup from dev_pm_set_wake_irq
  2015-09-01 14:53 [PATCH] drivers/power/wakeirq: Call device_init_wakeup from dev_pm_set_wake_irq Daniel Lezcano
@ 2015-09-01 23:58 ` Rafael J. Wysocki
  2015-09-14 13:43 ` Sudeep Holla
  1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2015-09-01 23:58 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: zhaoyang.huang, sudeep.holla, Len Brown, Pavel Machek,
	Greg Kroah-Hartman, open list:SUSPEND TO RAM, open list

On Tuesday, September 01, 2015 04:53:37 PM Daniel Lezcano wrote:
> The function dev_pm_set_wake_irq is typically called after device_init_wakeup.
> 
> Instead of summing a couple of call, let's call device_init_wakeup directly
> from dev_pm_set_wake_irq / dev_pm_clear_wake_irq.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

If there are any existing callers of dev_pm_attach_wake_irq(), you need to
update them too I think.  Also, what if someone wants to use
device_set_wakeup_capable() rather than device_init_wakeup()?


> ---
>  drivers/base/power/wakeirq.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c
> index eb6e674..287a021 100644
> --- a/drivers/base/power/wakeirq.c
> +++ b/drivers/base/power/wakeirq.c
> @@ -60,8 +60,7 @@ static int dev_pm_attach_wake_irq(struct device *dev, int irq,
>   *
>   * Attach a device IO interrupt as a wake IRQ. The wake IRQ gets
>   * automatically configured for wake-up from suspend  based
> - * on the device specific sysfs wakeup entry. Typically called
> - * during driver probe after calling device_init_wakeup().
> + * on the device specific sysfs wakeup entry.
>   */
>  int dev_pm_set_wake_irq(struct device *dev, int irq)
>  {
> @@ -75,9 +74,13 @@ int dev_pm_set_wake_irq(struct device *dev, int irq)
>  	wirq->dev = dev;
>  	wirq->irq = irq;
>  
> +	device_init_wakeup(dev, true);
> +
>  	err = dev_pm_attach_wake_irq(dev, irq, wirq);
> -	if (err)
> +	if (!err) {
>  		kfree(wirq);
> +		device_init_wakeup(dev, false);
> +	}
>  
>  	return err;
>  }
> @@ -102,6 +105,7 @@ void dev_pm_clear_wake_irq(struct device *dev)
>  	if (!wirq)
>  		return;
>  
> +	device_init_wakeup(dev, false);
>  	spin_lock_irqsave(&dev->power.lock, flags);
>  	device_wakeup_detach_irq(dev);
>  	dev->power.wakeirq = NULL;
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

* Re: [PATCH] drivers/power/wakeirq: Call device_init_wakeup from dev_pm_set_wake_irq
  2015-09-01 14:53 [PATCH] drivers/power/wakeirq: Call device_init_wakeup from dev_pm_set_wake_irq Daniel Lezcano
  2015-09-01 23:58 ` Rafael J. Wysocki
@ 2015-09-14 13:43 ` Sudeep Holla
  1 sibling, 0 replies; 3+ messages in thread
From: Sudeep Holla @ 2015-09-14 13:43 UTC (permalink / raw)
  To: Daniel Lezcano, rjw@rjwysocki.net
  Cc: Sudeep Holla, zhaoyang.huang@linaro.org, Len Brown, Pavel Machek,
	Greg Kroah-Hartman, open list:SUSPEND TO RAM, open list,
	tony@atomide.com

(+Tony in case he has any inputs)

Hi Daniel,

On 01/09/15 15:53, Daniel Lezcano wrote:
> The function dev_pm_set_wake_irq is typically called after device_init_wakeup.
>
> Instead of summing a couple of call, let's call device_init_wakeup directly
> from dev_pm_set_wake_irq / dev_pm_clear_wake_irq.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>   drivers/base/power/wakeirq.c | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c
> index eb6e674..287a021 100644
> --- a/drivers/base/power/wakeirq.c
> +++ b/drivers/base/power/wakeirq.c
> @@ -60,8 +60,7 @@ static int dev_pm_attach_wake_irq(struct device *dev, int irq,
>    *
>    * Attach a device IO interrupt as a wake IRQ. The wake IRQ gets
>    * automatically configured for wake-up from suspend  based
> - * on the device specific sysfs wakeup entry. Typically called
> - * during driver probe after calling device_init_wakeup().
> + * on the device specific sysfs wakeup entry.
>    */
>   int dev_pm_set_wake_irq(struct device *dev, int irq)
>   {
> @@ -75,9 +74,13 @@ int dev_pm_set_wake_irq(struct device *dev, int irq)
>   	wirq->dev = dev;
>   	wirq->irq = irq;
>
> +	device_init_wakeup(dev, true);
> +

IMO we can move this to dev_pm_attach_wake_irq, so that both
dev_pm_set_dedicated_wake_irq and dev_pm_set_wake_irq are handled at one
place.

Also the first user(drivers/i2c/i2c-core.c) of the API is added in
v4.3-rc1. So you need to fix that as Rafael pointed out initially.

Regards,
Sudeep

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

end of thread, other threads:[~2015-09-14 13:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-01 14:53 [PATCH] drivers/power/wakeirq: Call device_init_wakeup from dev_pm_set_wake_irq Daniel Lezcano
2015-09-01 23:58 ` Rafael J. Wysocki
2015-09-14 13:43 ` Sudeep Holla

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