Add suspend resume feature to lm75
RFC PATCH 1/1 Add suspend resume feature to lm75
There is a shutdown feature at suspend it can be enabled to reduce current consumption and resume it can be switched off. Also some minor changes to keep checkpatch happy
Signed-off-by Shubhrajyoti Datta <[email protected]>
--- drivers/hwmon/lm75.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/hwmon/lm75.h | 3 ++- 2 files changed, 39 insertions(+), 1 deletions(-) mode change 100644 => 100755 drivers/hwmon/lm75.c
drivers/hwmon/lm75.c +37 -0
@@ -281,11 +281,48 @@ 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,
drivers/hwmon/lm75.h +2 -1
@@ -30,13 +30,14 @@/* 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 */ static inline u16 LM75_TEMP_TO_REG (long temp) {int ntemp =SENSORS_LIMIT (temp,LM75_TEMP_MIN ,LM75_TEMP_MAX ); - ntemp += (ntemp<0 ?-250 :250 ); + ntemp += (ntemp <0 ?-250 :250 );return (u16)((ntemp /500 ) <<7 ); }
Signature · 7 lines
1.5.4.7 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 3 lines · Shubhrajyoti
There is a shutdown feature at suspend it can be enabled to reduce current consumption and resume it can be switched off. Also some minor changes to keep checkpatch happy
Please don't mix new features and cleanups. I've reverted the cleanup part - if you really want it, please send a separate patch.
Quoted 73 lines
Signed-off-by Shubhrajyoti Datta <[email protected]>--- drivers/hwmon/lm75.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/hwmon/lm75.h | 3 ++- 2 files changed, 39 insertions(+), 1 deletions(-) mode change 100644 => 100755 drivers/hwmon/lm75.cdrivers/hwmon/lm75.c +37
-0@@ -281,11 +281,48 @@ 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,drivers/hwmon/lm75.h +1
-0@@ -30,13 +30,14 @@/* straight from the datasheet */ #define LM75_TEMP_MIN (-55000)#define LM75_TEMP_MAX 125000 +#define LM75_SHUTDOWN 0x01
drivers/hwmon/lm75.h line 43
Quoted 10 lines
drivers/hwmon/lm75.h +1
-1/* TEMP: 0.001C/bit (-55C to +125C) REG: (0.5C/bit, two's complement) << 7 */ static inline u16 LM75_TEMP_TO_REG (long temp) {int ntemp =SENSORS_LIMIT (temp,LM75_TEMP_MIN ,LM75_TEMP_MAX ); - ntemp += (ntemp<0 ?-250 :250 ); + ntemp += (ntemp <0 ?-250 :250 );return (u16)((ntemp /500 ) <<7 ); }
Applied with some white-space cleanups, thanks.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors