Input: ad7879 - Convert I2C to dev_pm_ops
Subsystems (2)
PATCH 1/1 Input: ad7879 - Convert I2C to dev_pm_ops
There is a general move towards the use of dev_pm_ops rather than bus specific suspend APIs as this simplifies both the bus and PM core implementations. Convert the ad7879-ts I2C support over.
Compile tested only.
--- drivers/input/touchscreen/ad7879-i2c.c | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-)
drivers/input/touchscreen/ad7879-i2c.c +9 -6
@@ -10,14 +10,16 @@#include <linux/i2c.h> #include <linux/module.h> #include <linux/types.h> +#include <linux/pm.h> #include "ad7879.h" #define AD7879_DEVID 0x79/* AD7879-1/AD7889-1 */ #ifdef CONFIG_PM -static int ad7879_i2c_suspend (struct i2c_client *client,pm_message_t message) +static int ad7879_i2c_suspend (struct device *dev) { +struct i2c_client *client =to_i2c_client (dev);struct ad7879 *ts =i2c_get_clientdata (client);ad7879_suspend (ts);
@@ -25,17 +27,19 @@ static int ad7879_i2c_suspend(struct i2c_client *client, pm_message_t message)return 0 ; } -static int ad7879_i2c_resume (struct i2c_client *client) +static int ad7879_i2c_resume (struct device *dev) { +struct i2c_client *client =to_i2c_client (dev);struct ad7879 *ts =i2c_get_clientdata (client);ad7879_resume (ts);return 0 ; } + +static SIMPLE_DEV_PM_OPS(ad7879_i2c_pm, ad7879_i2c_suspend, ad7879_i2c_resume);#else -# define ad7879_i2c_suspend NULL -# define ad7879_i2c_resume NULL +# define ad7879_i2c_pm NULL#endif /* All registers are word-sized.
@@ -117,11 +121,10 @@ static struct i2c_driver ad7879_i2c_driver = { .driver = { .name = "ad7879", .owner = THIS_MODULE, + .pm = &ad7879_i2c_pm, }, .probe = ad7879_i2c_probe, .remove = __devexit_p(ad7879_i2c_remove), - .suspend = ad7879_i2c_suspend, - .resume = ad7879_i2c_resume, .id_table = ad7879_id, };
Signature · 1 line
1.7.2.3
Dmitry Torokhov
maintainerHi Mark,
drivers/input/touchscreen/ad7879-i2c.c static struct i2c_driver ad7879_i2c_driver = { · line 124
Quoted 9 lines · Mark Brown
drivers/input/touchscreen/ad7879-i2c.c +2
-0+# define ad7879_i2c_pm NULL#endif /* All registers are word-sized. @@ -117,11 +121,10 @@ static struct i2c_driver ad7879_i2c_driver = { .driver = { .name = "ad7879", .owner = THIS_MODULE, + .pm = &ad7879_i2c_pm,
I do not think you tested it with !CONFIG_PM since &NULL is not valid expression (& requires an lvalue for operand).
Please change to guard .pm = &ad7879_i2c_pm with #ifdef.
Thanks.
Signature · 1 line
Dmitry
Quoted 2 lines · Dmitry Torokhov
I do not think you tested it with !CONFIG_PM since &NULL is not valid expression (& requires an lvalue for operand).
Oh, fail. I knew there was a reason why dev_pm_ops stuff caused hassle. But then I do have to wonder who exactly builds without PM enabled these days.
Quoted 1 line
Please change to guard .pm =
&ad7879_i2c_pmwith #ifdef.
Meh, I guess. Though that ends up being annoying in general as some of the PM functions (things like poweroff) are active even without PM enabled, it always feels clearer to just have the struct there all the time and carry on with the standard NULLs for functions.
Dmitry Torokhov
maintainerQuoted 8 lines · Mark Brown
Quoted 2 lines · Dmitry Torokhov
I do not think you tested it with !CONFIG_PM since &NULL is not valid expression (& requires an lvalue for operand).
Oh, fail. I knew there was a reason why
dev_pm_opsstuff caused hassle. But then I do have to wonder who exactly builds without PM enabled these days.
Well, I kind of agree. Maybe someone should start looking into removing CONFIG_PM, we are in 2011 now...
Quoted 6 lines
Quoted 2 lines
Please change to guard .pm =
&ad7879_i2c_pmwith #ifdef.Meh, I guess. Though that ends up being annoying in general as some of the PM functions (things like poweroff) are active even without PM enabled,
Most of the drivers do not need special handlers for poweroff though... I actually do not much liek the "simple" initializator as it usually does way more than needed.
Quoted 2 lines
it always feels clearer to just have the struct there all the time and carry on with the standard NULLs for functions.
Thanks.
Signature · 1 line
Dmitry
Quoted 2 lines · Dmitry Torokhov
I actually do not much liek the "simple" initializator as it usually does way more than needed.
It does mean that we're exactly replicating the set of calls that get done where the legacy methods are used (at least for the simple buses like I2C) which is pretty important for this sort of mechanical update.
Quoted 1 line · Dmitry Torokhov
Please change to guard .pm =
&ad7879_i2c_pmwith #ifdef.
I've sent out updated versions of this and the other affected patches; the rest were already either not guarding at all or had the define due to following the idiom of the existing driver.
Dmitry Torokhov
maintainerQuoted 7 lines · Mark Brown
Quoted 1 line · Dmitry Torokhov
Please change to guard .pm =
&ad7879_i2c_pmwith #ifdef.I've sent out updated versions of this and the other affected patches; the rest were already either not guarding at all or had the define due to following the idiom of the existing driver.
Thanks Mark. I'll get them in.
Signature · 1 line
Dmitry