driver i2c-core: i2c bus should support PM entries in struct dev_pm_ops.
Subsystems (2)
PATCH 1/1 driver i2c-core: i2c bus should support PM entries in struct dev_pm_ops.
Struct dev_pm_ops is not configured in current i2c bus type. i2c drivers only depends on suspend/resume entries in struct dev_pm_ops are not informed of PM suspend and resume events by i2c framework.
--- drivers/i2c/i2c-core.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-)
drivers/i2c/i2c-core.c +39 -0
@@ -155,6 +155,39 @@ static void i2c_device_shutdown(struct device *dev) driver->shutdown (client); } +#ifdef CONFIG_SUSPEND +static int i2c_device_pm_suspend (struct device *dev) +{ +struct i2c_driver *driver; +struct dev_pm_ops *pm; + +if (!dev->driver) +return 0 ; + driver =to_i2c_driver (dev->driver); + pm = driver->driver.pm; +if (!pm || !pm->suspend) +return 0 ; +return pm->suspend (dev); +} + +static int i2c_device_pm_resume (struct device *dev) +{ +struct i2c_driver *driver; +struct dev_pm_ops *pm; + +if (!dev->driver) +return 0 ; + driver =to_i2c_driver (dev->driver); + pm = driver->driver.pm; +if (!pm || !pm->resume) +return 0 ; +return pm->resume (dev); +} +#else +# define i2c_device_pm_suspend NULL +# define i2c_device_pm_resume NULL +#endif +static int i2c_device_suspend (struct device *dev,pm_message_t mesg) {struct i2c_client *client =i2c_verify_client (dev);
@@ -219,6 +252,11 @@ static const struct attribute_group *i2c_dev_attr_groups[] = {NULL }; +static struct dev_pm_ops i2c_device_pm_ops = { + .suspend = i2c_device_pm_suspend, + .resume = i2c_device_pm_resume, +}; +struct bus_type i2c_bus_type = { .name ="i2c" , .match = i2c_device_match,
@@ -227,6 +265,7 @@ struct bus_type i2c_bus_type = { .shutdown = i2c_device_shutdown, .suspend = i2c_device_suspend, .resume = i2c_device_resume, + .pm = &i2c_device_pm_ops, };EXPORT_SYMBOL_GPL (i2c_bus_type);
Signature · 1 line
1.6.0
Any comments?
Thanks.
Sonic
Quoted 84 lines · sonic zhang
Struct
dev_pm_opsis not configured in current i2c bus type. i2c drivers only depends on suspend/resume entries in structdev_pm_opsare not informed of PM suspend and resume events by i2c framework.Signed-off-by Sonic Zhang <[email protected]>---
drivers/i2c/i2c-core.c | 39 +++++++++++++++++++++++++++++++++++++++1 files changed, 39 insertions(+), 0 deletions(-)drivers/i2c/i2c-core.c +33
-0@@ -155,6 +155,39 @@ static void i2c_device_shutdown(struct device *dev) driver->shutdown(client); } +#ifdef CONFIG_SUSPEND +static int i2c_device_pm_suspend (struct device *dev) +{ + struct i2c_driver *driver; + struct dev_pm_ops *pm; + + if (!dev->driver) + return 0; + driver = to_i2c_driver(dev->driver); + pm = driver->driver.pm; + if (!pm || !pm->suspend) + return 0; + return pm->suspend(dev); +} + +static int i2c_device_pm_resume (struct device *dev) +{ + struct i2c_driver *driver; + struct dev_pm_ops *pm; + + if (!dev->driver) + return 0; + driver = to_i2c_driver(dev->driver); + pm = driver->driver.pm; + if (!pm || !pm->resume) + return 0; + return pm->resume(dev); +} +#else +# define i2c_device_pm_suspend NULL +# define i2c_device_pm_resume NULL +#endif + static int i2c_device_suspend(struct device *dev, pm_message_t mesg) { struct i2c_client *client = i2c_verify_client(dev);@@ -219,6 +252,11 @@ static const struct attribute_group *i2c_dev_attr_groups[] = {NULL
};drivers/i2c/i2c-core.c +5
-0+static struct dev_pm_ops i2c_device_pm_ops = { + .suspend = i2c_device_pm_suspend, + .resume = i2c_device_pm_resume, +}; +struct
bus_typei2c_bus_type= {
.name = "i2c",
.match =i2c_device_match,drivers/i2c/i2c-core.c +1
-1@@ -227,6 +265,7 @@ struct bus_type i2c_bus_type = { .shutdown = i2c_device_shutdown, .suspend = i2c_device_suspend, .resume = i2c_device_resume, + .pm = &i2c_device_pm_ops, }; EXPORT_SYMBOL_GPL(i2c_bus_type); --1.6.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Hi Sonic,
Quoted 3 lines · sonic zhang
Struct
dev_pm_opsis not configured in current i2c bus type. i2c drivers only depends on suspend/resume entries in structdev_pm_opsare not informed of PM suspend and resume events by i2c framework.
Good point. I was wondering some times ago what was the status of pm_ops. I seem to understand this is the future of power management, and "direct" .suspend and .resume callbacks will stop being supported at some point in the future? If so, what is the migration plan? I don't really want to support both forever.
Your patch introduces the following warnings:
drivers/i2c/i2c-core.c: In function ‘i2c_device_pm_suspend’:drivers/i2c/i2c-core.c:167: warning: assignment discards qualifiers from pointer target type drivers/i2c/i2c-core.c: In function ‘i2c_device_pm_resume’:drivers/i2c/i2c-core.c:181: warning: assignment discards qualifiers from pointer target type
You will obviously have to fix them before I can accept your patch. Missing const...
Quoted 14 lines
Signed-off-by Sonic Zhang <[email protected]>--- drivers/i2c/i2c-core.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-)drivers/i2c/i2c-core.c +0
-0@@ -155,6 +155,39 @@ static void i2c_device_shutdown(struct device *dev) driver->shutdown (client); }
drivers/i2c/i2c-core.c static void i2c_device_shutdown(struct device *dev) · line 167
Quoted 10 lines
drivers/i2c/i2c-core.c +10
-0+#ifdef CONFIG_SUSPEND +static int i2c_device_pm_suspend (struct device *dev) +{ +struct i2c_driver *driver; +struct dev_pm_ops *pm; + +if (!dev->driver) +return 0 ; + driver =to_i2c_driver (dev->driver); + pm = driver->driver.pm;
This makes little sense, sorry. Why go from device_driver to i2c_driver and then again to device_driver? The following is equivalent and more efficient:
pm = dev->driver->pm;
Quoted 4 lines
drivers/i2c/i2c-core.c +4
-0+if (!pm || !pm->suspend) +return 0 ; +return pm->suspend (dev); +}
drivers/i2c/i2c-core.c static void i2c_device_shutdown(struct device *dev) · line 181
Quoted 10 lines
drivers/i2c/i2c-core.c +10
-0+ +static int i2c_device_pm_resume (struct device *dev) +{ +struct i2c_driver *driver; +struct dev_pm_ops *pm; + +if (!dev->driver) +return 0 ; + driver =to_i2c_driver (dev->driver); + pm = driver->driver.pm;
Same here.
drivers/i2c/i2c-core.c static void i2c_device_shutdown(struct device *dev) · line 188
Quoted 7 lines
drivers/i2c/i2c-core.c +7
-0+if (!pm || !pm->resume) +return 0 ; + return pm->resume(dev); +} +#else +# define i2c_device_pm_suspend NULL +# define i2c_device_pm_resume NULL
No space between "#" and "define", please.
drivers/i2c/i2c-core.c static const struct attribute_group *i2c_dev_attr_groups[] = { · line 255
Quoted 10 lines
drivers/i2c/i2c-core.c +3
-0+#endif +static int i2c_device_suspend (struct device *dev,pm_message_t mesg) {struct i2c_client *client =i2c_verify_client (dev);@@ -219,6 +252,11 @@ static const struct attribute_group *i2c_dev_attr_groups[] = {NULL }; +static struct dev_pm_ops i2c_device_pm_ops = {
Could be const.
Quoted 8 lines
drivers/i2c/i2c-core.c +4
-0+ .suspend = i2c_device_pm_suspend, + .resume = i2c_device_pm_resume, +}; +struct bus_type i2c_bus_type = { .name ="i2c" , .match = i2c_device_match,
drivers/i2c/i2c-core.c struct bus_type i2c_bus_type = { · line 271
Quoted 7 lines
drivers/i2c/i2c-core.c +1
-0@@ -227,6 +265,7 @@ struct bus_type i2c_bus_type = { .shutdown = i2c_device_shutdown, .suspend = i2c_device_suspend, .resume = i2c_device_resume, + .pm = &i2c_device_pm_ops, };EXPORT_SYMBOL_GPL (i2c_bus_type);
I've made all the changes above myself, it build OK but I can't test.
Modified patch is here:
ftp://ftp.kernel.org/pub/linux/kernel/people/jdelvare/linux-2.6/jdelvare-i2c/i2c-core-i2c-bus-should-support-pm-entries-in-struct-dev_pm_ops.patch
Please test and report if anything's wrong.
Thanks,
Signature · 1 line
Jean Delvare
You changes to the patch work OK for me.
Sonic Zhang
Quoted 120 lines · Jean Delvare
Hi Sonic,
Quoted 3 lines · sonic zhang
Struct
dev_pm_opsis not configured in current i2c bus type. i2c drivers only depends on suspend/resume entries in structdev_pm_opsare not informed of PM suspend and resume events by i2c framework.Good point. I was wondering some times ago what was the status of
pm_ops. I seem to understand this is the future of power management, and "direct" .suspend and .resume callbacks will stop being supported at some point in the future? If so, what is the migration plan? I don't really want to support both forever.Your patch introduces the following warnings:
drivers/i2c/i2c-core.c: In function ‘i2c_device_pm_suspend’:drivers/i2c/i2c-core.c:167: warning: assignment discards qualifiers from pointer target typedrivers/i2c/i2c-core.c: In function ‘i2c_device_pm_resume’:drivers/i2c/i2c-core.c:181: warning: assignment discards qualifiers from pointer target typeYou will obviously have to fix them before I can accept your patch. Missing const...
Quoted 14 lines
Signed-off-by Sonic Zhang <[email protected]>---
drivers/i2c/i2c-core.c | 39 +++++++++++++++++++++++++++++++++++++++1 files changed, 39 insertions(+), 0 deletions(-)drivers/i2c/i2c-core.c +0
-0@@ -155,6 +155,39 @@ static void i2c_device_shutdown(struct device *dev) driver->shutdown(client); }drivers/i2c/i2c-core.c static void i2c_device_shutdown(struct device *dev) · line 167
Quoted 10 lines
drivers/i2c/i2c-core.c +10
-0+#ifdef CONFIG_SUSPEND +static int i2c_device_pm_suspend (struct device *dev) +{ + struct i2c_driver *driver; + struct dev_pm_ops *pm; + + if (!dev->driver) + return 0; + driver = to_i2c_driver(dev->driver); + pm = driver->driver.pm;This makes little sense, sorry. Why go from
device_drivertoi2c_driverand then again todevice_driver? The following is equivalent and more efficient:pm =
dev->driver->pm;Quoted 4 lines
drivers/i2c/i2c-core.c +4
-0+ if (!pm || !pm->suspend) + return 0; + return pm->suspend(dev); +}drivers/i2c/i2c-core.c static void i2c_device_shutdown(struct device *dev) · line 181
Quoted 10 lines
drivers/i2c/i2c-core.c +10
-0+ +static int i2c_device_pm_resume (struct device *dev) +{ + struct i2c_driver *driver; + struct dev_pm_ops *pm; + + if (!dev->driver) + return 0; + driver = to_i2c_driver(dev->driver); + pm = driver->driver.pm;Same here.
drivers/i2c/i2c-core.c static void i2c_device_shutdown(struct device *dev) · line 188
Quoted 7 lines
drivers/i2c/i2c-core.c +7
-0+ if (!pm || !pm->resume) + return 0; + return pm->resume(dev); +} +#else +# define i2c_device_pm_suspend NULL +# define i2c_device_pm_resume NULLNo space between "#" and "define", please.
Quoted 10 lines
drivers/i2c/i2c-core.c +2
-0+#endif + static int i2c_device_suspend(struct device *dev, pm_message_t mesg) { struct i2c_client *client = i2c_verify_client(dev);@@ -219,6 +252,11 @@ static const struct attribute_group *i2c_dev_attr_groups[] = {NULL
};+static struct
dev_pm_opsi2c_device_pm_ops= {Could be const.
Quoted 8 lines
+ .suspend =
i2c_device_pm_suspend,
+ .resume =i2c_device_pm_resume,drivers/i2c/i2c-core.c +2
-0+}; +struct
bus_typei2c_bus_type= {
.name = "i2c",
.match =i2c_device_match,drivers/i2c/i2c-core.c struct bus_type i2c_bus_type = { · line 271
Quoted 7 lines
drivers/i2c/i2c-core.c +1
-0@@ -227,6 +265,7 @@ struct bus_type i2c_bus_type = { .shutdown = i2c_device_shutdown, .suspend = i2c_device_suspend, .resume = i2c_device_resume, + .pm = &i2c_device_pm_ops, }; EXPORT_SYMBOL_GPL(i2c_bus_type);I've made all the changes above myself, it build OK but I can't test.
Modified patch is here:
ftp://ftp.kernel.org/pub/linux/kernel/people/jdelvare/linux-2.6/jdelvare-i2c/i2c-core-i2c-bus-should-support-pm-entries-in-struct-dev_pm_ops.patchPlease test and report if anything's wrong.
Thanks,
--
Jean Delvare