On Tue, Mar 30, Greg KH wrote:
> On Tue, Mar 30, 2004 at 08:15:52PM +0200, Olaf Hering wrote:
> >
> > No. make it static. Always.
>
> How about adding a patch that does this to your tree and see if any of
> your users's devices break? If such a patch lives successfully in a
> distro patch for a release cycle or two, I'd be willing to add it to the
> main kernel tree.
>
> Sound good?
This one seems to work good enough.
Do you see any obvious technical problems with it?
diff -purNX /kernel_exclude.txt
linux-2.6.5-rc3-olh-usb.orig/drivers/usb/core/driverfs.c
linux-2.6.5-rc3-olh-usb/drivers/usb/core/driverfs.c
--- linux-2.6.5-rc3-olh-usb.orig/drivers/usb/core/driverfs.c 2004-03-31
11:17:44.000000000 +0000
+++ linux-2.6.5-rc3-olh-usb/drivers/usb/core/driverfs.c 2004-03-31 15:59:32.000000000
+0000
@@ -70,7 +70,9 @@ static ssize_t show_##name(struct devic
int len; \
\
udev = to_usb_device (dev); \
- len = usb_string(udev, udev->descriptor.field, buf, PAGE_SIZE); \
+ if (!udev->field) \
+ return 0; \
+ len = snprintf(buf, 256, "%s", udev->field); \
if (len < 0) \
return 0; \
buf[len] = '\n'; \
@@ -79,9 +81,9 @@ static ssize_t show_##name(struct devic
} \
static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
-usb_string_attr(product, iProduct);
-usb_string_attr(manufacturer, iManufacturer);
-usb_string_attr(serial, iSerialNumber);
+usb_string_attr(product, static_product); /* iProduct); */
+usb_string_attr(manufacturer, static_vendor); /* iManufacturer); */
+usb_string_attr(serial, static_serial); /* iSerialNumber); */
static ssize_t
show_speed (struct device *dev, char *buf)
diff -purNX /kernel_exclude.txt linux-2.6.5-rc3-olh-usb.orig/drivers/usb/core/usb.c
linux-2.6.5-rc3-olh-usb/drivers/usb/core/usb.c
--- linux-2.6.5-rc3-olh-usb.orig/drivers/usb/core/usb.c 2004-03-31 11:17:44.000000000
+0000
+++ linux-2.6.5-rc3-olh-usb/drivers/usb/core/usb.c 2004-03-31 15:30:00.000000000
+0000
@@ -992,6 +992,12 @@ void usb_disconnect(struct usb_device **
clear_bit(dev->devnum, dev->bus->devmap.devicemap);
usbfs_remove_device(dev);
}
+ if (dev->static_vendor)
+ kfree(dev->static_vendor);
+ if (dev->static_product)
+ kfree(dev->static_product);
+ if (dev->static_serial)
+ kfree(dev->static_serial);
up(&dev->serialize);
device_unregister(&dev->dev);
}
@@ -1057,6 +1063,20 @@ static inline void usb_show_string(struc
kfree(buf);
}
+static void usb_add_static_info(struct usb_device *dev, char *id, int index, char
**info)
+{
+ char *buf;
+ if (!index)
+ return;
+ if (!(buf = kmalloc(256, GFP_KERNEL)))
+ return;
+ if (usb_string(dev, index, buf, 256) > 0) {
+ *info = buf;
+ dev_printk(KERN_INFO, &dev->dev, "%s: %s\n", id, buf);
+ }
+ return;
+}
+
/*
* By the time we get here, we chose a new device address
* and is in the default state. We need to identify the thing and
@@ -1155,14 +1175,12 @@ int usb_new_device(struct usb_device *de
dev_dbg(&dev->dev, "new device strings: Mfr=%d, Product=%d, SerialNumber=%d\n",
dev->descriptor.iManufacturer, dev->descriptor.iProduct,
dev->descriptor.iSerialNumber);
-#ifdef DEBUG
if (dev->descriptor.iProduct)
- usb_show_string(dev, "Product", dev->descriptor.iProduct);
+ usb_add_static_info(dev, "Product", dev->descriptor.iProduct,
&dev->static_vendor);
if (dev->descriptor.iManufacturer)
- usb_show_string(dev, "Manufacturer", dev->descriptor.iManufacturer);
+ usb_add_static_info(dev, "Manufacturer",
dev->descriptor.iManufacturer, &dev->static_product);
if (dev->descriptor.iSerialNumber)
- usb_show_string(dev, "SerialNumber", dev->descriptor.iSerialNumber);
-#endif
+ usb_add_static_info(dev, "SerialNumber",
dev->descriptor.iSerialNumber, &dev->static_serial);
/* put device-specific files into sysfs */
err = device_add (&dev->dev);
diff -purNX /kernel_exclude.txt linux-2.6.5-rc3-olh-usb.orig/include/linux/usb.h
linux-2.6.5-rc3-olh-usb/include/linux/usb.h
--- linux-2.6.5-rc3-olh-usb.orig/include/linux/usb.h 2004-03-31 11:17:45.000000000
+0000
+++ linux-2.6.5-rc3-olh-usb/include/linux/usb.h 2004-03-31 14:47:39.000000000 +0000
@@ -301,6 +301,9 @@ struct usb_device {
int maxchild; /* Number of ports if hub */
struct usb_device *children[USB_MAXCHILDREN];
+ char *static_vendor;
+ char *static_product;
+ char *static_serial;
};
#define to_usb_device(d) container_of(d, struct usb_device, dev)
--
USB is for mice, FireWire is for men!
sUse lINUX ag, nÃRNBERG
-------------------------------------------------------
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