Skip to contentSkip to conversation

i2c bus classes in 2.6

DISCUSSION Jean Delvare 3 participants 4 messages May 19, 2005

lore
Share & tools
lore
#0 lore raw

Hi Greg,

Shouldn't all bus drivers under linux-2.6.0/drivers/i2c/busses have at least one class defined? Most of them (19 out of 31) do not, which makes them useless if my undertanding is correct. Or at least sensor chips are not detected on them (I experienced this a few minutes ago and it took me a while to figure out why). If you tell me what the general policy about classes is, I volunteer to write and submit the (trivial) patch to fixe all the bus drivers.

Thanks.

Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
#1 lore raw
Quoted 5 lines · Jean Delvare

Hi Greg,

Shouldn't all bus drivers under linux-2.6.0/drivers/i2c/busses have at least one class defined? Most of them (19 out of 31) do not, which makes them useless if my undertanding is correct.

Not at all. Chip drivers only seem to test for I2C_ADAP_CLASS_SMBUS, right? And I really think that we don't need that check either, but haven't played around with it much.

Quoted 2 lines

Or at least sensor chips are not detected on them (I experienced this a few minutes ago and it took me a while to figure out why).

What bus driver doesn't specify this? Why was a sensor chip not being detected? The SMBUS check in the chip driver?

Quoted 2 lines

If you tell me what the general policy about classes is, I volunteer to write and submit the (trivial) patch to fixe all the bus drivers.

I don't think it's really needed at first glance, but I could be wrong :)

Anyone else have an opinion?

thanks,

greg k-h

#2 lore raw
In reply to Jean Delvare
Quoted 5 lines
Quoted 2 lines

Or at least sensor chips are not detected on them (I experienced this a few minutes ago and it took me a while to figure out why).

What bus driver doesn't specify this? Why was a sensor chip not being detected? The SMBUS check in the chip driver?

My new i2c-parport driver(s) ;) But the older ones (i2c-philips-par, i2c-elv and i2c-velleman) don't specify any class either.

The sensor chip not being detected was the ADM1032 of my evaluation board (lm90 driver, port in progress). I copied the I2C_ADAP_CLASS_SMBUS check from lm83, where in turn I had copied it from lm78. All chip drivers but eeprom do have the check.

I think I remember that Ky?sti was quite interested in classes because it would let us ignore non-SMBus adapters in sensors. Not sure how great it is however, since actually we should look for specific chips, not specific adapters.

I don't see any problem using these classes as long as it is done consistently, and that adapters that are missing their class definition are given one where needed. This could help prevent misdetections (most chip drivers already defend themselves against that, but chips such as the LM75 or the LM80 are rather hard to detect) and help user-space programs as underlined above.

OTOH, we definitely can live without them, as we used to. And this will require a little bit more work from us and others.

Do we all agree that setting classes for an adapter is more or less arbitrary? To me, it is more of "it was noticed that this adapter usually has this kind of devices attached" than of "this adapter could not have devices of other kinds attached, ever". So it is a hint and a misdetection preventer, not an absolute truth.

Additional comments anyone?

Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
#3 lore raw
In reply to Jean Delvare
Quoted 4 lines · Jean Delvare

I think I remember that Ky?sti was quite interested in classes because it would let us ignore non-SMBus adapters in sensors. Not sure how great it is however, since actually we should look for specific chips, not specific adapters.

I was referring to a class_device in the driver-model. Registering a sensor as a class device would at minimum create symbolic links to sensor chips in a common directory under sysfs, no matter which hw bus implementation they have.

The class test with adapter and driver is something different. I don't know where this part of the code came from but the purpose seems clear, to prevent, eg. tuner driver unintentionally probing on an SMBus clock generator.

A related issue is i2c_clients_command. For every client on an adapter, it calls client->driver->command(client, cmd, data) if specified. This blindly assumes a global enumeration of cmd, which is not true.

Signature · 1 line
  Ky?sti M?lkki  <[email protected]>