* [PATCH] hwmon: (lm75) put chip into shutdown mode on shutdown
@ 2014-11-06 14:00 Michael Thalmeier
2014-11-06 14:17 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Michael Thalmeier @ 2014-11-06 14:00 UTC (permalink / raw)
To: linux, jdelvare; +Cc: lm-sensors, linux-kernel
In addition to going into shutdown mode on suspend also go into shutdown mode
on system shutdown. This way we can save a few mA when the main CPU is powered
off and the lm75 is still powered but not used any more.
Signed-off-by: Michael Thalmeier <michael.thalmeier@hale.at>
---
drivers/hwmon/lm75.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 7ec5ccd..d860af9 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -433,10 +433,10 @@ static int lm75_detect(struct i2c_client *new_client,
}
#ifdef CONFIG_PM
-static int lm75_suspend(struct device *dev)
+
+static int _lm75_shutdown(struct i2c_client *client)
{
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);
@@ -447,6 +447,18 @@ static int lm75_suspend(struct device *dev)
return 0;
}
+static void lm75_shutdown(struct i2c_client *client)
+{
+ _lm75_shutdown(client);
+}
+
+static int lm75_suspend(struct device *dev)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+
+ return _lm75_shutdown(client);
+}
+
static int lm75_resume(struct device *dev)
{
int status;
@@ -466,8 +478,10 @@ static const struct dev_pm_ops lm75_dev_pm_ops = {
.resume = lm75_resume,
};
#define LM75_DEV_PM_OPS (&lm75_dev_pm_ops)
+#define LM75_SHUTDOWN_OP lm75_shutdown
#else
#define LM75_DEV_PM_OPS NULL
+#define LM75_SHUTDOWN_OP NULL
#endif /* CONFIG_PM */
static struct i2c_driver lm75_driver = {
@@ -478,6 +492,7 @@ static struct i2c_driver lm75_driver = {
},
.probe = lm75_probe,
.remove = lm75_remove,
+ .shutdown = LM75_SHUTDOWN_OP,
.id_table = lm75_ids,
.detect = lm75_detect,
.address_list = normal_i2c,
--
1.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] hwmon: (lm75) put chip into shutdown mode on shutdown
2014-11-06 14:00 [PATCH] hwmon: (lm75) put chip into shutdown mode on shutdown Michael Thalmeier
@ 2014-11-06 14:17 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2014-11-06 14:17 UTC (permalink / raw)
To: Michael Thalmeier, jdelvare; +Cc: lm-sensors, linux-kernel
On 11/06/2014 06:00 AM, Michael Thalmeier wrote:
> In addition to going into shutdown mode on suspend also go into shutdown mode
> on system shutdown. This way we can save a few mA when the main CPU is powered
> off and the lm75 is still powered but not used any more.
>
You can do this in a more comprehensive way using SIMPLE_DEV_PM_OPS.
Guenter
> Signed-off-by: Michael Thalmeier <michael.thalmeier@hale.at>
> ---
> drivers/hwmon/lm75.c | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
> index 7ec5ccd..d860af9 100644
> --- a/drivers/hwmon/lm75.c
> +++ b/drivers/hwmon/lm75.c
> @@ -433,10 +433,10 @@ static int lm75_detect(struct i2c_client *new_client,
> }
>
> #ifdef CONFIG_PM
> -static int lm75_suspend(struct device *dev)
> +
> +static int _lm75_shutdown(struct i2c_client *client)
> {
> 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);
> @@ -447,6 +447,18 @@ static int lm75_suspend(struct device *dev)
> return 0;
> }
>
> +static void lm75_shutdown(struct i2c_client *client)
> +{
> + _lm75_shutdown(client);
> +}
> +
> +static int lm75_suspend(struct device *dev)
> +{
> + struct i2c_client *client = to_i2c_client(dev);
> +
> + return _lm75_shutdown(client);
> +}
> +
> static int lm75_resume(struct device *dev)
> {
> int status;
> @@ -466,8 +478,10 @@ static const struct dev_pm_ops lm75_dev_pm_ops = {
> .resume = lm75_resume,
> };
> #define LM75_DEV_PM_OPS (&lm75_dev_pm_ops)
> +#define LM75_SHUTDOWN_OP lm75_shutdown
> #else
> #define LM75_DEV_PM_OPS NULL
> +#define LM75_SHUTDOWN_OP NULL
> #endif /* CONFIG_PM */
>
> static struct i2c_driver lm75_driver = {
> @@ -478,6 +492,7 @@ static struct i2c_driver lm75_driver = {
> },
> .probe = lm75_probe,
> .remove = lm75_remove,
> + .shutdown = LM75_SHUTDOWN_OP,
> .id_table = lm75_ids,
> .detect = lm75_detect,
> .address_list = normal_i2c,
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-06 14:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-06 14:00 [PATCH] hwmon: (lm75) put chip into shutdown mode on shutdown Michael Thalmeier
2014-11-06 14:17 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox