aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-m41t80.c
diff options
context:
space:
mode:
authorWolfram Sang <wsa@sang-engineering.com>2014-06-06 17:35:46 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-06 19:08:07 -0400
commit85d77047c4eaa247bc19a581dba968571dd87e55 (patch)
treeb5e979cdd69e0e029b4ce6c194a2614c2aa9bfc5 /drivers/rtc/rtc-m41t80.c
parentc67fedfab2d29de88a62282e0633d43329552703 (diff)
drivers/rtc/rtc-m41t80.c: propagate error value from smbus functions
Don't replace the value we got from the I2C layer, just pass it on. Signed-off-by: Wolfram Sang <wsa@sang-engineering.com> Cc: Jingoo Han <jg1.han@samsung.com> Cc: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-m41t80.c')
-rw-r--r--drivers/rtc/rtc-m41t80.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 86eccb15f524..d348b23ce18b 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -230,7 +230,7 @@ static ssize_t m41t80_sysfs_show_flags(struct device *dev,
230 230
231 val = i2c_smbus_read_byte_data(client, M41T80_REG_FLAGS); 231 val = i2c_smbus_read_byte_data(client, M41T80_REG_FLAGS);
232 if (val < 0) 232 if (val < 0)
233 return -EIO; 233 return val;
234 return sprintf(buf, "%#x\n", val); 234 return sprintf(buf, "%#x\n", val);
235} 235}
236static DEVICE_ATTR(flags, S_IRUGO, m41t80_sysfs_show_flags, NULL); 236static DEVICE_ATTR(flags, S_IRUGO, m41t80_sysfs_show_flags, NULL);
@@ -250,7 +250,7 @@ static ssize_t m41t80_sysfs_show_sqwfreq(struct device *dev,
250 reg_sqw = M41T80_REG_WDAY; 250 reg_sqw = M41T80_REG_WDAY;
251 val = i2c_smbus_read_byte_data(client, reg_sqw); 251 val = i2c_smbus_read_byte_data(client, reg_sqw);
252 if (val < 0) 252 if (val < 0)
253 return -EIO; 253 return val;
254 val = (val >> 4) & 0xf; 254 val = (val >> 4) & 0xf;
255 switch (val) { 255 switch (val) {
256 case 0: 256 case 0:
@@ -269,7 +269,7 @@ static ssize_t m41t80_sysfs_set_sqwfreq(struct device *dev,
269{ 269{
270 struct i2c_client *client = to_i2c_client(dev); 270 struct i2c_client *client = to_i2c_client(dev);
271 struct m41t80_data *clientdata = i2c_get_clientdata(client); 271 struct m41t80_data *clientdata = i2c_get_clientdata(client);
272 int almon, sqw, reg_sqw; 272 int almon, sqw, reg_sqw, rc;
273 int val = simple_strtoul(buf, NULL, 0); 273 int val = simple_strtoul(buf, NULL, 0);
274 274
275 if (!(clientdata->features & M41T80_FEATURE_SQ)) 275 if (!(clientdata->features & M41T80_FEATURE_SQ))
@@ -289,21 +289,30 @@ static ssize_t m41t80_sysfs_set_sqwfreq(struct device *dev,
289 /* disable SQW, set SQW frequency & re-enable */ 289 /* disable SQW, set SQW frequency & re-enable */
290 almon = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_MON); 290 almon = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_MON);
291 if (almon < 0) 291 if (almon < 0)
292 return -EIO; 292 return almon;
293 reg_sqw = M41T80_REG_SQW; 293 reg_sqw = M41T80_REG_SQW;
294 if (clientdata->features & M41T80_FEATURE_SQ_ALT) 294 if (clientdata->features & M41T80_FEATURE_SQ_ALT)
295 reg_sqw = M41T80_REG_WDAY; 295 reg_sqw = M41T80_REG_WDAY;
296 sqw = i2c_smbus_read_byte_data(client, reg_sqw); 296 sqw = i2c_smbus_read_byte_data(client, reg_sqw);
297 if (sqw < 0) 297 if (sqw < 0)
298 return -EIO; 298 return sqw;
299 sqw = (sqw & 0x0f) | (val << 4); 299 sqw = (sqw & 0x0f) | (val << 4);
300 if (i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON, 300
301 almon & ~M41T80_ALMON_SQWE) < 0 || 301 rc = i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON,
302 i2c_smbus_write_byte_data(client, reg_sqw, sqw) < 0) 302 almon & ~M41T80_ALMON_SQWE);
303 return -EIO; 303 if (rc < 0)
304 if (val && i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON, 304 return rc;
305 almon | M41T80_ALMON_SQWE) < 0) 305
306 return -EIO; 306 if (val) {
307 rc = i2c_smbus_write_byte_data(client, reg_sqw, sqw);
308 if (rc < 0)
309 return rc;
310
311 rc = i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON,
312 almon | M41T80_ALMON_SQWE);
313 if (rc <0)
314 return rc;
315 }
307 return count; 316 return count;
308} 317}
309static DEVICE_ATTR(sqwfreq, S_IRUGO | S_IWUSR, 318static DEVICE_ATTR(sqwfreq, S_IRUGO | S_IWUSR,
@@ -665,7 +674,7 @@ static int m41t80_probe(struct i2c_client *client,
665 674
666 if (rc < 0) { 675 if (rc < 0) {
667 dev_err(&client->dev, "Can't clear HT bit\n"); 676 dev_err(&client->dev, "Can't clear HT bit\n");
668 return -EIO; 677 return rc;
669 } 678 }
670 679
671 /* Make sure ST (stop) bit is cleared */ 680 /* Make sure ST (stop) bit is cleared */
@@ -676,7 +685,7 @@ static int m41t80_probe(struct i2c_client *client,
676 rc & ~M41T80_SEC_ST); 685 rc & ~M41T80_SEC_ST);
677 if (rc < 0) { 686 if (rc < 0) {
678 dev_err(&client->dev, "Can't clear ST bit\n"); 687 dev_err(&client->dev, "Can't clear ST bit\n");
679 return -EIO; 688 return rc;
680 } 689 }
681 690
682 rc = m41t80_sysfs_register(&client->dev); 691 rc = m41t80_sysfs_register(&client->dev);