Commit 5d209358 authored by Alan Stern's avatar Alan Stern Committed by Tony Lindgren

misc musb tweaks

The patch below fixes a few minor infelicities.
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
parent 15a06ec5
...@@ -1513,9 +1513,9 @@ void musb_host_rx(struct musb *musb, u8 epnum) ...@@ -1513,9 +1513,9 @@ void musb_host_rx(struct musb *musb, u8 epnum)
#ifdef CONFIG_USB_INVENTRA_DMA #ifdef CONFIG_USB_INVENTRA_DMA
/* done if urb buffer is full or short packet is recd */ /* done if urb buffer is full or short packet is recd */
done = ((urb->actual_length + xfer_len) >= done = (urb->actual_length + xfer_len >=
urb->transfer_buffer_length) urb->transfer_buffer_length
|| (dma->actual_len & (qh->maxpacket - 1)); || dma->actual_len < qh->maxpacket);
/* send IN token for next packet, without AUTOREQ */ /* send IN token for next packet, without AUTOREQ */
if (!done) { if (!done) {
......
...@@ -37,13 +37,12 @@ ...@@ -37,13 +37,12 @@
static inline struct usb_hcd *musb_to_hcd(struct musb *musb) static inline struct usb_hcd *musb_to_hcd(struct musb *musb)
{ {
return (struct usb_hcd *) (((void *)musb) return container_of((void *) musb, struct usb_hcd, hcd_priv);
- offsetof(struct usb_hcd, hcd_priv));
} }
static inline struct musb *hcd_to_musb(struct usb_hcd *hcd) 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 */ /* stored in "usb_host_endpoint.hcpriv" for scheduled endpoints */
...@@ -77,7 +76,7 @@ static inline struct musb_qh *first_qh(struct list_head *q) ...@@ -77,7 +76,7 @@ static inline struct musb_qh *first_qh(struct list_head *q)
{ {
if (list_empty(q)) if (list_empty(q))
return NULL; return NULL;
return container_of(q->next, struct musb_qh, ring); return list_entry(q->next, struct musb_qh, ring);
} }
...@@ -102,7 +101,7 @@ static inline struct urb *next_urb(struct musb_qh *qh) ...@@ -102,7 +101,7 @@ static inline struct urb *next_urb(struct musb_qh *qh)
queue = &qh->hep->urb_list; queue = &qh->hep->urb_list;
if (list_empty(queue)) if (list_empty(queue))
return NULL; return NULL;
return container_of(queue->next, struct urb, urb_list); return list_entry(queue->next, struct urb, urb_list);
#else #else
return NULL; return NULL;
#endif #endif
......
...@@ -203,6 +203,7 @@ void musb_root_disconnect(struct musb *musb) ...@@ -203,6 +203,7 @@ void musb_root_disconnect(struct musb *musb)
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
/* Caller may or may not hold musb->lock */
int musb_hub_status_data(struct usb_hcd *hcd, char *buf) int musb_hub_status_data(struct usb_hcd *hcd, char *buf)
{ {
struct musb *musb = hcd_to_musb(hcd); struct musb *musb = hcd_to_musb(hcd);
...@@ -229,14 +230,17 @@ int musb_hub_control( ...@@ -229,14 +230,17 @@ int musb_hub_control(
int retval = 0; int retval = 0;
unsigned long flags; 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; return -ESHUTDOWN;
}
/* hub features: always zero, setting is a NOP /* hub features: always zero, setting is a NOP
* port features: reported, sometimes updated when host is active * port features: reported, sometimes updated when host is active
* no indicators * no indicators
*/ */
spin_lock_irqsave(&musb->lock, flags);
switch (typeReq) { switch (typeReq) {
case ClearHubFeature: case ClearHubFeature:
case SetHubFeature: case SetHubFeature:
...@@ -249,7 +253,7 @@ int musb_hub_control( ...@@ -249,7 +253,7 @@ int musb_hub_control(
} }
break; break;
case ClearPortFeature: case ClearPortFeature:
if (wIndex != 1) if ((wIndex & 0xff) != 1)
goto error; goto error;
switch (wValue) { switch (wValue) {
...@@ -303,12 +307,12 @@ int musb_hub_control( ...@@ -303,12 +307,12 @@ int musb_hub_control(
/* finish RESET signaling? */ /* finish RESET signaling? */
if ((musb->port1_status & USB_PORT_STAT_RESET) 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); musb_port_reset(musb, false);
/* finish RESUME signaling? */ /* finish RESUME signaling? */
if ((musb->port1_status & MUSB_PORT_STAT_RESUME) if ((musb->port1_status & MUSB_PORT_STAT_RESUME)
&& time_after(jiffies, musb->rh_timer)) { && time_after_eq(jiffies, musb->rh_timer)) {
u8 power; u8 power;
power = musb_readb(musb->mregs, MUSB_POWER); power = musb_readb(musb->mregs, MUSB_POWER);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment