Skip to contentSkip to conversation

I2C on 2.6

DISCUSSION Jon Smirl 2 participants 14 messages May 19, 2005

lore
Share & tools
lore

Jon Smirl

author
#0 lore raw

On kernel 2.6 I2C creates /sys/class/i2c-adapter. This directory contains all of my I2C busses. Now when I modprobe i2c-dev in it makes /sys/class/i2c-dev which also contains all of my I2C buses with the addition of a 'dev' file. Udev then picks up on this 'dev' file and makes the devices. Do we really need two I2C /sys/class entries? Could these be combined?

==Jon Smirl
[email protected]

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

#1 lore raw
Quoted 5 lines · Jon Smirl

On kernel 2.6 I2C creates /sys/class/i2c-adapter. This directory contains all of my I2C busses. Now when I modprobe i2c-dev in it makes /sys/class/i2c-dev which also contains all of my I2C buses with the addition of a 'dev' file. Udev then picks up on this 'dev' file and makes the devices. Do we really need two I2C /sys/class entries? Could these be combined?

Those are two completly separate things. So no, they can't be combined very easily :)

thanks,

greg k-h

author
#2 lore raw
In reply to Jon Smirl

Maybe /sys/class/i2c-adapter shouldn't exist. USB is using a different model to solve the same problem. With USB the adapters are in /sys/bus/usb/devices as usb1, usb2, etc. What about eliminating /sys/class/i2c-adapter and moving i2c-1, i2c-2, etc into ls /sys/bus/i2c/devices to match USB?

Quoted 10 lines · --- Greg KH
Quoted 1 line · Jon Smirl

On kernel 2.6 I2C creates /sys/class/i2c-adapter. This directory contains

all of

Quoted 1 line

my I2C busses. Now when I modprobe i2c-dev in it makes /sys/class/i2c-dev

which

Quoted 1 line

also contains all of my I2C buses with the addition of a 'dev' file. Udev

then

Quoted 2 lines

picks up on this 'dev' file and makes the devices. Do we really need two I2C /sys/class entries? Could these be combined?

Quoted 6 lines

Those are two completly separate things. So no, they can't be combined very easily :)

thanks,

greg k-h

==Jon Smirl
[email protected]

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

author
#3 lore raw
In reply to Jon Smirl

I see now that the usb hosts are in /sys/class/usb_host. But to be symetrical with USB and PCI we should have i2c-1, i2c-2, etc in /sys/bus/i2c/devices.

Quoted 10 lines · --- Greg KH
Quoted 1 line · Jon Smirl

On kernel 2.6 I2C creates /sys/class/i2c-adapter. This directory contains

all of

Quoted 1 line

my I2C busses. Now when I modprobe i2c-dev in it makes /sys/class/i2c-dev

which

Quoted 1 line

also contains all of my I2C buses with the addition of a 'dev' file. Udev

then

Quoted 2 lines

picks up on this 'dev' file and makes the devices. Do we really need two I2C /sys/class entries? Could these be combined?

Quoted 6 lines

Those are two completly separate things. So no, they can't be combined very easily :)

thanks,

greg k-h

==Jon Smirl
[email protected]

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

#4 lore raw
In reply to Jon Smirl
Quoted 1 line · Jon Smirl

Maybe /sys/class/i2c-adapter shouldn't exist.

No. It is necessary. Why do you want to get rid of it? What happens if you don't load the i2c_dev module? That isn't necessary to have a working i2c system (in fact I hate the i2c_dev code for lots of different reasons, it will probably go away in 2.7 for something else...)

A i2c-adapter device is the i2c "bridge". The i2c_dev device is just a way to talk to a specific i2c-adapter directly from userspace. There is a handy symlink in the i2c_dev device's directory to point you to where the i2c adapter that it is bound to is. That's more info than 2.4 ever gave you.

Quoted 1 line

USB is using a different model to solve the same problem.

As the person who wrote both pieces of code, I am very aware of what the USB and I2C driver model code does :)

Quoted 1 line

With USB the adapters are in /sys/bus/usb/devices as usb1, usb2, etc.

No, that is NOT the USB adapter! That is the USB root hub. You will find the usb adapter in /sys/class/usb_host. Hm, bet you missed that :)

So in short, that is a real usb device in /sys/bus/usb/devices/usb*

Yeah, I use the same names in both places in the USB tree to try to keep people from thinking I'm completely insane, but they are different things as you can see by the device and driver links in the /sys/class/usb_host/usb?/ directories.

Quoted 2 lines

What about eliminating /sys/class/i2c-adapter and moving i2c-1, i2c-2, etc into ls /sys/bus/i2c/devices to match USB?

Want to reconsider this based on the above knowledge? :)

thanks,

greg k-h

#5 lore raw
In reply to Jon Smirl
Quoted 2 lines · Jon Smirl

