Commit 320f3459 authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

[PATCH] USB: net2280 updates (sparse, SETUP api change)

This is mostly "sparse" related updates, one of which was a missing
le32_to_cpu() should have affected big-endian hardware.

Notable is the API change:  setup packets are now provided in USB
byte order.  This affects only big-endian hardware, and the gadget
drivers have been updated in a separate patch.
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 1bbc1696
...@@ -448,7 +448,7 @@ net2280_free_request (struct usb_ep *_ep, struct usb_request *_req) ...@@ -448,7 +448,7 @@ net2280_free_request (struct usb_ep *_ep, struct usb_request *_req)
#elif defined(CONFIG_PPC) && !defined(CONFIG_NOT_COHERENT_CACHE) #elif defined(CONFIG_PPC) && !defined(CONFIG_NOT_COHERENT_CACHE)
#define USE_KMALLOC #define USE_KMALLOC
#elif defined(CONFIG_MIPS) && !defined(CONFIG_NONCOHERENT_IO) #elif defined(CONFIG_MIPS) && !defined(CONFIG_DMA_NONCOHERENT)
#define USE_KMALLOC #define USE_KMALLOC
/* FIXME there are other cases, including an x86-64 one ... */ /* FIXME there are other cases, including an x86-64 one ... */
...@@ -1113,7 +1113,7 @@ static void restart_dma (struct net2280_ep *ep) ...@@ -1113,7 +1113,7 @@ static void restart_dma (struct net2280_ep *ep)
if (ep->in_fifo_validate) if (ep->in_fifo_validate)
dmactl |= (1 << DMA_FIFO_VALIDATE); dmactl |= (1 << DMA_FIFO_VALIDATE);
list_for_each_entry (entry, &ep->queue, queue) { list_for_each_entry (entry, &ep->queue, queue) {
u32 dmacount; __le32 dmacount;
if (entry == req) if (entry == req)
continue; continue;
...@@ -1238,7 +1238,7 @@ static int net2280_dequeue (struct usb_ep *_ep, struct usb_request *_req) ...@@ -1238,7 +1238,7 @@ static int net2280_dequeue (struct usb_ep *_ep, struct usb_request *_req)
&ep->dma->dmadesc); &ep->dma->dmadesc);
if (req->td->dmacount & dma_done_ie) if (req->td->dmacount & dma_done_ie)
writel (readl (&ep->dma->dmacount) writel (readl (&ep->dma->dmacount)
| dma_done_ie, | le32_to_cpu(dma_done_ie),
&ep->dma->dmacount); &ep->dma->dmacount);
} else { } else {
struct net2280_request *prev; struct net2280_request *prev;
...@@ -1779,6 +1779,9 @@ static void set_fifo_mode (struct net2280 *dev, int mode) ...@@ -1779,6 +1779,9 @@ static void set_fifo_mode (struct net2280 *dev, int mode)
list_add_tail (&dev->ep [6].ep.ep_list, &dev->gadget.ep_list); list_add_tail (&dev->ep [6].ep.ep_list, &dev->gadget.ep_list);
} }
/* just declare this in any driver that really need it */
extern int net2280_set_fifo_mode (struct usb_gadget *gadget, int mode);
/** /**
* net2280_set_fifo_mode - change allocation of fifo buffers * net2280_set_fifo_mode - change allocation of fifo buffers
* @gadget: access to the net2280 device that will be updated * @gadget: access to the net2280 device that will be updated
...@@ -2382,9 +2385,9 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) ...@@ -2382,9 +2385,9 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
cpu_to_le32s (&u.raw [0]); cpu_to_le32s (&u.raw [0]);
cpu_to_le32s (&u.raw [1]); cpu_to_le32s (&u.raw [1]);
le16_to_cpus (&u.r.wValue); #define w_value le16_to_cpup (&u.r.wValue)
le16_to_cpus (&u.r.wIndex); #define w_index le16_to_cpup (&u.r.wIndex)
le16_to_cpus (&u.r.wLength); #define w_length le16_to_cpup (&u.r.wLength)
/* ack the irq */ /* ack the irq */
writel (1 << SETUP_PACKET_INTERRUPT, &dev->regs->irqstat0); writel (1 << SETUP_PACKET_INTERRUPT, &dev->regs->irqstat0);
...@@ -2413,25 +2416,25 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) ...@@ -2413,25 +2416,25 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
switch (u.r.bRequest) { switch (u.r.bRequest) {
case USB_REQ_GET_STATUS: { case USB_REQ_GET_STATUS: {
struct net2280_ep *e; struct net2280_ep *e;
u16 status; __le32 status;
/* hw handles device and interface status */ /* hw handles device and interface status */
if (u.r.bRequestType != (USB_DIR_IN|USB_RECIP_ENDPOINT)) if (u.r.bRequestType != (USB_DIR_IN|USB_RECIP_ENDPOINT))
goto delegate; goto delegate;
if ((e = get_ep_by_addr (dev, u.r.wIndex)) == 0 if ((e = get_ep_by_addr (dev, w_index)) == 0
|| u.r.wLength > 2) || w_length > 2)
goto do_stall; goto do_stall;
if (readl (&e->regs->ep_rsp) if (readl (&e->regs->ep_rsp)
& (1 << SET_ENDPOINT_HALT)) & (1 << SET_ENDPOINT_HALT))
status = __constant_cpu_to_le16 (1); status = __constant_cpu_to_le32 (1);
else else
status = __constant_cpu_to_le16 (0); status = __constant_cpu_to_le32 (0);
/* don't bother with a request object! */ /* don't bother with a request object! */
writel (0, &dev->epregs [0].ep_irqenb); writel (0, &dev->epregs [0].ep_irqenb);
set_fifo_bytecount (ep, u.r.wLength); set_fifo_bytecount (ep, w_length);
writel (status, &dev->epregs [0].ep_data); writel ((__force u32)status, &dev->epregs [0].ep_data);
allow_status (ep); allow_status (ep);
VDEBUG (dev, "%s stat %02x\n", ep->ep.name, status); VDEBUG (dev, "%s stat %02x\n", ep->ep.name, status);
goto next_endpoints; goto next_endpoints;
...@@ -2443,10 +2446,10 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) ...@@ -2443,10 +2446,10 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
/* hw handles device features */ /* hw handles device features */
if (u.r.bRequestType != USB_RECIP_ENDPOINT) if (u.r.bRequestType != USB_RECIP_ENDPOINT)
goto delegate; goto delegate;
if (u.r.wValue != USB_ENDPOINT_HALT if (w_value != USB_ENDPOINT_HALT
|| u.r.wLength != 0) || w_length != 0)
goto do_stall; goto do_stall;
if ((e = get_ep_by_addr (dev, u.r.wIndex)) == 0) if ((e = get_ep_by_addr (dev, w_index)) == 0)
goto do_stall; goto do_stall;
clear_halt (e); clear_halt (e);
allow_status (ep); allow_status (ep);
...@@ -2460,10 +2463,10 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) ...@@ -2460,10 +2463,10 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
/* hw handles device features */ /* hw handles device features */
if (u.r.bRequestType != USB_RECIP_ENDPOINT) if (u.r.bRequestType != USB_RECIP_ENDPOINT)
goto delegate; goto delegate;
if (u.r.wValue != USB_ENDPOINT_HALT if (w_value != USB_ENDPOINT_HALT
|| u.r.wLength != 0) || w_length != 0)
goto do_stall; goto do_stall;
if ((e = get_ep_by_addr (dev, u.r.wIndex)) == 0) if ((e = get_ep_by_addr (dev, w_index)) == 0)
goto do_stall; goto do_stall;
set_halt (e); set_halt (e);
allow_status (ep); allow_status (ep);
...@@ -2473,10 +2476,10 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) ...@@ -2473,10 +2476,10 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
break; break;
default: default:
delegate: delegate:
VDEBUG (dev, "setup %02x.%02x v%04x i%04x " VDEBUG (dev, "setup %02x.%02x v%04x i%04x l%04x"
"ep_cfg %08x\n", "ep_cfg %08x\n",
u.r.bRequestType, u.r.bRequest, u.r.bRequestType, u.r.bRequest,
u.r.wValue, u.r.wIndex, w_value, w_index, w_length,
readl (&ep->regs->ep_cfg)); readl (&ep->regs->ep_cfg));
spin_unlock (&dev->lock); spin_unlock (&dev->lock);
tmp = dev->driver->setup (&dev->gadget, &u.r); tmp = dev->driver->setup (&dev->gadget, &u.r);
...@@ -2497,6 +2500,10 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) ...@@ -2497,6 +2500,10 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
*/ */
} }
#undef w_value
#undef w_index
#undef w_length
next_endpoints: next_endpoints:
/* endpoint data irq ? */ /* endpoint data irq ? */
scratch = stat & 0x7f; scratch = stat & 0x7f;
...@@ -2653,7 +2660,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat) ...@@ -2653,7 +2660,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
restart_dma (ep); restart_dma (ep);
else if (ep->is_in && use_dma_chaining) { else if (ep->is_in && use_dma_chaining) {
struct net2280_request *req; struct net2280_request *req;
u32 dmacount; __le32 dmacount;
/* the descriptor at the head of the chain /* the descriptor at the head of the chain
* may still have VALID_BIT clear; that's * may still have VALID_BIT clear; that's
......
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