Commit 7775f7ea authored by Robert Love's avatar Robert Love Committed by Greg Kroah-Hartman

[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.
parent 606d0900
......@@ -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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment