On Sep 13, 2013, at 6:45 AM, Hans de Goede <hdego...@redhat.com> wrote:
> Hi, > > On 09/13/2013 02:35 PM, Nathan Hjelm wrote: >> >> On Sep 13, 2013, at 3:18 AM, Hans de Goede <hdego...@redhat.com> wrote: > > <snip> > >>> 2) The alloc_streams backend op should not fail when the user requests more >>> streams >>> then available, instead it should simply allocate the number of >>> available streams >>> available and return that (as mentioned in the doxygen docs) >>> >>> So this is wrong: >>> >>> + (*(cInterface->interface))->SupportsStreams (cInterface->interface, >>> pipeRef, &supportsStreams); >>> + if (num_streams > supportsStreams) { >>> + rc = LIBUSB_ERROR_INVALID_PARAM; >>> + break; >>> + } >>> >>> And should be: >>> >>> + (*(cInterface->interface))->SupportsStreams (cInterface->interface, >>> pipeRef, &supportsStreams); >>> + if (num_streams > supportsStreams) >>> + num_streams = supportsStreams >>> >>> Note the check for how many streams are supported is done inside the kernel >>> with Linux, and it will continue with the maximum number of streams >>> supported >>> if the user request more streams, so it is hard to implement any other logic >>> under Linux, while it seems easy to mimick the Linux behavior with darwin. >> >> Hmm, what exactly are the semantics under Linux if the endpoints support a >> different number of streams? > > The xhci driver (which implements this) first iterates over all endpoints to > find the minimum support by > all of them. Then if the minimum <= 1 it bails with an error (no streams > supported on 1 or more eps), if > the minimum > 1, it allocates the minimum found on all eps. Makes sense. I updated the doxygen of alloc_streams to make those semantics clear. >> To mimic I will either need to take the minimum first and allocate that for >> each endpoint (returning an error if any endpoint returns 0 supported >> streams) or just allocate the smaller of num_streams or the maximum >> supported streams for each endpoint and return the mimimum. > > Right, you need to "calculate" the minimum first. I made the relevant changes and force-pushed an update to my tree. Let me know if there are any other issues. So far, I think the semantics are good. Will need some feedback from the Windows and BSD developers on how well they will work for them. Pete, I know the Microsoft compiler is a sub-par C compiler so I want to make sure uint32_t is available before chaning the type of num_streams. Does it support standard C99 integer types (stdint.h)? -Nathan ------------------------------------------------------------------------------ How ServiceNow helps IT people transform IT departments: 1. Consolidate legacy IT systems to a single system of record for IT 2. Standardize and globalize service processes across IT 3. Implement zero-touch automation to replace manual, redundant tasks http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk _______________________________________________ libusbx-devel mailing list libusbx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libusbx-devel