1
0
Fork 0
forked from len0rd/rockbox

usb: rename usb_drv_recv() to usb_recv_recv_nonblocking()

IMHO the current name is somewhat misleading:

- usb_drv_send() is blocking and we have usb_drv_send_nonblocking()
  for the non-blocking case. This inconsistent naming can only
  promote confusion. (And what would we call a blocking receive?)

- Other hardware abstraction APIs in Rockbox are usually blocking:
  storage, LCD, backlight, audio... in other words, blocking is the
  default expected behavior, with non-blocking calls being a rarity.

Change-Id: I05b41088d09eab582697674f4f06fdca0c8950af
This commit is contained in:
Aidan MacDonald 2021-09-19 10:54:26 +01:00
parent 99f333c64f
commit 672bbe434b
16 changed files with 36 additions and 38 deletions

View file

@ -412,12 +412,12 @@ void usb_drv_cancel_all_transfers(void)
restore_irq(flags);
}
int usb_drv_recv(int ep, void *ptr, int len)
int usb_drv_recv_nonblocking(int ep, void *ptr, int len)
{
struct usb_dev_dma_desc *uc_desc = endpoints[ep][1].uc_desc;
ep &= 0x7f;
logf("usb_drv_recv(%d,%x,%d)\n", ep, (int)ptr, len);
logf("usb_drv_recv_nonblocking(%d,%x,%d)\n", ep, (int)ptr, len);
if (len > USB_DMA_DESC_RXTX_BYTES)
panicf("usb_recv: len=%d > %d", len, USB_DMA_DESC_RXTX_BYTES);
@ -674,7 +674,8 @@ static void handle_out_ep(int ep)
* The usb_storage buffer is 63KB, but Linux sends 120KB.
* We get the first part, but upon re-enabling receive dma we
* get a 'buffer not available' error from the hardware, since
* we haven't gotten the next usb_drv_recv() from the stack yet.
* we haven't gotten the next usb_drv_recv_nonblocking() from
* the stack yet.
* It seems the NAK bit is ignored here and the HW tries to dma
* the incoming data anyway.
* In theory I think the BNA error should be recoverable, but

View file

@ -355,7 +355,7 @@ int usb_drv_send_nonblocking(int endpoint, void *ptr, int length)
}
/* Setup a receive transfer. (non blocking) */
int usb_drv_recv(int endpoint, void* ptr, int length)
int usb_drv_recv_nonblocking(int endpoint, void* ptr, int length)
{
logf("udc: recv(%x)", endpoint);
struct endpoint_t *ep;

View file

@ -1026,8 +1026,8 @@ static bool tnetv_handle_cppi(void)
if (rx_intstatus || tx_intstatus || rcv_sched)
{
/* Request calling again after short delay
* Needed when for example when OUT endpoint has pending
* data but the USB task did not call usb_drv_recv() yet.
* Needed when for example when OUT endpoint has pending data
* but the USB task did not call usb_drv_recv_nonblocking() yet.
*/
return true;
}
@ -1371,7 +1371,7 @@ int usb_drv_send_nonblocking(int endpoint, void* ptr, int length)
return _usb_drv_send(endpoint, ptr, length, false);
}
int usb_drv_recv(int endpoint, void* ptr, int length)
int usb_drv_recv_nonblocking(int endpoint, void* ptr, int length)
{
int epn = EP_NUM(endpoint);
struct ep_runtime_t *ep;
@ -1388,8 +1388,6 @@ int usb_drv_recv(int endpoint, void* ptr, int length)
return 0;
}
void usb_drv_ack(struct usb_ctrlrequest* req);
void usb_drv_set_address(int address)
{
UsbCtrlType usbCtrl;

View file

@ -593,7 +593,7 @@ int usb_drv_send(int endpoint, void* ptr, int length)
return prime_transfer(EP_NUM(endpoint), ptr, length, true, true);
}
int usb_drv_recv(int endpoint, void* ptr, int length)
int usb_drv_recv_nonblocking(int endpoint, void* ptr, int length)
{
//logf("usbrecv(%x, %d)", ptr, length);
return prime_transfer(EP_NUM(endpoint), ptr, length, false, false);

View file

@ -166,7 +166,7 @@ int usb_drv_send_nonblocking(int endpoint, void *ptr, int length)
return 0;
}
int usb_drv_recv(int endpoint, void* ptr, int length)
int usb_drv_recv_nonblocking(int endpoint, void* ptr, int length)
{
ep_transfer(EP_NUM(endpoint), ptr, length, true);
return 0;

View file

@ -609,7 +609,7 @@ int usb_drv_send_nonblocking(int endpoint, void *ptr, int length)
return rc;
}
int usb_drv_recv(int endpoint, void* ptr, int length)
int usb_drv_recv_nonblocking(int endpoint, void* ptr, int length)
{
volatile struct tcc_ep *tcc_ep = &tcc_endpoints[endpoint & 0x7f];
int flags;