From: Jean Delvare <khali@linux-fr.org>
To: lm-sensors@vger.kernel.org
Subject: [lm-sensors] [PATCH 2/3] hwmon: (tmp102) Fix suspend and resume
Date: Tue, 18 May 2010 09:02:53 +0000 [thread overview]
Message-ID: <20100518110253.58655906@hyperion.delvare> (raw)
Suspend and resume functions shouldn't overwrite the configuration
register. They should only alter the one bit they have to touch.
Also don't assume that register reads and writes always succeed.
Handle errors properly, shall they happen.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Steven King <sfking@fdwdc.com>
---
drivers/hwmon/tmp102.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
--- linux-2.6.34.orig/drivers/hwmon/tmp102.c 2010-05-18 10:57:05.000000000 +0200
+++ linux-2.6.34/drivers/hwmon/tmp102.c 2010-05-18 10:57:10.000000000 +0200
@@ -239,19 +239,27 @@ static int __devexit tmp102_remove(struc
static int tmp102_suspend(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
+ int config;
- tmp102_write_reg(client, TMP102_CONF_REG, TMP102_CONF_SD);
+ config = tmp102_read_reg(client, TMP102_CONF_REG);
+ if (config < 0)
+ return config;
- return 0;
+ config |= TMP102_CONF_SD;
+ return tmp102_write_reg(client, TMP102_CONF_REG, config);
}
static int tmp102_resume(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
+ int config;
- tmp102_write_reg(client, TMP102_CONF_REG, TMP102_CONFIG);
+ config = tmp102_read_reg(client, TMP102_CONF_REG);
+ if (config < 0)
+ return config;
- return 0;
+ config &= ~TMP102_CONF_SD;
+ return tmp102_write_reg(client, TMP102_CONF_REG, config);
}
static const struct dev_pm_ops tmp102_dev_pm_ops = {
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
reply other threads:[~2010-05-18 9:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20100518110253.58655906@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.