From: Jean Delvare <khali@linux-fr.org>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH 2/3] lm87: Restore original configuration
Date: Fri, 22 Aug 2008 15:01:43 +0000 [thread overview]
Message-ID: <20080822170143.02b34f27@hyperion.delvare> (raw)
In-Reply-To: <20080820201533.GN7908@solarflare.com>
Hi Ben,
On Wed, 20 Aug 2008 21:15:33 +0100, Ben Hutchings wrote:
> This means that if we have to start the monitor when probed, we also
> stop it on removal.
Looks OK to me, with only one suggestion:
>
> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
> ---
> drivers/hwmon/lm87.c | 12 +++++++-----
> 1 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c
> index 0fecbfd..695f5f2 100644
> --- a/drivers/hwmon/lm87.c
> +++ b/drivers/hwmon/lm87.c
> @@ -199,6 +199,7 @@ struct lm87_data {
> unsigned long last_updated; /* In jiffies */
>
> u8 channel; /* register value */
> + u8 config; /* original register value */
>
> u8 in[8]; /* register value */
> u8 in_max[8]; /* register value */
> @@ -832,6 +833,7 @@ exit_remove:
> sysfs_remove_group(&new_client->dev.kobj, &lm87_group);
> sysfs_remove_group(&new_client->dev.kobj, &lm87_group_opt);
> exit_free:
> + lm87_write_value(new_client, LM87_REG_CONFIG, data->config);
> kfree(data);
> exit:
> return err;
> @@ -840,12 +842,11 @@ exit:
> static void lm87_init_client(struct i2c_client *client)
> {
> struct lm87_data *data = i2c_get_clientdata(client);
> - u8 config;
>
> data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE);
> + data->config = lm87_read_value(client, LM87_REG_CONFIG);
Would you mind if I add "& 0x6f"? Bits 4 and 7 trigger an action when
you write to them, and self clear. Thus I think we want to make sure
that we will never write 1 to them accidentally. It shouldn't make a
difference in practice, but it feels safer to me that way.
>
> - config = lm87_read_value(client, LM87_REG_CONFIG);
> - if (!(config & 0x01)) {
> + if (!(data->config & 0x01)) {
> int i;
>
> /* Limits are left uninitialized after power-up */
> @@ -869,9 +870,9 @@ static void lm87_init_client(struct i2c_client *client)
> }
>
> /* Make sure Start is set and INT#_Clear is clear */
> - if ((config & 0x09) != 0x01)
> + if ((data->config & 0x09) != 0x01)
> lm87_write_value(client, LM87_REG_CONFIG,
> - (config & 0x77) | 0x01);
> + (data->config & 0x77) | 0x01);
> }
>
> static int lm87_remove(struct i2c_client *client)
> @@ -882,6 +883,7 @@ static int lm87_remove(struct i2c_client *client)
> sysfs_remove_group(&client->dev.kobj, &lm87_group);
> sysfs_remove_group(&client->dev.kobj, &lm87_group_opt);
>
> + lm87_write_value(client, LM87_REG_CONFIG, data->config);
> kfree(data);
> return 0;
> }
>
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
next prev parent reply other threads:[~2008-08-22 15:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-20 20:15 [lm-sensors] [PATCH 2/3] lm87: Restore original configuration Ben Hutchings
2008-08-22 15:01 ` Jean Delvare [this message]
2008-08-22 15:57 ` Ben Hutchings
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080822170143.02b34f27@hyperion.delvare \
--to=khali@linux-fr.org \
--cc=lm-sensors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.