[PATCH] USB: add modalias sysfs file for usb devices

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Greg KH 360b52b0 25b6f08e

+34
+34
drivers/usb/core/sysfs.c
··· 286 286 } 287 287 static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL); 288 288 289 + static ssize_t show_modalias(struct device *dev, char *buf) 290 + { 291 + struct usb_interface *intf; 292 + struct usb_device *udev; 293 + 294 + intf = to_usb_interface(dev); 295 + udev = interface_to_usbdev(intf); 296 + if (udev->descriptor.bDeviceClass == 0) { 297 + struct usb_host_interface *alt = intf->cur_altsetting; 298 + 299 + return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X\n", 300 + le16_to_cpu(udev->descriptor.idVendor), 301 + le16_to_cpu(udev->descriptor.idProduct), 302 + le16_to_cpu(udev->descriptor.bcdDevice), 303 + udev->descriptor.bDeviceClass, 304 + udev->descriptor.bDeviceSubClass, 305 + udev->descriptor.bDeviceProtocol, 306 + alt->desc.bInterfaceClass, 307 + alt->desc.bInterfaceSubClass, 308 + alt->desc.bInterfaceProtocol); 309 + } else { 310 + return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*\n", 311 + le16_to_cpu(udev->descriptor.idVendor), 312 + le16_to_cpu(udev->descriptor.idProduct), 313 + le16_to_cpu(udev->descriptor.bcdDevice), 314 + udev->descriptor.bDeviceClass, 315 + udev->descriptor.bDeviceSubClass, 316 + udev->descriptor.bDeviceProtocol); 317 + } 318 + 319 + } 320 + static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); 321 + 289 322 static struct attribute *intf_attrs[] = { 290 323 &dev_attr_bInterfaceNumber.attr, 291 324 &dev_attr_bAlternateSetting.attr, ··· 326 293 &dev_attr_bInterfaceClass.attr, 327 294 &dev_attr_bInterfaceSubClass.attr, 328 295 &dev_attr_bInterfaceProtocol.attr, 296 + &dev_attr_modalias.attr, 329 297 NULL, 330 298 }; 331 299 static struct attribute_group intf_attr_grp = {