aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLadislav Michl <ladis@linux-mips.org>2005-05-04 02:13:54 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-06-22 00:51:51 -0400
commit00588243053bb40d0406c7843833f8fae81294ab (patch)
treeabf967a76d51f002a878ce6e6544c0b1c6cde62e /drivers
parent0b46e334d77b2d3b8b3aa665c81c4afbe9f1f458 (diff)
[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: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: James Chapman <jchapman@katalix.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/chips/ds1337.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c
index 0967ec6d7947..c4762ac980a3 100644
--- a/drivers/i2c/chips/ds1337.c
+++ b/drivers/i2c/chips/ds1337.c
@@ -122,7 +122,7 @@ static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt)
122 __FUNCTION__, result, buf[0], buf[1], buf[2], buf[3], 122 __FUNCTION__, result, buf[0], buf[1], buf[2], buf[3],
123 buf[4], buf[5], buf[6]); 123 buf[4], buf[5], buf[6]);
124 124
125 if (result >= 0) { 125 if (result == 2) {
126 dt->tm_sec = BCD2BIN(buf[0]); 126 dt->tm_sec = BCD2BIN(buf[0]);
127 dt->tm_min = BCD2BIN(buf[1]); 127 dt->tm_min = BCD2BIN(buf[1]);
128 val = buf[2] & 0x3f; 128 val = buf[2] & 0x3f;
@@ -140,12 +140,12 @@ static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt)
140 __FUNCTION__, dt->tm_sec, dt->tm_min, 140 __FUNCTION__, dt->tm_sec, dt->tm_min,
141 dt->tm_hour, dt->tm_mday, 141 dt->tm_hour, dt->tm_mday,
142 dt->tm_mon, dt->tm_year, dt->tm_wday); 142 dt->tm_mon, dt->tm_year, dt->tm_wday);
143 } else { 143
144 dev_err(&client->dev, "error reading data! %d\n", result); 144 return 0;
145 result = -EIO;
146 } 145 }
147 146
148 return result; 147 dev_err(&client->dev, "error reading data! %d\n", result);
148 return -EIO;
149} 149}
150 150
151static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt) 151static 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 msg[0].buf = &buf[0]; 185 msg[0].buf = &buf[0];
186 186
187 result = i2c_transfer(client->adapter, msg, 1); 187 result = i2c_transfer(client->adapter, msg, 1);
188 if (result < 0) { 188 if (result == 1)
189 dev_err(&client->dev, "error writing data! %d\n", result); 189 return 0;
190 result = -EIO;
191 } else {
192 result = 0;
193 }
194 190
195 return result; 191 dev_err(&client->dev, "error writing data! %d\n", result);
192 return -EIO;
196} 193}
197 194
198static int ds1337_command(struct i2c_client *client, unsigned int cmd, 195static int ds1337_command(struct i2c_client *client, unsigned int cmd,