I see now that the usb hosts are in /sys/class/usb_host. But to be symetrical with USB and PCI we should have i2c-1, i2c-2, etc in /sys/bus/i2c/devices.

Again no. See my other response to you for why.

Remember, a i2c adapter is not a i2c device.

But a USB controller does contain a USB device (at least one, usually more than one these days) within itself.

thanks,

greg k-h

author
#6 lore raw
In reply to Jon Smirl

Thanks for the explanation, PCI, I2C, SCSI and USB all make sense now. I hadn't realized that USB hubs were also USB devices. This is all new so some things aren't obvious to me.

So looking at it from a symmetry point of view then shouldn't all entries in /sys/bus have a parallel entry in /sys/class like 'bus'_host?

I have these buses:
i2c i2c-adapter
ide
ieee1394
pci pci_bus
platform
scsi scsi_host
usb usb_host

What do you think about moving the 'host' class directories out of /class and into the bus directory? For example move /sys/class/usb_host to /sys/bus/usb/host, /sys/class/i2c_adapter to /sys/bus/i2c/adapter (or host).

Moving the 'host' items out of /sys/class will make /sys/class have more of a direct correspondence with /udev.

Quoted 7 lines · --- Greg KH
Quoted 1 line · Jon Smirl

I see now that the usb hosts are in /sys/class/usb_host. But to be

symetrical

Quoted 1 line

with USB and PCI we should have i2c-1, i2c-2, etc in /sys/bus/i2c/devices.

Again no. See my other response to you for why.

Quoted 8 lines

Remember, a i2c adapter is not a i2c device.

But a USB controller does contain a USB device (at least one, usually more than one these days) within itself.

thanks,

greg k-h

==Jon Smirl
[email protected]

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

#7 lore raw
In reply to Jon Smirl
Quoted 6 lines · Jon Smirl

Thanks for the explanation, PCI, I2C, SCSI and USB all make sense now. I hadn't realized that USB hubs were also USB devices. This is all new so some things aren't obvious to me.

So looking at it from a symmetry point of view then shouldn't all entries in /sys/bus have a parallel entry in /sys/class like 'bus'_host?

That might be a good idea, for 2.7

Quoted 9 lines

I have these buses:
i2c i2c-adapter
ide
ieee1394
pci pci_bus
platform
scsi scsi_host
usb usb_host

Quoted 3 lines

What do you think about moving the 'host' class directories out of /class and into the bus directory? For example move /sys/class/usb_host to /sys/bus/usb/host, /sys/class/i2c_adapter to /sys/bus/i2c/adapter (or host).

That would take some driver core changes to do this. Also 2.7 work.

Quoted 2 lines

Moving the 'host' items out of /sys/class will make /sys/class have more of a direct correspondence with /udev.

But there's no reason it has to have a directo correspondence with what udev sees. udev is smart enough to only care about the devices that have a "dev" file. And none of the above do, for now. But some types of host controllers might in the future, who knows :)

thanks,

greg k-h

author
#8 lore raw
In reply to Jon Smirl
Quoted 7 lines · --- Greg KH
Quoted 1 line

What do you think about moving the 'host' class directories out of /class

and

Quoted 2 lines

into the bus directory? For example move /sys/class/usb_host to /sys/bus/usb/host, /sys/class/i2c_adapter to /sys/bus/i2c/adapter (or host).

That would take some driver core changes to do this. Also 2.7 work.

Quoted 8 lines
Quoted 1 line

Moving the 'host' items out of /sys/class will make /sys/class have more of

a

Quoted 1 line

direct correspondence with /udev.

But there's no reason it has to have a directo correspondence with what udev sees. udev is smart enough to only care about the devices that have a "dev" file. And none of the above do, for now. But some types of host controllers might in the future, who knows :)

/sys/class is starting to feel a little confusing to me. And there are a lot more devices that don't have sysfs enabled yet that are going to end up in /sys/class too. Currently /sys/classs holds two classes of entries: hosts and devs. Are you sure you don't want to get the hosts out of there before software get written using them and it's too late to move them?

Is anything already using /class/sys/'host' entries? Or is the driver work just what is needed to move the location of the directory?

==Jon Smirl
[email protected]

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

#9 lore raw
In reply to Jon Smirl
Quoted 17 lines · Jon Smirl
Quoted 7 lines · --- Greg KH
Quoted 1 line

What do you think about moving the 'host' class directories out of /class

and

Quoted 2 lines

into the bus directory? For example move /sys/class/usb_host to /sys/bus/usb/host, /sys/class/i2c_adapter to /sys/bus/i2c/adapter (or host).

That would take some driver core changes to do this. Also 2.7 work.

Quoted 8 lines
Quoted 1 line

Moving the 'host' items out of /sys/class will make /sys/class have more of

a

Quoted 1 line

direct correspondence with /udev.

But there's no reason it has to have a directo correspondence with what udev sees. udev is smart enough to only care about the devices that have a "dev" file. And none of the above do, for now. But some types of host controllers might in the future, who knows :)

