diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2007-03-13 10:59:31 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-04-27 16:28:37 -0400 |
commit | 9f8b17e643fe6aa505629658445849397bda4e4f (patch) | |
tree | 30c45914f7be9f355db30964323673c7d37080e8 /drivers/usb/core/usb.c | |
parent | 87840289637e9ea95118ebd76e2e335fdcddd725 (diff) |
USB: make usbdevices export their device nodes instead of using a separate class
o The "real" usb-devices export now a device node which can
populate /dev/bus/usb.
o The usb_device class is optional now and can be disabled in the
kernel config. Major/minor of the "real" devices and class devices
are the same.
o The environment of the usb-device event contains DEVNUM and BUSNUM to
help udev and get rid of the ugly udev rule we need for the class
devices.
o The usb-devices and usb-interfaces share the same bus, so I used
the new "struct device_type" to let these devices identify
themselves. This also removes the current logic of using a magic
platform-pointer.
The name of the device_type is also added to the environment
which makes it easier to distinguish the different kinds of devices
on the same subsystem.
It looks like this:
add@/devices/pci0000:00/0000:00:1d.1/usb2/2-1
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb2/2-1
SUBSYSTEM=usb
SEQNUM=1533
MAJOR=189
MINOR=131
DEVTYPE=usb_device
PRODUCT=46d/c03e/2000
TYPE=0/0/0
BUSNUM=002
DEVNUM=004
This udev rule works as a replacement for usb_device class devices:
SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", \
NAME="bus/usb/$env{BUSNUM}/$env{DEVNUM}", MODE="0644"
Updated patch, which needs the device_type patches in Greg's tree.
I also got a bugzilla assigned for this. :)
https://bugzilla.novell.com/show_bug.cgi?id=250659
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/core/usb.c')
-rw-r--r-- | drivers/usb/core/usb.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 6f35dce8a95..dfd1b5c87ca 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -197,6 +197,11 @@ static void usb_release_dev(struct device *dev) | |||
197 | kfree(udev); | 197 | kfree(udev); |
198 | } | 198 | } |
199 | 199 | ||
200 | struct device_type usb_device_type = { | ||
201 | .name = "usb_device", | ||
202 | .release = usb_release_dev, | ||
203 | }; | ||
204 | |||
200 | #ifdef CONFIG_PM | 205 | #ifdef CONFIG_PM |
201 | 206 | ||
202 | static int ksuspend_usb_init(void) | 207 | static int ksuspend_usb_init(void) |
@@ -247,13 +252,10 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1) | |||
247 | 252 | ||
248 | device_initialize(&dev->dev); | 253 | device_initialize(&dev->dev); |
249 | dev->dev.bus = &usb_bus_type; | 254 | dev->dev.bus = &usb_bus_type; |
255 | dev->dev.type = &usb_device_type; | ||
250 | dev->dev.dma_mask = bus->controller->dma_mask; | 256 | dev->dev.dma_mask = bus->controller->dma_mask; |
251 | dev->dev.release = usb_release_dev; | ||
252 | dev->state = USB_STATE_ATTACHED; | 257 | dev->state = USB_STATE_ATTACHED; |
253 | 258 | ||
254 | /* This magic assignment distinguishes devices from interfaces */ | ||
255 | dev->dev.platform_data = &usb_generic_driver; | ||
256 | |||
257 | INIT_LIST_HEAD(&dev->ep0.urb_list); | 259 | INIT_LIST_HEAD(&dev->ep0.urb_list); |
258 | dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE; | 260 | dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE; |
259 | dev->ep0.desc.bDescriptorType = USB_DT_ENDPOINT; | 261 | dev->ep0.desc.bDescriptorType = USB_DT_ENDPOINT; |
@@ -882,9 +884,9 @@ static int __init usb_init(void) | |||
882 | retval = usb_register(&usbfs_driver); | 884 | retval = usb_register(&usbfs_driver); |
883 | if (retval) | 885 | if (retval) |
884 | goto driver_register_failed; | 886 | goto driver_register_failed; |
885 | retval = usbdev_init(); | 887 | retval = usb_devio_init(); |
886 | if (retval) | 888 | if (retval) |
887 | goto usbdevice_init_failed; | 889 | goto usb_devio_init_failed; |
888 | retval = usbfs_init(); | 890 | retval = usbfs_init(); |
889 | if (retval) | 891 | if (retval) |
890 | goto fs_init_failed; | 892 | goto fs_init_failed; |
@@ -899,8 +901,8 @@ static int __init usb_init(void) | |||
899 | hub_init_failed: | 901 | hub_init_failed: |
900 | usbfs_cleanup(); | 902 | usbfs_cleanup(); |
901 | fs_init_failed: | 903 | fs_init_failed: |
902 | usbdev_cleanup(); | 904 | usb_devio_cleanup(); |
903 | usbdevice_init_failed: | 905 | usb_devio_init_failed: |
904 | usb_deregister(&usbfs_driver); | 906 | usb_deregister(&usbfs_driver); |
905 | driver_register_failed: | 907 | driver_register_failed: |
906 | usb_major_cleanup(); | 908 | usb_major_cleanup(); |
@@ -927,7 +929,7 @@ static void __exit usb_exit(void) | |||
927 | usb_major_cleanup(); | 929 | usb_major_cleanup(); |
928 | usbfs_cleanup(); | 930 | usbfs_cleanup(); |
929 | usb_deregister(&usbfs_driver); | 931 | usb_deregister(&usbfs_driver); |
930 | usbdev_cleanup(); | 932 | usb_devio_cleanup(); |
931 | usb_hub_cleanup(); | 933 | usb_hub_cleanup(); |
932 | usb_host_cleanup(); | 934 | usb_host_cleanup(); |
933 | bus_unregister(&usb_bus_type); | 935 | bus_unregister(&usb_bus_type); |