Commit 64b4782f authored by Rajendra Nayak's avatar Rajendra Nayak Committed by Jean Delvare

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: default avatarRajendra Nayak <rnayak@ti.com>
Acked-by: default avatarRafael 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: default avatarJean Delvare <khali@linux-fr.org>
parent 6abb930a
...@@ -197,11 +197,12 @@ static int i2c_device_pm_suspend(struct device *dev) ...@@ -197,11 +197,12 @@ static int i2c_device_pm_suspend(struct device *dev)
{ {
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
if (pm_runtime_suspended(dev)) if (pm) {
return 0; if (pm_runtime_suspended(dev))
return 0;
if (pm) else
return pm->suspend ? pm->suspend(dev) : 0; return pm->suspend ? pm->suspend(dev) : 0;
}
return i2c_legacy_suspend(dev, PMSG_SUSPEND); return i2c_legacy_suspend(dev, PMSG_SUSPEND);
} }
...@@ -223,11 +224,12 @@ static int i2c_device_pm_freeze(struct device *dev) ...@@ -223,11 +224,12 @@ static int i2c_device_pm_freeze(struct device *dev)
{ {
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
if (pm_runtime_suspended(dev)) if (pm) {
return 0; if (pm_runtime_suspended(dev))
return 0;
if (pm) else
return pm->freeze ? pm->freeze(dev) : 0; return pm->freeze ? pm->freeze(dev) : 0;
}
return i2c_legacy_suspend(dev, PMSG_FREEZE); return i2c_legacy_suspend(dev, PMSG_FREEZE);
} }
...@@ -236,11 +238,12 @@ static int i2c_device_pm_thaw(struct device *dev) ...@@ -236,11 +238,12 @@ static int i2c_device_pm_thaw(struct device *dev)
{ {
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
if (pm_runtime_suspended(dev)) if (pm) {
return 0; if (pm_runtime_suspended(dev))
return 0;
if (pm) else
return pm->thaw ? pm->thaw(dev) : 0; return pm->thaw ? pm->thaw(dev) : 0;
}
return i2c_legacy_resume(dev); return i2c_legacy_resume(dev);
} }
...@@ -249,11 +252,12 @@ static int i2c_device_pm_poweroff(struct device *dev) ...@@ -249,11 +252,12 @@ static int i2c_device_pm_poweroff(struct device *dev)
{ {
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
if (pm_runtime_suspended(dev)) if (pm) {
return 0; if (pm_runtime_suspended(dev))
return 0;
if (pm) else
return pm->poweroff ? pm->poweroff(dev) : 0; return pm->poweroff ? pm->poweroff(dev) : 0;
}
return i2c_legacy_suspend(dev, PMSG_HIBERNATE); return i2c_legacy_suspend(dev, PMSG_HIBERNATE);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment