USB: add "busnum" attribute for USB devices
authorAlan Stern <stern@rowland.harvard.edu>
Wed, 25 Apr 2007 19:15:43 +0000 (15:15 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 27 Apr 2007 20:28:42 +0000 (13:28 -0700)
This patch (as903) adds a "busnum" sysfs attribute for USB devices.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/sysfs.c

index 2ea47a38aefa47fa935cebd2d7be24cbef713e32..e7c982377488fca4b727d9d2edd7084269298b1b 100644 (file)
@@ -117,6 +117,16 @@ show_speed(struct device *dev, struct device_attribute *attr, char *buf)
 }
 static DEVICE_ATTR(speed, S_IRUGO, show_speed, NULL);
 
+static ssize_t
+show_busnum(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct usb_device *udev;
+
+       udev = to_usb_device(dev);
+       return sprintf(buf, "%d\n", udev->bus->busnum);
+}
+static DEVICE_ATTR(busnum, S_IRUGO, show_busnum, NULL);
+
 static ssize_t
 show_devnum(struct device *dev, struct device_attribute *attr, char *buf)
 {
@@ -347,6 +357,7 @@ static struct attribute *dev_attrs[] = {
        &dev_attr_bNumConfigurations.attr,
        &dev_attr_bMaxPacketSize0.attr,
        &dev_attr_speed.attr,
+       &dev_attr_busnum.attr,
        &dev_attr_devnum.attr,
        &dev_attr_version.attr,
        &dev_attr_maxchild.attr,