From: Jean Delvare Date: Thu, 27 May 2010 17:58:58 +0000 (+0200) Subject: hwmon: (tmp102) Fix suspend and resume functions X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8d4dee98b10050db9c32a449e460a2f69bb558ec;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git 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 Cc: Steven King --- 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) 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 = {