Skip to content

Commit 6b17080

Browse files
larsclausenenomsg
authored andcommitted
pm2301-charger: Fix suspend/resume
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> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
1 parent f2c6a5f commit 6b17080

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

‎drivers/power/pm2301_charger.c‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/pm2301_charger.h>
2727
#include <linux/gpio.h>
2828
#include <linux/pm_runtime.h>
29+
#include <linux/pm.h>
2930

3031
#include "pm2301_charger.h"
3132

@@ -906,8 +907,13 @@ static struct pm2xxx_irq pm2xxx_charger_irq[] = {
906907
{"PM2XXX_IRQ_INT", pm2xxx_irq_int},
907908
};
908909

909-
static int pm2xxx_wall_charger_resume(struct i2c_client *i2c_client)
910+
#ifdef CONFIG_PM
911+
912+
#ifdef CONFIG_PM_SLEEP
913+
914+
static int pm2xxx_wall_charger_resume(struct device *dev)
910915
{
916+
struct i2c_client *i2c_client = to_i2c_client(dev);
911917
struct pm2xxx_charger *pm2;
912918

913919
pm2 = (struct pm2xxx_charger *)i2c_get_clientdata(i2c_client);
@@ -921,9 +927,9 @@ static int pm2xxx_wall_charger_resume(struct i2c_client *i2c_client)
921927
return 0;
922928
}
923929

924-
static int pm2xxx_wall_charger_suspend(struct i2c_client *i2c_client,
925-
pm_message_t state)
930+
static int pm2xxx_wall_charger_suspend(struct device *dev)
926931
{
932+
struct i2c_client *i2c_client = to_i2c_client(dev);
927933
struct pm2xxx_charger *pm2;
928934

929935
pm2 = (struct pm2xxx_charger *)i2c_get_clientdata(i2c_client);
@@ -939,7 +945,10 @@ static int pm2xxx_wall_charger_suspend(struct i2c_client *i2c_client,
939945
return 0;
940946
}
941947

942-
#ifdef CONFIG_PM
948+
#endif
949+
950+
#ifdef CONFIG_PM_RUNTIME
951+
943952
static int pm2xxx_runtime_suspend(struct device *dev)
944953
{
945954
struct i2c_client *pm2xxx_i2c_client = to_i2c_client(dev);
@@ -977,9 +986,12 @@ static int pm2xxx_runtime_resume(struct device *dev)
977986
return ret;
978987
}
979988

989+
#endif
990+
980991
static const struct dev_pm_ops pm2xxx_pm_ops = {
981-
.runtime_suspend = pm2xxx_runtime_suspend,
982-
.runtime_resume = pm2xxx_runtime_resume,
992+
SET_SYSTEM_SLEEP_PM_OPS(pm2xxx_wall_charger_suspend,
993+
pm2xxx_wall_charger_resume)
994+
SET_RUNTIME_PM_OPS(pm2xxx_runtime_suspend, pm2xxx_runtime_resume, NULL)
983995
};
984996
#define PM2XXX_PM_OPS (&pm2xxx_pm_ops)
985997
#else
@@ -1234,8 +1246,6 @@ MODULE_DEVICE_TABLE(i2c, pm2xxx_id);
12341246
static struct i2c_driver pm2xxx_charger_driver = {
12351247
.probe = pm2xxx_wall_charger_probe,
12361248
.remove = pm2xxx_wall_charger_remove,
1237-
.suspend = pm2xxx_wall_charger_suspend,
1238-
.resume = pm2xxx_wall_charger_resume,
12391249
.driver = {
12401250
.name = "pm2xxx-wall_charger",
12411251
.owner = THIS_MODULE,

0 commit comments

Comments
 (0)