aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-piix4.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-piix4.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-piix4.c')
-rw-r--r--drivers/i2c/busses/i2c-piix4.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index ac9165968587..dc76c0e2dc65 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -253,7 +253,7 @@ static int piix4_transaction(void)
253 outb_p(temp, SMBHSTSTS); 253 outb_p(temp, SMBHSTSTS);
254 if ((temp = inb_p(SMBHSTSTS)) != 0x00) { 254 if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
255 dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp); 255 dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp);
256 return -1; 256 return -EBUSY;
257 } else { 257 } else {
258 dev_dbg(&piix4_adapter.dev, "Successful!\n"); 258 dev_dbg(&piix4_adapter.dev, "Successful!\n");
259 } 259 }
@@ -275,23 +275,23 @@ static int piix4_transaction(void)
275 /* If the SMBus is still busy, we give up */ 275 /* If the SMBus is still busy, we give up */
276 if (timeout >= MAX_TIMEOUT) { 276 if (timeout >= MAX_TIMEOUT) {
277 dev_err(&piix4_adapter.dev, "SMBus Timeout!\n"); 277 dev_err(&piix4_adapter.dev, "SMBus Timeout!\n");
278 result = -1; 278 result = -ETIMEDOUT;
279 } 279 }
280 280
281 if (temp & 0x10) { 281 if (temp & 0x10) {
282 result = -1; 282 result = -EIO;
283 dev_err(&piix4_adapter.dev, "Error: Failed bus transaction\n"); 283 dev_err(&piix4_adapter.dev, "Error: Failed bus transaction\n");
284 } 284 }
285 285
286 if (temp & 0x08) { 286 if (temp & 0x08) {
287 result = -1; 287 result = -EIO;
288 dev_dbg(&piix4_adapter.dev, "Bus collision! SMBus may be " 288 dev_dbg(&piix4_adapter.dev, "Bus collision! SMBus may be "
289 "locked until next hard reset. (sorry!)\n"); 289 "locked until next hard reset. (sorry!)\n");
290 /* Clock stops and slave is stuck in mid-transmission */ 290 /* Clock stops and slave is stuck in mid-transmission */
291 } 291 }
292 292
293 if (temp & 0x04) { 293 if (temp & 0x04) {
294 result = -1; 294 result = -ENXIO;
295 dev_dbg(&piix4_adapter.dev, "Error: no response!\n"); 295 dev_dbg(&piix4_adapter.dev, "Error: no response!\n");
296 } 296 }
297 297
@@ -309,17 +309,18 @@ static int piix4_transaction(void)
309 return result; 309 return result;
310} 310}
311 311
312/* Return -1 on error. */ 312/* Return negative errno on error. */
313static s32 piix4_access(struct i2c_adapter * adap, u16 addr, 313static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
314 unsigned short flags, char read_write, 314 unsigned short flags, char read_write,
315 u8 command, int size, union i2c_smbus_data * data) 315 u8 command, int size, union i2c_smbus_data * data)
316{ 316{
317 int i, len; 317 int i, len;
318 int status;
318 319
319 switch (size) { 320 switch (size) {
320 case I2C_SMBUS_PROC_CALL: 321 case I2C_SMBUS_PROC_CALL:
321 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n"); 322 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
322 return -1; 323 return -EOPNOTSUPP;
323 case I2C_SMBUS_QUICK: 324 case I2C_SMBUS_QUICK:
324 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), 325 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
325 SMBHSTADD); 326 SMBHSTADD);
@@ -371,8 +372,9 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
371 372
372 outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT); 373 outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT);
373 374
374 if (piix4_transaction()) /* Error in transaction */ 375 status = piix4_transaction();
375 return -1; 376 if (status)
377 return status;
376 378
377 if ((read_write == I2C_SMBUS_WRITE) || (size == PIIX4_QUICK)) 379 if ((read_write == I2C_SMBUS_WRITE) || (size == PIIX4_QUICK))
378 return 0; 380 return 0;