Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 176221
b: refs/heads/master
c: 54067ee
h: refs/heads/master
i:
  176219: f996e47
v: v3
  • Loading branch information
sonic zhang authored and Jean Delvare committed Dec 14, 2009
1 parent ad61bfa commit 04e5504
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7f508118b1c1f9856a1c899a2bd4867a962b0225
refs/heads/master: 54067ee20645a4ee12a9546aeb3b048b4c44cf60
35 changes: 35 additions & 0 deletions trunk/drivers/i2c/i2c-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand All @@ -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);

Expand Down

0 comments on commit 04e5504

Please sign in to comment.