Skip to contentSkip to conversation

i2c-algo-bit: Let user test buses without failing

PATCH Superseded Jean Delvare 2 participants 2 messages Oct 4, 2011 1 message not in the archive I2C subsystem host drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 i2c-algo-bit: Let user test buses without failing

Always failing to register I2C buses when the line testing fails is a little harsh. While such a failure is definitely a bug in the driver that exposes the affected I2C bus, things may still work fine if the missing initialization steps are done later, before the I2C bus is used. So it seems a better debugging tool to just report the test failure by default. I introduce bit_test=2 if anyone really misses the original behavior of bit_test=1.

---
 drivers/i2c/algos/i2c-algo-bit.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/algos/i2c-algo-bit.c +3 -3
@@ -47,8 +47,8 @@
 /* ----- global variables ---------------------------------------------	*/
 
 static int bit_test;	/* see if the line-setting functions work	*/
-module_param(bit_test, bool, 0);
-MODULE_PARM_DESC(bit_test, "Test the lines of the bus to see if it is stuck");
+module_param(bit_test, bool, S_IRUGO);
+MODULE_PARM_DESC(bit_test, "lines testing - 0 off; 1 report; 2 fail if stuck");
 
 #ifdef DEBUG
 static int i2c_debug = 1;
@@ -624,7 +624,7 @@ static int __i2c_bit_add_bus(struct i2c_
 
 	if (bit_test) {
 		ret = test_bus(adap);
-		if (ret < 0)
+		if (bit_test >= 2 && ret < 0)
 			return -ENODEV;
 	}
 
Signature · 2 lines
Jean Delvare
Suse L3

A message that is not in the archive (sent off-list or not yet received): [email protected]

Reviewed-by
#2 lore raw
Quoted 10 lines · Jean Delvare

Always failing to register I2C buses when the line testing fails is a little harsh. While such a failure is definitely a bug in the driver that exposes the affected I2C bus, things may still work fine if the missing initialization steps are done later, before the I2C bus is used. So it seems a better debugging tool to just report the test failure by default. I introduce bit_test=2 if anyone really misses the original behavior of bit_test=1.

Quoted 31 lines

---
 drivers/i2c/algos/i2c-algo-bit.c |    6 +++---

 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/algos/i2c-algo-bit.c  2011-10-02 10:29:51.000000000 +0200 renamed from drivers/i2c/algos/i2c-algo-bit.c     2011-07-22 04:17:23.000000000 +0200 +0 -0
@@ -47,8 +47,8 @@
  /* ----- global variables ---------------------------------------------        */
 

 static int bit_test;   /* see if the line-setting functions work       */

drivers/i2c/algos/i2c-algo-bit.c  2011-10-02 10:29:51.000000000 +0200 renamed from drivers/i2c/algos/i2c-algo-bit.c     2011-07-22 04:17:23.000000000 +0200 +2 -2
-module_param(bit_test, bool, 0);
-MODULE_PARM_DESC(bit_test, "Test the lines of the bus to see if it is stuck");
+module_param(bit_test, bool, S_IRUGO);
+MODULE_PARM_DESC(bit_test, "lines testing - 0 off; 1 report; 2 fail if stuck");

 #ifdef DEBUG
 static int i2c_debug = 1;

drivers/i2c/algos/i2c-algo-bit.c  2011-10-02 10:29:51.000000000 +0200 renamed from drivers/i2c/algos/i2c-algo-bit.c     2011-07-22 04:17:23.000000000 +0200 +1 -2
@@ -624,7 +624,7 @@ static int __i2c_bit_add_bus(struct i2c_
 
        if (bit_test) {
                ret = test_bus(adap);
-               if (ret < 0)
+               if (bit_test >= 2 && ret < 0)
                        return -ENODEV;
        }
 
 
--

Jean Delvare
Suse L3