mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-11 15:49:56 +00:00
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>
This commit is contained in:
parent
960f12f4d1
commit
9914518e79
@ -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,
|
||||
|
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user