diff options
author | David Brownell <david-b@pacbell.net> | 2005-05-07 16:05:18 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-06-27 17:43:54 -0400 |
commit | 320f34595c3cf37d180a087a935c050e4ac0e4d5 (patch) | |
tree | c6f8ad80ca2d57d3b6b2584af427f7dd2b6cd5ae /drivers/usb/gadget/net2280.c | |
parent | 1bbc169621cbe502b9143a27eb12802a0f1d43a0 (diff) |
[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: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget/net2280.c')
-rw-r--r-- | drivers/usb/gadget/net2280.c | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index e47e398daeb5..13a3dbc9949b 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c | |||
@@ -448,7 +448,7 @@ net2280_free_request (struct usb_ep *_ep, struct usb_request *_req) | |||
448 | #elif defined(CONFIG_PPC) && !defined(CONFIG_NOT_COHERENT_CACHE) | 448 | #elif defined(CONFIG_PPC) && !defined(CONFIG_NOT_COHERENT_CACHE) |
449 | #define USE_KMALLOC | 449 | #define USE_KMALLOC |
450 | 450 | ||
451 | #elif defined(CONFIG_MIPS) && !defined(CONFIG_NONCOHERENT_IO) | 451 | #elif defined(CONFIG_MIPS) && !defined(CONFIG_DMA_NONCOHERENT) |
452 | #define USE_KMALLOC | 452 | #define USE_KMALLOC |
453 | 453 | ||
454 | /* FIXME there are other cases, including an x86-64 one ... */ | 454 | /* FIXME there are other cases, including an x86-64 one ... */ |
@@ -1113,7 +1113,7 @@ static void restart_dma (struct net2280_ep *ep) | |||
1113 | if (ep->in_fifo_validate) | 1113 | if (ep->in_fifo_validate) |
1114 | dmactl |= (1 << DMA_FIFO_VALIDATE); | 1114 | dmactl |= (1 << DMA_FIFO_VALIDATE); |
1115 | list_for_each_entry (entry, &ep->queue, queue) { | 1115 | list_for_each_entry (entry, &ep->queue, queue) { |
1116 | u32 dmacount; | 1116 | __le32 dmacount; |
1117 | 1117 | ||
1118 | if (entry == req) | 1118 | if (entry == req) |
1119 | continue; | 1119 | continue; |
@@ -1238,7 +1238,7 @@ static int net2280_dequeue (struct usb_ep *_ep, struct usb_request *_req) | |||
1238 | &ep->dma->dmadesc); | 1238 | &ep->dma->dmadesc); |
1239 | if (req->td->dmacount & dma_done_ie) | 1239 | if (req->td->dmacount & dma_done_ie) |
1240 | writel (readl (&ep->dma->dmacount) | 1240 | writel (readl (&ep->dma->dmacount) |
1241 | | dma_done_ie, | 1241 | | le32_to_cpu(dma_done_ie), |
1242 | &ep->dma->dmacount); | 1242 | &ep->dma->dmacount); |
1243 | } else { | 1243 | } else { |
1244 | struct net2280_request *prev; | 1244 | struct net2280_request *prev; |
@@ -1779,6 +1779,9 @@ static void set_fifo_mode (struct net2280 *dev, int mode) | |||
1779 | list_add_tail (&dev->ep [6].ep.ep_list, &dev->gadget.ep_list); | 1779 | list_add_tail (&dev->ep [6].ep.ep_list, &dev->gadget.ep_list); |
1780 | } | 1780 | } |
1781 | 1781 | ||
1782 | /* just declare this in any driver that really need it */ | ||
1783 | extern int net2280_set_fifo_mode (struct usb_gadget *gadget, int mode); | ||
1784 | |||
1782 | /** | 1785 | /** |
1783 | * net2280_set_fifo_mode - change allocation of fifo buffers | 1786 | * net2280_set_fifo_mode - change allocation of fifo buffers |
1784 | * @gadget: access to the net2280 device that will be updated | 1787 | * @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 | cpu_to_le32s (&u.raw [0]); | 2385 | cpu_to_le32s (&u.raw [0]); |
2383 | cpu_to_le32s (&u.raw [1]); | 2386 | cpu_to_le32s (&u.raw [1]); |
2384 | 2387 | ||
2385 | le16_to_cpus (&u.r.wValue); | 2388 | #define w_value le16_to_cpup (&u.r.wValue) |
2386 | le16_to_cpus (&u.r.wIndex); | 2389 | #define w_index le16_to_cpup (&u.r.wIndex) |
2387 | le16_to_cpus (&u.r.wLength); | 2390 | #define w_length le16_to_cpup (&u.r.wLength) |
2388 | 2391 | ||
2389 | /* ack the irq */ | 2392 | /* ack the irq */ |
2390 | writel (1 << SETUP_PACKET_INTERRUPT, &dev->regs->irqstat0); | 2393 | writel (1 << SETUP_PACKET_INTERRUPT, &dev->regs->irqstat0); |
@@ -2413,25 +2416,25 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) | |||
2413 | switch (u.r.bRequest) { | 2416 | switch (u.r.bRequest) { |
2414 | case USB_REQ_GET_STATUS: { | 2417 | case USB_REQ_GET_STATUS: { |
2415 | struct net2280_ep *e; | 2418 | struct net2280_ep *e; |
2416 | u16 status; | 2419 | __le32 status; |
2417 | 2420 | ||
2418 | /* hw handles device and interface status */ | 2421 | /* hw handles device and interface status */ |
2419 | if (u.r.bRequestType != (USB_DIR_IN|USB_RECIP_ENDPOINT)) | 2422 | if (u.r.bRequestType != (USB_DIR_IN|USB_RECIP_ENDPOINT)) |
2420 | goto delegate; | 2423 | goto delegate; |
2421 | if ((e = get_ep_by_addr (dev, u.r.wIndex)) == 0 | 2424 | if ((e = get_ep_by_addr (dev, w_index)) == 0 |
2422 | || u.r.wLength > 2) | 2425 | || w_length > 2) |
2423 | goto do_stall; | 2426 | goto do_stall; |
2424 | 2427 | ||
2425 | if (readl (&e->regs->ep_rsp) | 2428 | if (readl (&e->regs->ep_rsp) |
2426 | & (1 << SET_ENDPOINT_HALT)) | 2429 | & (1 << SET_ENDPOINT_HALT)) |
2427 | status = __constant_cpu_to_le16 (1); | 2430 | status = __constant_cpu_to_le32 (1); |
2428 | else | 2431 | else |
2429 | status = __constant_cpu_to_le16 (0); | 2432 | status = __constant_cpu_to_le32 (0); |
2430 | 2433 | ||
2431 | /* don't bother with a request object! */ | 2434 | /* don't bother with a request object! */ |
2432 | writel (0, &dev->epregs [0].ep_irqenb); | 2435 | writel (0, &dev->epregs [0].ep_irqenb); |
2433 | set_fifo_bytecount (ep, u.r.wLength); | 2436 | set_fifo_bytecount (ep, w_length); |
2434 | writel (status, &dev->epregs [0].ep_data); | 2437 | writel ((__force u32)status, &dev->epregs [0].ep_data); |
2435 | allow_status (ep); | 2438 | allow_status (ep); |
2436 | VDEBUG (dev, "%s stat %02x\n", ep->ep.name, status); | 2439 | VDEBUG (dev, "%s stat %02x\n", ep->ep.name, status); |
2437 | goto next_endpoints; | 2440 | goto next_endpoints; |
@@ -2443,10 +2446,10 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) | |||
2443 | /* hw handles device features */ | 2446 | /* hw handles device features */ |
2444 | if (u.r.bRequestType != USB_RECIP_ENDPOINT) | 2447 | if (u.r.bRequestType != USB_RECIP_ENDPOINT) |
2445 | goto delegate; | 2448 | goto delegate; |
2446 | if (u.r.wValue != USB_ENDPOINT_HALT | 2449 | if (w_value != USB_ENDPOINT_HALT |
2447 | || u.r.wLength != 0) | 2450 | || w_length != 0) |
2448 | goto do_stall; | 2451 | goto do_stall; |
2449 | if ((e = get_ep_by_addr (dev, u.r.wIndex)) == 0) | 2452 | if ((e = get_ep_by_addr (dev, w_index)) == 0) |
2450 | goto do_stall; | 2453 | goto do_stall; |
2451 | clear_halt (e); | 2454 | clear_halt (e); |
2452 | allow_status (ep); | 2455 | allow_status (ep); |
@@ -2460,10 +2463,10 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) | |||
2460 | /* hw handles device features */ | 2463 | /* hw handles device features */ |
2461 | if (u.r.bRequestType != USB_RECIP_ENDPOINT) | 2464 | if (u.r.bRequestType != USB_RECIP_ENDPOINT) |
2462 | goto delegate; | 2465 | goto delegate; |
2463 | if (u.r.wValue != USB_ENDPOINT_HALT | 2466 | if (w_value != USB_ENDPOINT_HALT |
2464 | || u.r.wLength != 0) | 2467 | || w_length != 0) |
2465 | goto do_stall; | 2468 | goto do_stall; |
2466 | if ((e = get_ep_by_addr (dev, u.r.wIndex)) == 0) | 2469 | if ((e = get_ep_by_addr (dev, w_index)) == 0) |
2467 | goto do_stall; | 2470 | goto do_stall; |
2468 | set_halt (e); | 2471 | set_halt (e); |
2469 | allow_status (ep); | 2472 | allow_status (ep); |
@@ -2473,10 +2476,10 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) | |||
2473 | break; | 2476 | break; |
2474 | default: | 2477 | default: |
2475 | delegate: | 2478 | delegate: |
2476 | VDEBUG (dev, "setup %02x.%02x v%04x i%04x " | 2479 | VDEBUG (dev, "setup %02x.%02x v%04x i%04x l%04x" |
2477 | "ep_cfg %08x\n", | 2480 | "ep_cfg %08x\n", |
2478 | u.r.bRequestType, u.r.bRequest, | 2481 | u.r.bRequestType, u.r.bRequest, |
2479 | u.r.wValue, u.r.wIndex, | 2482 | w_value, w_index, w_length, |
2480 | readl (&ep->regs->ep_cfg)); | 2483 | readl (&ep->regs->ep_cfg)); |
2481 | spin_unlock (&dev->lock); | 2484 | spin_unlock (&dev->lock); |
2482 | tmp = dev->driver->setup (&dev->gadget, &u.r); | 2485 | tmp = dev->driver->setup (&dev->gadget, &u.r); |
@@ -2497,6 +2500,10 @@ do_stall: | |||
2497 | */ | 2500 | */ |
2498 | } | 2501 | } |
2499 | 2502 | ||
2503 | #undef w_value | ||
2504 | #undef w_index | ||
2505 | #undef w_length | ||
2506 | |||
2500 | next_endpoints: | 2507 | next_endpoints: |
2501 | /* endpoint data irq ? */ | 2508 | /* endpoint data irq ? */ |
2502 | scratch = stat & 0x7f; | 2509 | scratch = stat & 0x7f; |
@@ -2653,7 +2660,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat) | |||
2653 | restart_dma (ep); | 2660 | restart_dma (ep); |
2654 | else if (ep->is_in && use_dma_chaining) { | 2661 | else if (ep->is_in && use_dma_chaining) { |
2655 | struct net2280_request *req; | 2662 | struct net2280_request *req; |
2656 | u32 dmacount; | 2663 | __le32 dmacount; |
2657 | 2664 | ||
2658 | /* the descriptor at the head of the chain | 2665 | /* the descriptor at the head of the chain |
2659 | * may still have VALID_BIT clear; that's | 2666 | * may still have VALID_BIT clear; that's |