Does this work for you?  With it you should get the right
product/manufacturer strings when you plug it in (also
in /proc/bus/usb/devices), and the right MAC address.

Ciao,

Duncan.

--- local-tree.orig/drivers/usb/core/message.c  2004-08-14 12:54:51.000000000 +0200
+++ local-tree/drivers/usb/core/message.c       2004-09-21 22:07:11.104005903 +0200
@@ -17,6 +17,7 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/timer.h>
+#include <linux/ctype.h>
 #include <asm/byteorder.h>
 
 #include "hcd.h"       /* for usbcore internals */
@@ -623,6 +624,20 @@
        return result;
 }
 
+static void usb_try_string_workarounds(unsigned char *buf, int *length)
+{
+       int newlength, oldlength = *length;
+
+       for(newlength = 2; newlength + 1 < oldlength; newlength += 2)
+               if (!isprint(buf[newlength]) || buf[newlength + 1])
+                       break;
+
+       if (newlength > 2) {
+               buf[0] = newlength;
+               *length = newlength;
+       }
+}
+
 static int usb_string_sub(struct usb_device *dev, unsigned int langid,
                unsigned int index, unsigned char *buf)
 {
@@ -634,16 +649,24 @@
 
        /* If that failed try to read the descriptor length, then
         * ask for just that many bytes */
-       if (rc < 0) {
+       if (rc < 2) {
                rc = usb_get_string(dev, langid, index, buf, 2);
                if (rc == 2)
                        rc = usb_get_string(dev, langid, index, buf, buf[0]);
        }
 
-       if (rc >= 0) {
+       if (rc < 2)
+               rc = (rc < 0 ? rc : -EINVAL);
+
+       if (rc > 0) {
+               if (!buf[0] && !buf[1])
+                       usb_try_string_workarounds(buf, &rc);
+
                /* There might be extra junk at the end of the descriptor */
                if (buf[0] < rc)
                        rc = buf[0];
+
+               rc = rc - rc % 2;
                if (rc < 2)
                        rc = -EINVAL;
        }


-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to