linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pm2301-charger: Fix suspend/resume
@ 2013-04-13 11:20 Lars-Peter Clausen
  2013-04-17  2:02 ` Anton Vorontsov
  0 siblings, 1 reply; 2+ messages in thread
From: Lars-Peter Clausen @ 2013-04-13 11:20 UTC (permalink / raw)
  To: Anton Vorontsov, David Woodhouse
  Cc: Lee Jones, linux-kernel, Lars-Peter Clausen

The pm2301-charger driver implements runtime pm and at the same time uses the
legacy pm callbacks for suspend and resume. This does not work since the I2C
core wont look at the legacy pm callbacks if a driver has the 'pm' field set.
This patch fixes it by moving over to dev_pm_ops for suspend/resume as well.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/power/pm2301_charger.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/power/pm2301_charger.c b/drivers/power/pm2301_charger.c
index 618c46d..f123f3c 100644
--- a/drivers/power/pm2301_charger.c
+++ b/drivers/power/pm2301_charger.c
@@ -26,6 +26,7 @@
 #include <linux/pm2301_charger.h>
 #include <linux/gpio.h>
 #include <linux/pm_runtime.h>
+#include <linux/pm.h>
 
 #include "pm2301_charger.h"
 
@@ -906,8 +907,13 @@ static struct pm2xxx_irq pm2xxx_charger_irq[] = {
 	{"PM2XXX_IRQ_INT", pm2xxx_irq_int},
 };
 
-static int pm2xxx_wall_charger_resume(struct i2c_client *i2c_client)
+#ifdef CONFIG_PM
+
+#ifdef CONFIG_PM_SLEEP
+
+static int pm2xxx_wall_charger_resume(struct device *dev)
 {
+	struct i2c_client *i2c_client = to_i2c_client(dev);
 	struct pm2xxx_charger *pm2;
 
 	pm2 =  (struct pm2xxx_charger *)i2c_get_clientdata(i2c_client);
@@ -921,9 +927,9 @@ static int pm2xxx_wall_charger_resume(struct i2c_client *i2c_client)
 	return 0;
 }
 
-static int pm2xxx_wall_charger_suspend(struct i2c_client *i2c_client,
-	pm_message_t state)
+static int pm2xxx_wall_charger_suspend(struct device *dev)
 {
+	struct i2c_client *i2c_client = to_i2c_client(dev);
 	struct pm2xxx_charger *pm2;
 
 	pm2 =  (struct pm2xxx_charger *)i2c_get_clientdata(i2c_client);
@@ -939,7 +945,10 @@ static int pm2xxx_wall_charger_suspend(struct i2c_client *i2c_client,
 	return 0;
 }
 
-#ifdef CONFIG_PM
+#endif
+
+#ifdef CONFIG_PM_RUNTIME
+
 static int  pm2xxx_runtime_suspend(struct device *dev)
 {
 	struct i2c_client *pm2xxx_i2c_client = to_i2c_client(dev);
@@ -977,9 +986,12 @@ static int  pm2xxx_runtime_resume(struct device *dev)
 	return ret;
 }
 
+#endif
+
 static const struct dev_pm_ops pm2xxx_pm_ops = {
-	.runtime_suspend = pm2xxx_runtime_suspend,
-	.runtime_resume = pm2xxx_runtime_resume,
+	SET_SYSTEM_SLEEP_PM_OPS(pm2xxx_wall_charger_suspend,
+		pm2xxx_wall_charger_resume)
+	SET_RUNTIME_PM_OPS(pm2xxx_runtime_suspend, pm2xxx_runtime_resume, NULL)
 };
 #define  PM2XXX_PM_OPS (&pm2xxx_pm_ops)
 #else
@@ -1234,8 +1246,6 @@ MODULE_DEVICE_TABLE(i2c, pm2xxx_id);
 static struct i2c_driver pm2xxx_charger_driver = {
 	.probe = pm2xxx_wall_charger_probe,
 	.remove = pm2xxx_wall_charger_remove,
-	.suspend = pm2xxx_wall_charger_suspend,
-	.resume = pm2xxx_wall_charger_resume,
 	.driver = {
 		.name = "pm2xxx-wall_charger",
 		.owner = THIS_MODULE,
-- 
1.8.0


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

* Re: [PATCH] pm2301-charger: Fix suspend/resume
  2013-04-13 11:20 [PATCH] pm2301-charger: Fix suspend/resume Lars-Peter Clausen
@ 2013-04-17  2:02 ` Anton Vorontsov
  0 siblings, 0 replies; 2+ messages in thread
From: Anton Vorontsov @ 2013-04-17  2:02 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: David Woodhouse, Lee Jones, linux-kernel

On Sat, Apr 13, 2013 at 01:20:07PM +0200, Lars-Peter Clausen wrote:
> The pm2301-charger driver implements runtime pm and at the same time uses the
> legacy pm callbacks for suspend and resume. This does not work since the I2C
> core wont look at the legacy pm callbacks if a driver has the 'pm' field set.
> This patch fixes it by moving over to dev_pm_ops for suspend/resume as well.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---

Applied, thanks a lot!

Anton

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

end of thread, other threads:[~2013-04-17  2:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-13 11:20 [PATCH] pm2301-charger: Fix suspend/resume Lars-Peter Clausen
2013-04-17  2:02 ` Anton Vorontsov

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