#ifdef CONFIG_USB_INVENTRA_DMA
/* done if urb buffer is full or short packet is recd */
- done = ((urb->actual_length + xfer_len) >=
- urb->transfer_buffer_length)
- || (dma->actual_len & (qh->maxpacket - 1));
+ done = (urb->actual_length + xfer_len >=
+ urb->transfer_buffer_length
+ || dma->actual_len < qh->maxpacket);
/* send IN token for next packet, without AUTOREQ */
if (!done) {
static inline struct usb_hcd *musb_to_hcd(struct musb *musb)
{
- return (struct usb_hcd *) (((void *)musb)
- - offsetof(struct usb_hcd, hcd_priv));
+ return container_of((void *) musb, struct usb_hcd, hcd_priv);
}
static inline struct musb *hcd_to_musb(struct usb_hcd *hcd)
{
- return (void *) hcd->hcd_priv;
+ return (struct musb *) (hcd->hcd_priv);
}
/* stored in "usb_host_endpoint.hcpriv" for scheduled endpoints */
{
if (list_empty(q))
return NULL;
- return container_of(q->next, struct musb_qh, ring);
+ return list_entry(q->next, struct musb_qh, ring);
}
queue = &qh->hep->urb_list;
if (list_empty(queue))
return NULL;
- return container_of(queue->next, struct urb, urb_list);
+ return list_entry(queue->next, struct urb, urb_list);
#else
return NULL;
#endif
/*---------------------------------------------------------------------*/
+/* Caller may or may not hold musb->lock */
int musb_hub_status_data(struct usb_hcd *hcd, char *buf)
{
struct musb *musb = hcd_to_musb(hcd);
int retval = 0;
unsigned long flags;
- if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)))
+ spin_lock_irqsave(&musb->lock, flags);
+
+ if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) {
+ spin_unlock_irqrestore(&musb->lock, flags);
return -ESHUTDOWN;
+ }
/* hub features: always zero, setting is a NOP
* port features: reported, sometimes updated when host is active
* no indicators
*/
- spin_lock_irqsave(&musb->lock, flags);
switch (typeReq) {
case ClearHubFeature:
case SetHubFeature:
}
break;
case ClearPortFeature:
- if (wIndex != 1)
+ if ((wIndex & 0xff) != 1)
goto error;
switch (wValue) {
/* finish RESET signaling? */
if ((musb->port1_status & USB_PORT_STAT_RESET)
- && time_after(jiffies, musb->rh_timer))
+ && time_after_eq(jiffies, musb->rh_timer))
musb_port_reset(musb, false);
/* finish RESUME signaling? */
if ((musb->port1_status & MUSB_PORT_STAT_RESUME)
- && time_after(jiffies, musb->rh_timer)) {
+ && time_after_eq(jiffies, musb->rh_timer)) {
u8 power;
power = musb_readb(musb->mregs, MUSB_POWER);