[PATCH 1/2] PM / Runtime: Fix error path for prepare

2013-11-15 Thread Ulf Hansson
If a device prepare callback for some reason would fail, the PM core
prevented the device from going inactive forever.

In this case, to reverse the pm_runtime_get_noresume() we invokes the
asyncronous pm_runtime_put(), thus restoring the usage count.

Cc: Kevin Hilman khil...@linaro.org
Cc: Alan Stern st...@rowland.harvard.edu
Signed-off-by: Ulf Hansson ulf.hans...@linaro.org
---
 drivers/base/power/main.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index ee039af..2a1b06a 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1350,6 +1350,9 @@ static int device_prepare(struct device *dev, 
pm_message_t state)
 
device_unlock(dev);
 
+   if (error)
+   pm_runtime_put(dev);
+
return error;
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] PM / Runtime: Fix error path for prepare

2013-11-15 Thread Rafael J. Wysocki
On Friday, November 15, 2013 12:40:44 PM Ulf Hansson wrote:
 If a device prepare callback for some reason would fail, the PM core
 prevented the device from going inactive forever.
 
 In this case, to reverse the pm_runtime_get_noresume() we invokes the
 asyncronous pm_runtime_put(), thus restoring the usage count.
 
 Cc: Kevin Hilman khil...@linaro.org
 Cc: Alan Stern st...@rowland.harvard.edu
 Signed-off-by: Ulf Hansson ulf.hans...@linaro.org

This should be in linux-next already.

Thanks!

 ---
  drivers/base/power/main.c |3 +++
  1 file changed, 3 insertions(+)
 
 diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
 index ee039af..2a1b06a 100644
 --- a/drivers/base/power/main.c
 +++ b/drivers/base/power/main.c
 @@ -1350,6 +1350,9 @@ static int device_prepare(struct device *dev, 
 pm_message_t state)
  
   device_unlock(dev);
  
 + if (error)
 + pm_runtime_put(dev);
 +
   return error;
  }
  
 
-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html