Commit 9914518e79800c977e20eda1335d43a4df813e3d
Committed by
Jean Delvare
1 parent
960f12f4d1
Exists in
master
and in
7 other branches
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>
Showing 2 changed files with 40 additions and 0 deletions Side-by-side Diff
drivers/hwmon/lm75.c
... | ... | @@ -280,10 +280,49 @@ |
280 | 280 | return 0; |
281 | 281 | } |
282 | 282 | |
283 | +#ifdef CONFIG_PM | |
284 | +static 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 | + | |
298 | +static 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 | + | |
312 | +static 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 | + | |
283 | 321 | static struct i2c_driver lm75_driver = { |
284 | 322 | .class = I2C_CLASS_HWMON, |
285 | 323 | .driver = { |
286 | 324 | .name = "lm75", |
325 | + .pm = LM75_DEV_PM_OPS, | |
287 | 326 | }, |
288 | 327 | .probe = lm75_probe, |
289 | 328 | .remove = lm75_remove, |
drivers/hwmon/lm75.h