i2c-algo-bit: Complain about masters which can't read SCL
PATCH 2/2 i2c-algo-bit: Complain about masters which can't read SCL
The I2C specification explicitly describes both SDA and SCL as bidirectional lines. An I2C master with a read-only SCL is thus not compliant. If a slow slave stretches the clock, errors will happen, so the bus can't be considered as reliable.
--- drivers/i2c/algos/i2c-algo-bit.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/i2c/algos/i2c-algo-bit.c +12 -2
@@ -604,9 +604,10 @@ static int __i2c_bit_add_bus(struct i2c_ int (*add_adapter)(struct i2c_adapter *)) {struct i2c_algo_bit_data *bit_adap = adap->algo_data; +int ret;if (bit_test) { -int ret =test_bus (bit_adap, adap->name); + ret =test_bus (bit_adap, adap->name);if (ret <0 )return -ENODEV ; }
@@ -615,7 +616,16 @@ static int __i2c_bit_add_bus(struct i2c_ adap->algo = &i2c_bit_algo; adap->retries =3 ; -return add_adapter (adap); + ret =add_adapter (adap); +if (ret <0 ) +return ret; + +/* Complain if SCL can't be read */ +if (bit_adap->getscl ==NULL ) { +dev_warn (&adap->dev,"Not I2C compliant: can't read SCL\n" ); +dev_warn (&adap->dev,"Bus may be unreliable\n" ); + } +return 0 ; }int i2c_bit_add_bus (struct i2c_adapter *adap)
Signature · 1 line
Jean Delvare
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 26 lines · Jean Delvare
The I2C specification explicitly describes both SDA and SCL as bidirectional lines. An I2C master with a read-only SCL is thus not compliant. If a slow slave stretches the clock, errors will happen, so the bus can't be considered as reliable.
Signed-off-by Jean Delvare <[email protected]>--- drivers/i2c/algos/i2c-algo-bit.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)drivers/i2c/algos/i2c-algo-bit.c +2
-1@@ -604,9 +604,10 @@ static int __i2c_bit_add_bus(struct i2c_ int (*add_adapter)(struct i2c_adapter *)) {struct i2c_algo_bit_data *bit_adap = adap->algo_data; +int ret;if (bit_test) { -int ret =test_bus (bit_adap, adap->name); + ret =test_bus (bit_adap, adap->name);if (ret <0 )return -ENODEV ; }@@ -615,7 +616,16 @@ static int __i2c_bit_add_bus(struct i2c_ adap->algo = &i2c_bit_algo;
drivers/i2c/algos/i2c-algo-bit.c static int __i2c_bit_add_bus(struct i2c_ · line 625
Quoted 10 lines
drivers/i2c/algos/i2c-algo-bit.c +7
-1adap->retries =3 ; -return add_adapter (adap); + ret =add_adapter (adap); +if (ret <0 ) +return ret; + +/* Complain if SCL can't be read */ +if (bit_adap->getscl ==NULL ) { +dev_warn (&adap->dev,"Not I2C compliant: can't read SCL\n" );
I'll have a think about wording. I might be able to improve it.
As a note, I always prefer cannot to can't.
drivers/i2c/algos/i2c-algo-bit.c static int __i2c_bit_add_bus(struct i2c_ · line 626
Quoted 1 line
drivers/i2c/algos/i2c-algo-bit.c +1
-0+dev_warn (&adap->dev,"Bus may be unreliable\n" );
if there are any other warnings, should we print just one unreliable warning at the end of the scan?
Signature · 4 lines
Ben Q: What's a light-year? A: One-third less calories than a regular year.
A message that is not in the archive (sent off-list or not yet received): 20101207115325.GN20097-SMNkleLxa3Z6Wcw2j4pizdi2O/[email protected]
Hi Ben,
Quoted 40 lines · Ben Dooks
Quoted 26 lines · Jean Delvare
The I2C specification explicitly describes both SDA and SCL as bidirectional lines. An I2C master with a read-only SCL is thus not compliant. If a slow slave stretches the clock, errors will happen, so the bus can't be considered as reliable.
Signed-off-by Jean Delvare <[email protected]>--- drivers/i2c/algos/i2c-algo-bit.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)drivers/i2c/algos/i2c-algo-bit.c +2
-1@@ -604,9 +604,10 @@ static int __i2c_bit_add_bus(struct i2c_ int (*add_adapter)(struct i2c_adapter *)) {struct i2c_algo_bit_data *bit_adap = adap->algo_data; +int ret;if (bit_test) { -int ret =test_bus (bit_adap, adap->name); + ret =test_bus (bit_adap, adap->name);if (ret <0 )return -ENODEV ; }@@ -615,7 +616,16 @@ static int __i2c_bit_add_bus(struct i2c_ adap->algo = &i2c_bit_algo;drivers/i2c/algos/i2c-algo-bit.c static int __i2c_bit_add_bus(struct i2c_ · line 625
Quoted 10 lines
drivers/i2c/algos/i2c-algo-bit.c +7
-1adap->retries =3 ; -return add_adapter (adap); + ret =add_adapter (adap); +if (ret <0 ) +return ret; + +/* Complain if SCL can't be read */ +if (bit_adap->getscl ==NULL ) { +dev_warn (&adap->dev,"Not I2C compliant: can't read SCL\n" );I'll have a think about wording. I might be able to improve it.
Quoted 1 line
As a note, I always prefer cannot to can't.
And I thought you were a busy developer ;)
There is no trend one way or another, neither in the kernel tree nor even in drivers/i2c specifically.
Quoted 4 lines
drivers/i2c/algos/i2c-algo-bit.c static int __i2c_bit_add_bus(struct i2c_ · line 626
Quoted 1 line
drivers/i2c/algos/i2c-algo-bit.c +1
-0+dev_warn (&adap->dev,"Bus may be unreliable\n" );if there are any other warnings, should we print just one unreliable warning at the end of the scan?
I'm not sure what "scan" you refer to, and in all honesty I'm not sure I get your point at all.
Signature · 1 line
Jean Delvare
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 9 lines · Jean Delvare
Hi Ben,
Quoted 5 lines · Ben Dooks
Quoted 4 lines · Jean Delvare
The I2C specification explicitly describes both SDA and SCL as bidirectional lines. An I2C master with a read-only SCL is thus not compliant. If a slow slave stretches the clock, errors will happen, so the bus can't be considered as reliable.
Quoted 8 lines
Quoted 6 lines
drivers/i2c/algos/i2c-algo-bit.c static int __i2c_bit_add_bus(struct i2c_ · line 625
Quoted 2 lines
drivers/i2c/algos/i2c-algo-bit.c +2
-0+if (bit_adap->getscl ==NULL ) { +dev_warn (&adap->dev,"Not I2C compliant: can't read SCL\n" );I'll have a think about wording. I might be able to improve it.
As a note, I always prefer cannot to can't.
And I thought you were a busy developer ;)
I've my reasons for this, blame my parents.
Quoted 2 lines
There is no trend one way or another, neither in the kernel tree nor even in
drivers/i2cspecifically.
no, just my preference.
Quoted 7 lines
Quoted 4 lines
drivers/i2c/algos/i2c-algo-bit.c static int __i2c_bit_add_bus(struct i2c_ · line 626
Quoted 1 line
drivers/i2c/algos/i2c-algo-bit.c +1
-0+dev_warn (&adap->dev,"Bus may be unreliable\n" );if there are any other warnings, should we print just one unreliable warning at the end of the scan?
I'm not sure what "scan" you refer to, and in all honesty I'm not sure I get your point at all.
ok, looking at the code it isn't important.
Signature · 4 lines
Ben Q: What's a light-year? A: One-third less calories than a regular year.
Quoted 6 lines · Jean Delvare
The I2C specification explicitly describes both SDA and SCL as bidirectional lines. An I2C master with a read-only SCL is thus not compliant. If a slow slave stretches the clock, errors will happen, so the bus can't be considered as reliable.
Signed-off-by Jean Delvare <[email protected]>
It'd be good to also flag this via sysfs so that it's more readily visible to things like diagnostic tools.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 10 lines · Mark Brown
Quoted 6 lines · Jean Delvare
The I2C specification explicitly describes both SDA and SCL as bidirectional lines. An I2C master with a read-only SCL is thus not compliant. If a slow slave stretches the clock, errors will happen, so the bus can't be considered as reliable.
Signed-off-by Jean Delvare <[email protected]>It'd be good to also flag this via sysfs so that it's more readily visible to things like diagnostic tools.
Could be, I wonder how many other hardware based adapters just don't do this. Quite a few devices i've seen don't use it as they're generally fast enough, or implement some other status polling system.
Signature · 4 lines
Ben Q: What's a light-year? A: One-third less calories than a regular year.
A message that is not in the archive (sent off-list or not yet received): 20101207123011.GO20097-SMNkleLxa3Z6Wcw2j4pizdi2O/[email protected]
Hi Marc, Ben,
Quoted 11 lines · Ben Dooks
Quoted 10 lines · Mark Brown
Quoted 6 lines · Jean Delvare
The I2C specification explicitly describes both SDA and SCL as bidirectional lines. An I2C master with a read-only SCL is thus not compliant. If a slow slave stretches the clock, errors will happen, so the bus can't be considered as reliable.
Signed-off-by Jean Delvare <[email protected]>It'd be good to also flag this via sysfs so that it's more readily visible to things like diagnostic tools.
In what form do you expect this, and what do you expect diagnostic tools to do about it?
I can't think of anything straightforward and useful. We could abuse one functionality flag for unreliable masters, but then this is a boolean flag, with no way to report the actual problem to the customer. And write-only SCL is only one thing they can do wrongly.
Quoted 3 lines
Could be, I wonder how many other hardware based adapters just don't do this. Quite a few devices i've seen don't use it as they're generally fast enough, or implement some other status polling system.
I don't know either, and I didn't mean to provide a general solution to this problem as I have no clue so far that a general problem exists. This patch is in response to the thread started by Matthias Zacharias where we were troubleshooting his I2C bus problems. I just wanted to make sure that the same problem doesn't happen again, i.e. developers don't set getscl to NULL in the hope that it will help in any way.
I don't know of that many pieces of hardware driven by i2c-algo-bit and not having a bidirectional SCL line. In fact I only know of the i2c-parport, i2c-parport-light and i2c-gpio drivers doing this, and then again, only for some of the supported devices. So I'm not sure there is much point in spending a lot of time on this.
Or, to make it clearer, you can spend as much time as _you_ want on this, but I won't. I'm busy enough as is.
Signature · 1 line
Jean Delvare
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 1 line · Jean Delvare
Hi Marc, Ben,
Ahem.
Quoted 6 lines
Quoted 4 lines · Mark Brown
Quoted 3 lines
It'd be good to also flag this via sysfs so that it's more readily visible to things like diagnostic tools.
In what form do you expect this, and what do you expect diagnostic
A sysfs file that got created if the issue is present, or a warnings file that read back a set of values as a bitmask.
Quoted 1 line
tools to do about it?
Report it - it'd increase the chances of us finding out about the error. A message in dmesg will often just be lost in the noise, and may be long gone before the users tarts doing diagnostics.
Quoted 15 lines · Jean Delvare
Hi Marc, Ben,
Quoted 11 lines · Ben Dooks
Quoted 10 lines · Mark Brown
Quoted 6 lines · Jean Delvare
The I2C specification explicitly describes both SDA and SCL as bidirectional lines. An I2C master with a read-only SCL is thus not compliant. If a slow slave stretches the clock, errors will happen, so the bus can't be considered as reliable.
Signed-off-by Jean Delvare <[email protected]>It'd be good to also flag this via sysfs so that it's more readily visible to things like diagnostic tools.
Quoted 7 lines
In what form do you expect this, and what do you expect diagnostic tools to do about it?
I can't think of anything straightforward and useful. We could abuse one functionality flag for unreliable masters, but then this is a boolean flag, with no way to report the actual problem to the customer. And write-only SCL is only one thing they can do wrongly.
Hmm, something to think about.
Quoted 10 lines
Quoted 3 lines
Could be, I wonder how many other hardware based adapters just don't do this. Quite a few devices i've seen don't use it as they're generally fast enough, or implement some other status polling system.
I don't know either, and I didn't mean to provide a general solution to this problem as I have no clue so far that a general problem exists. This patch is in response to the thread started by Matthias Zacharias where we were troubleshooting his I2C bus problems. I just wanted to make sure that the same problem doesn't happen again, i.e. developers don't set getscl to NULL in the hope that it will help in any way.
yes, sounds good.
Quoted 5 lines
I don't know of that many pieces of hardware driven by i2c-algo-bit and not having a bidirectional SCL line. In fact I only know of the i2c-parport, i2c-parport-light and i2c-gpio drivers doing this, and then again, only for some of the supported devices. So I'm not sure there is much point in spending a lot of time on this.
I was talking all hardware, not just ones integrated with this specific driver. Not to worry, this is just rambling on.
Signature · 4 lines
Ben Q: What's a light-year? A: One-third less calories than a regular year.