diff options
Diffstat (limited to 'drivers/i2c/algos/i2c-algo-bit.c')
-rw-r--r-- | drivers/i2c/algos/i2c-algo-bit.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index d6d58684712b..525c7345fa0b 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c | |||
@@ -47,8 +47,8 @@ | |||
47 | /* ----- global variables --------------------------------------------- */ | 47 | /* ----- global variables --------------------------------------------- */ |
48 | 48 | ||
49 | static int bit_test; /* see if the line-setting functions work */ | 49 | static int bit_test; /* see if the line-setting functions work */ |
50 | module_param(bit_test, bool, 0); | 50 | module_param(bit_test, int, S_IRUGO); |
51 | MODULE_PARM_DESC(bit_test, "Test the lines of the bus to see if it is stuck"); | 51 | MODULE_PARM_DESC(bit_test, "lines testing - 0 off; 1 report; 2 fail if stuck"); |
52 | 52 | ||
53 | #ifdef DEBUG | 53 | #ifdef DEBUG |
54 | static int i2c_debug = 1; | 54 | static int i2c_debug = 1; |
@@ -250,7 +250,9 @@ static int test_bus(struct i2c_adapter *i2c_adap) | |||
250 | sda = getsda(adap); | 250 | sda = getsda(adap); |
251 | scl = (adap->getscl == NULL) ? 1 : getscl(adap); | 251 | scl = (adap->getscl == NULL) ? 1 : getscl(adap); |
252 | if (!scl || !sda) { | 252 | if (!scl || !sda) { |
253 | printk(KERN_WARNING "%s: bus seems to be busy\n", name); | 253 | printk(KERN_WARNING |
254 | "%s: bus seems to be busy (scl=%d, sda=%d)\n", | ||
255 | name, scl, sda); | ||
254 | goto bailout; | 256 | goto bailout; |
255 | } | 257 | } |
256 | 258 | ||
@@ -441,7 +443,7 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) | |||
441 | acknak(i2c_adap, 0); | 443 | acknak(i2c_adap, 0); |
442 | dev_err(&i2c_adap->dev, "readbytes: invalid " | 444 | dev_err(&i2c_adap->dev, "readbytes: invalid " |
443 | "block length (%d)\n", inval); | 445 | "block length (%d)\n", inval); |
444 | return -EREMOTEIO; | 446 | return -EPROTO; |
445 | } | 447 | } |
446 | /* The original count value accounts for the extra | 448 | /* The original count value accounts for the extra |
447 | bytes, that is, either 1 for a regular transaction, | 449 | bytes, that is, either 1 for a regular transaction, |
@@ -470,7 +472,7 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) | |||
470 | * reads, writes as well as 10bit-addresses. | 472 | * reads, writes as well as 10bit-addresses. |
471 | * returns: | 473 | * returns: |
472 | * 0 everything went okay, the chip ack'ed, or IGNORE_NAK flag was set | 474 | * 0 everything went okay, the chip ack'ed, or IGNORE_NAK flag was set |
473 | * -x an error occurred (like: -EREMOTEIO if the device did not answer, or | 475 | * -x an error occurred (like: -ENXIO if the device did not answer, or |
474 | * -ETIMEDOUT, for example if the lines are stuck...) | 476 | * -ETIMEDOUT, for example if the lines are stuck...) |
475 | */ | 477 | */ |
476 | static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) | 478 | static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) |
@@ -486,21 +488,21 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) | |||
486 | 488 | ||
487 | if (flags & I2C_M_TEN) { | 489 | if (flags & I2C_M_TEN) { |
488 | /* a ten bit address */ | 490 | /* a ten bit address */ |
489 | addr = 0xf0 | ((msg->addr >> 7) & 0x03); | 491 | addr = 0xf0 | ((msg->addr >> 7) & 0x06); |
490 | bit_dbg(2, &i2c_adap->dev, "addr0: %d\n", addr); | 492 | bit_dbg(2, &i2c_adap->dev, "addr0: %d\n", addr); |
491 | /* try extended address code...*/ | 493 | /* try extended address code...*/ |
492 | ret = try_address(i2c_adap, addr, retries); | 494 | ret = try_address(i2c_adap, addr, retries); |
493 | if ((ret != 1) && !nak_ok) { | 495 | if ((ret != 1) && !nak_ok) { |
494 | dev_err(&i2c_adap->dev, | 496 | dev_err(&i2c_adap->dev, |
495 | "died at extended address code\n"); | 497 | "died at extended address code\n"); |
496 | return -EREMOTEIO; | 498 | return -ENXIO; |
497 | } | 499 | } |
498 | /* the remaining 8 bit address */ | 500 | /* the remaining 8 bit address */ |
499 | ret = i2c_outb(i2c_adap, msg->addr & 0x7f); | 501 | ret = i2c_outb(i2c_adap, msg->addr & 0xff); |
500 | if ((ret != 1) && !nak_ok) { | 502 | if ((ret != 1) && !nak_ok) { |
501 | /* the chip did not ack / xmission error occurred */ | 503 | /* the chip did not ack / xmission error occurred */ |
502 | dev_err(&i2c_adap->dev, "died at 2nd address code\n"); | 504 | dev_err(&i2c_adap->dev, "died at 2nd address code\n"); |
503 | return -EREMOTEIO; | 505 | return -ENXIO; |
504 | } | 506 | } |
505 | if (flags & I2C_M_RD) { | 507 | if (flags & I2C_M_RD) { |
506 | bit_dbg(3, &i2c_adap->dev, "emitting repeated " | 508 | bit_dbg(3, &i2c_adap->dev, "emitting repeated " |
@@ -512,7 +514,7 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) | |||
512 | if ((ret != 1) && !nak_ok) { | 514 | if ((ret != 1) && !nak_ok) { |
513 | dev_err(&i2c_adap->dev, | 515 | dev_err(&i2c_adap->dev, |
514 | "died at repeated address code\n"); | 516 | "died at repeated address code\n"); |
515 | return -EREMOTEIO; | 517 | return -EIO; |
516 | } | 518 | } |
517 | } | 519 | } |
518 | } else { /* normal 7bit address */ | 520 | } else { /* normal 7bit address */ |
@@ -570,7 +572,7 @@ static int bit_xfer(struct i2c_adapter *i2c_adap, | |||
570 | ret, ret == 1 ? "" : "s"); | 572 | ret, ret == 1 ? "" : "s"); |
571 | if (ret < pmsg->len) { | 573 | if (ret < pmsg->len) { |
572 | if (ret >= 0) | 574 | if (ret >= 0) |
573 | ret = -EREMOTEIO; | 575 | ret = -EIO; |
574 | goto bailout; | 576 | goto bailout; |
575 | } | 577 | } |
576 | } else { | 578 | } else { |
@@ -581,7 +583,7 @@ static int bit_xfer(struct i2c_adapter *i2c_adap, | |||
581 | ret, ret == 1 ? "" : "s"); | 583 | ret, ret == 1 ? "" : "s"); |
582 | if (ret < pmsg->len) { | 584 | if (ret < pmsg->len) { |
583 | if (ret >= 0) | 585 | if (ret >= 0) |
584 | ret = -EREMOTEIO; | 586 | ret = -EIO; |
585 | goto bailout; | 587 | goto bailout; |
586 | } | 588 | } |
587 | } | 589 | } |
@@ -624,7 +626,7 @@ static int __i2c_bit_add_bus(struct i2c_adapter *adap, | |||
624 | 626 | ||
625 | if (bit_test) { | 627 | if (bit_test) { |
626 | ret = test_bus(adap); | 628 | ret = test_bus(adap); |
627 | if (ret < 0) | 629 | if (bit_test >= 2 && ret < 0) |
628 | return -ENODEV; | 630 | return -ENODEV; |
629 | } | 631 | } |
630 | 632 | ||