-
-/* this is used for variable sized transfers where a normal bulk transfer would
- probably fail, since it expects some minimum size - we just want to
- read/write as much to the pipe as we can
- */
-static int
-usb_tx_all (struct usb_endpoint *eop, void *buf,
- int max_bytes, int bailout, bool in)
-{
- int txed;
- int token;
- int prev_sz = 0;
- struct host *h;
-
- if (max_bytes <= 0)
- return 0;
-
- if (bailout == 0)
- bailout = 512;
-
- txed = 0;
- token = (in) ? USB_TOKEN_IN : USB_TOKEN_OUT;
- h = eop->iface->dev->host;
- while (txed < max_bytes && txed < bailout)
- {
- int sz, err;
- sz = 0;
- err = h->dev->tx_pkt (eop->h_eop, token,
- buf + txed, 0, max_bytes - txed, &sz, true);
- if (prev_sz == 0)
- prev_sz = sz;
- txed += sz;
- /* this should probably be using short packet detection */
- if (err != USB_HOST_ERR_NONE || sz != prev_sz || sz == 0)
- {
- return txed;
- }
- }
- return txed;
-}