linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] driver i2c-core: i2c bus should support PM entries in struct dev_pm_ops.
@ 2009-12-02  9:08 sonic zhang
       [not found] ` <1259744920.25505.2.camel-x+10Id33CNwLe6dzpsQaEw@public.gmane.org>
  2009-12-13 21:12 ` Jean Delvare
  0 siblings, 2 replies; 4+ messages in thread
From: sonic zhang @ 2009-12-02  9:08 UTC (permalink / raw)
  To: khali-PUYAD+kWke1g9hUCZPvPmw
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Linux Kernel

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.

Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
---
 drivers/i2c/i2c-core.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 2965043..9713c0d 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -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);
 
-- 
1.6.0

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

end of thread, other threads:[~2009-12-15  5:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-02  9:08 [PATCH] driver i2c-core: i2c bus should support PM entries in struct dev_pm_ops sonic zhang
     [not found] ` <1259744920.25505.2.camel-x+10Id33CNwLe6dzpsQaEw@public.gmane.org>
2009-12-04  9:24   ` Sonic Zhang
2009-12-13 21:12 ` Jean Delvare
     [not found]   ` <20091213221222.724bef54-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-12-15  5:38     ` Sonic Zhang

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