aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorRajendra Nayak <rnayak@ti.com>2010-09-30 08:14:22 -0400
committerJean Delvare <khali@endymion.delvare>2010-09-30 08:14:22 -0400
commit64b4782fc9e4bdc59ae90897e2258e4ec938690e (patch)
tree6f48bc54d8b60b562141519bb9f638c904f91d5a /drivers/i2c
parent6abb930af064fb1cf4177d32e2c7bfb89eee0fe5 (diff)
i2c: Fix checks which cause legacy suspend to never get called
For devices which are not adapted to runtime PM a call to pm_runtime_suspended always returns true. Hence the pm_runtime_suspended checks below prevent legacy suspend from getting called. So do a pm_runtime_suspended check only for devices with a dev_pm_ops populated (which hence do not rely on the legacy suspend.) Signed-off-by: Rajendra Nayak <rnayak@ti.com> Acked-by: Rafael J. Wysocki <rjw@sisk.pl> Cc: Ben Dooks <ben-linux@fluff.org> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: Kevin Hilman <khilman@deeprootsystems.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/i2c-core.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 13927d54cb4e..9b3cac13a4a8 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -197,11 +197,12 @@ static int i2c_device_pm_suspend(struct device *dev)
197{ 197{
198 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 198 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
199 199
200 if (pm_runtime_suspended(dev)) 200 if (pm) {
201 return 0; 201 if (pm_runtime_suspended(dev))
202 202 return 0;
203 if (pm) 203 else
204 return pm->suspend ? pm->suspend(dev) : 0; 204 return pm->suspend ? pm->suspend(dev) : 0;
205 }
205 206
206 return i2c_legacy_suspend(dev, PMSG_SUSPEND); 207 return i2c_legacy_suspend(dev, PMSG_SUSPEND);
207} 208}
@@ -223,11 +224,12 @@ static int i2c_device_pm_freeze(struct device *dev)
223{ 224{
224 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 225 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
225 226
226 if (pm_runtime_suspended(dev)) 227 if (pm) {
227 return 0; 228 if (pm_runtime_suspended(dev))
228 229 return 0;
229 if (pm) 230 else
230 return pm->freeze ? pm->freeze(dev) : 0; 231 return pm->freeze ? pm->freeze(dev) : 0;
232 }
231 233
232 return i2c_legacy_suspend(dev, PMSG_FREEZE); 234 return i2c_legacy_suspend(dev, PMSG_FREEZE);
233} 235}
@@ -236,11 +238,12 @@ static int i2c_device_pm_thaw(struct device *dev)
236{ 238{
237 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 239 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
238 240
239 if (pm_runtime_suspended(dev)) 241 if (pm) {
240 return 0; 242 if (pm_runtime_suspended(dev))
241 243 return 0;
242 if (pm) 244 else
243 return pm->thaw ? pm->thaw(dev) : 0; 245 return pm->thaw ? pm->thaw(dev) : 0;
246 }
244 247
245 return i2c_legacy_resume(dev); 248 return i2c_legacy_resume(dev);
246} 249}
@@ -249,11 +252,12 @@ static int i2c_device_pm_poweroff(struct device *dev)
249{ 252{
250 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 253 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
251 254
252 if (pm_runtime_suspended(dev)) 255 if (pm) {
253 return 0; 256 if (pm_runtime_suspended(dev))
254 257 return 0;
255 if (pm) 258 else
256 return pm->poweroff ? pm->poweroff(dev) : 0; 259 return pm->poweroff ? pm->poweroff(dev) : 0;
260 }
257 261
258 return i2c_legacy_suspend(dev, PMSG_HIBERNATE); 262 return i2c_legacy_suspend(dev, PMSG_HIBERNATE);
259} 263}