USB: add devpath sysfs attribute
authorGreg Kroah-Hartman <gregkh@suse.de>
Mon, 30 Nov 2009 19:15:02 +0000 (11:15 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 11 Dec 2009 19:55:25 +0000 (11:55 -0800)
This is not exported from the usb core, yet we rely on it to create
paths to interfaces for this device in sysfs.  Export it to make
userspace tools have an easier time to figure things out.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/sysfs.c

index 470e2413a9cfcf36ffc46df40c44b31586c49952..ae763974be259bb2814c58489ad5f7a43152167c 100644 (file)
@@ -138,6 +138,16 @@ show_devnum(struct device *dev, struct device_attribute *attr, char *buf)
 }
 static DEVICE_ATTR(devnum, S_IRUGO, show_devnum, NULL);
 
+static ssize_t
+show_devpath(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct usb_device *udev;
+
+       udev = to_usb_device(dev);
+       return sprintf(buf, "%s\n", udev->devpath);
+}
+static DEVICE_ATTR(devpath, S_IRUGO, show_devpath, NULL);
+
 static ssize_t
 show_version(struct device *dev, struct device_attribute *attr, char *buf)
 {
@@ -538,8 +548,8 @@ static struct attribute *dev_attrs[] = {
        &dev_attr_bConfigurationValue.attr,
        &dev_attr_bmAttributes.attr,
        &dev_attr_bMaxPower.attr,
-       &dev_attr_urbnum.attr,
        /* device attributes */
+       &dev_attr_urbnum.attr,
        &dev_attr_idVendor.attr,
        &dev_attr_idProduct.attr,
        &dev_attr_bcdDevice.attr,
@@ -551,6 +561,7 @@ static struct attribute *dev_attrs[] = {
        &dev_attr_speed.attr,
        &dev_attr_busnum.attr,
        &dev_attr_devnum.attr,
+       &dev_attr_devpath.attr,
        &dev_attr_version.attr,
        &dev_attr_maxchild.attr,
        &dev_attr_quirks.attr,