ChangeSet 1.1713.7.7, 2004/04/07 16:52:34-07:00, [EMAIL PROTECTED]
[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 files changed, 35 insertions(+)
diff -Nru a/drivers/usb/core/driverfs.c b/drivers/usb/core/driverfs.c
--- a/drivers/usb/core/driverfs.c Wed Apr 14 14:33:45 2004
+++ b/drivers/usb/core/driverfs.c Wed Apr 14 14:33:45 2004
@@ -111,6 +111,37 @@
}
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 @@
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 */
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel