diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-01 13:23:01 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-01 13:23:01 -0700 |
commit | d9a807461fc8cc0d6ba589ea0730d139122af012 (patch) | |
tree | 9d8c7a044659d821748dd40718a22557c04e4299 /drivers/usb/gadget/lpc32xx_udc.c | |
parent | 3498d13b8090c0b0ef911409fbc503a7c4cca6ef (diff) | |
parent | 70c048a238c780c226eb4b115ebaa908cb3b34ec (diff) | |
download | op-kernel-dev-d9a807461fc8cc0d6ba589ea0730d139122af012.zip op-kernel-dev-d9a807461fc8cc0d6ba589ea0730d139122af012.tar.gz |
Merge tag 'usb-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB changes from Greg Kroah-Hartman:
"Here is the big USB pull request for 3.7-rc1
There are lots of gadget driver changes (including copying a bunch of
files into the drivers/staging/ccg/ directory so that the other gadget
drivers can be fixed up properly without breaking that driver), and we
remove the old obsolete ub.c driver from the tree.
There are also the usual XHCI set of updates, and other various driver
changes and updates. We also are trying hard to remove the old dbg()
macro, but the final bits of that removal will be coming in through
the networking tree before we can delete it for good.
All of these patches have been in the linux-next tree.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>"
Fix up several annoying - but fairly mindless - conflicts due to the
termios structure having moved into the tty device, and often clashing
with dbg -> dev_dbg conversion.
* tag 'usb-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (339 commits)
USB: ezusb: move ezusb.c from drivers/usb/serial to drivers/usb/misc
USB: uas: fix gcc warning
USB: uas: fix locking
USB: Fix race condition when removing host controllers
USB: uas: add locking
USB: uas: fix abort
USB: uas: remove aborted field, replace with status bit.
USB: uas: fix task management
USB: uas: keep track of command urbs
xhci: Intel Panther Point BEI quirk.
powerpc/usb: remove checking PHY_CLK_VALID for UTMI PHY
USB: ftdi_sio: add TIAO USB Multi-Protocol Adapter (TUMPA) support
Revert "usb : Add sysfs files to control port power."
USB: serial: remove vizzini driver
usb: host: xhci: Fix Null pointer dereferencing with 71c731a for non-x86 systems
Increase XHCI suspend timeout to 16ms
USB: ohci-at91: fix null pointer in ohci_hcd_at91_overcurrent_irq
USB: sierra_ms: don't keep unused variable
fsl/usb: Add support for USB controller version 2.4
USB: qcaux: add Pantech vendor class match
...
Diffstat (limited to 'drivers/usb/gadget/lpc32xx_udc.c')
-rw-r--r-- | drivers/usb/gadget/lpc32xx_udc.c | 129 |
1 files changed, 51 insertions, 78 deletions
diff --git a/drivers/usb/gadget/lpc32xx_udc.c b/drivers/usb/gadget/lpc32xx_udc.c index f1ec99e..f696fb9 100644 --- a/drivers/usb/gadget/lpc32xx_udc.c +++ b/drivers/usb/gadget/lpc32xx_udc.c @@ -141,8 +141,6 @@ struct lpc32xx_ep { u32 totalints; bool wedge; - - const struct usb_endpoint_descriptor *desc; }; /* @@ -556,10 +554,8 @@ static int proc_udc_show(struct seq_file *s, void *unused) if (udc->enabled && udc->vbus) { proc_ep_show(s, &udc->ep[0]); - list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { - if (ep->desc) - proc_ep_show(s, ep); - } + list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) + proc_ep_show(s, ep); } spin_unlock_irqrestore(&udc->lock, flags); @@ -1453,7 +1449,6 @@ static void udc_reinit(struct lpc32xx_udc *udc) if (i != 0) list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); - ep->desc = NULL; ep->ep.maxpacket = ep->maxpacket; INIT_LIST_HEAD(&ep->queue); ep->req_pending = 0; @@ -1515,7 +1510,7 @@ static void nuke(struct lpc32xx_ep *ep, int status) done(ep, req, status); } - if (ep->desc && status == -ESHUTDOWN) { + if (status == -ESHUTDOWN) { uda_disable_hwepint(ep->udc, ep->hwep_num); udc_disable_hwep(ep->udc, ep->hwep_num); } @@ -1658,9 +1653,6 @@ static int lpc32xx_ep_disable(struct usb_ep *_ep) nuke(ep, -ESHUTDOWN); - /* restore the endpoint's pristine config */ - ep->desc = NULL; - /* Clear all DMA statuses for this EP */ udc_ep_dma_disable(udc, ep->hwep_num); writel(1 << ep->hwep_num, USBD_EOTINTCLR(udc->udp_baseaddr)); @@ -1696,7 +1688,7 @@ static int lpc32xx_ep_enable(struct usb_ep *_ep, unsigned long flags; /* Verify EP data */ - if ((!_ep) || (!ep) || (!desc) || (ep->desc) || + if ((!_ep) || (!ep) || (!desc) || (desc->bDescriptorType != USB_DT_ENDPOINT)) { dev_dbg(udc->dev, "bad ep or descriptor\n"); return -EINVAL; @@ -1754,7 +1746,6 @@ static int lpc32xx_ep_enable(struct usb_ep *_ep, /* Initialize endpoint to match the selected descriptor */ ep->is_in = (desc->bEndpointAddress & USB_DIR_IN) != 0; - ep->desc = desc; ep->ep.maxpacket = maxpacket; /* Map hardware endpoint from base and direction */ @@ -1837,7 +1828,7 @@ static int lpc32xx_ep_queue(struct usb_ep *_ep, udc = ep->udc; - if (!_ep || (!ep->desc && ep->hwep_num_base != 0)) { + if (!_ep) { dev_dbg(udc->dev, "invalid ep\n"); return -EINVAL; } @@ -1976,7 +1967,7 @@ static int lpc32xx_ep_set_halt(struct usb_ep *_ep, int value) struct lpc32xx_udc *udc = ep->udc; unsigned long flags; - if ((!ep) || (ep->desc == NULL) || (ep->hwep_num <= 1)) + if ((!ep) || (ep->hwep_num <= 1)) return -EINVAL; /* Don't halt an IN EP */ @@ -2262,7 +2253,7 @@ static int udc_get_status(struct lpc32xx_udc *udc, u16 reqtype, u16 wIndex) case USB_RECIP_ENDPOINT: tmp = wIndex & USB_ENDPOINT_NUMBER_MASK; ep = &udc->ep[tmp]; - if ((tmp == 0) || (tmp >= NUM_ENDPOINTS) || (tmp && !ep->desc)) + if ((tmp == 0) || (tmp >= NUM_ENDPOINTS)) return -EOPNOTSUPP; if (wIndex & USB_DIR_IN) { @@ -2599,9 +2590,8 @@ static int lpc32xx_pullup(struct usb_gadget *gadget, int is_on) return 0; } -static int lpc32xx_start(struct usb_gadget_driver *driver, - int (*bind)(struct usb_gadget *)); -static int lpc32xx_stop(struct usb_gadget_driver *driver); +static int lpc32xx_start(struct usb_gadget *, struct usb_gadget_driver *); +static int lpc32xx_stop(struct usb_gadget *, struct usb_gadget_driver *); static const struct usb_gadget_ops lpc32xx_udc_ops = { .get_frame = lpc32xx_get_frame, @@ -2609,8 +2599,8 @@ static const struct usb_gadget_ops lpc32xx_udc_ops = { .set_selfpowered = lpc32xx_set_selfpowered, .vbus_session = lpc32xx_vbus_session, .pullup = lpc32xx_pullup, - .start = lpc32xx_start, - .stop = lpc32xx_stop, + .udc_start = lpc32xx_start, + .udc_stop = lpc32xx_stop, }; static void nop_release(struct device *dev) @@ -2618,10 +2608,9 @@ static void nop_release(struct device *dev) /* nothing to free */ } -static struct lpc32xx_udc controller = { +static const struct lpc32xx_udc controller_template = { .gadget = { .ops = &lpc32xx_udc_ops, - .ep0 = &controller.ep[0].ep, .name = driver_name, .dev = { .init_name = "gadget", @@ -2633,7 +2622,6 @@ static struct lpc32xx_udc controller = { .name = "ep0", .ops = &lpc32xx_ep_ops, }, - .udc = &controller, .maxpacket = 64, .hwep_num_base = 0, .hwep_num = 0, /* Can be 0 or 1, has special handling */ @@ -2645,7 +2633,6 @@ static struct lpc32xx_udc controller = { .name = "ep1-int", .ops = &lpc32xx_ep_ops, }, - .udc = &controller, .maxpacket = 64, .hwep_num_base = 2, .hwep_num = 0, /* 2 or 3, will be set later */ @@ -2657,7 +2644,6 @@ static struct lpc32xx_udc controller = { .name = "ep2-bulk", .ops = &lpc32xx_ep_ops, }, - .udc = &controller, .maxpacket = 64, .hwep_num_base = 4, .hwep_num = 0, /* 4 or 5, will be set later */ @@ -2669,7 +2655,6 @@ static struct lpc32xx_udc controller = { .name = "ep3-iso", .ops = &lpc32xx_ep_ops, }, - .udc = &controller, .maxpacket = 1023, .hwep_num_base = 6, .hwep_num = 0, /* 6 or 7, will be set later */ @@ -2681,7 +2666,6 @@ static struct lpc32xx_udc controller = { .name = "ep4-int", .ops = &lpc32xx_ep_ops, }, - .udc = &controller, .maxpacket = 64, .hwep_num_base = 8, .hwep_num = 0, /* 8 or 9, will be set later */ @@ -2693,7 +2677,6 @@ static struct lpc32xx_udc controller = { .name = "ep5-bulk", .ops = &lpc32xx_ep_ops, }, - .udc = &controller, .maxpacket = 64, .hwep_num_base = 10, .hwep_num = 0, /* 10 or 11, will be set later */ @@ -2705,7 +2688,6 @@ static struct lpc32xx_udc controller = { .name = "ep6-iso", .ops = &lpc32xx_ep_ops, }, - .udc = &controller, .maxpacket = 1023, .hwep_num_base = 12, .hwep_num = 0, /* 12 or 13, will be set later */ @@ -2717,7 +2699,6 @@ static struct lpc32xx_udc controller = { .name = "ep7-int", .ops = &lpc32xx_ep_ops, }, - .udc = &controller, .maxpacket = 64, .hwep_num_base = 14, .hwep_num = 0, @@ -2729,7 +2710,6 @@ static struct lpc32xx_udc controller = { .name = "ep8-bulk", .ops = &lpc32xx_ep_ops, }, - .udc = &controller, .maxpacket = 64, .hwep_num_base = 16, .hwep_num = 0, @@ -2741,7 +2721,6 @@ static struct lpc32xx_udc controller = { .name = "ep9-iso", .ops = &lpc32xx_ep_ops, }, - .udc = &controller, .maxpacket = 1023, .hwep_num_base = 18, .hwep_num = 0, @@ -2753,7 +2732,6 @@ static struct lpc32xx_udc controller = { .name = "ep10-int", .ops = &lpc32xx_ep_ops, }, - .udc = &controller, .maxpacket = 64, .hwep_num_base = 20, .hwep_num = 0, @@ -2765,7 +2743,6 @@ static struct lpc32xx_udc controller = { .name = "ep11-bulk", .ops = &lpc32xx_ep_ops, }, - .udc = &controller, .maxpacket = 64, .hwep_num_base = 22, .hwep_num = 0, @@ -2777,7 +2754,6 @@ static struct lpc32xx_udc controller = { .name = "ep12-iso", .ops = &lpc32xx_ep_ops, }, - .udc = &controller, .maxpacket = 1023, .hwep_num_base = 24, .hwep_num = 0, @@ -2789,7 +2765,6 @@ static struct lpc32xx_udc controller = { .name = "ep13-int", .ops = &lpc32xx_ep_ops, }, - .udc = &controller, .maxpacket = 64, .hwep_num_base = 26, .hwep_num = 0, @@ -2801,7 +2776,6 @@ static struct lpc32xx_udc controller = { .name = "ep14-bulk", .ops = &lpc32xx_ep_ops, }, - .udc = &controller, .maxpacket = 64, .hwep_num_base = 28, .hwep_num = 0, @@ -2813,7 +2787,6 @@ static struct lpc32xx_udc controller = { .name = "ep15-bulk", .ops = &lpc32xx_ep_ops, }, - .udc = &controller, .maxpacket = 1023, .hwep_num_base = 30, .hwep_num = 0, @@ -2987,14 +2960,13 @@ static irqreturn_t lpc32xx_usb_vbus_irq(int irq, void *_udc) return IRQ_HANDLED; } -static int lpc32xx_start(struct usb_gadget_driver *driver, - int (*bind)(struct usb_gadget *)) +static int lpc32xx_start(struct usb_gadget *gadget, + struct usb_gadget_driver *driver) { - struct lpc32xx_udc *udc = &controller; - int retval, i; + struct lpc32xx_udc *udc = to_udc(gadget); + int i; - if (!driver || driver->max_speed < USB_SPEED_FULL || - !bind || !driver->setup) { + if (!driver || driver->max_speed < USB_SPEED_FULL || !driver->setup) { dev_err(udc->dev, "bad parameter.\n"); return -EINVAL; } @@ -3011,18 +2983,6 @@ static int lpc32xx_start(struct usb_gadget_driver *driver, udc->selfpowered = 1; udc->vbus = 0; - retval = bind(&udc->gadget); - if (retval) { - dev_err(udc->dev, "bind() returned %d\n", retval); - udc->enabled = 0; - udc->selfpowered = 0; - udc->driver = NULL; - udc->gadget.dev.driver = NULL; - return retval; - } - - dev_dbg(udc->dev, "bound to %s\n", driver->driver.name); - /* Force VBUS process once to check for cable insertion */ udc->last_vbus = udc->vbus = 0; schedule_work(&udc->vbus_job); @@ -3034,22 +2994,19 @@ static int lpc32xx_start(struct usb_gadget_driver *driver, return 0; } -static int lpc32xx_stop(struct usb_gadget_driver *driver) +static int lpc32xx_stop(struct usb_gadget *gadget, + struct usb_gadget_driver *driver) { int i; - struct lpc32xx_udc *udc = &controller; + struct lpc32xx_udc *udc = to_udc(gadget); - if (!driver || driver != udc->driver || !driver->unbind) + if (!driver || driver != udc->driver) return -EINVAL; - /* Disable USB pullup */ - isp1301_pullup_enable(udc, 0, 1); - for (i = IRQ_USB_LP; i <= IRQ_USB_ATX; i++) disable_irq(udc->udp_irq[i]); if (udc->clocked) { - spin_lock(&udc->lock); stop_activity(udc); spin_unlock(&udc->lock); @@ -3069,20 +3026,16 @@ static int lpc32xx_stop(struct usb_gadget_driver *driver) } udc->enabled = 0; - pullup(udc, 0); - - driver->unbind(&udc->gadget); udc->gadget.dev.driver = NULL; udc->driver = NULL; - dev_dbg(udc->dev, "unbound from %s\n", driver->driver.name); return 0; } static void lpc32xx_udc_shutdown(struct platform_device *dev) { /* Force disconnect on reboot */ - struct lpc32xx_udc *udc = &controller; + struct lpc32xx_udc *udc = platform_get_drvdata(dev); pullup(udc, 0); } @@ -3120,12 +3073,21 @@ static u64 lpc32xx_usbd_dmamask = ~(u32) 0x7F; static int __init lpc32xx_udc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct lpc32xx_udc *udc = &controller; + struct lpc32xx_udc *udc; int retval, i; struct resource *res; dma_addr_t dma_handle; struct device_node *isp1301_node; + udc = kzalloc(sizeof(*udc), GFP_KERNEL); + if (!udc) + return -ENOMEM; + + memcpy(udc, &controller_template, sizeof(*udc)); + for (i = 0; i <= 15; i++) + udc->ep[i].udc = udc; + udc->gadget.ep0 = &udc->ep[0].ep; + /* init software state */ udc->gadget.dev.parent = dev; udc->pdev = pdev; @@ -3140,8 +3102,10 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev) } udc->isp1301_i2c_client = isp1301_get_client(isp1301_node); - if (!udc->isp1301_i2c_client) - return -EPROBE_DEFER; + if (!udc->isp1301_i2c_client) { + retval = -EPROBE_DEFER; + goto phy_fail; + } dev_info(udc->dev, "ISP1301 I2C device at address 0x%x\n", udc->isp1301_i2c_client->addr); @@ -3160,8 +3124,10 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev) * IORESOURCE_IRQ, USB transceiver interrupt number */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) - return -ENXIO; + if (!res) { + retval = -ENXIO; + goto resource_fail; + } spin_lock_init(&udc->lock); @@ -3171,7 +3137,8 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev) if (udc->udp_irq[i] < 0) { dev_err(udc->dev, "irq resource %d not available!\n", i); - return udc->udp_irq[i]; + retval = udc->udp_irq[i]; + goto irq_fail; } } @@ -3179,7 +3146,8 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev) udc->io_p_size = resource_size(res); if (!request_mem_region(udc->io_p_start, udc->io_p_size, driver_name)) { dev_err(udc->dev, "someone's using UDC memory\n"); - return -EBUSY; + retval = -EBUSY; + goto request_mem_region_fail; } udc->udp_baseaddr = ioremap(udc->io_p_start, udc->io_p_size); @@ -3208,7 +3176,7 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev) udc->usb_otg_clk = clk_get(&pdev->dev, "ck_usb_otg"); if (IS_ERR(udc->usb_otg_clk)) { dev_err(udc->dev, "failed to acquire USB otg clock\n"); - retval = PTR_ERR(udc->usb_slv_clk); + retval = PTR_ERR(udc->usb_otg_clk); goto usb_otg_clk_get_fail; } @@ -3376,7 +3344,11 @@ pll_get_fail: io_map_fail: release_mem_region(udc->io_p_start, udc->io_p_size); dev_err(udc->dev, "%s probe failed, %d\n", driver_name, retval); - +request_mem_region_fail: +irq_fail: +resource_fail: +phy_fail: + kfree(udc); return retval; } @@ -3414,6 +3386,7 @@ static int __devexit lpc32xx_udc_remove(struct platform_device *pdev) clk_put(udc->usb_pll_clk); iounmap(udc->udp_baseaddr); release_mem_region(udc->io_p_start, udc->io_p_size); + kfree(udc); return 0; } |