Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Freescale QUICC Engine USB Host Controller Driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (c) Freescale Semicondutor, Inc. 2006.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *               Shlomi Gridish <gridish@freescale.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *               Jerry Huang <Chang-Ming.Huang@freescale.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Copyright (c) Logic Product Development, Inc. 2007
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *               Peter Barada <peterb@logicpd.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * Copyright (c) MontaVista Software, Inc. 2008.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *               Anton Vorontsov <avorontsov@ru.mvista.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/usb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/usb/hcd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include "fhci.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) /* maps the hardware error code to the USB error code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) static int status_to_error(u32 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	if (status == USB_TD_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	else if (status & USB_TD_RX_ER_CRC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 		return -EILSEQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	else if (status & USB_TD_RX_ER_NONOCT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 		return -EPROTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	else if (status & USB_TD_RX_ER_OVERUN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		return -ECOMM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	else if (status & USB_TD_RX_ER_BITSTUFF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		return -EPROTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	else if (status & USB_TD_RX_ER_PID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		return -EILSEQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	else if (status & (USB_TD_TX_ER_NAK | USB_TD_TX_ER_TIMEOUT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		return -ETIMEDOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	else if (status & USB_TD_TX_ER_STALL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		return -EPIPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	else if (status & USB_TD_TX_ER_UNDERUN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		return -ENOSR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	else if (status & USB_TD_RX_DATA_UNDERUN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		return -EREMOTEIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	else if (status & USB_TD_RX_DATA_OVERUN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		return -EOVERFLOW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) void fhci_add_td_to_frame(struct fhci_time_frame *frame, struct td *td)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	list_add_tail(&td->frame_lh, &frame->tds_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) void fhci_add_tds_to_ed(struct ed *ed, struct td **td_list, int number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	for (i = 0; i < number; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		struct td *td = td_list[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		list_add_tail(&td->node, &ed->td_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	if (ed->td_head == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		ed->td_head = td_list[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) static struct td *peek_td_from_ed(struct ed *ed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	struct td *td;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	if (!list_empty(&ed->td_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		td = list_entry(ed->td_list.next, struct td, node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		td = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	return td;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) struct td *fhci_remove_td_from_frame(struct fhci_time_frame *frame)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	struct td *td;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	if (!list_empty(&frame->tds_list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		td = list_entry(frame->tds_list.next, struct td, frame_lh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		list_del_init(frame->tds_list.next);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		td = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	return td;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) struct td *fhci_peek_td_from_frame(struct fhci_time_frame *frame)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	struct td *td;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	if (!list_empty(&frame->tds_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		td = list_entry(frame->tds_list.next, struct td, frame_lh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		td = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	return td;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) struct td *fhci_remove_td_from_ed(struct ed *ed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	struct td *td;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	if (!list_empty(&ed->td_list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		td = list_entry(ed->td_list.next, struct td, node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		list_del_init(ed->td_list.next);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		/* if this TD was the ED's head, find next TD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		if (!list_empty(&ed->td_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 			ed->td_head = list_entry(ed->td_list.next, struct td,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 						 node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			ed->td_head = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		td = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	return td;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) struct td *fhci_remove_td_from_done_list(struct fhci_controller_list *p_list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	struct td *td;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	if (!list_empty(&p_list->done_list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		td = list_entry(p_list->done_list.next, struct td, node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		list_del_init(p_list->done_list.next);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		td = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	return td;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) void fhci_move_td_from_ed_to_done_list(struct fhci_usb *usb, struct ed *ed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	struct td *td;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	td = ed->td_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	list_del_init(&td->node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	/* If this TD was the ED's head,find next TD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	if (!list_empty(&ed->td_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		ed->td_head = list_entry(ed->td_list.next, struct td, node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		ed->td_head = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		ed->state = FHCI_ED_SKIP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	ed->toggle_carry = td->toggle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	list_add_tail(&td->node, &usb->hc_list->done_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	if (td->ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		usb->transfer_confirm(usb->fhci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) /* free done FHCI URB resource such as ED and TD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) static void free_urb_priv(struct fhci_hcd *fhci, struct urb *urb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	struct urb_priv *urb_priv = urb->hcpriv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	struct ed *ed = urb_priv->ed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	for (i = 0; i < urb_priv->num_of_tds; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		list_del_init(&urb_priv->tds[i]->node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		fhci_recycle_empty_td(fhci, urb_priv->tds[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	/* if this TD was the ED's head,find the next TD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	if (!list_empty(&ed->td_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		ed->td_head = list_entry(ed->td_list.next, struct td, node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		ed->td_head = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	kfree(urb_priv->tds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	kfree(urb_priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	urb->hcpriv = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	/* if this TD was the ED's head,find next TD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	if (ed->td_head == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		list_del_init(&ed->node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	fhci->active_urbs--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) /* this routine called to complete and free done URB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) void fhci_urb_complete_free(struct fhci_hcd *fhci, struct urb *urb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	free_urb_priv(fhci, urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	if (urb->status == -EINPROGRESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		if (urb->actual_length != urb->transfer_buffer_length &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 				urb->transfer_flags & URB_SHORT_NOT_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 			urb->status = -EREMOTEIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 			urb->status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	usb_hcd_unlink_urb_from_ep(fhci_to_hcd(fhci), urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	spin_unlock(&fhci->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	usb_hcd_giveback_urb(fhci_to_hcd(fhci), urb, urb->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	spin_lock(&fhci->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)  * caculate transfer length/stats and update the urb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)  * Precondition: irqsafe(only for urb-?status locking)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) void fhci_done_td(struct urb *urb, struct td *td)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	struct ed *ed = td->ed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	u32 cc = td->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	/* ISO...drivers see per-TD length/status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	if (ed->mode == FHCI_TF_ISO) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		if (!(urb->transfer_flags & URB_SHORT_NOT_OK &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 				cc == USB_TD_RX_DATA_UNDERUN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 			cc = USB_TD_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		if (usb_pipeout(urb->pipe))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 			len = urb->iso_frame_desc[td->iso_index].length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 			len = td->actual_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		urb->actual_length += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		urb->iso_frame_desc[td->iso_index].actual_length = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		urb->iso_frame_desc[td->iso_index].status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 			status_to_error(cc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	/* BULK,INT,CONTROL... drivers see aggregate length/status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	 * except that "setup" bytes aren't counted and "short" transfers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	 * might not be reported as errors.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		if (td->error_cnt >= 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 			urb->error_count = 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		/* control endpoint only have soft stalls */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		/* update packet status if needed(short may be ok) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		if (!(urb->transfer_flags & URB_SHORT_NOT_OK) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 				cc == USB_TD_RX_DATA_UNDERUN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 			ed->state = FHCI_ED_OPER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 			cc = USB_TD_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		if (cc != USB_TD_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 			if (urb->status == -EINPROGRESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 				urb->status = status_to_error(cc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		/* count all non-empty packets except control SETUP packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		if (td->type != FHCI_TA_SETUP || td->iso_index != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 			urb->actual_length += td->actual_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) /* there are some pedning request to unlink */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) void fhci_del_ed_list(struct fhci_hcd *fhci, struct ed *ed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	struct td *td = peek_td_from_ed(ed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	struct urb *urb = td->urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	struct urb_priv *urb_priv = urb->hcpriv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	if (urb_priv->state == URB_DEL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		td = fhci_remove_td_from_ed(ed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		/* HC may have partly processed this TD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 		if (td->status != USB_TD_INPROGRESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 			fhci_done_td(urb, td);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		/* URB is done;clean up */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 		if (++(urb_priv->tds_cnt) == urb_priv->num_of_tds)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 			fhci_urb_complete_free(fhci, urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) }