i2c adapters class
Hi Greg, all,
I noticed just today that a number of bus drivers in Linux 2.6.3 are mostly useless, because they do not define their class to I2C_ADAP_CLASS_SMBUS. This was the cause of sensors ticket 1501 problem, as well as a recent report on the mailing-list (same motherboard -> same bus driver: i2c-ali1535).
The list of bus drivers with no class defined is:i2c-ali1535.ci2c-elektor.ci2c-elv.ci2c-frodo.ci2c-hydra.ci2c-i810.ci2c-ibm_iic.ci2c-iop3xx.ci2c-ite.ci2c-keywest.ci2c-philips-par.ci2c-prosavage.ci2c-rpx.ci2c-savage4.ci2c-sis5595.ci2c-velleman.ci2c-via.ci2c-voodoo3.cscx200_acb.cscx200_i2c.c
I guess that the video card adapters don't want I2C_ADAP_CLASS_SMBUS:
i2c-i810.ci2c-prosavage.ci2c-savage4.ci2c-voodoo3.c
But at least these have to use it:
i2c-ali1535.ci2c-sis5595.ci2c-via.c
For the rest of them, I don't know.
This raises the following question: what are these classes really for?
So far, all sensor chip drivers, except lm85, do check for I2C_ADAP_CLASS_SMBUS.
If they are the list of chip types that can be present on each bus, they we really want to fill all the bus drivers according to what we know about them. One benefit I can see is limiting the risks of misdetection.
If this is more informative than anything else, and isn't supposed to be stricly filled, then we should not make chip drivers check it.
As soon as I know what we are supposed to do, I'll prepare a patch in that sense.
Thanks.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Greg,
Please accept this temporary fix for the class issue. I'd like users of the i2c-ali1535, i2c-sis5595 and i2c-via driver to be able to use sensors as soon as possible, even if we have not yet determined what our policy WRT classes should be.
Thanks.
BTW, don't you think I2C_ADAP_CLASS_SMBUS is a misnomer? It's about hardware monitoring, not the SMBus protocol. I'd say I2C_ADAP_CLASS_HWMON or I2C_ADAP_CLASS_SENSORS would have been more appropriate (although it may be a bit late for a change...)
drivers/i2c/busses/i2c-ali1535.c +1 -0
@@ -484,6 +484,7 @@static struct i2c_adapter ali1535_adapter = { .owner =THIS_MODULE , + .class =I2C_ADAP_CLASS_SMBUS , .algo = &smbus_algorithm, .name ="unset" , };
drivers/i2c/busses/i2c-sis5595.c +1 -0
@@ -364,6 +364,7 @@static struct i2c_adapter sis5595_adapter = { .owner =THIS_MODULE , + .class =I2C_ADAP_CLASS_SMBUS , .name ="unset" , .algo = &smbus_algorithm, };
drivers/i2c/busses/i2c-via.c +1 -0
@@ -92,6 +92,7 @@static struct i2c_adapter vt586b_adapter = { .owner =THIS_MODULE , + .class =I2C_ADAP_CLASS_SMBUS , .name ="VIA i2c" , .algo_data = &bit_data, };
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Quoted 6 lines · Jean Delvare
Greg,
Please accept this temporary fix for the class issue. I'd like users of the i2c-ali1535, i2c-sis5595 and i2c-via driver to be able to use sensors as soon as possible, even if we have not yet determined what our policy WRT classes should be.
Ok, applied.
Quoted 4 lines
BTW, don't you think
I2C_ADAP_CLASS_SMBUSis a misnomer? It's about hardware monitoring, not the SMBus protocol. I'd sayI2C_ADAP_CLASS_HWMONorI2C_ADAP_CLASS_SENSORSwould have been more appropriate (although it may be a bit late for a change...)
Yeah, it doesn't make the most sense. Care to propose something that does make sense? Or something to just fix this class stuff up all together?
thanks,
greg k-h
Quoted 8 lines
Quoted 4 lines
BTW, don't you think
I2C_ADAP_CLASS_SMBUSis a misnomer? It's about hardware monitoring, not the SMBus protocol. I'd sayI2C_ADAP_CLASS_HWMONorI2C_ADAP_CLASS_SENSORSwould have been more appropriate (although it may be a bit late for a change...)Yeah, it doesn't make the most sense. Care to propose something that does make sense? Or something to just fix this class stuff up all together?
Well, all depends on what we want to do. Renaming I2C_ADAP_CLASS_SMBUS to anything different means breaking compatibility with older code. Maybe people outside of the kernel tree already use this define. At least the rivatv project now does (because of me, admittedly). So basically, the question is: is the change worth a compatibility change.
It's not very difficult to fix for the "user", and supporting both defines looks easy, using something as:
#ifdef I2C_ADAP_CLASS_SMBUS
#ifndef I2C_ADAP_CLASS_SENSORS
#define I2C_ADAP_CLASS_SENSORS I2C_ADAP_CLASS_SMBUS #endif
#endif
at the top of the using code. So the renaming option sounds acceptable.
Another possibility would be to provide both defines for some times. The compatibility work would be the same for the "user", except that it can be postponed to much later (at the time we remove the I2C_ADAP_CLASS_SMBUS define).
Both options are fine with me. No option is also fine to me, we can live with _SMBUS, although it is a bit confusing at first IMHO.
My two proposals for a new name are I2C_ADAP_CLASS_HWMON and I2C_ADAP_CLASS_SENSORS. Either is fine with me too, I don't have any preference. Or any other with a similar meaning.
As for fixing the class problem, again, we need to decide what we want to do. Changing the code is easy after that. My opinion is that classes are a good way to make things clearer and prevent excessive probing of chips, and reduce the risks of misdetection for a limited number of chips too. So defining classes consistently in adapters and checking for them in chips makes sense.
But if anyone objects that it also makes the code slightly more complex and gives a little more work to maintain and support, that's true too. Question here is whether it's worth it or not. I tend to think it is (but no strong opinion here either).
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Quoted 9 lines · Jean Delvare
Quoted 8 lines
Quoted 4 lines
BTW, don't you think
I2C_ADAP_CLASS_SMBUSis a misnomer? It's about hardware monitoring, not the SMBus protocol. I'd sayI2C_ADAP_CLASS_HWMONorI2C_ADAP_CLASS_SENSORSwould have been more appropriate (although it may be a bit late for a change...)Yeah, it doesn't make the most sense. Care to propose something that does make sense? Or something to just fix this class stuff up all together?
Quoted 5 lines
Well, all depends on what we want to do. Renaming
I2C_ADAP_CLASS_SMBUSto anything different means breaking compatibility with older code. Maybe people outside of the kernel tree already use this define. At least the rivatv project now does (because of me, admittedly). So basically, the question is: is the change worth a compatibility change.
I don't care at all about "compatibility changes" as we can fix up all of the in-kernel usages. Anyone trying to keep drivers outside of the main kernel tree deserve the pain that this causes :)
Quoted 10 lines
It's not very difficult to fix for the "user", and supporting both defines looks easy, using something as:
#ifdef
I2C_ADAP_CLASS_SMBUS
#ifndefI2C_ADAP_CLASS_SENSORS
#defineI2C_ADAP_CLASS_SENSORSI2C_ADAP_CLASS_SMBUS#endif
#endifat the top of the using code. So the renaming option sounds acceptable.
Ick, no. Just rename the thing.
Quoted 3 lines
My two proposals for a new name are
I2C_ADAP_CLASS_HWMONandI2C_ADAP_CLASS_SENSORS. Either is fine with me too, I don't have any preference. Or any other with a similar meaning.
But what are these "classes" used for exactly? That was my main question. Does anyone really use them? Can we just delete them altogether?
thanks,
greg k-h
Quoted 10 lines
Quoted 6 lines
Well, all depends on what we want to do. Renaming
I2C_ADAP_CLASS_SMBUSto anything different means breaking compatibility with older code. Maybe people outside of the kernel tree already use this define. At least the rivatv project now does (because of me, admittedly). So basically, the question is: is the change worth a compatibility change.I don't care at all about "compatibility changes" as we can fix up all of the in-kernel usages. Anyone trying to keep drivers outside of the main kernel tree deserve the pain that this causes :)
OK, I take note.
Quoted 9 lines
Quoted 9 lines
It's not very difficult to fix for the "user", and supporting both defines looks easy, using something as:
#ifdef
I2C_ADAP_CLASS_SMBUS
#ifndefI2C_ADAP_CLASS_SENSORS
#defineI2C_ADAP_CLASS_SENSORSI2C_ADAP_CLASS_SMBUS#endif
#endif
Quoted 4 lines
Quoted 2 lines
at the top of the using code. So the renaming option sounds acceptable.
Ick, no. Just rename the thing.
I don't think you got me here. The code snippet above was not meant for in-kernel files. It was simply a suggestion of what "drivers outside of the main kernel tree" could do to support both pre-change and post-change trees. I was just trying to demonstrate that a change would be easily handled by those.
So I guess we in fact agree. Rename it, period :)
Quoted 3 lines
But what are these "classes" used for exactly? That was my main question. Does anyone really use them? Can we just delete them altogether?
Aha. I was expecting you to tell us ;) You are the one who introduced them in the first place, aren't you? If not, we definitely want to contact that person to know what he/she had in mind.
There were no classes concept in our 2.4 drivers, which tends to prove that we can possibly live without them. See my previous posts for my opinion on the topic.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Quoted 11 lines · Jean Delvare
Quoted 3 lines
But what are these "classes" used for exactly? That was my main question. Does anyone really use them? Can we just delete them altogether?
Aha. I was expecting you to tell us ;) You are the one who introduced them in the first place, aren't you? If not, we definitely want to contact that person to know what he/she had in mind.
There were no classes concept in our 2.4 drivers, which tends to prove that we can possibly live without them. See my previous posts for my opinion on the topic.
Ah, in digging through the change log entries I found the following:
ChangeSet 1.1738 2003/05/06 16:41:46 [email protected]
[PATCH] i2c #3/3: add class field to i2c_adapter
This is the last of three patches for i2c. It introduces a new field to i2c_adapter which classifies the kind of hardware a i2c adapter belongs to (analog tv card / dvb card / smbus / gfx card ...). i2c chip drivers can use this infomation to decide whenever they want to look for hardware on that adapter or not. It doesn't make sense to probe for a tv tuner on a smbus for example ...
So this was a video developer's request. Does that help explain it a bit more now?
thanks,
greg k-h
Quoted 4 lines
Ah, in digging through the change log entries I found the following:
(...)
So this was a video developer's request. Does that help explain it a bit more now?
This at leasts explain how it came in here with neither you nor I knowing why.
This also suggests that we should leave classes in place. And if other people use it, we should do as well, for the sake of consistency.
So, from now on, I suggest:
* Renaming I2C_ADAP_CLASS_SMBUS to I2C_ADAP_CLASS_SENSORS (unless someone prefers another name).
* All chip driver check for the bus being of this class.
* All bus driver known to host sensors get this class.
I'll submit a patch doing all that if nobody objects.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Quoted 7 lines · Jean Delvare
Quoted 4 lines
Ah, in digging through the change log entries I found the following:
(...)
So this was a video developer's request. Does that help explain it a bit more now?This at leasts explain how it came in here with neither you nor I knowing why.
Heh, well the patch did go though me to Linus, so I can't claim complete ignorance :)
Quoted 2 lines
This also suggests that we should leave classes in place. And if other people use it, we should do as well, for the sake of consistency.
Agreed.
Quoted 7 lines
So, from now on, I suggest:
* RenamingI2C_ADAP_CLASS_SMBUStoI2C_ADAP_CLASS_SENSORS(unless someone prefers another name).
* All chip driver check for the bus being of this class.
* All bus driver known to host sensors get this class.I'll submit a patch doing all that if nobody objects.
That sounds good to me.
thanks,
greg k-h