aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorShubhrajyoti Datta <shubhrajyoti@ti.com>2010-08-14 15:08:50 -0400
committerJean Delvare <khali@linux-fr.org>2010-08-14 15:08:50 -0400
commit9914518e79800c977e20eda1335d43a4df813e3d (patch)
tree48cc84975364ad67932b184722dce594a67650de /drivers/hwmon
parent960f12f4d1eb5ba3c76dc6b57a909a65dd59e1c2 (diff)
hwmon: (lm75) Add suspend/resume feature
There is a shutdown feature at suspend it can be enabled to reduce current consumption and resume it can be switched off. Signed-off-by: Shubhrajyoti Datta <shubhrajyoti@ti.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/lm75.c39
-rw-r--r--drivers/hwmon/lm75.h1
2 files changed, 40 insertions, 0 deletions
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 393f354f92a4..ab5b87a81677 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -280,10 +280,49 @@ static int lm75_detect(struct i2c_client *new_client,
280 return 0; 280 return 0;
281} 281}
282 282
283#ifdef CONFIG_PM
284static int lm75_suspend(struct device *dev)
285{
286 int status;
287 struct i2c_client *client = to_i2c_client(dev);
288 status = lm75_read_value(client, LM75_REG_CONF);
289 if (status < 0) {
290 dev_dbg(&client->dev, "Can't read config? %d\n", status);
291 return status;
292 }
293 status = status | LM75_SHUTDOWN;
294 lm75_write_value(client, LM75_REG_CONF, status);
295 return 0;
296}
297
298static int lm75_resume(struct device *dev)
299{
300 int status;
301 struct i2c_client *client = to_i2c_client(dev);
302 status = lm75_read_value(client, LM75_REG_CONF);
303 if (status < 0) {
304 dev_dbg(&client->dev, "Can't read config? %d\n", status);
305 return status;
306 }
307 status = status & ~LM75_SHUTDOWN;
308 lm75_write_value(client, LM75_REG_CONF, status);
309 return 0;
310}
311
312static const struct dev_pm_ops lm75_dev_pm_ops = {
313 .suspend = lm75_suspend,
314 .resume = lm75_resume,
315};
316#define LM75_DEV_PM_OPS (&lm75_dev_pm_ops)
317#else
318#define LM75_DEV_PM_OPS NULL
319#endif /* CONFIG_PM */
320
283static struct i2c_driver lm75_driver = { 321static struct i2c_driver lm75_driver = {
284 .class = I2C_CLASS_HWMON, 322 .class = I2C_CLASS_HWMON,
285 .driver = { 323 .driver = {
286 .name = "lm75", 324 .name = "lm75",
325 .pm = LM75_DEV_PM_OPS,
287 }, 326 },
288 .probe = lm75_probe, 327 .probe = lm75_probe,
289 .remove = lm75_remove, 328 .remove = lm75_remove,
diff --git a/drivers/hwmon/lm75.h b/drivers/hwmon/lm75.h
index 7c93454bb4e3..e547a3eb4de3 100644
--- a/drivers/hwmon/lm75.h
+++ b/drivers/hwmon/lm75.h
@@ -30,6 +30,7 @@
30/* straight from the datasheet */ 30/* straight from the datasheet */
31#define LM75_TEMP_MIN (-55000) 31#define LM75_TEMP_MIN (-55000)
32#define LM75_TEMP_MAX 125000 32#define LM75_TEMP_MAX 125000
33#define LM75_SHUTDOWN 0x01
33 34
34/* TEMP: 0.001C/bit (-55C to +125C) 35/* TEMP: 0.001C/bit (-55C to +125C)
35 REG: (0.5C/bit, two's complement) << 7 */ 36 REG: (0.5C/bit, two's complement) << 7 */