mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 16:24:13 +08:00
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. Signed-off-by: Sonic Zhang <sonic.zhang@analog.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
This commit is contained in:
parent
7f508118b1
commit
54067ee206
@ -155,6 +155,35 @@ static void i2c_device_shutdown(struct device *dev)
|
||||
driver->shutdown(client);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SUSPEND
|
||||
static int i2c_device_pm_suspend(struct device *dev)
|
||||
{
|
||||
const struct dev_pm_ops *pm;
|
||||
|
||||
if (!dev->driver)
|
||||
return 0;
|
||||
pm = dev->driver->pm;
|
||||
if (!pm || !pm->suspend)
|
||||
return 0;
|
||||
return pm->suspend(dev);
|
||||
}
|
||||
|
||||
static int i2c_device_pm_resume(struct device *dev)
|
||||
{
|
||||
const struct dev_pm_ops *pm;
|
||||
|
||||
if (!dev->driver)
|
||||
return 0;
|
||||
pm = dev->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 +248,11 @@ static const struct attribute_group *i2c_dev_attr_groups[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
const 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 +261,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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user