From 6dcf1bb85aed8a392ab071d3c2b6074bb302fcad Mon Sep 17 00:00:00 2001 From: Shubhrajyoti Datta Date: Sat, 14 Aug 2010 21:08:50 +0200 Subject: [PATCH] --- yaml --- r: 209421 b: refs/heads/master c: 9914518e79800c977e20eda1335d43a4df813e3d h: refs/heads/master i: 209419: 852a3318a45bd9415308c2b9c80390c0c460c1d5 v: v3 --- [refs] | 2 +- trunk/drivers/hwmon/lm75.c | 39 ++++++++++++++++++++++++++++++++++++++ trunk/drivers/hwmon/lm75.h | 1 + 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index cc8e12f1d298..3d9f0f61fd96 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 960f12f4d1eb5ba3c76dc6b57a909a65dd59e1c2 +refs/heads/master: 9914518e79800c977e20eda1335d43a4df813e3d diff --git a/trunk/drivers/hwmon/lm75.c b/trunk/drivers/hwmon/lm75.c index 393f354f92a4..ab5b87a81677 100644 --- a/trunk/drivers/hwmon/lm75.c +++ b/trunk/drivers/hwmon/lm75.c @@ -280,10 +280,49 @@ static int lm75_detect(struct i2c_client *new_client, return 0; } +#ifdef CONFIG_PM +static int lm75_suspend(struct device *dev) +{ + int status; + struct i2c_client *client = to_i2c_client(dev); + status = lm75_read_value(client, LM75_REG_CONF); + if (status < 0) { + dev_dbg(&client->dev, "Can't read config? %d\n", status); + return status; + } + status = status | LM75_SHUTDOWN; + lm75_write_value(client, LM75_REG_CONF, status); + return 0; +} + +static int lm75_resume(struct device *dev) +{ + int status; + struct i2c_client *client = to_i2c_client(dev); + status = lm75_read_value(client, LM75_REG_CONF); + if (status < 0) { + dev_dbg(&client->dev, "Can't read config? %d\n", status); + return status; + } + status = status & ~LM75_SHUTDOWN; + lm75_write_value(client, LM75_REG_CONF, status); + return 0; +} + +static const struct dev_pm_ops lm75_dev_pm_ops = { + .suspend = lm75_suspend, + .resume = lm75_resume, +}; +#define LM75_DEV_PM_OPS (&lm75_dev_pm_ops) +#else +#define LM75_DEV_PM_OPS NULL +#endif /* CONFIG_PM */ + static struct i2c_driver lm75_driver = { .class = I2C_CLASS_HWMON, .driver = { .name = "lm75", + .pm = LM75_DEV_PM_OPS, }, .probe = lm75_probe, .remove = lm75_remove, diff --git a/trunk/drivers/hwmon/lm75.h b/trunk/drivers/hwmon/lm75.h index 7c93454bb4e3..e547a3eb4de3 100644 --- a/trunk/drivers/hwmon/lm75.h +++ b/trunk/drivers/hwmon/lm75.h @@ -30,6 +30,7 @@ /* straight from the datasheet */ #define LM75_TEMP_MIN (-55000) #define LM75_TEMP_MAX 125000 +#define LM75_SHUTDOWN 0x01 /* TEMP: 0.001C/bit (-55C to +125C) REG: (0.5C/bit, two's complement) << 7 */