On Thu, Jun 27, 2002 at 03:12:04PM -0700, David Brownell wrote:
> This fixes a couple issues I noted when I finally spent some time
> looking at the first version of driverfs support for usb:
Thanks for the patch, I've now applied it.
I also just added the following patch, which creates files for the
serial number, product string, and manufacturer string if they are
present in the device.
thanks,
greg k-h
diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c Fri Jul 5 22:45:03 2002
+++ b/drivers/usb/core/usb.c Fri Jul 5 22:45:03 2002
@@ -788,6 +788,70 @@
show: show_altsetting,
};
+/* product driverfs file */
+static ssize_t show_product (struct device *dev, char *buf, size_t count, loff_t off)
+{
+ struct usb_device *udev;
+ int len;
+
+ if (off)
+ return 0;
+ udev = list_entry (dev, struct usb_device, dev);
+
+ len = usb_string(udev, udev->descriptor.iProduct, buf, PAGE_SIZE);
+ buf[len] = '\n';
+ buf[len+1] = 0x00;
+ return len+1;
+}
+static struct driver_file_entry usb_product_entry = {
+ name: "product",
+ mode: S_IRUGO,
+ show: show_product,
+};
+
+/* manufacturer driverfs file */
+static ssize_t
+show_manufacturer (struct device *dev, char *buf, size_t count, loff_t off)
+{
+ struct usb_device *udev;
+ int len;
+
+ if (off)
+ return 0;
+ udev = list_entry (dev, struct usb_device, dev);
+
+ len = usb_string(udev, udev->descriptor.iManufacturer, buf, PAGE_SIZE);
+ buf[len] = '\n';
+ buf[len+1] = 0x00;
+ return len+1;
+}
+static struct driver_file_entry usb_manufacturer_entry = {
+ name: "manufacturer",
+ mode: S_IRUGO,
+ show: show_manufacturer,
+};
+
+/* serial number driverfs file */
+static ssize_t
+show_serial (struct device *dev, char *buf, size_t count, loff_t off)
+{
+ struct usb_device *udev;
+ int len;
+
+ if (off)
+ return 0;
+ udev = list_entry (dev, struct usb_device, dev);
+
+ len = usb_string(udev, udev->descriptor.iSerialNumber, buf, PAGE_SIZE);
+ buf[len] = '\n';
+ buf[len+1] = 0x00;
+ return len+1;
+}
+static struct driver_file_entry usb_serial_entry = {
+ name: "serial",
+ mode: S_IRUGO,
+ show: show_serial,
+};
/*
* This entrypoint gets called for each new device.
@@ -1319,6 +1383,12 @@
if (err)
return err;
device_create_file (&dev->dev, &usb_config_entry);
+ if (dev->descriptor.iManufacturer)
+ device_create_file (&dev->dev, &usb_manufacturer_entry);
+ if (dev->descriptor.iProduct)
+ device_create_file (&dev->dev, &usb_product_entry);
+ if (dev->descriptor.iSerialNumber)
+ device_create_file (&dev->dev, &usb_serial_entry);
/* now that the basic setup is over, add a /proc/bus/usb entry */
usbfs_add_device(dev);
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Got root? We do.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel