aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorGreg KH <gregkh@suse.de>2005-05-10 09:45:10 -0400
committerGreg KH <gregkh@suse.de>2005-05-17 00:44:26 -0400
commit360b52b08972ada8fd4421e9a7bcbe1ea186c20e (patch)
tree06067522d817b8a792176b1076ce5a9d0c216f2b /drivers/usb
parent25b6f08e3fa0d84e26a373a205cfdad208b54af7 (diff)
[PATCH] USB: add modalias sysfs file for usb devices
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/core/sysfs.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index ec9b3bde8ae5..4ab50009291d 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -286,6 +286,39 @@ static ssize_t show_interface_string(struct device *dev, char *buf)
286} 286}
287static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL); 287static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL);
288 288
289static 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}
320static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL);
321
289static struct attribute *intf_attrs[] = { 322static struct attribute *intf_attrs[] = {
290 &dev_attr_bInterfaceNumber.attr, 323 &dev_attr_bInterfaceNumber.attr,
291 &dev_attr_bAlternateSetting.attr, 324 &dev_attr_bAlternateSetting.attr,
@@ -293,6 +326,7 @@ static struct attribute *intf_attrs[] = {
293 &dev_attr_bInterfaceClass.attr, 326 &dev_attr_bInterfaceClass.attr,
294 &dev_attr_bInterfaceSubClass.attr, 327 &dev_attr_bInterfaceSubClass.attr,
295 &dev_attr_bInterfaceProtocol.attr, 328 &dev_attr_bInterfaceProtocol.attr,
329 &dev_attr_modalias.attr,
296 NULL, 330 NULL,
297}; 331};
298static struct attribute_group intf_attr_grp = { 332static struct attribute_group intf_attr_grp = {