Quoted 5 lines

/sys/class is starting to feel a little confusing to me. And there are a lot more devices that don't have sysfs enabled yet that are going to end up in /sys/class too. Currently /sys/classs holds two classes of entries: hosts and devs. Are you sure you don't want to get the hosts out of there before software get written using them and it's too late to move them?

And how do you propose doing this? It will take some driver core mangling to do this.

And what's really wrong with it?

Quoted 2 lines

Is anything already using /class/sys/'host' entries? Or is the driver work just what is needed to move the location of the directory?

Driver core work and driver bus work would be needed.

It's much simpler the way things currently are. Leave this as a 2.7 thing to do if you really don't like it :)

thanks,

greg k-h

author
#10 lore raw
In reply to Jon Smirl
Quoted 13 lines · --- Greg KH
Quoted 3 lines

/sys/class is starting to feel a little confusing to me. And there are a lot more devices that don't have sysfs enabled yet that are going to end up in /sys/class too. Currently /sys/classs holds two classes of entries: hosts

and

Quoted 1 line

devs. Are you sure you don't want to get the hosts out of there before

software

Quoted 1 line

get written using them and it's too late to move them?

And how do you propose doing this? It will take some driver core mangling to do this.

And what's really wrong with it?

Quoted 8 lines
Quoted 1 line

Is anything already using /class/sys/'host' entries? Or is the driver work

just

Quoted 1 line

what is needed to move the location of the directory?

Driver core work and driver bus work would be needed.

It's much simpler the way things currently are. Leave this as a 2.7 thing to do if you really don't like it :)

This just feels to me like one of those things we're going regret not doing before a bunch of code gets built on top of it and it becomes impossible to change.

Does changing this involve anything except the syfs specific code in the drivers that creates the entries? In other words is there non-sysfs code that relies on where these directories are located? Right now there are only four buses that I know of that need to be moved.

This problem isn't too bad on a desktop, but what about a mainframe that might have a hundred different buses?

Quoted 4 lines

thanks,

greg k-h

==Jon Smirl
[email protected]

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

author
#11 lore raw
In reply to Jon Smirl

Would it be hard to add links like this: /sys/class/usb_host to /sys/bus/usb/host, /sys/class/i2c_adapter to /sys/bus/i2c/adapter (or host). Then move the 'host' entries out of /sys/class in 2.7? The links will make the move transparent to user space software.

Quoted 9 lines · --- Jon Smirl

I have these buses:
i2c i2c-adapter
ide
ieee1394
pci pci_bus
platform
scsi scsi_host
usb usb_host

Quoted 3 lines

What do you think about moving the 'host' class directories out of /class and into the bus directory? For example move /sys/class/usb_host to /sys/bus/usb/host, /sys/class/i2c_adapter to /sys/bus/i2c/adapter (or host).

==Jon Smirl
[email protected]

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

#12 lore raw
In reply to Jon Smirl
Quoted 4 lines · Jon Smirl

Would it be hard to add links like this: /sys/class/usb_host to /sys/bus/usb/host, /sys/class/i2c_adapter to /sys/bus/i2c/adapter (or host). Then move the 'host' entries out of /sys/class in 2.7? The links will make the move transparent to user space software.

I don't think you realize what you are trying to change.

Everything under /sys/class uses a struct class and a struct class_device.

Everything under /sys/devices and /sys/bus are of type struct device.

This would be a big core change to try to do this.

As for your comment of "thousands of different busses", I don't quite understand. We have unique directories in /sys/class for the different _types_ of bus hosts and classes. If I have a box with 40,000 scsi devices, I still only have 1 /sys/class/scsi_host directory.

If you think this is important, hey, I'm always willing to look over patches :)

thanks,

greg k-h

author
#13 lore raw
In reply to Jon Smirl

Alright, I'll leave this alone. I just got stuck on trying to figure out which entry in /sys/class goes with the corresponding entry in /sys/bus.

Quoted 21 lines · --- Greg KH
Quoted 3 lines · Jon Smirl

Would it be hard to add links like this: /sys/class/usb_host to /sys/bus/usb/host, /sys/class/i2c_adapter to /sys/bus/i2c/adapter (or host). Then move the 'host' entries out of /sys/class in 2.7? The links will make

the

Quoted 1 line

move transparent to user space software.

I don't think you realize what you are trying to change.

Everything under /sys/class uses a struct class and a struct class_device.

Everything under /sys/devices and /sys/bus are of type struct device.

This would be a big core change to try to do this.

As for your comment of "thousands of different busses", I don't quite understand. We have unique directories in /sys/class for the different _types_ of bus hosts and classes. If I have a box with 40,000 scsi devices, I still only have 1 /sys/class/scsi_host directory.

Quoted 6 lines

If you think this is important, hey, I'm always willing to look over patches :)

thanks,

greg k-h

==Jon Smirl
[email protected]

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html