]> git.hungrycats.org Git - linux/commitdiff
[PATCH] USB: add missing usb entries to sysfs
authorRobert Love <rml@ximian.com>
Wed, 7 Apr 2004 09:52:34 +0000 (02:52 -0700)
committerGreg Kroah-Hartman <greg@kroah.com>
Wed, 7 Apr 2004 09:52:34 +0000 (02:52 -0700)
We have found in the course of hacking on HAL that some information that
is in /proc/bus/usb/devices is not in sysfs.  It would be nice to rely
only on sysfs, so the attached patch adds three files to usb devices in
sysfs: devnum, maxChild, and version.

This patch is actually by David Zuethen, the HAL maintainer - I told him
I would clean it up and get it upstream.

drivers/usb/core/driverfs.c

index 2284803bdeed792639715f620e6aeaffbe38b581..948e42d09df525198ab78987f80a7c5e2d0f317a 100644 (file)
@@ -111,6 +111,37 @@ show_speed (struct device *dev, char *buf)
 }
 static DEVICE_ATTR(speed, S_IRUGO, show_speed, NULL);
 
+static ssize_t
+show_devnum (struct device *dev, char *buf)
+{
+       struct usb_device *udev;
+
+       udev = to_usb_device (dev);
+       return sprintf (buf, "%d\n", udev->devnum);
+}
+static DEVICE_ATTR(devnum, S_IRUGO, show_devnum, NULL);
+
+static ssize_t
+show_version (struct device *dev, char *buf)
+{
+       struct usb_device *udev;
+
+       udev = to_usb_device (dev);
+       return sprintf (buf, "%2x.%02x\n", udev->descriptor.bcdUSB >> 8, 
+                       udev->descriptor.bcdUSB & 0xff);
+}
+static DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
+
+static ssize_t
+show_maxchild (struct device *dev, char *buf)
+{
+       struct usb_device *udev;
+
+       udev = to_usb_device (dev);
+       return sprintf (buf, "%d\n", udev->maxchild);
+}
+static DEVICE_ATTR(maxChild, S_IRUGO, show_maxchild, NULL);
+
 /* Descriptor fields */
 #define usb_descriptor_attr(field, format_string)                      \
 static ssize_t                                                         \
@@ -161,6 +192,10 @@ void usb_create_driverfs_dev_files (struct usb_device *udev)
                device_create_file (dev, &dev_attr_product);
        if (udev->descriptor.iSerialNumber)
                device_create_file (dev, &dev_attr_serial);
+
+       device_create_file (dev, &dev_attr_devnum);
+       device_create_file (dev, &dev_attr_version);
+       device_create_file (dev, &dev_attr_maxchild);
 }
 
 /* Interface fields */