aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2010-05-27 13:58:58 -0400
committerJean Delvare <khali@linux-fr.org>2010-05-27 13:58:58 -0400
commit8d4dee98b10050db9c32a449e460a2f69bb558ec (patch)
treeeb3eff50616859bffda22485f6f8f4a5a0bbe8b1
parentcff37c9e82e022068840b3d33167e64c6a0ecc06 (diff)
hwmon: (tmp102) Fix suspend and resume functions
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>
-rw-r--r--drivers/hwmon/tmp102.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
index e9de28df0e4d..0da695d800c5 100644
--- a/drivers/hwmon/tmp102.c
+++ b/drivers/hwmon/tmp102.c
@@ -239,19 +239,27 @@ static int __devexit tmp102_remove(struct i2c_client *client)
239static int tmp102_suspend(struct device *dev) 239static int tmp102_suspend(struct device *dev)
240{ 240{
241 struct i2c_client *client = to_i2c_client(dev); 241 struct i2c_client *client = to_i2c_client(dev);
242 int config;
242 243
243 tmp102_write_reg(client, TMP102_CONF_REG, TMP102_CONF_SD); 244 config = tmp102_read_reg(client, TMP102_CONF_REG);
245 if (config < 0)
246 return config;
244 247
245 return 0; 248 config |= TMP102_CONF_SD;
249 return tmp102_write_reg(client, TMP102_CONF_REG, config);
246} 250}
247 251
248static int tmp102_resume(struct device *dev) 252static int tmp102_resume(struct device *dev)
249{ 253{
250 struct i2c_client *client = to_i2c_client(dev); 254 struct i2c_client *client = to_i2c_client(dev);
255 int config;
251 256
252 tmp102_write_reg(client, TMP102_CONF_REG, TMP102_CONFIG); 257 config = tmp102_read_reg(client, TMP102_CONF_REG);
258 if (config < 0)
259 return config;
253 260
254 return 0; 261 config &= ~TMP102_CONF_SD;
262 return tmp102_write_reg(client, TMP102_CONF_REG, config);
255} 263}
256 264
257static const struct dev_pm_ops tmp102_dev_pm_ops = { 265static const struct dev_pm_ops tmp102_dev_pm_ops = {