aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/i2c/i2c-core.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 9065c7238b5e..0ac2f90ab840 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -155,6 +155,35 @@ static void i2c_device_shutdown(struct device *dev)
155 driver->shutdown(client); 155 driver->shutdown(client);
156} 156}
157 157
158#ifdef CONFIG_SUSPEND
159static int i2c_device_pm_suspend(struct device *dev)
160{
161 const struct dev_pm_ops *pm;
162
163 if (!dev->driver)
164 return 0;
165 pm = dev->driver->pm;
166 if (!pm || !pm->suspend)
167 return 0;
168 return pm->suspend(dev);
169}
170
171static int i2c_device_pm_resume(struct device *dev)
172{
173 const struct dev_pm_ops *pm;
174
175 if (!dev->driver)
176 return 0;
177 pm = dev->driver->pm;
178 if (!pm || !pm->resume)
179 return 0;
180 return pm->resume(dev);
181}
182#else
183#define i2c_device_pm_suspend NULL
184#define i2c_device_pm_resume NULL
185#endif
186
158static int i2c_device_suspend(struct device *dev, pm_message_t mesg) 187static int i2c_device_suspend(struct device *dev, pm_message_t mesg)
159{ 188{
160 struct i2c_client *client = i2c_verify_client(dev); 189 struct i2c_client *client = i2c_verify_client(dev);
@@ -219,6 +248,11 @@ static const struct attribute_group *i2c_dev_attr_groups[] = {
219 NULL 248 NULL
220}; 249};
221 250
251const static struct dev_pm_ops i2c_device_pm_ops = {
252 .suspend = i2c_device_pm_suspend,
253 .resume = i2c_device_pm_resume,
254};
255
222struct bus_type i2c_bus_type = { 256struct bus_type i2c_bus_type = {
223 .name = "i2c", 257 .name = "i2c",
224 .match = i2c_device_match, 258 .match = i2c_device_match,
@@ -227,6 +261,7 @@ struct bus_type i2c_bus_type = {
227 .shutdown = i2c_device_shutdown, 261 .shutdown = i2c_device_shutdown,
228 .suspend = i2c_device_suspend, 262 .suspend = i2c_device_suspend,
229 .resume = i2c_device_resume, 263 .resume = i2c_device_resume,
264 .pm = &i2c_device_pm_ops,
230}; 265};
231EXPORT_SYMBOL_GPL(i2c_bus_type); 266EXPORT_SYMBOL_GPL(i2c_bus_type);
232 267