On Thu, 24 Feb 2005, Greg KH wrote:
> Ok, here's 3 patches that read the strings from the device at insertion
> time, and cache them. It makes the sysfs and /proc/bus/usb/devices file
> use these string values to prevent bus accesses from happening at
> inopportune times.
> I've added these three patches to my trees, but comments are appreciated
> if I've missed anything.
Your new get_string() routine in hub.c leaks a memory buffer if the
usb_string() call fails.
You don't store the iInterface string for non-active interfaces. Although
there don't seem to be any users for such strings at the moment, there
very well could be. For instance, doesn't it seem strange that
/proc/bus/usb/devices doesn't print the iConfiguration and iInterface
strings? Would it mess up any programs to add them in? (This does raise
a problem about wasting memory, if many different altsettings for an
interface all share the same string.)
Since you don't have a physical USB device with an iInterface string to
test, here's a patch to add one to g_file_storage. To test:
modprobe dummy-hcd
modprobe g-file-storage removable=y
Alan Stern
Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
===== drivers/usb/gadget/file_storage.c 1.38 vs edited =====
--- 1.38/drivers/usb/gadget/file_storage.c 2005-02-03 00:13:48 -05:00
+++ edited/drivers/usb/gadget/file_storage.c 2005-02-25 10:39:06 -05:00
@@ -1,7 +1,7 @@
/*
* file_storage.c -- File-backed USB Storage Gadget, for USB development
*
- * Copyright (C) 2003, 2004 Alan Stern
+ * Copyright (C) 2003-2005 Alan Stern
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -832,6 +832,8 @@
#define STRING_MANUFACTURER 1
#define STRING_PRODUCT 2
#define STRING_SERIAL 3
+#define STRING_CONFIG 4
+#define STRING_INTERFACE 5
/* There is only one configuration. */
#define CONFIG_VALUE 1
@@ -863,6 +865,7 @@
/* wTotalLength computed by usb_gadget_config_buf() */
.bNumInterfaces = 1,
.bConfigurationValue = CONFIG_VALUE,
+ .iConfiguration = STRING_CONFIG,
.bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
.bMaxPower = 1, // self-powered
};
@@ -886,6 +889,7 @@
.bInterfaceClass = USB_CLASS_MASS_STORAGE,
.bInterfaceSubClass = USB_SC_SCSI, // Adjusted during fsg_bind()
.bInterfaceProtocol = USB_PR_BULK, // Adjusted during fsg_bind()
+ .iInterface = STRING_INTERFACE,
};
/* Three full-speed endpoint descriptors: bulk-in, bulk-out,
@@ -1009,7 +1013,7 @@
/* The CBI specification limits the serial string to 12 uppercase hexadecimal
* characters. */
-static char manufacturer[50];
+static char manufacturer[64];
static char serial[13];
/* Static strings, in UTF-8 (for simplicity we use only ASCII characters) */
@@ -1017,6 +1021,8 @@
{STRING_MANUFACTURER, manufacturer},
{STRING_PRODUCT, longname},
{STRING_SERIAL, serial},
+ {STRING_CONFIG, "Self-powered"},
+ {STRING_INTERFACE, "Mass Storage"},
{}
};
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel