lm_sensors2/prog/dump i2cbusses.c
The 2.6 i2c-dev bus numbers don't necessarily match i2c-adapter bus numbers.
If you rmmod and re-insmod a bus driver, the driver seems to get its old i2c-dev bus number back. But the i2c-adapter number increments. Don't know why. It would be much better if they matched.
Most userspace tools need the i2c-dev numbers since they are going to use /dev/i2c-x devices to access the bus.
The bus numbers reported by libsensors apps are the i2c-adapter numbers. I think it has to be that way since we don't need i2c-dev and therefore can't count on it being installed.
So you can't take a bus number from 'sensors' and then take that number and use it in 'i2cdump', for example.
Quoted 9 lines · [email protected] wrote:
Update of
/home/cvs/lm_sensors2/prog/dump
In directory mordac.netroedge.com:/tmp/cvs-serv14049Modified Files:
i2cbusses.c
Log Message:
(mds) report i2c-dev bus numbers rather than i2c-adapter numbers,
which may be different.
Quoted 9 lines
The 2.6 i2c-dev bus numbers don't necessarily match i2c-adapter bus numbers.
If you rmmod and re-insmod a bus driver, the driver seems to get its old i2c-dev bus number back. But the i2c-adapter number increments. Don't know why. It would be much better if they matched.Most userspace tools need the i2c-dev numbers since they are going to use
/dev/i2c-xdevices to access the bus.
Quoted 6 lines
The bus numbers reported by libsensors apps are the i2c-adapter numbers. I think it has to be that way since we don't need i2c-dev and therefore can't count on it being installed.
So you can't take a bus number from 'sensors' and then take that number and use it in 'i2cdump', for example.
This is odd. Any idea how to correct this? I'm a bit lost, I don't even understand how there can be two values, since it obviously represent the same thing (i.e. a bus identifier).
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Thanks for the explanation. more below.
Quoted 14 lines · Ky?sti M?lkki
Quoted 5 lines · Mark Studebaker
The 2.6 i2c-dev bus numbers don't necessarily match i2c-adapter bus numbers.
If you rmmod and re-insmod a bus driver, the driver seems to get its old i2c-dev bus number back. But the i2c-adapter number increments. Don't know why. It would be much better if they matched.In i2c-dev adapter gets the first empty minor device.
In i2c-core, previously,
adap->nr(bus number) was an index in the array of adapters so it also took the first empty slot.
Quoted 9 lines
In 2.6 the array of adapters in i2c-core has been changed to a list and bus number is now just ever incrementing as you have noticed. The number was pretty dynamic anyway, as it depended of the order adapters were loaded.
IMO, one should point to i2c bus by its parent device. That is, pick the i2c bus behind pci device ABAD:BEEF, the one in parallel port etc, sysfs should have this information.
My main goal in bus numbering was
to list (and number) the installed i2c busses available for probing via i2c-dev.
That's what i2cdetect, i2cdump, and i2cset now do with no arguments, both for 2.4 and 2.6.
The secondary goal, which is difficult (and impossible if i2c-dev is not installed)
is to number the busses the same in the 'sensors' output, so that we can continue to say (as we have for years) after receiving a 'sensors' output
listing
w83781d-i2c-1-2d
Adapter: SMBus ALI15X3 adapter at e800 Algorithm: SMBus algorithm VCore 1: +2.22 V (min = +2.53 V, max = +3.09 V) ALARM VCore 2: +2.22 V (min = +2.53 V, max = +3.09 V) ALARM
+3.3V: +3.54 V (min = +2.98 V, max = +3.63 V)
...
"hey, user, do an 'i2cdump 1 0x2d' and send us the results".
This won't work now because the 'sensors' output currently uses sysfs numbers, not i2c-dev numbers.
So I wanted people to know that.
mds
Quoted 5 lines · Mark Studebaker
The 2.6 i2c-dev bus numbers don't necessarily match i2c-adapter bus numbers.
If you rmmod and re-insmod a bus driver, the driver seems to get its old i2c-dev bus number back. But the i2c-adapter number increments. Don't know why. It would be much better if they matched.
In i2c-dev adapter gets the first empty minor device.
In i2c-core, previously, adap->nr (bus number) was an index in the array of adapters so it also took the first empty slot.
In 2.6 the array of adapters in i2c-core has been changed to a list and bus number is now just ever incrementing as you have noticed. The number was pretty dynamic anyway, as it depended of the order adapters were loaded.
IMO, one should point to i2c bus by its parent device. That is, pick the i2c bus behind pci device ABAD:BEEF, the one in parallel port etc, sysfs should have this information.
Signature · 1 line
Ky?sti M?lkki <[email protected]> +358 50 462 8786
Walk the list of adapters and exit with the smallest unused bus number. Feeling lucky? No 2.6 here yet.
i2c-core-bus-number.c renamed from drivers/i2c/i2c-core.c +14 -2
@@ -122,13 +122,25 @@*/ int i2c_add_adapter (struct i2c_adapter *adap) { -static int nr =0 ; +int used, nr;struct list_head *item;struct i2c_driver *driver; +struct i2c_adapter *adapter;down (&core_lists); - adap->nr = nr++; +for (nr=0 , used=1 ; used ; nr++) { + used =0 ; +list_for_each (item,&adapters) { + adapter = list_entry(item, struct i2c_adapter, list); +if (nr = adapter->nr) { + used =1 ; +break ; + } + } + } + adap->nr = nr; +init_MUTEX (&adap->bus_lock);init_MUTEX (&adap->clist_lock);list_add_tail (&adap->list,&adapters);
Signature · 1 line
Ky?sti M?lkki <[email protected]> +358 50 462 8786
Quoted 5 lines · Mark Studebaker
The 2.6 i2c-dev bus numbers don't necessarily match i2c-adapter bus numbers.
If you rmmod and re-insmod a bus driver, the driver seems to get its old i2c-dev bus number back. But the i2c-adapter number increments. Don't know why. It would be much better if they matched.
Follow the symlink in the i2c-dev sysfs directory to find the adapter it is bound to. That's much easier than trying to match up numbers :)
thanks,
greg k-h
Quoted 13 lines · Jean Delvare
Quoted 13 lines
The 2.6 i2c-dev bus numbers don't necessarily match i2c-adapter bus numbers.
If you rmmod and re-insmod a bus driver, the driver seems to get its old i2c-dev bus number back. But the i2c-adapter number increments. Don't know why. It would be much better if they matched.Most userspace tools need the i2c-dev numbers since they are going to use
/dev/i2c-xdevices to access the bus.The bus numbers reported by libsensors apps are the i2c-adapter numbers. I think it has to be that way since we don't need i2c-dev and therefore can't count on it being installed.
Quoted 6 lines
Quoted 2 lines
So you can't take a bus number from 'sensors' and then take that number and use it in 'i2cdump', for example.
This is odd. Any idea how to correct this? I'm a bit lost, I don't even understand how there can be two values, since it obviously represent the same thing (i.e. a bus identifier).
No, they are independent things. Just so happens that they were the same in all previous kernels :)
But if it's a big pain, I can see about fixing it up to match.
thanks,
greg k-h