提交 00588243 编写于 作者: L Ladislav Michl 提交者: Greg Kroah-Hartman

[PATCH] I2C: ds1337: i2c_transfer() checking

i2c_transfer returns number of sucessfully transfered messages. Change
error checking to accordingly. (ds1337_set_datetime never returned
sucess)
Signed-off-by: NLadislav Michl <ladis@linux-mips.org>
Signed-off-by: NJames Chapman <jchapman@katalix.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 0b46e334
...@@ -122,7 +122,7 @@ static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt) ...@@ -122,7 +122,7 @@ static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt)
__FUNCTION__, result, buf[0], buf[1], buf[2], buf[3], __FUNCTION__, result, buf[0], buf[1], buf[2], buf[3],
buf[4], buf[5], buf[6]); buf[4], buf[5], buf[6]);
if (result >= 0) { if (result == 2) {
dt->tm_sec = BCD2BIN(buf[0]); dt->tm_sec = BCD2BIN(buf[0]);
dt->tm_min = BCD2BIN(buf[1]); dt->tm_min = BCD2BIN(buf[1]);
val = buf[2] & 0x3f; val = buf[2] & 0x3f;
...@@ -140,12 +140,12 @@ static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt) ...@@ -140,12 +140,12 @@ static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt)
__FUNCTION__, dt->tm_sec, dt->tm_min, __FUNCTION__, dt->tm_sec, dt->tm_min,
dt->tm_hour, dt->tm_mday, dt->tm_hour, dt->tm_mday,
dt->tm_mon, dt->tm_year, dt->tm_wday); dt->tm_mon, dt->tm_year, dt->tm_wday);
} else {
dev_err(&client->dev, "error reading data! %d\n", result); return 0;
result = -EIO;
} }
return result; dev_err(&client->dev, "error reading data! %d\n", result);
return -EIO;
} }
static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt) static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt)
...@@ -185,14 +185,11 @@ static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt) ...@@ -185,14 +185,11 @@ static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt)
msg[0].buf = &buf[0]; msg[0].buf = &buf[0];
result = i2c_transfer(client->adapter, msg, 1); result = i2c_transfer(client->adapter, msg, 1);
if (result < 0) { if (result == 1)
dev_err(&client->dev, "error writing data! %d\n", result); return 0;
result = -EIO;
} else {
result = 0;
}
return result; dev_err(&client->dev, "error writing data! %d\n", result);
return -EIO;
} }
static int ds1337_command(struct i2c_client *client, unsigned int cmd, static int ds1337_command(struct i2c_client *client, unsigned int cmd,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册