[PATCH 10/10] USB: add missing fields to interface uevents
Alan Stern <[email protected]>
| Newsgroups | gmane.linux.usb.devel |
|---|---|
| Message-ID | <[email protected]> |
This patch (as982) adds DEVICE, PRODUCT, and TYPE fields to the environment list for USB-interface uevents. This fixes a regression with respect to the user interface in earlier versions of the kernel. Signed-off-by: Alan Stern <[email protected]> CC: Kay Sievers <[email protected]> --- Kay's patch did this for 2.6.22, but nobody has written the equivalent for 2.6.23 -- so here it is. Unlike all the previous patches in this series, this one should go into 2.6.23 since it affects the userspace interface. Alan Stern Index: usb-2.6/drivers/usb/core/usb.h =================================================================== --- usb-2.6.orig/drivers/usb/core/usb.h +++ usb-2.6/drivers/usb/core/usb.h @@ -36,6 +36,9 @@ extern void usb_major_cleanup(void); extern int usb_host_init(void); extern void usb_host_cleanup(void); +extern int usb_uevent_add_device_vars(struct usb_device *usb_dev, + struct kobj_uevent_env *env); + #ifdef CONFIG_PM extern void usb_autosuspend_work(struct work_struct *work); Index: usb-2.6/drivers/usb/core/driver.c =================================================================== --- usb-2.6.orig/drivers/usb/core/driver.c +++ usb-2.6/drivers/usb/core/driver.c @@ -581,6 +581,37 @@ static int usb_device_match(struct devic } #ifdef CONFIG_HOTPLUG +int usb_uevent_add_device_vars(struct usb_device *usb_dev, + struct kobj_uevent_env *env) +{ + +#ifdef CONFIG_USB_DEVICEFS + /* If this is available, userspace programs can directly read + * all the device descriptors we don't tell them about. Or + * act as usermode drivers. + */ + if (add_uevent_var(env, "DEVICE=/proc/bus/usb/%03d/%03d", + usb_dev->bus->busnum, usb_dev->devnum)) + return -ENOMEM; +#endif + + /* per-device configurations are common */ + if (add_uevent_var(env, "PRODUCT=%x/%x/%x", + le16_to_cpu(usb_dev->descriptor.idVendor), + le16_to_cpu(usb_dev->descriptor.idProduct), + le16_to_cpu(usb_dev->descriptor.bcdDevice))) + return -ENOMEM; + + /* class-based driver binding models */ + if (add_uevent_var(env, "TYPE=%d/%d/%d", + usb_dev->descriptor.bDeviceClass, + usb_dev->descriptor.bDeviceSubClass, + usb_dev->descriptor.bDeviceProtocol)) + return -ENOMEM; + + return 0; +} + static int usb_uevent(struct device *dev, struct kobj_uevent_env *env) { struct usb_device *usb_dev; @@ -607,28 +638,7 @@ static int usb_uevent(struct device *dev return -ENODEV; } -#ifdef CONFIG_USB_DEVICEFS - /* If this is available, userspace programs can directly read - * all the device descriptors we don't tell them about. Or - * act as usermode drivers. - */ - if (add_uevent_var(env, "DEVICE=/proc/bus/usb/%03d/%03d", - usb_dev->bus->busnum, usb_dev->devnum)) - return -ENOMEM; -#endif - - /* per-device configurations are common */ - if (add_uevent_var(env, "PRODUCT=%x/%x/%x", - le16_to_cpu(usb_dev->descriptor.idVendor), - le16_to_cpu(usb_dev->descriptor.idProduct), - le16_to_cpu(usb_dev->descriptor.bcdDevice))) - return -ENOMEM; - - /* class-based driver binding models */ - if (add_uevent_var(env, "TYPE=%d/%d/%d", - usb_dev->descriptor.bDeviceClass, - usb_dev->descriptor.bDeviceSubClass, - usb_dev->descriptor.bDeviceProtocol)) + if (usb_uevent_add_device_vars(usb_dev, env)) return -ENOMEM; if (add_uevent_var(env, "BUSNUM=%03d", Index: usb-2.6/drivers/usb/core/message.c =================================================================== --- usb-2.6.orig/drivers/usb/core/message.c +++ usb-2.6/drivers/usb/core/message.c @@ -1359,6 +1359,9 @@ static int usb_if_uevent(struct device * usb_dev = interface_to_usbdev(intf); alt = intf->cur_altsetting; + if (usb_uevent_add_device_vars(usb_dev, env)) + return -ENOMEM; + if (add_uevent_var(env, "INTERFACE=%d/%d/%d", alt->desc.bInterfaceClass, alt->desc.bInterfaceSubClass, ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel