diff options
author | David Brownell <david-b@pacbell.net> | 2008-07-14 16:38:25 -0400 |
---|---|---|
committer | Jean Delvare <khali@mahadeva.delvare> | 2008-07-14 16:38:25 -0400 |
commit | 97140342e69d479a3ad82bfd4c154c0b08fe3eea (patch) | |
tree | 2ee2ad225c7e4850a30bc57c4bf07251c1da1085 /drivers/i2c/busses/i2c-ali15x3.c | |
parent | 6ea438ec8da4ec56bf415f5ea360e6b0cb59c6c3 (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-ali15x3.c')
-rw-r--r-- | drivers/i2c/busses/i2c-ali15x3.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c index 93bf87d70961..3d752561dc37 100644 --- a/drivers/i2c/busses/i2c-ali15x3.c +++ b/drivers/i2c/busses/i2c-ali15x3.c | |||
@@ -282,7 +282,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap) | |||
282 | dev_err(&adap->dev, "SMBus reset failed! (0x%02x) - " | 282 | dev_err(&adap->dev, "SMBus reset failed! (0x%02x) - " |
283 | "controller or device on bus is probably hung\n", | 283 | "controller or device on bus is probably hung\n", |
284 | temp); | 284 | temp); |
285 | return -1; | 285 | return -EBUSY; |
286 | } | 286 | } |
287 | } else { | 287 | } else { |
288 | /* check and clear done bit */ | 288 | /* check and clear done bit */ |
@@ -304,12 +304,12 @@ static int ali15x3_transaction(struct i2c_adapter *adap) | |||
304 | 304 | ||
305 | /* If the SMBus is still busy, we give up */ | 305 | /* If the SMBus is still busy, we give up */ |
306 | if (timeout >= MAX_TIMEOUT) { | 306 | if (timeout >= MAX_TIMEOUT) { |
307 | result = -1; | 307 | result = -ETIMEDOUT; |
308 | dev_err(&adap->dev, "SMBus Timeout!\n"); | 308 | dev_err(&adap->dev, "SMBus Timeout!\n"); |
309 | } | 309 | } |
310 | 310 | ||
311 | if (temp & ALI15X3_STS_TERM) { | 311 | if (temp & ALI15X3_STS_TERM) { |
312 | result = -1; | 312 | result = -EIO; |
313 | dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); | 313 | dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); |
314 | } | 314 | } |
315 | 315 | ||
@@ -320,7 +320,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap) | |||
320 | This means that bus collisions go unreported. | 320 | This means that bus collisions go unreported. |
321 | */ | 321 | */ |
322 | if (temp & ALI15X3_STS_COLL) { | 322 | if (temp & ALI15X3_STS_COLL) { |
323 | result = -1; | 323 | result = -ENXIO; |
324 | dev_dbg(&adap->dev, | 324 | dev_dbg(&adap->dev, |
325 | "Error: no response or bus collision ADD=%02x\n", | 325 | "Error: no response or bus collision ADD=%02x\n", |
326 | inb_p(SMBHSTADD)); | 326 | inb_p(SMBHSTADD)); |
@@ -328,7 +328,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap) | |||
328 | 328 | ||
329 | /* haven't ever seen this */ | 329 | /* haven't ever seen this */ |
330 | if (temp & ALI15X3_STS_DEV) { | 330 | if (temp & ALI15X3_STS_DEV) { |
331 | result = -1; | 331 | result = -EIO; |
332 | dev_err(&adap->dev, "Error: device error\n"); | 332 | dev_err(&adap->dev, "Error: device error\n"); |
333 | } | 333 | } |
334 | dev_dbg(&adap->dev, "Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, " | 334 | dev_dbg(&adap->dev, "Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, " |
@@ -338,7 +338,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap) | |||
338 | return result; | 338 | return result; |
339 | } | 339 | } |
340 | 340 | ||
341 | /* Return -1 on error. */ | 341 | /* Return negative errno on error. */ |
342 | static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, | 342 | static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, |
343 | unsigned short flags, char read_write, u8 command, | 343 | unsigned short flags, char read_write, u8 command, |
344 | int size, union i2c_smbus_data * data) | 344 | int size, union i2c_smbus_data * data) |
@@ -364,7 +364,7 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, | |||
364 | switch (size) { | 364 | switch (size) { |
365 | case I2C_SMBUS_PROC_CALL: | 365 | case I2C_SMBUS_PROC_CALL: |
366 | dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n"); | 366 | dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n"); |
367 | return -1; | 367 | return -EOPNOTSUPP; |
368 | case I2C_SMBUS_QUICK: | 368 | case I2C_SMBUS_QUICK: |
369 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), | 369 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), |
370 | SMBHSTADD); | 370 | SMBHSTADD); |
@@ -421,8 +421,9 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, | |||
421 | 421 | ||
422 | outb_p(size, SMBHSTCNT); /* output command */ | 422 | outb_p(size, SMBHSTCNT); /* output command */ |
423 | 423 | ||
424 | if (ali15x3_transaction(adap)) /* Error in transaction */ | 424 | temp = ali15x3_transaction(adap); |
425 | return -1; | 425 | if (temp) |
426 | return temp; | ||
426 | 427 | ||
427 | if ((read_write == I2C_SMBUS_WRITE) || (size == ALI15X3_QUICK)) | 428 | if ((read_write == I2C_SMBUS_WRITE) || (size == ALI15X3_QUICK)) |
428 | return 0; | 429 | return 0; |