On Wed, Jun 15, 2005, Alan Stern <[EMAIL PROTECTED]> wrote:
> On Wed, 15 Jun 2005, Pete Zaitcev wrote:
> > Makes sense. I don't need an extra call, everything works as it is.
> > How about this:
> > 
> > diff -urp -X dontdiff linux-2.6.12-rc6/drivers/usb/core/message.c 
> > linux-2.6.12-rc6-lem/drivers/usb/core/message.c
> > --- linux-2.6.12-rc6/drivers/usb/core/message.c     2005-06-06 
> > 13:44:37.000000000 -0700
> > +++ linux-2.6.12-rc6-lem/drivers/usb/core/message.c 2005-06-15 
> > 12:13:52.000000000 -0700
> > @@ -658,8 +658,12 @@ static int usb_string_sub(struct usb_dev
> >  {
> >     int rc;
> >  
> > -   /* Try to read the string descriptor by asking for the maximum
> > -    * possible number of bytes */
> > +   /*
> > +    * Try to read the string descriptor by asking for the maximum
> > +    * possible number of bytes.
> > +    * A request for an odd number of bytes of a UTF-16 string
> > +    * may seem odd, but this is what Windows does, so let's be safe.
> > +    */
> >     rc = usb_get_string(dev, langid, index, buf, 255);
> >  
> >     /* If that failed try to read the descriptor length, then
> > 
> > Signed-off-by: Pete Zaitcev <[EMAIL PROTECTED]>
> 
> That looks good.  Someone at Microsoft may have been thinking of the 
> bLength value in the descriptor header.  Since it's a single byte, it 
> can't hold anything larger than 255.

I can't say why Windows went with a value of 255 here, but I can say
that I have received a couple of reports of devices that only treat the
length as an 8 bit field. I suspect the behavior of these devices is
specifically because Windows only reads 255 bytes.

libusb used to use 256 byte reads as well and since 256 is actually 9
bits, it caused some devices to think we were requesting 0 bytes.

So there is real world evidence that using a read of 255 is the best for
compatibility :)

JE



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to