misc: apds9802als: Fix suspend/resume
PATCH 1/4 misc: apds9802als: Fix suspend/resume
The apds9802als 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. Since both runtime pm and suspend/resume behave the same way this can easily be done using the UNIVERSAL_DEV_PM_OPS macro.
--- drivers/misc/apds9802als.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)
drivers/misc/apds9802als.c +4 -21
@@ -272,19 +272,8 @@ static int apds9802als_remove(struct i2c_client *client) }#ifdef CONFIG_PM -static int apds9802als_suspend (struct i2c_client *client,pm_message_t mesg) -{ -als_set_power_state (client, false); -return 0 ; -} - -static int apds9802als_resume (struct i2c_client *client) -{ -als_set_default_config (client); -return 0 ; -} -static int apds9802als_runtime_suspend (struct device *dev) +static int apds9802als_suspend (struct device *dev) {struct i2c_client *client =to_i2c_client (dev);
@@ -292,7 +281,7 @@ static int apds9802als_runtime_suspend(struct device *dev)return 0 ; } -static int apds9802als_runtime_resume (struct device *dev) +static int apds9802als_resume (struct device *dev) {struct i2c_client *client =to_i2c_client (dev);
@@ -300,16 +289,12 @@ static int apds9802als_runtime_resume(struct device *dev)return 0 ; } -static const struct dev_pm_ops apds9802als_pm_ops = { - .runtime_suspend = apds9802als_runtime_suspend, - .runtime_resume = apds9802als_runtime_resume, -}; +static UNIVERSAL_DEV_PM_OPS(apds9802als_pm_ops, apds9802als_suspend, + apds9802als_resume, NULL);#define APDS9802ALS_PM_OPS (&apds9802als_pm_ops)#else /* CONFIG_PM */ -#define apds9802als_suspend NULL -#define apds9802als_resume NULL#define APDS9802ALS_PM_OPS NULL#endif /* CONFIG_PM */
@@ -327,8 +312,6 @@ static struct i2c_driver apds9802als_driver = { }, .probe = apds9802als_probe, .remove = apds9802als_remove, - .suspend = apds9802als_suspend, - .resume = apds9802als_resume, .id_table = apds9802als_id, };
Signature · 1 line
1.8.0
PATCH 2/4 misc: fsa8480: Use dev_pm_ops
Use dev_pm_ops instead of the deprecated legacy suspend/resume callbacks.
--- drivers/misc/fsa9480.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/misc/fsa9480.c +11 -8
@@ -474,10 +474,11 @@ static int fsa9480_remove(struct i2c_client *client)return 0 ; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP -static int fsa9480_suspend (struct i2c_client *client,pm_message_t state) +static int fsa9480_suspend (struct device *dev) { +struct i2c_client *client =to_i2c_client (dev);struct fsa9480_usbsw *usbsw =i2c_get_clientdata (client);struct fsa9480_platform_data *pdata = usbsw->pdata;
@@ -490,8 +491,9 @@ static int fsa9480_suspend(struct i2c_client *client, pm_message_t state)return 0 ; } -static int fsa9480_resume (struct i2c_client *client) +static int fsa9480_resume (struct device *dev) { +struct i2c_client *client =to_i2c_client (dev);struct fsa9480_usbsw *usbsw =i2c_get_clientdata (client);int dev1, dev2;
@@ -515,12 +517,14 @@ static int fsa9480_resume(struct i2c_client *client)return 0 ; } +static SIMPLE_DEV_PM_OPS(fsa9480_pm_ops, fsa9480_suspend, fsa9480_resume); +#define FSA9480_PM_OPS (&fsa9480_pm_ops) +#else -#define fsa9480_suspend NULL -#define fsa9480_resume NULL +#define FSA9480_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static const struct i2c_device_id fsa9480_id[] = { {"fsa9480" ,0 },
@@ -531,11 +535,10 @@ MODULE_DEVICE_TABLE(i2c, fsa9480_id);static struct i2c_driver fsa9480_i2c_driver = { .driver = { .name ="fsa9480" , + .pm =FSA9480_PM_OPS , }, .probe = fsa9480_probe, .remove = fsa9480_remove, - .resume = fsa9480_resume, - .suspend = fsa9480_suspend, .id_table = fsa9480_id, };
Signature · 1 line
1.8.0
PATCH 3/4 misc: isl29003: Use dev_pm_ops
In reply to Lars-Peter ClausenUse dev_pm_ops instead of the deprecated legacy suspend/resume callbacks.
--- drivers/misc/isl29003.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/misc/isl29003.c +11 -8
@@ -409,18 +409,20 @@ static int isl29003_remove(struct i2c_client *client)return 0 ; } -#ifdef CONFIG_PM -static int isl29003_suspend (struct i2c_client *client,pm_message_t mesg) +#ifdef CONFIG_PM_SLEEP +static int isl29003_suspend (struct device *dev) { +struct i2c_client *client =to_i2c_client (dev);struct isl29003_data *data =i2c_get_clientdata (client); data->power_state_before_suspend =isl29003_get_power_state (client);return isl29003_set_power_state (client,0 ); } -static int isl29003_resume (struct i2c_client *client) +static int isl29003_resume (struct device *dev) {int i; +struct i2c_client *client =to_i2c_client (dev);struct isl29003_data *data =i2c_get_clientdata (client);/* restore registers from cache */
@@ -432,10 +434,12 @@ static int isl29003_resume(struct i2c_client *client) data->power_state_before_suspend); } +static SIMPLE_DEV_PM_OPS(isl29003_pm_ops, isl29003_suspend, isl29003_resume); +#define ISL29003_PM_OPS (&isl29003_pm_ops) +#else -#define isl29003_suspend NULL -#define isl29003_resume NULL -#endif /* CONFIG_PM */ +#define ISL29003_PM_OPS NULL +#endif /* CONFIG_PM_SLEEP */ static const struct i2c_device_id isl29003_id[] = { {"isl29003" ,0 },
@@ -447,9 +451,8 @@ static struct i2c_driver isl29003_driver = { .driver = { .name = ISL29003_DRV_NAME, .owner = THIS_MODULE, + .pm = ISL29003_PM_OPS, }, - .suspend = isl29003_suspend, - .resume = isl29003_resume, .probe = isl29003_probe, .remove = isl29003_remove, .id_table = isl29003_id,
Signature · 1 line
1.8.0
PATCH 4/4 misc: tsl2550: Use dev_pm_ops
In reply to Lars-Peter ClausenUse dev_pm_ops instead of the deprecated legacy suspend/resume callbacks.
--- drivers/misc/tsl2550.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/misc/tsl2550.c +11 -10
@@ -417,24 +417,26 @@ static int tsl2550_remove(struct i2c_client *client)return 0 ; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP -static int tsl2550_suspend (struct i2c_client *client,pm_message_t mesg) +static int tsl2550_suspend (struct device *dev) { -return tsl2550_set_power_state (client,0 ); +return tsl2550_set_power_state (to_i2c_client (dev),0 ); } -static int tsl2550_resume (struct i2c_client *client) +static int tsl2550_resume (struct device *dev) { -return tsl2550_set_power_state (client,1 ); +return tsl2550_set_power_state (to_i2c_client (dev),1 ); } +static SIMPLE_DEV_PM_OPS(tsl2550_pm_ops, tsl2550_suspend, tsl2550_resume); +#define TSL2550_PM_OPS (&tsl2550_pm_ops) +#else -#define tsl2550_suspend NULL -#define tsl2550_resume NULL +#define TSL2550_PM_OPS NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static const struct i2c_device_id tsl2550_id[] = { {"tsl2550" ,0 },
@@ -446,9 +448,8 @@ static struct i2c_driver tsl2550_driver = { .driver = { .name = TSL2550_DRV_NAME, .owner = THIS_MODULE, + .pm = TSL2550_PM_OPS, }, - .suspend = tsl2550_suspend, - .resume = tsl2550_resume, .probe = tsl2550_probe, .remove = tsl2550_remove, .id_table = tsl2550_id,
Signature · 1 line
1.8.0