On Wednesday 11 October 2006 07:22, Alan Stern wrote:
> On Mon, 9 Oct 2006, Inaky Perez-Gonzalez wrote:

> >
> >     pseudo allocates buffer 'maxp' bytes in size using usb_maxpacket()
> >       [?? which gets the max packet size from the interrupt
> >       endpoint]. That's maybe not as proper. According to the spec
> >       (see below) the amount of data to read for the hub status is
> >       (PORTS + 1 + 7) / 8 bytes.
>
> That is the amount of data the hub is _supposed_ to send.  Some hubs have
> been known to send more.  Using the maxpacket size helps to avoid
> EOVERFLOW errors.

Huh, so that *is* the reason -- then it'd be a good idea to document 
it in the code, so the next guy who goes around it doesn't try to do 
the same thing I did.

And on the way there, check that the maxpacketsize is bigger or equal
to (PORTS + 1 + 7) / 8 and flag a warning otherwise.

> >       Haven't been able to track how a fake endpoint descriptor is
> >       generated for the root hub's interrupt endpoint, but somehow we
> >       ended up with wrong data in there and thus we always had two
> >       bytes of buffer space instead of the three that we needed for 16
> >       ports (for example) or more...
>
> It's a static array defined near the beginning of drivers/usb/core/hcd.c.

How about I change the maxpacketsize definition to be (USB_MAXCHILDREN + 
1 + 7) / 8? That way we won't have to worry about it any more (and I doubt
it'll ever go over 255 ... so we don't have to worry about endianess either.

> >     hub_activate()
> >       usb_hcd_submit_urb()
> >         rh_urb_enqueue()
> >           urb->pipe is neither int nor ctl, so it errors out
> >             rh_queue_status()
> >               Returns -EINVAL because the buffer length is smaller
> >               than the minimum needed to report all the hub port
> >               bits as in accordance with USB2.0[11.12.3]. There has
> >               to be trunc((PORTS + 1 + 7) / 8) bytes of space at
> >               least.
> >
> > So this patch simply changes that size calculation to be based on the
> > number of ports declared by the hub on its hub descriptor, so it
> > always floats based on that.
>
> It would be better to change the maxpacket value returned in the
> endpoint descriptor.

I am guessing you refer to changing the value in the static array, right?

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to