diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-03-08 15:21:04 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-03-08 15:21:04 -0500 |
commit | 988addf82e4c03739375279de73929580a2d4a6a (patch) | |
tree | 989ae1cd4e264bbad80c65f04480486246e7b9f3 /drivers/usb/gadget | |
parent | 004c1c7096659d352b83047a7593e91d8a30e3c5 (diff) | |
parent | 25cf84cf377c0aae5dbcf937ea89bc7893db5176 (diff) |
Merge branch 'origin' into devel-stable
Conflicts:
arch/arm/mach-mx2/devices.c
arch/arm/mach-mx2/devices.h
sound/soc/pxa/pxa-ssp.c
Diffstat (limited to 'drivers/usb/gadget')
27 files changed, 479 insertions, 230 deletions
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index ee411206c69..7460cd797f4 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -812,6 +812,16 @@ config USB_CDC_COMPOSITE | |||
812 | Say "y" to link the driver statically, or "m" to build a | 812 | Say "y" to link the driver statically, or "m" to build a |
813 | dynamically linked module. | 813 | dynamically linked module. |
814 | 814 | ||
815 | config USB_G_NOKIA | ||
816 | tristate "Nokia composite gadget" | ||
817 | depends on PHONET | ||
818 | help | ||
819 | The Nokia composite gadget provides support for acm, obex | ||
820 | and phonet in only one composite gadget driver. | ||
821 | |||
822 | It's only really useful for N900 hardware. If you're building | ||
823 | a kernel for N900, say Y or M here. If unsure, say N. | ||
824 | |||
815 | config USB_G_MULTI | 825 | config USB_G_MULTI |
816 | tristate "Multifunction Composite Gadget (EXPERIMENTAL)" | 826 | tristate "Multifunction Composite Gadget (EXPERIMENTAL)" |
817 | depends on BLOCK && NET | 827 | depends on BLOCK && NET |
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 2e2c047262b..43b51da8d72 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile | |||
@@ -43,6 +43,7 @@ g_mass_storage-objs := mass_storage.o | |||
43 | g_printer-objs := printer.o | 43 | g_printer-objs := printer.o |
44 | g_cdc-objs := cdc2.o | 44 | g_cdc-objs := cdc2.o |
45 | g_multi-objs := multi.o | 45 | g_multi-objs := multi.o |
46 | g_nokia-objs := nokia.o | ||
46 | 47 | ||
47 | obj-$(CONFIG_USB_ZERO) += g_zero.o | 48 | obj-$(CONFIG_USB_ZERO) += g_zero.o |
48 | obj-$(CONFIG_USB_AUDIO) += g_audio.o | 49 | obj-$(CONFIG_USB_AUDIO) += g_audio.o |
@@ -55,4 +56,5 @@ obj-$(CONFIG_USB_G_PRINTER) += g_printer.o | |||
55 | obj-$(CONFIG_USB_MIDI_GADGET) += g_midi.o | 56 | obj-$(CONFIG_USB_MIDI_GADGET) += g_midi.o |
56 | obj-$(CONFIG_USB_CDC_COMPOSITE) += g_cdc.o | 57 | obj-$(CONFIG_USB_CDC_COMPOSITE) += g_cdc.o |
57 | obj-$(CONFIG_USB_G_MULTI) += g_multi.o | 58 | obj-$(CONFIG_USB_G_MULTI) += g_multi.o |
59 | obj-$(CONFIG_USB_G_NOKIA) += g_nokia.o | ||
58 | 60 | ||
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 043e04db2a0..12ac9cd32a0 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c | |||
@@ -1656,9 +1656,7 @@ static int __init at91udc_probe(struct platform_device *pdev) | |||
1656 | if (!res) | 1656 | if (!res) |
1657 | return -ENXIO; | 1657 | return -ENXIO; |
1658 | 1658 | ||
1659 | if (!request_mem_region(res->start, | 1659 | if (!request_mem_region(res->start, resource_size(res), driver_name)) { |
1660 | res->end - res->start + 1, | ||
1661 | driver_name)) { | ||
1662 | DBG("someone's using UDC memory\n"); | 1660 | DBG("someone's using UDC memory\n"); |
1663 | return -EBUSY; | 1661 | return -EBUSY; |
1664 | } | 1662 | } |
@@ -1699,7 +1697,7 @@ static int __init at91udc_probe(struct platform_device *pdev) | |||
1699 | udc->ep[3].maxpacket = 64; | 1697 | udc->ep[3].maxpacket = 64; |
1700 | } | 1698 | } |
1701 | 1699 | ||
1702 | udc->udp_baseaddr = ioremap(res->start, res->end - res->start + 1); | 1700 | udc->udp_baseaddr = ioremap(res->start, resource_size(res)); |
1703 | if (!udc->udp_baseaddr) { | 1701 | if (!udc->udp_baseaddr) { |
1704 | retval = -ENOMEM; | 1702 | retval = -ENOMEM; |
1705 | goto fail0a; | 1703 | goto fail0a; |
@@ -1781,7 +1779,7 @@ fail0a: | |||
1781 | if (cpu_is_at91rm9200()) | 1779 | if (cpu_is_at91rm9200()) |
1782 | gpio_free(udc->board.pullup_pin); | 1780 | gpio_free(udc->board.pullup_pin); |
1783 | fail0: | 1781 | fail0: |
1784 | release_mem_region(res->start, res->end - res->start + 1); | 1782 | release_mem_region(res->start, resource_size(res)); |
1785 | DBG("%s probe failed, %d\n", driver_name, retval); | 1783 | DBG("%s probe failed, %d\n", driver_name, retval); |
1786 | return retval; | 1784 | return retval; |
1787 | } | 1785 | } |
@@ -1813,7 +1811,7 @@ static int __exit at91udc_remove(struct platform_device *pdev) | |||
1813 | gpio_free(udc->board.pullup_pin); | 1811 | gpio_free(udc->board.pullup_pin); |
1814 | 1812 | ||
1815 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1813 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1816 | release_mem_region(res->start, res->end - res->start + 1); | 1814 | release_mem_region(res->start, resource_size(res)); |
1817 | 1815 | ||
1818 | clk_put(udc->iclk); | 1816 | clk_put(udc->iclk); |
1819 | clk_put(udc->fclk); | 1817 | clk_put(udc->fclk); |
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index 4e970cf0e29..f79bdfe4bed 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c | |||
@@ -320,7 +320,7 @@ static inline void usba_cleanup_debugfs(struct usba_udc *udc) | |||
320 | static int vbus_is_present(struct usba_udc *udc) | 320 | static int vbus_is_present(struct usba_udc *udc) |
321 | { | 321 | { |
322 | if (gpio_is_valid(udc->vbus_pin)) | 322 | if (gpio_is_valid(udc->vbus_pin)) |
323 | return gpio_get_value(udc->vbus_pin); | 323 | return gpio_get_value(udc->vbus_pin) ^ udc->vbus_pin_inverted; |
324 | 324 | ||
325 | /* No Vbus detection: Assume always present */ | 325 | /* No Vbus detection: Assume always present */ |
326 | return 1; | 326 | return 1; |
@@ -1763,7 +1763,7 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid) | |||
1763 | if (!udc->driver) | 1763 | if (!udc->driver) |
1764 | goto out; | 1764 | goto out; |
1765 | 1765 | ||
1766 | vbus = gpio_get_value(udc->vbus_pin); | 1766 | vbus = vbus_is_present(udc); |
1767 | if (vbus != udc->vbus_prev) { | 1767 | if (vbus != udc->vbus_prev) { |
1768 | if (vbus) { | 1768 | if (vbus) { |
1769 | toggle_bias(1); | 1769 | toggle_bias(1); |
@@ -1914,14 +1914,14 @@ static int __init usba_udc_probe(struct platform_device *pdev) | |||
1914 | udc->vbus_pin = -ENODEV; | 1914 | udc->vbus_pin = -ENODEV; |
1915 | 1915 | ||
1916 | ret = -ENOMEM; | 1916 | ret = -ENOMEM; |
1917 | udc->regs = ioremap(regs->start, regs->end - regs->start + 1); | 1917 | udc->regs = ioremap(regs->start, resource_size(regs)); |
1918 | if (!udc->regs) { | 1918 | if (!udc->regs) { |
1919 | dev_err(&pdev->dev, "Unable to map I/O memory, aborting.\n"); | 1919 | dev_err(&pdev->dev, "Unable to map I/O memory, aborting.\n"); |
1920 | goto err_map_regs; | 1920 | goto err_map_regs; |
1921 | } | 1921 | } |
1922 | dev_info(&pdev->dev, "MMIO registers at 0x%08lx mapped at %p\n", | 1922 | dev_info(&pdev->dev, "MMIO registers at 0x%08lx mapped at %p\n", |
1923 | (unsigned long)regs->start, udc->regs); | 1923 | (unsigned long)regs->start, udc->regs); |
1924 | udc->fifo = ioremap(fifo->start, fifo->end - fifo->start + 1); | 1924 | udc->fifo = ioremap(fifo->start, resource_size(fifo)); |
1925 | if (!udc->fifo) { | 1925 | if (!udc->fifo) { |
1926 | dev_err(&pdev->dev, "Unable to map FIFO, aborting.\n"); | 1926 | dev_err(&pdev->dev, "Unable to map FIFO, aborting.\n"); |
1927 | goto err_map_fifo; | 1927 | goto err_map_fifo; |
@@ -2000,6 +2000,7 @@ static int __init usba_udc_probe(struct platform_device *pdev) | |||
2000 | if (gpio_is_valid(pdata->vbus_pin)) { | 2000 | if (gpio_is_valid(pdata->vbus_pin)) { |
2001 | if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) { | 2001 | if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) { |
2002 | udc->vbus_pin = pdata->vbus_pin; | 2002 | udc->vbus_pin = pdata->vbus_pin; |
2003 | udc->vbus_pin_inverted = pdata->vbus_pin_inverted; | ||
2003 | 2004 | ||
2004 | ret = request_irq(gpio_to_irq(udc->vbus_pin), | 2005 | ret = request_irq(gpio_to_irq(udc->vbus_pin), |
2005 | usba_vbus_irq, 0, | 2006 | usba_vbus_irq, 0, |
diff --git a/drivers/usb/gadget/atmel_usba_udc.h b/drivers/usb/gadget/atmel_usba_udc.h index f7baea307f0..88a2e07a11a 100644 --- a/drivers/usb/gadget/atmel_usba_udc.h +++ b/drivers/usb/gadget/atmel_usba_udc.h | |||
@@ -323,6 +323,7 @@ struct usba_udc { | |||
323 | struct platform_device *pdev; | 323 | struct platform_device *pdev; |
324 | int irq; | 324 | int irq; |
325 | int vbus_pin; | 325 | int vbus_pin; |
326 | int vbus_pin_inverted; | ||
326 | struct clk *pclk; | 327 | struct clk *pclk; |
327 | struct clk *hclk; | 328 | struct clk *hclk; |
328 | 329 | ||
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index cd0914ec898..65a5f94cbc0 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c | |||
@@ -265,16 +265,24 @@ struct usb_ep * __init usb_ep_autoconfig ( | |||
265 | return ep; | 265 | return ep; |
266 | } | 266 | } |
267 | 267 | ||
268 | } else if (gadget_is_sh (gadget) && USB_ENDPOINT_XFER_INT == type) { | 268 | #ifdef CONFIG_BLACKFIN |
269 | /* single buffering is enough; maybe 8 byte fifo is too */ | 269 | } else if (gadget_is_musbhsfc(gadget) || gadget_is_musbhdrc(gadget)) { |
270 | ep = find_ep (gadget, "ep3in-bulk"); | 270 | if ((USB_ENDPOINT_XFER_BULK == type) || |
271 | if (ep && ep_matches (gadget, ep, desc)) | 271 | (USB_ENDPOINT_XFER_ISOC == type)) { |
272 | return ep; | 272 | if (USB_DIR_IN & desc->bEndpointAddress) |
273 | 273 | ep = find_ep (gadget, "ep5in"); | |
274 | } else if (gadget_is_mq11xx (gadget) && USB_ENDPOINT_XFER_INT == type) { | 274 | else |
275 | ep = find_ep (gadget, "ep1-bulk"); | 275 | ep = find_ep (gadget, "ep6out"); |
276 | } else if (USB_ENDPOINT_XFER_INT == type) { | ||
277 | if (USB_DIR_IN & desc->bEndpointAddress) | ||
278 | ep = find_ep(gadget, "ep1in"); | ||
279 | else | ||
280 | ep = find_ep(gadget, "ep2out"); | ||
281 | } else | ||
282 | ep = NULL; | ||
276 | if (ep && ep_matches (gadget, ep, desc)) | 283 | if (ep && ep_matches (gadget, ep, desc)) |
277 | return ep; | 284 | return ep; |
285 | #endif | ||
278 | } | 286 | } |
279 | 287 | ||
280 | /* Second, look at endpoints until an unclaimed one looks usable */ | 288 | /* Second, look at endpoints until an unclaimed one looks usable */ |
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 141372b6e7a..400f80372d9 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -259,7 +259,7 @@ static struct usb_configuration rndis_config_driver = { | |||
259 | 259 | ||
260 | /*-------------------------------------------------------------------------*/ | 260 | /*-------------------------------------------------------------------------*/ |
261 | 261 | ||
262 | #ifdef USB_ETH_EEM | 262 | #ifdef CONFIG_USB_ETH_EEM |
263 | static int use_eem = 1; | 263 | static int use_eem = 1; |
264 | #else | 264 | #else |
265 | static int use_eem; | 265 | static int use_eem; |
diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c index d10353d46b8..e49c7325dce 100644 --- a/drivers/usb/gadget/f_acm.c +++ b/drivers/usb/gadget/f_acm.c | |||
@@ -702,14 +702,6 @@ acm_unbind(struct usb_configuration *c, struct usb_function *f) | |||
702 | /* Some controllers can't support CDC ACM ... */ | 702 | /* Some controllers can't support CDC ACM ... */ |
703 | static inline bool can_support_cdc(struct usb_configuration *c) | 703 | static inline bool can_support_cdc(struct usb_configuration *c) |
704 | { | 704 | { |
705 | /* SH3 doesn't support multiple interfaces */ | ||
706 | if (gadget_is_sh(c->cdev->gadget)) | ||
707 | return false; | ||
708 | |||
709 | /* sa1100 doesn't have a third interrupt endpoint */ | ||
710 | if (gadget_is_sa1100(c->cdev->gadget)) | ||
711 | return false; | ||
712 | |||
713 | /* everything else is *probably* fine ... */ | 705 | /* everything else is *probably* fine ... */ |
714 | return true; | 706 | return true; |
715 | } | 707 | } |
diff --git a/drivers/usb/gadget/f_audio.c b/drivers/usb/gadget/f_audio.c index df77f6131c7..f1e3aad76c3 100644 --- a/drivers/usb/gadget/f_audio.c +++ b/drivers/usb/gadget/f_audio.c | |||
@@ -60,7 +60,7 @@ DECLARE_UAC_AC_HEADER_DESCRIPTOR(2); | |||
60 | #define UAC_DT_TOTAL_LENGTH (UAC_DT_AC_HEADER_LENGTH + UAC_DT_INPUT_TERMINAL_SIZE \ | 60 | #define UAC_DT_TOTAL_LENGTH (UAC_DT_AC_HEADER_LENGTH + UAC_DT_INPUT_TERMINAL_SIZE \ |
61 | + UAC_DT_OUTPUT_TERMINAL_SIZE + UAC_DT_FEATURE_UNIT_SIZE(0)) | 61 | + UAC_DT_OUTPUT_TERMINAL_SIZE + UAC_DT_FEATURE_UNIT_SIZE(0)) |
62 | /* B.3.2 Class-Specific AC Interface Descriptor */ | 62 | /* B.3.2 Class-Specific AC Interface Descriptor */ |
63 | static struct uac_ac_header_descriptor_2 ac_header_desc = { | 63 | static struct uac_ac_header_descriptor_v1_2 ac_header_desc = { |
64 | .bLength = UAC_DT_AC_HEADER_LENGTH, | 64 | .bLength = UAC_DT_AC_HEADER_LENGTH, |
65 | .bDescriptorType = USB_DT_CS_INTERFACE, | 65 | .bDescriptorType = USB_DT_CS_INTERFACE, |
66 | .bDescriptorSubtype = UAC_HEADER, | 66 | .bDescriptorSubtype = UAC_HEADER, |
@@ -124,7 +124,7 @@ static struct usb_audio_control_selector feature_unit = { | |||
124 | }; | 124 | }; |
125 | 125 | ||
126 | #define OUTPUT_TERMINAL_ID 3 | 126 | #define OUTPUT_TERMINAL_ID 3 |
127 | static struct uac_output_terminal_descriptor output_terminal_desc = { | 127 | static struct uac_output_terminal_descriptor_v1 output_terminal_desc = { |
128 | .bLength = UAC_DT_OUTPUT_TERMINAL_SIZE, | 128 | .bLength = UAC_DT_OUTPUT_TERMINAL_SIZE, |
129 | .bDescriptorType = USB_DT_CS_INTERFACE, | 129 | .bDescriptorType = USB_DT_CS_INTERFACE, |
130 | .bDescriptorSubtype = UAC_OUTPUT_TERMINAL, | 130 | .bDescriptorSubtype = UAC_OUTPUT_TERMINAL, |
@@ -154,7 +154,7 @@ static struct usb_interface_descriptor as_interface_alt_1_desc = { | |||
154 | }; | 154 | }; |
155 | 155 | ||
156 | /* B.4.2 Class-Specific AS Interface Descriptor */ | 156 | /* B.4.2 Class-Specific AS Interface Descriptor */ |
157 | static struct uac_as_header_descriptor as_header_desc = { | 157 | static struct uac_as_header_descriptor_v1 as_header_desc = { |
158 | .bLength = UAC_DT_AS_HEADER_SIZE, | 158 | .bLength = UAC_DT_AS_HEADER_SIZE, |
159 | .bDescriptorType = USB_DT_CS_INTERFACE, | 159 | .bDescriptorType = USB_DT_CS_INTERFACE, |
160 | .bDescriptorSubtype = UAC_AS_GENERAL, | 160 | .bDescriptorSubtype = UAC_AS_GENERAL, |
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c index ecf5bdd0ae0..2fff530efc1 100644 --- a/drivers/usb/gadget/f_ecm.c +++ b/drivers/usb/gadget/f_ecm.c | |||
@@ -497,12 +497,9 @@ static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
497 | struct net_device *net; | 497 | struct net_device *net; |
498 | 498 | ||
499 | /* Enable zlps by default for ECM conformance; | 499 | /* Enable zlps by default for ECM conformance; |
500 | * override for musb_hdrc (avoids txdma ovhead) | 500 | * override for musb_hdrc (avoids txdma ovhead). |
501 | * and sa1100 (can't). | ||
502 | */ | 501 | */ |
503 | ecm->port.is_zlp_ok = !( | 502 | ecm->port.is_zlp_ok = !(gadget_is_musbhdrc(cdev->gadget) |
504 | gadget_is_sa1100(cdev->gadget) | ||
505 | || gadget_is_musbhdrc(cdev->gadget) | ||
506 | ); | 503 | ); |
507 | ecm->port.cdc_filter = DEFAULT_FILTER; | 504 | ecm->port.cdc_filter = DEFAULT_FILTER; |
508 | DBG(cdev, "activate ecm\n"); | 505 | DBG(cdev, "activate ecm\n"); |
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index a37640eba43..5a3cdd08f1d 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c | |||
@@ -368,7 +368,7 @@ struct fsg_common { | |||
368 | struct task_struct *thread_task; | 368 | struct task_struct *thread_task; |
369 | 369 | ||
370 | /* Callback function to call when thread exits. */ | 370 | /* Callback function to call when thread exits. */ |
371 | void (*thread_exits)(struct fsg_common *common); | 371 | int (*thread_exits)(struct fsg_common *common); |
372 | /* Gadget's private data. */ | 372 | /* Gadget's private data. */ |
373 | void *private_data; | 373 | void *private_data; |
374 | 374 | ||
@@ -392,8 +392,12 @@ struct fsg_config { | |||
392 | const char *lun_name_format; | 392 | const char *lun_name_format; |
393 | const char *thread_name; | 393 | const char *thread_name; |
394 | 394 | ||
395 | /* Callback function to call when thread exits. */ | 395 | /* Callback function to call when thread exits. If no |
396 | void (*thread_exits)(struct fsg_common *common); | 396 | * callback is set or it returns value lower then zero MSF |
397 | * will force eject all LUNs it operates on (including those | ||
398 | * marked as non-removable or with prevent_medium_removal flag | ||
399 | * set). */ | ||
400 | int (*thread_exits)(struct fsg_common *common); | ||
397 | /* Gadget's private data. */ | 401 | /* Gadget's private data. */ |
398 | void *private_data; | 402 | void *private_data; |
399 | 403 | ||
@@ -614,7 +618,12 @@ static int fsg_setup(struct usb_function *f, | |||
614 | return -EDOM; | 618 | return -EDOM; |
615 | VDBG(fsg, "get max LUN\n"); | 619 | VDBG(fsg, "get max LUN\n"); |
616 | *(u8 *) req->buf = fsg->common->nluns - 1; | 620 | *(u8 *) req->buf = fsg->common->nluns - 1; |
617 | return 1; | 621 | |
622 | /* Respond with data/status */ | ||
623 | req->length = min((u16)1, w_length); | ||
624 | fsg->common->ep0req_name = | ||
625 | ctrl->bRequestType & USB_DIR_IN ? "ep0-in" : "ep0-out"; | ||
626 | return ep0_queue(fsg->common); | ||
618 | } | 627 | } |
619 | 628 | ||
620 | VDBG(fsg, | 629 | VDBG(fsg, |
@@ -1041,7 +1050,7 @@ static void invalidate_sub(struct fsg_lun *curlun) | |||
1041 | unsigned long rc; | 1050 | unsigned long rc; |
1042 | 1051 | ||
1043 | rc = invalidate_mapping_pages(inode->i_mapping, 0, -1); | 1052 | rc = invalidate_mapping_pages(inode->i_mapping, 0, -1); |
1044 | VLDBG(curlun, "invalidate_inode_pages -> %ld\n", rc); | 1053 | VLDBG(curlun, "invalidate_mapping_pages -> %ld\n", rc); |
1045 | } | 1054 | } |
1046 | 1055 | ||
1047 | static int do_verify(struct fsg_common *common) | 1056 | static int do_verify(struct fsg_common *common) |
@@ -2524,14 +2533,6 @@ static void handle_exception(struct fsg_common *common) | |||
2524 | 2533 | ||
2525 | case FSG_STATE_CONFIG_CHANGE: | 2534 | case FSG_STATE_CONFIG_CHANGE: |
2526 | rc = do_set_config(common, new_config); | 2535 | rc = do_set_config(common, new_config); |
2527 | if (common->ep0_req_tag != exception_req_tag) | ||
2528 | break; | ||
2529 | if (rc != 0) { /* STALL on errors */ | ||
2530 | DBG(common, "ep0 set halt\n"); | ||
2531 | usb_ep_set_halt(common->ep0); | ||
2532 | } else { /* Complete the status stage */ | ||
2533 | ep0_queue(common); | ||
2534 | } | ||
2535 | break; | 2536 | break; |
2536 | 2537 | ||
2537 | case FSG_STATE_EXIT: | 2538 | case FSG_STATE_EXIT: |
@@ -2615,8 +2616,20 @@ static int fsg_main_thread(void *common_) | |||
2615 | common->thread_task = NULL; | 2616 | common->thread_task = NULL; |
2616 | spin_unlock_irq(&common->lock); | 2617 | spin_unlock_irq(&common->lock); |
2617 | 2618 | ||
2618 | if (common->thread_exits) | 2619 | if (!common->thread_exits || common->thread_exits(common) < 0) { |
2619 | common->thread_exits(common); | 2620 | struct fsg_lun *curlun = common->luns; |
2621 | unsigned i = common->nluns; | ||
2622 | |||
2623 | down_write(&common->filesem); | ||
2624 | for (; i--; ++curlun) { | ||
2625 | if (!fsg_lun_is_open(curlun)) | ||
2626 | continue; | ||
2627 | |||
2628 | fsg_lun_close(curlun); | ||
2629 | curlun->unit_attention_data = SS_MEDIUM_NOT_PRESENT; | ||
2630 | } | ||
2631 | up_write(&common->filesem); | ||
2632 | } | ||
2620 | 2633 | ||
2621 | /* Let the unbind and cleanup routines know the thread has exited */ | 2634 | /* Let the unbind and cleanup routines know the thread has exited */ |
2622 | complete_and_exit(&common->thread_notifier, 0); | 2635 | complete_and_exit(&common->thread_notifier, 0); |
@@ -2763,10 +2776,7 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, | |||
2763 | if (cfg->release != 0xffff) { | 2776 | if (cfg->release != 0xffff) { |
2764 | i = cfg->release; | 2777 | i = cfg->release; |
2765 | } else { | 2778 | } else { |
2766 | /* The sa1100 controller is not supported */ | 2779 | i = usb_gadget_controller_number(gadget); |
2767 | i = gadget_is_sa1100(gadget) | ||
2768 | ? -1 | ||
2769 | : usb_gadget_controller_number(gadget); | ||
2770 | if (i >= 0) { | 2780 | if (i >= 0) { |
2771 | i = 0x0300 + i; | 2781 | i = 0x0300 + i; |
2772 | } else { | 2782 | } else { |
@@ -2791,8 +2801,7 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, | |||
2791 | * disable stalls. | 2801 | * disable stalls. |
2792 | */ | 2802 | */ |
2793 | common->can_stall = cfg->can_stall && | 2803 | common->can_stall = cfg->can_stall && |
2794 | !(gadget_is_sh(common->gadget) || | 2804 | !(gadget_is_at91(common->gadget)); |
2795 | gadget_is_at91(common->gadget)); | ||
2796 | 2805 | ||
2797 | 2806 | ||
2798 | spin_lock_init(&common->lock); | 2807 | spin_lock_init(&common->lock); |
@@ -2852,7 +2861,6 @@ error_release: | |||
2852 | /* Call fsg_common_release() directly, ref might be not | 2861 | /* Call fsg_common_release() directly, ref might be not |
2853 | * initialised */ | 2862 | * initialised */ |
2854 | fsg_common_release(&common->ref); | 2863 | fsg_common_release(&common->ref); |
2855 | complete(&common->thread_notifier); | ||
2856 | return ERR_PTR(rc); | 2864 | return ERR_PTR(rc); |
2857 | } | 2865 | } |
2858 | 2866 | ||
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c index 95dae4c1ea4..a30e60c7f12 100644 --- a/drivers/usb/gadget/f_rndis.c +++ b/drivers/usb/gadget/f_rndis.c | |||
@@ -769,10 +769,6 @@ rndis_unbind(struct usb_configuration *c, struct usb_function *f) | |||
769 | /* Some controllers can't support RNDIS ... */ | 769 | /* Some controllers can't support RNDIS ... */ |
770 | static inline bool can_support_rndis(struct usb_configuration *c) | 770 | static inline bool can_support_rndis(struct usb_configuration *c) |
771 | { | 771 | { |
772 | /* only two endpoints on sa1100 */ | ||
773 | if (gadget_is_sa1100(c->cdev->gadget)) | ||
774 | return false; | ||
775 | |||
776 | /* everything else is *presumably* fine */ | 772 | /* everything else is *presumably* fine */ |
777 | return true; | 773 | return true; |
778 | } | 774 | } |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 29dfb0277ff..b49d86e3e45 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -1448,7 +1448,7 @@ static void invalidate_sub(struct fsg_lun *curlun) | |||
1448 | unsigned long rc; | 1448 | unsigned long rc; |
1449 | 1449 | ||
1450 | rc = invalidate_mapping_pages(inode->i_mapping, 0, -1); | 1450 | rc = invalidate_mapping_pages(inode->i_mapping, 0, -1); |
1451 | VLDBG(curlun, "invalidate_inode_pages -> %ld\n", rc); | 1451 | VLDBG(curlun, "invalidate_mapping_pages -> %ld\n", rc); |
1452 | } | 1452 | } |
1453 | 1453 | ||
1454 | static int do_verify(struct fsg_dev *fsg) | 1454 | static int do_verify(struct fsg_dev *fsg) |
@@ -3208,15 +3208,11 @@ static int __init check_parameters(struct fsg_dev *fsg) | |||
3208 | * halt bulk endpoints correctly. If one of them is present, | 3208 | * halt bulk endpoints correctly. If one of them is present, |
3209 | * disable stalls. | 3209 | * disable stalls. |
3210 | */ | 3210 | */ |
3211 | if (gadget_is_sh(fsg->gadget) || gadget_is_at91(fsg->gadget)) | 3211 | if (gadget_is_at91(fsg->gadget)) |
3212 | mod_data.can_stall = 0; | 3212 | mod_data.can_stall = 0; |
3213 | 3213 | ||
3214 | if (mod_data.release == 0xffff) { // Parameter wasn't set | 3214 | if (mod_data.release == 0xffff) { // Parameter wasn't set |
3215 | /* The sa1100 controller is not supported */ | 3215 | gcnum = usb_gadget_controller_number(fsg->gadget); |
3216 | if (gadget_is_sa1100(fsg->gadget)) | ||
3217 | gcnum = -1; | ||
3218 | else | ||
3219 | gcnum = usb_gadget_controller_number(fsg->gadget); | ||
3220 | if (gcnum >= 0) | 3216 | if (gcnum >= 0) |
3221 | mod_data.release = 0x0300 + gcnum; | 3217 | mod_data.release = 0x0300 + gcnum; |
3222 | else { | 3218 | else { |
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c index 7881f12413c..3537d51073b 100644 --- a/drivers/usb/gadget/fsl_qe_udc.c +++ b/drivers/usb/gadget/fsl_qe_udc.c | |||
@@ -2749,7 +2749,7 @@ static int __devexit qe_udc_remove(struct of_device *ofdev) | |||
2749 | } | 2749 | } |
2750 | 2750 | ||
2751 | /*-------------------------------------------------------------------------*/ | 2751 | /*-------------------------------------------------------------------------*/ |
2752 | static struct of_device_id __devinitdata qe_udc_match[] = { | 2752 | static const struct of_device_id qe_udc_match[] __devinitconst = { |
2753 | { | 2753 | { |
2754 | .compatible = "fsl,mpc8323-qe-usb", | 2754 | .compatible = "fsl,mpc8323-qe-usb", |
2755 | .data = (void *)PORT_QE, | 2755 | .data = (void *)PORT_QE, |
diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h index f2d270b202f..1edbc12fff1 100644 --- a/drivers/usb/gadget/gadget_chips.h +++ b/drivers/usb/gadget/gadget_chips.h | |||
@@ -45,46 +45,18 @@ | |||
45 | #define gadget_is_goku(g) 0 | 45 | #define gadget_is_goku(g) 0 |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | /* SH3 UDC -- not yet ported 2.4 --> 2.6 */ | ||
49 | #ifdef CONFIG_USB_GADGET_SUPERH | ||
50 | #define gadget_is_sh(g) !strcmp("sh_udc", (g)->name) | ||
51 | #else | ||
52 | #define gadget_is_sh(g) 0 | ||
53 | #endif | ||
54 | |||
55 | /* not yet stable on 2.6 (would help "original Zaurus") */ | ||
56 | #ifdef CONFIG_USB_GADGET_SA1100 | ||
57 | #define gadget_is_sa1100(g) !strcmp("sa1100_udc", (g)->name) | ||
58 | #else | ||
59 | #define gadget_is_sa1100(g) 0 | ||
60 | #endif | ||
61 | |||
62 | #ifdef CONFIG_USB_GADGET_LH7A40X | 48 | #ifdef CONFIG_USB_GADGET_LH7A40X |
63 | #define gadget_is_lh7a40x(g) !strcmp("lh7a40x_udc", (g)->name) | 49 | #define gadget_is_lh7a40x(g) !strcmp("lh7a40x_udc", (g)->name) |
64 | #else | 50 | #else |
65 | #define gadget_is_lh7a40x(g) 0 | 51 | #define gadget_is_lh7a40x(g) 0 |
66 | #endif | 52 | #endif |
67 | 53 | ||
68 | /* handhelds.org tree (?) */ | ||
69 | #ifdef CONFIG_USB_GADGET_MQ11XX | ||
70 | #define gadget_is_mq11xx(g) !strcmp("mq11xx_udc", (g)->name) | ||
71 | #else | ||
72 | #define gadget_is_mq11xx(g) 0 | ||
73 | #endif | ||
74 | |||
75 | #ifdef CONFIG_USB_GADGET_OMAP | 54 | #ifdef CONFIG_USB_GADGET_OMAP |
76 | #define gadget_is_omap(g) !strcmp("omap_udc", (g)->name) | 55 | #define gadget_is_omap(g) !strcmp("omap_udc", (g)->name) |
77 | #else | 56 | #else |
78 | #define gadget_is_omap(g) 0 | 57 | #define gadget_is_omap(g) 0 |
79 | #endif | 58 | #endif |
80 | 59 | ||
81 | /* not yet ported 2.4 --> 2.6 */ | ||
82 | #ifdef CONFIG_USB_GADGET_N9604 | ||
83 | #define gadget_is_n9604(g) !strcmp("n9604_udc", (g)->name) | ||
84 | #else | ||
85 | #define gadget_is_n9604(g) 0 | ||
86 | #endif | ||
87 | |||
88 | /* various unstable versions available */ | 60 | /* various unstable versions available */ |
89 | #ifdef CONFIG_USB_GADGET_PXA27X | 61 | #ifdef CONFIG_USB_GADGET_PXA27X |
90 | #define gadget_is_pxa27x(g) !strcmp("pxa27x_udc", (g)->name) | 62 | #define gadget_is_pxa27x(g) !strcmp("pxa27x_udc", (g)->name) |
@@ -122,14 +94,6 @@ | |||
122 | #define gadget_is_fsl_usb2(g) 0 | 94 | #define gadget_is_fsl_usb2(g) 0 |
123 | #endif | 95 | #endif |
124 | 96 | ||
125 | /* Mentor high speed function controller */ | ||
126 | /* from Montavista kernel (?) */ | ||
127 | #ifdef CONFIG_USB_GADGET_MUSBHSFC | ||
128 | #define gadget_is_musbhsfc(g) !strcmp("musbhsfc_udc", (g)->name) | ||
129 | #else | ||
130 | #define gadget_is_musbhsfc(g) 0 | ||
131 | #endif | ||
132 | |||
133 | /* Mentor high speed "dual role" controller, in peripheral role */ | 97 | /* Mentor high speed "dual role" controller, in peripheral role */ |
134 | #ifdef CONFIG_USB_GADGET_MUSB_HDRC | 98 | #ifdef CONFIG_USB_GADGET_MUSB_HDRC |
135 | #define gadget_is_musbhdrc(g) !strcmp("musb_hdrc", (g)->name) | 99 | #define gadget_is_musbhdrc(g) !strcmp("musb_hdrc", (g)->name) |
@@ -143,13 +107,6 @@ | |||
143 | #define gadget_is_langwell(g) 0 | 107 | #define gadget_is_langwell(g) 0 |
144 | #endif | 108 | #endif |
145 | 109 | ||
146 | /* from Montavista kernel (?) */ | ||
147 | #ifdef CONFIG_USB_GADGET_MPC8272 | ||
148 | #define gadget_is_mpc8272(g) !strcmp("mpc8272_udc", (g)->name) | ||
149 | #else | ||
150 | #define gadget_is_mpc8272(g) 0 | ||
151 | #endif | ||
152 | |||
153 | #ifdef CONFIG_USB_GADGET_M66592 | 110 | #ifdef CONFIG_USB_GADGET_M66592 |
154 | #define gadget_is_m66592(g) !strcmp("m66592_udc", (g)->name) | 111 | #define gadget_is_m66592(g) !strcmp("m66592_udc", (g)->name) |
155 | #else | 112 | #else |
@@ -203,20 +160,12 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget) | |||
203 | return 0x02; | 160 | return 0x02; |
204 | else if (gadget_is_pxa(gadget)) | 161 | else if (gadget_is_pxa(gadget)) |
205 | return 0x03; | 162 | return 0x03; |
206 | else if (gadget_is_sh(gadget)) | ||
207 | return 0x04; | ||
208 | else if (gadget_is_sa1100(gadget)) | ||
209 | return 0x05; | ||
210 | else if (gadget_is_goku(gadget)) | 163 | else if (gadget_is_goku(gadget)) |
211 | return 0x06; | 164 | return 0x06; |
212 | else if (gadget_is_mq11xx(gadget)) | ||
213 | return 0x07; | ||
214 | else if (gadget_is_omap(gadget)) | 165 | else if (gadget_is_omap(gadget)) |
215 | return 0x08; | 166 | return 0x08; |
216 | else if (gadget_is_lh7a40x(gadget)) | 167 | else if (gadget_is_lh7a40x(gadget)) |
217 | return 0x09; | 168 | return 0x09; |
218 | else if (gadget_is_n9604(gadget)) | ||
219 | return 0x10; | ||
220 | else if (gadget_is_pxa27x(gadget)) | 169 | else if (gadget_is_pxa27x(gadget)) |
221 | return 0x11; | 170 | return 0x11; |
222 | else if (gadget_is_s3c2410(gadget)) | 171 | else if (gadget_is_s3c2410(gadget)) |
@@ -225,12 +174,8 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget) | |||
225 | return 0x13; | 174 | return 0x13; |
226 | else if (gadget_is_imx(gadget)) | 175 | else if (gadget_is_imx(gadget)) |
227 | return 0x14; | 176 | return 0x14; |
228 | else if (gadget_is_musbhsfc(gadget)) | ||
229 | return 0x15; | ||
230 | else if (gadget_is_musbhdrc(gadget)) | 177 | else if (gadget_is_musbhdrc(gadget)) |
231 | return 0x16; | 178 | return 0x16; |
232 | else if (gadget_is_mpc8272(gadget)) | ||
233 | return 0x17; | ||
234 | else if (gadget_is_atmel_usba(gadget)) | 179 | else if (gadget_is_atmel_usba(gadget)) |
235 | return 0x18; | 180 | return 0x18; |
236 | else if (gadget_is_fsl_usb2(gadget)) | 181 | else if (gadget_is_fsl_usb2(gadget)) |
@@ -265,10 +210,6 @@ static inline bool gadget_supports_altsettings(struct usb_gadget *gadget) | |||
265 | if (gadget_is_pxa27x(gadget)) | 210 | if (gadget_is_pxa27x(gadget)) |
266 | return false; | 211 | return false; |
267 | 212 | ||
268 | /* SH3 hardware just doesn't do altsettings */ | ||
269 | if (gadget_is_sh(gadget)) | ||
270 | return false; | ||
271 | |||
272 | /* Everything else is *presumably* fine ... */ | 213 | /* Everything else is *presumably* fine ... */ |
273 | return true; | 214 | return true; |
274 | } | 215 | } |
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index d0b1e836f0e..04f6224b7e0 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c | |||
@@ -237,7 +237,7 @@ static const struct usb_interface_descriptor ac_interface_desc = { | |||
237 | }; | 237 | }; |
238 | 238 | ||
239 | /* B.3.2 Class-Specific AC Interface Descriptor */ | 239 | /* B.3.2 Class-Specific AC Interface Descriptor */ |
240 | static const struct uac_ac_header_descriptor_1 ac_header_desc = { | 240 | static const struct uac_ac_header_descriptor_v1_1 ac_header_desc = { |
241 | .bLength = UAC_DT_AC_HEADER_SIZE(1), | 241 | .bLength = UAC_DT_AC_HEADER_SIZE(1), |
242 | .bDescriptorType = USB_DT_CS_INTERFACE, | 242 | .bDescriptorType = USB_DT_CS_INTERFACE, |
243 | .bDescriptorSubtype = USB_MS_HEADER, | 243 | .bDescriptorSubtype = USB_MS_HEADER, |
@@ -618,11 +618,6 @@ gmidi_set_config(struct gmidi_device *dev, unsigned number, gfp_t gfp_flags) | |||
618 | } | 618 | } |
619 | #endif | 619 | #endif |
620 | 620 | ||
621 | if (gadget_is_sa1100(gadget) && dev->config) { | ||
622 | /* tx fifo is full, but we can't clear it...*/ | ||
623 | ERROR(dev, "can't change configurations\n"); | ||
624 | return -ESPIPE; | ||
625 | } | ||
626 | gmidi_reset_config(dev); | 621 | gmidi_reset_config(dev); |
627 | 622 | ||
628 | switch (number) { | 623 | switch (number) { |
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index 112bb40a427..e8edc640381 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c | |||
@@ -1859,7 +1859,7 @@ done: | |||
1859 | 1859 | ||
1860 | /*-------------------------------------------------------------------------*/ | 1860 | /*-------------------------------------------------------------------------*/ |
1861 | 1861 | ||
1862 | static struct pci_device_id pci_ids [] = { { | 1862 | static const struct pci_device_id pci_ids[] = { { |
1863 | .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe), | 1863 | .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe), |
1864 | .class_mask = ~0, | 1864 | .class_mask = ~0, |
1865 | .vendor = 0x102f, /* Toshiba */ | 1865 | .vendor = 0x102f, /* Toshiba */ |
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index bf0f6520c6d..de8a8380350 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c | |||
@@ -194,7 +194,7 @@ enum ep_state { | |||
194 | }; | 194 | }; |
195 | 195 | ||
196 | struct ep_data { | 196 | struct ep_data { |
197 | struct semaphore lock; | 197 | struct mutex lock; |
198 | enum ep_state state; | 198 | enum ep_state state; |
199 | atomic_t count; | 199 | atomic_t count; |
200 | struct dev_data *dev; | 200 | struct dev_data *dev; |
@@ -298,10 +298,10 @@ get_ready_ep (unsigned f_flags, struct ep_data *epdata) | |||
298 | int val; | 298 | int val; |
299 | 299 | ||
300 | if (f_flags & O_NONBLOCK) { | 300 | if (f_flags & O_NONBLOCK) { |
301 | if (down_trylock (&epdata->lock) != 0) | 301 | if (!mutex_trylock(&epdata->lock)) |
302 | goto nonblock; | 302 | goto nonblock; |
303 | if (epdata->state != STATE_EP_ENABLED) { | 303 | if (epdata->state != STATE_EP_ENABLED) { |
304 | up (&epdata->lock); | 304 | mutex_unlock(&epdata->lock); |
305 | nonblock: | 305 | nonblock: |
306 | val = -EAGAIN; | 306 | val = -EAGAIN; |
307 | } else | 307 | } else |
@@ -309,7 +309,8 @@ nonblock: | |||
309 | return val; | 309 | return val; |
310 | } | 310 | } |
311 | 311 | ||
312 | if ((val = down_interruptible (&epdata->lock)) < 0) | 312 | val = mutex_lock_interruptible(&epdata->lock); |
313 | if (val < 0) | ||
313 | return val; | 314 | return val; |
314 | 315 | ||
315 | switch (epdata->state) { | 316 | switch (epdata->state) { |
@@ -323,7 +324,7 @@ nonblock: | |||
323 | // FALLTHROUGH | 324 | // FALLTHROUGH |
324 | case STATE_EP_UNBOUND: /* clean disconnect */ | 325 | case STATE_EP_UNBOUND: /* clean disconnect */ |
325 | val = -ENODEV; | 326 | val = -ENODEV; |
326 | up (&epdata->lock); | 327 | mutex_unlock(&epdata->lock); |
327 | } | 328 | } |
328 | return val; | 329 | return val; |
329 | } | 330 | } |
@@ -393,7 +394,7 @@ ep_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr) | |||
393 | if (likely (data->ep != NULL)) | 394 | if (likely (data->ep != NULL)) |
394 | usb_ep_set_halt (data->ep); | 395 | usb_ep_set_halt (data->ep); |
395 | spin_unlock_irq (&data->dev->lock); | 396 | spin_unlock_irq (&data->dev->lock); |
396 | up (&data->lock); | 397 | mutex_unlock(&data->lock); |
397 | return -EBADMSG; | 398 | return -EBADMSG; |
398 | } | 399 | } |
399 | 400 | ||
@@ -411,7 +412,7 @@ ep_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr) | |||
411 | value = -EFAULT; | 412 | value = -EFAULT; |
412 | 413 | ||
413 | free1: | 414 | free1: |
414 | up (&data->lock); | 415 | mutex_unlock(&data->lock); |
415 | kfree (kbuf); | 416 | kfree (kbuf); |
416 | return value; | 417 | return value; |
417 | } | 418 | } |
@@ -436,7 +437,7 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
436 | if (likely (data->ep != NULL)) | 437 | if (likely (data->ep != NULL)) |
437 | usb_ep_set_halt (data->ep); | 438 | usb_ep_set_halt (data->ep); |
438 | spin_unlock_irq (&data->dev->lock); | 439 | spin_unlock_irq (&data->dev->lock); |
439 | up (&data->lock); | 440 | mutex_unlock(&data->lock); |
440 | return -EBADMSG; | 441 | return -EBADMSG; |
441 | } | 442 | } |
442 | 443 | ||
@@ -455,7 +456,7 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
455 | VDEBUG (data->dev, "%s write %zu IN, status %d\n", | 456 | VDEBUG (data->dev, "%s write %zu IN, status %d\n", |
456 | data->name, len, (int) value); | 457 | data->name, len, (int) value); |
457 | free1: | 458 | free1: |
458 | up (&data->lock); | 459 | mutex_unlock(&data->lock); |
459 | kfree (kbuf); | 460 | kfree (kbuf); |
460 | return value; | 461 | return value; |
461 | } | 462 | } |
@@ -466,7 +467,8 @@ ep_release (struct inode *inode, struct file *fd) | |||
466 | struct ep_data *data = fd->private_data; | 467 | struct ep_data *data = fd->private_data; |
467 | int value; | 468 | int value; |
468 | 469 | ||
469 | if ((value = down_interruptible(&data->lock)) < 0) | 470 | value = mutex_lock_interruptible(&data->lock); |
471 | if (value < 0) | ||
470 | return value; | 472 | return value; |
471 | 473 | ||
472 | /* clean up if this can be reopened */ | 474 | /* clean up if this can be reopened */ |
@@ -476,7 +478,7 @@ ep_release (struct inode *inode, struct file *fd) | |||
476 | data->hs_desc.bDescriptorType = 0; | 478 | data->hs_desc.bDescriptorType = 0; |
477 | usb_ep_disable(data->ep); | 479 | usb_ep_disable(data->ep); |
478 | } | 480 | } |
479 | up (&data->lock); | 481 | mutex_unlock(&data->lock); |
480 | put_ep (data); | 482 | put_ep (data); |
481 | return 0; | 483 | return 0; |
482 | } | 484 | } |
@@ -507,7 +509,7 @@ static long ep_ioctl(struct file *fd, unsigned code, unsigned long value) | |||
507 | } else | 509 | } else |
508 | status = -ENODEV; | 510 | status = -ENODEV; |
509 | spin_unlock_irq (&data->dev->lock); | 511 | spin_unlock_irq (&data->dev->lock); |
510 | up (&data->lock); | 512 | mutex_unlock(&data->lock); |
511 | return status; | 513 | return status; |
512 | } | 514 | } |
513 | 515 | ||
@@ -673,7 +675,7 @@ fail: | |||
673 | value = -ENODEV; | 675 | value = -ENODEV; |
674 | spin_unlock_irq(&epdata->dev->lock); | 676 | spin_unlock_irq(&epdata->dev->lock); |
675 | 677 | ||
676 | up(&epdata->lock); | 678 | mutex_unlock(&epdata->lock); |
677 | 679 | ||
678 | if (unlikely(value)) { | 680 | if (unlikely(value)) { |
679 | kfree(priv); | 681 | kfree(priv); |
@@ -765,7 +767,8 @@ ep_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
765 | u32 tag; | 767 | u32 tag; |
766 | int value, length = len; | 768 | int value, length = len; |
767 | 769 | ||
768 | if ((value = down_interruptible (&data->lock)) < 0) | 770 | value = mutex_lock_interruptible(&data->lock); |
771 | if (value < 0) | ||
769 | return value; | 772 | return value; |
770 | 773 | ||
771 | if (data->state != STATE_EP_READY) { | 774 | if (data->state != STATE_EP_READY) { |
@@ -854,7 +857,7 @@ fail: | |||
854 | data->desc.bDescriptorType = 0; | 857 | data->desc.bDescriptorType = 0; |
855 | data->hs_desc.bDescriptorType = 0; | 858 | data->hs_desc.bDescriptorType = 0; |
856 | } | 859 | } |
857 | up (&data->lock); | 860 | mutex_unlock(&data->lock); |
858 | return value; | 861 | return value; |
859 | fail0: | 862 | fail0: |
860 | value = -EINVAL; | 863 | value = -EINVAL; |
@@ -870,7 +873,7 @@ ep_open (struct inode *inode, struct file *fd) | |||
870 | struct ep_data *data = inode->i_private; | 873 | struct ep_data *data = inode->i_private; |
871 | int value = -EBUSY; | 874 | int value = -EBUSY; |
872 | 875 | ||
873 | if (down_interruptible (&data->lock) != 0) | 876 | if (mutex_lock_interruptible(&data->lock) != 0) |
874 | return -EINTR; | 877 | return -EINTR; |
875 | spin_lock_irq (&data->dev->lock); | 878 | spin_lock_irq (&data->dev->lock); |
876 | if (data->dev->state == STATE_DEV_UNBOUND) | 879 | if (data->dev->state == STATE_DEV_UNBOUND) |
@@ -885,7 +888,7 @@ ep_open (struct inode *inode, struct file *fd) | |||
885 | DBG (data->dev, "%s state %d\n", | 888 | DBG (data->dev, "%s state %d\n", |
886 | data->name, data->state); | 889 | data->name, data->state); |
887 | spin_unlock_irq (&data->dev->lock); | 890 | spin_unlock_irq (&data->dev->lock); |
888 | up (&data->lock); | 891 | mutex_unlock(&data->lock); |
889 | return value; | 892 | return value; |
890 | } | 893 | } |
891 | 894 | ||
@@ -1631,7 +1634,7 @@ static int activate_ep_files (struct dev_data *dev) | |||
1631 | if (!data) | 1634 | if (!data) |
1632 | goto enomem0; | 1635 | goto enomem0; |
1633 | data->state = STATE_EP_DISABLED; | 1636 | data->state = STATE_EP_DISABLED; |
1634 | init_MUTEX (&data->lock); | 1637 | mutex_init(&data->lock); |
1635 | init_waitqueue_head (&data->wait); | 1638 | init_waitqueue_head (&data->wait); |
1636 | 1639 | ||
1637 | strncpy (data->name, ep->name, sizeof (data->name) - 1); | 1640 | strncpy (data->name, ep->name, sizeof (data->name) - 1); |
diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index 19619fbf20a..705cc1f7632 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c | |||
@@ -135,6 +135,12 @@ FSG_MODULE_PARAMETERS(/* no prefix */, mod_data); | |||
135 | static unsigned long msg_registered = 0; | 135 | static unsigned long msg_registered = 0; |
136 | static void msg_cleanup(void); | 136 | static void msg_cleanup(void); |
137 | 137 | ||
138 | static int msg_thread_exits(struct fsg_common *common) | ||
139 | { | ||
140 | msg_cleanup(); | ||
141 | return 0; | ||
142 | } | ||
143 | |||
138 | static int __init msg_do_config(struct usb_configuration *c) | 144 | static int __init msg_do_config(struct usb_configuration *c) |
139 | { | 145 | { |
140 | struct fsg_common *common; | 146 | struct fsg_common *common; |
@@ -147,7 +153,7 @@ static int __init msg_do_config(struct usb_configuration *c) | |||
147 | } | 153 | } |
148 | 154 | ||
149 | fsg_config_from_params(&config, &mod_data); | 155 | fsg_config_from_params(&config, &mod_data); |
150 | config.thread_exits = (void(*)(struct fsg_common*))&msg_cleanup; | 156 | config.thread_exits = msg_thread_exits; |
151 | common = fsg_common_init(0, c->cdev, &config); | 157 | common = fsg_common_init(0, c->cdev, &config); |
152 | if (IS_ERR(common)) | 158 | if (IS_ERR(common)) |
153 | return PTR_ERR(common); | 159 | return PTR_ERR(common); |
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c new file mode 100644 index 00000000000..7d6b66a8572 --- /dev/null +++ b/drivers/usb/gadget/nokia.c | |||
@@ -0,0 +1,259 @@ | |||
1 | /* | ||
2 | * nokia.c -- Nokia Composite Gadget Driver | ||
3 | * | ||
4 | * Copyright (C) 2008-2010 Nokia Corporation | ||
5 | * Contact: Felipe Balbi <felipe.balbi@nokia.com> | ||
6 | * | ||
7 | * This gadget driver borrows from serial.c which is: | ||
8 | * | ||
9 | * Copyright (C) 2003 Al Borchers (alborchers@steinerpoint.com) | ||
10 | * Copyright (C) 2008 by David Brownell | ||
11 | * Copyright (C) 2008 by Nokia Corporation | ||
12 | * | ||
13 | * This software is distributed under the terms of the GNU General | ||
14 | * Public License ("GPL") as published by the Free Software Foundation, | ||
15 | * version 2 of that License. | ||
16 | */ | ||
17 | |||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/utsname.h> | ||
20 | #include <linux/device.h> | ||
21 | |||
22 | #include "u_serial.h" | ||
23 | #include "u_ether.h" | ||
24 | #include "u_phonet.h" | ||
25 | #include "gadget_chips.h" | ||
26 | |||
27 | /* Defines */ | ||
28 | |||
29 | #define NOKIA_VERSION_NUM 0x0211 | ||
30 | #define NOKIA_LONG_NAME "N900 (PC-Suite Mode)" | ||
31 | |||
32 | /*-------------------------------------------------------------------------*/ | ||
33 | |||
34 | /* | ||
35 | * Kbuild is not very cooperative with respect to linking separately | ||
36 | * compiled library objects into one module. So for now we won't use | ||
37 | * separate compilation ... ensuring init/exit sections work to shrink | ||
38 | * the runtime footprint, and giving us at least some parts of what | ||
39 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | ||
40 | */ | ||
41 | #include "composite.c" | ||
42 | #include "usbstring.c" | ||
43 | #include "config.c" | ||
44 | #include "epautoconf.c" | ||
45 | |||
46 | #include "u_serial.c" | ||
47 | #include "f_acm.c" | ||
48 | #include "f_ecm.c" | ||
49 | #include "f_obex.c" | ||
50 | #include "f_serial.c" | ||
51 | #include "f_phonet.c" | ||
52 | #include "u_ether.c" | ||
53 | |||
54 | /*-------------------------------------------------------------------------*/ | ||
55 | |||
56 | #define NOKIA_VENDOR_ID 0x0421 /* Nokia */ | ||
57 | #define NOKIA_PRODUCT_ID 0x01c8 /* Nokia Gadget */ | ||
58 | |||
59 | /* string IDs are assigned dynamically */ | ||
60 | |||
61 | #define STRING_MANUFACTURER_IDX 0 | ||
62 | #define STRING_PRODUCT_IDX 1 | ||
63 | #define STRING_DESCRIPTION_IDX 2 | ||
64 | |||
65 | static char manufacturer_nokia[] = "Nokia"; | ||
66 | static const char product_nokia[] = NOKIA_LONG_NAME; | ||
67 | static const char description_nokia[] = "PC-Suite Configuration"; | ||
68 | |||
69 | static struct usb_string strings_dev[] = { | ||
70 | [STRING_MANUFACTURER_IDX].s = manufacturer_nokia, | ||
71 | [STRING_PRODUCT_IDX].s = NOKIA_LONG_NAME, | ||
72 | [STRING_DESCRIPTION_IDX].s = description_nokia, | ||
73 | { } /* end of list */ | ||
74 | }; | ||
75 | |||
76 | static struct usb_gadget_strings stringtab_dev = { | ||
77 | .language = 0x0409, /* en-us */ | ||
78 | .strings = strings_dev, | ||
79 | }; | ||
80 | |||
81 | static struct usb_gadget_strings *dev_strings[] = { | ||
82 | &stringtab_dev, | ||
83 | NULL, | ||
84 | }; | ||
85 | |||
86 | static struct usb_device_descriptor device_desc = { | ||
87 | .bLength = USB_DT_DEVICE_SIZE, | ||
88 | .bDescriptorType = USB_DT_DEVICE, | ||
89 | .bcdUSB = __constant_cpu_to_le16(0x0200), | ||
90 | .bDeviceClass = USB_CLASS_COMM, | ||
91 | .idVendor = __constant_cpu_to_le16(NOKIA_VENDOR_ID), | ||
92 | .idProduct = __constant_cpu_to_le16(NOKIA_PRODUCT_ID), | ||
93 | /* .iManufacturer = DYNAMIC */ | ||
94 | /* .iProduct = DYNAMIC */ | ||
95 | .bNumConfigurations = 1, | ||
96 | }; | ||
97 | |||
98 | /*-------------------------------------------------------------------------*/ | ||
99 | |||
100 | /* Module */ | ||
101 | MODULE_DESCRIPTION("Nokia composite gadget driver for N900"); | ||
102 | MODULE_AUTHOR("Felipe Balbi"); | ||
103 | MODULE_LICENSE("GPL"); | ||
104 | |||
105 | /*-------------------------------------------------------------------------*/ | ||
106 | |||
107 | static u8 hostaddr[ETH_ALEN]; | ||
108 | |||
109 | static int __init nokia_bind_config(struct usb_configuration *c) | ||
110 | { | ||
111 | int status = 0; | ||
112 | |||
113 | status = phonet_bind_config(c); | ||
114 | if (status) | ||
115 | printk(KERN_DEBUG "could not bind phonet config\n"); | ||
116 | |||
117 | status = obex_bind_config(c, 0); | ||
118 | if (status) | ||
119 | printk(KERN_DEBUG "could not bind obex config %d\n", 0); | ||
120 | |||
121 | status = obex_bind_config(c, 1); | ||
122 | if (status) | ||
123 | printk(KERN_DEBUG "could not bind obex config %d\n", 0); | ||
124 | |||
125 | status = acm_bind_config(c, 2); | ||
126 | if (status) | ||
127 | printk(KERN_DEBUG "could not bind acm config\n"); | ||
128 | |||
129 | status = ecm_bind_config(c, hostaddr); | ||
130 | if (status) | ||
131 | printk(KERN_DEBUG "could not bind ecm config\n"); | ||
132 | |||
133 | return status; | ||
134 | } | ||
135 | |||
136 | static struct usb_configuration nokia_config_500ma_driver = { | ||
137 | .label = "Bus Powered", | ||
138 | .bind = nokia_bind_config, | ||
139 | .bConfigurationValue = 1, | ||
140 | /* .iConfiguration = DYNAMIC */ | ||
141 | .bmAttributes = USB_CONFIG_ATT_ONE, | ||
142 | .bMaxPower = 250, /* 500mA */ | ||
143 | }; | ||
144 | |||
145 | static struct usb_configuration nokia_config_100ma_driver = { | ||
146 | .label = "Self Powered", | ||
147 | .bind = nokia_bind_config, | ||
148 | .bConfigurationValue = 2, | ||
149 | /* .iConfiguration = DYNAMIC */ | ||
150 | .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, | ||
151 | .bMaxPower = 50, /* 100 mA */ | ||
152 | }; | ||
153 | |||
154 | static int __init nokia_bind(struct usb_composite_dev *cdev) | ||
155 | { | ||
156 | int gcnum; | ||
157 | struct usb_gadget *gadget = cdev->gadget; | ||
158 | int status; | ||
159 | |||
160 | status = gphonet_setup(cdev->gadget); | ||
161 | if (status < 0) | ||
162 | goto err_phonet; | ||
163 | |||
164 | status = gserial_setup(cdev->gadget, 3); | ||
165 | if (status < 0) | ||
166 | goto err_serial; | ||
167 | |||
168 | status = gether_setup(cdev->gadget, hostaddr); | ||
169 | if (status < 0) | ||
170 | goto err_ether; | ||
171 | |||
172 | status = usb_string_id(cdev); | ||
173 | if (status < 0) | ||
174 | goto err_usb; | ||
175 | strings_dev[STRING_MANUFACTURER_IDX].id = status; | ||
176 | |||
177 | device_desc.iManufacturer = status; | ||
178 | |||
179 | status = usb_string_id(cdev); | ||
180 | if (status < 0) | ||
181 | goto err_usb; | ||
182 | strings_dev[STRING_PRODUCT_IDX].id = status; | ||
183 | |||
184 | device_desc.iProduct = status; | ||
185 | |||
186 | /* config description */ | ||
187 | status = usb_string_id(cdev); | ||
188 | if (status < 0) | ||
189 | goto err_usb; | ||
190 | strings_dev[STRING_DESCRIPTION_IDX].id = status; | ||
191 | |||
192 | nokia_config_500ma_driver.iConfiguration = status; | ||
193 | nokia_config_100ma_driver.iConfiguration = status; | ||
194 | |||
195 | /* set up other descriptors */ | ||
196 | gcnum = usb_gadget_controller_number(gadget); | ||
197 | if (gcnum >= 0) | ||
198 | device_desc.bcdDevice = cpu_to_le16(NOKIA_VERSION_NUM); | ||
199 | else { | ||
200 | /* this should only work with hw that supports altsettings | ||
201 | * and several endpoints, anything else, panic. | ||
202 | */ | ||
203 | pr_err("nokia_bind: controller '%s' not recognized\n", | ||
204 | gadget->name); | ||
205 | goto err_usb; | ||
206 | } | ||
207 | |||
208 | /* finaly register the configuration */ | ||
209 | status = usb_add_config(cdev, &nokia_config_500ma_driver); | ||
210 | if (status < 0) | ||
211 | goto err_usb; | ||
212 | |||
213 | status = usb_add_config(cdev, &nokia_config_100ma_driver); | ||
214 | if (status < 0) | ||
215 | goto err_usb; | ||
216 | |||
217 | dev_info(&gadget->dev, "%s\n", NOKIA_LONG_NAME); | ||
218 | |||
219 | return 0; | ||
220 | |||
221 | err_usb: | ||
222 | gether_cleanup(); | ||
223 | err_ether: | ||
224 | gserial_cleanup(); | ||
225 | err_serial: | ||
226 | gphonet_cleanup(); | ||
227 | err_phonet: | ||
228 | return status; | ||
229 | } | ||
230 | |||
231 | static int __exit nokia_unbind(struct usb_composite_dev *cdev) | ||
232 | { | ||
233 | gphonet_cleanup(); | ||
234 | gserial_cleanup(); | ||
235 | gether_cleanup(); | ||
236 | |||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static struct usb_composite_driver nokia_driver = { | ||
241 | .name = "g_nokia", | ||
242 | .dev = &device_desc, | ||
243 | .strings = dev_strings, | ||
244 | .bind = nokia_bind, | ||
245 | .unbind = __exit_p(nokia_unbind), | ||
246 | }; | ||
247 | |||
248 | static int __init nokia_init(void) | ||
249 | { | ||
250 | return usb_composite_register(&nokia_driver); | ||
251 | } | ||
252 | module_init(nokia_init); | ||
253 | |||
254 | static void __exit nokia_cleanup(void) | ||
255 | { | ||
256 | usb_composite_unregister(&nokia_driver); | ||
257 | } | ||
258 | module_exit(nokia_cleanup); | ||
259 | |||
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index 2d867fd2241..6b8bf8c781c 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c | |||
@@ -949,12 +949,6 @@ printer_set_config(struct printer_dev *dev, unsigned number) | |||
949 | int result = 0; | 949 | int result = 0; |
950 | struct usb_gadget *gadget = dev->gadget; | 950 | struct usb_gadget *gadget = dev->gadget; |
951 | 951 | ||
952 | if (gadget_is_sa1100(gadget) && dev->config) { | ||
953 | /* tx fifo is full, but we can't clear it...*/ | ||
954 | INFO(dev, "can't change configurations\n"); | ||
955 | return -ESPIPE; | ||
956 | } | ||
957 | |||
958 | switch (number) { | 952 | switch (number) { |
959 | case DEV_CONFIG_VALUE: | 953 | case DEV_CONFIG_VALUE: |
960 | result = 0; | 954 | result = 0; |
@@ -1033,12 +1027,6 @@ set_interface(struct printer_dev *dev, unsigned number) | |||
1033 | { | 1027 | { |
1034 | int result = 0; | 1028 | int result = 0; |
1035 | 1029 | ||
1036 | if (gadget_is_sa1100(dev->gadget) && dev->interface < 0) { | ||
1037 | /* tx fifo is full, but we can't clear it...*/ | ||
1038 | INFO(dev, "can't change interfaces\n"); | ||
1039 | return -ESPIPE; | ||
1040 | } | ||
1041 | |||
1042 | /* Free the current interface */ | 1030 | /* Free the current interface */ |
1043 | switch (dev->interface) { | 1031 | switch (dev->interface) { |
1044 | case PRINTER_INTERFACE: | 1032 | case PRINTER_INTERFACE: |
@@ -1392,12 +1380,6 @@ printer_bind(struct usb_gadget *gadget) | |||
1392 | goto fail; | 1380 | goto fail; |
1393 | } | 1381 | } |
1394 | 1382 | ||
1395 | if (gadget_is_sa1100(gadget)) { | ||
1396 | /* hardware can't write zero length packets. */ | ||
1397 | ERROR(dev, "SA1100 controller is unsupport by this driver\n"); | ||
1398 | goto fail; | ||
1399 | } | ||
1400 | |||
1401 | gcnum = usb_gadget_controller_number(gadget); | 1383 | gcnum = usb_gadget_controller_number(gadget); |
1402 | if (gcnum >= 0) { | 1384 | if (gcnum >= 0) { |
1403 | device_desc.bcdDevice = cpu_to_le16(0x0200 + gcnum); | 1385 | device_desc.bcdDevice = cpu_to_le16(0x0200 + gcnum); |
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c index adda1208a1e..05b892c3d68 100644 --- a/drivers/usb/gadget/pxa27x_udc.c +++ b/drivers/usb/gadget/pxa27x_udc.c | |||
@@ -742,13 +742,17 @@ static void ep_del_request(struct pxa_ep *ep, struct pxa27x_request *req) | |||
742 | * @ep: pxa physical endpoint | 742 | * @ep: pxa physical endpoint |
743 | * @req: pxa request | 743 | * @req: pxa request |
744 | * @status: usb request status sent to gadget API | 744 | * @status: usb request status sent to gadget API |
745 | * @pflags: flags of previous spinlock_irq_save() or NULL if no lock held | ||
745 | * | 746 | * |
746 | * Context: ep->lock held | 747 | * Context: ep->lock held if flags not NULL, else ep->lock released |
747 | * | 748 | * |
748 | * Retire a pxa27x usb request. Endpoint must be locked. | 749 | * Retire a pxa27x usb request. Endpoint must be locked. |
749 | */ | 750 | */ |
750 | static void req_done(struct pxa_ep *ep, struct pxa27x_request *req, int status) | 751 | static void req_done(struct pxa_ep *ep, struct pxa27x_request *req, int status, |
752 | unsigned long *pflags) | ||
751 | { | 753 | { |
754 | unsigned long flags; | ||
755 | |||
752 | ep_del_request(ep, req); | 756 | ep_del_request(ep, req); |
753 | if (likely(req->req.status == -EINPROGRESS)) | 757 | if (likely(req->req.status == -EINPROGRESS)) |
754 | req->req.status = status; | 758 | req->req.status = status; |
@@ -760,38 +764,48 @@ static void req_done(struct pxa_ep *ep, struct pxa27x_request *req, int status) | |||
760 | &req->req, status, | 764 | &req->req, status, |
761 | req->req.actual, req->req.length); | 765 | req->req.actual, req->req.length); |
762 | 766 | ||
767 | if (pflags) | ||
768 | spin_unlock_irqrestore(&ep->lock, *pflags); | ||
769 | local_irq_save(flags); | ||
763 | req->req.complete(&req->udc_usb_ep->usb_ep, &req->req); | 770 | req->req.complete(&req->udc_usb_ep->usb_ep, &req->req); |
771 | local_irq_restore(flags); | ||
772 | if (pflags) | ||
773 | spin_lock_irqsave(&ep->lock, *pflags); | ||
764 | } | 774 | } |
765 | 775 | ||
766 | /** | 776 | /** |
767 | * ep_end_out_req - Ends endpoint OUT request | 777 | * ep_end_out_req - Ends endpoint OUT request |
768 | * @ep: physical endpoint | 778 | * @ep: physical endpoint |
769 | * @req: pxa request | 779 | * @req: pxa request |
780 | * @pflags: flags of previous spinlock_irq_save() or NULL if no lock held | ||
770 | * | 781 | * |
771 | * Context: ep->lock held | 782 | * Context: ep->lock held or released (see req_done()) |
772 | * | 783 | * |
773 | * Ends endpoint OUT request (completes usb request). | 784 | * Ends endpoint OUT request (completes usb request). |
774 | */ | 785 | */ |
775 | static void ep_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req) | 786 | static void ep_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req, |
787 | unsigned long *pflags) | ||
776 | { | 788 | { |
777 | inc_ep_stats_reqs(ep, !USB_DIR_IN); | 789 | inc_ep_stats_reqs(ep, !USB_DIR_IN); |
778 | req_done(ep, req, 0); | 790 | req_done(ep, req, 0, pflags); |
779 | } | 791 | } |
780 | 792 | ||
781 | /** | 793 | /** |
782 | * ep0_end_out_req - Ends control endpoint OUT request (ends data stage) | 794 | * ep0_end_out_req - Ends control endpoint OUT request (ends data stage) |
783 | * @ep: physical endpoint | 795 | * @ep: physical endpoint |
784 | * @req: pxa request | 796 | * @req: pxa request |
797 | * @pflags: flags of previous spinlock_irq_save() or NULL if no lock held | ||
785 | * | 798 | * |
786 | * Context: ep->lock held | 799 | * Context: ep->lock held or released (see req_done()) |
787 | * | 800 | * |
788 | * Ends control endpoint OUT request (completes usb request), and puts | 801 | * Ends control endpoint OUT request (completes usb request), and puts |
789 | * control endpoint into idle state | 802 | * control endpoint into idle state |
790 | */ | 803 | */ |
791 | static void ep0_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req) | 804 | static void ep0_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req, |
805 | unsigned long *pflags) | ||
792 | { | 806 | { |
793 | set_ep0state(ep->dev, OUT_STATUS_STAGE); | 807 | set_ep0state(ep->dev, OUT_STATUS_STAGE); |
794 | ep_end_out_req(ep, req); | 808 | ep_end_out_req(ep, req, pflags); |
795 | ep0_idle(ep->dev); | 809 | ep0_idle(ep->dev); |
796 | } | 810 | } |
797 | 811 | ||
@@ -799,31 +813,35 @@ static void ep0_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req) | |||
799 | * ep_end_in_req - Ends endpoint IN request | 813 | * ep_end_in_req - Ends endpoint IN request |
800 | * @ep: physical endpoint | 814 | * @ep: physical endpoint |
801 | * @req: pxa request | 815 | * @req: pxa request |
816 | * @pflags: flags of previous spinlock_irq_save() or NULL if no lock held | ||
802 | * | 817 | * |
803 | * Context: ep->lock held | 818 | * Context: ep->lock held or released (see req_done()) |
804 | * | 819 | * |
805 | * Ends endpoint IN request (completes usb request). | 820 | * Ends endpoint IN request (completes usb request). |
806 | */ | 821 | */ |
807 | static void ep_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req) | 822 | static void ep_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req, |
823 | unsigned long *pflags) | ||
808 | { | 824 | { |
809 | inc_ep_stats_reqs(ep, USB_DIR_IN); | 825 | inc_ep_stats_reqs(ep, USB_DIR_IN); |
810 | req_done(ep, req, 0); | 826 | req_done(ep, req, 0, pflags); |
811 | } | 827 | } |
812 | 828 | ||
813 | /** | 829 | /** |
814 | * ep0_end_in_req - Ends control endpoint IN request (ends data stage) | 830 | * ep0_end_in_req - Ends control endpoint IN request (ends data stage) |
815 | * @ep: physical endpoint | 831 | * @ep: physical endpoint |
816 | * @req: pxa request | 832 | * @req: pxa request |
833 | * @pflags: flags of previous spinlock_irq_save() or NULL if no lock held | ||
817 | * | 834 | * |
818 | * Context: ep->lock held | 835 | * Context: ep->lock held or released (see req_done()) |
819 | * | 836 | * |
820 | * Ends control endpoint IN request (completes usb request), and puts | 837 | * Ends control endpoint IN request (completes usb request), and puts |
821 | * control endpoint into status state | 838 | * control endpoint into status state |
822 | */ | 839 | */ |
823 | static void ep0_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req) | 840 | static void ep0_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req, |
841 | unsigned long *pflags) | ||
824 | { | 842 | { |
825 | set_ep0state(ep->dev, IN_STATUS_STAGE); | 843 | set_ep0state(ep->dev, IN_STATUS_STAGE); |
826 | ep_end_in_req(ep, req); | 844 | ep_end_in_req(ep, req, pflags); |
827 | } | 845 | } |
828 | 846 | ||
829 | /** | 847 | /** |
@@ -831,19 +849,22 @@ static void ep0_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req) | |||
831 | * @ep: pxa endpoint | 849 | * @ep: pxa endpoint |
832 | * @status: usb request status | 850 | * @status: usb request status |
833 | * | 851 | * |
834 | * Context: ep->lock held | 852 | * Context: ep->lock released |
835 | * | 853 | * |
836 | * Dequeues all requests on an endpoint. As a side effect, interrupts will be | 854 | * Dequeues all requests on an endpoint. As a side effect, interrupts will be |
837 | * disabled on that endpoint (because no more requests). | 855 | * disabled on that endpoint (because no more requests). |
838 | */ | 856 | */ |
839 | static void nuke(struct pxa_ep *ep, int status) | 857 | static void nuke(struct pxa_ep *ep, int status) |
840 | { | 858 | { |
841 | struct pxa27x_request *req; | 859 | struct pxa27x_request *req; |
860 | unsigned long flags; | ||
842 | 861 | ||
862 | spin_lock_irqsave(&ep->lock, flags); | ||
843 | while (!list_empty(&ep->queue)) { | 863 | while (!list_empty(&ep->queue)) { |
844 | req = list_entry(ep->queue.next, struct pxa27x_request, queue); | 864 | req = list_entry(ep->queue.next, struct pxa27x_request, queue); |
845 | req_done(ep, req, status); | 865 | req_done(ep, req, status, &flags); |
846 | } | 866 | } |
867 | spin_unlock_irqrestore(&ep->lock, flags); | ||
847 | } | 868 | } |
848 | 869 | ||
849 | /** | 870 | /** |
@@ -1123,6 +1144,7 @@ static int pxa_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
1123 | int rc = 0; | 1144 | int rc = 0; |
1124 | int is_first_req; | 1145 | int is_first_req; |
1125 | unsigned length; | 1146 | unsigned length; |
1147 | int recursion_detected; | ||
1126 | 1148 | ||
1127 | req = container_of(_req, struct pxa27x_request, req); | 1149 | req = container_of(_req, struct pxa27x_request, req); |
1128 | udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep); | 1150 | udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep); |
@@ -1152,6 +1174,7 @@ static int pxa_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
1152 | return -EMSGSIZE; | 1174 | return -EMSGSIZE; |
1153 | 1175 | ||
1154 | spin_lock_irqsave(&ep->lock, flags); | 1176 | spin_lock_irqsave(&ep->lock, flags); |
1177 | recursion_detected = ep->in_handle_ep; | ||
1155 | 1178 | ||
1156 | is_first_req = list_empty(&ep->queue); | 1179 | is_first_req = list_empty(&ep->queue); |
1157 | ep_dbg(ep, "queue req %p(first=%s), len %d buf %p\n", | 1180 | ep_dbg(ep, "queue req %p(first=%s), len %d buf %p\n", |
@@ -1161,12 +1184,12 @@ static int pxa_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
1161 | if (!ep->enabled) { | 1184 | if (!ep->enabled) { |
1162 | _req->status = -ESHUTDOWN; | 1185 | _req->status = -ESHUTDOWN; |
1163 | rc = -ESHUTDOWN; | 1186 | rc = -ESHUTDOWN; |
1164 | goto out; | 1187 | goto out_locked; |
1165 | } | 1188 | } |
1166 | 1189 | ||
1167 | if (req->in_use) { | 1190 | if (req->in_use) { |
1168 | ep_err(ep, "refusing to queue req %p (already queued)\n", req); | 1191 | ep_err(ep, "refusing to queue req %p (already queued)\n", req); |
1169 | goto out; | 1192 | goto out_locked; |
1170 | } | 1193 | } |
1171 | 1194 | ||
1172 | length = _req->length; | 1195 | length = _req->length; |
@@ -1174,12 +1197,13 @@ static int pxa_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
1174 | _req->actual = 0; | 1197 | _req->actual = 0; |
1175 | 1198 | ||
1176 | ep_add_request(ep, req); | 1199 | ep_add_request(ep, req); |
1200 | spin_unlock_irqrestore(&ep->lock, flags); | ||
1177 | 1201 | ||
1178 | if (is_ep0(ep)) { | 1202 | if (is_ep0(ep)) { |
1179 | switch (dev->ep0state) { | 1203 | switch (dev->ep0state) { |
1180 | case WAIT_ACK_SET_CONF_INTERF: | 1204 | case WAIT_ACK_SET_CONF_INTERF: |
1181 | if (length == 0) { | 1205 | if (length == 0) { |
1182 | ep_end_in_req(ep, req); | 1206 | ep_end_in_req(ep, req, NULL); |
1183 | } else { | 1207 | } else { |
1184 | ep_err(ep, "got a request of %d bytes while" | 1208 | ep_err(ep, "got a request of %d bytes while" |
1185 | "in state WAIT_ACK_SET_CONF_INTERF\n", | 1209 | "in state WAIT_ACK_SET_CONF_INTERF\n", |
@@ -1192,12 +1216,12 @@ static int pxa_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
1192 | case IN_DATA_STAGE: | 1216 | case IN_DATA_STAGE: |
1193 | if (!ep_is_full(ep)) | 1217 | if (!ep_is_full(ep)) |
1194 | if (write_ep0_fifo(ep, req)) | 1218 | if (write_ep0_fifo(ep, req)) |
1195 | ep0_end_in_req(ep, req); | 1219 | ep0_end_in_req(ep, req, NULL); |
1196 | break; | 1220 | break; |
1197 | case OUT_DATA_STAGE: | 1221 | case OUT_DATA_STAGE: |
1198 | if ((length == 0) || !epout_has_pkt(ep)) | 1222 | if ((length == 0) || !epout_has_pkt(ep)) |
1199 | if (read_ep0_fifo(ep, req)) | 1223 | if (read_ep0_fifo(ep, req)) |
1200 | ep0_end_out_req(ep, req); | 1224 | ep0_end_out_req(ep, req, NULL); |
1201 | break; | 1225 | break; |
1202 | default: | 1226 | default: |
1203 | ep_err(ep, "odd state %s to send me a request\n", | 1227 | ep_err(ep, "odd state %s to send me a request\n", |
@@ -1207,12 +1231,15 @@ static int pxa_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
1207 | break; | 1231 | break; |
1208 | } | 1232 | } |
1209 | } else { | 1233 | } else { |
1210 | handle_ep(ep); | 1234 | if (!recursion_detected) |
1235 | handle_ep(ep); | ||
1211 | } | 1236 | } |
1212 | 1237 | ||
1213 | out: | 1238 | out: |
1214 | spin_unlock_irqrestore(&ep->lock, flags); | ||
1215 | return rc; | 1239 | return rc; |
1240 | out_locked: | ||
1241 | spin_unlock_irqrestore(&ep->lock, flags); | ||
1242 | goto out; | ||
1216 | } | 1243 | } |
1217 | 1244 | ||
1218 | /** | 1245 | /** |
@@ -1242,13 +1269,14 @@ static int pxa_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) | |||
1242 | /* make sure it's actually queued on this endpoint */ | 1269 | /* make sure it's actually queued on this endpoint */ |
1243 | list_for_each_entry(req, &ep->queue, queue) { | 1270 | list_for_each_entry(req, &ep->queue, queue) { |
1244 | if (&req->req == _req) { | 1271 | if (&req->req == _req) { |
1245 | req_done(ep, req, -ECONNRESET); | ||
1246 | rc = 0; | 1272 | rc = 0; |
1247 | break; | 1273 | break; |
1248 | } | 1274 | } |
1249 | } | 1275 | } |
1250 | 1276 | ||
1251 | spin_unlock_irqrestore(&ep->lock, flags); | 1277 | spin_unlock_irqrestore(&ep->lock, flags); |
1278 | if (!rc) | ||
1279 | req_done(ep, req, -ECONNRESET, NULL); | ||
1252 | return rc; | 1280 | return rc; |
1253 | } | 1281 | } |
1254 | 1282 | ||
@@ -1445,7 +1473,6 @@ static int pxa_ep_disable(struct usb_ep *_ep) | |||
1445 | { | 1473 | { |
1446 | struct pxa_ep *ep; | 1474 | struct pxa_ep *ep; |
1447 | struct udc_usb_ep *udc_usb_ep; | 1475 | struct udc_usb_ep *udc_usb_ep; |
1448 | unsigned long flags; | ||
1449 | 1476 | ||
1450 | if (!_ep) | 1477 | if (!_ep) |
1451 | return -EINVAL; | 1478 | return -EINVAL; |
@@ -1455,10 +1482,8 @@ static int pxa_ep_disable(struct usb_ep *_ep) | |||
1455 | if (!ep || is_ep0(ep) || !list_empty(&ep->queue)) | 1482 | if (!ep || is_ep0(ep) || !list_empty(&ep->queue)) |
1456 | return -EINVAL; | 1483 | return -EINVAL; |
1457 | 1484 | ||
1458 | spin_lock_irqsave(&ep->lock, flags); | ||
1459 | ep->enabled = 0; | 1485 | ep->enabled = 0; |
1460 | nuke(ep, -ESHUTDOWN); | 1486 | nuke(ep, -ESHUTDOWN); |
1461 | spin_unlock_irqrestore(&ep->lock, flags); | ||
1462 | 1487 | ||
1463 | pxa_ep_fifo_flush(_ep); | 1488 | pxa_ep_fifo_flush(_ep); |
1464 | udc_usb_ep->pxa_ep = NULL; | 1489 | udc_usb_ep->pxa_ep = NULL; |
@@ -1907,8 +1932,10 @@ static void handle_ep0_ctrl_req(struct pxa_udc *udc, | |||
1907 | } u; | 1932 | } u; |
1908 | int i; | 1933 | int i; |
1909 | int have_extrabytes = 0; | 1934 | int have_extrabytes = 0; |
1935 | unsigned long flags; | ||
1910 | 1936 | ||
1911 | nuke(ep, -EPROTO); | 1937 | nuke(ep, -EPROTO); |
1938 | spin_lock_irqsave(&ep->lock, flags); | ||
1912 | 1939 | ||
1913 | /* | 1940 | /* |
1914 | * In the PXA320 manual, in the section about Back-to-Back setup | 1941 | * In the PXA320 manual, in the section about Back-to-Back setup |
@@ -1947,10 +1974,13 @@ static void handle_ep0_ctrl_req(struct pxa_udc *udc, | |||
1947 | /* Tell UDC to enter Data Stage */ | 1974 | /* Tell UDC to enter Data Stage */ |
1948 | ep_write_UDCCSR(ep, UDCCSR0_SA | UDCCSR0_OPC); | 1975 | ep_write_UDCCSR(ep, UDCCSR0_SA | UDCCSR0_OPC); |
1949 | 1976 | ||
1977 | spin_unlock_irqrestore(&ep->lock, flags); | ||
1950 | i = udc->driver->setup(&udc->gadget, &u.r); | 1978 | i = udc->driver->setup(&udc->gadget, &u.r); |
1979 | spin_lock_irqsave(&ep->lock, flags); | ||
1951 | if (i < 0) | 1980 | if (i < 0) |
1952 | goto stall; | 1981 | goto stall; |
1953 | out: | 1982 | out: |
1983 | spin_unlock_irqrestore(&ep->lock, flags); | ||
1954 | return; | 1984 | return; |
1955 | stall: | 1985 | stall: |
1956 | ep_dbg(ep, "protocol STALL, udccsr0=%03x err %d\n", | 1986 | ep_dbg(ep, "protocol STALL, udccsr0=%03x err %d\n", |
@@ -2055,13 +2085,13 @@ static void handle_ep0(struct pxa_udc *udc, int fifo_irq, int opc_irq) | |||
2055 | if (req && !ep_is_full(ep)) | 2085 | if (req && !ep_is_full(ep)) |
2056 | completed = write_ep0_fifo(ep, req); | 2086 | completed = write_ep0_fifo(ep, req); |
2057 | if (completed) | 2087 | if (completed) |
2058 | ep0_end_in_req(ep, req); | 2088 | ep0_end_in_req(ep, req, NULL); |
2059 | break; | 2089 | break; |
2060 | case OUT_DATA_STAGE: /* SET_DESCRIPTOR */ | 2090 | case OUT_DATA_STAGE: /* SET_DESCRIPTOR */ |
2061 | if (epout_has_pkt(ep) && req) | 2091 | if (epout_has_pkt(ep) && req) |
2062 | completed = read_ep0_fifo(ep, req); | 2092 | completed = read_ep0_fifo(ep, req); |
2063 | if (completed) | 2093 | if (completed) |
2064 | ep0_end_out_req(ep, req); | 2094 | ep0_end_out_req(ep, req, NULL); |
2065 | break; | 2095 | break; |
2066 | case STALL: | 2096 | case STALL: |
2067 | ep_write_UDCCSR(ep, UDCCSR0_FST); | 2097 | ep_write_UDCCSR(ep, UDCCSR0_FST); |
@@ -2091,7 +2121,7 @@ static void handle_ep0(struct pxa_udc *udc, int fifo_irq, int opc_irq) | |||
2091 | * Tries to transfer all pending request data into the endpoint and/or | 2121 | * Tries to transfer all pending request data into the endpoint and/or |
2092 | * transfer all pending data in the endpoint into usb requests. | 2122 | * transfer all pending data in the endpoint into usb requests. |
2093 | * | 2123 | * |
2094 | * Is always called when in_interrupt() or with ep->lock held. | 2124 | * Is always called when in_interrupt() and with ep->lock released. |
2095 | */ | 2125 | */ |
2096 | static void handle_ep(struct pxa_ep *ep) | 2126 | static void handle_ep(struct pxa_ep *ep) |
2097 | { | 2127 | { |
@@ -2100,10 +2130,17 @@ static void handle_ep(struct pxa_ep *ep) | |||
2100 | u32 udccsr; | 2130 | u32 udccsr; |
2101 | int is_in = ep->dir_in; | 2131 | int is_in = ep->dir_in; |
2102 | int loop = 0; | 2132 | int loop = 0; |
2133 | unsigned long flags; | ||
2134 | |||
2135 | spin_lock_irqsave(&ep->lock, flags); | ||
2136 | if (ep->in_handle_ep) | ||
2137 | goto recursion_detected; | ||
2138 | ep->in_handle_ep = 1; | ||
2103 | 2139 | ||
2104 | do { | 2140 | do { |
2105 | completed = 0; | 2141 | completed = 0; |
2106 | udccsr = udc_ep_readl(ep, UDCCSR); | 2142 | udccsr = udc_ep_readl(ep, UDCCSR); |
2143 | |||
2107 | if (likely(!list_empty(&ep->queue))) | 2144 | if (likely(!list_empty(&ep->queue))) |
2108 | req = list_entry(ep->queue.next, | 2145 | req = list_entry(ep->queue.next, |
2109 | struct pxa27x_request, queue); | 2146 | struct pxa27x_request, queue); |
@@ -2122,15 +2159,22 @@ static void handle_ep(struct pxa_ep *ep) | |||
2122 | if (unlikely(is_in)) { | 2159 | if (unlikely(is_in)) { |
2123 | if (likely(!ep_is_full(ep))) | 2160 | if (likely(!ep_is_full(ep))) |
2124 | completed = write_fifo(ep, req); | 2161 | completed = write_fifo(ep, req); |
2125 | if (completed) | ||
2126 | ep_end_in_req(ep, req); | ||
2127 | } else { | 2162 | } else { |
2128 | if (likely(epout_has_pkt(ep))) | 2163 | if (likely(epout_has_pkt(ep))) |
2129 | completed = read_fifo(ep, req); | 2164 | completed = read_fifo(ep, req); |
2130 | if (completed) | 2165 | } |
2131 | ep_end_out_req(ep, req); | 2166 | |
2167 | if (completed) { | ||
2168 | if (is_in) | ||
2169 | ep_end_in_req(ep, req, &flags); | ||
2170 | else | ||
2171 | ep_end_out_req(ep, req, &flags); | ||
2132 | } | 2172 | } |
2133 | } while (completed); | 2173 | } while (completed); |
2174 | |||
2175 | ep->in_handle_ep = 0; | ||
2176 | recursion_detected: | ||
2177 | spin_unlock_irqrestore(&ep->lock, flags); | ||
2134 | } | 2178 | } |
2135 | 2179 | ||
2136 | /** | 2180 | /** |
@@ -2218,9 +2262,13 @@ static void irq_handle_data(int irq, struct pxa_udc *udc) | |||
2218 | continue; | 2262 | continue; |
2219 | 2263 | ||
2220 | udc_writel(udc, UDCISR0, UDCISR_INT(i, UDCISR_INT_MASK)); | 2264 | udc_writel(udc, UDCISR0, UDCISR_INT(i, UDCISR_INT_MASK)); |
2221 | ep = &udc->pxa_ep[i]; | 2265 | |
2222 | ep->stats.irqs++; | 2266 | WARN_ON(i >= ARRAY_SIZE(udc->pxa_ep)); |
2223 | handle_ep(ep); | 2267 | if (i < ARRAY_SIZE(udc->pxa_ep)) { |
2268 | ep = &udc->pxa_ep[i]; | ||
2269 | ep->stats.irqs++; | ||
2270 | handle_ep(ep); | ||
2271 | } | ||
2224 | } | 2272 | } |
2225 | 2273 | ||
2226 | for (i = 16; udcisr1 != 0 && i < 24; udcisr1 >>= 2, i++) { | 2274 | for (i = 16; udcisr1 != 0 && i < 24; udcisr1 >>= 2, i++) { |
@@ -2228,9 +2276,12 @@ static void irq_handle_data(int irq, struct pxa_udc *udc) | |||
2228 | if (!(udcisr1 & UDCISR_INT_MASK)) | 2276 | if (!(udcisr1 & UDCISR_INT_MASK)) |
2229 | continue; | 2277 | continue; |
2230 | 2278 | ||
2231 | ep = &udc->pxa_ep[i]; | 2279 | WARN_ON(i >= ARRAY_SIZE(udc->pxa_ep)); |
2232 | ep->stats.irqs++; | 2280 | if (i < ARRAY_SIZE(udc->pxa_ep)) { |
2233 | handle_ep(ep); | 2281 | ep = &udc->pxa_ep[i]; |
2282 | ep->stats.irqs++; | ||
2283 | handle_ep(ep); | ||
2284 | } | ||
2234 | } | 2285 | } |
2235 | 2286 | ||
2236 | } | 2287 | } |
@@ -2439,7 +2490,7 @@ static int __init pxa_udc_probe(struct platform_device *pdev) | |||
2439 | } | 2490 | } |
2440 | 2491 | ||
2441 | retval = -ENOMEM; | 2492 | retval = -ENOMEM; |
2442 | udc->regs = ioremap(regs->start, regs->end - regs->start + 1); | 2493 | udc->regs = ioremap(regs->start, resource_size(regs)); |
2443 | if (!udc->regs) { | 2494 | if (!udc->regs) { |
2444 | dev_err(&pdev->dev, "Unable to map UDC I/O memory\n"); | 2495 | dev_err(&pdev->dev, "Unable to map UDC I/O memory\n"); |
2445 | goto err_map; | 2496 | goto err_map; |
diff --git a/drivers/usb/gadget/pxa27x_udc.h b/drivers/usb/gadget/pxa27x_udc.h index e25225e2658..ff61e4866e8 100644 --- a/drivers/usb/gadget/pxa27x_udc.h +++ b/drivers/usb/gadget/pxa27x_udc.h | |||
@@ -318,6 +318,11 @@ struct udc_usb_ep { | |||
318 | * @queue: requests queue | 318 | * @queue: requests queue |
319 | * @lock: lock to pxa_ep data (queues and stats) | 319 | * @lock: lock to pxa_ep data (queues and stats) |
320 | * @enabled: true when endpoint enabled (not stopped by gadget layer) | 320 | * @enabled: true when endpoint enabled (not stopped by gadget layer) |
321 | * @in_handle_ep: number of recursions of handle_ep() function | ||
322 | * Prevents deadlocks or infinite recursions of types : | ||
323 | * irq->handle_ep()->req_done()->req.complete()->pxa_ep_queue()->handle_ep() | ||
324 | * or | ||
325 | * pxa_ep_queue()->handle_ep()->req_done()->req.complete()->pxa_ep_queue() | ||
321 | * @idx: endpoint index (1 => epA, 2 => epB, ..., 24 => epX) | 326 | * @idx: endpoint index (1 => epA, 2 => epB, ..., 24 => epX) |
322 | * @name: endpoint name (for trace/debug purpose) | 327 | * @name: endpoint name (for trace/debug purpose) |
323 | * @dir_in: 1 if IN endpoint, 0 if OUT endpoint | 328 | * @dir_in: 1 if IN endpoint, 0 if OUT endpoint |
@@ -346,6 +351,7 @@ struct pxa_ep { | |||
346 | spinlock_t lock; /* Protects this structure */ | 351 | spinlock_t lock; /* Protects this structure */ |
347 | /* (queues, stats) */ | 352 | /* (queues, stats) */ |
348 | unsigned enabled:1; | 353 | unsigned enabled:1; |
354 | unsigned in_handle_ep:1; | ||
349 | 355 | ||
350 | unsigned idx:5; | 356 | unsigned idx:5; |
351 | char *name; | 357 | char *name; |
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 9941fc61341..f742c8e7397 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c | |||
@@ -317,7 +317,8 @@ static void s3c_hsotg_init_fifo(struct s3c_hsotg *hsotg) | |||
317 | * | 317 | * |
318 | * Allocate a new USB request structure appropriate for the specified endpoint | 318 | * Allocate a new USB request structure appropriate for the specified endpoint |
319 | */ | 319 | */ |
320 | struct usb_request *s3c_hsotg_ep_alloc_request(struct usb_ep *ep, gfp_t flags) | 320 | static struct usb_request *s3c_hsotg_ep_alloc_request(struct usb_ep *ep, |
321 | gfp_t flags) | ||
321 | { | 322 | { |
322 | struct s3c_hsotg_req *req; | 323 | struct s3c_hsotg_req *req; |
323 | 324 | ||
@@ -373,7 +374,7 @@ static void s3c_hsotg_unmap_dma(struct s3c_hsotg *hsotg, | |||
373 | req->dma = DMA_ADDR_INVALID; | 374 | req->dma = DMA_ADDR_INVALID; |
374 | hs_req->mapped = 0; | 375 | hs_req->mapped = 0; |
375 | } else { | 376 | } else { |
376 | dma_sync_single(hsotg->dev, req->dma, req->length, dir); | 377 | dma_sync_single_for_cpu(hsotg->dev, req->dma, req->length, dir); |
377 | } | 378 | } |
378 | } | 379 | } |
379 | 380 | ||
@@ -755,7 +756,7 @@ static int s3c_hsotg_map_dma(struct s3c_hsotg *hsotg, | |||
755 | hs_req->mapped = 1; | 756 | hs_req->mapped = 1; |
756 | req->dma = dma; | 757 | req->dma = dma; |
757 | } else { | 758 | } else { |
758 | dma_sync_single(hsotg->dev, req->dma, req->length, dir); | 759 | dma_sync_single_for_cpu(hsotg->dev, req->dma, req->length, dir); |
759 | hs_req->mapped = 0; | 760 | hs_req->mapped = 0; |
760 | } | 761 | } |
761 | 762 | ||
@@ -1460,7 +1461,7 @@ static u32 s3c_hsotg_read_frameno(struct s3c_hsotg *hsotg) | |||
1460 | * as the actual data should be sent to the memory directly and we turn | 1461 | * as the actual data should be sent to the memory directly and we turn |
1461 | * on the completion interrupts to get notifications of transfer completion. | 1462 | * on the completion interrupts to get notifications of transfer completion. |
1462 | */ | 1463 | */ |
1463 | void s3c_hsotg_handle_rx(struct s3c_hsotg *hsotg) | 1464 | static void s3c_hsotg_handle_rx(struct s3c_hsotg *hsotg) |
1464 | { | 1465 | { |
1465 | u32 grxstsr = readl(hsotg->regs + S3C_GRXSTSP); | 1466 | u32 grxstsr = readl(hsotg->regs + S3C_GRXSTSP); |
1466 | u32 epnum, status, size; | 1467 | u32 epnum, status, size; |
@@ -3094,7 +3095,7 @@ static void s3c_hsotg_gate(struct platform_device *pdev, bool on) | |||
3094 | local_irq_restore(flags); | 3095 | local_irq_restore(flags); |
3095 | } | 3096 | } |
3096 | 3097 | ||
3097 | struct s3c_hsotg_plat s3c_hsotg_default_pdata; | 3098 | static struct s3c_hsotg_plat s3c_hsotg_default_pdata; |
3098 | 3099 | ||
3099 | static int __devinit s3c_hsotg_probe(struct platform_device *pdev) | 3100 | static int __devinit s3c_hsotg_probe(struct platform_device *pdev) |
3100 | { | 3101 | { |
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c index 2fc02bd9584..84ca195c2d1 100644 --- a/drivers/usb/gadget/u_ether.c +++ b/drivers/usb/gadget/u_ether.c | |||
@@ -746,6 +746,10 @@ static const struct net_device_ops eth_netdev_ops = { | |||
746 | .ndo_validate_addr = eth_validate_addr, | 746 | .ndo_validate_addr = eth_validate_addr, |
747 | }; | 747 | }; |
748 | 748 | ||
749 | static struct device_type gadget_type = { | ||
750 | .name = "gadget", | ||
751 | }; | ||
752 | |||
749 | /** | 753 | /** |
750 | * gether_setup - initialize one ethernet-over-usb link | 754 | * gether_setup - initialize one ethernet-over-usb link |
751 | * @g: gadget to associated with these links | 755 | * @g: gadget to associated with these links |
@@ -808,6 +812,7 @@ int __init gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN]) | |||
808 | 812 | ||
809 | dev->gadget = g; | 813 | dev->gadget = g; |
810 | SET_NETDEV_DEV(net, &g->dev); | 814 | SET_NETDEV_DEV(net, &g->dev); |
815 | SET_NETDEV_DEVTYPE(net, &gadget_type); | ||
811 | 816 | ||
812 | status = register_netdev(net); | 817 | status = register_netdev(net); |
813 | if (status < 0) { | 818 | if (status < 0) { |
diff --git a/drivers/usb/gadget/u_ether.h b/drivers/usb/gadget/u_ether.h index fd55f450bc0..3c8c0c9f9d7 100644 --- a/drivers/usb/gadget/u_ether.h +++ b/drivers/usb/gadget/u_ether.h | |||
@@ -93,13 +93,6 @@ static inline bool can_support_ecm(struct usb_gadget *gadget) | |||
93 | if (!gadget_supports_altsettings(gadget)) | 93 | if (!gadget_supports_altsettings(gadget)) |
94 | return false; | 94 | return false; |
95 | 95 | ||
96 | /* SA1100 can do ECM, *without* status endpoint ... but we'll | ||
97 | * only use it in non-ECM mode for backwards compatibility | ||
98 | * (and since we currently require a status endpoint) | ||
99 | */ | ||
100 | if (gadget_is_sa1100(gadget)) | ||
101 | return false; | ||
102 | |||
103 | /* Everything else is *presumably* fine ... but this is a bit | 96 | /* Everything else is *presumably* fine ... but this is a bit |
104 | * chancy, so be **CERTAIN** there are no hardware issues with | 97 | * chancy, so be **CERTAIN** there are no hardware issues with |
105 | * your controller. Add it above if it can't handle CDC. | 98 | * your controller. Add it above if it can't handle CDC. |
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index 2d772401b7a..fac81ee193d 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c | |||
@@ -297,12 +297,10 @@ static int __init zero_bind(struct usb_composite_dev *cdev) | |||
297 | */ | 297 | */ |
298 | if (loopdefault) { | 298 | if (loopdefault) { |
299 | loopback_add(cdev, autoresume != 0); | 299 | loopback_add(cdev, autoresume != 0); |
300 | if (!gadget_is_sh(gadget)) | 300 | sourcesink_add(cdev, autoresume != 0); |
301 | sourcesink_add(cdev, autoresume != 0); | ||
302 | } else { | 301 | } else { |
303 | sourcesink_add(cdev, autoresume != 0); | 302 | sourcesink_add(cdev, autoresume != 0); |
304 | if (!gadget_is_sh(gadget)) | 303 | loopback_add(cdev, autoresume != 0); |
305 | loopback_add(cdev, autoresume != 0); | ||
306 | } | 304 | } |
307 | 305 | ||
308 | gcnum = usb_gadget_controller_number(gadget); | 306 | gcnum = usb_gadget_controller_number(gadget); |