47
47
/* ----- global variables --------------------------------------------- */
48
48
49
49
static int bit_test ; /* see if the line-setting functions work */
50
- module_param (bit_test , bool , 0 );
51
- MODULE_PARM_DESC (bit_test , "Test the lines of the bus to see if it is stuck" );
50
+ module_param (bit_test , int , S_IRUGO );
51
+ MODULE_PARM_DESC (bit_test , "lines testing - 0 off; 1 report; 2 fail if stuck" );
52
52
53
53
#ifdef DEBUG
54
54
static int i2c_debug = 1 ;
@@ -250,7 +250,9 @@ static int test_bus(struct i2c_adapter *i2c_adap)
250
250
sda = getsda (adap );
251
251
scl = (adap -> getscl == NULL ) ? 1 : getscl (adap );
252
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
256
goto bailout ;
255
257
}
256
258
@@ -441,7 +443,7 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
441
443
acknak (i2c_adap , 0 );
442
444
dev_err (& i2c_adap -> dev , "readbytes: invalid "
443
445
"block length (%d)\n" , inval );
444
- return - EREMOTEIO ;
446
+ return - EPROTO ;
445
447
}
446
448
/* The original count value accounts for the extra
447
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
472
* reads, writes as well as 10bit-addresses.
471
473
* returns:
472
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
476
* -ETIMEDOUT, for example if the lines are stuck...)
475
477
*/
476
478
static int bit_doAddress (struct i2c_adapter * i2c_adap , struct i2c_msg * msg )
@@ -493,14 +495,14 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
493
495
if ((ret != 1 ) && !nak_ok ) {
494
496
dev_err (& i2c_adap -> dev ,
495
497
"died at extended address code\n" );
496
- return - EREMOTEIO ;
498
+ return - ENXIO ;
497
499
}
498
500
/* the remaining 8 bit address */
499
501
ret = i2c_outb (i2c_adap , msg -> addr & 0x7f );
500
502
if ((ret != 1 ) && !nak_ok ) {
501
503
/* the chip did not ack / xmission error occurred */
502
504
dev_err (& i2c_adap -> dev , "died at 2nd address code\n" );
503
- return - EREMOTEIO ;
505
+ return - ENXIO ;
504
506
}
505
507
if (flags & I2C_M_RD ) {
506
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
514
if ((ret != 1 ) && !nak_ok ) {
513
515
dev_err (& i2c_adap -> dev ,
514
516
"died at repeated address code\n" );
515
- return - EREMOTEIO ;
517
+ return - EIO ;
516
518
}
517
519
}
518
520
} else { /* normal 7bit address */
@@ -570,7 +572,7 @@ static int bit_xfer(struct i2c_adapter *i2c_adap,
570
572
ret , ret == 1 ? "" : "s" );
571
573
if (ret < pmsg -> len ) {
572
574
if (ret >= 0 )
573
- ret = - EREMOTEIO ;
575
+ ret = - EIO ;
574
576
goto bailout ;
575
577
}
576
578
} else {
@@ -581,7 +583,7 @@ static int bit_xfer(struct i2c_adapter *i2c_adap,
581
583
ret , ret == 1 ? "" : "s" );
582
584
if (ret < pmsg -> len ) {
583
585
if (ret >= 0 )
584
- ret = - EREMOTEIO ;
586
+ ret = - EIO ;
585
587
goto bailout ;
586
588
}
587
589
}
@@ -624,7 +626,7 @@ static int __i2c_bit_add_bus(struct i2c_adapter *adap,
624
626
625
627
if (bit_test ) {
626
628
ret = test_bus (adap );
627
- if (ret < 0 )
629
+ if (bit_test >= 2 && ret < 0 )
628
630
return - ENODEV ;
629
631
}
630
632
0 commit comments