# This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.624 -> 1.625 # drivers/usb/core/usb.c 1.65 -> 1.66 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 02/07/05 greg@kroah.com 1.625 # USB: added product, manufacturer, and serial driverfs files for a device # -------------------------------------------- # diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c --- a/drivers/usb/core/usb.c Sun Jul 7 12:36:10 2002 +++ b/drivers/usb/core/usb.c Sun Jul 7 12:36:10 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);