X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fusb%2Fgadget%2Flh7a40x_udc.c;h=0d3424eda0380f622d0b96053132ad873f310e7f;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=0def9f70e88920863b9f2a6380fdf42c33b4205a;hpb=6a77f38946aaee1cd85eeec6cf4229b204c15071;p=linux-2.6.git diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c index 0def9f70e..0d3424eda 100644 --- a/drivers/usb/gadget/lh7a40x_udc.c +++ b/drivers/usb/gadget/lh7a40x_udc.c @@ -21,6 +21,8 @@ * */ +#include + #include "lh7a40x_udc.h" //#define DEBUG printk @@ -71,13 +73,13 @@ static char *state_names[] = { static int lh7a40x_ep_enable(struct usb_ep *ep, const struct usb_endpoint_descriptor *); static int lh7a40x_ep_disable(struct usb_ep *ep); -static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep, int); +static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep, gfp_t); static void lh7a40x_free_request(struct usb_ep *ep, struct usb_request *); static void *lh7a40x_alloc_buffer(struct usb_ep *ep, unsigned, dma_addr_t *, - int); + gfp_t); static void lh7a40x_free_buffer(struct usb_ep *ep, void *, dma_addr_t, unsigned); -static int lh7a40x_queue(struct usb_ep *ep, struct usb_request *, int); +static int lh7a40x_queue(struct usb_ep *ep, struct usb_request *, gfp_t); static int lh7a40x_dequeue(struct usb_ep *ep, struct usb_request *); static int lh7a40x_set_halt(struct usb_ep *ep, int); static int lh7a40x_fifo_status(struct usb_ep *ep); @@ -705,7 +707,7 @@ void nuke(struct lh7a40x_ep *ep, int status) done(ep, req, status); } - /* Disable IRQ if EP is enabled (has decriptor) */ + /* Disable IRQ if EP is enabled (has descriptor) */ if (ep->desc) pio_irq_disable(ep_index(ep)); } @@ -1060,11 +1062,11 @@ static int lh7a40x_ep_enable(struct usb_ep *_ep, ep->pio_irqs = 0; ep->ep.maxpacket = le16_to_cpu(desc->wMaxPacketSize); + spin_unlock_irqrestore(&ep->dev->lock, flags); + /* Reset halt state (does flush) */ lh7a40x_set_halt(_ep, 0); - spin_unlock_irqrestore(&ep->dev->lock, flags); - DEBUG("%s: enabled %s\n", __FUNCTION__, _ep->name); return 0; } @@ -1106,17 +1108,16 @@ static int lh7a40x_ep_disable(struct usb_ep *_ep) } static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep, - int gfp_flags) + gfp_t gfp_flags) { struct lh7a40x_request *req; DEBUG("%s, %p\n", __FUNCTION__, ep); - req = kmalloc(sizeof *req, gfp_flags); + req = kzalloc(sizeof(*req), gfp_flags); if (!req) return 0; - memset(req, 0, sizeof *req); INIT_LIST_HEAD(&req->queue); return &req->req; @@ -1134,7 +1135,7 @@ static void lh7a40x_free_request(struct usb_ep *ep, struct usb_request *_req) } static void *lh7a40x_alloc_buffer(struct usb_ep *ep, unsigned bytes, - dma_addr_t * dma, int gfp_flags) + dma_addr_t * dma, gfp_t gfp_flags) { char *retval; @@ -1158,7 +1159,7 @@ static void lh7a40x_free_buffer(struct usb_ep *ep, void *buf, dma_addr_t dma, * NOTE: Sets INDEX register */ static int lh7a40x_queue(struct usb_ep *_ep, struct usb_request *_req, - int gfp_flags) + gfp_t gfp_flags) { struct lh7a40x_request *req; struct lh7a40x_ep *ep; @@ -1773,6 +1774,7 @@ static void lh7a40x_ep0_setup(struct lh7a40x_udc *dev, u32 csr) break; qep = &dev->ep[ep_num]; + spin_unlock(&dev->lock); if (ctrl.bRequest == USB_REQ_SET_FEATURE) { DEBUG_SETUP("SET_FEATURE (%d)\n", ep_num); @@ -1782,6 +1784,7 @@ static void lh7a40x_ep0_setup(struct lh7a40x_udc *dev, u32 csr) ep_num); lh7a40x_set_halt(&qep->ep, 0); } + spin_lock(&dev->lock); usb_set_index(0); /* Reply with a ZLP on next IN token */ @@ -2083,21 +2086,21 @@ static struct lh7a40x_udc memory = { /* * probe - binds to the platform device */ -static int lh7a40x_udc_probe(struct device *_dev) +static int lh7a40x_udc_probe(struct platform_device *pdev) { struct lh7a40x_udc *dev = &memory; int retval; - DEBUG("%s: %p\n", __FUNCTION__, _dev); + DEBUG("%s: %p\n", __FUNCTION__, pdev); spin_lock_init(&dev->lock); - dev->dev = _dev; + dev->dev = &pdev->dev; device_initialize(&dev->gadget.dev); - dev->gadget.dev.parent = _dev; + dev->gadget.dev.parent = &pdev->dev; the_controller = dev; - dev_set_drvdata(_dev, dev); + platform_set_drvdata(pdev, dev); udc_disable(dev); udc_reinit(dev); @@ -2117,11 +2120,11 @@ static int lh7a40x_udc_probe(struct device *_dev) return retval; } -static int lh7a40x_udc_remove(struct device *_dev) +static int lh7a40x_udc_remove(struct platform_device *pdev) { - struct lh7a40x_udc *dev = _dev->driver_data; + struct lh7a40x_udc *dev = platform_get_drvdata(pdev); - DEBUG("%s: %p\n", __FUNCTION__, dev); + DEBUG("%s: %p\n", __FUNCTION__, pdev); udc_disable(dev); remove_proc_files(); @@ -2129,7 +2132,7 @@ static int lh7a40x_udc_remove(struct device *_dev) free_irq(IRQ_USBINTR, dev); - dev_set_drvdata(_dev, 0); + platform_set_drvdata(pdev, 0); the_controller = 0; @@ -2138,25 +2141,27 @@ static int lh7a40x_udc_remove(struct device *_dev) /*-------------------------------------------------------------------------*/ -static struct device_driver udc_driver = { - .name = (char *)driver_name, - .bus = &platform_bus_type, +static struct platform_driver udc_driver = { .probe = lh7a40x_udc_probe, .remove = lh7a40x_udc_remove /* FIXME power management support */ /* .suspend = ... disable UDC */ /* .resume = ... re-enable UDC */ + .driver = { + .name = (char *)driver_name, + .owner = THIS_MODULE, + }, }; static int __init udc_init(void) { DEBUG("%s: %s version %s\n", __FUNCTION__, driver_name, DRIVER_VERSION); - return driver_register(&udc_driver); + return platform_driver_register(&udc_driver); } static void __exit udc_exit(void) { - driver_unregister(&udc_driver); + platform_driver_unregister(&udc_driver); } module_init(udc_init);