mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-16 09:54:35 +00:00
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-usb
This commit is contained in:
commit
97d638e77a
2 changed files with 37 additions and 18 deletions
37
common/usb.c
37
common/usb.c
|
@ -214,8 +214,9 @@ int usb_int_msg(struct usb_device *dev, unsigned long pipe,
|
|||
* clear keyboards LEDs). For data transfers, (storage transfers) we don't
|
||||
* allow control messages with 0 timeout, by previousely resetting the flag
|
||||
* asynch_allowed (usb_disable_asynch(1)).
|
||||
* returns the transferred length if OK or -1 if error. The transferred length
|
||||
* and the current status are stored in the dev->act_len and dev->status.
|
||||
* returns the transferred length if OK, otherwise a negative error code. The
|
||||
* transferred length and the current status are stored in the dev->act_len and
|
||||
* dev->status.
|
||||
*/
|
||||
int usb_control_msg(struct usb_device *dev, unsigned int pipe,
|
||||
unsigned char request, unsigned char requesttype,
|
||||
|
@ -257,11 +258,14 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
|
|||
break;
|
||||
mdelay(1);
|
||||
}
|
||||
|
||||
if (timeout == 0)
|
||||
return -ETIMEDOUT;
|
||||
|
||||
if (dev->status)
|
||||
return -1;
|
||||
|
||||
return dev->act_len;
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------
|
||||
|
@ -562,10 +566,29 @@ int usb_clear_halt(struct usb_device *dev, int pipe)
|
|||
static int usb_get_descriptor(struct usb_device *dev, unsigned char type,
|
||||
unsigned char index, void *buf, int size)
|
||||
{
|
||||
return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
|
||||
USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
|
||||
(type << 8) + index, 0, buf, size,
|
||||
USB_CNTL_TIMEOUT);
|
||||
int i;
|
||||
int result;
|
||||
|
||||
if (size <= 0) /* No point in asking for no data */
|
||||
return -EINVAL;
|
||||
|
||||
memset(buf, 0, size); /* Make sure we parse really received data */
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
/* retry on length 0 or error; some devices are flakey */
|
||||
result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
|
||||
USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
|
||||
(type << 8) + index, 0, buf, size,
|
||||
USB_CNTL_TIMEOUT);
|
||||
if (result <= 0 && result != -ETIMEDOUT)
|
||||
continue;
|
||||
if (result > 1 && ((u8 *)buf)[1] != type) {
|
||||
result = -ENODATA;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
|
|
@ -530,9 +530,8 @@ static void reset_ep(struct usb_device *udev, int ep_index)
|
|||
if (!event)
|
||||
return;
|
||||
|
||||
BUG_ON(TRB_TO_SLOT_ID(le32_to_cpu(event->event_cmd.flags))
|
||||
!= udev->slot_id || GET_COMP_CODE(le32_to_cpu(
|
||||
event->event_cmd.status)) != COMP_SUCCESS);
|
||||
BUG_ON(TRB_TO_SLOT_ID(le32_to_cpu(event->event_cmd.flags)) != udev->slot_id ||
|
||||
GET_COMP_CODE(le32_to_cpu(event->event_cmd.status)) != COMP_SUCCESS);
|
||||
xhci_acknowledge_event(ctrl);
|
||||
}
|
||||
|
||||
|
@ -565,8 +564,7 @@ static void abort_td(struct usb_device *udev, int ep_index)
|
|||
field = le32_to_cpu(event->trans_event.flags);
|
||||
BUG_ON(TRB_TO_SLOT_ID(field) != udev->slot_id);
|
||||
BUG_ON(TRB_TO_EP_INDEX(field) != ep_index);
|
||||
BUG_ON(GET_COMP_CODE(le32_to_cpu(event->trans_event.transfer_len
|
||||
!= COMP_STOP)));
|
||||
BUG_ON(GET_COMP_CODE(le32_to_cpu(event->trans_event.transfer_len != COMP_STOP)));
|
||||
xhci_acknowledge_event(ctrl);
|
||||
|
||||
event = xhci_wait_for_event(ctrl, TRB_COMPLETION);
|
||||
|
@ -580,9 +578,8 @@ static void abort_td(struct usb_device *udev, int ep_index)
|
|||
|
||||
comp = GET_COMP_CODE(le32_to_cpu(event->event_cmd.status));
|
||||
BUG_ON(type != TRB_COMPLETION ||
|
||||
TRB_TO_SLOT_ID(le32_to_cpu(event->event_cmd.flags))
|
||||
!= udev->slot_id || (comp != COMP_SUCCESS && comp
|
||||
!= COMP_CTX_STATE));
|
||||
TRB_TO_SLOT_ID(le32_to_cpu(event->event_cmd.flags)) != udev->slot_id ||
|
||||
(comp != COMP_SUCCESS && comp != COMP_CTX_STATE));
|
||||
xhci_acknowledge_event(ctrl);
|
||||
|
||||
addr = xhci_trb_virt_to_dma(ring->enq_seg,
|
||||
|
@ -592,9 +589,8 @@ static void abort_td(struct usb_device *udev, int ep_index)
|
|||
if (!event)
|
||||
return;
|
||||
|
||||
BUG_ON(TRB_TO_SLOT_ID(le32_to_cpu(event->event_cmd.flags))
|
||||
!= udev->slot_id || GET_COMP_CODE(le32_to_cpu(
|
||||
event->event_cmd.status)) != COMP_SUCCESS);
|
||||
BUG_ON(TRB_TO_SLOT_ID(le32_to_cpu(event->event_cmd.flags)) != udev->slot_id ||
|
||||
GET_COMP_CODE(le32_to_cpu(event->event_cmd.status)) != COMP_SUCCESS);
|
||||
xhci_acknowledge_event(ctrl);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue