aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-ali1535.c
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2008-07-14 16:38:25 -0400
committerJean Delvare <khali@mahadeva.delvare>2008-07-14 16:38:25 -0400
commit97140342e69d479a3ad82bfd4c154c0b08fe3eea (patch)
tree2ee2ad225c7e4850a30bc57c4bf07251c1da1085 /drivers/i2c/busses/i2c-ali1535.c
parent6ea438ec8da4ec56bf415f5ea360e6b0cb59c6c3 (diff)
i2c: Bus drivers return -Errno not -1
Tighten error paths used by various i2c adapters (mostly x86) so they return real fault/errno codes instead of a "-1" (which is most often interpreted as "-EPERM"). Build tested, with eyeball review. One minor initial goal is to have adapters consistently return the code "-ENXIO" when addressing a device doesn't get an ACK response, at least in the probe paths where they are already good at stifling related logspam. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c/busses/i2c-ali1535.c')
-rw-r--r--drivers/i2c/busses/i2c-ali1535.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
index f14372ac2fc5..c21e4d96382e 100644
--- a/drivers/i2c/busses/i2c-ali1535.c
+++ b/drivers/i2c/busses/i2c-ali1535.c
@@ -259,7 +259,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
259 dev_err(&adap->dev, 259 dev_err(&adap->dev,
260 "SMBus reset failed! (0x%02x) - controller or " 260 "SMBus reset failed! (0x%02x) - controller or "
261 "device on bus is probably hung\n", temp); 261 "device on bus is probably hung\n", temp);
262 return -1; 262 return -EBUSY;
263 } 263 }
264 } else { 264 } else {
265 /* check and clear done bit */ 265 /* check and clear done bit */
@@ -281,12 +281,12 @@ static int ali1535_transaction(struct i2c_adapter *adap)
281 281
282 /* If the SMBus is still busy, we give up */ 282 /* If the SMBus is still busy, we give up */
283 if (timeout >= MAX_TIMEOUT) { 283 if (timeout >= MAX_TIMEOUT) {
284 result = -1; 284 result = -ETIMEDOUT;
285 dev_err(&adap->dev, "SMBus Timeout!\n"); 285 dev_err(&adap->dev, "SMBus Timeout!\n");
286 } 286 }
287 287
288 if (temp & ALI1535_STS_FAIL) { 288 if (temp & ALI1535_STS_FAIL) {
289 result = -1; 289 result = -EIO;
290 dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); 290 dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
291 } 291 }
292 292
@@ -295,7 +295,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
295 * do a printk. This means that bus collisions go unreported. 295 * do a printk. This means that bus collisions go unreported.
296 */ 296 */
297 if (temp & ALI1535_STS_BUSERR) { 297 if (temp & ALI1535_STS_BUSERR) {
298 result = -1; 298 result = -ENXIO;
299 dev_dbg(&adap->dev, 299 dev_dbg(&adap->dev,
300 "Error: no response or bus collision ADD=%02x\n", 300 "Error: no response or bus collision ADD=%02x\n",
301 inb_p(SMBHSTADD)); 301 inb_p(SMBHSTADD));
@@ -303,13 +303,13 @@ static int ali1535_transaction(struct i2c_adapter *adap)
303 303
304 /* haven't ever seen this */ 304 /* haven't ever seen this */
305 if (temp & ALI1535_STS_DEV) { 305 if (temp & ALI1535_STS_DEV) {
306 result = -1; 306 result = -EIO;
307 dev_err(&adap->dev, "Error: device error\n"); 307 dev_err(&adap->dev, "Error: device error\n");
308 } 308 }
309 309
310 /* check to see if the "command complete" indication is set */ 310 /* check to see if the "command complete" indication is set */
311 if (!(temp & ALI1535_STS_DONE)) { 311 if (!(temp & ALI1535_STS_DONE)) {
312 result = -1; 312 result = -ETIMEDOUT;
313 dev_err(&adap->dev, "Error: command never completed\n"); 313 dev_err(&adap->dev, "Error: command never completed\n");
314 } 314 }
315 315
@@ -332,7 +332,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
332 return result; 332 return result;
333} 333}
334 334
335/* Return -1 on error. */ 335/* Return negative errno on error. */
336static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, 336static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
337 unsigned short flags, char read_write, u8 command, 337 unsigned short flags, char read_write, u8 command,
338 int size, union i2c_smbus_data *data) 338 int size, union i2c_smbus_data *data)
@@ -359,7 +359,7 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
359 switch (size) { 359 switch (size) {
360 case I2C_SMBUS_PROC_CALL: 360 case I2C_SMBUS_PROC_CALL:
361 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n"); 361 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
362 result = -1; 362 result = -EOPNOTSUPP;
363 goto EXIT; 363 goto EXIT;
364 case I2C_SMBUS_QUICK: 364 case I2C_SMBUS_QUICK:
365 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), 365 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
@@ -420,11 +420,9 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
420 break; 420 break;
421 } 421 }
422 422
423 if (ali1535_transaction(adap)) { 423 result = ali1535_transaction(adap);
424 /* Error in transaction */ 424 if (result)
425 result = -1;
426 goto EXIT; 425 goto EXIT;
427 }
428 426
429 if ((read_write == I2C_SMBUS_WRITE) || (size == ALI1535_QUICK)) { 427 if ((read_write == I2C_SMBUS_WRITE) || (size == ALI1535_QUICK)) {
430 result = 0; 428 result = 0;