From 7775f7ea6fdab0f2f6323b504c0ecd53bc5c8586 Mon Sep 17 00:00:00 2001 From: Robert Love Date: Wed, 7 Apr 2004 02:52:34 -0700 Subject: [PATCH] [PATCH] USB: add missing usb entries to sysfs 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 | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/usb/core/driverfs.c b/drivers/usb/core/driverfs.c index 2284803bdeed7..948e42d09df52 100644 --- a/drivers/usb/core/driverfs.c +++ b/drivers/usb/core/driverfs.c @@ -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 */ -- 2.53.0