Subject: "usbd_get_string: getting lang failed, using 0"
To: None <>
From: Cliff Neighbors <>
List: tech-kern
Date: 11/14/2007 01:25:07
so there I was...  trying to bring up the ohci driver on XYZ chip:

ohci0: OHCI version 1.0
usb0 at ohci0: USB revision 1.0
usbd_get_string: getting lang failed, using 0

it seems in usbd_get_string_desc()\usb_subr.c the minimum value for 
`actlen' as returned from the first call to usbd_do_request_flags()
(to get /* only size byte first */) is 2:

     if (actlen < 2)
             return (USBD_SHORT_XFER);

but the case when `sindex' value is 0, (Language table) `actlen; will
come back with value 1, thanks to ohci_root_ctrl_start()\ohci.c
who does
	totlen = 1;
which ultimately gets returned via xfer->actlen through 
usbd_do_request_flags() as 'actlen'.

So we have ohci_root_ctrl_start() setting xfer->actlen to 1,
and usbd_get_string_desc() insisting `actlen' should be
minimum of 2.

I'm not sure which is right; it seems that when asking for
only the size byte, the minimum can be 1.

here is my diff showing a proposed fix:

diff -u -r1.148.8.1 usb_subr.c
--- usb_subr.c  6 Nov 2007 23:30:42 -0000
+++ usb_subr.c  14 Nov 2007 08:58:19 -0000
@@ -180,7 +180,7 @@
         if (err)
                 return (err);

-       if (actlen < 2)
+       if (actlen < 1)
                 return (USBD_SHORT_XFER);

         USETW(req.wLength, sdesc->bLength);     /* the whole string */

this solves my immediate problem, but I'm not sure it is correct.
can someone who has spent more time in ohci.c review this?