Skip to contentSkip to conversation

change netdevice to use struct device instead of struct class_device

RFC Greg KH 4 participants 8 messages Jul 3, 2006 – Jul 7, 2006

Subsystems (2)
lore
Share & tools
lore

Greg KH

author
#0 lore raw

I have a patch here that converts the network device structure to use the struct device instead of struct class_device structure. It's a bit too big to post here, so it's at:
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/network-class_device-to-device.patch

I can split it out, but then it will not build for the intermediate steps, which 'git bisect' users might not appreciate. If you all want me to break it up to make it easier to review, please let me know and I'll be glad to do it.

With this patch applied, sysfs now looks like:

 $ tree /sys/class/net/
 /sys/class/net/
 |-- eth0 -> ../../devices/pci0000:00/0000:00:02.0/0000:01:00.2/0000:03:0e.0/eth0
 |-- gerg -> ../../devices/pci0000:00/0000:00:02.0/0000:01:00.2/0000:03:0c.0/gerg
 `-- lo -> ../../devices/lo

Instead of the different directories being in /sys/class/net.

What this buys us is now the different network devices can be called by the core when the system is shutting down or restoring, with the suspend/resume changes that Linus has written (and are now in -mm). This can be used by the network core to stop the queue, or whatever else it desires.

Other good things happen with this, as the network devices are now real devices, instead of the second-class citizens that "class_device" was. (which is one reason why I'm getting rid of class_device entirely).

The patch needs some other changes to the driver core that are also in my git tree, and included in the -mm release. Specifically these patches are needed:
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/driver/device-groups.patch
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/driver/device-class-parent.patch
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/driver/device-class-attr.patch
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/driver/device_rename.patch

And if you are curious, the suspend stuff from Linus is at:
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/driver/suspend-infrastructure-cleanup-and-extension.patch

I can gladly keep this in my tree (due to the previously mentioned requirements) and eventually merge it with Linus after 2.6.18 is out, if no one objects to it.

thanks,

greg k-h

p.s. That bonding code! WTF is going on with poking around in the
internals of krefs? And why are you returning more than one value from a sysfs file? I thought I asked that this stuff be fixed up a long time ago?

author
#2 lore raw
Quoted 7 lines · Jeff Garzik
Quoted 4 lines · Greg KH

I have a patch here that converts the network device structure to use the struct device instead of struct class_device structure. It's a bit too big to post here, so it's at:
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/network-class_device-to-device.patch

So.... this is a userspace ABI change, then?

No, not really. According to Documentation/ABI/testing/sysfs-class all code that uses /sys/class/foo/ needs to be able to handle the fact that those entries might be symlinks and not just directories. Everything that I know of already works properly because the input layer has had symlinks in /sys/class/input for quite some time now.

Do you know of any tools that use /sys/class/net/ that can not handle symlinks there? I've been running this on my boxes for about a week now with no noticeable issues. Renaming interfaces works just fine too.

thanks,

greg k-h

maintainer
#3 lore raw

From: Greg KH <[email protected]>
Date: Mon, 3 Jul 2006 16:16:10 -0700

Quoted 9 lines

No, not really. According to Documentation/ABI/testing/sysfs-class all code that uses /sys/class/foo/ needs to be able to handle the fact that those entries might be symlinks and not just directories. Everything that I know of already works properly because the input layer has had symlinks in /sys/class/input for quite some time now.

Do you know of any tools that use /sys/class/net/ that can not handle symlinks there? I've been running this on my boxes for about a week now with no noticeable issues. Renaming interfaces works just fine too.

I do not think this change will cause any problems.

author
#4 lore raw
Quoted 9 lines · David Miller

From: Greg KH <[email protected]>
Date: Mon, 3 Jul 2006 16:16:10 -0700

Quoted 6 lines

No, not really. According to Documentation/ABI/testing/sysfs-class all code that uses /sys/class/foo/ needs to be able to handle the fact that those entries might be symlinks and not just directories. Everything that I know of already works properly because the input layer has had symlinks in /sys/class/input for quite some time now.

Quoted 5 lines
Quoted 3 lines

Do you know of any tools that use /sys/class/net/ that can not handle symlinks there? I've been running this on my boxes for about a week now with no noticeable issues. Renaming interfaces works just fine too.

I do not think this change will cause any problems.

Great, thanks for looking.

Do you mind if I keep this in my tree, due to the dependancies on the other driver core changes?

thanks,

greg k-h

maintainer
#5 lore raw

From: Greg KH <[email protected]>
Date: Tue, 4 Jul 2006 15:31:01 -0700

Quoted 2 lines

Do you mind if I keep this in my tree, due to the dependancies on the other driver core changes?

Feel free.

#6 lore raw
In reply to Greg KH

Hi Greg,

Quoted 5 lines

The patch needs some other changes to the driver core that are also in my git tree, and included in the -mm release. Specifically these patches are needed:
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/driver/device-groups.patch
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/driver/device-class-parent.patch

while converting the Bluetooth subsystem from class devices to real devices, I had some similar situation with devices without parent. I actually used a Bluetooth platform device as parent for virtual or serial based devices.

Regards

Marcel

author
#7 lore raw
Quoted 8 lines · Marcel Holtmann

Hi Greg,

Quoted 5 lines

The patch needs some other changes to the driver core that are also in my git tree, and included in the -mm release. Specifically these patches are needed:
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/driver/device-groups.patch
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/driver/device-class-parent.patch

Quoted 4 lines

while converting the Bluetooth subsystem from class devices to real devices, I had some similar situation with devices without parent. I actually used a Bluetooth platform device as parent for virtual or serial based devices.

The problem with that is you get a bunch of symlinks to that parent device that you really don't want to have, when we have a device that is associated with a class.

I was thinking of creating a /sys/devices/virtual/ to put these unassociated devices into, and I'll play around with that a bit. I don't know if we will hit some namespace issues with all of the different devices that aren't associated with a "real" device if we lump them all together into one directory...

thanks,

greg k-h