aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/DocBook/gadget.tmpl2
-rw-r--r--Documentation/devices.txt3
-rw-r--r--Documentation/devicetree/bindings/usb/am33xx-usb.txt8
-rw-r--r--Documentation/usb/error-codes.txt7
-rw-r--r--Documentation/usb/mass-storage.txt15
-rw-r--r--MAINTAINERS6
-rw-r--r--arch/arm/configs/afeb9260_defconfig2
-rw-r--r--arch/arm/configs/at91sam9260_defconfig2
-rw-r--r--arch/arm/configs/at91sam9261_defconfig2
-rw-r--r--arch/arm/configs/at91sam9263_defconfig2
-rw-r--r--arch/arm/configs/at91sam9g20_defconfig2
-rw-r--r--arch/arm/configs/corgi_defconfig2
-rw-r--r--arch/arm/configs/davinci_all_defconfig2
-rw-r--r--arch/arm/configs/h7202_defconfig3
-rw-r--r--arch/arm/configs/magician_defconfig2
-rw-r--r--arch/arm/configs/mini2440_defconfig2
-rw-r--r--arch/arm/configs/omap1_defconfig3
-rw-r--r--arch/arm/configs/prima2_defconfig1
-rw-r--r--arch/arm/configs/spitz_defconfig2
-rw-r--r--arch/arm/configs/stamp9g20_defconfig2
-rw-r--r--arch/arm/configs/viper_defconfig2
-rw-r--r--arch/arm/configs/zeus_defconfig2
-rw-r--r--arch/arm/mach-cns3xxx/cns3420vb.c53
-rw-r--r--arch/avr32/configs/atngw100_defconfig2
-rw-r--r--arch/avr32/configs/atngw100_evklcd100_defconfig2
-rw-r--r--arch/avr32/configs/atngw100_evklcd101_defconfig2
-rw-r--r--arch/avr32/configs/atngw100_mrmt_defconfig2
-rw-r--r--arch/avr32/configs/atngw100mkii_defconfig2
-rw-r--r--arch/avr32/configs/atngw100mkii_evklcd100_defconfig2
-rw-r--r--arch/avr32/configs/atngw100mkii_evklcd101_defconfig2
-rw-r--r--arch/avr32/configs/atstk1002_defconfig2
-rw-r--r--arch/avr32/configs/atstk1003_defconfig2
-rw-r--r--arch/avr32/configs/atstk1004_defconfig2
-rw-r--r--arch/avr32/configs/atstk1006_defconfig2
-rw-r--r--arch/avr32/configs/favr-32_defconfig2
-rw-r--r--arch/avr32/configs/hammerhead_defconfig2
-rw-r--r--arch/blackfin/configs/CM-BF527_defconfig2
-rw-r--r--arch/blackfin/configs/CM-BF548_defconfig2
-rw-r--r--arch/blackfin/configs/CM-BF561_defconfig2
-rw-r--r--arch/mips/alchemy/common/Makefile2
-rw-r--r--arch/mips/alchemy/common/platform.c58
-rw-r--r--arch/mips/alchemy/common/usb.c (renamed from drivers/usb/host/alchemy-common.c)0
-rw-r--r--arch/mips/ath79/dev-usb.c2
-rw-r--r--arch/mips/configs/bcm47xx_defconfig2
-rw-r--r--arch/mips/configs/db1000_defconfig1
-rw-r--r--arch/mips/configs/db1235_defconfig2
-rw-r--r--arch/mips/configs/gpr_defconfig1
-rw-r--r--arch/mips/configs/ls1b_defconfig1
-rw-r--r--arch/mips/configs/mtx1_defconfig3
-rw-r--r--arch/mips/loongson1/common/platform.c7
-rw-r--r--arch/mips/netlogic/xlr/platform.c17
-rw-r--r--arch/mips/pnx8550/common/platform.c31
-rw-r--r--arch/sh/configs/ecovec24_defconfig2
-rw-r--r--arch/sh/configs/se7724_defconfig2
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh7720.c6
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7757.c6
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7763.c6
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7786.c6
-rw-r--r--drivers/usb/c67x00/c67x00-drv.c6
-rw-r--r--drivers/usb/chipidea/Kconfig1
-rw-r--r--drivers/usb/chipidea/ci13xxx_imx.c8
-rw-r--r--drivers/usb/chipidea/ci13xxx_msm.c6
-rw-r--r--drivers/usb/chipidea/ci13xxx_pci.c6
-rw-r--r--drivers/usb/chipidea/core.c9
-rw-r--r--drivers/usb/chipidea/debug.c3
-rw-r--r--drivers/usb/chipidea/host.c67
-rw-r--r--drivers/usb/chipidea/usbmisc_imx6q.c6
-rw-r--r--drivers/usb/class/cdc-acm.c38
-rw-r--r--drivers/usb/core/devices.c18
-rw-r--r--drivers/usb/core/driver.c25
-rw-r--r--drivers/usb/core/generic.c7
-rw-r--r--drivers/usb/core/hcd.c19
-rw-r--r--drivers/usb/core/hub.c97
-rw-r--r--drivers/usb/core/message.c66
-rw-r--r--drivers/usb/core/urb.c29
-rw-r--r--drivers/usb/core/usb.c13
-rw-r--r--drivers/usb/dwc3/Makefile14
-rw-r--r--drivers/usb/dwc3/core.c96
-rw-r--r--drivers/usb/dwc3/core.h3
-rw-r--r--drivers/usb/dwc3/debugfs.c4
-rw-r--r--drivers/usb/dwc3/dwc3-exynos.c57
-rw-r--r--drivers/usb/dwc3/dwc3-omap.c24
-rw-r--r--drivers/usb/dwc3/dwc3-pci.c24
-rw-r--r--drivers/usb/dwc3/gadget.c4
-rw-r--r--drivers/usb/early/ehci-dbgp.c4
-rw-r--r--drivers/usb/gadget/Kconfig29
-rw-r--r--drivers/usb/gadget/Makefile2
-rw-r--r--drivers/usb/gadget/at91_udc.c4
-rw-r--r--drivers/usb/gadget/bcm63xx_udc.c6
-rw-r--r--drivers/usb/gadget/composite.c8
-rw-r--r--drivers/usb/gadget/config.c39
-rw-r--r--drivers/usb/gadget/dummy_hcd.c170
-rw-r--r--drivers/usb/gadget/f_acm.c79
-rw-r--r--drivers/usb/gadget/f_ecm.c112
-rw-r--r--drivers/usb/gadget/f_eem.c51
-rw-r--r--drivers/usb/gadget/f_fs.c4
-rw-r--r--drivers/usb/gadget/f_hid.c30
-rw-r--r--drivers/usb/gadget/f_loopback.c28
-rw-r--r--drivers/usb/gadget/f_mass_storage.c63
-rw-r--r--drivers/usb/gadget/f_midi.c14
-rw-r--r--drivers/usb/gadget/f_ncm.c94
-rw-r--r--drivers/usb/gadget/f_obex.c42
-rw-r--r--drivers/usb/gadget/f_phonet.c21
-rw-r--r--drivers/usb/gadget/f_rndis.c94
-rw-r--r--drivers/usb/gadget/f_serial.c38
-rw-r--r--drivers/usb/gadget/f_sourcesink.c104
-rw-r--r--drivers/usb/gadget/f_subset.c75
-rw-r--r--drivers/usb/gadget/f_uac1.c23
-rw-r--r--drivers/usb/gadget/f_uac2.c222
-rw-r--r--drivers/usb/gadget/f_uvc.c138
-rw-r--r--drivers/usb/gadget/file_storage.c3656
-rw-r--r--drivers/usb/gadget/fsl_qe_udc.c14
-rw-r--r--drivers/usb/gadget/fsl_udc_core.c2
-rw-r--r--drivers/usb/gadget/hid.c4
-rw-r--r--drivers/usb/gadget/inode.c3
-rw-r--r--drivers/usb/gadget/lpc32xx_udc.c6
-rw-r--r--drivers/usb/gadget/mv_u3d_core.c2
-rw-r--r--drivers/usb/gadget/mv_udc_core.c4
-rw-r--r--drivers/usb/gadget/net2272.c29
-rw-r--r--drivers/usb/gadget/net2280.c2
-rw-r--r--drivers/usb/gadget/omap_udc.c10
-rw-r--r--drivers/usb/gadget/printer.c12
-rw-r--r--drivers/usb/gadget/pxa27x_udc.h2
-rw-r--r--drivers/usb/gadget/s3c-hsotg.c12
-rw-r--r--drivers/usb/gadget/s3c-hsudc.c2
-rw-r--r--drivers/usb/gadget/storage_common.c165
-rw-r--r--drivers/usb/gadget/tcm_usb_gadget.c13
-rw-r--r--drivers/usb/gadget/udc-core.c11
-rw-r--r--drivers/usb/host/Kconfig35
-rw-r--r--drivers/usb/host/Makefile4
-rw-r--r--drivers/usb/host/bcma-hcd.c15
-rw-r--r--drivers/usb/host/ehci-atmel.c15
-rw-r--r--drivers/usb/host/ehci-au1xxx.c184
-rw-r--r--drivers/usb/host/ehci-cns3xxx.c155
-rw-r--r--drivers/usb/host/ehci-dbg.c112
-rw-r--r--drivers/usb/host/ehci-fsl.c1
-rw-r--r--drivers/usb/host/ehci-grlib.c20
-rw-r--r--drivers/usb/host/ehci-hcd.c204
-rw-r--r--drivers/usb/host/ehci-hub.c47
-rw-r--r--drivers/usb/host/ehci-ixp4xx.c139
-rw-r--r--drivers/usb/host/ehci-lpm.c84
-rw-r--r--drivers/usb/host/ehci-ls1x.c147
-rw-r--r--drivers/usb/host/ehci-msm.c5
-rw-r--r--drivers/usb/host/ehci-mxc.c10
-rw-r--r--drivers/usb/host/ehci-octeon.c3
-rw-r--r--drivers/usb/host/ehci-omap.c3
-rw-r--r--drivers/usb/host/ehci-orion.c20
-rw-r--r--drivers/usb/host/ehci-pci.c132
-rw-r--r--drivers/usb/host/ehci-platform.c102
-rw-r--r--drivers/usb/host/ehci-pmcmsp.c1
-rw-r--r--drivers/usb/host/ehci-ppc-of.c4
-rw-r--r--drivers/usb/host/ehci-ps3.c2
-rw-r--r--drivers/usb/host/ehci-q.c12
-rw-r--r--drivers/usb/host/ehci-s5p.c16
-rw-r--r--drivers/usb/host/ehci-sched.c136
-rw-r--r--drivers/usb/host/ehci-sh.c9
-rw-r--r--drivers/usb/host/ehci-spear.c59
-rw-r--r--drivers/usb/host/ehci-tegra.c18
-rw-r--r--drivers/usb/host/ehci-vt8500.c21
-rw-r--r--drivers/usb/host/ehci-w90x900.c10
-rw-r--r--drivers/usb/host/ehci-xilinx-of.c2
-rw-r--r--drivers/usb/host/ehci-xls.c142
-rw-r--r--drivers/usb/host/ehci.h45
-rw-r--r--drivers/usb/host/fhci-hcd.c8
-rw-r--r--drivers/usb/host/fsl-mph-dr-of.c16
-rw-r--r--drivers/usb/host/imx21-hcd.c2
-rw-r--r--drivers/usb/host/isp116x-hcd.c2
-rw-r--r--drivers/usb/host/isp1362-hcd.c6
-rw-r--r--drivers/usb/host/isp1760-if.c15
-rw-r--r--drivers/usb/host/ohci-at91.c22
-rw-r--r--drivers/usb/host/ohci-au1xxx.c234
-rw-r--r--drivers/usb/host/ohci-cns3xxx.c166
-rw-r--r--drivers/usb/host/ohci-ep93xx.c4
-rw-r--r--drivers/usb/host/ohci-exynos.c38
-rw-r--r--drivers/usb/host/ohci-hcd.c139
-rw-r--r--drivers/usb/host/ohci-hub.c42
-rw-r--r--drivers/usb/host/ohci-jz4740.c6
-rw-r--r--drivers/usb/host/ohci-nxp.c4
-rw-r--r--drivers/usb/host/ohci-octeon.c2
-rw-r--r--drivers/usb/host/ohci-omap.c2
-rw-r--r--drivers/usb/host/ohci-omap3.c6
-rw-r--r--drivers/usb/host/ohci-pci.c49
-rw-r--r--drivers/usb/host/ohci-platform.c34
-rw-r--r--drivers/usb/host/ohci-pnx8550.c243
-rw-r--r--drivers/usb/host/ohci-ppc-of.c4
-rw-r--r--drivers/usb/host/ohci-ppc-soc.c216
-rw-r--r--drivers/usb/host/ohci-ps3.c4
-rw-r--r--drivers/usb/host/ohci-pxa27x.c8
-rw-r--r--drivers/usb/host/ohci-q.c23
-rw-r--r--drivers/usb/host/ohci-s3c2410.c41
-rw-r--r--drivers/usb/host/ohci-sa1111.c2
-rw-r--r--drivers/usb/host/ohci-sh.c141
-rw-r--r--drivers/usb/host/ohci-sm501.c2
-rw-r--r--drivers/usb/host/ohci-spear.c50
-rw-r--r--drivers/usb/host/ohci-tmio.c8
-rw-r--r--drivers/usb/host/ohci-xls.c152
-rw-r--r--drivers/usb/host/pci-quirks.c20
-rw-r--r--drivers/usb/host/r8a66597-hcd.c12
-rw-r--r--drivers/usb/host/sl811-hcd.c6
-rw-r--r--drivers/usb/host/ssb-hcd.c19
-rw-r--r--drivers/usb/host/u132-hcd.c6
-rw-r--r--drivers/usb/host/uhci-grlib.c2
-rw-r--r--drivers/usb/host/uhci-platform.c2
-rw-r--r--drivers/usb/host/uhci-q.c73
-rw-r--r--drivers/usb/host/xhci-mem.c9
-rw-r--r--drivers/usb/host/xhci-pci.c16
-rw-r--r--drivers/usb/host/xhci-ring.c34
-rw-r--r--drivers/usb/host/xhci.c32
-rw-r--r--drivers/usb/host/xhci.h2
-rw-r--r--drivers/usb/misc/Kconfig1
-rw-r--r--drivers/usb/misc/ezusb.c38
-rw-r--r--drivers/usb/misc/usbtest.c4
-rw-r--r--drivers/usb/musb/am35x.c40
-rw-r--r--drivers/usb/musb/blackfin.c38
-rw-r--r--drivers/usb/musb/cppi_dma.c4
-rw-r--r--drivers/usb/musb/da8xx.c40
-rw-r--r--drivers/usb/musb/davinci.c40
-rw-r--r--drivers/usb/musb/musb_core.c137
-rw-r--r--drivers/usb/musb/musb_core.h5
-rw-r--r--drivers/usb/musb/musb_debugfs.c2
-rw-r--r--drivers/usb/musb/musb_dma.h3
-rw-r--r--drivers/usb/musb/musb_dsps.c141
-rw-r--r--drivers/usb/musb/musb_gadget.c36
-rw-r--r--drivers/usb/musb/musb_gadget_ep0.c6
-rw-r--r--drivers/usb/musb/musb_host.c2
-rw-r--r--drivers/usb/musb/musbhsdma.c3
-rw-r--r--drivers/usb/musb/musbhsdma.h4
-rw-r--r--drivers/usb/musb/omap2430.c52
-rw-r--r--drivers/usb/musb/tusb6010.c40
-rw-r--r--drivers/usb/musb/tusb6010_omap.c3
-rw-r--r--drivers/usb/musb/ux500.c62
-rw-r--r--drivers/usb/musb/ux500_dma.c3
-rw-r--r--drivers/usb/otg/ab8500-usb.c6
-rw-r--r--drivers/usb/otg/fsl_otg.c6
-rw-r--r--drivers/usb/otg/isp1301_omap.c2
-rw-r--r--drivers/usb/otg/msm_otg.c4
-rw-r--r--drivers/usb/otg/mv_otg.c14
-rw-r--r--drivers/usb/otg/mxs-phy.c59
-rw-r--r--drivers/usb/otg/nop-usb-xceiv.c6
-rw-r--r--drivers/usb/otg/twl4030-usb.c48
-rw-r--r--drivers/usb/otg/twl6030-usb.c2
-rw-r--r--drivers/usb/phy/Kconfig12
-rw-r--r--drivers/usb/phy/Makefile1
-rw-r--r--drivers/usb/phy/mv_u3d_phy.c4
-rw-r--r--drivers/usb/phy/omap-usb2.c6
-rw-r--r--drivers/usb/phy/rcar-phy.c220
-rw-r--r--drivers/usb/phy/tegra_usb_phy.c4
-rw-r--r--drivers/usb/renesas_usbhs/common.c9
-rw-r--r--drivers/usb/renesas_usbhs/common.h1
-rw-r--r--drivers/usb/renesas_usbhs/fifo.c14
-rw-r--r--drivers/usb/renesas_usbhs/mod.c3
-rw-r--r--drivers/usb/renesas_usbhs/mod_gadget.c11
-rw-r--r--drivers/usb/renesas_usbhs/mod_host.c45
-rw-r--r--drivers/usb/renesas_usbhs/pipe.c101
-rw-r--r--drivers/usb/renesas_usbhs/pipe.h1
-rw-r--r--drivers/usb/serial/aircable.c5
-rw-r--r--drivers/usb/serial/ark3116.c5
-rw-r--r--drivers/usb/serial/belkin_sa.c5
-rw-r--r--drivers/usb/serial/bus.c10
-rw-r--r--drivers/usb/serial/cp210x.c37
-rw-r--r--drivers/usb/serial/cyberjack.c5
-rw-r--r--drivers/usb/serial/cypress_m8.c5
-rw-r--r--drivers/usb/serial/digi_acceleport.c4
-rw-r--r--drivers/usb/serial/empeg.c4
-rw-r--r--drivers/usb/serial/ftdi_sio.c82
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h6
-rw-r--r--drivers/usb/serial/generic.c1
-rw-r--r--drivers/usb/serial/hp4x.c5
-rw-r--r--drivers/usb/serial/io_edgeport.c4
-rw-r--r--drivers/usb/serial/io_ti.c4
-rw-r--r--drivers/usb/serial/ipaq.c5
-rw-r--r--drivers/usb/serial/ipw.c4
-rw-r--r--drivers/usb/serial/iuu_phoenix.c8
-rw-r--r--drivers/usb/serial/keyspan.c4
-rw-r--r--drivers/usb/serial/keyspan_pda.c4
-rw-r--r--drivers/usb/serial/kl5kusb105.c4
-rw-r--r--drivers/usb/serial/kobil_sct.c2
-rw-r--r--drivers/usb/serial/mct_u232.c4
-rw-r--r--drivers/usb/serial/metro-usb.c2
-rw-r--r--drivers/usb/serial/mos7720.c4
-rw-r--r--drivers/usb/serial/mos7840.c4
-rw-r--r--drivers/usb/serial/omninet.c4
-rw-r--r--drivers/usb/serial/opticon.c351
-rw-r--r--drivers/usb/serial/option.c113
-rw-r--r--drivers/usb/serial/oti6858.c2
-rw-r--r--drivers/usb/serial/quatech2.c2
-rw-r--r--drivers/usb/serial/siemens_mpi.c2
-rw-r--r--drivers/usb/serial/sierra.c3
-rw-r--r--drivers/usb/serial/spcp8x5.c4
-rw-r--r--drivers/usb/serial/ssu100.c2
-rw-r--r--drivers/usb/serial/usb_wwan.c2
-rw-r--r--drivers/usb/serial/vivopay-serial.c3
-rw-r--r--drivers/usb/storage/Kconfig2
-rw-r--r--drivers/usb/storage/realtek_cr.c2
-rw-r--r--drivers/usb/storage/usb.c1
-rw-r--r--drivers/usb/usb-skeleton.c13
-rw-r--r--drivers/usb/wusbcore/devconnect.c13
-rw-r--r--drivers/uwb/Kconfig3
-rw-r--r--drivers/uwb/reset.c1
-rw-r--r--drivers/uwb/umc-bus.c2
-rw-r--r--firmware/Makefile1
-rw-r--r--firmware/dabusb/bitstream.bin.ihex761
-rw-r--r--firmware/dabusb/firmware.HEX649
-rw-r--r--include/linux/usb.h50
-rw-r--r--include/linux/usb/composite.h4
-rw-r--r--include/linux/usb/ehci_pdriver.h5
-rw-r--r--include/linux/usb/ezusb.h8
-rw-r--r--include/linux/usb/gadget.h7
-rw-r--r--include/linux/usb/ohci_pdriver.h2
-rw-r--r--include/linux/usb/phy.h15
310 files changed, 3028 insertions, 10754 deletions
diff --git a/Documentation/DocBook/gadget.tmpl b/Documentation/DocBook/gadget.tmpl
index 6ef2f0073e5a..4017f147ba2f 100644
--- a/Documentation/DocBook/gadget.tmpl
+++ b/Documentation/DocBook/gadget.tmpl
@@ -671,7 +671,7 @@ than a kernel driver.
671<para>There's a USB Mass Storage class driver, which provides 671<para>There's a USB Mass Storage class driver, which provides
672a different solution for interoperability with systems such 672a different solution for interoperability with systems such
673as MS-Windows and MacOS. 673as MS-Windows and MacOS.
674That <emphasis>File-backed Storage</emphasis> driver uses a 674That <emphasis>Mass Storage</emphasis> driver uses a
675file or block device as backing store for a drive, 675file or block device as backing store for a drive,
676like the <filename>loop</filename> driver. 676like the <filename>loop</filename> driver.
677The USB host uses the BBB, CB, or CBI versions of the mass 677The USB host uses the BBB, CB, or CBI versions of the mass
diff --git a/Documentation/devices.txt b/Documentation/devices.txt
index b6251cca9263..08f01e79c41a 100644
--- a/Documentation/devices.txt
+++ b/Documentation/devices.txt
@@ -2561,9 +2561,6 @@ Your cooperation is appreciated.
2561 192 = /dev/usb/yurex1 First USB Yurex device 2561 192 = /dev/usb/yurex1 First USB Yurex device
2562 ... 2562 ...
2563 209 = /dev/usb/yurex16 16th USB Yurex device 2563 209 = /dev/usb/yurex16 16th USB Yurex device
2564 240 = /dev/usb/dabusb0 First daubusb device
2565 ...
2566 243 = /dev/usb/dabusb3 Fourth dabusb device
2567 2564
2568180 block USB block devices 2565180 block USB block devices
2569 0 = /dev/uba First USB block device 2566 0 = /dev/uba First USB block device
diff --git a/Documentation/devicetree/bindings/usb/am33xx-usb.txt b/Documentation/devicetree/bindings/usb/am33xx-usb.txt
index ca8fa56e9f03..a92250512a4e 100644
--- a/Documentation/devicetree/bindings/usb/am33xx-usb.txt
+++ b/Documentation/devicetree/bindings/usb/am33xx-usb.txt
@@ -3,12 +3,12 @@ AM33XX MUSB GLUE
3 - ti,hwmods : must be "usb_otg_hs" 3 - ti,hwmods : must be "usb_otg_hs"
4 - multipoint : Should be "1" indicating the musb controller supports 4 - multipoint : Should be "1" indicating the musb controller supports
5 multipoint. This is a MUSB configuration-specific setting. 5 multipoint. This is a MUSB configuration-specific setting.
6 - num_eps : Specifies the number of endpoints. This is also a 6 - num-eps : Specifies the number of endpoints. This is also a
7 MUSB configuration-specific setting. Should be set to "16" 7 MUSB configuration-specific setting. Should be set to "16"
8 - ram_bits : Specifies the ram address size. Should be set to "12" 8 - ram-bits : Specifies the ram address size. Should be set to "12"
9 - port0_mode : Should be "3" to represent OTG. "1" signifies HOST and "2" 9 - port0-mode : Should be "3" to represent OTG. "1" signifies HOST and "2"
10 represents PERIPHERAL. 10 represents PERIPHERAL.
11 - port1_mode : Should be "1" to represent HOST. "3" signifies OTG and "2" 11 - port1-mode : Should be "1" to represent HOST. "3" signifies OTG and "2"
12 represents PERIPHERAL. 12 represents PERIPHERAL.
13 - power : Should be "250". This signifies the controller can supply upto 13 - power : Should be "250". This signifies the controller can supply upto
14 500mA when operating in host mode. 14 500mA when operating in host mode.
diff --git a/Documentation/usb/error-codes.txt b/Documentation/usb/error-codes.txt
index b3f606b81a03..9c3eb845ebe5 100644
--- a/Documentation/usb/error-codes.txt
+++ b/Documentation/usb/error-codes.txt
@@ -21,6 +21,8 @@ Non-USB-specific:
21 21
22USB-specific: 22USB-specific:
23 23
24-EBUSY The URB is already active.
25
24-ENODEV specified USB-device or bus doesn't exist 26-ENODEV specified USB-device or bus doesn't exist
25 27
26-ENOENT specified interface or endpoint does not exist or 28-ENOENT specified interface or endpoint does not exist or
@@ -35,9 +37,8 @@ USB-specific:
35 d) ISO: number_of_packets is < 0 37 d) ISO: number_of_packets is < 0
36 e) various other cases 38 e) various other cases
37 39
38-EAGAIN a) specified ISO start frame too early 40-EXDEV ISO: URB_ISO_ASAP wasn't specified and all the frames
39 b) (using ISO-ASAP) too much scheduled for the future 41 the URB would be scheduled in have already expired.
40 wait some time and try again.
41 42
42-EFBIG Host controller driver can't schedule that many ISO frames. 43-EFBIG Host controller driver can't schedule that many ISO frames.
43 44
diff --git a/Documentation/usb/mass-storage.txt b/Documentation/usb/mass-storage.txt
index e9b9334627bf..59063ad7a60d 100644
--- a/Documentation/usb/mass-storage.txt
+++ b/Documentation/usb/mass-storage.txt
@@ -20,9 +20,9 @@
20 20
21 This document describes how to use the gadget from user space, its 21 This document describes how to use the gadget from user space, its
22 relation to mass storage function (or MSF) and different gadgets 22 relation to mass storage function (or MSF) and different gadgets
23 using it, and how it differs from File Storage Gadget (or FSG). It 23 using it, and how it differs from File Storage Gadget (or FSG)
24 will talk only briefly about how to use MSF within composite 24 (which is no longer included in Linux). It will talk only briefly
25 gadgets. 25 about how to use MSF within composite gadgets.
26 26
27* Module parameters 27* Module parameters
28 28
@@ -198,16 +198,15 @@
198 The Mass Storage Function and thus the Mass Storage Gadget has been 198 The Mass Storage Function and thus the Mass Storage Gadget has been
199 based on the File Storage Gadget. The difference between the two is 199 based on the File Storage Gadget. The difference between the two is
200 that MSG is a composite gadget (ie. uses the composite framework) 200 that MSG is a composite gadget (ie. uses the composite framework)
201 while file storage gadget is a traditional gadget. From userspace 201 while file storage gadget was a traditional gadget. From userspace
202 point of view this distinction does not really matter, but from 202 point of view this distinction does not really matter, but from
203 kernel hacker's point of view, this means that (i) MSG does not 203 kernel hacker's point of view, this means that (i) MSG does not
204 duplicate code needed for handling basic USB protocol commands and 204 duplicate code needed for handling basic USB protocol commands and
205 (ii) MSF can be used in any other composite gadget. 205 (ii) MSF can be used in any other composite gadget.
206 206
207 Because of that, File Storage Gadget has been deprecated and 207 Because of that, File Storage Gadget has been removed in Linux 3.8.
208 scheduled to be removed in Linux 3.8. All users need to transition 208 All users need to transition to the Mass Storage Gadget. The two
209 to the Mass Storage Gadget by that time. The two gadgets behave 209 gadgets behave mostly the same from the outside except:
210 mostly the same from the outside except:
211 210
212 1. In FSG the “removable” and “cdrom” module parameters set the flag 211 1. In FSG the “removable” and “cdrom” module parameters set the flag
213 for all logical units whereas in MSG they accept a list of y/n 212 for all logical units whereas in MSG they accept a list of y/n
diff --git a/MAINTAINERS b/MAINTAINERS
index b68c3a10006c..23b9584c44cb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7587,12 +7587,6 @@ L: linux-scsi@vger.kernel.org
7587S: Supported 7587S: Supported
7588F: drivers/usb/storage/uas.c 7588F: drivers/usb/storage/uas.c
7589 7589
7590USB BLOCK DRIVER (UB ub)
7591M: Pete Zaitcev <zaitcev@redhat.com>
7592L: linux-usb@vger.kernel.org
7593S: Supported
7594F: drivers/block/ub.c
7595
7596USB CDC ETHERNET DRIVER 7590USB CDC ETHERNET DRIVER
7597M: Oliver Neukum <oliver@neukum.org> 7591M: Oliver Neukum <oliver@neukum.org>
7598L: linux-usb@vger.kernel.org 7592L: linux-usb@vger.kernel.org
diff --git a/arch/arm/configs/afeb9260_defconfig b/arch/arm/configs/afeb9260_defconfig
index c285a9d777d9..a8dbc1e05253 100644
--- a/arch/arm/configs/afeb9260_defconfig
+++ b/arch/arm/configs/afeb9260_defconfig
@@ -79,7 +79,7 @@ CONFIG_USB_STORAGE=y
79CONFIG_USB_GADGET=y 79CONFIG_USB_GADGET=y
80CONFIG_USB_ZERO=m 80CONFIG_USB_ZERO=m
81CONFIG_USB_GADGETFS=m 81CONFIG_USB_GADGETFS=m
82CONFIG_USB_FILE_STORAGE=m 82CONFIG_USB_MASS_STORAGE=m
83CONFIG_USB_G_SERIAL=m 83CONFIG_USB_G_SERIAL=m
84CONFIG_RTC_CLASS=y 84CONFIG_RTC_CLASS=y
85CONFIG_RTC_DEBUG=y 85CONFIG_RTC_DEBUG=y
diff --git a/arch/arm/configs/at91sam9260_defconfig b/arch/arm/configs/at91sam9260_defconfig
index 505b3765f87e..0ea5d2c97fc4 100644
--- a/arch/arm/configs/at91sam9260_defconfig
+++ b/arch/arm/configs/at91sam9260_defconfig
@@ -75,7 +75,7 @@ CONFIG_USB_STORAGE_DEBUG=y
75CONFIG_USB_GADGET=y 75CONFIG_USB_GADGET=y
76CONFIG_USB_ZERO=m 76CONFIG_USB_ZERO=m
77CONFIG_USB_GADGETFS=m 77CONFIG_USB_GADGETFS=m
78CONFIG_USB_FILE_STORAGE=m 78CONFIG_USB_MASS_STORAGE=m
79CONFIG_USB_G_SERIAL=m 79CONFIG_USB_G_SERIAL=m
80CONFIG_RTC_CLASS=y 80CONFIG_RTC_CLASS=y
81CONFIG_RTC_DRV_AT91SAM9=y 81CONFIG_RTC_DRV_AT91SAM9=y
diff --git a/arch/arm/configs/at91sam9261_defconfig b/arch/arm/configs/at91sam9261_defconfig
index 1e8712ef062e..c87beb973b37 100644
--- a/arch/arm/configs/at91sam9261_defconfig
+++ b/arch/arm/configs/at91sam9261_defconfig
@@ -125,7 +125,7 @@ CONFIG_USB_GADGET=y
125CONFIG_USB_ZERO=m 125CONFIG_USB_ZERO=m
126CONFIG_USB_ETH=m 126CONFIG_USB_ETH=m
127CONFIG_USB_GADGETFS=m 127CONFIG_USB_GADGETFS=m
128CONFIG_USB_FILE_STORAGE=m 128CONFIG_USB_MASS_STORAGE=m
129CONFIG_USB_G_SERIAL=m 129CONFIG_USB_G_SERIAL=m
130CONFIG_MMC=y 130CONFIG_MMC=y
131CONFIG_MMC_ATMELMCI=m 131CONFIG_MMC_ATMELMCI=m
diff --git a/arch/arm/configs/at91sam9263_defconfig b/arch/arm/configs/at91sam9263_defconfig
index d2050cada82d..c5212f43eee6 100644
--- a/arch/arm/configs/at91sam9263_defconfig
+++ b/arch/arm/configs/at91sam9263_defconfig
@@ -133,7 +133,7 @@ CONFIG_USB_GADGET=y
133CONFIG_USB_ZERO=m 133CONFIG_USB_ZERO=m
134CONFIG_USB_ETH=m 134CONFIG_USB_ETH=m
135CONFIG_USB_GADGETFS=m 135CONFIG_USB_GADGETFS=m
136CONFIG_USB_FILE_STORAGE=m 136CONFIG_USB_MASS_STORAGE=m
137CONFIG_USB_G_SERIAL=m 137CONFIG_USB_G_SERIAL=m
138CONFIG_MMC=y 138CONFIG_MMC=y
139CONFIG_SDIO_UART=m 139CONFIG_SDIO_UART=m
diff --git a/arch/arm/configs/at91sam9g20_defconfig b/arch/arm/configs/at91sam9g20_defconfig
index e1b0e80b54a5..3b1881033ad8 100644
--- a/arch/arm/configs/at91sam9g20_defconfig
+++ b/arch/arm/configs/at91sam9g20_defconfig
@@ -96,7 +96,7 @@ CONFIG_USB_STORAGE=y
96CONFIG_USB_GADGET=y 96CONFIG_USB_GADGET=y
97CONFIG_USB_ZERO=m 97CONFIG_USB_ZERO=m
98CONFIG_USB_GADGETFS=m 98CONFIG_USB_GADGETFS=m
99CONFIG_USB_FILE_STORAGE=m 99CONFIG_USB_MASS_STORAGE=m
100CONFIG_USB_G_SERIAL=m 100CONFIG_USB_G_SERIAL=m
101CONFIG_MMC=y 101CONFIG_MMC=y
102CONFIG_MMC_ATMELMCI=m 102CONFIG_MMC_ATMELMCI=m
diff --git a/arch/arm/configs/corgi_defconfig b/arch/arm/configs/corgi_defconfig
index 4b8a25d9e686..1fd1d1de3220 100644
--- a/arch/arm/configs/corgi_defconfig
+++ b/arch/arm/configs/corgi_defconfig
@@ -218,7 +218,7 @@ CONFIG_USB_GADGET=y
218CONFIG_USB_ZERO=m 218CONFIG_USB_ZERO=m
219CONFIG_USB_ETH=m 219CONFIG_USB_ETH=m
220CONFIG_USB_GADGETFS=m 220CONFIG_USB_GADGETFS=m
221CONFIG_USB_FILE_STORAGE=m 221CONFIG_USB_MASS_STORAGE=m
222CONFIG_USB_G_SERIAL=m 222CONFIG_USB_G_SERIAL=m
223CONFIG_MMC=y 223CONFIG_MMC=y
224CONFIG_MMC_PXA=y 224CONFIG_MMC_PXA=y
diff --git a/arch/arm/configs/davinci_all_defconfig b/arch/arm/configs/davinci_all_defconfig
index 67b5abb6f857..4ea7c95719d2 100644
--- a/arch/arm/configs/davinci_all_defconfig
+++ b/arch/arm/configs/davinci_all_defconfig
@@ -144,7 +144,7 @@ CONFIG_USB_GADGET_DEBUG_FS=y
144CONFIG_USB_ZERO=m 144CONFIG_USB_ZERO=m
145CONFIG_USB_ETH=m 145CONFIG_USB_ETH=m
146CONFIG_USB_GADGETFS=m 146CONFIG_USB_GADGETFS=m
147CONFIG_USB_FILE_STORAGE=m 147CONFIG_USB_MASS_STORAGE=m
148CONFIG_USB_G_SERIAL=m 148CONFIG_USB_G_SERIAL=m
149CONFIG_USB_G_PRINTER=m 149CONFIG_USB_G_PRINTER=m
150CONFIG_USB_CDC_COMPOSITE=m 150CONFIG_USB_CDC_COMPOSITE=m
diff --git a/arch/arm/configs/h7202_defconfig b/arch/arm/configs/h7202_defconfig
index 69405a762423..e16d3f372e2a 100644
--- a/arch/arm/configs/h7202_defconfig
+++ b/arch/arm/configs/h7202_defconfig
@@ -34,8 +34,7 @@ CONFIG_FB_MODE_HELPERS=y
34CONFIG_USB_GADGET=m 34CONFIG_USB_GADGET=m
35CONFIG_USB_ZERO=m 35CONFIG_USB_ZERO=m
36CONFIG_USB_GADGETFS=m 36CONFIG_USB_GADGETFS=m
37CONFIG_USB_FILE_STORAGE=m 37CONFIG_USB_MASS_STORAGE=m
38CONFIG_USB_FILE_STORAGE_TEST=y
39CONFIG_USB_G_SERIAL=m 38CONFIG_USB_G_SERIAL=m
40CONFIG_EXT2_FS=y 39CONFIG_EXT2_FS=y
41CONFIG_TMPFS=y 40CONFIG_TMPFS=y
diff --git a/arch/arm/configs/magician_defconfig b/arch/arm/configs/magician_defconfig
index a691ef4c6008..557dd291288b 100644
--- a/arch/arm/configs/magician_defconfig
+++ b/arch/arm/configs/magician_defconfig
@@ -136,7 +136,7 @@ CONFIG_USB_PXA27X=y
136CONFIG_USB_ETH=m 136CONFIG_USB_ETH=m
137# CONFIG_USB_ETH_RNDIS is not set 137# CONFIG_USB_ETH_RNDIS is not set
138CONFIG_USB_GADGETFS=m 138CONFIG_USB_GADGETFS=m
139CONFIG_USB_FILE_STORAGE=m 139CONFIG_USB_MASS_STORAGE=m
140CONFIG_USB_G_SERIAL=m 140CONFIG_USB_G_SERIAL=m
141CONFIG_USB_CDC_COMPOSITE=m 141CONFIG_USB_CDC_COMPOSITE=m
142CONFIG_USB_GPIO_VBUS=y 142CONFIG_USB_GPIO_VBUS=y
diff --git a/arch/arm/configs/mini2440_defconfig b/arch/arm/configs/mini2440_defconfig
index 00630e6af45c..a07948a87caa 100644
--- a/arch/arm/configs/mini2440_defconfig
+++ b/arch/arm/configs/mini2440_defconfig
@@ -240,7 +240,7 @@ CONFIG_USB_GADGET_S3C2410=y
240CONFIG_USB_ZERO=m 240CONFIG_USB_ZERO=m
241CONFIG_USB_ETH=m 241CONFIG_USB_ETH=m
242CONFIG_USB_GADGETFS=m 242CONFIG_USB_GADGETFS=m
243CONFIG_USB_FILE_STORAGE=m 243CONFIG_USB_MASS_STORAGE=m
244CONFIG_USB_G_SERIAL=m 244CONFIG_USB_G_SERIAL=m
245CONFIG_USB_CDC_COMPOSITE=m 245CONFIG_USB_CDC_COMPOSITE=m
246CONFIG_MMC=y 246CONFIG_MMC=y
diff --git a/arch/arm/configs/omap1_defconfig b/arch/arm/configs/omap1_defconfig
index dde2a1af7b39..42eab9a2a0fd 100644
--- a/arch/arm/configs/omap1_defconfig
+++ b/arch/arm/configs/omap1_defconfig
@@ -214,8 +214,7 @@ CONFIG_USB_TEST=y
214CONFIG_USB_GADGET=y 214CONFIG_USB_GADGET=y
215CONFIG_USB_ETH=m 215CONFIG_USB_ETH=m
216# CONFIG_USB_ETH_RNDIS is not set 216# CONFIG_USB_ETH_RNDIS is not set
217CONFIG_USB_FILE_STORAGE=m 217CONFIG_USB_MASS_STORAGE=m
218CONFIG_USB_FILE_STORAGE_TEST=y
219CONFIG_MMC=y 218CONFIG_MMC=y
220CONFIG_MMC_SDHCI=y 219CONFIG_MMC_SDHCI=y
221CONFIG_MMC_SDHCI_PLTFM=y 220CONFIG_MMC_SDHCI_PLTFM=y
diff --git a/arch/arm/configs/prima2_defconfig b/arch/arm/configs/prima2_defconfig
index 807d4e2acb17..6a936c7c078a 100644
--- a/arch/arm/configs/prima2_defconfig
+++ b/arch/arm/configs/prima2_defconfig
@@ -37,7 +37,6 @@ CONFIG_SPI_SIRF=y
37CONFIG_SPI_SPIDEV=y 37CONFIG_SPI_SPIDEV=y
38# CONFIG_HWMON is not set 38# CONFIG_HWMON is not set
39CONFIG_USB_GADGET=y 39CONFIG_USB_GADGET=y
40CONFIG_USB_FILE_STORAGE=m
41CONFIG_USB_MASS_STORAGE=m 40CONFIG_USB_MASS_STORAGE=m
42CONFIG_MMC=y 41CONFIG_MMC=y
43CONFIG_MMC_SDHCI=y 42CONFIG_MMC_SDHCI=y
diff --git a/arch/arm/configs/spitz_defconfig b/arch/arm/configs/spitz_defconfig
index df77931a4326..2e0419d1b964 100644
--- a/arch/arm/configs/spitz_defconfig
+++ b/arch/arm/configs/spitz_defconfig
@@ -214,7 +214,7 @@ CONFIG_USB_GADGET_DUMMY_HCD=y
214CONFIG_USB_ZERO=m 214CONFIG_USB_ZERO=m
215CONFIG_USB_ETH=m 215CONFIG_USB_ETH=m
216CONFIG_USB_GADGETFS=m 216CONFIG_USB_GADGETFS=m
217CONFIG_USB_FILE_STORAGE=m 217CONFIG_USB_MASS_STORAGE=m
218CONFIG_USB_G_SERIAL=m 218CONFIG_USB_G_SERIAL=m
219CONFIG_MMC=y 219CONFIG_MMC=y
220CONFIG_MMC_PXA=y 220CONFIG_MMC_PXA=y
diff --git a/arch/arm/configs/stamp9g20_defconfig b/arch/arm/configs/stamp9g20_defconfig
index 52f1488591c7..b845f5519bcc 100644
--- a/arch/arm/configs/stamp9g20_defconfig
+++ b/arch/arm/configs/stamp9g20_defconfig
@@ -97,7 +97,7 @@ CONFIG_USB_STORAGE=y
97CONFIG_USB_GADGET=m 97CONFIG_USB_GADGET=m
98CONFIG_USB_ZERO=m 98CONFIG_USB_ZERO=m
99CONFIG_USB_ETH=m 99CONFIG_USB_ETH=m
100CONFIG_USB_FILE_STORAGE=m 100CONFIG_USB_MASS_STORAGE=m
101CONFIG_USB_G_SERIAL=m 101CONFIG_USB_G_SERIAL=m
102CONFIG_MMC=y 102CONFIG_MMC=y
103CONFIG_MMC_ATMELMCI=y 103CONFIG_MMC_ATMELMCI=y
diff --git a/arch/arm/configs/viper_defconfig b/arch/arm/configs/viper_defconfig
index 1d01ddd33122..d36e0d3c86ec 100644
--- a/arch/arm/configs/viper_defconfig
+++ b/arch/arm/configs/viper_defconfig
@@ -139,7 +139,7 @@ CONFIG_USB_SERIAL_MCT_U232=m
139CONFIG_USB_GADGET=m 139CONFIG_USB_GADGET=m
140CONFIG_USB_ETH=m 140CONFIG_USB_ETH=m
141CONFIG_USB_GADGETFS=m 141CONFIG_USB_GADGETFS=m
142CONFIG_USB_FILE_STORAGE=m 142CONFIG_USB_MASS_STORAGE=m
143CONFIG_USB_G_SERIAL=m 143CONFIG_USB_G_SERIAL=m
144CONFIG_USB_G_PRINTER=m 144CONFIG_USB_G_PRINTER=m
145CONFIG_RTC_CLASS=y 145CONFIG_RTC_CLASS=y
diff --git a/arch/arm/configs/zeus_defconfig b/arch/arm/configs/zeus_defconfig
index 547a3c1e59db..731d4f985310 100644
--- a/arch/arm/configs/zeus_defconfig
+++ b/arch/arm/configs/zeus_defconfig
@@ -143,7 +143,7 @@ CONFIG_USB_GADGET=m
143CONFIG_USB_PXA27X=y 143CONFIG_USB_PXA27X=y
144CONFIG_USB_ETH=m 144CONFIG_USB_ETH=m
145CONFIG_USB_GADGETFS=m 145CONFIG_USB_GADGETFS=m
146CONFIG_USB_FILE_STORAGE=m 146CONFIG_USB_MASS_STORAGE=m
147CONFIG_USB_G_SERIAL=m 147CONFIG_USB_G_SERIAL=m
148CONFIG_USB_G_PRINTER=m 148CONFIG_USB_G_PRINTER=m
149CONFIG_MMC=y 149CONFIG_MMC=y
diff --git a/arch/arm/mach-cns3xxx/cns3420vb.c b/arch/arm/mach-cns3xxx/cns3420vb.c
index 2c5fb4c7e509..ae305397003c 100644
--- a/arch/arm/mach-cns3xxx/cns3420vb.c
+++ b/arch/arm/mach-cns3xxx/cns3420vb.c
@@ -24,6 +24,8 @@
24#include <linux/mtd/mtd.h> 24#include <linux/mtd/mtd.h>
25#include <linux/mtd/physmap.h> 25#include <linux/mtd/physmap.h>
26#include <linux/mtd/partitions.h> 26#include <linux/mtd/partitions.h>
27#include <linux/usb/ehci_pdriver.h>
28#include <linux/usb/ohci_pdriver.h>
27#include <asm/setup.h> 29#include <asm/setup.h>
28#include <asm/mach-types.h> 30#include <asm/mach-types.h>
29#include <asm/hardware/gic.h> 31#include <asm/hardware/gic.h>
@@ -32,6 +34,7 @@
32#include <asm/mach/time.h> 34#include <asm/mach/time.h>
33#include <mach/cns3xxx.h> 35#include <mach/cns3xxx.h>
34#include <mach/irqs.h> 36#include <mach/irqs.h>
37#include <mach/pm.h>
35#include "core.h" 38#include "core.h"
36#include "devices.h" 39#include "devices.h"
37 40
@@ -125,13 +128,52 @@ static struct resource cns3xxx_usb_ehci_resources[] = {
125 128
126static u64 cns3xxx_usb_ehci_dma_mask = DMA_BIT_MASK(32); 129static u64 cns3xxx_usb_ehci_dma_mask = DMA_BIT_MASK(32);
127 130
131static int csn3xxx_usb_power_on(struct platform_device *pdev)
132{
133 /*
134 * EHCI and OHCI share the same clock and power,
135 * resetting twice would cause the 1st controller been reset.
136 * Therefore only do power up at the first up device, and
137 * power down at the last down device.
138 *
139 * Set USB AHB INCR length to 16
140 */
141 if (atomic_inc_return(&usb_pwr_ref) == 1) {
142 cns3xxx_pwr_power_up(1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_PLL_USB);
143 cns3xxx_pwr_clk_en(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST);
144 cns3xxx_pwr_soft_rst(1 << PM_SOFT_RST_REG_OFFST_USB_HOST);
145 __raw_writel((__raw_readl(MISC_CHIP_CONFIG_REG) | (0X2 << 24)),
146 MISC_CHIP_CONFIG_REG);
147 }
148
149 return 0;
150}
151
152static void csn3xxx_usb_power_off(struct platform_device *pdev)
153{
154 /*
155 * EHCI and OHCI share the same clock and power,
156 * resetting twice would cause the 1st controller been reset.
157 * Therefore only do power up at the first up device, and
158 * power down at the last down device.
159 */
160 if (atomic_dec_return(&usb_pwr_ref) == 0)
161 cns3xxx_pwr_clk_dis(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST);
162}
163
164static struct usb_ehci_pdata cns3xxx_usb_ehci_pdata = {
165 .power_on = csn3xxx_usb_power_on,
166 .power_off = csn3xxx_usb_power_off,
167};
168
128static struct platform_device cns3xxx_usb_ehci_device = { 169static struct platform_device cns3xxx_usb_ehci_device = {
129 .name = "cns3xxx-ehci", 170 .name = "ehci-platform",
130 .num_resources = ARRAY_SIZE(cns3xxx_usb_ehci_resources), 171 .num_resources = ARRAY_SIZE(cns3xxx_usb_ehci_resources),
131 .resource = cns3xxx_usb_ehci_resources, 172 .resource = cns3xxx_usb_ehci_resources,
132 .dev = { 173 .dev = {
133 .dma_mask = &cns3xxx_usb_ehci_dma_mask, 174 .dma_mask = &cns3xxx_usb_ehci_dma_mask,
134 .coherent_dma_mask = DMA_BIT_MASK(32), 175 .coherent_dma_mask = DMA_BIT_MASK(32),
176 .platform_data = &cns3xxx_usb_ehci_pdata,
135 }, 177 },
136}; 178};
137 179
@@ -149,13 +191,20 @@ static struct resource cns3xxx_usb_ohci_resources[] = {
149 191
150static u64 cns3xxx_usb_ohci_dma_mask = DMA_BIT_MASK(32); 192static u64 cns3xxx_usb_ohci_dma_mask = DMA_BIT_MASK(32);
151 193
194static struct usb_ohci_pdata cns3xxx_usb_ohci_pdata = {
195 .num_ports = 1,
196 .power_on = csn3xxx_usb_power_on,
197 .power_off = csn3xxx_usb_power_off,
198};
199
152static struct platform_device cns3xxx_usb_ohci_device = { 200static struct platform_device cns3xxx_usb_ohci_device = {
153 .name = "cns3xxx-ohci", 201 .name = "ohci-platform",
154 .num_resources = ARRAY_SIZE(cns3xxx_usb_ohci_resources), 202 .num_resources = ARRAY_SIZE(cns3xxx_usb_ohci_resources),
155 .resource = cns3xxx_usb_ohci_resources, 203 .resource = cns3xxx_usb_ohci_resources,
156 .dev = { 204 .dev = {
157 .dma_mask = &cns3xxx_usb_ohci_dma_mask, 205 .dma_mask = &cns3xxx_usb_ohci_dma_mask,
158 .coherent_dma_mask = DMA_BIT_MASK(32), 206 .coherent_dma_mask = DMA_BIT_MASK(32),
207 .platform_data = &cns3xxx_usb_ohci_pdata,
159 }, 208 },
160}; 209};
161 210
diff --git a/arch/avr32/configs/atngw100_defconfig b/arch/avr32/configs/atngw100_defconfig
index a06bfccc2840..f4025db184ff 100644
--- a/arch/avr32/configs/atngw100_defconfig
+++ b/arch/avr32/configs/atngw100_defconfig
@@ -109,7 +109,7 @@ CONFIG_USB_GADGET_VBUS_DRAW=350
109CONFIG_USB_ZERO=m 109CONFIG_USB_ZERO=m
110CONFIG_USB_ETH=m 110CONFIG_USB_ETH=m
111CONFIG_USB_GADGETFS=m 111CONFIG_USB_GADGETFS=m
112CONFIG_USB_FILE_STORAGE=m 112CONFIG_USB_MASS_STORAGE=m
113CONFIG_USB_G_SERIAL=m 113CONFIG_USB_G_SERIAL=m
114CONFIG_USB_CDC_COMPOSITE=m 114CONFIG_USB_CDC_COMPOSITE=m
115CONFIG_MMC=y 115CONFIG_MMC=y
diff --git a/arch/avr32/configs/atngw100_evklcd100_defconfig b/arch/avr32/configs/atngw100_evklcd100_defconfig
index d8f1fe80d210..c76a49b9e9d0 100644
--- a/arch/avr32/configs/atngw100_evklcd100_defconfig
+++ b/arch/avr32/configs/atngw100_evklcd100_defconfig
@@ -125,7 +125,7 @@ CONFIG_USB_GADGET_VBUS_DRAW=350
125CONFIG_USB_ZERO=m 125CONFIG_USB_ZERO=m
126CONFIG_USB_ETH=m 126CONFIG_USB_ETH=m
127CONFIG_USB_GADGETFS=m 127CONFIG_USB_GADGETFS=m
128CONFIG_USB_FILE_STORAGE=m 128CONFIG_USB_MASS_STORAGE=m
129CONFIG_USB_G_SERIAL=m 129CONFIG_USB_G_SERIAL=m
130CONFIG_USB_CDC_COMPOSITE=m 130CONFIG_USB_CDC_COMPOSITE=m
131CONFIG_MMC=y 131CONFIG_MMC=y
diff --git a/arch/avr32/configs/atngw100_evklcd101_defconfig b/arch/avr32/configs/atngw100_evklcd101_defconfig
index d4c5b19ec950..2d8ab089a64e 100644
--- a/arch/avr32/configs/atngw100_evklcd101_defconfig
+++ b/arch/avr32/configs/atngw100_evklcd101_defconfig
@@ -124,7 +124,7 @@ CONFIG_USB_GADGET_VBUS_DRAW=350
124CONFIG_USB_ZERO=m 124CONFIG_USB_ZERO=m
125CONFIG_USB_ETH=m 125CONFIG_USB_ETH=m
126CONFIG_USB_GADGETFS=m 126CONFIG_USB_GADGETFS=m
127CONFIG_USB_FILE_STORAGE=m 127CONFIG_USB_MASS_STORAGE=m
128CONFIG_USB_G_SERIAL=m 128CONFIG_USB_G_SERIAL=m
129CONFIG_USB_CDC_COMPOSITE=m 129CONFIG_USB_CDC_COMPOSITE=m
130CONFIG_MMC=y 130CONFIG_MMC=y
diff --git a/arch/avr32/configs/atngw100_mrmt_defconfig b/arch/avr32/configs/atngw100_mrmt_defconfig
index 77ca4f905d2c..b189e0cab04b 100644
--- a/arch/avr32/configs/atngw100_mrmt_defconfig
+++ b/arch/avr32/configs/atngw100_mrmt_defconfig
@@ -99,7 +99,7 @@ CONFIG_SND_ATMEL_AC97C=m
99# CONFIG_SND_SPI is not set 99# CONFIG_SND_SPI is not set
100CONFIG_USB_GADGET=m 100CONFIG_USB_GADGET=m
101CONFIG_USB_GADGET_DEBUG_FILES=y 101CONFIG_USB_GADGET_DEBUG_FILES=y
102CONFIG_USB_FILE_STORAGE=m 102CONFIG_USB_MASS_STORAGE=m
103CONFIG_USB_G_SERIAL=m 103CONFIG_USB_G_SERIAL=m
104CONFIG_MMC=y 104CONFIG_MMC=y
105CONFIG_MMC_ATMELMCI=y 105CONFIG_MMC_ATMELMCI=y
diff --git a/arch/avr32/configs/atngw100mkii_defconfig b/arch/avr32/configs/atngw100mkii_defconfig
index 6e0dca4d3131..2e4de42a53c4 100644
--- a/arch/avr32/configs/atngw100mkii_defconfig
+++ b/arch/avr32/configs/atngw100mkii_defconfig
@@ -111,7 +111,7 @@ CONFIG_USB_GADGET_VBUS_DRAW=350
111CONFIG_USB_ZERO=m 111CONFIG_USB_ZERO=m
112CONFIG_USB_ETH=m 112CONFIG_USB_ETH=m
113CONFIG_USB_GADGETFS=m 113CONFIG_USB_GADGETFS=m
114CONFIG_USB_FILE_STORAGE=m 114CONFIG_USB_MASS_STORAGE=m
115CONFIG_USB_G_SERIAL=m 115CONFIG_USB_G_SERIAL=m
116CONFIG_USB_CDC_COMPOSITE=m 116CONFIG_USB_CDC_COMPOSITE=m
117CONFIG_MMC=y 117CONFIG_MMC=y
diff --git a/arch/avr32/configs/atngw100mkii_evklcd100_defconfig b/arch/avr32/configs/atngw100mkii_evklcd100_defconfig
index 7f2a344a5fa8..fad3cd22dfd3 100644
--- a/arch/avr32/configs/atngw100mkii_evklcd100_defconfig
+++ b/arch/avr32/configs/atngw100mkii_evklcd100_defconfig
@@ -128,7 +128,7 @@ CONFIG_USB_GADGET_VBUS_DRAW=350
128CONFIG_USB_ZERO=m 128CONFIG_USB_ZERO=m
129CONFIG_USB_ETH=m 129CONFIG_USB_ETH=m
130CONFIG_USB_GADGETFS=m 130CONFIG_USB_GADGETFS=m
131CONFIG_USB_FILE_STORAGE=m 131CONFIG_USB_MASS_STORAGE=m
132CONFIG_USB_G_SERIAL=m 132CONFIG_USB_G_SERIAL=m
133CONFIG_USB_CDC_COMPOSITE=m 133CONFIG_USB_CDC_COMPOSITE=m
134CONFIG_MMC=y 134CONFIG_MMC=y
diff --git a/arch/avr32/configs/atngw100mkii_evklcd101_defconfig b/arch/avr32/configs/atngw100mkii_evklcd101_defconfig
index 085eeba88f67..29986230aaa5 100644
--- a/arch/avr32/configs/atngw100mkii_evklcd101_defconfig
+++ b/arch/avr32/configs/atngw100mkii_evklcd101_defconfig
@@ -127,7 +127,7 @@ CONFIG_USB_GADGET_VBUS_DRAW=350
127CONFIG_USB_ZERO=m 127CONFIG_USB_ZERO=m
128CONFIG_USB_ETH=m 128CONFIG_USB_ETH=m
129CONFIG_USB_GADGETFS=m 129CONFIG_USB_GADGETFS=m
130CONFIG_USB_FILE_STORAGE=m 130CONFIG_USB_MASS_STORAGE=m
131CONFIG_USB_G_SERIAL=m 131CONFIG_USB_G_SERIAL=m
132CONFIG_USB_CDC_COMPOSITE=m 132CONFIG_USB_CDC_COMPOSITE=m
133CONFIG_MMC=y 133CONFIG_MMC=y
diff --git a/arch/avr32/configs/atstk1002_defconfig b/arch/avr32/configs/atstk1002_defconfig
index d1a887e64055..a582465e1cef 100644
--- a/arch/avr32/configs/atstk1002_defconfig
+++ b/arch/avr32/configs/atstk1002_defconfig
@@ -126,7 +126,7 @@ CONFIG_USB_GADGET=y
126CONFIG_USB_ZERO=m 126CONFIG_USB_ZERO=m
127CONFIG_USB_ETH=m 127CONFIG_USB_ETH=m
128CONFIG_USB_GADGETFS=m 128CONFIG_USB_GADGETFS=m
129CONFIG_USB_FILE_STORAGE=m 129CONFIG_USB_MASS_STORAGE=m
130CONFIG_USB_G_SERIAL=m 130CONFIG_USB_G_SERIAL=m
131CONFIG_USB_CDC_COMPOSITE=m 131CONFIG_USB_CDC_COMPOSITE=m
132CONFIG_MMC=y 132CONFIG_MMC=y
diff --git a/arch/avr32/configs/atstk1003_defconfig b/arch/avr32/configs/atstk1003_defconfig
index 956f2819ad45..57a79df2ce5d 100644
--- a/arch/avr32/configs/atstk1003_defconfig
+++ b/arch/avr32/configs/atstk1003_defconfig
@@ -105,7 +105,7 @@ CONFIG_USB_GADGET=y
105CONFIG_USB_ZERO=m 105CONFIG_USB_ZERO=m
106CONFIG_USB_ETH=m 106CONFIG_USB_ETH=m
107CONFIG_USB_GADGETFS=m 107CONFIG_USB_GADGETFS=m
108CONFIG_USB_FILE_STORAGE=m 108CONFIG_USB_MASS_STORAGE=m
109CONFIG_USB_G_SERIAL=m 109CONFIG_USB_G_SERIAL=m
110CONFIG_USB_CDC_COMPOSITE=m 110CONFIG_USB_CDC_COMPOSITE=m
111CONFIG_MMC=y 111CONFIG_MMC=y
diff --git a/arch/avr32/configs/atstk1004_defconfig b/arch/avr32/configs/atstk1004_defconfig
index 40c69f38c61a..1a49bd8c6340 100644
--- a/arch/avr32/configs/atstk1004_defconfig
+++ b/arch/avr32/configs/atstk1004_defconfig
@@ -104,7 +104,7 @@ CONFIG_USB_GADGET=y
104CONFIG_USB_ZERO=m 104CONFIG_USB_ZERO=m
105CONFIG_USB_ETH=m 105CONFIG_USB_ETH=m
106CONFIG_USB_GADGETFS=m 106CONFIG_USB_GADGETFS=m
107CONFIG_USB_FILE_STORAGE=m 107CONFIG_USB_MASS_STORAGE=m
108CONFIG_USB_G_SERIAL=m 108CONFIG_USB_G_SERIAL=m
109CONFIG_USB_CDC_COMPOSITE=m 109CONFIG_USB_CDC_COMPOSITE=m
110CONFIG_MMC=y 110CONFIG_MMC=y
diff --git a/arch/avr32/configs/atstk1006_defconfig b/arch/avr32/configs/atstk1006_defconfig
index 511eb8af356d..206a1b67f763 100644
--- a/arch/avr32/configs/atstk1006_defconfig
+++ b/arch/avr32/configs/atstk1006_defconfig
@@ -129,7 +129,7 @@ CONFIG_USB_GADGET=y
129CONFIG_USB_ZERO=m 129CONFIG_USB_ZERO=m
130CONFIG_USB_ETH=m 130CONFIG_USB_ETH=m
131CONFIG_USB_GADGETFS=m 131CONFIG_USB_GADGETFS=m
132CONFIG_USB_FILE_STORAGE=m 132CONFIG_USB_MASS_STORAGE=m
133CONFIG_USB_G_SERIAL=m 133CONFIG_USB_G_SERIAL=m
134CONFIG_USB_CDC_COMPOSITE=m 134CONFIG_USB_CDC_COMPOSITE=m
135CONFIG_MMC=y 135CONFIG_MMC=y
diff --git a/arch/avr32/configs/favr-32_defconfig b/arch/avr32/configs/favr-32_defconfig
index 19973b06170c..0421498d666b 100644
--- a/arch/avr32/configs/favr-32_defconfig
+++ b/arch/avr32/configs/favr-32_defconfig
@@ -117,7 +117,7 @@ CONFIG_USB_GADGET=y
117CONFIG_USB_ZERO=m 117CONFIG_USB_ZERO=m
118CONFIG_USB_ETH=m 118CONFIG_USB_ETH=m
119CONFIG_USB_GADGETFS=m 119CONFIG_USB_GADGETFS=m
120CONFIG_USB_FILE_STORAGE=m 120CONFIG_USB_MASS_STORAGE=m
121CONFIG_USB_G_SERIAL=m 121CONFIG_USB_G_SERIAL=m
122CONFIG_USB_CDC_COMPOSITE=m 122CONFIG_USB_CDC_COMPOSITE=m
123CONFIG_MMC=y 123CONFIG_MMC=y
diff --git a/arch/avr32/configs/hammerhead_defconfig b/arch/avr32/configs/hammerhead_defconfig
index 6f45681196d1..82f24eb251bd 100644
--- a/arch/avr32/configs/hammerhead_defconfig
+++ b/arch/avr32/configs/hammerhead_defconfig
@@ -127,7 +127,7 @@ CONFIG_USB_GADGET=y
127CONFIG_USB_ZERO=m 127CONFIG_USB_ZERO=m
128CONFIG_USB_ETH=m 128CONFIG_USB_ETH=m
129CONFIG_USB_GADGETFS=m 129CONFIG_USB_GADGETFS=m
130CONFIG_USB_FILE_STORAGE=m 130CONFIG_USB_MASS_STORAGE=m
131CONFIG_USB_G_SERIAL=m 131CONFIG_USB_G_SERIAL=m
132CONFIG_MMC=m 132CONFIG_MMC=m
133CONFIG_MMC_ATMELMCI=m 133CONFIG_MMC_ATMELMCI=m
diff --git a/arch/blackfin/configs/CM-BF527_defconfig b/arch/blackfin/configs/CM-BF527_defconfig
index c280a50e7943..f59c80ee78e3 100644
--- a/arch/blackfin/configs/CM-BF527_defconfig
+++ b/arch/blackfin/configs/CM-BF527_defconfig
@@ -106,7 +106,7 @@ CONFIG_MUSB_PIO_ONLY=y
106CONFIG_USB_STORAGE=m 106CONFIG_USB_STORAGE=m
107CONFIG_USB_GADGET=m 107CONFIG_USB_GADGET=m
108CONFIG_USB_ETH=m 108CONFIG_USB_ETH=m
109CONFIG_USB_FILE_STORAGE=m 109CONFIG_USB_MASS_STORAGE=m
110CONFIG_USB_G_SERIAL=m 110CONFIG_USB_G_SERIAL=m
111CONFIG_USB_G_PRINTER=m 111CONFIG_USB_G_PRINTER=m
112CONFIG_RTC_CLASS=y 112CONFIG_RTC_CLASS=y
diff --git a/arch/blackfin/configs/CM-BF548_defconfig b/arch/blackfin/configs/CM-BF548_defconfig
index 349922be01f3..e961483f1879 100644
--- a/arch/blackfin/configs/CM-BF548_defconfig
+++ b/arch/blackfin/configs/CM-BF548_defconfig
@@ -107,7 +107,7 @@ CONFIG_USB_ZERO=m
107CONFIG_USB_ETH=m 107CONFIG_USB_ETH=m
108# CONFIG_USB_ETH_RNDIS is not set 108# CONFIG_USB_ETH_RNDIS is not set
109CONFIG_USB_GADGETFS=m 109CONFIG_USB_GADGETFS=m
110CONFIG_USB_FILE_STORAGE=m 110CONFIG_USB_MASS_STORAGE=m
111CONFIG_USB_G_SERIAL=m 111CONFIG_USB_G_SERIAL=m
112CONFIG_USB_G_PRINTER=m 112CONFIG_USB_G_PRINTER=m
113CONFIG_MMC=m 113CONFIG_MMC=m
diff --git a/arch/blackfin/configs/CM-BF561_defconfig b/arch/blackfin/configs/CM-BF561_defconfig
index 0456deaa2d6f..24936b91a6ee 100644
--- a/arch/blackfin/configs/CM-BF561_defconfig
+++ b/arch/blackfin/configs/CM-BF561_defconfig
@@ -83,7 +83,7 @@ CONFIG_GPIOLIB=y
83CONFIG_GPIO_SYSFS=y 83CONFIG_GPIO_SYSFS=y
84CONFIG_USB_GADGET=m 84CONFIG_USB_GADGET=m
85CONFIG_USB_ETH=m 85CONFIG_USB_ETH=m
86CONFIG_USB_FILE_STORAGE=m 86CONFIG_USB_MASS_STORAGE=m
87CONFIG_USB_G_SERIAL=m 87CONFIG_USB_G_SERIAL=m
88CONFIG_USB_G_PRINTER=m 88CONFIG_USB_G_PRINTER=m
89CONFIG_MMC=y 89CONFIG_MMC=y
diff --git a/arch/mips/alchemy/common/Makefile b/arch/mips/alchemy/common/Makefile
index 407ebc00e661..cb83d8d21aef 100644
--- a/arch/mips/alchemy/common/Makefile
+++ b/arch/mips/alchemy/common/Makefile
@@ -6,7 +6,7 @@
6# 6#
7 7
8obj-y += prom.o time.o clocks.o platform.o power.o setup.o \ 8obj-y += prom.o time.o clocks.o platform.o power.o setup.o \
9 sleeper.o dma.o dbdma.o vss.o irq.o 9 sleeper.o dma.o dbdma.o vss.o irq.o usb.o
10 10
11# optional gpiolib support 11# optional gpiolib support
12ifeq ($(CONFIG_ALCHEMY_GPIO_INDIRECT),) 12ifeq ($(CONFIG_ALCHEMY_GPIO_INDIRECT),)
diff --git a/arch/mips/alchemy/common/platform.c b/arch/mips/alchemy/common/platform.c
index c0f3ce6dcb56..7af941d8e717 100644
--- a/arch/mips/alchemy/common/platform.c
+++ b/arch/mips/alchemy/common/platform.c
@@ -17,6 +17,8 @@
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/serial_8250.h> 18#include <linux/serial_8250.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/usb/ehci_pdriver.h>
21#include <linux/usb/ohci_pdriver.h>
20 22
21#include <asm/mach-au1x00/au1000.h> 23#include <asm/mach-au1x00/au1000.h>
22#include <asm/mach-au1x00/au1xxx_dbdma.h> 24#include <asm/mach-au1x00/au1xxx_dbdma.h>
@@ -122,6 +124,53 @@ static void __init alchemy_setup_uarts(int ctype)
122static u64 alchemy_ohci_dmamask = DMA_BIT_MASK(32); 124static u64 alchemy_ohci_dmamask = DMA_BIT_MASK(32);
123static u64 __maybe_unused alchemy_ehci_dmamask = DMA_BIT_MASK(32); 125static u64 __maybe_unused alchemy_ehci_dmamask = DMA_BIT_MASK(32);
124 126
127/* Power on callback for the ehci platform driver */
128static int alchemy_ehci_power_on(struct platform_device *pdev)
129{
130 return alchemy_usb_control(ALCHEMY_USB_EHCI0, 1);
131}
132
133/* Power off/suspend callback for the ehci platform driver */
134static void alchemy_ehci_power_off(struct platform_device *pdev)
135{
136 alchemy_usb_control(ALCHEMY_USB_EHCI0, 0);
137}
138
139static struct usb_ehci_pdata alchemy_ehci_pdata = {
140 .no_io_watchdog = 1,
141 .power_on = alchemy_ehci_power_on,
142 .power_off = alchemy_ehci_power_off,
143 .power_suspend = alchemy_ehci_power_off,
144};
145
146/* Power on callback for the ohci platform driver */
147static int alchemy_ohci_power_on(struct platform_device *pdev)
148{
149 int unit;
150
151 unit = (pdev->id == 1) ?
152 ALCHEMY_USB_OHCI1 : ALCHEMY_USB_OHCI0;
153
154 return alchemy_usb_control(unit, 1);
155}
156
157/* Power off/suspend callback for the ohci platform driver */
158static void alchemy_ohci_power_off(struct platform_device *pdev)
159{
160 int unit;
161
162 unit = (pdev->id == 1) ?
163 ALCHEMY_USB_OHCI1 : ALCHEMY_USB_OHCI0;
164
165 alchemy_usb_control(unit, 0);
166}
167
168static struct usb_ohci_pdata alchemy_ohci_pdata = {
169 .power_on = alchemy_ohci_power_on,
170 .power_off = alchemy_ohci_power_off,
171 .power_suspend = alchemy_ohci_power_off,
172};
173
125static unsigned long alchemy_ohci_data[][2] __initdata = { 174static unsigned long alchemy_ohci_data[][2] __initdata = {
126 [ALCHEMY_CPU_AU1000] = { AU1000_USB_OHCI_PHYS_ADDR, AU1000_USB_HOST_INT }, 175 [ALCHEMY_CPU_AU1000] = { AU1000_USB_OHCI_PHYS_ADDR, AU1000_USB_HOST_INT },
127 [ALCHEMY_CPU_AU1500] = { AU1000_USB_OHCI_PHYS_ADDR, AU1500_USB_HOST_INT }, 176 [ALCHEMY_CPU_AU1500] = { AU1000_USB_OHCI_PHYS_ADDR, AU1500_USB_HOST_INT },
@@ -169,9 +218,10 @@ static void __init alchemy_setup_usb(int ctype)
169 res[1].start = alchemy_ohci_data[ctype][1]; 218 res[1].start = alchemy_ohci_data[ctype][1];
170 res[1].end = res[1].start; 219 res[1].end = res[1].start;
171 res[1].flags = IORESOURCE_IRQ; 220 res[1].flags = IORESOURCE_IRQ;
172 pdev->name = "au1xxx-ohci"; 221 pdev->name = "ohci-platform";
173 pdev->id = 0; 222 pdev->id = 0;
174 pdev->dev.dma_mask = &alchemy_ohci_dmamask; 223 pdev->dev.dma_mask = &alchemy_ohci_dmamask;
224 pdev->dev.platform_data = &alchemy_ohci_pdata;
175 225
176 if (platform_device_register(pdev)) 226 if (platform_device_register(pdev))
177 printk(KERN_INFO "Alchemy USB: cannot add OHCI0\n"); 227 printk(KERN_INFO "Alchemy USB: cannot add OHCI0\n");
@@ -188,9 +238,10 @@ static void __init alchemy_setup_usb(int ctype)
188 res[1].start = alchemy_ehci_data[ctype][1]; 238 res[1].start = alchemy_ehci_data[ctype][1];
189 res[1].end = res[1].start; 239 res[1].end = res[1].start;
190 res[1].flags = IORESOURCE_IRQ; 240 res[1].flags = IORESOURCE_IRQ;
191 pdev->name = "au1xxx-ehci"; 241 pdev->name = "ehci-platform";
192 pdev->id = 0; 242 pdev->id = 0;
193 pdev->dev.dma_mask = &alchemy_ehci_dmamask; 243 pdev->dev.dma_mask = &alchemy_ehci_dmamask;
244 pdev->dev.platform_data = &alchemy_ehci_pdata;
194 245
195 if (platform_device_register(pdev)) 246 if (platform_device_register(pdev))
196 printk(KERN_INFO "Alchemy USB: cannot add EHCI0\n"); 247 printk(KERN_INFO "Alchemy USB: cannot add EHCI0\n");
@@ -207,9 +258,10 @@ static void __init alchemy_setup_usb(int ctype)
207 res[1].start = AU1300_USB_INT; 258 res[1].start = AU1300_USB_INT;
208 res[1].end = res[1].start; 259 res[1].end = res[1].start;
209 res[1].flags = IORESOURCE_IRQ; 260 res[1].flags = IORESOURCE_IRQ;
210 pdev->name = "au1xxx-ohci"; 261 pdev->name = "ohci-platform";
211 pdev->id = 1; 262 pdev->id = 1;
212 pdev->dev.dma_mask = &alchemy_ohci_dmamask; 263 pdev->dev.dma_mask = &alchemy_ohci_dmamask;
264 pdev->dev.platform_data = &alchemy_ohci_pdata;
213 265
214 if (platform_device_register(pdev)) 266 if (platform_device_register(pdev))
215 printk(KERN_INFO "Alchemy USB: cannot add OHCI1\n"); 267 printk(KERN_INFO "Alchemy USB: cannot add OHCI1\n");
diff --git a/drivers/usb/host/alchemy-common.c b/arch/mips/alchemy/common/usb.c
index 936af8359fb2..936af8359fb2 100644
--- a/drivers/usb/host/alchemy-common.c
+++ b/arch/mips/alchemy/common/usb.c
diff --git a/arch/mips/ath79/dev-usb.c b/arch/mips/ath79/dev-usb.c
index 072bb9be2304..bd2bc108e1b5 100644
--- a/arch/mips/ath79/dev-usb.c
+++ b/arch/mips/ath79/dev-usb.c
@@ -50,13 +50,11 @@ static u64 ath79_ehci_dmamask = DMA_BIT_MASK(32);
50 50
51static struct usb_ehci_pdata ath79_ehci_pdata_v1 = { 51static struct usb_ehci_pdata ath79_ehci_pdata_v1 = {
52 .has_synopsys_hc_bug = 1, 52 .has_synopsys_hc_bug = 1,
53 .port_power_off = 1,
54}; 53};
55 54
56static struct usb_ehci_pdata ath79_ehci_pdata_v2 = { 55static struct usb_ehci_pdata ath79_ehci_pdata_v2 = {
57 .caps_offset = 0x100, 56 .caps_offset = 0x100,
58 .has_tt = 1, 57 .has_tt = 1,
59 .port_power_off = 1,
60}; 58};
61 59
62static struct platform_device ath79_ehci_device = { 60static struct platform_device ath79_ehci_device = {
diff --git a/arch/mips/configs/bcm47xx_defconfig b/arch/mips/configs/bcm47xx_defconfig
index b6fde2bb51b6..4ca8e5c99225 100644
--- a/arch/mips/configs/bcm47xx_defconfig
+++ b/arch/mips/configs/bcm47xx_defconfig
@@ -473,7 +473,7 @@ CONFIG_USB_GADGET_NET2280=y
473CONFIG_USB_ZERO=m 473CONFIG_USB_ZERO=m
474CONFIG_USB_ETH=m 474CONFIG_USB_ETH=m
475CONFIG_USB_GADGETFS=m 475CONFIG_USB_GADGETFS=m
476CONFIG_USB_FILE_STORAGE=m 476CONFIG_USB_MASS_STORAGE=m
477CONFIG_USB_G_SERIAL=m 477CONFIG_USB_G_SERIAL=m
478CONFIG_USB_MIDI_GADGET=m 478CONFIG_USB_MIDI_GADGET=m
479CONFIG_LEDS_CLASS=y 479CONFIG_LEDS_CLASS=y
diff --git a/arch/mips/configs/db1000_defconfig b/arch/mips/configs/db1000_defconfig
index 17a36c125172..face9d26e6d5 100644
--- a/arch/mips/configs/db1000_defconfig
+++ b/arch/mips/configs/db1000_defconfig
@@ -233,6 +233,7 @@ CONFIG_USB_EHCI_HCD=y
233CONFIG_USB_EHCI_ROOT_HUB_TT=y 233CONFIG_USB_EHCI_ROOT_HUB_TT=y
234CONFIG_USB_EHCI_TT_NEWSCHED=y 234CONFIG_USB_EHCI_TT_NEWSCHED=y
235CONFIG_USB_OHCI_HCD=y 235CONFIG_USB_OHCI_HCD=y
236CONFIG_USB_OHCI_HCD_PLATFORM=y
236CONFIG_USB_UHCI_HCD=y 237CONFIG_USB_UHCI_HCD=y
237CONFIG_USB_STORAGE=y 238CONFIG_USB_STORAGE=y
238CONFIG_NEW_LEDS=y 239CONFIG_NEW_LEDS=y
diff --git a/arch/mips/configs/db1235_defconfig b/arch/mips/configs/db1235_defconfig
index c48998ffd198..14752dde7540 100644
--- a/arch/mips/configs/db1235_defconfig
+++ b/arch/mips/configs/db1235_defconfig
@@ -346,8 +346,10 @@ CONFIG_USB=y
346CONFIG_USB_DYNAMIC_MINORS=y 346CONFIG_USB_DYNAMIC_MINORS=y
347CONFIG_USB_SUSPEND=y 347CONFIG_USB_SUSPEND=y
348CONFIG_USB_EHCI_HCD=y 348CONFIG_USB_EHCI_HCD=y
349CONFIG_USB_EHCI_HCD_PLATFORM=y
349CONFIG_USB_EHCI_ROOT_HUB_TT=y 350CONFIG_USB_EHCI_ROOT_HUB_TT=y
350CONFIG_USB_OHCI_HCD=y 351CONFIG_USB_OHCI_HCD=y
352CONFIG_USB_OHCI_HCD_PLATFORM=y
351CONFIG_USB_STORAGE=y 353CONFIG_USB_STORAGE=y
352CONFIG_MMC=y 354CONFIG_MMC=y
353CONFIG_MMC_CLKGATE=y 355CONFIG_MMC_CLKGATE=y
diff --git a/arch/mips/configs/gpr_defconfig b/arch/mips/configs/gpr_defconfig
index 48a40aefaf58..fb64589015fc 100644
--- a/arch/mips/configs/gpr_defconfig
+++ b/arch/mips/configs/gpr_defconfig
@@ -291,6 +291,7 @@ CONFIG_USB_MON=y
291CONFIG_USB_EHCI_HCD=y 291CONFIG_USB_EHCI_HCD=y
292CONFIG_USB_EHCI_ROOT_HUB_TT=y 292CONFIG_USB_EHCI_ROOT_HUB_TT=y
293CONFIG_USB_OHCI_HCD=y 293CONFIG_USB_OHCI_HCD=y
294CONFIG_USB_OHCI_HCD_PLATFORM=y
294CONFIG_USB_STORAGE=m 295CONFIG_USB_STORAGE=m
295CONFIG_USB_LIBUSUAL=y 296CONFIG_USB_LIBUSUAL=y
296CONFIG_USB_SERIAL=y 297CONFIG_USB_SERIAL=y
diff --git a/arch/mips/configs/ls1b_defconfig b/arch/mips/configs/ls1b_defconfig
index 80cff8bea8e8..7eb75543ca1a 100644
--- a/arch/mips/configs/ls1b_defconfig
+++ b/arch/mips/configs/ls1b_defconfig
@@ -76,6 +76,7 @@ CONFIG_HID_GENERIC=m
76CONFIG_USB=y 76CONFIG_USB=y
77CONFIG_USB_ANNOUNCE_NEW_DEVICES=y 77CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
78CONFIG_USB_EHCI_HCD=y 78CONFIG_USB_EHCI_HCD=y
79CONFIG_USB_EHCI_HCD_PLATFORM=y
79# CONFIG_USB_EHCI_TT_NEWSCHED is not set 80# CONFIG_USB_EHCI_TT_NEWSCHED is not set
80CONFIG_USB_STORAGE=m 81CONFIG_USB_STORAGE=m
81CONFIG_USB_SERIAL=m 82CONFIG_USB_SERIAL=m
diff --git a/arch/mips/configs/mtx1_defconfig b/arch/mips/configs/mtx1_defconfig
index 46c61edcdf7b..9fa8f16068d8 100644
--- a/arch/mips/configs/mtx1_defconfig
+++ b/arch/mips/configs/mtx1_defconfig
@@ -581,6 +581,7 @@ CONFIG_USB_MON=m
581CONFIG_USB_EHCI_HCD=m 581CONFIG_USB_EHCI_HCD=m
582CONFIG_USB_EHCI_ROOT_HUB_TT=y 582CONFIG_USB_EHCI_ROOT_HUB_TT=y
583CONFIG_USB_OHCI_HCD=m 583CONFIG_USB_OHCI_HCD=m
584CONFIG_USB_OHCI_HCD_PLATFORM=y
584CONFIG_USB_UHCI_HCD=m 585CONFIG_USB_UHCI_HCD=m
585CONFIG_USB_U132_HCD=m 586CONFIG_USB_U132_HCD=m
586CONFIG_USB_SL811_HCD=m 587CONFIG_USB_SL811_HCD=m
@@ -661,7 +662,7 @@ CONFIG_USB_GADGET_NET2280=y
661CONFIG_USB_ZERO=m 662CONFIG_USB_ZERO=m
662CONFIG_USB_ETH=m 663CONFIG_USB_ETH=m
663CONFIG_USB_GADGETFS=m 664CONFIG_USB_GADGETFS=m
664CONFIG_USB_FILE_STORAGE=m 665CONFIG_USB_MASS_STORAGE=m
665CONFIG_USB_G_SERIAL=m 666CONFIG_USB_G_SERIAL=m
666CONFIG_USB_MIDI_GADGET=m 667CONFIG_USB_MIDI_GADGET=m
667CONFIG_MMC=m 668CONFIG_MMC=m
diff --git a/arch/mips/loongson1/common/platform.c b/arch/mips/loongson1/common/platform.c
index e92d59c4bd78..0412ad61e290 100644
--- a/arch/mips/loongson1/common/platform.c
+++ b/arch/mips/loongson1/common/platform.c
@@ -13,6 +13,7 @@
13#include <linux/phy.h> 13#include <linux/phy.h>
14#include <linux/serial_8250.h> 14#include <linux/serial_8250.h>
15#include <linux/stmmac.h> 15#include <linux/stmmac.h>
16#include <linux/usb/ehci_pdriver.h>
16#include <asm-generic/sizes.h> 17#include <asm-generic/sizes.h>
17 18
18#include <loongson1.h> 19#include <loongson1.h>
@@ -107,13 +108,17 @@ static struct resource ls1x_ehci_resources[] = {
107 }, 108 },
108}; 109};
109 110
111static struct usb_ehci_pdata ls1x_ehci_pdata = {
112};
113
110struct platform_device ls1x_ehci_device = { 114struct platform_device ls1x_ehci_device = {
111 .name = "ls1x-ehci", 115 .name = "ehci-platform",
112 .id = -1, 116 .id = -1,
113 .num_resources = ARRAY_SIZE(ls1x_ehci_resources), 117 .num_resources = ARRAY_SIZE(ls1x_ehci_resources),
114 .resource = ls1x_ehci_resources, 118 .resource = ls1x_ehci_resources,
115 .dev = { 119 .dev = {
116 .dma_mask = &ls1x_ehci_dmamask, 120 .dma_mask = &ls1x_ehci_dmamask,
121 .platform_data = &ls1x_ehci_pdata,
117 }, 122 },
118}; 123};
119 124
diff --git a/arch/mips/netlogic/xlr/platform.c b/arch/mips/netlogic/xlr/platform.c
index 71b44d82621d..507230eeb768 100644
--- a/arch/mips/netlogic/xlr/platform.c
+++ b/arch/mips/netlogic/xlr/platform.c
@@ -15,6 +15,8 @@
15#include <linux/serial_8250.h> 15#include <linux/serial_8250.h>
16#include <linux/serial_reg.h> 16#include <linux/serial_reg.h>
17#include <linux/i2c.h> 17#include <linux/i2c.h>
18#include <linux/usb/ehci_pdriver.h>
19#include <linux/usb/ohci_pdriver.h>
18 20
19#include <asm/netlogic/haldefs.h> 21#include <asm/netlogic/haldefs.h>
20#include <asm/netlogic/xlr/iomap.h> 22#include <asm/netlogic/xlr/iomap.h>
@@ -123,12 +125,18 @@ static u64 xls_usb_dmamask = ~(u32)0;
123 }, \ 125 }, \
124 } 126 }
125 127
128static struct usb_ehci_pdata xls_usb_ehci_pdata = {
129 .caps_offset = 0,
130};
131
132static struct usb_ohci_pdata xls_usb_ohci_pdata;
133
126static struct platform_device xls_usb_ehci_device = 134static struct platform_device xls_usb_ehci_device =
127 USB_PLATFORM_DEV("ehci-xls", 0, PIC_USB_IRQ); 135 USB_PLATFORM_DEV("ehci-platform", 0, PIC_USB_IRQ);
128static struct platform_device xls_usb_ohci_device_0 = 136static struct platform_device xls_usb_ohci_device_0 =
129 USB_PLATFORM_DEV("ohci-xls-0", 1, PIC_USB_IRQ); 137 USB_PLATFORM_DEV("ohci-platform", 1, PIC_USB_IRQ);
130static struct platform_device xls_usb_ohci_device_1 = 138static struct platform_device xls_usb_ohci_device_1 =
131 USB_PLATFORM_DEV("ohci-xls-1", 2, PIC_USB_IRQ); 139 USB_PLATFORM_DEV("ohci-platform", 2, PIC_USB_IRQ);
132 140
133static struct platform_device *xls_platform_devices[] = { 141static struct platform_device *xls_platform_devices[] = {
134 &xls_usb_ehci_device, 142 &xls_usb_ehci_device,
@@ -172,14 +180,17 @@ int xls_platform_usb_init(void)
172 memres = CPHYSADDR((unsigned long)usb_mmio); 180 memres = CPHYSADDR((unsigned long)usb_mmio);
173 xls_usb_ehci_device.resource[0].start = memres; 181 xls_usb_ehci_device.resource[0].start = memres;
174 xls_usb_ehci_device.resource[0].end = memres + 0x400 - 1; 182 xls_usb_ehci_device.resource[0].end = memres + 0x400 - 1;
183 xls_usb_ehci_device.dev.platform_data = &xls_usb_ehci_pdata;
175 184
176 memres += 0x400; 185 memres += 0x400;
177 xls_usb_ohci_device_0.resource[0].start = memres; 186 xls_usb_ohci_device_0.resource[0].start = memres;
178 xls_usb_ohci_device_0.resource[0].end = memres + 0x400 - 1; 187 xls_usb_ohci_device_0.resource[0].end = memres + 0x400 - 1;
188 xls_usb_ohci_device_0.dev.platform_data = &xls_usb_ohci_pdata;
179 189
180 memres += 0x400; 190 memres += 0x400;
181 xls_usb_ohci_device_1.resource[0].start = memres; 191 xls_usb_ohci_device_1.resource[0].start = memres;
182 xls_usb_ohci_device_1.resource[0].end = memres + 0x400 - 1; 192 xls_usb_ohci_device_1.resource[0].end = memres + 0x400 - 1;
193 xls_usb_ohci_device_1.dev.platform_data = &xls_usb_ohci_pdata;
183 194
184 return platform_add_devices(xls_platform_devices, 195 return platform_add_devices(xls_platform_devices,
185 ARRAY_SIZE(xls_platform_devices)); 196 ARRAY_SIZE(xls_platform_devices));
diff --git a/arch/mips/pnx8550/common/platform.c b/arch/mips/pnx8550/common/platform.c
index 5264cc09a27b..0a8faeaa7b70 100644
--- a/arch/mips/pnx8550/common/platform.c
+++ b/arch/mips/pnx8550/common/platform.c
@@ -20,6 +20,7 @@
20#include <linux/serial.h> 20#include <linux/serial.h>
21#include <linux/serial_pnx8xxx.h> 21#include <linux/serial_pnx8xxx.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/usb/ohci_pdriver.h>
23 24
24#include <int.h> 25#include <int.h>
25#include <usb.h> 26#include <usb.h>
@@ -96,12 +97,40 @@ static u64 ohci_dmamask = DMA_BIT_MASK(32);
96 97
97static u64 uart_dmamask = DMA_BIT_MASK(32); 98static u64 uart_dmamask = DMA_BIT_MASK(32);
98 99
100static int pnx8550_usb_ohci_power_on(struct platform_device *pdev)
101{
102 /*
103 * Set register CLK48CTL to enable and 48MHz
104 */
105 outl(0x00000003, PCI_BASE | 0x0004770c);
106
107 /*
108 * Set register CLK12CTL to enable and 48MHz
109 */
110 outl(0x00000003, PCI_BASE | 0x00047710);
111
112 udelay(100);
113
114 return 0;
115}
116
117static void pnx8550_usb_ohci_power_off(struct platform_device *pdev)
118{
119 udelay(10);
120}
121
122static struct usb_ohci_pdata pnx8550_usb_ohci_pdata = {
123 .power_on = pnx8550_usb_ohci_power_on,
124 .power_off = pnx8550_usb_ohci_power_off,
125};
126
99static struct platform_device pnx8550_usb_ohci_device = { 127static struct platform_device pnx8550_usb_ohci_device = {
100 .name = "pnx8550-ohci", 128 .name = "ohci-platform",
101 .id = -1, 129 .id = -1,
102 .dev = { 130 .dev = {
103 .dma_mask = &ohci_dmamask, 131 .dma_mask = &ohci_dmamask,
104 .coherent_dma_mask = DMA_BIT_MASK(32), 132 .coherent_dma_mask = DMA_BIT_MASK(32),
133 .platform_data = &pnx8550_usb_ohci_pdata,
105 }, 134 },
106 .num_resources = ARRAY_SIZE(pnx8550_usb_ohci_resources), 135 .num_resources = ARRAY_SIZE(pnx8550_usb_ohci_resources),
107 .resource = pnx8550_usb_ohci_resources, 136 .resource = pnx8550_usb_ohci_resources,
diff --git a/arch/sh/configs/ecovec24_defconfig b/arch/sh/configs/ecovec24_defconfig
index 911e30c9abfd..c6c2becdc8ab 100644
--- a/arch/sh/configs/ecovec24_defconfig
+++ b/arch/sh/configs/ecovec24_defconfig
@@ -112,7 +112,7 @@ CONFIG_USB_MON=y
112CONFIG_USB_R8A66597_HCD=y 112CONFIG_USB_R8A66597_HCD=y
113CONFIG_USB_STORAGE=y 113CONFIG_USB_STORAGE=y
114CONFIG_USB_GADGET=y 114CONFIG_USB_GADGET=y
115CONFIG_USB_FILE_STORAGE=m 115CONFIG_USB_MASS_STORAGE=m
116CONFIG_MMC=y 116CONFIG_MMC=y
117CONFIG_MMC_SPI=y 117CONFIG_MMC_SPI=y
118CONFIG_MMC_SDHI=y 118CONFIG_MMC_SDHI=y
diff --git a/arch/sh/configs/se7724_defconfig b/arch/sh/configs/se7724_defconfig
index ed35093e3758..1faa788aecae 100644
--- a/arch/sh/configs/se7724_defconfig
+++ b/arch/sh/configs/se7724_defconfig
@@ -109,7 +109,7 @@ CONFIG_USB_STORAGE=y
109CONFIG_USB_GADGET=y 109CONFIG_USB_GADGET=y
110CONFIG_USB_ETH=m 110CONFIG_USB_ETH=m
111CONFIG_USB_GADGETFS=m 111CONFIG_USB_GADGETFS=m
112CONFIG_USB_FILE_STORAGE=m 112CONFIG_USB_MASS_STORAGE=m
113CONFIG_USB_G_SERIAL=m 113CONFIG_USB_G_SERIAL=m
114CONFIG_MMC=y 114CONFIG_MMC=y
115CONFIG_MMC_SPI=y 115CONFIG_MMC_SPI=y
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7720.c b/arch/sh/kernel/cpu/sh3/setup-sh7720.c
index 0c2f1b2c2e19..42d991f632b1 100644
--- a/arch/sh/kernel/cpu/sh3/setup-sh7720.c
+++ b/arch/sh/kernel/cpu/sh3/setup-sh7720.c
@@ -20,6 +20,7 @@
20#include <linux/serial_sci.h> 20#include <linux/serial_sci.h>
21#include <linux/sh_timer.h> 21#include <linux/sh_timer.h>
22#include <linux/sh_intc.h> 22#include <linux/sh_intc.h>
23#include <linux/usb/ohci_pdriver.h>
23#include <asm/rtc.h> 24#include <asm/rtc.h>
24#include <cpu/serial.h> 25#include <cpu/serial.h>
25 26
@@ -103,12 +104,15 @@ static struct resource usb_ohci_resources[] = {
103 104
104static u64 usb_ohci_dma_mask = 0xffffffffUL; 105static u64 usb_ohci_dma_mask = 0xffffffffUL;
105 106
107static struct usb_ohci_pdata usb_ohci_pdata;
108
106static struct platform_device usb_ohci_device = { 109static struct platform_device usb_ohci_device = {
107 .name = "sh_ohci", 110 .name = "ohci-platform",
108 .id = -1, 111 .id = -1,
109 .dev = { 112 .dev = {
110 .dma_mask = &usb_ohci_dma_mask, 113 .dma_mask = &usb_ohci_dma_mask,
111 .coherent_dma_mask = 0xffffffff, 114 .coherent_dma_mask = 0xffffffff,
115 .platform_data = &usb_ohci_pdata,
112 }, 116 },
113 .num_resources = ARRAY_SIZE(usb_ohci_resources), 117 .num_resources = ARRAY_SIZE(usb_ohci_resources),
114 .resource = usb_ohci_resources, 118 .resource = usb_ohci_resources,
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7757.c b/arch/sh/kernel/cpu/sh4a/setup-sh7757.c
index 4a2f357f4df8..9079a0f9ea9b 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7757.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7757.c
@@ -19,6 +19,7 @@
19#include <linux/sh_timer.h> 19#include <linux/sh_timer.h>
20#include <linux/sh_dma.h> 20#include <linux/sh_dma.h>
21#include <linux/sh_intc.h> 21#include <linux/sh_intc.h>
22#include <linux/usb/ohci_pdriver.h>
22#include <cpu/dma-register.h> 23#include <cpu/dma-register.h>
23#include <cpu/sh7757.h> 24#include <cpu/sh7757.h>
24 25
@@ -750,12 +751,15 @@ static struct resource usb_ohci_resources[] = {
750 }, 751 },
751}; 752};
752 753
754static struct usb_ohci_pdata usb_ohci_pdata;
755
753static struct platform_device usb_ohci_device = { 756static struct platform_device usb_ohci_device = {
754 .name = "sh_ohci", 757 .name = "ohci-platform",
755 .id = -1, 758 .id = -1,
756 .dev = { 759 .dev = {
757 .dma_mask = &usb_ohci_device.dev.coherent_dma_mask, 760 .dma_mask = &usb_ohci_device.dev.coherent_dma_mask,
758 .coherent_dma_mask = DMA_BIT_MASK(32), 761 .coherent_dma_mask = DMA_BIT_MASK(32),
762 .platform_data = &usb_ohci_pdata,
759 }, 763 },
760 .num_resources = ARRAY_SIZE(usb_ohci_resources), 764 .num_resources = ARRAY_SIZE(usb_ohci_resources),
761 .resource = usb_ohci_resources, 765 .resource = usb_ohci_resources,
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7763.c b/arch/sh/kernel/cpu/sh4a/setup-sh7763.c
index bd0a8fbe610f..1686acaaf45a 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7763.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7763.c
@@ -16,6 +16,7 @@
16#include <linux/sh_intc.h> 16#include <linux/sh_intc.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/serial_sci.h> 18#include <linux/serial_sci.h>
19#include <linux/usb/ohci_pdriver.h>
19 20
20static struct plat_sci_port scif0_platform_data = { 21static struct plat_sci_port scif0_platform_data = {
21 .mapbase = 0xffe00000, 22 .mapbase = 0xffe00000,
@@ -106,12 +107,15 @@ static struct resource usb_ohci_resources[] = {
106 107
107static u64 usb_ohci_dma_mask = 0xffffffffUL; 108static u64 usb_ohci_dma_mask = 0xffffffffUL;
108 109
110static struct usb_ohci_pdata usb_ohci_pdata;
111
109static struct platform_device usb_ohci_device = { 112static struct platform_device usb_ohci_device = {
110 .name = "sh_ohci", 113 .name = "ohci-platform",
111 .id = -1, 114 .id = -1,
112 .dev = { 115 .dev = {
113 .dma_mask = &usb_ohci_dma_mask, 116 .dma_mask = &usb_ohci_dma_mask,
114 .coherent_dma_mask = 0xffffffff, 117 .coherent_dma_mask = 0xffffffff,
118 .platform_data = &usb_ohci_pdata,
115 }, 119 },
116 .num_resources = ARRAY_SIZE(usb_ohci_resources), 120 .num_resources = ARRAY_SIZE(usb_ohci_resources),
117 .resource = usb_ohci_resources, 121 .resource = usb_ohci_resources,
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7786.c b/arch/sh/kernel/cpu/sh4a/setup-sh7786.c
index 2e6952f87848..ab52d4d4484d 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7786.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7786.c
@@ -23,6 +23,7 @@
23#include <linux/sh_timer.h> 23#include <linux/sh_timer.h>
24#include <linux/sh_dma.h> 24#include <linux/sh_dma.h>
25#include <linux/sh_intc.h> 25#include <linux/sh_intc.h>
26#include <linux/usb/ohci_pdriver.h>
26#include <cpu/dma-register.h> 27#include <cpu/dma-register.h>
27#include <asm/mmzone.h> 28#include <asm/mmzone.h>
28 29
@@ -583,12 +584,15 @@ static struct resource usb_ohci_resources[] = {
583 }, 584 },
584}; 585};
585 586
587static struct usb_ohci_pdata usb_ohci_pdata;
588
586static struct platform_device usb_ohci_device = { 589static struct platform_device usb_ohci_device = {
587 .name = "sh_ohci", 590 .name = "ohci-platform",
588 .id = -1, 591 .id = -1,
589 .dev = { 592 .dev = {
590 .dma_mask = &usb_ohci_device.dev.coherent_dma_mask, 593 .dma_mask = &usb_ohci_device.dev.coherent_dma_mask,
591 .coherent_dma_mask = DMA_BIT_MASK(32), 594 .coherent_dma_mask = DMA_BIT_MASK(32),
595 .platform_data = &usb_ohci_pdata,
592 }, 596 },
593 .num_resources = ARRAY_SIZE(usb_ohci_resources), 597 .num_resources = ARRAY_SIZE(usb_ohci_resources),
594 .resource = usb_ohci_resources, 598 .resource = usb_ohci_resources,
diff --git a/drivers/usb/c67x00/c67x00-drv.c b/drivers/usb/c67x00/c67x00-drv.c
index 6f3b6e267398..fe815ecd557e 100644
--- a/drivers/usb/c67x00/c67x00-drv.c
+++ b/drivers/usb/c67x00/c67x00-drv.c
@@ -116,7 +116,7 @@ static irqreturn_t c67x00_irq(int irq, void *__dev)
116 116
117/* ------------------------------------------------------------------------- */ 117/* ------------------------------------------------------------------------- */
118 118
119static int __devinit c67x00_drv_probe(struct platform_device *pdev) 119static int c67x00_drv_probe(struct platform_device *pdev)
120{ 120{
121 struct c67x00_device *c67x00; 121 struct c67x00_device *c67x00;
122 struct c67x00_platform_data *pdata; 122 struct c67x00_platform_data *pdata;
@@ -191,7 +191,7 @@ static int __devinit c67x00_drv_probe(struct platform_device *pdev)
191 return ret; 191 return ret;
192} 192}
193 193
194static int __devexit c67x00_drv_remove(struct platform_device *pdev) 194static int c67x00_drv_remove(struct platform_device *pdev)
195{ 195{
196 struct c67x00_device *c67x00 = platform_get_drvdata(pdev); 196 struct c67x00_device *c67x00 = platform_get_drvdata(pdev);
197 struct resource *res; 197 struct resource *res;
@@ -219,7 +219,7 @@ static int __devexit c67x00_drv_remove(struct platform_device *pdev)
219 219
220static struct platform_driver c67x00_driver = { 220static struct platform_driver c67x00_driver = {
221 .probe = c67x00_drv_probe, 221 .probe = c67x00_drv_probe,
222 .remove = __devexit_p(c67x00_drv_remove), 222 .remove = c67x00_drv_remove,
223 .driver = { 223 .driver = {
224 .owner = THIS_MODULE, 224 .owner = THIS_MODULE,
225 .name = "c67x00", 225 .name = "c67x00",
diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig
index 1ea932a13685..608a2aeb400c 100644
--- a/drivers/usb/chipidea/Kconfig
+++ b/drivers/usb/chipidea/Kconfig
@@ -20,6 +20,7 @@ config USB_CHIPIDEA_UDC
20config USB_CHIPIDEA_HOST 20config USB_CHIPIDEA_HOST
21 bool "ChipIdea host controller" 21 bool "ChipIdea host controller"
22 depends on USB=y || USB=USB_CHIPIDEA 22 depends on USB=y || USB=USB_CHIPIDEA
23 depends on USB_EHCI_HCD
23 select USB_EHCI_ROOT_HUB_TT 24 select USB_EHCI_ROOT_HUB_TT
24 help 25 help
25 Say Y here to enable host controller functionality of the 26 Say Y here to enable host controller functionality of the
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c
index 0f5ca4bea17f..8c291220be7f 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -85,7 +85,7 @@ EXPORT_SYMBOL_GPL(usbmisc_get_init_data);
85 85
86/* End of common functions shared by usbmisc drivers*/ 86/* End of common functions shared by usbmisc drivers*/
87 87
88static struct ci13xxx_platform_data ci13xxx_imx_platdata __devinitdata = { 88static struct ci13xxx_platform_data ci13xxx_imx_platdata = {
89 .name = "ci13xxx_imx", 89 .name = "ci13xxx_imx",
90 .flags = CI13XXX_REQUIRE_TRANSCEIVER | 90 .flags = CI13XXX_REQUIRE_TRANSCEIVER |
91 CI13XXX_PULLUP_ON_VBUS | 91 CI13XXX_PULLUP_ON_VBUS |
@@ -93,7 +93,7 @@ static struct ci13xxx_platform_data ci13xxx_imx_platdata __devinitdata = {
93 .capoffset = DEF_CAPOFFSET, 93 .capoffset = DEF_CAPOFFSET,
94}; 94};
95 95
96static int __devinit ci13xxx_imx_probe(struct platform_device *pdev) 96static int ci13xxx_imx_probe(struct platform_device *pdev)
97{ 97{
98 struct ci13xxx_imx_data *data; 98 struct ci13xxx_imx_data *data;
99 struct platform_device *plat_ci, *phy_pdev; 99 struct platform_device *plat_ci, *phy_pdev;
@@ -220,7 +220,7 @@ put_np:
220 return ret; 220 return ret;
221} 221}
222 222
223static int __devexit ci13xxx_imx_remove(struct platform_device *pdev) 223static int ci13xxx_imx_remove(struct platform_device *pdev)
224{ 224{
225 struct ci13xxx_imx_data *data = platform_get_drvdata(pdev); 225 struct ci13xxx_imx_data *data = platform_get_drvdata(pdev);
226 226
@@ -252,7 +252,7 @@ MODULE_DEVICE_TABLE(of, ci13xxx_imx_dt_ids);
252 252
253static struct platform_driver ci13xxx_imx_driver = { 253static struct platform_driver ci13xxx_imx_driver = {
254 .probe = ci13xxx_imx_probe, 254 .probe = ci13xxx_imx_probe,
255 .remove = __devexit_p(ci13xxx_imx_remove), 255 .remove = ci13xxx_imx_remove,
256 .driver = { 256 .driver = {
257 .name = "imx_usb", 257 .name = "imx_usb",
258 .owner = THIS_MODULE, 258 .owner = THIS_MODULE,
diff --git a/drivers/usb/chipidea/ci13xxx_msm.c b/drivers/usb/chipidea/ci13xxx_msm.c
index b01feb3be92e..7d16681fd3d2 100644
--- a/drivers/usb/chipidea/ci13xxx_msm.c
+++ b/drivers/usb/chipidea/ci13xxx_msm.c
@@ -55,7 +55,7 @@ static struct ci13xxx_platform_data ci13xxx_msm_platdata = {
55 .notify_event = ci13xxx_msm_notify_event, 55 .notify_event = ci13xxx_msm_notify_event,
56}; 56};
57 57
58static int __devinit ci13xxx_msm_probe(struct platform_device *pdev) 58static int ci13xxx_msm_probe(struct platform_device *pdev)
59{ 59{
60 struct platform_device *plat_ci; 60 struct platform_device *plat_ci;
61 61
@@ -77,7 +77,7 @@ static int __devinit ci13xxx_msm_probe(struct platform_device *pdev)
77 return 0; 77 return 0;
78} 78}
79 79
80static int __devexit ci13xxx_msm_remove(struct platform_device *pdev) 80static int ci13xxx_msm_remove(struct platform_device *pdev)
81{ 81{
82 struct platform_device *plat_ci = platform_get_drvdata(pdev); 82 struct platform_device *plat_ci = platform_get_drvdata(pdev);
83 83
@@ -89,7 +89,7 @@ static int __devexit ci13xxx_msm_remove(struct platform_device *pdev)
89 89
90static struct platform_driver ci13xxx_msm_driver = { 90static struct platform_driver ci13xxx_msm_driver = {
91 .probe = ci13xxx_msm_probe, 91 .probe = ci13xxx_msm_probe,
92 .remove = __devexit_p(ci13xxx_msm_remove), 92 .remove = ci13xxx_msm_remove,
93 .driver = { .name = "msm_hsusb", }, 93 .driver = { .name = "msm_hsusb", },
94}; 94};
95 95
diff --git a/drivers/usb/chipidea/ci13xxx_pci.c b/drivers/usb/chipidea/ci13xxx_pci.c
index 918e14971f2b..9b227e39299a 100644
--- a/drivers/usb/chipidea/ci13xxx_pci.c
+++ b/drivers/usb/chipidea/ci13xxx_pci.c
@@ -48,7 +48,7 @@ struct ci13xxx_platform_data penwell_pci_platdata = {
48 * Allocates basic PCI resources for this USB device controller, and then 48 * Allocates basic PCI resources for this USB device controller, and then
49 * invokes the udc_probe() method to start the UDC associated with it 49 * invokes the udc_probe() method to start the UDC associated with it
50 */ 50 */
51static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev, 51static int ci13xxx_pci_probe(struct pci_dev *pdev,
52 const struct pci_device_id *id) 52 const struct pci_device_id *id)
53{ 53{
54 struct ci13xxx_platform_data *platdata = (void *)id->driver_data; 54 struct ci13xxx_platform_data *platdata = (void *)id->driver_data;
@@ -107,7 +107,7 @@ static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
107 * first invoking the udc_remove() and then releases 107 * first invoking the udc_remove() and then releases
108 * all PCI resources allocated for this USB device controller 108 * all PCI resources allocated for this USB device controller
109 */ 109 */
110static void __devexit ci13xxx_pci_remove(struct pci_dev *pdev) 110static void ci13xxx_pci_remove(struct pci_dev *pdev)
111{ 111{
112 struct platform_device *plat_ci = pci_get_drvdata(pdev); 112 struct platform_device *plat_ci = pci_get_drvdata(pdev);
113 113
@@ -147,7 +147,7 @@ static struct pci_driver ci13xxx_pci_driver = {
147 .name = UDC_DRIVER_NAME, 147 .name = UDC_DRIVER_NAME,
148 .id_table = ci13xxx_pci_id_table, 148 .id_table = ci13xxx_pci_id_table,
149 .probe = ci13xxx_pci_probe, 149 .probe = ci13xxx_pci_probe,
150 .remove = __devexit_p(ci13xxx_pci_remove), 150 .remove = ci13xxx_pci_remove,
151}; 151};
152 152
153module_pci_driver(ci13xxx_pci_driver); 153module_pci_driver(ci13xxx_pci_driver);
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index f69d029b4607..aebf695a9344 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -385,12 +385,13 @@ EXPORT_SYMBOL_GPL(ci13xxx_add_device);
385 385
386void ci13xxx_remove_device(struct platform_device *pdev) 386void ci13xxx_remove_device(struct platform_device *pdev)
387{ 387{
388 int id = pdev->id;
388 platform_device_unregister(pdev); 389 platform_device_unregister(pdev);
389 ida_simple_remove(&ci_ida, pdev->id); 390 ida_simple_remove(&ci_ida, id);
390} 391}
391EXPORT_SYMBOL_GPL(ci13xxx_remove_device); 392EXPORT_SYMBOL_GPL(ci13xxx_remove_device);
392 393
393static int __devinit ci_hdrc_probe(struct platform_device *pdev) 394static int ci_hdrc_probe(struct platform_device *pdev)
394{ 395{
395 struct device *dev = &pdev->dev; 396 struct device *dev = &pdev->dev;
396 struct ci13xxx *ci; 397 struct ci13xxx *ci;
@@ -508,7 +509,7 @@ rm_wq:
508 return ret; 509 return ret;
509} 510}
510 511
511static int __devexit ci_hdrc_remove(struct platform_device *pdev) 512static int ci_hdrc_remove(struct platform_device *pdev)
512{ 513{
513 struct ci13xxx *ci = platform_get_drvdata(pdev); 514 struct ci13xxx *ci = platform_get_drvdata(pdev);
514 515
@@ -523,7 +524,7 @@ static int __devexit ci_hdrc_remove(struct platform_device *pdev)
523 524
524static struct platform_driver ci_hdrc_driver = { 525static struct platform_driver ci_hdrc_driver = {
525 .probe = ci_hdrc_probe, 526 .probe = ci_hdrc_probe,
526 .remove = __devexit_p(ci_hdrc_remove), 527 .remove = ci_hdrc_remove,
527 .driver = { 528 .driver = {
528 .name = "ci_hdrc", 529 .name = "ci_hdrc",
529 }, 530 },
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index c6f50a257565..3bc244d2636a 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -160,9 +160,6 @@ static ssize_t show_device(struct device *dev, struct device_attribute *attr,
160 gadget->speed); 160 gadget->speed);
161 n += scnprintf(buf + n, PAGE_SIZE - n, "max_speed = %d\n", 161 n += scnprintf(buf + n, PAGE_SIZE - n, "max_speed = %d\n",
162 gadget->max_speed); 162 gadget->max_speed);
163 /* TODO: Scheduled for removal in 3.8. */
164 n += scnprintf(buf + n, PAGE_SIZE - n, "is_dualspeed = %d\n",
165 gadget_is_dualspeed(gadget));
166 n += scnprintf(buf + n, PAGE_SIZE - n, "is_otg = %d\n", 163 n += scnprintf(buf + n, PAGE_SIZE - n, "is_otg = %d\n",
167 gadget->is_otg); 164 gadget->is_otg);
168 n += scnprintf(buf + n, PAGE_SIZE - n, "is_a_peripheral = %d\n", 165 n += scnprintf(buf + n, PAGE_SIZE - n, "is_a_peripheral = %d\n",
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index ebff9f4f56ec..caecad9213f5 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -20,77 +20,18 @@
20 */ 20 */
21 21
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/io.h>
23#include <linux/usb.h> 24#include <linux/usb.h>
24#include <linux/usb/hcd.h> 25#include <linux/usb/hcd.h>
25#include <linux/usb/chipidea.h> 26#include <linux/usb/chipidea.h>
26 27
27#define CHIPIDEA_EHCI 28#include "../host/ehci.h"
28#include "../host/ehci-hcd.c"
29 29
30#include "ci.h" 30#include "ci.h"
31#include "bits.h" 31#include "bits.h"
32#include "host.h" 32#include "host.h"
33 33
34static int ci_ehci_setup(struct usb_hcd *hcd) 34static struct hc_driver __read_mostly ci_ehci_hc_driver;
35{
36 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
37 int ret;
38
39 hcd->has_tt = 1;
40
41 ret = ehci_setup(hcd);
42 if (ret)
43 return ret;
44
45 ehci_port_power(ehci, 0);
46
47 return ret;
48}
49
50static const struct hc_driver ci_ehci_hc_driver = {
51 .description = "ehci_hcd",
52 .product_desc = "ChipIdea HDRC EHCI",
53 .hcd_priv_size = sizeof(struct ehci_hcd),
54
55 /*
56 * generic hardware linkage
57 */
58 .irq = ehci_irq,
59 .flags = HCD_MEMORY | HCD_USB2,
60
61 /*
62 * basic lifecycle operations
63 */
64 .reset = ci_ehci_setup,
65 .start = ehci_run,
66 .stop = ehci_stop,
67 .shutdown = ehci_shutdown,
68
69 /*
70 * managing i/o requests and associated device resources
71 */
72 .urb_enqueue = ehci_urb_enqueue,
73 .urb_dequeue = ehci_urb_dequeue,
74 .endpoint_disable = ehci_endpoint_disable,
75 .endpoint_reset = ehci_endpoint_reset,
76
77 /*
78 * scheduling support
79 */
80 .get_frame_number = ehci_get_frame,
81
82 /*
83 * root hub support
84 */
85 .hub_status_data = ehci_hub_status_data,
86 .hub_control = ehci_hub_control,
87 .bus_suspend = ehci_bus_suspend,
88 .bus_resume = ehci_bus_resume,
89 .relinquish_port = ehci_relinquish_port,
90 .port_handed_over = ehci_port_handed_over,
91
92 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
93};
94 35
95static irqreturn_t host_irq(struct ci13xxx *ci) 36static irqreturn_t host_irq(struct ci13xxx *ci)
96{ 37{
@@ -157,5 +98,7 @@ int ci_hdrc_host_init(struct ci13xxx *ci)
157 rdrv->name = "host"; 98 rdrv->name = "host";
158 ci->roles[CI_ROLE_HOST] = rdrv; 99 ci->roles[CI_ROLE_HOST] = rdrv;
159 100
101 ehci_init_driver(&ci_ehci_hc_driver, NULL);
102
160 return 0; 103 return 0;
161} 104}
diff --git a/drivers/usb/chipidea/usbmisc_imx6q.c b/drivers/usb/chipidea/usbmisc_imx6q.c
index 416e3fc58fd0..845efe29e6b9 100644
--- a/drivers/usb/chipidea/usbmisc_imx6q.c
+++ b/drivers/usb/chipidea/usbmisc_imx6q.c
@@ -82,7 +82,7 @@ static const struct of_device_id usbmisc_imx6q_dt_ids[] = {
82 { /* sentinel */ } 82 { /* sentinel */ }
83}; 83};
84 84
85static int __devinit usbmisc_imx6q_probe(struct platform_device *pdev) 85static int usbmisc_imx6q_probe(struct platform_device *pdev)
86{ 86{
87 struct resource *res; 87 struct resource *res;
88 struct imx6q_usbmisc *data; 88 struct imx6q_usbmisc *data;
@@ -127,7 +127,7 @@ static int __devinit usbmisc_imx6q_probe(struct platform_device *pdev)
127 return 0; 127 return 0;
128} 128}
129 129
130static int __devexit usbmisc_imx6q_remove(struct platform_device *pdev) 130static int usbmisc_imx6q_remove(struct platform_device *pdev)
131{ 131{
132 usbmisc_unset_ops(&imx6q_usbmisc_ops); 132 usbmisc_unset_ops(&imx6q_usbmisc_ops);
133 clk_disable_unprepare(usbmisc->clk); 133 clk_disable_unprepare(usbmisc->clk);
@@ -136,7 +136,7 @@ static int __devexit usbmisc_imx6q_remove(struct platform_device *pdev)
136 136
137static struct platform_driver usbmisc_imx6q_driver = { 137static struct platform_driver usbmisc_imx6q_driver = {
138 .probe = usbmisc_imx6q_probe, 138 .probe = usbmisc_imx6q_probe,
139 .remove = __devexit_p(usbmisc_imx6q_remove), 139 .remove = usbmisc_imx6q_remove,
140 .driver = { 140 .driver = {
141 .name = "usbmisc_imx6q", 141 .name = "usbmisc_imx6q",
142 .owner = THIS_MODULE, 142 .owner = THIS_MODULE,
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 6e49ec6f3adc..8d809a811e16 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -787,6 +787,10 @@ static int get_serial_info(struct acm *acm, struct serial_struct __user *info)
787 tmp.flags = ASYNC_LOW_LATENCY; 787 tmp.flags = ASYNC_LOW_LATENCY;
788 tmp.xmit_fifo_size = acm->writesize; 788 tmp.xmit_fifo_size = acm->writesize;
789 tmp.baud_base = le32_to_cpu(acm->line.dwDTERate); 789 tmp.baud_base = le32_to_cpu(acm->line.dwDTERate);
790 tmp.close_delay = acm->port.close_delay / 10;
791 tmp.closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
792 ASYNC_CLOSING_WAIT_NONE :
793 acm->port.closing_wait / 10;
790 794
791 if (copy_to_user(info, &tmp, sizeof(tmp))) 795 if (copy_to_user(info, &tmp, sizeof(tmp)))
792 return -EFAULT; 796 return -EFAULT;
@@ -794,6 +798,37 @@ static int get_serial_info(struct acm *acm, struct serial_struct __user *info)
794 return 0; 798 return 0;
795} 799}
796 800
801static int set_serial_info(struct acm *acm,
802 struct serial_struct __user *newinfo)
803{
804 struct serial_struct new_serial;
805 unsigned int closing_wait, close_delay;
806 int retval = 0;
807
808 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
809 return -EFAULT;
810
811 close_delay = new_serial.close_delay * 10;
812 closing_wait = new_serial.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
813 ASYNC_CLOSING_WAIT_NONE : new_serial.closing_wait * 10;
814
815 mutex_lock(&acm->port.mutex);
816
817 if (!capable(CAP_SYS_ADMIN)) {
818 if ((close_delay != acm->port.close_delay) ||
819 (closing_wait != acm->port.closing_wait))
820 retval = -EPERM;
821 else
822 retval = -EOPNOTSUPP;
823 } else {
824 acm->port.close_delay = close_delay;
825 acm->port.closing_wait = closing_wait;
826 }
827
828 mutex_unlock(&acm->port.mutex);
829 return retval;
830}
831
797static int acm_tty_ioctl(struct tty_struct *tty, 832static int acm_tty_ioctl(struct tty_struct *tty,
798 unsigned int cmd, unsigned long arg) 833 unsigned int cmd, unsigned long arg)
799{ 834{
@@ -804,6 +839,9 @@ static int acm_tty_ioctl(struct tty_struct *tty,
804 case TIOCGSERIAL: /* gets serial port data */ 839 case TIOCGSERIAL: /* gets serial port data */
805 rv = get_serial_info(acm, (struct serial_struct __user *) arg); 840 rv = get_serial_info(acm, (struct serial_struct __user *) arg);
806 break; 841 break;
842 case TIOCSSERIAL:
843 rv = set_serial_info(acm, (struct serial_struct __user *) arg);
844 break;
807 } 845 }
808 846
809 return rv; 847 return rv;
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index f460de31acee..cbacea933b18 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -591,16 +591,14 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes,
591 591
592 /* Now look at all of this device's children. */ 592 /* Now look at all of this device's children. */
593 usb_hub_for_each_child(usbdev, chix, childdev) { 593 usb_hub_for_each_child(usbdev, chix, childdev) {
594 if (childdev) { 594 usb_lock_device(childdev);
595 usb_lock_device(childdev); 595 ret = usb_device_dump(buffer, nbytes, skip_bytes,
596 ret = usb_device_dump(buffer, nbytes, skip_bytes, 596 file_offset, childdev, bus,
597 file_offset, childdev, bus, 597 level + 1, chix - 1, ++cnt);
598 level + 1, chix - 1, ++cnt); 598 usb_unlock_device(childdev);
599 usb_unlock_device(childdev); 599 if (ret == -EFAULT)
600 if (ret == -EFAULT) 600 return total_written;
601 return total_written; 601 total_written += ret;
602 total_written += ret;
603 }
604 } 602 }
605 return total_written; 603 return total_written;
606} 604}
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 6056db7af410..88dde95b6795 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -32,8 +32,6 @@
32#include "usb.h" 32#include "usb.h"
33 33
34 34
35#ifdef CONFIG_HOTPLUG
36
37/* 35/*
38 * Adds a new dynamic USBdevice ID to this driver, 36 * Adds a new dynamic USBdevice ID to this driver,
39 * and cause the driver to probe for all devices again. 37 * and cause the driver to probe for all devices again.
@@ -194,20 +192,6 @@ static void usb_free_dynids(struct usb_driver *usb_drv)
194 } 192 }
195 spin_unlock(&usb_drv->dynids.lock); 193 spin_unlock(&usb_drv->dynids.lock);
196} 194}
197#else
198static inline int usb_create_newid_files(struct usb_driver *usb_drv)
199{
200 return 0;
201}
202
203static void usb_remove_newid_files(struct usb_driver *usb_drv)
204{
205}
206
207static inline void usb_free_dynids(struct usb_driver *usb_drv)
208{
209}
210#endif
211 195
212static const struct usb_device_id *usb_match_dynamic_id(struct usb_interface *intf, 196static const struct usb_device_id *usb_match_dynamic_id(struct usb_interface *intf,
213 struct usb_driver *drv) 197 struct usb_driver *drv)
@@ -790,7 +774,6 @@ static int usb_device_match(struct device *dev, struct device_driver *drv)
790 return 0; 774 return 0;
791} 775}
792 776
793#ifdef CONFIG_HOTPLUG
794static int usb_uevent(struct device *dev, struct kobj_uevent_env *env) 777static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
795{ 778{
796 struct usb_device *usb_dev; 779 struct usb_device *usb_dev;
@@ -832,14 +815,6 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
832 return 0; 815 return 0;
833} 816}
834 817
835#else
836
837static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
838{
839 return -ENODEV;
840}
841#endif /* CONFIG_HOTPLUG */
842
843/** 818/**
844 * usb_register_device_driver - register a USB device (not interface) driver 819 * usb_register_device_driver - register a USB device (not interface) driver
845 * @new_udriver: USB operations for the device driver 820 * @new_udriver: USB operations for the device driver
diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
index 69ecd3c92311..eff2010eb63f 100644
--- a/drivers/usb/core/generic.c
+++ b/drivers/usb/core/generic.c
@@ -47,6 +47,9 @@ int usb_choose_configuration(struct usb_device *udev)
47 int insufficient_power = 0; 47 int insufficient_power = 0;
48 struct usb_host_config *c, *best; 48 struct usb_host_config *c, *best;
49 49
50 if (usb_device_is_owned(udev))
51 return 0;
52
50 best = NULL; 53 best = NULL;
51 c = udev->config; 54 c = udev->config;
52 num_configs = udev->descriptor.bNumConfigurations; 55 num_configs = udev->descriptor.bNumConfigurations;
@@ -160,9 +163,7 @@ static int generic_probe(struct usb_device *udev)
160 /* Choose and set the configuration. This registers the interfaces 163 /* Choose and set the configuration. This registers the interfaces
161 * with the driver core and lets interface drivers bind to them. 164 * with the driver core and lets interface drivers bind to them.
162 */ 165 */
163 if (usb_device_is_owned(udev)) 166 if (udev->authorized == 0)
164 ; /* Don't configure if the device is owned */
165 else if (udev->authorized == 0)
166 dev_err(&udev->dev, "Device is not authorized for usage\n"); 167 dev_err(&udev->dev, "Device is not authorized for usage\n");
167 else { 168 else {
168 c = usb_choose_configuration(udev); 169 c = usb_choose_configuration(udev);
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index f034716190ff..4225d5e72131 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2039,8 +2039,9 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg)
2039 status = hcd->driver->bus_resume(hcd); 2039 status = hcd->driver->bus_resume(hcd);
2040 clear_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags); 2040 clear_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags);
2041 if (status == 0) { 2041 if (status == 0) {
2042 /* TRSMRCY = 10 msec */ 2042 struct usb_device *udev;
2043 msleep(10); 2043 int port1;
2044
2044 spin_lock_irq(&hcd_root_hub_lock); 2045 spin_lock_irq(&hcd_root_hub_lock);
2045 if (!HCD_DEAD(hcd)) { 2046 if (!HCD_DEAD(hcd)) {
2046 usb_set_device_state(rhdev, rhdev->actconfig 2047 usb_set_device_state(rhdev, rhdev->actconfig
@@ -2050,6 +2051,20 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg)
2050 hcd->state = HC_STATE_RUNNING; 2051 hcd->state = HC_STATE_RUNNING;
2051 } 2052 }
2052 spin_unlock_irq(&hcd_root_hub_lock); 2053 spin_unlock_irq(&hcd_root_hub_lock);
2054
2055 /*
2056 * Check whether any of the enabled ports on the root hub are
2057 * unsuspended. If they are then a TRSMRCY delay is needed
2058 * (this is what the USB-2 spec calls a "global resume").
2059 * Otherwise we can skip the delay.
2060 */
2061 usb_hub_for_each_child(rhdev, port1, udev) {
2062 if (udev->state != USB_STATE_NOTATTACHED &&
2063 !udev->port_is_suspended) {
2064 usleep_range(10000, 11000); /* TRSMRCY */
2065 break;
2066 }
2067 }
2053 } else { 2068 } else {
2054 hcd->state = old_state; 2069 hcd->state = old_state;
2055 dev_dbg(&rhdev->dev, "bus %s fail, err %d\n", 2070 dev_dbg(&rhdev->dev, "bus %s fail, err %d\n",
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 1af04bdeaf0c..a815fd2cc5e7 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -39,6 +39,9 @@
39#endif 39#endif
40#endif 40#endif
41 41
42#define USB_VENDOR_GENESYS_LOGIC 0x05e3
43#define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND 0x01
44
42struct usb_port { 45struct usb_port {
43 struct usb_device *child; 46 struct usb_device *child;
44 struct device dev; 47 struct device dev;
@@ -86,6 +89,8 @@ struct usb_hub {
86 unsigned quiescing:1; 89 unsigned quiescing:1;
87 unsigned disconnected:1; 90 unsigned disconnected:1;
88 91
92 unsigned quirk_check_port_auto_suspend:1;
93
89 unsigned has_indicators:1; 94 unsigned has_indicators:1;
90 u8 indicator[USB_MAXCHILDREN]; 95 u8 indicator[USB_MAXCHILDREN];
91 struct delayed_work leds; 96 struct delayed_work leds;
@@ -736,7 +741,6 @@ static void hub_tt_work(struct work_struct *work)
736 struct usb_hub *hub = 741 struct usb_hub *hub =
737 container_of(work, struct usb_hub, tt.clear_work); 742 container_of(work, struct usb_hub, tt.clear_work);
738 unsigned long flags; 743 unsigned long flags;
739 int limit = 100;
740 744
741 spin_lock_irqsave (&hub->tt.lock, flags); 745 spin_lock_irqsave (&hub->tt.lock, flags);
742 while (!list_empty(&hub->tt.clear_list)) { 746 while (!list_empty(&hub->tt.clear_list)) {
@@ -746,9 +750,6 @@ static void hub_tt_work(struct work_struct *work)
746 const struct hc_driver *drv; 750 const struct hc_driver *drv;
747 int status; 751 int status;
748 752
749 if (!hub->quiescing && --limit < 0)
750 break;
751
752 next = hub->tt.clear_list.next; 753 next = hub->tt.clear_list.next;
753 clear = list_entry (next, struct usb_tt_clear, clear_list); 754 clear = list_entry (next, struct usb_tt_clear, clear_list);
754 list_del (&clear->clear_list); 755 list_del (&clear->clear_list);
@@ -1612,6 +1613,41 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
1612 desc = intf->cur_altsetting; 1613 desc = intf->cur_altsetting;
1613 hdev = interface_to_usbdev(intf); 1614 hdev = interface_to_usbdev(intf);
1614 1615
1616 /*
1617 * Set default autosuspend delay as 0 to speedup bus suspend,
1618 * based on the below considerations:
1619 *
1620 * - Unlike other drivers, the hub driver does not rely on the
1621 * autosuspend delay to provide enough time to handle a wakeup
1622 * event, and the submitted status URB is just to check future
1623 * change on hub downstream ports, so it is safe to do it.
1624 *
1625 * - The patch might cause one or more auto supend/resume for
1626 * below very rare devices when they are plugged into hub
1627 * first time:
1628 *
1629 * devices having trouble initializing, and disconnect
1630 * themselves from the bus and then reconnect a second
1631 * or so later
1632 *
1633 * devices just for downloading firmware, and disconnects
1634 * themselves after completing it
1635 *
1636 * For these quite rare devices, their drivers may change the
1637 * autosuspend delay of their parent hub in the probe() to one
1638 * appropriate value to avoid the subtle problem if someone
1639 * does care it.
1640 *
1641 * - The patch may cause one or more auto suspend/resume on
1642 * hub during running 'lsusb', but it is probably too
1643 * infrequent to worry about.
1644 *
1645 * - Change autosuspend delay of hub can avoid unnecessary auto
1646 * suspend timer for hub, also may decrease power consumption
1647 * of USB bus.
1648 */
1649 pm_runtime_set_autosuspend_delay(&hdev->dev, 0);
1650
1615 /* Hubs have proper suspend/resume support. */ 1651 /* Hubs have proper suspend/resume support. */
1616 usb_enable_autosuspend(hdev); 1652 usb_enable_autosuspend(hdev);
1617 1653
@@ -1670,6 +1706,9 @@ descriptor_error:
1670 if (hdev->speed == USB_SPEED_HIGH) 1706 if (hdev->speed == USB_SPEED_HIGH)
1671 highspeed_hubs++; 1707 highspeed_hubs++;
1672 1708
1709 if (id->driver_info & HUB_QUIRK_CHECK_PORT_AUTOSUSPEND)
1710 hub->quirk_check_port_auto_suspend = 1;
1711
1673 if (hub_configure(hub, endpoint) >= 0) 1712 if (hub_configure(hub, endpoint) >= 0)
1674 return 0; 1713 return 0;
1675 1714
@@ -2012,7 +2051,7 @@ static void show_string(struct usb_device *udev, char *id, char *string)
2012{ 2051{
2013 if (!string) 2052 if (!string)
2014 return; 2053 return;
2015 dev_printk(KERN_INFO, &udev->dev, "%s: %s\n", id, string); 2054 dev_info(&udev->dev, "%s: %s\n", id, string);
2016} 2055}
2017 2056
2018static void announce_device(struct usb_device *udev) 2057static void announce_device(struct usb_device *udev)
@@ -2879,6 +2918,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
2879 (PMSG_IS_AUTO(msg) ? "auto-" : ""), 2918 (PMSG_IS_AUTO(msg) ? "auto-" : ""),
2880 udev->do_remote_wakeup); 2919 udev->do_remote_wakeup);
2881 usb_set_device_state(udev, USB_STATE_SUSPENDED); 2920 usb_set_device_state(udev, USB_STATE_SUSPENDED);
2921 udev->port_is_suspended = 1;
2882 msleep(10); 2922 msleep(10);
2883 } 2923 }
2884 usb_mark_last_busy(hub->hdev); 2924 usb_mark_last_busy(hub->hdev);
@@ -3043,6 +3083,7 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
3043 3083
3044 SuspendCleared: 3084 SuspendCleared:
3045 if (status == 0) { 3085 if (status == 0) {
3086 udev->port_is_suspended = 0;
3046 if (hub_is_superspeed(hub->hdev)) { 3087 if (hub_is_superspeed(hub->hdev)) {
3047 if (portchange & USB_PORT_STAT_C_LINK_STATE) 3088 if (portchange & USB_PORT_STAT_C_LINK_STATE)
3048 clear_port_feature(hub->hdev, port1, 3089 clear_port_feature(hub->hdev, port1,
@@ -3126,6 +3167,21 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
3126 3167
3127#endif 3168#endif
3128 3169
3170static int check_ports_changed(struct usb_hub *hub)
3171{
3172 int port1;
3173
3174 for (port1 = 1; port1 <= hub->hdev->maxchild; ++port1) {
3175 u16 portstatus, portchange;
3176 int status;
3177
3178 status = hub_port_status(hub, port1, &portstatus, &portchange);
3179 if (!status && portchange)
3180 return 1;
3181 }
3182 return 0;
3183}
3184
3129static int hub_suspend(struct usb_interface *intf, pm_message_t msg) 3185static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
3130{ 3186{
3131 struct usb_hub *hub = usb_get_intfdata (intf); 3187 struct usb_hub *hub = usb_get_intfdata (intf);
@@ -3144,6 +3200,16 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
3144 return -EBUSY; 3200 return -EBUSY;
3145 } 3201 }
3146 } 3202 }
3203
3204 if (hdev->do_remote_wakeup && hub->quirk_check_port_auto_suspend) {
3205 /* check if there are changes pending on hub ports */
3206 if (check_ports_changed(hub)) {
3207 if (PMSG_IS_AUTO(msg))
3208 return -EBUSY;
3209 pm_wakeup_event(&hdev->dev, 2000);
3210 }
3211 }
3212
3147 if (hub_is_superspeed(hdev) && hdev->do_remote_wakeup) { 3213 if (hub_is_superspeed(hdev) && hdev->do_remote_wakeup) {
3148 /* Enable hub to send remote wakeup for all ports. */ 3214 /* Enable hub to send remote wakeup for all ports. */
3149 for (port1 = 1; port1 <= hdev->maxchild; port1++) { 3215 for (port1 = 1; port1 <= hdev->maxchild; port1++) {
@@ -3972,6 +4038,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
3972 if (retval) 4038 if (retval)
3973 goto fail; 4039 goto fail;
3974 4040
4041 if (hcd->phy && !hdev->parent)
4042 usb_phy_notify_connect(hcd->phy, udev->speed);
4043
3975 /* 4044 /*
3976 * Some superspeed devices have finished the link training process 4045 * Some superspeed devices have finished the link training process
3977 * and attached to a superspeed hub port, but the device descriptor 4046 * and attached to a superspeed hub port, but the device descriptor
@@ -4166,8 +4235,12 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
4166 } 4235 }
4167 4236
4168 /* Disconnect any existing devices under this port */ 4237 /* Disconnect any existing devices under this port */
4169 if (udev) 4238 if (udev) {
4239 if (hcd->phy && !hdev->parent &&
4240 !(portstatus & USB_PORT_STAT_CONNECTION))
4241 usb_phy_notify_disconnect(hcd->phy, udev->speed);
4170 usb_disconnect(&hub->ports[port1 - 1]->child); 4242 usb_disconnect(&hub->ports[port1 - 1]->child);
4243 }
4171 clear_bit(port1, hub->change_bits); 4244 clear_bit(port1, hub->change_bits);
4172 4245
4173 /* We can forget about a "removed" device when there's a physical 4246 /* We can forget about a "removed" device when there's a physical
@@ -4190,13 +4263,6 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
4190 } 4263 }
4191 } 4264 }
4192 4265
4193 if (hcd->phy && !hdev->parent) {
4194 if (portstatus & USB_PORT_STAT_CONNECTION)
4195 usb_phy_notify_connect(hcd->phy, port1);
4196 else
4197 usb_phy_notify_disconnect(hcd->phy, port1);
4198 }
4199
4200 /* Return now if debouncing failed or nothing is connected or 4266 /* Return now if debouncing failed or nothing is connected or
4201 * the device was "removed". 4267 * the device was "removed".
4202 */ 4268 */
@@ -4648,6 +4714,11 @@ static int hub_thread(void *__unused)
4648} 4714}
4649 4715
4650static const struct usb_device_id hub_id_table[] = { 4716static const struct usb_device_id hub_id_table[] = {
4717 { .match_flags = USB_DEVICE_ID_MATCH_VENDOR
4718 | USB_DEVICE_ID_MATCH_INT_CLASS,
4719 .idVendor = USB_VENDOR_GENESYS_LOGIC,
4720 .bInterfaceClass = USB_CLASS_HUB,
4721 .driver_info = HUB_QUIRK_CHECK_PORT_AUTOSUSPEND},
4651 { .match_flags = USB_DEVICE_ID_MATCH_DEV_CLASS, 4722 { .match_flags = USB_DEVICE_ID_MATCH_DEV_CLASS,
4652 .bDeviceClass = USB_CLASS_HUB}, 4723 .bDeviceClass = USB_CLASS_HUB},
4653 { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS, 4724 { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS,
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 1ed5afd91e6d..131f73649b60 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1540,7 +1540,6 @@ static void usb_release_interface(struct device *dev)
1540 kfree(intf); 1540 kfree(intf);
1541} 1541}
1542 1542
1543#ifdef CONFIG_HOTPLUG
1544static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env) 1543static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env)
1545{ 1544{
1546 struct usb_device *usb_dev; 1545 struct usb_device *usb_dev;
@@ -1575,14 +1574,6 @@ static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env)
1575 return 0; 1574 return 0;
1576} 1575}
1577 1576
1578#else
1579
1580static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env)
1581{
1582 return -ENODEV;
1583}
1584#endif /* CONFIG_HOTPLUG */
1585
1586struct device_type usb_if_device_type = { 1577struct device_type usb_if_device_type = {
1587 .name = "usb_interface", 1578 .name = "usb_interface",
1588 .release = usb_release_interface, 1579 .release = usb_release_interface,
@@ -1795,7 +1786,8 @@ free_interfaces:
1795 if (dev->actconfig && usb_disable_lpm(dev)) { 1786 if (dev->actconfig && usb_disable_lpm(dev)) {
1796 dev_err(&dev->dev, "%s Failed to disable LPM\n.", __func__); 1787 dev_err(&dev->dev, "%s Failed to disable LPM\n.", __func__);
1797 mutex_unlock(hcd->bandwidth_mutex); 1788 mutex_unlock(hcd->bandwidth_mutex);
1798 return -ENOMEM; 1789 ret = -ENOMEM;
1790 goto free_interfaces;
1799 } 1791 }
1800 ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL); 1792 ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL);
1801 if (ret < 0) { 1793 if (ret < 0) {
@@ -1806,29 +1798,8 @@ free_interfaces:
1806 goto free_interfaces; 1798 goto free_interfaces;
1807 } 1799 }
1808 1800
1809 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1801 /*
1810 USB_REQ_SET_CONFIGURATION, 0, configuration, 0, 1802 * Initialize the new interface structures and the
1811 NULL, 0, USB_CTRL_SET_TIMEOUT);
1812 if (ret < 0) {
1813 /* All the old state is gone, so what else can we do?
1814 * The device is probably useless now anyway.
1815 */
1816 cp = NULL;
1817 }
1818
1819 dev->actconfig = cp;
1820 if (!cp) {
1821 usb_set_device_state(dev, USB_STATE_ADDRESS);
1822 usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
1823 /* Leave LPM disabled while the device is unconfigured. */
1824 mutex_unlock(hcd->bandwidth_mutex);
1825 usb_autosuspend_device(dev);
1826 goto free_interfaces;
1827 }
1828 mutex_unlock(hcd->bandwidth_mutex);
1829 usb_set_device_state(dev, USB_STATE_CONFIGURED);
1830
1831 /* Initialize the new interface structures and the
1832 * hc/hcd/usbcore interface/endpoint state. 1803 * hc/hcd/usbcore interface/endpoint state.
1833 */ 1804 */
1834 for (i = 0; i < nintf; ++i) { 1805 for (i = 0; i < nintf; ++i) {
@@ -1872,6 +1843,35 @@ free_interfaces:
1872 } 1843 }
1873 kfree(new_interfaces); 1844 kfree(new_interfaces);
1874 1845
1846 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1847 USB_REQ_SET_CONFIGURATION, 0, configuration, 0,
1848 NULL, 0, USB_CTRL_SET_TIMEOUT);
1849 if (ret < 0 && cp) {
1850 /*
1851 * All the old state is gone, so what else can we do?
1852 * The device is probably useless now anyway.
1853 */
1854 usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
1855 for (i = 0; i < nintf; ++i) {
1856 usb_disable_interface(dev, cp->interface[i], true);
1857 put_device(&cp->interface[i]->dev);
1858 cp->interface[i] = NULL;
1859 }
1860 cp = NULL;
1861 }
1862
1863 dev->actconfig = cp;
1864 mutex_unlock(hcd->bandwidth_mutex);
1865
1866 if (!cp) {
1867 usb_set_device_state(dev, USB_STATE_ADDRESS);
1868
1869 /* Leave LPM disabled while the device is unconfigured. */
1870 usb_autosuspend_device(dev);
1871 return ret;
1872 }
1873 usb_set_device_state(dev, USB_STATE_CONFIGURED);
1874
1875 if (cp->string == NULL && 1875 if (cp->string == NULL &&
1876 !(dev->quirks & USB_QUIRK_CONFIG_INTF_STRINGS)) 1876 !(dev->quirks & USB_QUIRK_CONFIG_INTF_STRINGS))
1877 cp->string = usb_cache_string(dev, cp->desc.iConfiguration); 1877 cp->string = usb_cache_string(dev, cp->desc.iConfiguration);
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 9d912bfdcffe..e0d9d948218c 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -214,9 +214,25 @@ EXPORT_SYMBOL_GPL(usb_unanchor_urb);
214 * urb->interval is modified to reflect the actual transfer period used 214 * urb->interval is modified to reflect the actual transfer period used
215 * (normally some power of two units). And for isochronous urbs, 215 * (normally some power of two units). And for isochronous urbs,
216 * urb->start_frame is modified to reflect when the URB's transfers were 216 * urb->start_frame is modified to reflect when the URB's transfers were
217 * scheduled to start. Not all isochronous transfer scheduling policies 217 * scheduled to start.
218 * will work, but most host controller drivers should easily handle ISO 218 *
219 * queues going from now until 10-200 msec into the future. 219 * Not all isochronous transfer scheduling policies will work, but most
220 * host controller drivers should easily handle ISO queues going from now
221 * until 10-200 msec into the future. Drivers should try to keep at
222 * least one or two msec of data in the queue; many controllers require
223 * that new transfers start at least 1 msec in the future when they are
224 * added. If the driver is unable to keep up and the queue empties out,
225 * the behavior for new submissions is governed by the URB_ISO_ASAP flag.
226 * If the flag is set, or if the queue is idle, then the URB is always
227 * assigned to the first available (and not yet expired) slot in the
228 * endpoint's schedule. If the flag is not set and the queue is active
229 * then the URB is always assigned to the next slot in the schedule
230 * following the end of the endpoint's previous URB, even if that slot is
231 * in the past. When a packet is assigned in this way to a slot that has
232 * already expired, the packet is not transmitted and the corresponding
233 * usb_iso_packet_descriptor's status field will return -EXDEV. If this
234 * would happen to all the packets in the URB, submission fails with a
235 * -EXDEV error code.
220 * 236 *
221 * For control endpoints, the synchronous usb_control_msg() call is 237 * For control endpoints, the synchronous usb_control_msg() call is
222 * often used (in non-interrupt context) instead of this call. 238 * often used (in non-interrupt context) instead of this call.
@@ -305,8 +321,13 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
305 struct usb_host_endpoint *ep; 321 struct usb_host_endpoint *ep;
306 int is_out; 322 int is_out;
307 323
308 if (!urb || urb->hcpriv || !urb->complete) 324 if (!urb || !urb->complete)
309 return -EINVAL; 325 return -EINVAL;
326 if (urb->hcpriv) {
327 WARN_ONCE(1, "URB %p submitted while active\n", urb);
328 return -EBUSY;
329 }
330
310 dev = urb->dev; 331 dev = urb->dev;
311 if ((!dev) || (dev->state < USB_STATE_UNAUTHENTICATED)) 332 if ((!dev) || (dev->state < USB_STATE_UNAUTHENTICATED))
312 return -ENODEV; 333 return -ENODEV;
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index cd8fb44a3e16..f81b92572735 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -233,7 +233,6 @@ static void usb_release_dev(struct device *dev)
233 kfree(udev); 233 kfree(udev);
234} 234}
235 235
236#ifdef CONFIG_HOTPLUG
237static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env) 236static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
238{ 237{
239 struct usb_device *usb_dev; 238 struct usb_device *usb_dev;
@@ -249,14 +248,6 @@ static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
249 return 0; 248 return 0;
250} 249}
251 250
252#else
253
254static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
255{
256 return -ENODEV;
257}
258#endif /* CONFIG_HOTPLUG */
259
260#ifdef CONFIG_PM 251#ifdef CONFIG_PM
261 252
262/* USB device Power-Management thunks. 253/* USB device Power-Management thunks.
@@ -370,14 +361,14 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
370 struct usb_bus *bus, unsigned port1) 361 struct usb_bus *bus, unsigned port1)
371{ 362{
372 struct usb_device *dev; 363 struct usb_device *dev;
373 struct usb_hcd *usb_hcd = container_of(bus, struct usb_hcd, self); 364 struct usb_hcd *usb_hcd = bus_to_hcd(bus);
374 unsigned root_hub = 0; 365 unsigned root_hub = 0;
375 366
376 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 367 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
377 if (!dev) 368 if (!dev)
378 return NULL; 369 return NULL;
379 370
380 if (!usb_get_hcd(bus_to_hcd(bus))) { 371 if (!usb_get_hcd(usb_hcd)) {
381 kfree(dev); 372 kfree(dev);
382 return NULL; 373 return NULL;
383 } 374 }
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index d441fe4c180b..4502648b8171 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -27,19 +27,7 @@ endif
27## 27##
28 28
29obj-$(CONFIG_USB_DWC3) += dwc3-omap.o 29obj-$(CONFIG_USB_DWC3) += dwc3-omap.o
30 30obj-$(CONFIG_USB_DWC3) += dwc3-exynos.o
31##
32# REVISIT Samsung Exynos platform needs the clk API which isn't
33# defined on all architectures. If we allow dwc3-exynos.c compile
34# always we will fail the linking phase on those architectures
35# which don't provide clk api implementation and that's unnaceptable.
36#
37# When Samsung's platform start supporting pm_runtime, this check
38# for HAVE_CLK should be removed.
39##
40ifneq ($(CONFIG_HAVE_CLK),)
41 obj-$(CONFIG_USB_DWC3) += dwc3-exynos.o
42endif
43 31
44ifneq ($(CONFIG_PCI),) 32ifneq ($(CONFIG_PCI),)
45 obj-$(CONFIG_USB_DWC3) += dwc3-pci.o 33 obj-$(CONFIG_USB_DWC3) += dwc3-pci.o
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index c14ebc975ba4..3a4004a620ad 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -66,45 +66,6 @@ MODULE_PARM_DESC(maximum_speed, "Maximum supported speed.");
66 66
67/* -------------------------------------------------------------------------- */ 67/* -------------------------------------------------------------------------- */
68 68
69#define DWC3_DEVS_POSSIBLE 32
70
71static DECLARE_BITMAP(dwc3_devs, DWC3_DEVS_POSSIBLE);
72
73int dwc3_get_device_id(void)
74{
75 int id;
76
77again:
78 id = find_first_zero_bit(dwc3_devs, DWC3_DEVS_POSSIBLE);
79 if (id < DWC3_DEVS_POSSIBLE) {
80 int old;
81
82 old = test_and_set_bit(id, dwc3_devs);
83 if (old)
84 goto again;
85 } else {
86 pr_err("dwc3: no space for new device\n");
87 id = -ENOMEM;
88 }
89
90 return id;
91}
92EXPORT_SYMBOL_GPL(dwc3_get_device_id);
93
94void dwc3_put_device_id(int id)
95{
96 int ret;
97
98 if (id < 0)
99 return;
100
101 ret = test_bit(id, dwc3_devs);
102 WARN(!ret, "dwc3: ID %d not in use\n", id);
103 smp_mb__before_clear_bit();
104 clear_bit(id, dwc3_devs);
105}
106EXPORT_SYMBOL_GPL(dwc3_put_device_id);
107
108void dwc3_set_mode(struct dwc3 *dwc, u32 mode) 69void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
109{ 70{
110 u32 reg; 71 u32 reg;
@@ -169,7 +130,6 @@ static void dwc3_free_one_event_buffer(struct dwc3 *dwc,
169 struct dwc3_event_buffer *evt) 130 struct dwc3_event_buffer *evt)
170{ 131{
171 dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma); 132 dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma);
172 kfree(evt);
173} 133}
174 134
175/** 135/**
@@ -180,12 +140,11 @@ static void dwc3_free_one_event_buffer(struct dwc3 *dwc,
180 * Returns a pointer to the allocated event buffer structure on success 140 * Returns a pointer to the allocated event buffer structure on success
181 * otherwise ERR_PTR(errno). 141 * otherwise ERR_PTR(errno).
182 */ 142 */
183static struct dwc3_event_buffer *__devinit 143static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc, unsigned length)
184dwc3_alloc_one_event_buffer(struct dwc3 *dwc, unsigned length)
185{ 144{
186 struct dwc3_event_buffer *evt; 145 struct dwc3_event_buffer *evt;
187 146
188 evt = kzalloc(sizeof(*evt), GFP_KERNEL); 147 evt = devm_kzalloc(dwc->dev, sizeof(*evt), GFP_KERNEL);
189 if (!evt) 148 if (!evt)
190 return ERR_PTR(-ENOMEM); 149 return ERR_PTR(-ENOMEM);
191 150
@@ -193,10 +152,8 @@ dwc3_alloc_one_event_buffer(struct dwc3 *dwc, unsigned length)
193 evt->length = length; 152 evt->length = length;
194 evt->buf = dma_alloc_coherent(dwc->dev, length, 153 evt->buf = dma_alloc_coherent(dwc->dev, length,
195 &evt->dma, GFP_KERNEL); 154 &evt->dma, GFP_KERNEL);
196 if (!evt->buf) { 155 if (!evt->buf)
197 kfree(evt);
198 return ERR_PTR(-ENOMEM); 156 return ERR_PTR(-ENOMEM);
199 }
200 157
201 return evt; 158 return evt;
202} 159}
@@ -215,8 +172,6 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc)
215 if (evt) 172 if (evt)
216 dwc3_free_one_event_buffer(dwc, evt); 173 dwc3_free_one_event_buffer(dwc, evt);
217 } 174 }
218
219 kfree(dwc->ev_buffs);
220} 175}
221 176
222/** 177/**
@@ -227,7 +182,7 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc)
227 * Returns 0 on success otherwise negative errno. In the error case, dwc 182 * Returns 0 on success otherwise negative errno. In the error case, dwc
228 * may contain some buffers allocated but not all which were requested. 183 * may contain some buffers allocated but not all which were requested.
229 */ 184 */
230static int __devinit dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) 185static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
231{ 186{
232 int num; 187 int num;
233 int i; 188 int i;
@@ -235,7 +190,8 @@ static int __devinit dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
235 num = DWC3_NUM_INT(dwc->hwparams.hwparams1); 190 num = DWC3_NUM_INT(dwc->hwparams.hwparams1);
236 dwc->num_event_buffers = num; 191 dwc->num_event_buffers = num;
237 192
238 dwc->ev_buffs = kzalloc(sizeof(*dwc->ev_buffs) * num, GFP_KERNEL); 193 dwc->ev_buffs = devm_kzalloc(dwc->dev, sizeof(*dwc->ev_buffs) * num,
194 GFP_KERNEL);
239 if (!dwc->ev_buffs) { 195 if (!dwc->ev_buffs) {
240 dev_err(dwc->dev, "can't allocate event buffers array\n"); 196 dev_err(dwc->dev, "can't allocate event buffers array\n");
241 return -ENOMEM; 197 return -ENOMEM;
@@ -303,7 +259,7 @@ static void dwc3_event_buffers_cleanup(struct dwc3 *dwc)
303 } 259 }
304} 260}
305 261
306static void __devinit dwc3_cache_hwparams(struct dwc3 *dwc) 262static void dwc3_cache_hwparams(struct dwc3 *dwc)
307{ 263{
308 struct dwc3_hwparams *parms = &dwc->hwparams; 264 struct dwc3_hwparams *parms = &dwc->hwparams;
309 265
@@ -324,7 +280,7 @@ static void __devinit dwc3_cache_hwparams(struct dwc3 *dwc)
324 * 280 *
325 * Returns 0 on success otherwise negative errno. 281 * Returns 0 on success otherwise negative errno.
326 */ 282 */
327static int __devinit dwc3_core_init(struct dwc3 *dwc) 283static int dwc3_core_init(struct dwc3 *dwc)
328{ 284{
329 unsigned long timeout; 285 unsigned long timeout;
330 u32 reg; 286 u32 reg;
@@ -358,8 +314,6 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc)
358 314
359 dwc3_core_soft_reset(dwc); 315 dwc3_core_soft_reset(dwc);
360 316
361 dwc3_cache_hwparams(dwc);
362
363 reg = dwc3_readl(dwc->regs, DWC3_GCTL); 317 reg = dwc3_readl(dwc->regs, DWC3_GCTL);
364 reg &= ~DWC3_GCTL_SCALEDOWN_MASK; 318 reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
365 reg &= ~DWC3_GCTL_DISSCRAMBLE; 319 reg &= ~DWC3_GCTL_DISSCRAMBLE;
@@ -383,24 +337,14 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc)
383 337
384 dwc3_writel(dwc->regs, DWC3_GCTL, reg); 338 dwc3_writel(dwc->regs, DWC3_GCTL, reg);
385 339
386 ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE);
387 if (ret) {
388 dev_err(dwc->dev, "failed to allocate event buffers\n");
389 ret = -ENOMEM;
390 goto err1;
391 }
392
393 ret = dwc3_event_buffers_setup(dwc); 340 ret = dwc3_event_buffers_setup(dwc);
394 if (ret) { 341 if (ret) {
395 dev_err(dwc->dev, "failed to setup event buffers\n"); 342 dev_err(dwc->dev, "failed to setup event buffers\n");
396 goto err1; 343 goto err0;
397 } 344 }
398 345
399 return 0; 346 return 0;
400 347
401err1:
402 dwc3_free_event_buffers(dwc);
403
404err0: 348err0:
405 return ret; 349 return ret;
406} 350}
@@ -408,16 +352,14 @@ err0:
408static void dwc3_core_exit(struct dwc3 *dwc) 352static void dwc3_core_exit(struct dwc3 *dwc)
409{ 353{
410 dwc3_event_buffers_cleanup(dwc); 354 dwc3_event_buffers_cleanup(dwc);
411 dwc3_free_event_buffers(dwc);
412 355
413 usb_phy_shutdown(dwc->usb2_phy); 356 usb_phy_shutdown(dwc->usb2_phy);
414 usb_phy_shutdown(dwc->usb3_phy); 357 usb_phy_shutdown(dwc->usb3_phy);
415
416} 358}
417 359
418#define DWC3_ALIGN_MASK (16 - 1) 360#define DWC3_ALIGN_MASK (16 - 1)
419 361
420static int __devinit dwc3_probe(struct platform_device *pdev) 362static int dwc3_probe(struct platform_device *pdev)
421{ 363{
422 struct device_node *node = pdev->dev.of_node; 364 struct device_node *node = pdev->dev.of_node;
423 struct resource *res; 365 struct resource *res;
@@ -515,10 +457,19 @@ static int __devinit dwc3_probe(struct platform_device *pdev)
515 pm_runtime_get_sync(dev); 457 pm_runtime_get_sync(dev);
516 pm_runtime_forbid(dev); 458 pm_runtime_forbid(dev);
517 459
460 dwc3_cache_hwparams(dwc);
461
462 ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE);
463 if (ret) {
464 dev_err(dwc->dev, "failed to allocate event buffers\n");
465 ret = -ENOMEM;
466 goto err0;
467 }
468
518 ret = dwc3_core_init(dwc); 469 ret = dwc3_core_init(dwc);
519 if (ret) { 470 if (ret) {
520 dev_err(dev, "failed to initialize core\n"); 471 dev_err(dev, "failed to initialize core\n");
521 return ret; 472 goto err0;
522 } 473 }
523 474
524 mode = DWC3_MODE(dwc->hwparams.hwparams0); 475 mode = DWC3_MODE(dwc->hwparams.hwparams0);
@@ -590,10 +541,13 @@ err2:
590err1: 541err1:
591 dwc3_core_exit(dwc); 542 dwc3_core_exit(dwc);
592 543
544err0:
545 dwc3_free_event_buffers(dwc);
546
593 return ret; 547 return ret;
594} 548}
595 549
596static int __devexit dwc3_remove(struct platform_device *pdev) 550static int dwc3_remove(struct platform_device *pdev)
597{ 551{
598 struct dwc3 *dwc = platform_get_drvdata(pdev); 552 struct dwc3 *dwc = platform_get_drvdata(pdev);
599 struct resource *res; 553 struct resource *res;
@@ -628,7 +582,7 @@ static int __devexit dwc3_remove(struct platform_device *pdev)
628 582
629static struct platform_driver dwc3_driver = { 583static struct platform_driver dwc3_driver = {
630 .probe = dwc3_probe, 584 .probe = dwc3_probe,
631 .remove = __devexit_p(dwc3_remove), 585 .remove = dwc3_remove,
632 .driver = { 586 .driver = {
633 .name = "dwc3", 587 .name = "dwc3",
634 }, 588 },
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 243affc93431..499956344262 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -868,7 +868,4 @@ void dwc3_host_exit(struct dwc3 *dwc);
868int dwc3_gadget_init(struct dwc3 *dwc); 868int dwc3_gadget_init(struct dwc3 *dwc);
869void dwc3_gadget_exit(struct dwc3 *dwc); 869void dwc3_gadget_exit(struct dwc3 *dwc);
870 870
871extern int dwc3_get_device_id(void);
872extern void dwc3_put_device_id(int id);
873
874#endif /* __DRIVERS_USB_DWC3_CORE_H */ 871#endif /* __DRIVERS_USB_DWC3_CORE_H */
diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
index d4a30f118724..92604b4f9712 100644
--- a/drivers/usb/dwc3/debugfs.c
+++ b/drivers/usb/dwc3/debugfs.c
@@ -652,7 +652,7 @@ static const struct file_operations dwc3_link_state_fops = {
652 .release = single_release, 652 .release = single_release,
653}; 653};
654 654
655int __devinit dwc3_debugfs_init(struct dwc3 *dwc) 655int dwc3_debugfs_init(struct dwc3 *dwc)
656{ 656{
657 struct dentry *root; 657 struct dentry *root;
658 struct dentry *file; 658 struct dentry *file;
@@ -703,7 +703,7 @@ err0:
703 return ret; 703 return ret;
704} 704}
705 705
706void __devexit dwc3_debugfs_exit(struct dwc3 *dwc) 706void dwc3_debugfs_exit(struct dwc3 *dwc)
707{ 707{
708 debugfs_remove_recursive(dwc->root); 708 debugfs_remove_recursive(dwc->root);
709 dwc->root = NULL; 709 dwc->root = NULL;
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index ca6597853f90..aae5328ac771 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -21,6 +21,7 @@
21#include <linux/clk.h> 21#include <linux/clk.h>
22#include <linux/usb/otg.h> 22#include <linux/usb/otg.h>
23#include <linux/usb/nop-usb-xceiv.h> 23#include <linux/usb/nop-usb-xceiv.h>
24#include <linux/of.h>
24 25
25#include "core.h" 26#include "core.h"
26 27
@@ -33,7 +34,7 @@ struct dwc3_exynos {
33 struct clk *clk; 34 struct clk *clk;
34}; 35};
35 36
36static int __devinit dwc3_exynos_register_phys(struct dwc3_exynos *exynos) 37static int dwc3_exynos_register_phys(struct dwc3_exynos *exynos)
37{ 38{
38 struct nop_usb_xceiv_platform_data pdata; 39 struct nop_usb_xceiv_platform_data pdata;
39 struct platform_device *pdev; 40 struct platform_device *pdev;
@@ -87,14 +88,14 @@ err1:
87 return ret; 88 return ret;
88} 89}
89 90
90static int __devinit dwc3_exynos_probe(struct platform_device *pdev) 91static u64 dwc3_exynos_dma_mask = DMA_BIT_MASK(32);
92
93static int dwc3_exynos_probe(struct platform_device *pdev)
91{ 94{
92 struct dwc3_exynos_data *pdata = pdev->dev.platform_data;
93 struct platform_device *dwc3; 95 struct platform_device *dwc3;
94 struct dwc3_exynos *exynos; 96 struct dwc3_exynos *exynos;
95 struct clk *clk; 97 struct clk *clk;
96 98
97 int devid;
98 int ret = -ENOMEM; 99 int ret = -ENOMEM;
99 100
100 exynos = kzalloc(sizeof(*exynos), GFP_KERNEL); 101 exynos = kzalloc(sizeof(*exynos), GFP_KERNEL);
@@ -103,11 +104,15 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev)
103 goto err0; 104 goto err0;
104 } 105 }
105 106
106 platform_set_drvdata(pdev, exynos); 107 /*
108 * Right now device-tree probed devices don't get dma_mask set.
109 * Since shared usb code relies on it, set it here for now.
110 * Once we move to full device tree support this will vanish off.
111 */
112 if (!pdev->dev.dma_mask)
113 pdev->dev.dma_mask = &dwc3_exynos_dma_mask;
107 114
108 devid = dwc3_get_device_id(); 115 platform_set_drvdata(pdev, exynos);
109 if (devid < 0)
110 goto err1;
111 116
112 ret = dwc3_exynos_register_phys(exynos); 117 ret = dwc3_exynos_register_phys(exynos);
113 if (ret) { 118 if (ret) {
@@ -115,10 +120,10 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev)
115 goto err1; 120 goto err1;
116 } 121 }
117 122
118 dwc3 = platform_device_alloc("dwc3", devid); 123 dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO);
119 if (!dwc3) { 124 if (!dwc3) {
120 dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); 125 dev_err(&pdev->dev, "couldn't allocate dwc3 device\n");
121 goto err2; 126 goto err1;
122 } 127 }
123 128
124 clk = clk_get(&pdev->dev, "usbdrd30"); 129 clk = clk_get(&pdev->dev, "usbdrd30");
@@ -139,14 +144,6 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev)
139 144
140 clk_enable(exynos->clk); 145 clk_enable(exynos->clk);
141 146
142 /* PHY initialization */
143 if (!pdata) {
144 dev_dbg(&pdev->dev, "missing platform data\n");
145 } else {
146 if (pdata->phy_init)
147 pdata->phy_init(pdev, pdata->phy_type);
148 }
149
150 ret = platform_device_add_resources(dwc3, pdev->resource, 147 ret = platform_device_add_resources(dwc3, pdev->resource,
151 pdev->num_resources); 148 pdev->num_resources);
152 if (ret) { 149 if (ret) {
@@ -163,35 +160,24 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev)
163 return 0; 160 return 0;
164 161
165err4: 162err4:
166 if (pdata && pdata->phy_exit)
167 pdata->phy_exit(pdev, pdata->phy_type);
168
169 clk_disable(clk); 163 clk_disable(clk);
170 clk_put(clk); 164 clk_put(clk);
171err3: 165err3:
172 platform_device_put(dwc3); 166 platform_device_put(dwc3);
173err2:
174 dwc3_put_device_id(devid);
175err1: 167err1:
176 kfree(exynos); 168 kfree(exynos);
177err0: 169err0:
178 return ret; 170 return ret;
179} 171}
180 172
181static int __devexit dwc3_exynos_remove(struct platform_device *pdev) 173static int dwc3_exynos_remove(struct platform_device *pdev)
182{ 174{
183 struct dwc3_exynos *exynos = platform_get_drvdata(pdev); 175 struct dwc3_exynos *exynos = platform_get_drvdata(pdev);
184 struct dwc3_exynos_data *pdata = pdev->dev.platform_data;
185 176
186 platform_device_unregister(exynos->dwc3); 177 platform_device_unregister(exynos->dwc3);
187 platform_device_unregister(exynos->usb2_phy); 178 platform_device_unregister(exynos->usb2_phy);
188 platform_device_unregister(exynos->usb3_phy); 179 platform_device_unregister(exynos->usb3_phy);
189 180
190 dwc3_put_device_id(exynos->dwc3->id);
191
192 if (pdata && pdata->phy_exit)
193 pdata->phy_exit(pdev, pdata->phy_type);
194
195 clk_disable(exynos->clk); 181 clk_disable(exynos->clk);
196 clk_put(exynos->clk); 182 clk_put(exynos->clk);
197 183
@@ -200,11 +186,20 @@ static int __devexit dwc3_exynos_remove(struct platform_device *pdev)
200 return 0; 186 return 0;
201} 187}
202 188
189#ifdef CONFIG_OF
190static const struct of_device_id exynos_dwc3_match[] = {
191 { .compatible = "samsung,exynos-dwc3" },
192 {},
193};
194MODULE_DEVICE_TABLE(of, exynos_dwc3_match);
195#endif
196
203static struct platform_driver dwc3_exynos_driver = { 197static struct platform_driver dwc3_exynos_driver = {
204 .probe = dwc3_exynos_probe, 198 .probe = dwc3_exynos_probe,
205 .remove = __devexit_p(dwc3_exynos_remove), 199 .remove = dwc3_exynos_remove,
206 .driver = { 200 .driver = {
207 .name = "exynos-dwc3", 201 .name = "exynos-dwc3",
202 .of_match_table = of_match_ptr(exynos_dwc3_match),
208 }, 203 },
209}; 204};
210 205
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index ee57a10d90d0..f31867fd2574 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -157,7 +157,7 @@ static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value)
157 writel(value, base + offset); 157 writel(value, base + offset);
158} 158}
159 159
160static int __devinit dwc3_omap_register_phys(struct dwc3_omap *omap) 160static int dwc3_omap_register_phys(struct dwc3_omap *omap)
161{ 161{
162 struct nop_usb_xceiv_platform_data pdata; 162 struct nop_usb_xceiv_platform_data pdata;
163 struct platform_device *pdev; 163 struct platform_device *pdev;
@@ -262,7 +262,7 @@ static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap)
262 return IRQ_HANDLED; 262 return IRQ_HANDLED;
263} 263}
264 264
265static int __devinit dwc3_omap_probe(struct platform_device *pdev) 265static int dwc3_omap_probe(struct platform_device *pdev)
266{ 266{
267 struct dwc3_omap_data *pdata = pdev->dev.platform_data; 267 struct dwc3_omap_data *pdata = pdev->dev.platform_data;
268 struct device_node *node = pdev->dev.of_node; 268 struct device_node *node = pdev->dev.of_node;
@@ -272,7 +272,6 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
272 struct resource *res; 272 struct resource *res;
273 struct device *dev = &pdev->dev; 273 struct device *dev = &pdev->dev;
274 274
275 int devid;
276 int size; 275 int size;
277 int ret = -ENOMEM; 276 int ret = -ENOMEM;
278 int irq; 277 int irq;
@@ -315,14 +314,10 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
315 return ret; 314 return ret;
316 } 315 }
317 316
318 devid = dwc3_get_device_id(); 317 dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO);
319 if (devid < 0)
320 return -ENODEV;
321
322 dwc3 = platform_device_alloc("dwc3", devid);
323 if (!dwc3) { 318 if (!dwc3) {
324 dev_err(dev, "couldn't allocate dwc3 device\n"); 319 dev_err(dev, "couldn't allocate dwc3 device\n");
325 goto err1; 320 return -ENOMEM;
326 } 321 }
327 322
328 context = devm_kzalloc(dev, resource_size(res), GFP_KERNEL); 323 context = devm_kzalloc(dev, resource_size(res), GFP_KERNEL);
@@ -423,23 +418,16 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
423 418
424err2: 419err2:
425 platform_device_put(dwc3); 420 platform_device_put(dwc3);
426
427err1:
428 dwc3_put_device_id(devid);
429
430 return ret; 421 return ret;
431} 422}
432 423
433static int __devexit dwc3_omap_remove(struct platform_device *pdev) 424static int dwc3_omap_remove(struct platform_device *pdev)
434{ 425{
435 struct dwc3_omap *omap = platform_get_drvdata(pdev); 426 struct dwc3_omap *omap = platform_get_drvdata(pdev);
436 427
437 platform_device_unregister(omap->dwc3); 428 platform_device_unregister(omap->dwc3);
438 platform_device_unregister(omap->usb2_phy); 429 platform_device_unregister(omap->usb2_phy);
439 platform_device_unregister(omap->usb3_phy); 430 platform_device_unregister(omap->usb3_phy);
440
441 dwc3_put_device_id(omap->dwc3->id);
442
443 return 0; 431 return 0;
444} 432}
445 433
@@ -453,7 +441,7 @@ MODULE_DEVICE_TABLE(of, of_dwc3_matach);
453 441
454static struct platform_driver dwc3_omap_driver = { 442static struct platform_driver dwc3_omap_driver = {
455 .probe = dwc3_omap_probe, 443 .probe = dwc3_omap_probe,
456 .remove = __devexit_p(dwc3_omap_remove), 444 .remove = dwc3_omap_remove,
457 .driver = { 445 .driver = {
458 .name = "omap-dwc3", 446 .name = "omap-dwc3",
459 .of_match_table = of_dwc3_matach, 447 .of_match_table = of_dwc3_matach,
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 94f550e37f98..7d70f44567d2 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -58,7 +58,7 @@ struct dwc3_pci {
58 struct platform_device *usb3_phy; 58 struct platform_device *usb3_phy;
59}; 59};
60 60
61static int __devinit dwc3_pci_register_phys(struct dwc3_pci *glue) 61static int dwc3_pci_register_phys(struct dwc3_pci *glue)
62{ 62{
63 struct nop_usb_xceiv_platform_data pdata; 63 struct nop_usb_xceiv_platform_data pdata;
64 struct platform_device *pdev; 64 struct platform_device *pdev;
@@ -112,14 +112,13 @@ err1:
112 return ret; 112 return ret;
113} 113}
114 114
115static int __devinit dwc3_pci_probe(struct pci_dev *pci, 115static int dwc3_pci_probe(struct pci_dev *pci,
116 const struct pci_device_id *id) 116 const struct pci_device_id *id)
117{ 117{
118 struct resource res[2]; 118 struct resource res[2];
119 struct platform_device *dwc3; 119 struct platform_device *dwc3;
120 struct dwc3_pci *glue; 120 struct dwc3_pci *glue;
121 int ret = -ENOMEM; 121 int ret = -ENOMEM;
122 int devid;
123 struct device *dev = &pci->dev; 122 struct device *dev = &pci->dev;
124 123
125 glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL); 124 glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL);
@@ -145,13 +144,7 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci,
145 return ret; 144 return ret;
146 } 145 }
147 146
148 devid = dwc3_get_device_id(); 147 dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO);
149 if (devid < 0) {
150 ret = -ENOMEM;
151 goto err1;
152 }
153
154 dwc3 = platform_device_alloc("dwc3", devid);
155 if (!dwc3) { 148 if (!dwc3) {
156 dev_err(dev, "couldn't allocate dwc3 device\n"); 149 dev_err(dev, "couldn't allocate dwc3 device\n");
157 ret = -ENOMEM; 150 ret = -ENOMEM;
@@ -172,7 +165,7 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci,
172 ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res)); 165 ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
173 if (ret) { 166 if (ret) {
174 dev_err(dev, "couldn't add resources to dwc3 device\n"); 167 dev_err(dev, "couldn't add resources to dwc3 device\n");
175 goto err2; 168 goto err1;
176 } 169 }
177 170
178 pci_set_drvdata(pci, glue); 171 pci_set_drvdata(pci, glue);
@@ -195,23 +188,18 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci,
195err3: 188err3:
196 pci_set_drvdata(pci, NULL); 189 pci_set_drvdata(pci, NULL);
197 platform_device_put(dwc3); 190 platform_device_put(dwc3);
198
199err2:
200 dwc3_put_device_id(devid);
201
202err1: 191err1:
203 pci_disable_device(pci); 192 pci_disable_device(pci);
204 193
205 return ret; 194 return ret;
206} 195}
207 196
208static void __devexit dwc3_pci_remove(struct pci_dev *pci) 197static void dwc3_pci_remove(struct pci_dev *pci)
209{ 198{
210 struct dwc3_pci *glue = pci_get_drvdata(pci); 199 struct dwc3_pci *glue = pci_get_drvdata(pci);
211 200
212 platform_device_unregister(glue->usb2_phy); 201 platform_device_unregister(glue->usb2_phy);
213 platform_device_unregister(glue->usb3_phy); 202 platform_device_unregister(glue->usb3_phy);
214 dwc3_put_device_id(glue->dwc3->id);
215 platform_device_unregister(glue->dwc3); 203 platform_device_unregister(glue->dwc3);
216 pci_set_drvdata(pci, NULL); 204 pci_set_drvdata(pci, NULL);
217 pci_disable_device(pci); 205 pci_disable_device(pci);
@@ -230,7 +218,7 @@ static struct pci_driver dwc3_pci_driver = {
230 .name = "dwc3-pci", 218 .name = "dwc3-pci",
231 .id_table = dwc3_pci_id_table, 219 .id_table = dwc3_pci_id_table,
232 .probe = dwc3_pci_probe, 220 .probe = dwc3_pci_probe,
233 .remove = __devexit_p(dwc3_pci_remove), 221 .remove = dwc3_pci_remove,
234}; 222};
235 223
236MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); 224MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 7b7deddf6a52..2e43b332aae8 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1579,7 +1579,7 @@ static const struct usb_gadget_ops dwc3_gadget_ops = {
1579 1579
1580/* -------------------------------------------------------------------------- */ 1580/* -------------------------------------------------------------------------- */
1581 1581
1582static int __devinit dwc3_gadget_init_endpoints(struct dwc3 *dwc) 1582static int dwc3_gadget_init_endpoints(struct dwc3 *dwc)
1583{ 1583{
1584 struct dwc3_ep *dep; 1584 struct dwc3_ep *dep;
1585 u8 epnum; 1585 u8 epnum;
@@ -2374,7 +2374,7 @@ static irqreturn_t dwc3_interrupt(int irq, void *_dwc)
2374 * 2374 *
2375 * Returns 0 on success otherwise negative errno. 2375 * Returns 0 on success otherwise negative errno.
2376 */ 2376 */
2377int __devinit dwc3_gadget_init(struct dwc3 *dwc) 2377int dwc3_gadget_init(struct dwc3 *dwc)
2378{ 2378{
2379 u32 reg; 2379 u32 reg;
2380 int ret; 2380 int ret;
diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
index 4bfa78af379c..5e29ddeb4d33 100644
--- a/drivers/usb/early/ehci-dbgp.c
+++ b/drivers/usb/early/ehci-dbgp.c
@@ -974,7 +974,7 @@ struct console early_dbgp_console = {
974 .index = -1, 974 .index = -1,
975}; 975};
976 976
977#if IS_ENABLED(CONFIG_USB_EHCI_HCD) 977#if IS_ENABLED(CONFIG_USB)
978int dbgp_reset_prep(struct usb_hcd *hcd) 978int dbgp_reset_prep(struct usb_hcd *hcd)
979{ 979{
980 int ret = xen_dbgp_reset_prep(hcd); 980 int ret = xen_dbgp_reset_prep(hcd);
@@ -1008,7 +1008,7 @@ int dbgp_external_startup(struct usb_hcd *hcd)
1008 return xen_dbgp_external_startup(hcd) ?: _dbgp_external_startup(); 1008 return xen_dbgp_external_startup(hcd) ?: _dbgp_external_startup();
1009} 1009}
1010EXPORT_SYMBOL_GPL(dbgp_external_startup); 1010EXPORT_SYMBOL_GPL(dbgp_external_startup);
1011#endif /* USB_EHCI_HCD */ 1011#endif /* USB */
1012 1012
1013#ifdef CONFIG_KGDB 1013#ifdef CONFIG_KGDB
1014 1014
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index e0ff51b89529..14625fd2cecd 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -721,31 +721,6 @@ config USB_FUNCTIONFS_GENERIC
721 Include a configuration with the Function Filesystem alone with 721 Include a configuration with the Function Filesystem alone with
722 no Ethernet interface. 722 no Ethernet interface.
723 723
724config USB_FILE_STORAGE
725 tristate "File-backed Storage Gadget (DEPRECATED)"
726 depends on BLOCK
727 help
728 The File-backed Storage Gadget acts as a USB Mass Storage
729 disk drive. As its storage repository it can use a regular
730 file or a block device (in much the same way as the "loop"
731 device driver), specified as a module parameter.
732
733 Say "y" to link the driver statically, or "m" to build a
734 dynamically linked module called "g_file_storage".
735
736 NOTE: This driver is deprecated. Its replacement is the
737 Mass Storage Gadget.
738
739config USB_FILE_STORAGE_TEST
740 bool "File-backed Storage Gadget testing version"
741 depends on USB_FILE_STORAGE
742 default n
743 help
744 Say "y" to generate the larger testing version of the
745 File-backed Storage Gadget, useful for probing the
746 behavior of USB Mass Storage hosts. Not needed for
747 normal operation.
748
749config USB_MASS_STORAGE 724config USB_MASS_STORAGE
750 tristate "Mass Storage Gadget" 725 tristate "Mass Storage Gadget"
751 depends on BLOCK 726 depends on BLOCK
@@ -756,8 +731,8 @@ config USB_MASS_STORAGE
756 device (in much the same way as the "loop" device driver), 731 device (in much the same way as the "loop" device driver),
757 specified as a module parameter or sysfs option. 732 specified as a module parameter or sysfs option.
758 733
759 This driver is an updated replacement for the deprecated 734 This driver is a replacement for now removed File-backed
760 File-backed Storage Gadget (g_file_storage). 735 Storage Gadget (g_file_storage).
761 736
762 Say "y" to link the driver statically, or "m" to build 737 Say "y" to link the driver statically, or "m" to build
763 a dynamically linked module called "g_mass_storage". 738 a dynamically linked module called "g_mass_storage".
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 307be5fa824c..8b4acfd92aa3 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -44,7 +44,6 @@ g_ether-y := ether.o
44g_serial-y := serial.o 44g_serial-y := serial.o
45g_midi-y := gmidi.o 45g_midi-y := gmidi.o
46gadgetfs-y := inode.o 46gadgetfs-y := inode.o
47g_file_storage-y := file_storage.o
48g_mass_storage-y := mass_storage.o 47g_mass_storage-y := mass_storage.o
49g_printer-y := printer.o 48g_printer-y := printer.o
50g_cdc-y := cdc2.o 49g_cdc-y := cdc2.o
@@ -62,7 +61,6 @@ obj-$(CONFIG_USB_AUDIO) += g_audio.o
62obj-$(CONFIG_USB_ETH) += g_ether.o 61obj-$(CONFIG_USB_ETH) += g_ether.o
63obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o 62obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o
64obj-$(CONFIG_USB_FUNCTIONFS) += g_ffs.o 63obj-$(CONFIG_USB_FUNCTIONFS) += g_ffs.o
65obj-$(CONFIG_USB_FILE_STORAGE) += g_file_storage.o
66obj-$(CONFIG_USB_MASS_STORAGE) += g_mass_storage.o 64obj-$(CONFIG_USB_MASS_STORAGE) += g_mass_storage.o
67obj-$(CONFIG_USB_G_SERIAL) += g_serial.o 65obj-$(CONFIG_USB_G_SERIAL) += g_serial.o
68obj-$(CONFIG_USB_G_PRINTER) += g_printer.o 66obj-$(CONFIG_USB_G_PRINTER) += g_printer.o
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 89d90b5fb787..e6135faabc3a 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1673,7 +1673,7 @@ static void at91udc_shutdown(struct platform_device *dev)
1673 spin_unlock_irqrestore(&udc->lock, flags); 1673 spin_unlock_irqrestore(&udc->lock, flags);
1674} 1674}
1675 1675
1676static void __devinit at91udc_of_init(struct at91_udc *udc, 1676static void at91udc_of_init(struct at91_udc *udc,
1677 struct device_node *np) 1677 struct device_node *np)
1678{ 1678{
1679 struct at91_udc_data *board = &udc->board; 1679 struct at91_udc_data *board = &udc->board;
@@ -1693,7 +1693,7 @@ static void __devinit at91udc_of_init(struct at91_udc *udc,
1693 board->pullup_active_low = (flags & OF_GPIO_ACTIVE_LOW) ? 1 : 0; 1693 board->pullup_active_low = (flags & OF_GPIO_ACTIVE_LOW) ? 1 : 0;
1694} 1694}
1695 1695
1696static int __devinit at91udc_probe(struct platform_device *pdev) 1696static int at91udc_probe(struct platform_device *pdev)
1697{ 1697{
1698 struct device *dev = &pdev->dev; 1698 struct device *dev = &pdev->dev;
1699 struct at91_udc *udc; 1699 struct at91_udc *udc;
diff --git a/drivers/usb/gadget/bcm63xx_udc.c b/drivers/usb/gadget/bcm63xx_udc.c
index 9ca792224cd4..47a49931361e 100644
--- a/drivers/usb/gadget/bcm63xx_udc.c
+++ b/drivers/usb/gadget/bcm63xx_udc.c
@@ -2323,7 +2323,7 @@ static void bcm63xx_udc_gadget_release(struct device *dev)
2323 * Note that platform data is required, because pd.port_no varies from chip 2323 * Note that platform data is required, because pd.port_no varies from chip
2324 * to chip and is used to switch the correct USB port to device mode. 2324 * to chip and is used to switch the correct USB port to device mode.
2325 */ 2325 */
2326static int __devinit bcm63xx_udc_probe(struct platform_device *pdev) 2326static int bcm63xx_udc_probe(struct platform_device *pdev)
2327{ 2327{
2328 struct device *dev = &pdev->dev; 2328 struct device *dev = &pdev->dev;
2329 struct bcm63xx_usbd_platform_data *pd = dev->platform_data; 2329 struct bcm63xx_usbd_platform_data *pd = dev->platform_data;
@@ -2433,7 +2433,7 @@ out_uninit:
2433 * bcm63xx_udc_remove - Remove the device from the system. 2433 * bcm63xx_udc_remove - Remove the device from the system.
2434 * @pdev: Platform device struct from the bcm63xx BSP code. 2434 * @pdev: Platform device struct from the bcm63xx BSP code.
2435 */ 2435 */
2436static int __devexit bcm63xx_udc_remove(struct platform_device *pdev) 2436static int bcm63xx_udc_remove(struct platform_device *pdev)
2437{ 2437{
2438 struct bcm63xx_udc *udc = platform_get_drvdata(pdev); 2438 struct bcm63xx_udc *udc = platform_get_drvdata(pdev);
2439 2439
@@ -2450,7 +2450,7 @@ static int __devexit bcm63xx_udc_remove(struct platform_device *pdev)
2450 2450
2451static struct platform_driver bcm63xx_udc_driver = { 2451static struct platform_driver bcm63xx_udc_driver = {
2452 .probe = bcm63xx_udc_probe, 2452 .probe = bcm63xx_udc_probe,
2453 .remove = __devexit_p(bcm63xx_udc_remove), 2453 .remove = bcm63xx_udc_remove,
2454 .driver = { 2454 .driver = {
2455 .name = DRV_MODULE_NAME, 2455 .name = DRV_MODULE_NAME,
2456 .owner = THIS_MODULE, 2456 .owner = THIS_MODULE,
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 957f973dd96a..2a6bfe759c29 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -107,7 +107,7 @@ int config_ep_by_speed(struct usb_gadget *g,
107 } 107 }
108 /* else: fall through */ 108 /* else: fall through */
109 default: 109 default:
110 speed_desc = f->descriptors; 110 speed_desc = f->fs_descriptors;
111 } 111 }
112 /* find descriptors */ 112 /* find descriptors */
113 for_each_ep_desc(speed_desc, d_spd) { 113 for_each_ep_desc(speed_desc, d_spd) {
@@ -200,7 +200,7 @@ int usb_add_function(struct usb_configuration *config,
200 * as full speed ... it's the function drivers that will need 200 * as full speed ... it's the function drivers that will need
201 * to avoid bulk and ISO transfers. 201 * to avoid bulk and ISO transfers.
202 */ 202 */
203 if (!config->fullspeed && function->descriptors) 203 if (!config->fullspeed && function->fs_descriptors)
204 config->fullspeed = true; 204 config->fullspeed = true;
205 if (!config->highspeed && function->hs_descriptors) 205 if (!config->highspeed && function->hs_descriptors)
206 config->highspeed = true; 206 config->highspeed = true;
@@ -363,7 +363,7 @@ static int config_buf(struct usb_configuration *config,
363 descriptors = f->hs_descriptors; 363 descriptors = f->hs_descriptors;
364 break; 364 break;
365 default: 365 default:
366 descriptors = f->descriptors; 366 descriptors = f->fs_descriptors;
367 } 367 }
368 368
369 if (!descriptors) 369 if (!descriptors)
@@ -620,7 +620,7 @@ static int set_config(struct usb_composite_dev *cdev,
620 descriptors = f->hs_descriptors; 620 descriptors = f->hs_descriptors;
621 break; 621 break;
622 default: 622 default:
623 descriptors = f->descriptors; 623 descriptors = f->fs_descriptors;
624 } 624 }
625 625
626 for (; *descriptors; ++descriptors) { 626 for (; *descriptors; ++descriptors) {
diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
index e3a98929d346..34e12fc52c23 100644
--- a/drivers/usb/gadget/config.c
+++ b/drivers/usb/gadget/config.c
@@ -19,7 +19,7 @@
19 19
20#include <linux/usb/ch9.h> 20#include <linux/usb/ch9.h>
21#include <linux/usb/gadget.h> 21#include <linux/usb/gadget.h>
22 22#include <linux/usb/composite.h>
23 23
24/** 24/**
25 * usb_descriptor_fillbuf - fill buffer with descriptors 25 * usb_descriptor_fillbuf - fill buffer with descriptors
@@ -158,3 +158,40 @@ usb_copy_descriptors(struct usb_descriptor_header **src)
158 return ret; 158 return ret;
159} 159}
160EXPORT_SYMBOL_GPL(usb_copy_descriptors); 160EXPORT_SYMBOL_GPL(usb_copy_descriptors);
161
162int usb_assign_descriptors(struct usb_function *f,
163 struct usb_descriptor_header **fs,
164 struct usb_descriptor_header **hs,
165 struct usb_descriptor_header **ss)
166{
167 struct usb_gadget *g = f->config->cdev->gadget;
168
169 if (fs) {
170 f->fs_descriptors = usb_copy_descriptors(fs);
171 if (!f->fs_descriptors)
172 goto err;
173 }
174 if (hs && gadget_is_dualspeed(g)) {
175 f->hs_descriptors = usb_copy_descriptors(hs);
176 if (!f->hs_descriptors)
177 goto err;
178 }
179 if (ss && gadget_is_superspeed(g)) {
180 f->ss_descriptors = usb_copy_descriptors(ss);
181 if (!f->ss_descriptors)
182 goto err;
183 }
184 return 0;
185err:
186 usb_free_all_descriptors(f);
187 return -ENOMEM;
188}
189EXPORT_SYMBOL_GPL(usb_assign_descriptors);
190
191void usb_free_all_descriptors(struct usb_function *f)
192{
193 usb_free_descriptors(f->fs_descriptors);
194 usb_free_descriptors(f->hs_descriptors);
195 usb_free_descriptors(f->ss_descriptors);
196}
197EXPORT_SYMBOL_GPL(usb_free_all_descriptors);
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index 0f7541be28f3..95d584dbed13 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -63,16 +63,20 @@ MODULE_LICENSE("GPL");
63struct dummy_hcd_module_parameters { 63struct dummy_hcd_module_parameters {
64 bool is_super_speed; 64 bool is_super_speed;
65 bool is_high_speed; 65 bool is_high_speed;
66 unsigned int num;
66}; 67};
67 68
68static struct dummy_hcd_module_parameters mod_data = { 69static struct dummy_hcd_module_parameters mod_data = {
69 .is_super_speed = false, 70 .is_super_speed = false,
70 .is_high_speed = true, 71 .is_high_speed = true,
72 .num = 1,
71}; 73};
72module_param_named(is_super_speed, mod_data.is_super_speed, bool, S_IRUGO); 74module_param_named(is_super_speed, mod_data.is_super_speed, bool, S_IRUGO);
73MODULE_PARM_DESC(is_super_speed, "true to simulate SuperSpeed connection"); 75MODULE_PARM_DESC(is_super_speed, "true to simulate SuperSpeed connection");
74module_param_named(is_high_speed, mod_data.is_high_speed, bool, S_IRUGO); 76module_param_named(is_high_speed, mod_data.is_high_speed, bool, S_IRUGO);
75MODULE_PARM_DESC(is_high_speed, "true to simulate HighSpeed connection"); 77MODULE_PARM_DESC(is_high_speed, "true to simulate HighSpeed connection");
78module_param_named(num, mod_data.num, uint, S_IRUGO);
79MODULE_PARM_DESC(num, "number of emulated controllers");
76/*-------------------------------------------------------------------------*/ 80/*-------------------------------------------------------------------------*/
77 81
78/* gadget side driver data structres */ 82/* gadget side driver data structres */
@@ -238,8 +242,6 @@ static inline struct dummy *gadget_dev_to_dummy(struct device *dev)
238 return container_of(dev, struct dummy, gadget.dev); 242 return container_of(dev, struct dummy, gadget.dev);
239} 243}
240 244
241static struct dummy the_controller;
242
243/*-------------------------------------------------------------------------*/ 245/*-------------------------------------------------------------------------*/
244 246
245/* SLAVE/GADGET SIDE UTILITY ROUTINES */ 247/* SLAVE/GADGET SIDE UTILITY ROUTINES */
@@ -973,9 +975,10 @@ static void init_dummy_udc_hw(struct dummy *dum)
973 975
974static int dummy_udc_probe(struct platform_device *pdev) 976static int dummy_udc_probe(struct platform_device *pdev)
975{ 977{
976 struct dummy *dum = &the_controller; 978 struct dummy *dum;
977 int rc; 979 int rc;
978 980
981 dum = *((void **)dev_get_platdata(&pdev->dev));
979 dum->gadget.name = gadget_name; 982 dum->gadget.name = gadget_name;
980 dum->gadget.ops = &dummy_ops; 983 dum->gadget.ops = &dummy_ops;
981 dum->gadget.max_speed = USB_SPEED_SUPER; 984 dum->gadget.max_speed = USB_SPEED_SUPER;
@@ -2398,10 +2401,13 @@ static int dummy_h_get_frame(struct usb_hcd *hcd)
2398 2401
2399static int dummy_setup(struct usb_hcd *hcd) 2402static int dummy_setup(struct usb_hcd *hcd)
2400{ 2403{
2404 struct dummy *dum;
2405
2406 dum = *((void **)dev_get_platdata(hcd->self.controller));
2401 hcd->self.sg_tablesize = ~0; 2407 hcd->self.sg_tablesize = ~0;
2402 if (usb_hcd_is_primary_hcd(hcd)) { 2408 if (usb_hcd_is_primary_hcd(hcd)) {
2403 the_controller.hs_hcd = hcd_to_dummy_hcd(hcd); 2409 dum->hs_hcd = hcd_to_dummy_hcd(hcd);
2404 the_controller.hs_hcd->dum = &the_controller; 2410 dum->hs_hcd->dum = dum;
2405 /* 2411 /*
2406 * Mark the first roothub as being USB 2.0. 2412 * Mark the first roothub as being USB 2.0.
2407 * The USB 3.0 roothub will be registered later by 2413 * The USB 3.0 roothub will be registered later by
@@ -2410,8 +2416,8 @@ static int dummy_setup(struct usb_hcd *hcd)
2410 hcd->speed = HCD_USB2; 2416 hcd->speed = HCD_USB2;
2411 hcd->self.root_hub->speed = USB_SPEED_HIGH; 2417 hcd->self.root_hub->speed = USB_SPEED_HIGH;
2412 } else { 2418 } else {
2413 the_controller.ss_hcd = hcd_to_dummy_hcd(hcd); 2419 dum->ss_hcd = hcd_to_dummy_hcd(hcd);
2414 the_controller.ss_hcd->dum = &the_controller; 2420 dum->ss_hcd->dum = dum;
2415 hcd->speed = HCD_USB3; 2421 hcd->speed = HCD_USB3;
2416 hcd->self.root_hub->speed = USB_SPEED_SUPER; 2422 hcd->self.root_hub->speed = USB_SPEED_SUPER;
2417 } 2423 }
@@ -2524,11 +2530,13 @@ static struct hc_driver dummy_hcd = {
2524 2530
2525static int dummy_hcd_probe(struct platform_device *pdev) 2531static int dummy_hcd_probe(struct platform_device *pdev)
2526{ 2532{
2533 struct dummy *dum;
2527 struct usb_hcd *hs_hcd; 2534 struct usb_hcd *hs_hcd;
2528 struct usb_hcd *ss_hcd; 2535 struct usb_hcd *ss_hcd;
2529 int retval; 2536 int retval;
2530 2537
2531 dev_info(&pdev->dev, "%s, driver " DRIVER_VERSION "\n", driver_desc); 2538 dev_info(&pdev->dev, "%s, driver " DRIVER_VERSION "\n", driver_desc);
2539 dum = *((void **)dev_get_platdata(&pdev->dev));
2532 2540
2533 if (!mod_data.is_super_speed) 2541 if (!mod_data.is_super_speed)
2534 dummy_hcd.flags = HCD_USB2; 2542 dummy_hcd.flags = HCD_USB2;
@@ -2561,7 +2569,7 @@ dealloc_usb2_hcd:
2561 usb_remove_hcd(hs_hcd); 2569 usb_remove_hcd(hs_hcd);
2562put_usb2_hcd: 2570put_usb2_hcd:
2563 usb_put_hcd(hs_hcd); 2571 usb_put_hcd(hs_hcd);
2564 the_controller.hs_hcd = the_controller.ss_hcd = NULL; 2572 dum->hs_hcd = dum->ss_hcd = NULL;
2565 return retval; 2573 return retval;
2566} 2574}
2567 2575
@@ -2579,8 +2587,8 @@ static int dummy_hcd_remove(struct platform_device *pdev)
2579 usb_remove_hcd(dummy_hcd_to_hcd(dum->hs_hcd)); 2587 usb_remove_hcd(dummy_hcd_to_hcd(dum->hs_hcd));
2580 usb_put_hcd(dummy_hcd_to_hcd(dum->hs_hcd)); 2588 usb_put_hcd(dummy_hcd_to_hcd(dum->hs_hcd));
2581 2589
2582 the_controller.hs_hcd = NULL; 2590 dum->hs_hcd = NULL;
2583 the_controller.ss_hcd = NULL; 2591 dum->ss_hcd = NULL;
2584 2592
2585 return 0; 2593 return 0;
2586} 2594}
@@ -2627,13 +2635,15 @@ static struct platform_driver dummy_hcd_driver = {
2627}; 2635};
2628 2636
2629/*-------------------------------------------------------------------------*/ 2637/*-------------------------------------------------------------------------*/
2630 2638#define MAX_NUM_UDC 2
2631static struct platform_device *the_udc_pdev; 2639static struct platform_device *the_udc_pdev[MAX_NUM_UDC];
2632static struct platform_device *the_hcd_pdev; 2640static struct platform_device *the_hcd_pdev[MAX_NUM_UDC];
2633 2641
2634static int __init init(void) 2642static int __init init(void)
2635{ 2643{
2636 int retval = -ENOMEM; 2644 int retval = -ENOMEM;
2645 int i;
2646 struct dummy *dum[MAX_NUM_UDC];
2637 2647
2638 if (usb_disabled()) 2648 if (usb_disabled())
2639 return -ENODEV; 2649 return -ENODEV;
@@ -2641,65 +2651,129 @@ static int __init init(void)
2641 if (!mod_data.is_high_speed && mod_data.is_super_speed) 2651 if (!mod_data.is_high_speed && mod_data.is_super_speed)
2642 return -EINVAL; 2652 return -EINVAL;
2643 2653
2644 the_hcd_pdev = platform_device_alloc(driver_name, -1); 2654 if (mod_data.num < 1 || mod_data.num > MAX_NUM_UDC) {
2645 if (!the_hcd_pdev) 2655 pr_err("Number of emulated UDC must be in range of 1…%d\n",
2646 return retval; 2656 MAX_NUM_UDC);
2647 the_udc_pdev = platform_device_alloc(gadget_name, -1); 2657 return -EINVAL;
2648 if (!the_udc_pdev) 2658 }
2649 goto err_alloc_udc; 2659
2660 for (i = 0; i < mod_data.num; i++) {
2661 the_hcd_pdev[i] = platform_device_alloc(driver_name, i);
2662 if (!the_hcd_pdev[i]) {
2663 i--;
2664 while (i >= 0)
2665 platform_device_put(the_hcd_pdev[i--]);
2666 return retval;
2667 }
2668 }
2669 for (i = 0; i < mod_data.num; i++) {
2670 the_udc_pdev[i] = platform_device_alloc(gadget_name, i);
2671 if (!the_udc_pdev[i]) {
2672 i--;
2673 while (i >= 0)
2674 platform_device_put(the_udc_pdev[i--]);
2675 goto err_alloc_udc;
2676 }
2677 }
2678 for (i = 0; i < mod_data.num; i++) {
2679 dum[i] = kzalloc(sizeof(struct dummy), GFP_KERNEL);
2680 if (!dum[i])
2681 goto err_add_pdata;
2682 retval = platform_device_add_data(the_hcd_pdev[i], &dum[i],
2683 sizeof(void *));
2684 if (retval)
2685 goto err_add_pdata;
2686 retval = platform_device_add_data(the_udc_pdev[i], &dum[i],
2687 sizeof(void *));
2688 if (retval)
2689 goto err_add_pdata;
2690 }
2650 2691
2651 retval = platform_driver_register(&dummy_hcd_driver); 2692 retval = platform_driver_register(&dummy_hcd_driver);
2652 if (retval < 0) 2693 if (retval < 0)
2653 goto err_register_hcd_driver; 2694 goto err_add_pdata;
2654 retval = platform_driver_register(&dummy_udc_driver); 2695 retval = platform_driver_register(&dummy_udc_driver);
2655 if (retval < 0) 2696 if (retval < 0)
2656 goto err_register_udc_driver; 2697 goto err_register_udc_driver;
2657 2698
2658 retval = platform_device_add(the_hcd_pdev); 2699 for (i = 0; i < mod_data.num; i++) {
2659 if (retval < 0) 2700 retval = platform_device_add(the_hcd_pdev[i]);
2660 goto err_add_hcd; 2701 if (retval < 0) {
2661 if (!the_controller.hs_hcd || 2702 i--;
2662 (!the_controller.ss_hcd && mod_data.is_super_speed)) { 2703 while (i >= 0)
2663 /* 2704 platform_device_del(the_hcd_pdev[i--]);
2664 * The hcd was added successfully but its probe function failed 2705 goto err_add_hcd;
2665 * for some reason. 2706 }
2666 */
2667 retval = -EINVAL;
2668 goto err_add_udc;
2669 } 2707 }
2670 retval = platform_device_add(the_udc_pdev); 2708 for (i = 0; i < mod_data.num; i++) {
2671 if (retval < 0) 2709 if (!dum[i]->hs_hcd ||
2672 goto err_add_udc; 2710 (!dum[i]->ss_hcd && mod_data.is_super_speed)) {
2673 if (!platform_get_drvdata(the_udc_pdev)) { 2711 /*
2674 /* 2712 * The hcd was added successfully but its probe
2675 * The udc was added successfully but its probe function failed 2713 * function failed for some reason.
2676 * for some reason. 2714 */
2677 */ 2715 retval = -EINVAL;
2678 retval = -EINVAL; 2716 goto err_add_udc;
2679 goto err_probe_udc; 2717 }
2718 }
2719
2720 for (i = 0; i < mod_data.num; i++) {
2721 retval = platform_device_add(the_udc_pdev[i]);
2722 if (retval < 0) {
2723 i--;
2724 while (i >= 0)
2725 platform_device_del(the_udc_pdev[i]);
2726 goto err_add_udc;
2727 }
2728 }
2729
2730 for (i = 0; i < mod_data.num; i++) {
2731 if (!platform_get_drvdata(the_udc_pdev[i])) {
2732 /*
2733 * The udc was added successfully but its probe
2734 * function failed for some reason.
2735 */
2736 retval = -EINVAL;
2737 goto err_probe_udc;
2738 }
2680 } 2739 }
2681 return retval; 2740 return retval;
2682 2741
2683err_probe_udc: 2742err_probe_udc:
2684 platform_device_del(the_udc_pdev); 2743 for (i = 0; i < mod_data.num; i++)
2744 platform_device_del(the_udc_pdev[i]);
2685err_add_udc: 2745err_add_udc:
2686 platform_device_del(the_hcd_pdev); 2746 for (i = 0; i < mod_data.num; i++)
2747 platform_device_del(the_hcd_pdev[i]);
2687err_add_hcd: 2748err_add_hcd:
2688 platform_driver_unregister(&dummy_udc_driver); 2749 platform_driver_unregister(&dummy_udc_driver);
2689err_register_udc_driver: 2750err_register_udc_driver:
2690 platform_driver_unregister(&dummy_hcd_driver); 2751 platform_driver_unregister(&dummy_hcd_driver);
2691err_register_hcd_driver: 2752err_add_pdata:
2692 platform_device_put(the_udc_pdev); 2753 for (i = 0; i < mod_data.num; i++)
2754 kfree(dum[i]);
2755 for (i = 0; i < mod_data.num; i++)
2756 platform_device_put(the_udc_pdev[i]);
2693err_alloc_udc: 2757err_alloc_udc:
2694 platform_device_put(the_hcd_pdev); 2758 for (i = 0; i < mod_data.num; i++)
2759 platform_device_put(the_hcd_pdev[i]);
2695 return retval; 2760 return retval;
2696} 2761}
2697module_init(init); 2762module_init(init);
2698 2763
2699static void __exit cleanup(void) 2764static void __exit cleanup(void)
2700{ 2765{
2701 platform_device_unregister(the_udc_pdev); 2766 int i;
2702 platform_device_unregister(the_hcd_pdev); 2767
2768 for (i = 0; i < mod_data.num; i++) {
2769 struct dummy *dum;
2770
2771 dum = *((void **)dev_get_platdata(&the_udc_pdev[i]->dev));
2772
2773 platform_device_unregister(the_udc_pdev[i]);
2774 platform_device_unregister(the_hcd_pdev[i]);
2775 kfree(dum);
2776 }
2703 platform_driver_unregister(&dummy_udc_driver); 2777 platform_driver_unregister(&dummy_udc_driver);
2704 platform_driver_unregister(&dummy_hcd_driver); 2778 platform_driver_unregister(&dummy_hcd_driver);
2705} 2779}
diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c
index d672250a61fa..549174466c21 100644
--- a/drivers/usb/gadget/f_acm.c
+++ b/drivers/usb/gadget/f_acm.c
@@ -87,7 +87,7 @@ static inline struct f_acm *port_to_acm(struct gserial *p)
87 87
88/* notification endpoint uses smallish and infrequent fixed-size messages */ 88/* notification endpoint uses smallish and infrequent fixed-size messages */
89 89
90#define GS_LOG2_NOTIFY_INTERVAL 5 /* 1 << 5 == 32 msec */ 90#define GS_NOTIFY_INTERVAL_MS 32
91#define GS_NOTIFY_MAXPACKET 10 /* notification + 2 bytes */ 91#define GS_NOTIFY_MAXPACKET 10 /* notification + 2 bytes */
92 92
93/* interface and class descriptors: */ 93/* interface and class descriptors: */
@@ -167,7 +167,7 @@ static struct usb_endpoint_descriptor acm_fs_notify_desc = {
167 .bEndpointAddress = USB_DIR_IN, 167 .bEndpointAddress = USB_DIR_IN,
168 .bmAttributes = USB_ENDPOINT_XFER_INT, 168 .bmAttributes = USB_ENDPOINT_XFER_INT,
169 .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET), 169 .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET),
170 .bInterval = 1 << GS_LOG2_NOTIFY_INTERVAL, 170 .bInterval = GS_NOTIFY_INTERVAL_MS,
171}; 171};
172 172
173static struct usb_endpoint_descriptor acm_fs_in_desc = { 173static struct usb_endpoint_descriptor acm_fs_in_desc = {
@@ -199,14 +199,13 @@ static struct usb_descriptor_header *acm_fs_function[] = {
199}; 199};
200 200
201/* high speed support: */ 201/* high speed support: */
202
203static struct usb_endpoint_descriptor acm_hs_notify_desc = { 202static struct usb_endpoint_descriptor acm_hs_notify_desc = {
204 .bLength = USB_DT_ENDPOINT_SIZE, 203 .bLength = USB_DT_ENDPOINT_SIZE,
205 .bDescriptorType = USB_DT_ENDPOINT, 204 .bDescriptorType = USB_DT_ENDPOINT,
206 .bEndpointAddress = USB_DIR_IN, 205 .bEndpointAddress = USB_DIR_IN,
207 .bmAttributes = USB_ENDPOINT_XFER_INT, 206 .bmAttributes = USB_ENDPOINT_XFER_INT,
208 .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET), 207 .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET),
209 .bInterval = GS_LOG2_NOTIFY_INTERVAL+4, 208 .bInterval = USB_MS_TO_HS_INTERVAL(GS_NOTIFY_INTERVAL_MS),
210}; 209};
211 210
212static struct usb_endpoint_descriptor acm_hs_in_desc = { 211static struct usb_endpoint_descriptor acm_hs_in_desc = {
@@ -659,37 +658,22 @@ acm_bind(struct usb_configuration *c, struct usb_function *f)
659 acm->notify_req->complete = acm_cdc_notify_complete; 658 acm->notify_req->complete = acm_cdc_notify_complete;
660 acm->notify_req->context = acm; 659 acm->notify_req->context = acm;
661 660
662 /* copy descriptors */
663 f->descriptors = usb_copy_descriptors(acm_fs_function);
664 if (!f->descriptors)
665 goto fail;
666
667 /* support all relevant hardware speeds... we expect that when 661 /* support all relevant hardware speeds... we expect that when
668 * hardware is dual speed, all bulk-capable endpoints work at 662 * hardware is dual speed, all bulk-capable endpoints work at
669 * both speeds 663 * both speeds
670 */ 664 */
671 if (gadget_is_dualspeed(c->cdev->gadget)) { 665 acm_hs_in_desc.bEndpointAddress = acm_fs_in_desc.bEndpointAddress;
672 acm_hs_in_desc.bEndpointAddress = 666 acm_hs_out_desc.bEndpointAddress = acm_fs_out_desc.bEndpointAddress;
673 acm_fs_in_desc.bEndpointAddress; 667 acm_hs_notify_desc.bEndpointAddress =
674 acm_hs_out_desc.bEndpointAddress = 668 acm_fs_notify_desc.bEndpointAddress;
675 acm_fs_out_desc.bEndpointAddress; 669
676 acm_hs_notify_desc.bEndpointAddress = 670 acm_ss_in_desc.bEndpointAddress = acm_fs_in_desc.bEndpointAddress;
677 acm_fs_notify_desc.bEndpointAddress; 671 acm_ss_out_desc.bEndpointAddress = acm_fs_out_desc.bEndpointAddress;
678 672
679 /* copy descriptors */ 673 status = usb_assign_descriptors(f, acm_fs_function, acm_hs_function,
680 f->hs_descriptors = usb_copy_descriptors(acm_hs_function); 674 acm_ss_function);
681 } 675 if (status)
682 if (gadget_is_superspeed(c->cdev->gadget)) { 676 goto fail;
683 acm_ss_in_desc.bEndpointAddress =
684 acm_fs_in_desc.bEndpointAddress;
685 acm_ss_out_desc.bEndpointAddress =
686 acm_fs_out_desc.bEndpointAddress;
687
688 /* copy descriptors, and track endpoint copies */
689 f->ss_descriptors = usb_copy_descriptors(acm_ss_function);
690 if (!f->ss_descriptors)
691 goto fail;
692 }
693 677
694 DBG(cdev, "acm ttyGS%d: %s speed IN/%s OUT/%s NOTIFY/%s\n", 678 DBG(cdev, "acm ttyGS%d: %s speed IN/%s OUT/%s NOTIFY/%s\n",
695 acm->port_num, 679 acm->port_num,
@@ -721,11 +705,8 @@ acm_unbind(struct usb_configuration *c, struct usb_function *f)
721{ 705{
722 struct f_acm *acm = func_to_acm(f); 706 struct f_acm *acm = func_to_acm(f);
723 707
724 if (gadget_is_dualspeed(c->cdev->gadget)) 708 acm_string_defs[0].id = 0;
725 usb_free_descriptors(f->hs_descriptors); 709 usb_free_all_descriptors(f);
726 if (gadget_is_superspeed(c->cdev->gadget))
727 usb_free_descriptors(f->ss_descriptors);
728 usb_free_descriptors(f->descriptors);
729 gs_free_req(acm->notify, acm->notify_req); 710 gs_free_req(acm->notify, acm->notify_req);
730 kfree(acm); 711 kfree(acm);
731} 712}
@@ -762,27 +743,15 @@ int acm_bind_config(struct usb_configuration *c, u8 port_num)
762 */ 743 */
763 744
764 /* maybe allocate device-global string IDs, and patch descriptors */ 745 /* maybe allocate device-global string IDs, and patch descriptors */
765 if (acm_string_defs[ACM_CTRL_IDX].id == 0) { 746 if (acm_string_defs[0].id == 0) {
766 status = usb_string_id(c->cdev); 747 status = usb_string_ids_tab(c->cdev, acm_string_defs);
767 if (status < 0) 748 if (status < 0)
768 return status; 749 return status;
769 acm_string_defs[ACM_CTRL_IDX].id = status; 750 acm_control_interface_desc.iInterface =
770 751 acm_string_defs[ACM_CTRL_IDX].id;
771 acm_control_interface_desc.iInterface = status; 752 acm_data_interface_desc.iInterface =
772 753 acm_string_defs[ACM_DATA_IDX].id;
773 status = usb_string_id(c->cdev); 754 acm_iad_descriptor.iFunction = acm_string_defs[ACM_IAD_IDX].id;
774 if (status < 0)
775 return status;
776 acm_string_defs[ACM_DATA_IDX].id = status;
777
778 acm_data_interface_desc.iInterface = status;
779
780 status = usb_string_id(c->cdev);
781 if (status < 0)
782 return status;
783 acm_string_defs[ACM_IAD_IDX].id = status;
784
785 acm_iad_descriptor.iFunction = status;
786 } 755 }
787 756
788 /* allocate and initialize one new instance */ 757 /* allocate and initialize one new instance */
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c
index 95bc94f8e570..83420a310fb7 100644
--- a/drivers/usb/gadget/f_ecm.c
+++ b/drivers/usb/gadget/f_ecm.c
@@ -91,7 +91,7 @@ static inline unsigned ecm_bitrate(struct usb_gadget *g)
91 * encapsulated commands (vendor-specific, using control-OUT). 91 * encapsulated commands (vendor-specific, using control-OUT).
92 */ 92 */
93 93
94#define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 == 32 msec */ 94#define ECM_STATUS_INTERVAL_MS 32
95#define ECM_STATUS_BYTECOUNT 16 /* 8 byte header + data */ 95#define ECM_STATUS_BYTECOUNT 16 /* 8 byte header + data */
96 96
97 97
@@ -192,7 +192,7 @@ static struct usb_endpoint_descriptor fs_ecm_notify_desc = {
192 .bEndpointAddress = USB_DIR_IN, 192 .bEndpointAddress = USB_DIR_IN,
193 .bmAttributes = USB_ENDPOINT_XFER_INT, 193 .bmAttributes = USB_ENDPOINT_XFER_INT,
194 .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT), 194 .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT),
195 .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, 195 .bInterval = ECM_STATUS_INTERVAL_MS,
196}; 196};
197 197
198static struct usb_endpoint_descriptor fs_ecm_in_desc = { 198static struct usb_endpoint_descriptor fs_ecm_in_desc = {
@@ -239,7 +239,7 @@ static struct usb_endpoint_descriptor hs_ecm_notify_desc = {
239 .bEndpointAddress = USB_DIR_IN, 239 .bEndpointAddress = USB_DIR_IN,
240 .bmAttributes = USB_ENDPOINT_XFER_INT, 240 .bmAttributes = USB_ENDPOINT_XFER_INT,
241 .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT), 241 .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT),
242 .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, 242 .bInterval = USB_MS_TO_HS_INTERVAL(ECM_STATUS_INTERVAL_MS),
243}; 243};
244 244
245static struct usb_endpoint_descriptor hs_ecm_in_desc = { 245static struct usb_endpoint_descriptor hs_ecm_in_desc = {
@@ -288,7 +288,7 @@ static struct usb_endpoint_descriptor ss_ecm_notify_desc = {
288 .bEndpointAddress = USB_DIR_IN, 288 .bEndpointAddress = USB_DIR_IN,
289 .bmAttributes = USB_ENDPOINT_XFER_INT, 289 .bmAttributes = USB_ENDPOINT_XFER_INT,
290 .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT), 290 .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT),
291 .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, 291 .bInterval = USB_MS_TO_HS_INTERVAL(ECM_STATUS_INTERVAL_MS),
292}; 292};
293 293
294static struct usb_ss_ep_comp_descriptor ss_ecm_intr_comp_desc = { 294static struct usb_ss_ep_comp_descriptor ss_ecm_intr_comp_desc = {
@@ -330,6 +330,7 @@ static struct usb_ss_ep_comp_descriptor ss_ecm_bulk_comp_desc = {
330 330
331static struct usb_descriptor_header *ecm_ss_function[] = { 331static struct usb_descriptor_header *ecm_ss_function[] = {
332 /* CDC ECM control descriptors */ 332 /* CDC ECM control descriptors */
333 (struct usb_descriptor_header *) &ecm_iad_descriptor,
333 (struct usb_descriptor_header *) &ecm_control_intf, 334 (struct usb_descriptor_header *) &ecm_control_intf,
334 (struct usb_descriptor_header *) &ecm_header_desc, 335 (struct usb_descriptor_header *) &ecm_header_desc,
335 (struct usb_descriptor_header *) &ecm_union_desc, 336 (struct usb_descriptor_header *) &ecm_union_desc,
@@ -353,7 +354,7 @@ static struct usb_descriptor_header *ecm_ss_function[] = {
353 354
354static struct usb_string ecm_string_defs[] = { 355static struct usb_string ecm_string_defs[] = {
355 [0].s = "CDC Ethernet Control Model (ECM)", 356 [0].s = "CDC Ethernet Control Model (ECM)",
356 [1].s = NULL /* DYNAMIC */, 357 [1].s = "",
357 [2].s = "CDC Ethernet Data", 358 [2].s = "CDC Ethernet Data",
358 [3].s = "CDC ECM", 359 [3].s = "CDC ECM",
359 { } /* end of list */ 360 { } /* end of list */
@@ -742,42 +743,24 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
742 ecm->notify_req->context = ecm; 743 ecm->notify_req->context = ecm;
743 ecm->notify_req->complete = ecm_notify_complete; 744 ecm->notify_req->complete = ecm_notify_complete;
744 745
745 /* copy descriptors, and track endpoint copies */
746 f->descriptors = usb_copy_descriptors(ecm_fs_function);
747 if (!f->descriptors)
748 goto fail;
749
750 /* support all relevant hardware speeds... we expect that when 746 /* support all relevant hardware speeds... we expect that when
751 * hardware is dual speed, all bulk-capable endpoints work at 747 * hardware is dual speed, all bulk-capable endpoints work at
752 * both speeds 748 * both speeds
753 */ 749 */
754 if (gadget_is_dualspeed(c->cdev->gadget)) { 750 hs_ecm_in_desc.bEndpointAddress = fs_ecm_in_desc.bEndpointAddress;
755 hs_ecm_in_desc.bEndpointAddress = 751 hs_ecm_out_desc.bEndpointAddress = fs_ecm_out_desc.bEndpointAddress;
756 fs_ecm_in_desc.bEndpointAddress; 752 hs_ecm_notify_desc.bEndpointAddress =
757 hs_ecm_out_desc.bEndpointAddress = 753 fs_ecm_notify_desc.bEndpointAddress;
758 fs_ecm_out_desc.bEndpointAddress; 754
759 hs_ecm_notify_desc.bEndpointAddress = 755 ss_ecm_in_desc.bEndpointAddress = fs_ecm_in_desc.bEndpointAddress;
760 fs_ecm_notify_desc.bEndpointAddress; 756 ss_ecm_out_desc.bEndpointAddress = fs_ecm_out_desc.bEndpointAddress;
761 757 ss_ecm_notify_desc.bEndpointAddress =
762 /* copy descriptors, and track endpoint copies */ 758 fs_ecm_notify_desc.bEndpointAddress;
763 f->hs_descriptors = usb_copy_descriptors(ecm_hs_function); 759
764 if (!f->hs_descriptors) 760 status = usb_assign_descriptors(f, ecm_fs_function, ecm_hs_function,
765 goto fail; 761 ecm_ss_function);
766 } 762 if (status)
767 763 goto fail;
768 if (gadget_is_superspeed(c->cdev->gadget)) {
769 ss_ecm_in_desc.bEndpointAddress =
770 fs_ecm_in_desc.bEndpointAddress;
771 ss_ecm_out_desc.bEndpointAddress =
772 fs_ecm_out_desc.bEndpointAddress;
773 ss_ecm_notify_desc.bEndpointAddress =
774 fs_ecm_notify_desc.bEndpointAddress;
775
776 /* copy descriptors, and track endpoint copies */
777 f->ss_descriptors = usb_copy_descriptors(ecm_ss_function);
778 if (!f->ss_descriptors)
779 goto fail;
780 }
781 764
782 /* NOTE: all that is done without knowing or caring about 765 /* NOTE: all that is done without knowing or caring about
783 * the network link ... which is unavailable to this code 766 * the network link ... which is unavailable to this code
@@ -795,11 +778,6 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
795 return 0; 778 return 0;
796 779
797fail: 780fail:
798 if (f->descriptors)
799 usb_free_descriptors(f->descriptors);
800 if (f->hs_descriptors)
801 usb_free_descriptors(f->hs_descriptors);
802
803 if (ecm->notify_req) { 781 if (ecm->notify_req) {
804 kfree(ecm->notify_req->buf); 782 kfree(ecm->notify_req->buf);
805 usb_ep_free_request(ecm->notify, ecm->notify_req); 783 usb_ep_free_request(ecm->notify, ecm->notify_req);
@@ -808,9 +786,9 @@ fail:
808 /* we might as well release our claims on endpoints */ 786 /* we might as well release our claims on endpoints */
809 if (ecm->notify) 787 if (ecm->notify)
810 ecm->notify->driver_data = NULL; 788 ecm->notify->driver_data = NULL;
811 if (ecm->port.out_ep->desc) 789 if (ecm->port.out_ep)
812 ecm->port.out_ep->driver_data = NULL; 790 ecm->port.out_ep->driver_data = NULL;
813 if (ecm->port.in_ep->desc) 791 if (ecm->port.in_ep)
814 ecm->port.in_ep->driver_data = NULL; 792 ecm->port.in_ep->driver_data = NULL;
815 793
816 ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); 794 ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
@@ -825,16 +803,11 @@ ecm_unbind(struct usb_configuration *c, struct usb_function *f)
825 803
826 DBG(c->cdev, "ecm unbind\n"); 804 DBG(c->cdev, "ecm unbind\n");
827 805
828 if (gadget_is_superspeed(c->cdev->gadget)) 806 ecm_string_defs[0].id = 0;
829 usb_free_descriptors(f->ss_descriptors); 807 usb_free_all_descriptors(f);
830 if (gadget_is_dualspeed(c->cdev->gadget))
831 usb_free_descriptors(f->hs_descriptors);
832 usb_free_descriptors(f->descriptors);
833 808
834 kfree(ecm->notify_req->buf); 809 kfree(ecm->notify_req->buf);
835 usb_ep_free_request(ecm->notify, ecm->notify_req); 810 usb_ep_free_request(ecm->notify, ecm->notify_req);
836
837 ecm_string_defs[1].s = NULL;
838 kfree(ecm); 811 kfree(ecm);
839} 812}
840 813
@@ -859,36 +832,15 @@ ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
859 if (!can_support_ecm(c->cdev->gadget) || !ethaddr) 832 if (!can_support_ecm(c->cdev->gadget) || !ethaddr)
860 return -EINVAL; 833 return -EINVAL;
861 834
862 /* maybe allocate device-global string IDs */
863 if (ecm_string_defs[0].id == 0) { 835 if (ecm_string_defs[0].id == 0) {
864 836 status = usb_string_ids_tab(c->cdev, ecm_string_defs);
865 /* control interface label */ 837 if (status)
866 status = usb_string_id(c->cdev);
867 if (status < 0)
868 return status;
869 ecm_string_defs[0].id = status;
870 ecm_control_intf.iInterface = status;
871
872 /* data interface label */
873 status = usb_string_id(c->cdev);
874 if (status < 0)
875 return status; 838 return status;
876 ecm_string_defs[2].id = status;
877 ecm_data_intf.iInterface = status;
878 839
879 /* MAC address */ 840 ecm_control_intf.iInterface = ecm_string_defs[0].id;
880 status = usb_string_id(c->cdev); 841 ecm_data_intf.iInterface = ecm_string_defs[2].id;
881 if (status < 0) 842 ecm_desc.iMACAddress = ecm_string_defs[1].id;
882 return status; 843 ecm_iad_descriptor.iFunction = ecm_string_defs[3].id;
883 ecm_string_defs[1].id = status;
884 ecm_desc.iMACAddress = status;
885
886 /* IAD label */
887 status = usb_string_id(c->cdev);
888 if (status < 0)
889 return status;
890 ecm_string_defs[3].id = status;
891 ecm_iad_descriptor.iFunction = status;
892 } 844 }
893 845
894 /* allocate and initialize one new instance */ 846 /* allocate and initialize one new instance */
@@ -913,9 +865,7 @@ ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
913 ecm->port.func.disable = ecm_disable; 865 ecm->port.func.disable = ecm_disable;
914 866
915 status = usb_add_function(c, &ecm->port.func); 867 status = usb_add_function(c, &ecm->port.func);
916 if (status) { 868 if (status)
917 ecm_string_defs[1].s = NULL;
918 kfree(ecm); 869 kfree(ecm);
919 }
920 return status; 870 return status;
921} 871}
diff --git a/drivers/usb/gadget/f_eem.c b/drivers/usb/gadget/f_eem.c
index 1a7b2dd7d408..cf0ebee85563 100644
--- a/drivers/usb/gadget/f_eem.c
+++ b/drivers/usb/gadget/f_eem.c
@@ -274,38 +274,20 @@ eem_bind(struct usb_configuration *c, struct usb_function *f)
274 274
275 status = -ENOMEM; 275 status = -ENOMEM;
276 276
277 /* copy descriptors, and track endpoint copies */
278 f->descriptors = usb_copy_descriptors(eem_fs_function);
279 if (!f->descriptors)
280 goto fail;
281
282 /* support all relevant hardware speeds... we expect that when 277 /* support all relevant hardware speeds... we expect that when
283 * hardware is dual speed, all bulk-capable endpoints work at 278 * hardware is dual speed, all bulk-capable endpoints work at
284 * both speeds 279 * both speeds
285 */ 280 */
286 if (gadget_is_dualspeed(c->cdev->gadget)) { 281 eem_hs_in_desc.bEndpointAddress = eem_fs_in_desc.bEndpointAddress;
287 eem_hs_in_desc.bEndpointAddress = 282 eem_hs_out_desc.bEndpointAddress = eem_fs_out_desc.bEndpointAddress;
288 eem_fs_in_desc.bEndpointAddress;
289 eem_hs_out_desc.bEndpointAddress =
290 eem_fs_out_desc.bEndpointAddress;
291
292 /* copy descriptors, and track endpoint copies */
293 f->hs_descriptors = usb_copy_descriptors(eem_hs_function);
294 if (!f->hs_descriptors)
295 goto fail;
296 }
297 283
298 if (gadget_is_superspeed(c->cdev->gadget)) { 284 eem_ss_in_desc.bEndpointAddress = eem_fs_in_desc.bEndpointAddress;
299 eem_ss_in_desc.bEndpointAddress = 285 eem_ss_out_desc.bEndpointAddress = eem_fs_out_desc.bEndpointAddress;
300 eem_fs_in_desc.bEndpointAddress;
301 eem_ss_out_desc.bEndpointAddress =
302 eem_fs_out_desc.bEndpointAddress;
303 286
304 /* copy descriptors, and track endpoint copies */ 287 status = usb_assign_descriptors(f, eem_fs_function, eem_hs_function,
305 f->ss_descriptors = usb_copy_descriptors(eem_ss_function); 288 eem_ss_function);
306 if (!f->ss_descriptors) 289 if (status)
307 goto fail; 290 goto fail;
308 }
309 291
310 DBG(cdev, "CDC Ethernet (EEM): %s speed IN/%s OUT/%s\n", 292 DBG(cdev, "CDC Ethernet (EEM): %s speed IN/%s OUT/%s\n",
311 gadget_is_superspeed(c->cdev->gadget) ? "super" : 293 gadget_is_superspeed(c->cdev->gadget) ? "super" :
@@ -314,15 +296,10 @@ eem_bind(struct usb_configuration *c, struct usb_function *f)
314 return 0; 296 return 0;
315 297
316fail: 298fail:
317 if (f->descriptors) 299 usb_free_all_descriptors(f);
318 usb_free_descriptors(f->descriptors); 300 if (eem->port.out_ep)
319 if (f->hs_descriptors)
320 usb_free_descriptors(f->hs_descriptors);
321
322 /* we might as well release our claims on endpoints */
323 if (eem->port.out_ep->desc)
324 eem->port.out_ep->driver_data = NULL; 301 eem->port.out_ep->driver_data = NULL;
325 if (eem->port.in_ep->desc) 302 if (eem->port.in_ep)
326 eem->port.in_ep->driver_data = NULL; 303 eem->port.in_ep->driver_data = NULL;
327 304
328 ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); 305 ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
@@ -337,11 +314,7 @@ eem_unbind(struct usb_configuration *c, struct usb_function *f)
337 314
338 DBG(c->cdev, "eem unbind\n"); 315 DBG(c->cdev, "eem unbind\n");
339 316
340 if (gadget_is_superspeed(c->cdev->gadget)) 317 usb_free_all_descriptors(f);
341 usb_free_descriptors(f->ss_descriptors);
342 if (gadget_is_dualspeed(c->cdev->gadget))
343 usb_free_descriptors(f->hs_descriptors);
344 usb_free_descriptors(f->descriptors);
345 kfree(eem); 318 kfree(eem);
346} 319}
347 320
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 64c4ec10d1fc..4a6961c517f2 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -2097,7 +2097,7 @@ static int __ffs_func_bind_do_descs(enum ffs_entity_type type, u8 *valuep,
2097 if (isHS) 2097 if (isHS)
2098 func->function.hs_descriptors[(long)valuep] = desc; 2098 func->function.hs_descriptors[(long)valuep] = desc;
2099 else 2099 else
2100 func->function.descriptors[(long)valuep] = desc; 2100 func->function.fs_descriptors[(long)valuep] = desc;
2101 2101
2102 if (!desc || desc->bDescriptorType != USB_DT_ENDPOINT) 2102 if (!desc || desc->bDescriptorType != USB_DT_ENDPOINT)
2103 return 0; 2103 return 0;
@@ -2249,7 +2249,7 @@ static int ffs_func_bind(struct usb_configuration *c,
2249 * numbers without worrying that it may be described later on. 2249 * numbers without worrying that it may be described later on.
2250 */ 2250 */
2251 if (likely(full)) { 2251 if (likely(full)) {
2252 func->function.descriptors = data->fs_descs; 2252 func->function.fs_descriptors = data->fs_descs;
2253 ret = ffs_do_descs(ffs->fs_descs_count, 2253 ret = ffs_do_descs(ffs->fs_descs_count,
2254 data->raw_descs, 2254 data->raw_descs,
2255 sizeof data->raw_descs, 2255 sizeof data->raw_descs,
diff --git a/drivers/usb/gadget/f_hid.c b/drivers/usb/gadget/f_hid.c
index 511e527178e2..6e69a8e8d22a 100644
--- a/drivers/usb/gadget/f_hid.c
+++ b/drivers/usb/gadget/f_hid.c
@@ -573,7 +573,6 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f)
573 goto fail; 573 goto fail;
574 hidg_interface_desc.bInterfaceNumber = status; 574 hidg_interface_desc.bInterfaceNumber = status;
575 575
576
577 /* allocate instance-specific endpoints */ 576 /* allocate instance-specific endpoints */
578 status = -ENODEV; 577 status = -ENODEV;
579 ep = usb_ep_autoconfig(c->cdev->gadget, &hidg_fs_in_ep_desc); 578 ep = usb_ep_autoconfig(c->cdev->gadget, &hidg_fs_in_ep_desc);
@@ -609,20 +608,15 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f)
609 hidg_desc.desc[0].wDescriptorLength = 608 hidg_desc.desc[0].wDescriptorLength =
610 cpu_to_le16(hidg->report_desc_length); 609 cpu_to_le16(hidg->report_desc_length);
611 610
612 /* copy descriptors */ 611 hidg_hs_in_ep_desc.bEndpointAddress =
613 f->descriptors = usb_copy_descriptors(hidg_fs_descriptors); 612 hidg_fs_in_ep_desc.bEndpointAddress;
614 if (!f->descriptors) 613 hidg_hs_out_ep_desc.bEndpointAddress =
615 goto fail; 614 hidg_fs_out_ep_desc.bEndpointAddress;
616 615
617 if (gadget_is_dualspeed(c->cdev->gadget)) { 616 status = usb_assign_descriptors(f, hidg_fs_descriptors,
618 hidg_hs_in_ep_desc.bEndpointAddress = 617 hidg_hs_descriptors, NULL);
619 hidg_fs_in_ep_desc.bEndpointAddress; 618 if (status)
620 hidg_hs_out_ep_desc.bEndpointAddress = 619 goto fail;
621 hidg_fs_out_ep_desc.bEndpointAddress;
622 f->hs_descriptors = usb_copy_descriptors(hidg_hs_descriptors);
623 if (!f->hs_descriptors)
624 goto fail;
625 }
626 620
627 mutex_init(&hidg->lock); 621 mutex_init(&hidg->lock);
628 spin_lock_init(&hidg->spinlock); 622 spin_lock_init(&hidg->spinlock);
@@ -649,9 +643,7 @@ fail:
649 usb_ep_free_request(hidg->in_ep, hidg->req); 643 usb_ep_free_request(hidg->in_ep, hidg->req);
650 } 644 }
651 645
652 usb_free_descriptors(f->hs_descriptors); 646 usb_free_all_descriptors(f);
653 usb_free_descriptors(f->descriptors);
654
655 return status; 647 return status;
656} 648}
657 649
@@ -668,9 +660,7 @@ static void hidg_unbind(struct usb_configuration *c, struct usb_function *f)
668 kfree(hidg->req->buf); 660 kfree(hidg->req->buf);
669 usb_ep_free_request(hidg->in_ep, hidg->req); 661 usb_ep_free_request(hidg->in_ep, hidg->req);
670 662
671 /* free descriptors copies */ 663 usb_free_all_descriptors(f);
672 usb_free_descriptors(f->hs_descriptors);
673 usb_free_descriptors(f->descriptors);
674 664
675 kfree(hidg->report_desc); 665 kfree(hidg->report_desc);
676 kfree(hidg); 666 kfree(hidg);
diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c
index 7275706caeb0..bb39cb2bb3a3 100644
--- a/drivers/usb/gadget/f_loopback.c
+++ b/drivers/usb/gadget/f_loopback.c
@@ -177,6 +177,7 @@ loopback_bind(struct usb_configuration *c, struct usb_function *f)
177 struct usb_composite_dev *cdev = c->cdev; 177 struct usb_composite_dev *cdev = c->cdev;
178 struct f_loopback *loop = func_to_loop(f); 178 struct f_loopback *loop = func_to_loop(f);
179 int id; 179 int id;
180 int ret;
180 181
181 /* allocate interface ID(s) */ 182 /* allocate interface ID(s) */
182 id = usb_interface_id(c, f); 183 id = usb_interface_id(c, f);
@@ -201,22 +202,19 @@ autoconf_fail:
201 loop->out_ep->driver_data = cdev; /* claim */ 202 loop->out_ep->driver_data = cdev; /* claim */
202 203
203 /* support high speed hardware */ 204 /* support high speed hardware */
204 if (gadget_is_dualspeed(c->cdev->gadget)) { 205 hs_loop_source_desc.bEndpointAddress =
205 hs_loop_source_desc.bEndpointAddress = 206 fs_loop_source_desc.bEndpointAddress;
206 fs_loop_source_desc.bEndpointAddress; 207 hs_loop_sink_desc.bEndpointAddress = fs_loop_sink_desc.bEndpointAddress;
207 hs_loop_sink_desc.bEndpointAddress =
208 fs_loop_sink_desc.bEndpointAddress;
209 f->hs_descriptors = hs_loopback_descs;
210 }
211 208
212 /* support super speed hardware */ 209 /* support super speed hardware */
213 if (gadget_is_superspeed(c->cdev->gadget)) { 210 ss_loop_source_desc.bEndpointAddress =
214 ss_loop_source_desc.bEndpointAddress = 211 fs_loop_source_desc.bEndpointAddress;
215 fs_loop_source_desc.bEndpointAddress; 212 ss_loop_sink_desc.bEndpointAddress = fs_loop_sink_desc.bEndpointAddress;
216 ss_loop_sink_desc.bEndpointAddress = 213
217 fs_loop_sink_desc.bEndpointAddress; 214 ret = usb_assign_descriptors(f, fs_loopback_descs, hs_loopback_descs,
218 f->ss_descriptors = ss_loopback_descs; 215 ss_loopback_descs);
219 } 216 if (ret)
217 return ret;
220 218
221 DBG(cdev, "%s speed %s: IN/%s, OUT/%s\n", 219 DBG(cdev, "%s speed %s: IN/%s, OUT/%s\n",
222 (gadget_is_superspeed(c->cdev->gadget) ? "super" : 220 (gadget_is_superspeed(c->cdev->gadget) ? "super" :
@@ -228,6 +226,7 @@ autoconf_fail:
228static void 226static void
229loopback_unbind(struct usb_configuration *c, struct usb_function *f) 227loopback_unbind(struct usb_configuration *c, struct usb_function *f)
230{ 228{
229 usb_free_all_descriptors(f);
231 kfree(func_to_loop(f)); 230 kfree(func_to_loop(f));
232} 231}
233 232
@@ -379,7 +378,6 @@ static int __init loopback_bind_config(struct usb_configuration *c)
379 return -ENOMEM; 378 return -ENOMEM;
380 379
381 loop->function.name = "loopback"; 380 loop->function.name = "loopback";
382 loop->function.descriptors = fs_loopback_descs;
383 loop->function.bind = loopback_bind; 381 loop->function.bind = loopback_bind;
384 loop->function.unbind = loopback_unbind; 382 loop->function.unbind = loopback_unbind;
385 loop->function.set_alt = loopback_set_alt; 383 loop->function.set_alt = loopback_set_alt;
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 3a7668bde3ef..5d027b3e1ef0 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -228,10 +228,6 @@
228 228
229static const char fsg_string_interface[] = "Mass Storage"; 229static const char fsg_string_interface[] = "Mass Storage";
230 230
231#define FSG_NO_DEVICE_STRINGS 1
232#define FSG_NO_OTG 1
233#define FSG_NO_INTR_EP 1
234
235#include "storage_common.c" 231#include "storage_common.c"
236 232
237 233
@@ -2904,9 +2900,7 @@ static void fsg_unbind(struct usb_configuration *c, struct usb_function *f)
2904 } 2900 }
2905 2901
2906 fsg_common_put(common); 2902 fsg_common_put(common);
2907 usb_free_descriptors(fsg->function.descriptors); 2903 usb_free_all_descriptors(&fsg->function);
2908 usb_free_descriptors(fsg->function.hs_descriptors);
2909 usb_free_descriptors(fsg->function.ss_descriptors);
2910 kfree(fsg); 2904 kfree(fsg);
2911} 2905}
2912 2906
@@ -2916,6 +2910,8 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
2916 struct usb_gadget *gadget = c->cdev->gadget; 2910 struct usb_gadget *gadget = c->cdev->gadget;
2917 int i; 2911 int i;
2918 struct usb_ep *ep; 2912 struct usb_ep *ep;
2913 unsigned max_burst;
2914 int ret;
2919 2915
2920 fsg->gadget = gadget; 2916 fsg->gadget = gadget;
2921 2917
@@ -2939,45 +2935,27 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
2939 ep->driver_data = fsg->common; /* claim the endpoint */ 2935 ep->driver_data = fsg->common; /* claim the endpoint */
2940 fsg->bulk_out = ep; 2936 fsg->bulk_out = ep;
2941 2937
2942 /* Copy descriptors */ 2938 /* Assume endpoint addresses are the same for both speeds */
2943 f->descriptors = usb_copy_descriptors(fsg_fs_function); 2939 fsg_hs_bulk_in_desc.bEndpointAddress =
2944 if (unlikely(!f->descriptors)) 2940 fsg_fs_bulk_in_desc.bEndpointAddress;
2945 return -ENOMEM; 2941 fsg_hs_bulk_out_desc.bEndpointAddress =
2946 2942 fsg_fs_bulk_out_desc.bEndpointAddress;
2947 if (gadget_is_dualspeed(gadget)) {
2948 /* Assume endpoint addresses are the same for both speeds */
2949 fsg_hs_bulk_in_desc.bEndpointAddress =
2950 fsg_fs_bulk_in_desc.bEndpointAddress;
2951 fsg_hs_bulk_out_desc.bEndpointAddress =
2952 fsg_fs_bulk_out_desc.bEndpointAddress;
2953 f->hs_descriptors = usb_copy_descriptors(fsg_hs_function);
2954 if (unlikely(!f->hs_descriptors)) {
2955 usb_free_descriptors(f->descriptors);
2956 return -ENOMEM;
2957 }
2958 }
2959
2960 if (gadget_is_superspeed(gadget)) {
2961 unsigned max_burst;
2962 2943
2963 /* Calculate bMaxBurst, we know packet size is 1024 */ 2944 /* Calculate bMaxBurst, we know packet size is 1024 */
2964 max_burst = min_t(unsigned, FSG_BUFLEN / 1024, 15); 2945 max_burst = min_t(unsigned, FSG_BUFLEN / 1024, 15);
2965 2946
2966 fsg_ss_bulk_in_desc.bEndpointAddress = 2947 fsg_ss_bulk_in_desc.bEndpointAddress =
2967 fsg_fs_bulk_in_desc.bEndpointAddress; 2948 fsg_fs_bulk_in_desc.bEndpointAddress;
2968 fsg_ss_bulk_in_comp_desc.bMaxBurst = max_burst; 2949 fsg_ss_bulk_in_comp_desc.bMaxBurst = max_burst;
2969 2950
2970 fsg_ss_bulk_out_desc.bEndpointAddress = 2951 fsg_ss_bulk_out_desc.bEndpointAddress =
2971 fsg_fs_bulk_out_desc.bEndpointAddress; 2952 fsg_fs_bulk_out_desc.bEndpointAddress;
2972 fsg_ss_bulk_out_comp_desc.bMaxBurst = max_burst; 2953 fsg_ss_bulk_out_comp_desc.bMaxBurst = max_burst;
2973 2954
2974 f->ss_descriptors = usb_copy_descriptors(fsg_ss_function); 2955 ret = usb_assign_descriptors(f, fsg_fs_function, fsg_hs_function,
2975 if (unlikely(!f->ss_descriptors)) { 2956 fsg_ss_function);
2976 usb_free_descriptors(f->hs_descriptors); 2957 if (ret)
2977 usb_free_descriptors(f->descriptors); 2958 goto autoconf_fail;
2978 return -ENOMEM;
2979 }
2980 }
2981 2959
2982 return 0; 2960 return 0;
2983 2961
@@ -2986,7 +2964,6 @@ autoconf_fail:
2986 return -ENOTSUPP; 2964 return -ENOTSUPP;
2987} 2965}
2988 2966
2989
2990/****************************** ADD FUNCTION ******************************/ 2967/****************************** ADD FUNCTION ******************************/
2991 2968
2992static struct usb_gadget_strings *fsg_strings_array[] = { 2969static struct usb_gadget_strings *fsg_strings_array[] = {
diff --git a/drivers/usb/gadget/f_midi.c b/drivers/usb/gadget/f_midi.c
index 8ed1259fe80d..263e721c2694 100644
--- a/drivers/usb/gadget/f_midi.c
+++ b/drivers/usb/gadget/f_midi.c
@@ -414,7 +414,7 @@ static void f_midi_unbind(struct usb_configuration *c, struct usb_function *f)
414 kfree(midi->id); 414 kfree(midi->id);
415 midi->id = NULL; 415 midi->id = NULL;
416 416
417 usb_free_descriptors(f->descriptors); 417 usb_free_all_descriptors(f);
418 kfree(midi); 418 kfree(midi);
419} 419}
420 420
@@ -881,19 +881,25 @@ f_midi_bind(struct usb_configuration *c, struct usb_function *f)
881 * both speeds 881 * both speeds
882 */ 882 */
883 /* copy descriptors, and track endpoint copies */ 883 /* copy descriptors, and track endpoint copies */
884 f->fs_descriptors = usb_copy_descriptors(midi_function);
885 if (!f->fs_descriptors)
886 goto fail_f_midi;
887
884 if (gadget_is_dualspeed(c->cdev->gadget)) { 888 if (gadget_is_dualspeed(c->cdev->gadget)) {
885 c->highspeed = true;
886 bulk_in_desc.wMaxPacketSize = cpu_to_le16(512); 889 bulk_in_desc.wMaxPacketSize = cpu_to_le16(512);
887 bulk_out_desc.wMaxPacketSize = cpu_to_le16(512); 890 bulk_out_desc.wMaxPacketSize = cpu_to_le16(512);
888 f->hs_descriptors = usb_copy_descriptors(midi_function); 891 f->hs_descriptors = usb_copy_descriptors(midi_function);
889 } else { 892 if (!f->hs_descriptors)
890 f->descriptors = usb_copy_descriptors(midi_function); 893 goto fail_f_midi;
891 } 894 }
892 895
893 kfree(midi_function); 896 kfree(midi_function);
894 897
895 return 0; 898 return 0;
896 899
900fail_f_midi:
901 kfree(midi_function);
902 usb_free_descriptors(f->hs_descriptors);
897fail: 903fail:
898 /* we might as well release our claims on endpoints */ 904 /* we might as well release our claims on endpoints */
899 if (midi->out_ep) 905 if (midi->out_ep)
diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index b651b529c67f..6c8362f937be 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -102,7 +102,7 @@ static inline unsigned ncm_bitrate(struct usb_gadget *g)
102 USB_CDC_NCM_NTB32_SUPPORTED) 102 USB_CDC_NCM_NTB32_SUPPORTED)
103 103
104static struct usb_cdc_ncm_ntb_parameters ntb_parameters = { 104static struct usb_cdc_ncm_ntb_parameters ntb_parameters = {
105 .wLength = sizeof ntb_parameters, 105 .wLength = cpu_to_le16(sizeof(ntb_parameters)),
106 .bmNtbFormatsSupported = cpu_to_le16(FORMATS_SUPPORTED), 106 .bmNtbFormatsSupported = cpu_to_le16(FORMATS_SUPPORTED),
107 .dwNtbInMaxSize = cpu_to_le32(NTB_DEFAULT_IN_SIZE), 107 .dwNtbInMaxSize = cpu_to_le32(NTB_DEFAULT_IN_SIZE),
108 .wNdpInDivisor = cpu_to_le16(4), 108 .wNdpInDivisor = cpu_to_le16(4),
@@ -121,7 +121,7 @@ static struct usb_cdc_ncm_ntb_parameters ntb_parameters = {
121 * waste less bandwidth. 121 * waste less bandwidth.
122 */ 122 */
123 123
124#define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 == 32 msec */ 124#define NCM_STATUS_INTERVAL_MS 32
125#define NCM_STATUS_BYTECOUNT 16 /* 8 byte header + data */ 125#define NCM_STATUS_BYTECOUNT 16 /* 8 byte header + data */
126 126
127static struct usb_interface_assoc_descriptor ncm_iad_desc __initdata = { 127static struct usb_interface_assoc_descriptor ncm_iad_desc __initdata = {
@@ -230,7 +230,7 @@ static struct usb_endpoint_descriptor fs_ncm_notify_desc __initdata = {
230 .bEndpointAddress = USB_DIR_IN, 230 .bEndpointAddress = USB_DIR_IN,
231 .bmAttributes = USB_ENDPOINT_XFER_INT, 231 .bmAttributes = USB_ENDPOINT_XFER_INT,
232 .wMaxPacketSize = cpu_to_le16(NCM_STATUS_BYTECOUNT), 232 .wMaxPacketSize = cpu_to_le16(NCM_STATUS_BYTECOUNT),
233 .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, 233 .bInterval = NCM_STATUS_INTERVAL_MS,
234}; 234};
235 235
236static struct usb_endpoint_descriptor fs_ncm_in_desc __initdata = { 236static struct usb_endpoint_descriptor fs_ncm_in_desc __initdata = {
@@ -275,7 +275,7 @@ static struct usb_endpoint_descriptor hs_ncm_notify_desc __initdata = {
275 .bEndpointAddress = USB_DIR_IN, 275 .bEndpointAddress = USB_DIR_IN,
276 .bmAttributes = USB_ENDPOINT_XFER_INT, 276 .bmAttributes = USB_ENDPOINT_XFER_INT,
277 .wMaxPacketSize = cpu_to_le16(NCM_STATUS_BYTECOUNT), 277 .wMaxPacketSize = cpu_to_le16(NCM_STATUS_BYTECOUNT),
278 .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, 278 .bInterval = USB_MS_TO_HS_INTERVAL(NCM_STATUS_INTERVAL_MS),
279}; 279};
280static struct usb_endpoint_descriptor hs_ncm_in_desc __initdata = { 280static struct usb_endpoint_descriptor hs_ncm_in_desc __initdata = {
281 .bLength = USB_DT_ENDPOINT_SIZE, 281 .bLength = USB_DT_ENDPOINT_SIZE,
@@ -321,7 +321,7 @@ static struct usb_descriptor_header *ncm_hs_function[] __initdata = {
321 321
322static struct usb_string ncm_string_defs[] = { 322static struct usb_string ncm_string_defs[] = {
323 [STRING_CTRL_IDX].s = "CDC Network Control Model (NCM)", 323 [STRING_CTRL_IDX].s = "CDC Network Control Model (NCM)",
324 [STRING_MAC_IDX].s = NULL /* DYNAMIC */, 324 [STRING_MAC_IDX].s = "",
325 [STRING_DATA_IDX].s = "CDC Network Data", 325 [STRING_DATA_IDX].s = "CDC Network Data",
326 [STRING_IAD_IDX].s = "CDC NCM", 326 [STRING_IAD_IDX].s = "CDC NCM",
327 { } /* end of list */ 327 { } /* end of list */
@@ -869,15 +869,19 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port,
869 struct sk_buff *skb2; 869 struct sk_buff *skb2;
870 int ncb_len = 0; 870 int ncb_len = 0;
871 __le16 *tmp; 871 __le16 *tmp;
872 int div = ntb_parameters.wNdpInDivisor; 872 int div;
873 int rem = ntb_parameters.wNdpInPayloadRemainder; 873 int rem;
874 int pad; 874 int pad;
875 int ndp_align = ntb_parameters.wNdpInAlignment; 875 int ndp_align;
876 int ndp_pad; 876 int ndp_pad;
877 unsigned max_size = ncm->port.fixed_in_len; 877 unsigned max_size = ncm->port.fixed_in_len;
878 struct ndp_parser_opts *opts = ncm->parser_opts; 878 struct ndp_parser_opts *opts = ncm->parser_opts;
879 unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0; 879 unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0;
880 880
881 div = le16_to_cpu(ntb_parameters.wNdpInDivisor);
882 rem = le16_to_cpu(ntb_parameters.wNdpInPayloadRemainder);
883 ndp_align = le16_to_cpu(ntb_parameters.wNdpInAlignment);
884
881 ncb_len += opts->nth_size; 885 ncb_len += opts->nth_size;
882 ndp_pad = ALIGN(ncb_len, ndp_align) - ncb_len; 886 ndp_pad = ALIGN(ncb_len, ndp_align) - ncb_len;
883 ncb_len += ndp_pad; 887 ncb_len += ndp_pad;
@@ -1208,30 +1212,18 @@ ncm_bind(struct usb_configuration *c, struct usb_function *f)
1208 ncm->notify_req->context = ncm; 1212 ncm->notify_req->context = ncm;
1209 ncm->notify_req->complete = ncm_notify_complete; 1213 ncm->notify_req->complete = ncm_notify_complete;
1210 1214
1211 /* copy descriptors, and track endpoint copies */
1212 f->descriptors = usb_copy_descriptors(ncm_fs_function);
1213 if (!f->descriptors)
1214 goto fail;
1215
1216 /* 1215 /*
1217 * support all relevant hardware speeds... we expect that when 1216 * support all relevant hardware speeds... we expect that when
1218 * hardware is dual speed, all bulk-capable endpoints work at 1217 * hardware is dual speed, all bulk-capable endpoints work at
1219 * both speeds 1218 * both speeds
1220 */ 1219 */
1221 if (gadget_is_dualspeed(c->cdev->gadget)) { 1220 hs_ncm_in_desc.bEndpointAddress = fs_ncm_in_desc.bEndpointAddress;
1222 hs_ncm_in_desc.bEndpointAddress = 1221 hs_ncm_out_desc.bEndpointAddress = fs_ncm_out_desc.bEndpointAddress;
1223 fs_ncm_in_desc.bEndpointAddress; 1222 hs_ncm_notify_desc.bEndpointAddress =
1224 hs_ncm_out_desc.bEndpointAddress = 1223 fs_ncm_notify_desc.bEndpointAddress;
1225 fs_ncm_out_desc.bEndpointAddress;
1226 hs_ncm_notify_desc.bEndpointAddress =
1227 fs_ncm_notify_desc.bEndpointAddress;
1228
1229 /* copy descriptors, and track endpoint copies */
1230 f->hs_descriptors = usb_copy_descriptors(ncm_hs_function);
1231 if (!f->hs_descriptors)
1232 goto fail;
1233 }
1234 1224
1225 status = usb_assign_descriptors(f, ncm_fs_function, ncm_hs_function,
1226 NULL);
1235 /* 1227 /*
1236 * NOTE: all that is done without knowing or caring about 1228 * NOTE: all that is done without knowing or caring about
1237 * the network link ... which is unavailable to this code 1229 * the network link ... which is unavailable to this code
@@ -1248,9 +1240,7 @@ ncm_bind(struct usb_configuration *c, struct usb_function *f)
1248 return 0; 1240 return 0;
1249 1241
1250fail: 1242fail:
1251 if (f->descriptors) 1243 usb_free_all_descriptors(f);
1252 usb_free_descriptors(f->descriptors);
1253
1254 if (ncm->notify_req) { 1244 if (ncm->notify_req) {
1255 kfree(ncm->notify_req->buf); 1245 kfree(ncm->notify_req->buf);
1256 usb_ep_free_request(ncm->notify, ncm->notify_req); 1246 usb_ep_free_request(ncm->notify, ncm->notify_req);
@@ -1259,9 +1249,9 @@ fail:
1259 /* we might as well release our claims on endpoints */ 1249 /* we might as well release our claims on endpoints */
1260 if (ncm->notify) 1250 if (ncm->notify)
1261 ncm->notify->driver_data = NULL; 1251 ncm->notify->driver_data = NULL;
1262 if (ncm->port.out_ep->desc) 1252 if (ncm->port.out_ep)
1263 ncm->port.out_ep->driver_data = NULL; 1253 ncm->port.out_ep->driver_data = NULL;
1264 if (ncm->port.in_ep->desc) 1254 if (ncm->port.in_ep)
1265 ncm->port.in_ep->driver_data = NULL; 1255 ncm->port.in_ep->driver_data = NULL;
1266 1256
1267 ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); 1257 ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
@@ -1276,14 +1266,12 @@ ncm_unbind(struct usb_configuration *c, struct usb_function *f)
1276 1266
1277 DBG(c->cdev, "ncm unbind\n"); 1267 DBG(c->cdev, "ncm unbind\n");
1278 1268
1279 if (gadget_is_dualspeed(c->cdev->gadget)) 1269 ncm_string_defs[0].id = 0;
1280 usb_free_descriptors(f->hs_descriptors); 1270 usb_free_all_descriptors(f);
1281 usb_free_descriptors(f->descriptors);
1282 1271
1283 kfree(ncm->notify_req->buf); 1272 kfree(ncm->notify_req->buf);
1284 usb_ep_free_request(ncm->notify, ncm->notify_req); 1273 usb_ep_free_request(ncm->notify, ncm->notify_req);
1285 1274
1286 ncm_string_defs[1].s = NULL;
1287 kfree(ncm); 1275 kfree(ncm);
1288} 1276}
1289 1277
@@ -1307,37 +1295,19 @@ int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
1307 if (!can_support_ecm(c->cdev->gadget) || !ethaddr) 1295 if (!can_support_ecm(c->cdev->gadget) || !ethaddr)
1308 return -EINVAL; 1296 return -EINVAL;
1309 1297
1310 /* maybe allocate device-global string IDs */
1311 if (ncm_string_defs[0].id == 0) { 1298 if (ncm_string_defs[0].id == 0) {
1312 1299 status = usb_string_ids_tab(c->cdev, ncm_string_defs);
1313 /* control interface label */
1314 status = usb_string_id(c->cdev);
1315 if (status < 0) 1300 if (status < 0)
1316 return status; 1301 return status;
1317 ncm_string_defs[STRING_CTRL_IDX].id = status; 1302 ncm_control_intf.iInterface =
1318 ncm_control_intf.iInterface = status; 1303 ncm_string_defs[STRING_CTRL_IDX].id;
1319 1304
1320 /* data interface label */ 1305 status = ncm_string_defs[STRING_DATA_IDX].id;
1321 status = usb_string_id(c->cdev);
1322 if (status < 0)
1323 return status;
1324 ncm_string_defs[STRING_DATA_IDX].id = status;
1325 ncm_data_nop_intf.iInterface = status; 1306 ncm_data_nop_intf.iInterface = status;
1326 ncm_data_intf.iInterface = status; 1307 ncm_data_intf.iInterface = status;
1327 1308
1328 /* MAC address */ 1309 ecm_desc.iMACAddress = ncm_string_defs[STRING_MAC_IDX].id;
1329 status = usb_string_id(c->cdev); 1310 ncm_iad_desc.iFunction = ncm_string_defs[STRING_IAD_IDX].id;
1330 if (status < 0)
1331 return status;
1332 ncm_string_defs[STRING_MAC_IDX].id = status;
1333 ecm_desc.iMACAddress = status;
1334
1335 /* IAD */
1336 status = usb_string_id(c->cdev);
1337 if (status < 0)
1338 return status;
1339 ncm_string_defs[STRING_IAD_IDX].id = status;
1340 ncm_iad_desc.iFunction = status;
1341 } 1311 }
1342 1312
1343 /* allocate and initialize one new instance */ 1313 /* allocate and initialize one new instance */
@@ -1347,7 +1317,7 @@ int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
1347 1317
1348 /* export host's Ethernet address in CDC format */ 1318 /* export host's Ethernet address in CDC format */
1349 snprintf(ncm->ethaddr, sizeof ncm->ethaddr, "%pm", ethaddr); 1319 snprintf(ncm->ethaddr, sizeof ncm->ethaddr, "%pm", ethaddr);
1350 ncm_string_defs[1].s = ncm->ethaddr; 1320 ncm_string_defs[STRING_MAC_IDX].s = ncm->ethaddr;
1351 1321
1352 spin_lock_init(&ncm->lock); 1322 spin_lock_init(&ncm->lock);
1353 ncm_reset_values(ncm); 1323 ncm_reset_values(ncm);
@@ -1367,9 +1337,7 @@ int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
1367 ncm->port.unwrap = ncm_unwrap_ntb; 1337 ncm->port.unwrap = ncm_unwrap_ntb;
1368 1338
1369 status = usb_add_function(c, &ncm->port.func); 1339 status = usb_add_function(c, &ncm->port.func);
1370 if (status) { 1340 if (status)
1371 ncm_string_defs[1].s = NULL;
1372 kfree(ncm); 1341 kfree(ncm);
1373 }
1374 return status; 1342 return status;
1375} 1343}
diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c
index 5f400f66aa9b..d8dd8782768c 100644
--- a/drivers/usb/gadget/f_obex.c
+++ b/drivers/usb/gadget/f_obex.c
@@ -331,23 +331,19 @@ obex_bind(struct usb_configuration *c, struct usb_function *f)
331 obex->port.out = ep; 331 obex->port.out = ep;
332 ep->driver_data = cdev; /* claim */ 332 ep->driver_data = cdev; /* claim */
333 333
334 /* copy descriptors, and track endpoint copies */
335 f->descriptors = usb_copy_descriptors(fs_function);
336
337 /* support all relevant hardware speeds... we expect that when 334 /* support all relevant hardware speeds... we expect that when
338 * hardware is dual speed, all bulk-capable endpoints work at 335 * hardware is dual speed, all bulk-capable endpoints work at
339 * both speeds 336 * both speeds
340 */ 337 */
341 if (gadget_is_dualspeed(c->cdev->gadget)) {
342 338
343 obex_hs_ep_in_desc.bEndpointAddress = 339 obex_hs_ep_in_desc.bEndpointAddress =
344 obex_fs_ep_in_desc.bEndpointAddress; 340 obex_fs_ep_in_desc.bEndpointAddress;
345 obex_hs_ep_out_desc.bEndpointAddress = 341 obex_hs_ep_out_desc.bEndpointAddress =
346 obex_fs_ep_out_desc.bEndpointAddress; 342 obex_fs_ep_out_desc.bEndpointAddress;
347 343
348 /* copy descriptors, and track endpoint copies */ 344 status = usb_assign_descriptors(f, fs_function, hs_function, NULL);
349 f->hs_descriptors = usb_copy_descriptors(hs_function); 345 if (status)
350 } 346 goto fail;
351 347
352 /* Avoid letting this gadget enumerate until the userspace 348 /* Avoid letting this gadget enumerate until the userspace
353 * OBEX server is active. 349 * OBEX server is active.
@@ -368,6 +364,7 @@ obex_bind(struct usb_configuration *c, struct usb_function *f)
368 return 0; 364 return 0;
369 365
370fail: 366fail:
367 usb_free_all_descriptors(f);
371 /* we might as well release our claims on endpoints */ 368 /* we might as well release our claims on endpoints */
372 if (obex->port.out) 369 if (obex->port.out)
373 obex->port.out->driver_data = NULL; 370 obex->port.out->driver_data = NULL;
@@ -382,9 +379,8 @@ fail:
382static void 379static void
383obex_unbind(struct usb_configuration *c, struct usb_function *f) 380obex_unbind(struct usb_configuration *c, struct usb_function *f)
384{ 381{
385 if (gadget_is_dualspeed(c->cdev->gadget)) 382 obex_string_defs[OBEX_CTRL_IDX].id = 0;
386 usb_free_descriptors(f->hs_descriptors); 383 usb_free_all_descriptors(f);
387 usb_free_descriptors(f->descriptors);
388 kfree(func_to_obex(f)); 384 kfree(func_to_obex(f));
389} 385}
390 386
@@ -423,22 +419,16 @@ int __init obex_bind_config(struct usb_configuration *c, u8 port_num)
423 if (!can_support_obex(c)) 419 if (!can_support_obex(c))
424 return -EINVAL; 420 return -EINVAL;
425 421
426 /* maybe allocate device-global string IDs, and patch descriptors */
427 if (obex_string_defs[OBEX_CTRL_IDX].id == 0) { 422 if (obex_string_defs[OBEX_CTRL_IDX].id == 0) {
428 status = usb_string_id(c->cdev); 423 status = usb_string_ids_tab(c->cdev, obex_string_defs);
429 if (status < 0)
430 return status;
431 obex_string_defs[OBEX_CTRL_IDX].id = status;
432
433 obex_control_intf.iInterface = status;
434
435 status = usb_string_id(c->cdev);
436 if (status < 0) 424 if (status < 0)
437 return status; 425 return status;
438 obex_string_defs[OBEX_DATA_IDX].id = status; 426 obex_control_intf.iInterface =
427 obex_string_defs[OBEX_CTRL_IDX].id;
439 428
440 obex_data_nop_intf.iInterface = 429 status = obex_string_defs[OBEX_DATA_IDX].id;
441 obex_data_intf.iInterface = status; 430 obex_data_nop_intf.iInterface = status;
431 obex_data_intf.iInterface = status;
442 } 432 }
443 433
444 /* allocate and initialize one new instance */ 434 /* allocate and initialize one new instance */
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index 8ee9268fe253..b21ab558b6c0 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -515,14 +515,14 @@ int pn_bind(struct usb_configuration *c, struct usb_function *f)
515 fp->in_ep = ep; 515 fp->in_ep = ep;
516 ep->driver_data = fp; /* Claim */ 516 ep->driver_data = fp; /* Claim */
517 517
518 pn_hs_sink_desc.bEndpointAddress = 518 pn_hs_sink_desc.bEndpointAddress = pn_fs_sink_desc.bEndpointAddress;
519 pn_fs_sink_desc.bEndpointAddress; 519 pn_hs_source_desc.bEndpointAddress = pn_fs_source_desc.bEndpointAddress;
520 pn_hs_source_desc.bEndpointAddress =
521 pn_fs_source_desc.bEndpointAddress;
522 520
523 /* Do not try to bind Phonet twice... */ 521 /* Do not try to bind Phonet twice... */
524 fp->function.descriptors = fs_pn_function; 522 status = usb_assign_descriptors(f, fs_pn_function, hs_pn_function,
525 fp->function.hs_descriptors = hs_pn_function; 523 NULL);
524 if (status)
525 goto err;
526 526
527 /* Incoming USB requests */ 527 /* Incoming USB requests */
528 status = -ENOMEM; 528 status = -ENOMEM;
@@ -531,7 +531,7 @@ int pn_bind(struct usb_configuration *c, struct usb_function *f)
531 531
532 req = usb_ep_alloc_request(fp->out_ep, GFP_KERNEL); 532 req = usb_ep_alloc_request(fp->out_ep, GFP_KERNEL);
533 if (!req) 533 if (!req)
534 goto err; 534 goto err_req;
535 535
536 req->complete = pn_rx_complete; 536 req->complete = pn_rx_complete;
537 fp->out_reqv[i] = req; 537 fp->out_reqv[i] = req;
@@ -540,14 +540,18 @@ int pn_bind(struct usb_configuration *c, struct usb_function *f)
540 /* Outgoing USB requests */ 540 /* Outgoing USB requests */
541 fp->in_req = usb_ep_alloc_request(fp->in_ep, GFP_KERNEL); 541 fp->in_req = usb_ep_alloc_request(fp->in_ep, GFP_KERNEL);
542 if (!fp->in_req) 542 if (!fp->in_req)
543 goto err; 543 goto err_req;
544 544
545 INFO(cdev, "USB CDC Phonet function\n"); 545 INFO(cdev, "USB CDC Phonet function\n");
546 INFO(cdev, "using %s, OUT %s, IN %s\n", cdev->gadget->name, 546 INFO(cdev, "using %s, OUT %s, IN %s\n", cdev->gadget->name,
547 fp->out_ep->name, fp->in_ep->name); 547 fp->out_ep->name, fp->in_ep->name);
548 return 0; 548 return 0;
549 549
550err_req:
551 for (i = 0; i < phonet_rxq_size && fp->out_reqv[i]; i++)
552 usb_ep_free_request(fp->out_ep, fp->out_reqv[i]);
550err: 553err:
554 usb_free_all_descriptors(f);
551 if (fp->out_ep) 555 if (fp->out_ep)
552 fp->out_ep->driver_data = NULL; 556 fp->out_ep->driver_data = NULL;
553 if (fp->in_ep) 557 if (fp->in_ep)
@@ -569,6 +573,7 @@ pn_unbind(struct usb_configuration *c, struct usb_function *f)
569 if (fp->out_reqv[i]) 573 if (fp->out_reqv[i])
570 usb_ep_free_request(fp->out_ep, fp->out_reqv[i]); 574 usb_ep_free_request(fp->out_ep, fp->out_reqv[i]);
571 575
576 usb_free_all_descriptors(f);
572 kfree(fp); 577 kfree(fp);
573} 578}
574 579
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index b1681e45aca7..71beeb833558 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -101,7 +101,7 @@ static unsigned int bitrate(struct usb_gadget *g)
101/* 101/*
102 */ 102 */
103 103
104#define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 == 32 msec */ 104#define RNDIS_STATUS_INTERVAL_MS 32
105#define STATUS_BYTECOUNT 8 /* 8 bytes data */ 105#define STATUS_BYTECOUNT 8 /* 8 bytes data */
106 106
107 107
@@ -190,7 +190,7 @@ static struct usb_endpoint_descriptor fs_notify_desc = {
190 .bEndpointAddress = USB_DIR_IN, 190 .bEndpointAddress = USB_DIR_IN,
191 .bmAttributes = USB_ENDPOINT_XFER_INT, 191 .bmAttributes = USB_ENDPOINT_XFER_INT,
192 .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT), 192 .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT),
193 .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, 193 .bInterval = RNDIS_STATUS_INTERVAL_MS,
194}; 194};
195 195
196static struct usb_endpoint_descriptor fs_in_desc = { 196static struct usb_endpoint_descriptor fs_in_desc = {
@@ -236,7 +236,7 @@ static struct usb_endpoint_descriptor hs_notify_desc = {
236 .bEndpointAddress = USB_DIR_IN, 236 .bEndpointAddress = USB_DIR_IN,
237 .bmAttributes = USB_ENDPOINT_XFER_INT, 237 .bmAttributes = USB_ENDPOINT_XFER_INT,
238 .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT), 238 .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT),
239 .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, 239 .bInterval = USB_MS_TO_HS_INTERVAL(RNDIS_STATUS_INTERVAL_MS)
240}; 240};
241 241
242static struct usb_endpoint_descriptor hs_in_desc = { 242static struct usb_endpoint_descriptor hs_in_desc = {
@@ -284,7 +284,7 @@ static struct usb_endpoint_descriptor ss_notify_desc = {
284 .bEndpointAddress = USB_DIR_IN, 284 .bEndpointAddress = USB_DIR_IN,
285 .bmAttributes = USB_ENDPOINT_XFER_INT, 285 .bmAttributes = USB_ENDPOINT_XFER_INT,
286 .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT), 286 .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT),
287 .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, 287 .bInterval = USB_MS_TO_HS_INTERVAL(RNDIS_STATUS_INTERVAL_MS)
288}; 288};
289 289
290static struct usb_ss_ep_comp_descriptor ss_intr_comp_desc = { 290static struct usb_ss_ep_comp_descriptor ss_intr_comp_desc = {
@@ -722,42 +722,22 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f)
722 rndis->notify_req->context = rndis; 722 rndis->notify_req->context = rndis;
723 rndis->notify_req->complete = rndis_response_complete; 723 rndis->notify_req->complete = rndis_response_complete;
724 724
725 /* copy descriptors, and track endpoint copies */
726 f->descriptors = usb_copy_descriptors(eth_fs_function);
727 if (!f->descriptors)
728 goto fail;
729
730 /* support all relevant hardware speeds... we expect that when 725 /* support all relevant hardware speeds... we expect that when
731 * hardware is dual speed, all bulk-capable endpoints work at 726 * hardware is dual speed, all bulk-capable endpoints work at
732 * both speeds 727 * both speeds
733 */ 728 */
734 if (gadget_is_dualspeed(c->cdev->gadget)) { 729 hs_in_desc.bEndpointAddress = fs_in_desc.bEndpointAddress;
735 hs_in_desc.bEndpointAddress = 730 hs_out_desc.bEndpointAddress = fs_out_desc.bEndpointAddress;
736 fs_in_desc.bEndpointAddress; 731 hs_notify_desc.bEndpointAddress = fs_notify_desc.bEndpointAddress;
737 hs_out_desc.bEndpointAddress =
738 fs_out_desc.bEndpointAddress;
739 hs_notify_desc.bEndpointAddress =
740 fs_notify_desc.bEndpointAddress;
741
742 /* copy descriptors, and track endpoint copies */
743 f->hs_descriptors = usb_copy_descriptors(eth_hs_function);
744 if (!f->hs_descriptors)
745 goto fail;
746 }
747 732
748 if (gadget_is_superspeed(c->cdev->gadget)) { 733 ss_in_desc.bEndpointAddress = fs_in_desc.bEndpointAddress;
749 ss_in_desc.bEndpointAddress = 734 ss_out_desc.bEndpointAddress = fs_out_desc.bEndpointAddress;
750 fs_in_desc.bEndpointAddress; 735 ss_notify_desc.bEndpointAddress = fs_notify_desc.bEndpointAddress;
751 ss_out_desc.bEndpointAddress = 736
752 fs_out_desc.bEndpointAddress; 737 status = usb_assign_descriptors(f, eth_fs_function, eth_hs_function,
753 ss_notify_desc.bEndpointAddress = 738 eth_ss_function);
754 fs_notify_desc.bEndpointAddress; 739 if (status)
755 740 goto fail;
756 /* copy descriptors, and track endpoint copies */
757 f->ss_descriptors = usb_copy_descriptors(eth_ss_function);
758 if (!f->ss_descriptors)
759 goto fail;
760 }
761 741
762 rndis->port.open = rndis_open; 742 rndis->port.open = rndis_open;
763 rndis->port.close = rndis_close; 743 rndis->port.close = rndis_close;
@@ -788,12 +768,7 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f)
788 return 0; 768 return 0;
789 769
790fail: 770fail:
791 if (gadget_is_superspeed(c->cdev->gadget) && f->ss_descriptors) 771 usb_free_all_descriptors(f);
792 usb_free_descriptors(f->ss_descriptors);
793 if (gadget_is_dualspeed(c->cdev->gadget) && f->hs_descriptors)
794 usb_free_descriptors(f->hs_descriptors);
795 if (f->descriptors)
796 usb_free_descriptors(f->descriptors);
797 772
798 if (rndis->notify_req) { 773 if (rndis->notify_req) {
799 kfree(rndis->notify_req->buf); 774 kfree(rndis->notify_req->buf);
@@ -803,9 +778,9 @@ fail:
803 /* we might as well release our claims on endpoints */ 778 /* we might as well release our claims on endpoints */
804 if (rndis->notify) 779 if (rndis->notify)
805 rndis->notify->driver_data = NULL; 780 rndis->notify->driver_data = NULL;
806 if (rndis->port.out_ep->desc) 781 if (rndis->port.out_ep)
807 rndis->port.out_ep->driver_data = NULL; 782 rndis->port.out_ep->driver_data = NULL;
808 if (rndis->port.in_ep->desc) 783 if (rndis->port.in_ep)
809 rndis->port.in_ep->driver_data = NULL; 784 rndis->port.in_ep->driver_data = NULL;
810 785
811 ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); 786 ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
@@ -820,13 +795,9 @@ rndis_unbind(struct usb_configuration *c, struct usb_function *f)
820 795
821 rndis_deregister(rndis->config); 796 rndis_deregister(rndis->config);
822 rndis_exit(); 797 rndis_exit();
823 rndis_string_defs[0].id = 0;
824 798
825 if (gadget_is_superspeed(c->cdev->gadget)) 799 rndis_string_defs[0].id = 0;
826 usb_free_descriptors(f->ss_descriptors); 800 usb_free_all_descriptors(f);
827 if (gadget_is_dualspeed(c->cdev->gadget))
828 usb_free_descriptors(f->hs_descriptors);
829 usb_free_descriptors(f->descriptors);
830 801
831 kfree(rndis->notify_req->buf); 802 kfree(rndis->notify_req->buf);
832 usb_ep_free_request(rndis->notify, rndis->notify_req); 803 usb_ep_free_request(rndis->notify, rndis->notify_req);
@@ -851,34 +822,19 @@ rndis_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
851 if (!can_support_rndis(c) || !ethaddr) 822 if (!can_support_rndis(c) || !ethaddr)
852 return -EINVAL; 823 return -EINVAL;
853 824
854 /* maybe allocate device-global string IDs */
855 if (rndis_string_defs[0].id == 0) { 825 if (rndis_string_defs[0].id == 0) {
856
857 /* ... and setup RNDIS itself */ 826 /* ... and setup RNDIS itself */
858 status = rndis_init(); 827 status = rndis_init();
859 if (status < 0) 828 if (status < 0)
860 return status; 829 return status;
861 830
862 /* control interface label */ 831 status = usb_string_ids_tab(c->cdev, rndis_string_defs);
863 status = usb_string_id(c->cdev); 832 if (status)
864 if (status < 0)
865 return status; 833 return status;
866 rndis_string_defs[0].id = status;
867 rndis_control_intf.iInterface = status;
868 834
869 /* data interface label */ 835 rndis_control_intf.iInterface = rndis_string_defs[0].id;
870 status = usb_string_id(c->cdev); 836 rndis_data_intf.iInterface = rndis_string_defs[1].id;
871 if (status < 0) 837 rndis_iad_descriptor.iFunction = rndis_string_defs[2].id;
872 return status;
873 rndis_string_defs[1].id = status;
874 rndis_data_intf.iInterface = status;
875
876 /* IAD iFunction label */
877 status = usb_string_id(c->cdev);
878 if (status < 0)
879 return status;
880 rndis_string_defs[2].id = status;
881 rndis_iad_descriptor.iFunction = status;
882 } 838 }
883 839
884 /* allocate and initialize one new instance */ 840 /* allocate and initialize one new instance */
diff --git a/drivers/usb/gadget/f_serial.c b/drivers/usb/gadget/f_serial.c
index 07197d63d9b1..98fa7795df5f 100644
--- a/drivers/usb/gadget/f_serial.c
+++ b/drivers/usb/gadget/f_serial.c
@@ -213,34 +213,20 @@ gser_bind(struct usb_configuration *c, struct usb_function *f)
213 gser->port.out = ep; 213 gser->port.out = ep;
214 ep->driver_data = cdev; /* claim */ 214 ep->driver_data = cdev; /* claim */
215 215
216 /* copy descriptors, and track endpoint copies */
217 f->descriptors = usb_copy_descriptors(gser_fs_function);
218
219 /* support all relevant hardware speeds... we expect that when 216 /* support all relevant hardware speeds... we expect that when
220 * hardware is dual speed, all bulk-capable endpoints work at 217 * hardware is dual speed, all bulk-capable endpoints work at
221 * both speeds 218 * both speeds
222 */ 219 */
223 if (gadget_is_dualspeed(c->cdev->gadget)) { 220 gser_hs_in_desc.bEndpointAddress = gser_fs_in_desc.bEndpointAddress;
224 gser_hs_in_desc.bEndpointAddress = 221 gser_hs_out_desc.bEndpointAddress = gser_fs_out_desc.bEndpointAddress;
225 gser_fs_in_desc.bEndpointAddress;
226 gser_hs_out_desc.bEndpointAddress =
227 gser_fs_out_desc.bEndpointAddress;
228
229 /* copy descriptors, and track endpoint copies */
230 f->hs_descriptors = usb_copy_descriptors(gser_hs_function);
231 }
232 if (gadget_is_superspeed(c->cdev->gadget)) {
233 gser_ss_in_desc.bEndpointAddress =
234 gser_fs_in_desc.bEndpointAddress;
235 gser_ss_out_desc.bEndpointAddress =
236 gser_fs_out_desc.bEndpointAddress;
237
238 /* copy descriptors, and track endpoint copies */
239 f->ss_descriptors = usb_copy_descriptors(gser_ss_function);
240 if (!f->ss_descriptors)
241 goto fail;
242 }
243 222
223 gser_ss_in_desc.bEndpointAddress = gser_fs_in_desc.bEndpointAddress;
224 gser_ss_out_desc.bEndpointAddress = gser_fs_out_desc.bEndpointAddress;
225
226 status = usb_assign_descriptors(f, gser_fs_function, gser_hs_function,
227 gser_ss_function);
228 if (status)
229 goto fail;
244 DBG(cdev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n", 230 DBG(cdev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n",
245 gser->port_num, 231 gser->port_num,
246 gadget_is_superspeed(c->cdev->gadget) ? "super" : 232 gadget_is_superspeed(c->cdev->gadget) ? "super" :
@@ -263,11 +249,7 @@ fail:
263static void 249static void
264gser_unbind(struct usb_configuration *c, struct usb_function *f) 250gser_unbind(struct usb_configuration *c, struct usb_function *f)
265{ 251{
266 if (gadget_is_dualspeed(c->cdev->gadget)) 252 usb_free_all_descriptors(f);
267 usb_free_descriptors(f->hs_descriptors);
268 if (gadget_is_superspeed(c->cdev->gadget))
269 usb_free_descriptors(f->ss_descriptors);
270 usb_free_descriptors(f->descriptors);
271 kfree(func_to_gser(f)); 253 kfree(func_to_gser(f));
272} 254}
273 255
diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c
index 3c126fde6e7e..102d49beb9df 100644
--- a/drivers/usb/gadget/f_sourcesink.c
+++ b/drivers/usb/gadget/f_sourcesink.c
@@ -319,6 +319,7 @@ sourcesink_bind(struct usb_configuration *c, struct usb_function *f)
319 struct usb_composite_dev *cdev = c->cdev; 319 struct usb_composite_dev *cdev = c->cdev;
320 struct f_sourcesink *ss = func_to_ss(f); 320 struct f_sourcesink *ss = func_to_ss(f);
321 int id; 321 int id;
322 int ret;
322 323
323 /* allocate interface ID(s) */ 324 /* allocate interface ID(s) */
324 id = usb_interface_id(c, f); 325 id = usb_interface_id(c, f);
@@ -387,64 +388,57 @@ no_iso:
387 isoc_maxpacket = 1024; 388 isoc_maxpacket = 1024;
388 389
389 /* support high speed hardware */ 390 /* support high speed hardware */
390 if (gadget_is_dualspeed(c->cdev->gadget)) { 391 hs_source_desc.bEndpointAddress = fs_source_desc.bEndpointAddress;
391 hs_source_desc.bEndpointAddress = 392 hs_sink_desc.bEndpointAddress = fs_sink_desc.bEndpointAddress;
392 fs_source_desc.bEndpointAddress;
393 hs_sink_desc.bEndpointAddress =
394 fs_sink_desc.bEndpointAddress;
395 393
396 /* 394 /*
397 * Fill in the HS isoc descriptors from the module parameters. 395 * Fill in the HS isoc descriptors from the module parameters.
398 * We assume that the user knows what they are doing and won't 396 * We assume that the user knows what they are doing and won't
399 * give parameters that their UDC doesn't support. 397 * give parameters that their UDC doesn't support.
400 */ 398 */
401 hs_iso_source_desc.wMaxPacketSize = isoc_maxpacket; 399 hs_iso_source_desc.wMaxPacketSize = isoc_maxpacket;
402 hs_iso_source_desc.wMaxPacketSize |= isoc_mult << 11; 400 hs_iso_source_desc.wMaxPacketSize |= isoc_mult << 11;
403 hs_iso_source_desc.bInterval = isoc_interval; 401 hs_iso_source_desc.bInterval = isoc_interval;
404 hs_iso_source_desc.bEndpointAddress = 402 hs_iso_source_desc.bEndpointAddress =
405 fs_iso_source_desc.bEndpointAddress; 403 fs_iso_source_desc.bEndpointAddress;
406 404
407 hs_iso_sink_desc.wMaxPacketSize = isoc_maxpacket; 405 hs_iso_sink_desc.wMaxPacketSize = isoc_maxpacket;
408 hs_iso_sink_desc.wMaxPacketSize |= isoc_mult << 11; 406 hs_iso_sink_desc.wMaxPacketSize |= isoc_mult << 11;
409 hs_iso_sink_desc.bInterval = isoc_interval; 407 hs_iso_sink_desc.bInterval = isoc_interval;
410 hs_iso_sink_desc.bEndpointAddress = 408 hs_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress;
411 fs_iso_sink_desc.bEndpointAddress;
412
413 f->hs_descriptors = hs_source_sink_descs;
414 }
415 409
416 /* support super speed hardware */ 410 /* support super speed hardware */
417 if (gadget_is_superspeed(c->cdev->gadget)) { 411 ss_source_desc.bEndpointAddress =
418 ss_source_desc.bEndpointAddress = 412 fs_source_desc.bEndpointAddress;
419 fs_source_desc.bEndpointAddress; 413 ss_sink_desc.bEndpointAddress =
420 ss_sink_desc.bEndpointAddress = 414 fs_sink_desc.bEndpointAddress;
421 fs_sink_desc.bEndpointAddress;
422 415
423 /* 416 /*
424 * Fill in the SS isoc descriptors from the module parameters. 417 * Fill in the SS isoc descriptors from the module parameters.
425 * We assume that the user knows what they are doing and won't 418 * We assume that the user knows what they are doing and won't
426 * give parameters that their UDC doesn't support. 419 * give parameters that their UDC doesn't support.
427 */ 420 */
428 ss_iso_source_desc.wMaxPacketSize = isoc_maxpacket; 421 ss_iso_source_desc.wMaxPacketSize = isoc_maxpacket;
429 ss_iso_source_desc.bInterval = isoc_interval; 422 ss_iso_source_desc.bInterval = isoc_interval;
430 ss_iso_source_comp_desc.bmAttributes = isoc_mult; 423 ss_iso_source_comp_desc.bmAttributes = isoc_mult;
431 ss_iso_source_comp_desc.bMaxBurst = isoc_maxburst; 424 ss_iso_source_comp_desc.bMaxBurst = isoc_maxburst;
432 ss_iso_source_comp_desc.wBytesPerInterval = 425 ss_iso_source_comp_desc.wBytesPerInterval =
433 isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1); 426 isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1);
434 ss_iso_source_desc.bEndpointAddress = 427 ss_iso_source_desc.bEndpointAddress =
435 fs_iso_source_desc.bEndpointAddress; 428 fs_iso_source_desc.bEndpointAddress;
436 429
437 ss_iso_sink_desc.wMaxPacketSize = isoc_maxpacket; 430 ss_iso_sink_desc.wMaxPacketSize = isoc_maxpacket;
438 ss_iso_sink_desc.bInterval = isoc_interval; 431 ss_iso_sink_desc.bInterval = isoc_interval;
439 ss_iso_sink_comp_desc.bmAttributes = isoc_mult; 432 ss_iso_sink_comp_desc.bmAttributes = isoc_mult;
440 ss_iso_sink_comp_desc.bMaxBurst = isoc_maxburst; 433 ss_iso_sink_comp_desc.bMaxBurst = isoc_maxburst;
441 ss_iso_sink_comp_desc.wBytesPerInterval = 434 ss_iso_sink_comp_desc.wBytesPerInterval =
442 isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1); 435 isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1);
443 ss_iso_sink_desc.bEndpointAddress = 436 ss_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress;
444 fs_iso_sink_desc.bEndpointAddress; 437
445 438 ret = usb_assign_descriptors(f, fs_source_sink_descs,
446 f->ss_descriptors = ss_source_sink_descs; 439 hs_source_sink_descs, ss_source_sink_descs);
447 } 440 if (ret)
441 return ret;
448 442
449 DBG(cdev, "%s speed %s: IN/%s, OUT/%s, ISO-IN/%s, ISO-OUT/%s\n", 443 DBG(cdev, "%s speed %s: IN/%s, OUT/%s, ISO-IN/%s, ISO-OUT/%s\n",
450 (gadget_is_superspeed(c->cdev->gadget) ? "super" : 444 (gadget_is_superspeed(c->cdev->gadget) ? "super" :
@@ -458,6 +452,7 @@ no_iso:
458static void 452static void
459sourcesink_unbind(struct usb_configuration *c, struct usb_function *f) 453sourcesink_unbind(struct usb_configuration *c, struct usb_function *f)
460{ 454{
455 usb_free_all_descriptors(f);
461 kfree(func_to_ss(f)); 456 kfree(func_to_ss(f));
462} 457}
463 458
@@ -773,7 +768,6 @@ static int __init sourcesink_bind_config(struct usb_configuration *c)
773 return -ENOMEM; 768 return -ENOMEM;
774 769
775 ss->function.name = "source/sink"; 770 ss->function.name = "source/sink";
776 ss->function.descriptors = fs_source_sink_descs;
777 ss->function.bind = sourcesink_bind; 771 ss->function.bind = sourcesink_bind;
778 ss->function.unbind = sourcesink_unbind; 772 ss->function.unbind = sourcesink_unbind;
779 ss->function.set_alt = sourcesink_set_alt; 773 ss->function.set_alt = sourcesink_set_alt;
diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c
index 4060c0bd9785..f172bd152fbb 100644
--- a/drivers/usb/gadget/f_subset.c
+++ b/drivers/usb/gadget/f_subset.c
@@ -236,7 +236,7 @@ static struct usb_descriptor_header *ss_eth_function[] = {
236 236
237static struct usb_string geth_string_defs[] = { 237static struct usb_string geth_string_defs[] = {
238 [0].s = "CDC Ethernet Subset/SAFE", 238 [0].s = "CDC Ethernet Subset/SAFE",
239 [1].s = NULL /* DYNAMIC */, 239 [1].s = "",
240 { } /* end of list */ 240 { } /* end of list */
241}; 241};
242 242
@@ -319,38 +319,22 @@ geth_bind(struct usb_configuration *c, struct usb_function *f)
319 geth->port.out_ep = ep; 319 geth->port.out_ep = ep;
320 ep->driver_data = cdev; /* claim */ 320 ep->driver_data = cdev; /* claim */
321 321
322 /* copy descriptors, and track endpoint copies */
323 f->descriptors = usb_copy_descriptors(fs_eth_function);
324 if (!f->descriptors)
325 goto fail;
326
327 /* support all relevant hardware speeds... we expect that when 322 /* support all relevant hardware speeds... we expect that when
328 * hardware is dual speed, all bulk-capable endpoints work at 323 * hardware is dual speed, all bulk-capable endpoints work at
329 * both speeds 324 * both speeds
330 */ 325 */
331 if (gadget_is_dualspeed(c->cdev->gadget)) { 326 hs_subset_in_desc.bEndpointAddress = fs_subset_in_desc.bEndpointAddress;
332 hs_subset_in_desc.bEndpointAddress = 327 hs_subset_out_desc.bEndpointAddress =
333 fs_subset_in_desc.bEndpointAddress; 328 fs_subset_out_desc.bEndpointAddress;
334 hs_subset_out_desc.bEndpointAddress =
335 fs_subset_out_desc.bEndpointAddress;
336
337 /* copy descriptors, and track endpoint copies */
338 f->hs_descriptors = usb_copy_descriptors(hs_eth_function);
339 if (!f->hs_descriptors)
340 goto fail;
341 }
342 329
343 if (gadget_is_superspeed(c->cdev->gadget)) { 330 ss_subset_in_desc.bEndpointAddress = fs_subset_in_desc.bEndpointAddress;
344 ss_subset_in_desc.bEndpointAddress = 331 ss_subset_out_desc.bEndpointAddress =
345 fs_subset_in_desc.bEndpointAddress; 332 fs_subset_out_desc.bEndpointAddress;
346 ss_subset_out_desc.bEndpointAddress =
347 fs_subset_out_desc.bEndpointAddress;
348 333
349 /* copy descriptors, and track endpoint copies */ 334 status = usb_assign_descriptors(f, fs_eth_function, hs_eth_function,
350 f->ss_descriptors = usb_copy_descriptors(ss_eth_function); 335 ss_eth_function);
351 if (!f->ss_descriptors) 336 if (status)
352 goto fail; 337 goto fail;
353 }
354 338
355 /* NOTE: all that is done without knowing or caring about 339 /* NOTE: all that is done without knowing or caring about
356 * the network link ... which is unavailable to this code 340 * the network link ... which is unavailable to this code
@@ -364,15 +348,11 @@ geth_bind(struct usb_configuration *c, struct usb_function *f)
364 return 0; 348 return 0;
365 349
366fail: 350fail:
367 if (f->descriptors) 351 usb_free_all_descriptors(f);
368 usb_free_descriptors(f->descriptors);
369 if (f->hs_descriptors)
370 usb_free_descriptors(f->hs_descriptors);
371
372 /* we might as well release our claims on endpoints */ 352 /* we might as well release our claims on endpoints */
373 if (geth->port.out_ep->desc) 353 if (geth->port.out_ep)
374 geth->port.out_ep->driver_data = NULL; 354 geth->port.out_ep->driver_data = NULL;
375 if (geth->port.in_ep->desc) 355 if (geth->port.in_ep)
376 geth->port.in_ep->driver_data = NULL; 356 geth->port.in_ep->driver_data = NULL;
377 357
378 ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); 358 ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
@@ -383,12 +363,8 @@ fail:
383static void 363static void
384geth_unbind(struct usb_configuration *c, struct usb_function *f) 364geth_unbind(struct usb_configuration *c, struct usb_function *f)
385{ 365{
386 if (gadget_is_superspeed(c->cdev->gadget)) 366 geth_string_defs[0].id = 0;
387 usb_free_descriptors(f->ss_descriptors); 367 usb_free_all_descriptors(f);
388 if (gadget_is_dualspeed(c->cdev->gadget))
389 usb_free_descriptors(f->hs_descriptors);
390 usb_free_descriptors(f->descriptors);
391 geth_string_defs[1].s = NULL;
392 kfree(func_to_geth(f)); 368 kfree(func_to_geth(f));
393} 369}
394 370
@@ -414,20 +390,11 @@ int geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
414 390
415 /* maybe allocate device-global string IDs */ 391 /* maybe allocate device-global string IDs */
416 if (geth_string_defs[0].id == 0) { 392 if (geth_string_defs[0].id == 0) {
417 393 status = usb_string_ids_tab(c->cdev, geth_string_defs);
418 /* interface label */
419 status = usb_string_id(c->cdev);
420 if (status < 0) 394 if (status < 0)
421 return status; 395 return status;
422 geth_string_defs[0].id = status; 396 subset_data_intf.iInterface = geth_string_defs[0].id;
423 subset_data_intf.iInterface = status; 397 ether_desc.iMACAddress = geth_string_defs[1].id;
424
425 /* MAC address */
426 status = usb_string_id(c->cdev);
427 if (status < 0)
428 return status;
429 geth_string_defs[1].id = status;
430 ether_desc.iMACAddress = status;
431 } 398 }
432 399
433 /* allocate and initialize one new instance */ 400 /* allocate and initialize one new instance */
@@ -449,9 +416,7 @@ int geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
449 geth->port.func.disable = geth_disable; 416 geth->port.func.disable = geth_disable;
450 417
451 status = usb_add_function(c, &geth->port.func); 418 status = usb_add_function(c, &geth->port.func);
452 if (status) { 419 if (status)
453 geth_string_defs[1].s = NULL;
454 kfree(geth); 420 kfree(geth);
455 }
456 return status; 421 return status;
457} 422}
diff --git a/drivers/usb/gadget/f_uac1.c b/drivers/usb/gadget/f_uac1.c
index 1a5dcd5565e3..f570e667a640 100644
--- a/drivers/usb/gadget/f_uac1.c
+++ b/drivers/usb/gadget/f_uac1.c
@@ -630,7 +630,7 @@ f_audio_bind(struct usb_configuration *c, struct usb_function *f)
630 struct usb_composite_dev *cdev = c->cdev; 630 struct usb_composite_dev *cdev = c->cdev;
631 struct f_audio *audio = func_to_audio(f); 631 struct f_audio *audio = func_to_audio(f);
632 int status; 632 int status;
633 struct usb_ep *ep; 633 struct usb_ep *ep = NULL;
634 634
635 f_audio_build_desc(audio); 635 f_audio_build_desc(audio);
636 636
@@ -659,22 +659,14 @@ f_audio_bind(struct usb_configuration *c, struct usb_function *f)
659 status = -ENOMEM; 659 status = -ENOMEM;
660 660
661 /* copy descriptors, and track endpoint copies */ 661 /* copy descriptors, and track endpoint copies */
662 f->descriptors = usb_copy_descriptors(f_audio_desc); 662 status = usb_assign_descriptors(f, f_audio_desc, f_audio_desc, NULL);
663 663 if (status)
664 /* 664 goto fail;
665 * support all relevant hardware speeds... we expect that when
666 * hardware is dual speed, all bulk-capable endpoints work at
667 * both speeds
668 */
669 if (gadget_is_dualspeed(c->cdev->gadget)) {
670 c->highspeed = true;
671 f->hs_descriptors = usb_copy_descriptors(f_audio_desc);
672 }
673
674 return 0; 665 return 0;
675 666
676fail: 667fail:
677 668 if (ep)
669 ep->driver_data = NULL;
678 return status; 670 return status;
679} 671}
680 672
@@ -683,8 +675,7 @@ f_audio_unbind(struct usb_configuration *c, struct usb_function *f)
683{ 675{
684 struct f_audio *audio = func_to_audio(f); 676 struct f_audio *audio = func_to_audio(f);
685 677
686 usb_free_descriptors(f->descriptors); 678 usb_free_all_descriptors(f);
687 usb_free_descriptors(f->hs_descriptors);
688 kfree(audio); 679 kfree(audio);
689} 680}
690 681
diff --git a/drivers/usb/gadget/f_uac2.c b/drivers/usb/gadget/f_uac2.c
index d3c6cffccb72..d7da258fa3f6 100644
--- a/drivers/usb/gadget/f_uac2.c
+++ b/drivers/usb/gadget/f_uac2.c
@@ -50,13 +50,6 @@ static int c_ssize = 2;
50module_param(c_ssize, uint, S_IRUGO); 50module_param(c_ssize, uint, S_IRUGO);
51MODULE_PARM_DESC(c_ssize, "Capture Sample Size(bytes)"); 51MODULE_PARM_DESC(c_ssize, "Capture Sample Size(bytes)");
52 52
53#define DMA_ADDR_INVALID (~(dma_addr_t)0)
54
55#define ALT_SET(x, a) do {(x) &= ~0xff; (x) |= (a); } while (0)
56#define ALT_GET(x) ((x) & 0xff)
57#define INTF_SET(x, i) do {(x) &= 0xff; (x) |= ((i) << 8); } while (0)
58#define INTF_GET(x) ((x >> 8) & 0xff)
59
60/* Keep everyone on toes */ 53/* Keep everyone on toes */
61#define USB_XFERS 2 54#define USB_XFERS 2
62 55
@@ -144,8 +137,9 @@ static struct snd_pcm_hardware uac2_pcm_hardware = {
144}; 137};
145 138
146struct audio_dev { 139struct audio_dev {
147 /* Currently active {Interface[15:8] | AltSettings[7:0]} */ 140 u8 ac_intf, ac_alt;
148 __u16 ac_alt, as_out_alt, as_in_alt; 141 u8 as_out_intf, as_out_alt;
142 u8 as_in_intf, as_in_alt;
149 143
150 struct usb_ep *in_ep, *out_ep; 144 struct usb_ep *in_ep, *out_ep;
151 struct usb_function func; 145 struct usb_function func;
@@ -408,7 +402,7 @@ static struct snd_pcm_ops uac2_pcm_ops = {
408 .prepare = uac2_pcm_null, 402 .prepare = uac2_pcm_null,
409}; 403};
410 404
411static int __devinit snd_uac2_probe(struct platform_device *pdev) 405static int snd_uac2_probe(struct platform_device *pdev)
412{ 406{
413 struct snd_uac2_chip *uac2 = pdev_to_uac2(pdev); 407 struct snd_uac2_chip *uac2 = pdev_to_uac2(pdev);
414 struct snd_card *card; 408 struct snd_card *card;
@@ -526,32 +520,22 @@ enum {
526 STR_AS_IN_ALT1, 520 STR_AS_IN_ALT1,
527}; 521};
528 522
529static const char ifassoc[] = "Source/Sink";
530static const char ifctrl[] = "Topology Control";
531static char clksrc_in[8]; 523static char clksrc_in[8];
532static char clksrc_out[8]; 524static char clksrc_out[8];
533static const char usb_it[] = "USBH Out";
534static const char io_it[] = "USBD Out";
535static const char usb_ot[] = "USBH In";
536static const char io_ot[] = "USBD In";
537static const char out_alt0[] = "Playback Inactive";
538static const char out_alt1[] = "Playback Active";
539static const char in_alt0[] = "Capture Inactive";
540static const char in_alt1[] = "Capture Active";
541 525
542static struct usb_string strings_fn[] = { 526static struct usb_string strings_fn[] = {
543 [STR_ASSOC].s = ifassoc, 527 [STR_ASSOC].s = "Source/Sink",
544 [STR_IF_CTRL].s = ifctrl, 528 [STR_IF_CTRL].s = "Topology Control",
545 [STR_CLKSRC_IN].s = clksrc_in, 529 [STR_CLKSRC_IN].s = clksrc_in,
546 [STR_CLKSRC_OUT].s = clksrc_out, 530 [STR_CLKSRC_OUT].s = clksrc_out,
547 [STR_USB_IT].s = usb_it, 531 [STR_USB_IT].s = "USBH Out",
548 [STR_IO_IT].s = io_it, 532 [STR_IO_IT].s = "USBD Out",
549 [STR_USB_OT].s = usb_ot, 533 [STR_USB_OT].s = "USBH In",
550 [STR_IO_OT].s = io_ot, 534 [STR_IO_OT].s = "USBD In",
551 [STR_AS_OUT_ALT0].s = out_alt0, 535 [STR_AS_OUT_ALT0].s = "Playback Inactive",
552 [STR_AS_OUT_ALT1].s = out_alt1, 536 [STR_AS_OUT_ALT1].s = "Playback Active",
553 [STR_AS_IN_ALT0].s = in_alt0, 537 [STR_AS_IN_ALT0].s = "Capture Inactive",
554 [STR_AS_IN_ALT1].s = in_alt1, 538 [STR_AS_IN_ALT1].s = "Capture Active",
555 { }, 539 { },
556}; 540};
557 541
@@ -952,8 +936,8 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
952 return ret; 936 return ret;
953 } 937 }
954 std_ac_if_desc.bInterfaceNumber = ret; 938 std_ac_if_desc.bInterfaceNumber = ret;
955 ALT_SET(agdev->ac_alt, 0); 939 agdev->ac_intf = ret;
956 INTF_SET(agdev->ac_alt, ret); 940 agdev->ac_alt = 0;
957 941
958 ret = usb_interface_id(cfg, fn); 942 ret = usb_interface_id(cfg, fn);
959 if (ret < 0) { 943 if (ret < 0) {
@@ -963,8 +947,8 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
963 } 947 }
964 std_as_out_if0_desc.bInterfaceNumber = ret; 948 std_as_out_if0_desc.bInterfaceNumber = ret;
965 std_as_out_if1_desc.bInterfaceNumber = ret; 949 std_as_out_if1_desc.bInterfaceNumber = ret;
966 ALT_SET(agdev->as_out_alt, 0); 950 agdev->as_out_intf = ret;
967 INTF_SET(agdev->as_out_alt, ret); 951 agdev->as_out_alt = 0;
968 952
969 ret = usb_interface_id(cfg, fn); 953 ret = usb_interface_id(cfg, fn);
970 if (ret < 0) { 954 if (ret < 0) {
@@ -974,19 +958,23 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
974 } 958 }
975 std_as_in_if0_desc.bInterfaceNumber = ret; 959 std_as_in_if0_desc.bInterfaceNumber = ret;
976 std_as_in_if1_desc.bInterfaceNumber = ret; 960 std_as_in_if1_desc.bInterfaceNumber = ret;
977 ALT_SET(agdev->as_in_alt, 0); 961 agdev->as_in_intf = ret;
978 INTF_SET(agdev->as_in_alt, ret); 962 agdev->as_in_alt = 0;
979 963
980 agdev->out_ep = usb_ep_autoconfig(gadget, &fs_epout_desc); 964 agdev->out_ep = usb_ep_autoconfig(gadget, &fs_epout_desc);
981 if (!agdev->out_ep) 965 if (!agdev->out_ep) {
982 dev_err(&uac2->pdev.dev, 966 dev_err(&uac2->pdev.dev,
983 "%s:%d Error!\n", __func__, __LINE__); 967 "%s:%d Error!\n", __func__, __LINE__);
968 goto err;
969 }
984 agdev->out_ep->driver_data = agdev; 970 agdev->out_ep->driver_data = agdev;
985 971
986 agdev->in_ep = usb_ep_autoconfig(gadget, &fs_epin_desc); 972 agdev->in_ep = usb_ep_autoconfig(gadget, &fs_epin_desc);
987 if (!agdev->in_ep) 973 if (!agdev->in_ep) {
988 dev_err(&uac2->pdev.dev, 974 dev_err(&uac2->pdev.dev,
989 "%s:%d Error!\n", __func__, __LINE__); 975 "%s:%d Error!\n", __func__, __LINE__);
976 goto err;
977 }
990 agdev->in_ep->driver_data = agdev; 978 agdev->in_ep->driver_data = agdev;
991 979
992 hs_epout_desc.bEndpointAddress = fs_epout_desc.bEndpointAddress; 980 hs_epout_desc.bEndpointAddress = fs_epout_desc.bEndpointAddress;
@@ -994,9 +982,9 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
994 hs_epin_desc.bEndpointAddress = fs_epin_desc.bEndpointAddress; 982 hs_epin_desc.bEndpointAddress = fs_epin_desc.bEndpointAddress;
995 hs_epin_desc.wMaxPacketSize = fs_epin_desc.wMaxPacketSize; 983 hs_epin_desc.wMaxPacketSize = fs_epin_desc.wMaxPacketSize;
996 984
997 fn->descriptors = usb_copy_descriptors(fs_audio_desc); 985 ret = usb_assign_descriptors(fn, fs_audio_desc, hs_audio_desc, NULL);
998 if (gadget_is_dualspeed(gadget)) 986 if (ret)
999 fn->hs_descriptors = usb_copy_descriptors(hs_audio_desc); 987 goto err;
1000 988
1001 prm = &agdev->uac2.c_prm; 989 prm = &agdev->uac2.c_prm;
1002 prm->max_psize = hs_epout_desc.wMaxPacketSize; 990 prm->max_psize = hs_epout_desc.wMaxPacketSize;
@@ -1005,6 +993,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
1005 prm->max_psize = 0; 993 prm->max_psize = 0;
1006 dev_err(&uac2->pdev.dev, 994 dev_err(&uac2->pdev.dev,
1007 "%s:%d Error!\n", __func__, __LINE__); 995 "%s:%d Error!\n", __func__, __LINE__);
996 goto err;
1008 } 997 }
1009 998
1010 prm = &agdev->uac2.p_prm; 999 prm = &agdev->uac2.p_prm;
@@ -1014,17 +1003,28 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
1014 prm->max_psize = 0; 1003 prm->max_psize = 0;
1015 dev_err(&uac2->pdev.dev, 1004 dev_err(&uac2->pdev.dev,
1016 "%s:%d Error!\n", __func__, __LINE__); 1005 "%s:%d Error!\n", __func__, __LINE__);
1006 goto err;
1017 } 1007 }
1018 1008
1019 return alsa_uac2_init(agdev); 1009 ret = alsa_uac2_init(agdev);
1010 if (ret)
1011 goto err;
1012 return 0;
1013err:
1014 kfree(agdev->uac2.p_prm.rbuf);
1015 kfree(agdev->uac2.c_prm.rbuf);
1016 usb_free_all_descriptors(fn);
1017 if (agdev->in_ep)
1018 agdev->in_ep->driver_data = NULL;
1019 if (agdev->out_ep)
1020 agdev->out_ep->driver_data = NULL;
1021 return -EINVAL;
1020} 1022}
1021 1023
1022static void 1024static void
1023afunc_unbind(struct usb_configuration *cfg, struct usb_function *fn) 1025afunc_unbind(struct usb_configuration *cfg, struct usb_function *fn)
1024{ 1026{
1025 struct audio_dev *agdev = func_to_agdev(fn); 1027 struct audio_dev *agdev = func_to_agdev(fn);
1026 struct usb_composite_dev *cdev = cfg->cdev;
1027 struct usb_gadget *gadget = cdev->gadget;
1028 struct uac2_rtd_params *prm; 1028 struct uac2_rtd_params *prm;
1029 1029
1030 alsa_uac2_exit(agdev); 1030 alsa_uac2_exit(agdev);
@@ -1034,10 +1034,7 @@ afunc_unbind(struct usb_configuration *cfg, struct usb_function *fn)
1034 1034
1035 prm = &agdev->uac2.c_prm; 1035 prm = &agdev->uac2.c_prm;
1036 kfree(prm->rbuf); 1036 kfree(prm->rbuf);
1037 1037 usb_free_all_descriptors(fn);
1038 if (gadget_is_dualspeed(gadget))
1039 usb_free_descriptors(fn->hs_descriptors);
1040 usb_free_descriptors(fn->descriptors);
1041 1038
1042 if (agdev->in_ep) 1039 if (agdev->in_ep)
1043 agdev->in_ep->driver_data = NULL; 1040 agdev->in_ep->driver_data = NULL;
@@ -1064,7 +1061,7 @@ afunc_set_alt(struct usb_function *fn, unsigned intf, unsigned alt)
1064 return -EINVAL; 1061 return -EINVAL;
1065 } 1062 }
1066 1063
1067 if (intf == INTF_GET(agdev->ac_alt)) { 1064 if (intf == agdev->ac_intf) {
1068 /* Control I/f has only 1 AltSetting - 0 */ 1065 /* Control I/f has only 1 AltSetting - 0 */
1069 if (alt) { 1066 if (alt) {
1070 dev_err(&uac2->pdev.dev, 1067 dev_err(&uac2->pdev.dev,
@@ -1074,16 +1071,16 @@ afunc_set_alt(struct usb_function *fn, unsigned intf, unsigned alt)
1074 return 0; 1071 return 0;
1075 } 1072 }
1076 1073
1077 if (intf == INTF_GET(agdev->as_out_alt)) { 1074 if (intf == agdev->as_out_intf) {
1078 ep = agdev->out_ep; 1075 ep = agdev->out_ep;
1079 prm = &uac2->c_prm; 1076 prm = &uac2->c_prm;
1080 config_ep_by_speed(gadget, fn, ep); 1077 config_ep_by_speed(gadget, fn, ep);
1081 ALT_SET(agdev->as_out_alt, alt); 1078 agdev->as_out_alt = alt;
1082 } else if (intf == INTF_GET(agdev->as_in_alt)) { 1079 } else if (intf == agdev->as_in_intf) {
1083 ep = agdev->in_ep; 1080 ep = agdev->in_ep;
1084 prm = &uac2->p_prm; 1081 prm = &uac2->p_prm;
1085 config_ep_by_speed(gadget, fn, ep); 1082 config_ep_by_speed(gadget, fn, ep);
1086 ALT_SET(agdev->as_in_alt, alt); 1083 agdev->as_in_alt = alt;
1087 } else { 1084 } else {
1088 dev_err(&uac2->pdev.dev, 1085 dev_err(&uac2->pdev.dev,
1089 "%s:%d Error!\n", __func__, __LINE__); 1086 "%s:%d Error!\n", __func__, __LINE__);
@@ -1117,7 +1114,6 @@ afunc_set_alt(struct usb_function *fn, unsigned intf, unsigned alt)
1117 prm->ureq[i].pp = prm; 1114 prm->ureq[i].pp = prm;
1118 1115
1119 req->zero = 0; 1116 req->zero = 0;
1120 req->dma = DMA_ADDR_INVALID;
1121 req->context = &prm->ureq[i]; 1117 req->context = &prm->ureq[i];
1122 req->length = prm->max_psize; 1118 req->length = prm->max_psize;
1123 req->complete = agdev_iso_complete; 1119 req->complete = agdev_iso_complete;
@@ -1136,12 +1132,12 @@ afunc_get_alt(struct usb_function *fn, unsigned intf)
1136 struct audio_dev *agdev = func_to_agdev(fn); 1132 struct audio_dev *agdev = func_to_agdev(fn);
1137 struct snd_uac2_chip *uac2 = &agdev->uac2; 1133 struct snd_uac2_chip *uac2 = &agdev->uac2;
1138 1134
1139 if (intf == INTF_GET(agdev->ac_alt)) 1135 if (intf == agdev->ac_intf)
1140 return ALT_GET(agdev->ac_alt); 1136 return agdev->ac_alt;
1141 else if (intf == INTF_GET(agdev->as_out_alt)) 1137 else if (intf == agdev->as_out_intf)
1142 return ALT_GET(agdev->as_out_alt); 1138 return agdev->as_out_alt;
1143 else if (intf == INTF_GET(agdev->as_in_alt)) 1139 else if (intf == agdev->as_in_intf)
1144 return ALT_GET(agdev->as_in_alt); 1140 return agdev->as_in_alt;
1145 else 1141 else
1146 dev_err(&uac2->pdev.dev, 1142 dev_err(&uac2->pdev.dev,
1147 "%s:%d Invalid Interface %d!\n", 1143 "%s:%d Invalid Interface %d!\n",
@@ -1157,10 +1153,10 @@ afunc_disable(struct usb_function *fn)
1157 struct snd_uac2_chip *uac2 = &agdev->uac2; 1153 struct snd_uac2_chip *uac2 = &agdev->uac2;
1158 1154
1159 free_ep(&uac2->p_prm, agdev->in_ep); 1155 free_ep(&uac2->p_prm, agdev->in_ep);
1160 ALT_SET(agdev->as_in_alt, 0); 1156 agdev->as_in_alt = 0;
1161 1157
1162 free_ep(&uac2->c_prm, agdev->out_ep); 1158 free_ep(&uac2->c_prm, agdev->out_ep);
1163 ALT_SET(agdev->as_out_alt, 0); 1159 agdev->as_out_alt = 0;
1164} 1160}
1165 1161
1166static int 1162static int
@@ -1267,7 +1263,7 @@ setup_rq_inf(struct usb_function *fn, const struct usb_ctrlrequest *cr)
1267 u16 w_index = le16_to_cpu(cr->wIndex); 1263 u16 w_index = le16_to_cpu(cr->wIndex);
1268 u8 intf = w_index & 0xff; 1264 u8 intf = w_index & 0xff;
1269 1265
1270 if (intf != INTF_GET(agdev->ac_alt)) { 1266 if (intf != agdev->ac_intf) {
1271 dev_err(&uac2->pdev.dev, 1267 dev_err(&uac2->pdev.dev,
1272 "%s:%d Error!\n", __func__, __LINE__); 1268 "%s:%d Error!\n", __func__, __LINE__);
1273 return -EOPNOTSUPP; 1269 return -EOPNOTSUPP;
@@ -1316,7 +1312,7 @@ afunc_setup(struct usb_function *fn, const struct usb_ctrlrequest *cr)
1316 1312
1317static int audio_bind_config(struct usb_configuration *cfg) 1313static int audio_bind_config(struct usb_configuration *cfg)
1318{ 1314{
1319 int id, res; 1315 int res;
1320 1316
1321 agdev_g = kzalloc(sizeof *agdev_g, GFP_KERNEL); 1317 agdev_g = kzalloc(sizeof *agdev_g, GFP_KERNEL);
1322 if (agdev_g == NULL) { 1318 if (agdev_g == NULL) {
@@ -1324,89 +1320,21 @@ static int audio_bind_config(struct usb_configuration *cfg)
1324 return -ENOMEM; 1320 return -ENOMEM;
1325 } 1321 }
1326 1322
1327 id = usb_string_id(cfg->cdev); 1323 res = usb_string_ids_tab(cfg->cdev, strings_fn);
1328 if (id < 0) 1324 if (res)
1329 return id; 1325 return res;
1330 1326 iad_desc.iFunction = strings_fn[STR_ASSOC].id;
1331 strings_fn[STR_ASSOC].id = id; 1327 std_ac_if_desc.iInterface = strings_fn[STR_IF_CTRL].id;
1332 iad_desc.iFunction = id, 1328 in_clk_src_desc.iClockSource = strings_fn[STR_CLKSRC_IN].id;
1333 1329 out_clk_src_desc.iClockSource = strings_fn[STR_CLKSRC_OUT].id;
1334 id = usb_string_id(cfg->cdev); 1330 usb_out_it_desc.iTerminal = strings_fn[STR_USB_IT].id;
1335 if (id < 0) 1331 io_in_it_desc.iTerminal = strings_fn[STR_IO_IT].id;
1336 return id; 1332 usb_in_ot_desc.iTerminal = strings_fn[STR_USB_OT].id;
1337 1333 io_out_ot_desc.iTerminal = strings_fn[STR_IO_OT].id;
1338 strings_fn[STR_IF_CTRL].id = id; 1334 std_as_out_if0_desc.iInterface = strings_fn[STR_AS_OUT_ALT0].id;
1339 std_ac_if_desc.iInterface = id, 1335 std_as_out_if1_desc.iInterface = strings_fn[STR_AS_OUT_ALT1].id;
1340 1336 std_as_in_if0_desc.iInterface = strings_fn[STR_AS_IN_ALT0].id;
1341 id = usb_string_id(cfg->cdev); 1337 std_as_in_if1_desc.iInterface = strings_fn[STR_AS_IN_ALT1].id;
1342 if (id < 0)
1343 return id;
1344
1345 strings_fn[STR_CLKSRC_IN].id = id;
1346 in_clk_src_desc.iClockSource = id,
1347
1348 id = usb_string_id(cfg->cdev);
1349 if (id < 0)
1350 return id;
1351
1352 strings_fn[STR_CLKSRC_OUT].id = id;
1353 out_clk_src_desc.iClockSource = id,
1354
1355 id = usb_string_id(cfg->cdev);
1356 if (id < 0)
1357 return id;
1358
1359 strings_fn[STR_USB_IT].id = id;
1360 usb_out_it_desc.iTerminal = id,
1361
1362 id = usb_string_id(cfg->cdev);
1363 if (id < 0)
1364 return id;
1365
1366 strings_fn[STR_IO_IT].id = id;
1367 io_in_it_desc.iTerminal = id;
1368
1369 id = usb_string_id(cfg->cdev);
1370 if (id < 0)
1371 return id;
1372
1373 strings_fn[STR_USB_OT].id = id;
1374 usb_in_ot_desc.iTerminal = id;
1375
1376 id = usb_string_id(cfg->cdev);
1377 if (id < 0)
1378 return id;
1379
1380 strings_fn[STR_IO_OT].id = id;
1381 io_out_ot_desc.iTerminal = id;
1382
1383 id = usb_string_id(cfg->cdev);
1384 if (id < 0)
1385 return id;
1386
1387 strings_fn[STR_AS_OUT_ALT0].id = id;
1388 std_as_out_if0_desc.iInterface = id;
1389
1390 id = usb_string_id(cfg->cdev);
1391 if (id < 0)
1392 return id;
1393
1394 strings_fn[STR_AS_OUT_ALT1].id = id;
1395 std_as_out_if1_desc.iInterface = id;
1396
1397 id = usb_string_id(cfg->cdev);
1398 if (id < 0)
1399 return id;
1400
1401 strings_fn[STR_AS_IN_ALT0].id = id;
1402 std_as_in_if0_desc.iInterface = id;
1403
1404 id = usb_string_id(cfg->cdev);
1405 if (id < 0)
1406 return id;
1407
1408 strings_fn[STR_AS_IN_ALT1].id = id;
1409 std_as_in_if1_desc.iInterface = id;
1410 1338
1411 agdev_g->func.name = "uac2_func"; 1339 agdev_g->func.name = "uac2_func";
1412 agdev_g->func.strings = fn_strings; 1340 agdev_g->func.strings = fn_strings;
diff --git a/drivers/usb/gadget/f_uvc.c b/drivers/usb/gadget/f_uvc.c
index 2a8bf0655c60..5b629876941b 100644
--- a/drivers/usb/gadget/f_uvc.c
+++ b/drivers/usb/gadget/f_uvc.c
@@ -417,7 +417,6 @@ uvc_register_video(struct uvc_device *uvc)
417 return -ENOMEM; 417 return -ENOMEM;
418 418
419 video->parent = &cdev->gadget->dev; 419 video->parent = &cdev->gadget->dev;
420 video->minor = -1;
421 video->fops = &uvc_v4l2_fops; 420 video->fops = &uvc_v4l2_fops;
422 video->release = video_device_release; 421 video->release = video_device_release;
423 strncpy(video->name, cdev->gadget->name, sizeof(video->name)); 422 strncpy(video->name, cdev->gadget->name, sizeof(video->name));
@@ -577,27 +576,15 @@ uvc_function_unbind(struct usb_configuration *c, struct usb_function *f)
577 576
578 INFO(cdev, "uvc_function_unbind\n"); 577 INFO(cdev, "uvc_function_unbind\n");
579 578
580 if (uvc->vdev) { 579 video_unregister_device(uvc->vdev);
581 if (uvc->vdev->minor == -1) 580 uvc->control_ep->driver_data = NULL;
582 video_device_release(uvc->vdev); 581 uvc->video.ep->driver_data = NULL;
583 else
584 video_unregister_device(uvc->vdev);
585 uvc->vdev = NULL;
586 }
587 582
588 if (uvc->control_ep) 583 uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id = 0;
589 uvc->control_ep->driver_data = NULL; 584 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req);
590 if (uvc->video.ep) 585 kfree(uvc->control_buf);
591 uvc->video.ep->driver_data = NULL;
592
593 if (uvc->control_req) {
594 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req);
595 kfree(uvc->control_buf);
596 }
597 586
598 kfree(f->descriptors); 587 usb_free_all_descriptors(f);
599 kfree(f->hs_descriptors);
600 kfree(f->ss_descriptors);
601 588
602 kfree(uvc); 589 kfree(uvc);
603} 590}
@@ -663,49 +650,40 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
663 /* sanity check the streaming endpoint module parameters */ 650 /* sanity check the streaming endpoint module parameters */
664 if (streaming_maxpacket > 1024) 651 if (streaming_maxpacket > 1024)
665 streaming_maxpacket = 1024; 652 streaming_maxpacket = 1024;
653 /*
654 * Fill in the HS descriptors from the module parameters for the Video
655 * Streaming endpoint.
656 * NOTE: We assume that the user knows what they are doing and won't
657 * give parameters that their UDC doesn't support.
658 */
659 uvc_hs_streaming_ep.wMaxPacketSize = streaming_maxpacket;
660 uvc_hs_streaming_ep.wMaxPacketSize |= streaming_mult << 11;
661 uvc_hs_streaming_ep.bInterval = streaming_interval;
662 uvc_hs_streaming_ep.bEndpointAddress =
663 uvc_fs_streaming_ep.bEndpointAddress;
666 664
667 /* Copy descriptors for FS. */ 665 /*
668 f->descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL); 666 * Fill in the SS descriptors from the module parameters for the Video
669 667 * Streaming endpoint.
670 /* support high speed hardware */ 668 * NOTE: We assume that the user knows what they are doing and won't
671 if (gadget_is_dualspeed(cdev->gadget)) { 669 * give parameters that their UDC doesn't support.
672 /* 670 */
673 * Fill in the HS descriptors from the module parameters for the 671 uvc_ss_streaming_ep.wMaxPacketSize = streaming_maxpacket;
674 * Video Streaming endpoint. 672 uvc_ss_streaming_ep.bInterval = streaming_interval;
675 * NOTE: We assume that the user knows what they are doing and 673 uvc_ss_streaming_comp.bmAttributes = streaming_mult;
676 * won't give parameters that their UDC doesn't support. 674 uvc_ss_streaming_comp.bMaxBurst = streaming_maxburst;
677 */ 675 uvc_ss_streaming_comp.wBytesPerInterval =
678 uvc_hs_streaming_ep.wMaxPacketSize = streaming_maxpacket; 676 streaming_maxpacket * (streaming_mult + 1) *
679 uvc_hs_streaming_ep.wMaxPacketSize |= streaming_mult << 11; 677 (streaming_maxburst + 1);
680 uvc_hs_streaming_ep.bInterval = streaming_interval; 678 uvc_ss_streaming_ep.bEndpointAddress =
681 uvc_hs_streaming_ep.bEndpointAddress = 679 uvc_fs_streaming_ep.bEndpointAddress;
682 uvc_fs_streaming_ep.bEndpointAddress;
683
684 /* Copy descriptors. */
685 f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH);
686 }
687 680
688 /* support super speed hardware */ 681 /* Copy descriptors */
689 if (gadget_is_superspeed(c->cdev->gadget)) { 682 f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL);
690 /* 683 if (gadget_is_dualspeed(cdev->gadget))
691 * Fill in the SS descriptors from the module parameters for the 684 f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH);
692 * Video Streaming endpoint. 685 if (gadget_is_superspeed(c->cdev->gadget))
693 * NOTE: We assume that the user knows what they are doing and
694 * won't give parameters that their UDC doesn't support.
695 */
696 uvc_ss_streaming_ep.wMaxPacketSize = streaming_maxpacket;
697 uvc_ss_streaming_ep.bInterval = streaming_interval;
698 uvc_ss_streaming_comp.bmAttributes = streaming_mult;
699 uvc_ss_streaming_comp.bMaxBurst = streaming_maxburst;
700 uvc_ss_streaming_comp.wBytesPerInterval =
701 streaming_maxpacket * (streaming_mult + 1) *
702 (streaming_maxburst + 1);
703 uvc_ss_streaming_ep.bEndpointAddress =
704 uvc_fs_streaming_ep.bEndpointAddress;
705
706 /* Copy descriptors. */
707 f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER); 686 f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER);
708 }
709 687
710 /* Preallocate control endpoint request. */ 688 /* Preallocate control endpoint request. */
711 uvc->control_req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); 689 uvc->control_req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL);
@@ -740,7 +718,20 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
740 return 0; 718 return 0;
741 719
742error: 720error:
743 uvc_function_unbind(c, f); 721 if (uvc->vdev)
722 video_device_release(uvc->vdev);
723
724 if (uvc->control_ep)
725 uvc->control_ep->driver_data = NULL;
726 if (uvc->video.ep)
727 uvc->video.ep->driver_data = NULL;
728
729 if (uvc->control_req) {
730 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req);
731 kfree(uvc->control_buf);
732 }
733
734 usb_free_all_descriptors(f);
744 return ret; 735 return ret;
745} 736}
746 737
@@ -808,25 +799,16 @@ uvc_bind_config(struct usb_configuration *c,
808 uvc->desc.hs_streaming = hs_streaming; 799 uvc->desc.hs_streaming = hs_streaming;
809 uvc->desc.ss_streaming = ss_streaming; 800 uvc->desc.ss_streaming = ss_streaming;
810 801
811 /* maybe allocate device-global string IDs, and patch descriptors */ 802 /* Allocate string descriptor numbers. */
812 if (uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id == 0) { 803 if (uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id == 0) {
813 /* Allocate string descriptor numbers. */ 804 ret = usb_string_ids_tab(c->cdev, uvc_en_us_strings);
814 ret = usb_string_id(c->cdev); 805 if (ret)
815 if (ret < 0)
816 goto error;
817 uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id = ret;
818 uvc_iad.iFunction = ret;
819
820 ret = usb_string_id(c->cdev);
821 if (ret < 0)
822 goto error;
823 uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id = ret;
824 uvc_control_intf.iInterface = ret;
825
826 ret = usb_string_id(c->cdev);
827 if (ret < 0)
828 goto error; 806 goto error;
829 uvc_en_us_strings[UVC_STRING_STREAMING_IDX].id = ret; 807 uvc_iad.iFunction =
808 uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id;
809 uvc_control_intf.iInterface =
810 uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id;
811 ret = uvc_en_us_strings[UVC_STRING_STREAMING_IDX].id;
830 uvc_streaming_intf_alt0.iInterface = ret; 812 uvc_streaming_intf_alt0.iInterface = ret;
831 uvc_streaming_intf_alt1.iInterface = ret; 813 uvc_streaming_intf_alt1.iInterface = ret;
832 } 814 }
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
deleted file mode 100644
index 3f7d640b6758..000000000000
--- a/drivers/usb/gadget/file_storage.c
+++ /dev/null
@@ -1,3656 +0,0 @@
1/*
2 * file_storage.c -- File-backed USB Storage Gadget, for USB development
3 *
4 * Copyright (C) 2003-2008 Alan Stern
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer,
12 * without modification.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The names of the above-listed copyright holders may not be used
17 * to endorse or promote products derived from this software without
18 * specific prior written permission.
19 *
20 * ALTERNATIVELY, this software may be distributed under the terms of the
21 * GNU General Public License ("GPL") as published by the Free Software
22 * Foundation, either version 2 of that License or (at your option) any
23 * later version.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
26 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38
39/*
40 * The File-backed Storage Gadget acts as a USB Mass Storage device,
41 * appearing to the host as a disk drive or as a CD-ROM drive. In addition
42 * to providing an example of a genuinely useful gadget driver for a USB
43 * device, it also illustrates a technique of double-buffering for increased
44 * throughput. Last but not least, it gives an easy way to probe the
45 * behavior of the Mass Storage drivers in a USB host.
46 *
47 * Backing storage is provided by a regular file or a block device, specified
48 * by the "file" module parameter. Access can be limited to read-only by
49 * setting the optional "ro" module parameter. (For CD-ROM emulation,
50 * access is always read-only.) The gadget will indicate that it has
51 * removable media if the optional "removable" module parameter is set.
52 *
53 * The gadget supports the Control-Bulk (CB), Control-Bulk-Interrupt (CBI),
54 * and Bulk-Only (also known as Bulk-Bulk-Bulk or BBB) transports, selected
55 * by the optional "transport" module parameter. It also supports the
56 * following protocols: RBC (0x01), ATAPI or SFF-8020i (0x02), QIC-157 (0c03),
57 * UFI (0x04), SFF-8070i (0x05), and transparent SCSI (0x06), selected by
58 * the optional "protocol" module parameter. In addition, the default
59 * Vendor ID, Product ID, release number and serial number can be overridden.
60 *
61 * There is support for multiple logical units (LUNs), each of which has
62 * its own backing file. The number of LUNs can be set using the optional
63 * "luns" module parameter (anywhere from 1 to 8), and the corresponding
64 * files are specified using comma-separated lists for "file" and "ro".
65 * The default number of LUNs is taken from the number of "file" elements;
66 * it is 1 if "file" is not given. If "removable" is not set then a backing
67 * file must be specified for each LUN. If it is set, then an unspecified
68 * or empty backing filename means the LUN's medium is not loaded. Ideally
69 * each LUN would be settable independently as a disk drive or a CD-ROM
70 * drive, but currently all LUNs have to be the same type. The CD-ROM
71 * emulation includes a single data track and no audio tracks; hence there
72 * need be only one backing file per LUN.
73 *
74 * Requirements are modest; only a bulk-in and a bulk-out endpoint are
75 * needed (an interrupt-out endpoint is also needed for CBI). The memory
76 * requirement amounts to two 16K buffers, size configurable by a parameter.
77 * Support is included for both full-speed and high-speed operation.
78 *
79 * Note that the driver is slightly non-portable in that it assumes a
80 * single memory/DMA buffer will be useable for bulk-in, bulk-out, and
81 * interrupt-in endpoints. With most device controllers this isn't an
82 * issue, but there may be some with hardware restrictions that prevent
83 * a buffer from being used by more than one endpoint.
84 *
85 * Module options:
86 *
87 * file=filename[,filename...]
88 * Required if "removable" is not set, names of
89 * the files or block devices used for
90 * backing storage
91 * serial=HHHH... Required serial number (string of hex chars)
92 * ro=b[,b...] Default false, booleans for read-only access
93 * removable Default false, boolean for removable media
94 * luns=N Default N = number of filenames, number of
95 * LUNs to support
96 * nofua=b[,b...] Default false, booleans for ignore FUA flag
97 * in SCSI WRITE(10,12) commands
98 * stall Default determined according to the type of
99 * USB device controller (usually true),
100 * boolean to permit the driver to halt
101 * bulk endpoints
102 * cdrom Default false, boolean for whether to emulate
103 * a CD-ROM drive
104 * transport=XXX Default BBB, transport name (CB, CBI, or BBB)
105 * protocol=YYY Default SCSI, protocol name (RBC, 8020 or
106 * ATAPI, QIC, UFI, 8070, or SCSI;
107 * also 1 - 6)
108 * vendor=0xVVVV Default 0x0525 (NetChip), USB Vendor ID
109 * product=0xPPPP Default 0xa4a5 (FSG), USB Product ID
110 * release=0xRRRR Override the USB release number (bcdDevice)
111 * buflen=N Default N=16384, buffer size used (will be
112 * rounded down to a multiple of
113 * PAGE_CACHE_SIZE)
114 *
115 * If CONFIG_USB_FILE_STORAGE_TEST is not set, only the "file", "serial", "ro",
116 * "removable", "luns", "nofua", "stall", and "cdrom" options are available;
117 * default values are used for everything else.
118 *
119 * The pathnames of the backing files and the ro settings are available in
120 * the attribute files "file", "nofua", and "ro" in the lun<n> subdirectory of
121 * the gadget's sysfs directory. If the "removable" option is set, writing to
122 * these files will simulate ejecting/loading the medium (writing an empty
123 * line means eject) and adjusting a write-enable tab. Changes to the ro
124 * setting are not allowed when the medium is loaded or if CD-ROM emulation
125 * is being used.
126 *
127 * This gadget driver is heavily based on "Gadget Zero" by David Brownell.
128 * The driver's SCSI command interface was based on the "Information
129 * technology - Small Computer System Interface - 2" document from
130 * X3T9.2 Project 375D, Revision 10L, 7-SEP-93, available at
131 * <http://www.t10.org/ftp/t10/drafts/s2/s2-r10l.pdf>. The single exception
132 * is opcode 0x23 (READ FORMAT CAPACITIES), which was based on the
133 * "Universal Serial Bus Mass Storage Class UFI Command Specification"
134 * document, Revision 1.0, December 14, 1998, available at
135 * <http://www.usb.org/developers/devclass_docs/usbmass-ufi10.pdf>.
136 */
137
138
139/*
140 * Driver Design
141 *
142 * The FSG driver is fairly straightforward. There is a main kernel
143 * thread that handles most of the work. Interrupt routines field
144 * callbacks from the controller driver: bulk- and interrupt-request
145 * completion notifications, endpoint-0 events, and disconnect events.
146 * Completion events are passed to the main thread by wakeup calls. Many
147 * ep0 requests are handled at interrupt time, but SetInterface,
148 * SetConfiguration, and device reset requests are forwarded to the
149 * thread in the form of "exceptions" using SIGUSR1 signals (since they
150 * should interrupt any ongoing file I/O operations).
151 *
152 * The thread's main routine implements the standard command/data/status
153 * parts of a SCSI interaction. It and its subroutines are full of tests
154 * for pending signals/exceptions -- all this polling is necessary since
155 * the kernel has no setjmp/longjmp equivalents. (Maybe this is an
156 * indication that the driver really wants to be running in userspace.)
157 * An important point is that so long as the thread is alive it keeps an
158 * open reference to the backing file. This will prevent unmounting
159 * the backing file's underlying filesystem and could cause problems
160 * during system shutdown, for example. To prevent such problems, the
161 * thread catches INT, TERM, and KILL signals and converts them into
162 * an EXIT exception.
163 *
164 * In normal operation the main thread is started during the gadget's
165 * fsg_bind() callback and stopped during fsg_unbind(). But it can also
166 * exit when it receives a signal, and there's no point leaving the
167 * gadget running when the thread is dead. So just before the thread
168 * exits, it deregisters the gadget driver. This makes things a little
169 * tricky: The driver is deregistered at two places, and the exiting
170 * thread can indirectly call fsg_unbind() which in turn can tell the
171 * thread to exit. The first problem is resolved through the use of the
172 * REGISTERED atomic bitflag; the driver will only be deregistered once.
173 * The second problem is resolved by having fsg_unbind() check
174 * fsg->state; it won't try to stop the thread if the state is already
175 * FSG_STATE_TERMINATED.
176 *
177 * To provide maximum throughput, the driver uses a circular pipeline of
178 * buffer heads (struct fsg_buffhd). In principle the pipeline can be
179 * arbitrarily long; in practice the benefits don't justify having more
180 * than 2 stages (i.e., double buffering). But it helps to think of the
181 * pipeline as being a long one. Each buffer head contains a bulk-in and
182 * a bulk-out request pointer (since the buffer can be used for both
183 * output and input -- directions always are given from the host's
184 * point of view) as well as a pointer to the buffer and various state
185 * variables.
186 *
187 * Use of the pipeline follows a simple protocol. There is a variable
188 * (fsg->next_buffhd_to_fill) that points to the next buffer head to use.
189 * At any time that buffer head may still be in use from an earlier
190 * request, so each buffer head has a state variable indicating whether
191 * it is EMPTY, FULL, or BUSY. Typical use involves waiting for the
192 * buffer head to be EMPTY, filling the buffer either by file I/O or by
193 * USB I/O (during which the buffer head is BUSY), and marking the buffer
194 * head FULL when the I/O is complete. Then the buffer will be emptied
195 * (again possibly by USB I/O, during which it is marked BUSY) and
196 * finally marked EMPTY again (possibly by a completion routine).
197 *
198 * A module parameter tells the driver to avoid stalling the bulk
199 * endpoints wherever the transport specification allows. This is
200 * necessary for some UDCs like the SuperH, which cannot reliably clear a
201 * halt on a bulk endpoint. However, under certain circumstances the
202 * Bulk-only specification requires a stall. In such cases the driver
203 * will halt the endpoint and set a flag indicating that it should clear
204 * the halt in software during the next device reset. Hopefully this
205 * will permit everything to work correctly. Furthermore, although the
206 * specification allows the bulk-out endpoint to halt when the host sends
207 * too much data, implementing this would cause an unavoidable race.
208 * The driver will always use the "no-stall" approach for OUT transfers.
209 *
210 * One subtle point concerns sending status-stage responses for ep0
211 * requests. Some of these requests, such as device reset, can involve
212 * interrupting an ongoing file I/O operation, which might take an
213 * arbitrarily long time. During that delay the host might give up on
214 * the original ep0 request and issue a new one. When that happens the
215 * driver should not notify the host about completion of the original
216 * request, as the host will no longer be waiting for it. So the driver
217 * assigns to each ep0 request a unique tag, and it keeps track of the
218 * tag value of the request associated with a long-running exception
219 * (device-reset, interface-change, or configuration-change). When the
220 * exception handler is finished, the status-stage response is submitted
221 * only if the current ep0 request tag is equal to the exception request
222 * tag. Thus only the most recently received ep0 request will get a
223 * status-stage response.
224 *
225 * Warning: This driver source file is too long. It ought to be split up
226 * into a header file plus about 3 separate .c files, to handle the details
227 * of the Gadget, USB Mass Storage, and SCSI protocols.
228 */
229
230
231/* #define VERBOSE_DEBUG */
232/* #define DUMP_MSGS */
233
234
235#include <linux/blkdev.h>
236#include <linux/completion.h>
237#include <linux/dcache.h>
238#include <linux/delay.h>
239#include <linux/device.h>
240#include <linux/fcntl.h>
241#include <linux/file.h>
242#include <linux/fs.h>
243#include <linux/kref.h>
244#include <linux/kthread.h>
245#include <linux/limits.h>
246#include <linux/module.h>
247#include <linux/rwsem.h>
248#include <linux/slab.h>
249#include <linux/spinlock.h>
250#include <linux/string.h>
251#include <linux/freezer.h>
252#include <linux/utsname.h>
253
254#include <linux/usb/composite.h>
255#include <linux/usb/ch9.h>
256#include <linux/usb/gadget.h>
257
258#include "gadget_chips.h"
259
260#define DRIVER_DESC "File-backed Storage Gadget"
261#define DRIVER_NAME "g_file_storage"
262#define DRIVER_VERSION "1 September 2010"
263
264static char fsg_string_manufacturer[64];
265static const char fsg_string_product[] = DRIVER_DESC;
266static const char fsg_string_config[] = "Self-powered";
267static const char fsg_string_interface[] = "Mass Storage";
268
269
270#include "storage_common.c"
271
272
273MODULE_DESCRIPTION(DRIVER_DESC);
274MODULE_AUTHOR("Alan Stern");
275MODULE_LICENSE("Dual BSD/GPL");
276
277/*
278 * This driver assumes self-powered hardware and has no way for users to
279 * trigger remote wakeup. It uses autoconfiguration to select endpoints
280 * and endpoint addresses.
281 */
282
283
284/*-------------------------------------------------------------------------*/
285
286
287/* Encapsulate the module parameter settings */
288
289static struct {
290 char *file[FSG_MAX_LUNS];
291 char *serial;
292 bool ro[FSG_MAX_LUNS];
293 bool nofua[FSG_MAX_LUNS];
294 unsigned int num_filenames;
295 unsigned int num_ros;
296 unsigned int num_nofuas;
297 unsigned int nluns;
298
299 bool removable;
300 bool can_stall;
301 bool cdrom;
302
303 char *transport_parm;
304 char *protocol_parm;
305 unsigned short vendor;
306 unsigned short product;
307 unsigned short release;
308 unsigned int buflen;
309
310 int transport_type;
311 char *transport_name;
312 int protocol_type;
313 char *protocol_name;
314
315} mod_data = { // Default values
316 .transport_parm = "BBB",
317 .protocol_parm = "SCSI",
318 .removable = 0,
319 .can_stall = 1,
320 .cdrom = 0,
321 .vendor = FSG_VENDOR_ID,
322 .product = FSG_PRODUCT_ID,
323 .release = 0xffff, // Use controller chip type
324 .buflen = 16384,
325 };
326
327
328module_param_array_named(file, mod_data.file, charp, &mod_data.num_filenames,
329 S_IRUGO);
330MODULE_PARM_DESC(file, "names of backing files or devices");
331
332module_param_named(serial, mod_data.serial, charp, S_IRUGO);
333MODULE_PARM_DESC(serial, "USB serial number");
334
335module_param_array_named(ro, mod_data.ro, bool, &mod_data.num_ros, S_IRUGO);
336MODULE_PARM_DESC(ro, "true to force read-only");
337
338module_param_array_named(nofua, mod_data.nofua, bool, &mod_data.num_nofuas,
339 S_IRUGO);
340MODULE_PARM_DESC(nofua, "true to ignore SCSI WRITE(10,12) FUA bit");
341
342module_param_named(luns, mod_data.nluns, uint, S_IRUGO);
343MODULE_PARM_DESC(luns, "number of LUNs");
344
345module_param_named(removable, mod_data.removable, bool, S_IRUGO);
346MODULE_PARM_DESC(removable, "true to simulate removable media");
347
348module_param_named(stall, mod_data.can_stall, bool, S_IRUGO);
349MODULE_PARM_DESC(stall, "false to prevent bulk stalls");
350
351module_param_named(cdrom, mod_data.cdrom, bool, S_IRUGO);
352MODULE_PARM_DESC(cdrom, "true to emulate cdrom instead of disk");
353
354/* In the non-TEST version, only the module parameters listed above
355 * are available. */
356#ifdef CONFIG_USB_FILE_STORAGE_TEST
357
358module_param_named(transport, mod_data.transport_parm, charp, S_IRUGO);
359MODULE_PARM_DESC(transport, "type of transport (BBB, CBI, or CB)");
360
361module_param_named(protocol, mod_data.protocol_parm, charp, S_IRUGO);
362MODULE_PARM_DESC(protocol, "type of protocol (RBC, 8020, QIC, UFI, "
363 "8070, or SCSI)");
364
365module_param_named(vendor, mod_data.vendor, ushort, S_IRUGO);
366MODULE_PARM_DESC(vendor, "USB Vendor ID");
367
368module_param_named(product, mod_data.product, ushort, S_IRUGO);
369MODULE_PARM_DESC(product, "USB Product ID");
370
371module_param_named(release, mod_data.release, ushort, S_IRUGO);
372MODULE_PARM_DESC(release, "USB release number");
373
374module_param_named(buflen, mod_data.buflen, uint, S_IRUGO);
375MODULE_PARM_DESC(buflen, "I/O buffer size");
376
377#endif /* CONFIG_USB_FILE_STORAGE_TEST */
378
379
380/*
381 * These definitions will permit the compiler to avoid generating code for
382 * parts of the driver that aren't used in the non-TEST version. Even gcc
383 * can recognize when a test of a constant expression yields a dead code
384 * path.
385 */
386
387#ifdef CONFIG_USB_FILE_STORAGE_TEST
388
389#define transport_is_bbb() (mod_data.transport_type == USB_PR_BULK)
390#define transport_is_cbi() (mod_data.transport_type == USB_PR_CBI)
391#define protocol_is_scsi() (mod_data.protocol_type == USB_SC_SCSI)
392
393#else
394
395#define transport_is_bbb() 1
396#define transport_is_cbi() 0
397#define protocol_is_scsi() 1
398
399#endif /* CONFIG_USB_FILE_STORAGE_TEST */
400
401
402/*-------------------------------------------------------------------------*/
403
404
405struct fsg_dev {
406 /* lock protects: state, all the req_busy's, and cbbuf_cmnd */
407 spinlock_t lock;
408 struct usb_gadget *gadget;
409
410 /* filesem protects: backing files in use */
411 struct rw_semaphore filesem;
412
413 /* reference counting: wait until all LUNs are released */
414 struct kref ref;
415
416 struct usb_ep *ep0; // Handy copy of gadget->ep0
417 struct usb_request *ep0req; // For control responses
418 unsigned int ep0_req_tag;
419 const char *ep0req_name;
420
421 struct usb_request *intreq; // For interrupt responses
422 int intreq_busy;
423 struct fsg_buffhd *intr_buffhd;
424
425 unsigned int bulk_out_maxpacket;
426 enum fsg_state state; // For exception handling
427 unsigned int exception_req_tag;
428
429 u8 config, new_config;
430
431 unsigned int running : 1;
432 unsigned int bulk_in_enabled : 1;
433 unsigned int bulk_out_enabled : 1;
434 unsigned int intr_in_enabled : 1;
435 unsigned int phase_error : 1;
436 unsigned int short_packet_received : 1;
437 unsigned int bad_lun_okay : 1;
438
439 unsigned long atomic_bitflags;
440#define REGISTERED 0
441#define IGNORE_BULK_OUT 1
442#define SUSPENDED 2
443
444 struct usb_ep *bulk_in;
445 struct usb_ep *bulk_out;
446 struct usb_ep *intr_in;
447
448 struct fsg_buffhd *next_buffhd_to_fill;
449 struct fsg_buffhd *next_buffhd_to_drain;
450
451 int thread_wakeup_needed;
452 struct completion thread_notifier;
453 struct task_struct *thread_task;
454
455 int cmnd_size;
456 u8 cmnd[MAX_COMMAND_SIZE];
457 enum data_direction data_dir;
458 u32 data_size;
459 u32 data_size_from_cmnd;
460 u32 tag;
461 unsigned int lun;
462 u32 residue;
463 u32 usb_amount_left;
464
465 /* The CB protocol offers no way for a host to know when a command
466 * has completed. As a result the next command may arrive early,
467 * and we will still have to handle it. For that reason we need
468 * a buffer to store new commands when using CB (or CBI, which
469 * does not oblige a host to wait for command completion either). */
470 int cbbuf_cmnd_size;
471 u8 cbbuf_cmnd[MAX_COMMAND_SIZE];
472
473 unsigned int nluns;
474 struct fsg_lun *luns;
475 struct fsg_lun *curlun;
476 /* Must be the last entry */
477 struct fsg_buffhd buffhds[];
478};
479
480typedef void (*fsg_routine_t)(struct fsg_dev *);
481
482static int exception_in_progress(struct fsg_dev *fsg)
483{
484 return (fsg->state > FSG_STATE_IDLE);
485}
486
487/* Make bulk-out requests be divisible by the maxpacket size */
488static void set_bulk_out_req_length(struct fsg_dev *fsg,
489 struct fsg_buffhd *bh, unsigned int length)
490{
491 unsigned int rem;
492
493 bh->bulk_out_intended_length = length;
494 rem = length % fsg->bulk_out_maxpacket;
495 if (rem > 0)
496 length += fsg->bulk_out_maxpacket - rem;
497 bh->outreq->length = length;
498}
499
500static struct fsg_dev *the_fsg;
501static struct usb_gadget_driver fsg_driver;
502
503
504/*-------------------------------------------------------------------------*/
505
506static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep)
507{
508 const char *name;
509
510 if (ep == fsg->bulk_in)
511 name = "bulk-in";
512 else if (ep == fsg->bulk_out)
513 name = "bulk-out";
514 else
515 name = ep->name;
516 DBG(fsg, "%s set halt\n", name);
517 return usb_ep_set_halt(ep);
518}
519
520
521/*-------------------------------------------------------------------------*/
522
523/*
524 * DESCRIPTORS ... most are static, but strings and (full) configuration
525 * descriptors are built on demand. Also the (static) config and interface
526 * descriptors are adjusted during fsg_bind().
527 */
528
529/* There is only one configuration. */
530#define CONFIG_VALUE 1
531
532static struct usb_device_descriptor
533device_desc = {
534 .bLength = sizeof device_desc,
535 .bDescriptorType = USB_DT_DEVICE,
536
537 .bcdUSB = cpu_to_le16(0x0200),
538 .bDeviceClass = USB_CLASS_PER_INTERFACE,
539
540 /* The next three values can be overridden by module parameters */
541 .idVendor = cpu_to_le16(FSG_VENDOR_ID),
542 .idProduct = cpu_to_le16(FSG_PRODUCT_ID),
543 .bcdDevice = cpu_to_le16(0xffff),
544
545 .iManufacturer = FSG_STRING_MANUFACTURER,
546 .iProduct = FSG_STRING_PRODUCT,
547 .iSerialNumber = FSG_STRING_SERIAL,
548 .bNumConfigurations = 1,
549};
550
551static struct usb_config_descriptor
552config_desc = {
553 .bLength = sizeof config_desc,
554 .bDescriptorType = USB_DT_CONFIG,
555
556 /* wTotalLength computed by usb_gadget_config_buf() */
557 .bNumInterfaces = 1,
558 .bConfigurationValue = CONFIG_VALUE,
559 .iConfiguration = FSG_STRING_CONFIG,
560 .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
561 .bMaxPower = CONFIG_USB_GADGET_VBUS_DRAW / 2,
562};
563
564
565static struct usb_qualifier_descriptor
566dev_qualifier = {
567 .bLength = sizeof dev_qualifier,
568 .bDescriptorType = USB_DT_DEVICE_QUALIFIER,
569
570 .bcdUSB = cpu_to_le16(0x0200),
571 .bDeviceClass = USB_CLASS_PER_INTERFACE,
572
573 .bNumConfigurations = 1,
574};
575
576static int populate_bos(struct fsg_dev *fsg, u8 *buf)
577{
578 memcpy(buf, &fsg_bos_desc, USB_DT_BOS_SIZE);
579 buf += USB_DT_BOS_SIZE;
580
581 memcpy(buf, &fsg_ext_cap_desc, USB_DT_USB_EXT_CAP_SIZE);
582 buf += USB_DT_USB_EXT_CAP_SIZE;
583
584 memcpy(buf, &fsg_ss_cap_desc, USB_DT_USB_SS_CAP_SIZE);
585
586 return USB_DT_BOS_SIZE + USB_DT_USB_SS_CAP_SIZE
587 + USB_DT_USB_EXT_CAP_SIZE;
588}
589
590/*
591 * Config descriptors must agree with the code that sets configurations
592 * and with code managing interfaces and their altsettings. They must
593 * also handle different speeds and other-speed requests.
594 */
595static int populate_config_buf(struct usb_gadget *gadget,
596 u8 *buf, u8 type, unsigned index)
597{
598 enum usb_device_speed speed = gadget->speed;
599 int len;
600 const struct usb_descriptor_header **function;
601
602 if (index > 0)
603 return -EINVAL;
604
605 if (gadget_is_dualspeed(gadget) && type == USB_DT_OTHER_SPEED_CONFIG)
606 speed = (USB_SPEED_FULL + USB_SPEED_HIGH) - speed;
607 function = gadget_is_dualspeed(gadget) && speed == USB_SPEED_HIGH
608 ? (const struct usb_descriptor_header **)fsg_hs_function
609 : (const struct usb_descriptor_header **)fsg_fs_function;
610
611 /* for now, don't advertise srp-only devices */
612 if (!gadget_is_otg(gadget))
613 function++;
614
615 len = usb_gadget_config_buf(&config_desc, buf, EP0_BUFSIZE, function);
616 ((struct usb_config_descriptor *) buf)->bDescriptorType = type;
617 return len;
618}
619
620
621/*-------------------------------------------------------------------------*/
622
623/* These routines may be called in process context or in_irq */
624
625/* Caller must hold fsg->lock */
626static void wakeup_thread(struct fsg_dev *fsg)
627{
628 /* Tell the main thread that something has happened */
629 fsg->thread_wakeup_needed = 1;
630 if (fsg->thread_task)
631 wake_up_process(fsg->thread_task);
632}
633
634
635static void raise_exception(struct fsg_dev *fsg, enum fsg_state new_state)
636{
637 unsigned long flags;
638
639 /* Do nothing if a higher-priority exception is already in progress.
640 * If a lower-or-equal priority exception is in progress, preempt it
641 * and notify the main thread by sending it a signal. */
642 spin_lock_irqsave(&fsg->lock, flags);
643 if (fsg->state <= new_state) {
644 fsg->exception_req_tag = fsg->ep0_req_tag;
645 fsg->state = new_state;
646 if (fsg->thread_task)
647 send_sig_info(SIGUSR1, SEND_SIG_FORCED,
648 fsg->thread_task);
649 }
650 spin_unlock_irqrestore(&fsg->lock, flags);
651}
652
653
654/*-------------------------------------------------------------------------*/
655
656/* The disconnect callback and ep0 routines. These always run in_irq,
657 * except that ep0_queue() is called in the main thread to acknowledge
658 * completion of various requests: set config, set interface, and
659 * Bulk-only device reset. */
660
661static void fsg_disconnect(struct usb_gadget *gadget)
662{
663 struct fsg_dev *fsg = get_gadget_data(gadget);
664
665 DBG(fsg, "disconnect or port reset\n");
666 raise_exception(fsg, FSG_STATE_DISCONNECT);
667}
668
669
670static int ep0_queue(struct fsg_dev *fsg)
671{
672 int rc;
673
674 rc = usb_ep_queue(fsg->ep0, fsg->ep0req, GFP_ATOMIC);
675 if (rc != 0 && rc != -ESHUTDOWN) {
676
677 /* We can't do much more than wait for a reset */
678 WARNING(fsg, "error in submission: %s --> %d\n",
679 fsg->ep0->name, rc);
680 }
681 return rc;
682}
683
684static void ep0_complete(struct usb_ep *ep, struct usb_request *req)
685{
686 struct fsg_dev *fsg = ep->driver_data;
687
688 if (req->actual > 0)
689 dump_msg(fsg, fsg->ep0req_name, req->buf, req->actual);
690 if (req->status || req->actual != req->length)
691 DBG(fsg, "%s --> %d, %u/%u\n", __func__,
692 req->status, req->actual, req->length);
693 if (req->status == -ECONNRESET) // Request was cancelled
694 usb_ep_fifo_flush(ep);
695
696 if (req->status == 0 && req->context)
697 ((fsg_routine_t) (req->context))(fsg);
698}
699
700
701/*-------------------------------------------------------------------------*/
702
703/* Bulk and interrupt endpoint completion handlers.
704 * These always run in_irq. */
705
706static void bulk_in_complete(struct usb_ep *ep, struct usb_request *req)
707{
708 struct fsg_dev *fsg = ep->driver_data;
709 struct fsg_buffhd *bh = req->context;
710
711 if (req->status || req->actual != req->length)
712 DBG(fsg, "%s --> %d, %u/%u\n", __func__,
713 req->status, req->actual, req->length);
714 if (req->status == -ECONNRESET) // Request was cancelled
715 usb_ep_fifo_flush(ep);
716
717 /* Hold the lock while we update the request and buffer states */
718 smp_wmb();
719 spin_lock(&fsg->lock);
720 bh->inreq_busy = 0;
721 bh->state = BUF_STATE_EMPTY;
722 wakeup_thread(fsg);
723 spin_unlock(&fsg->lock);
724}
725
726static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req)
727{
728 struct fsg_dev *fsg = ep->driver_data;
729 struct fsg_buffhd *bh = req->context;
730
731 dump_msg(fsg, "bulk-out", req->buf, req->actual);
732 if (req->status || req->actual != bh->bulk_out_intended_length)
733 DBG(fsg, "%s --> %d, %u/%u\n", __func__,
734 req->status, req->actual,
735 bh->bulk_out_intended_length);
736 if (req->status == -ECONNRESET) // Request was cancelled
737 usb_ep_fifo_flush(ep);
738
739 /* Hold the lock while we update the request and buffer states */
740 smp_wmb();
741 spin_lock(&fsg->lock);
742 bh->outreq_busy = 0;
743 bh->state = BUF_STATE_FULL;
744 wakeup_thread(fsg);
745 spin_unlock(&fsg->lock);
746}
747
748
749#ifdef CONFIG_USB_FILE_STORAGE_TEST
750static void intr_in_complete(struct usb_ep *ep, struct usb_request *req)
751{
752 struct fsg_dev *fsg = ep->driver_data;
753 struct fsg_buffhd *bh = req->context;
754
755 if (req->status || req->actual != req->length)
756 DBG(fsg, "%s --> %d, %u/%u\n", __func__,
757 req->status, req->actual, req->length);
758 if (req->status == -ECONNRESET) // Request was cancelled
759 usb_ep_fifo_flush(ep);
760
761 /* Hold the lock while we update the request and buffer states */
762 smp_wmb();
763 spin_lock(&fsg->lock);
764 fsg->intreq_busy = 0;
765 bh->state = BUF_STATE_EMPTY;
766 wakeup_thread(fsg);
767 spin_unlock(&fsg->lock);
768}
769
770#else
771static void intr_in_complete(struct usb_ep *ep, struct usb_request *req)
772{}
773#endif /* CONFIG_USB_FILE_STORAGE_TEST */
774
775
776/*-------------------------------------------------------------------------*/
777
778/* Ep0 class-specific handlers. These always run in_irq. */
779
780#ifdef CONFIG_USB_FILE_STORAGE_TEST
781static void received_cbi_adsc(struct fsg_dev *fsg, struct fsg_buffhd *bh)
782{
783 struct usb_request *req = fsg->ep0req;
784 static u8 cbi_reset_cmnd[6] = {
785 SEND_DIAGNOSTIC, 4, 0xff, 0xff, 0xff, 0xff};
786
787 /* Error in command transfer? */
788 if (req->status || req->length != req->actual ||
789 req->actual < 6 || req->actual > MAX_COMMAND_SIZE) {
790
791 /* Not all controllers allow a protocol stall after
792 * receiving control-out data, but we'll try anyway. */
793 fsg_set_halt(fsg, fsg->ep0);
794 return; // Wait for reset
795 }
796
797 /* Is it the special reset command? */
798 if (req->actual >= sizeof cbi_reset_cmnd &&
799 memcmp(req->buf, cbi_reset_cmnd,
800 sizeof cbi_reset_cmnd) == 0) {
801
802 /* Raise an exception to stop the current operation
803 * and reinitialize our state. */
804 DBG(fsg, "cbi reset request\n");
805 raise_exception(fsg, FSG_STATE_RESET);
806 return;
807 }
808
809 VDBG(fsg, "CB[I] accept device-specific command\n");
810 spin_lock(&fsg->lock);
811
812 /* Save the command for later */
813 if (fsg->cbbuf_cmnd_size)
814 WARNING(fsg, "CB[I] overwriting previous command\n");
815 fsg->cbbuf_cmnd_size = req->actual;
816 memcpy(fsg->cbbuf_cmnd, req->buf, fsg->cbbuf_cmnd_size);
817
818 wakeup_thread(fsg);
819 spin_unlock(&fsg->lock);
820}
821
822#else
823static void received_cbi_adsc(struct fsg_dev *fsg, struct fsg_buffhd *bh)
824{}
825#endif /* CONFIG_USB_FILE_STORAGE_TEST */
826
827
828static int class_setup_req(struct fsg_dev *fsg,
829 const struct usb_ctrlrequest *ctrl)
830{
831 struct usb_request *req = fsg->ep0req;
832 int value = -EOPNOTSUPP;
833 u16 w_index = le16_to_cpu(ctrl->wIndex);
834 u16 w_value = le16_to_cpu(ctrl->wValue);
835 u16 w_length = le16_to_cpu(ctrl->wLength);
836
837 if (!fsg->config)
838 return value;
839
840 /* Handle Bulk-only class-specific requests */
841 if (transport_is_bbb()) {
842 switch (ctrl->bRequest) {
843
844 case US_BULK_RESET_REQUEST:
845 if (ctrl->bRequestType != (USB_DIR_OUT |
846 USB_TYPE_CLASS | USB_RECIP_INTERFACE))
847 break;
848 if (w_index != 0 || w_value != 0 || w_length != 0) {
849 value = -EDOM;
850 break;
851 }
852
853 /* Raise an exception to stop the current operation
854 * and reinitialize our state. */
855 DBG(fsg, "bulk reset request\n");
856 raise_exception(fsg, FSG_STATE_RESET);
857 value = DELAYED_STATUS;
858 break;
859
860 case US_BULK_GET_MAX_LUN:
861 if (ctrl->bRequestType != (USB_DIR_IN |
862 USB_TYPE_CLASS | USB_RECIP_INTERFACE))
863 break;
864 if (w_index != 0 || w_value != 0 || w_length != 1) {
865 value = -EDOM;
866 break;
867 }
868 VDBG(fsg, "get max LUN\n");
869 *(u8 *) req->buf = fsg->nluns - 1;
870 value = 1;
871 break;
872 }
873 }
874
875 /* Handle CBI class-specific requests */
876 else {
877 switch (ctrl->bRequest) {
878
879 case USB_CBI_ADSC_REQUEST:
880 if (ctrl->bRequestType != (USB_DIR_OUT |
881 USB_TYPE_CLASS | USB_RECIP_INTERFACE))
882 break;
883 if (w_index != 0 || w_value != 0) {
884 value = -EDOM;
885 break;
886 }
887 if (w_length > MAX_COMMAND_SIZE) {
888 value = -EOVERFLOW;
889 break;
890 }
891 value = w_length;
892 fsg->ep0req->context = received_cbi_adsc;
893 break;
894 }
895 }
896
897 if (value == -EOPNOTSUPP)
898 VDBG(fsg,
899 "unknown class-specific control req "
900 "%02x.%02x v%04x i%04x l%u\n",
901 ctrl->bRequestType, ctrl->bRequest,
902 le16_to_cpu(ctrl->wValue), w_index, w_length);
903 return value;
904}
905
906
907/*-------------------------------------------------------------------------*/
908
909/* Ep0 standard request handlers. These always run in_irq. */
910
911static int standard_setup_req(struct fsg_dev *fsg,
912 const struct usb_ctrlrequest *ctrl)
913{
914 struct usb_request *req = fsg->ep0req;
915 int value = -EOPNOTSUPP;
916 u16 w_index = le16_to_cpu(ctrl->wIndex);
917 u16 w_value = le16_to_cpu(ctrl->wValue);
918
919 /* Usually this just stores reply data in the pre-allocated ep0 buffer,
920 * but config change events will also reconfigure hardware. */
921 switch (ctrl->bRequest) {
922
923 case USB_REQ_GET_DESCRIPTOR:
924 if (ctrl->bRequestType != (USB_DIR_IN | USB_TYPE_STANDARD |
925 USB_RECIP_DEVICE))
926 break;
927 switch (w_value >> 8) {
928
929 case USB_DT_DEVICE:
930 VDBG(fsg, "get device descriptor\n");
931 device_desc.bMaxPacketSize0 = fsg->ep0->maxpacket;
932 value = sizeof device_desc;
933 memcpy(req->buf, &device_desc, value);
934 break;
935 case USB_DT_DEVICE_QUALIFIER:
936 VDBG(fsg, "get device qualifier\n");
937 if (!gadget_is_dualspeed(fsg->gadget) ||
938 fsg->gadget->speed == USB_SPEED_SUPER)
939 break;
940 /*
941 * Assume ep0 uses the same maxpacket value for both
942 * speeds
943 */
944 dev_qualifier.bMaxPacketSize0 = fsg->ep0->maxpacket;
945 value = sizeof dev_qualifier;
946 memcpy(req->buf, &dev_qualifier, value);
947 break;
948
949 case USB_DT_OTHER_SPEED_CONFIG:
950 VDBG(fsg, "get other-speed config descriptor\n");
951 if (!gadget_is_dualspeed(fsg->gadget) ||
952 fsg->gadget->speed == USB_SPEED_SUPER)
953 break;
954 goto get_config;
955 case USB_DT_CONFIG:
956 VDBG(fsg, "get configuration descriptor\n");
957get_config:
958 value = populate_config_buf(fsg->gadget,
959 req->buf,
960 w_value >> 8,
961 w_value & 0xff);
962 break;
963
964 case USB_DT_STRING:
965 VDBG(fsg, "get string descriptor\n");
966
967 /* wIndex == language code */
968 value = usb_gadget_get_string(&fsg_stringtab,
969 w_value & 0xff, req->buf);
970 break;
971
972 case USB_DT_BOS:
973 VDBG(fsg, "get bos descriptor\n");
974
975 if (gadget_is_superspeed(fsg->gadget))
976 value = populate_bos(fsg, req->buf);
977 break;
978 }
979
980 break;
981
982 /* One config, two speeds */
983 case USB_REQ_SET_CONFIGURATION:
984 if (ctrl->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD |
985 USB_RECIP_DEVICE))
986 break;
987 VDBG(fsg, "set configuration\n");
988 if (w_value == CONFIG_VALUE || w_value == 0) {
989 fsg->new_config = w_value;
990
991 /* Raise an exception to wipe out previous transaction
992 * state (queued bufs, etc) and set the new config. */
993 raise_exception(fsg, FSG_STATE_CONFIG_CHANGE);
994 value = DELAYED_STATUS;
995 }
996 break;
997 case USB_REQ_GET_CONFIGURATION:
998 if (ctrl->bRequestType != (USB_DIR_IN | USB_TYPE_STANDARD |
999 USB_RECIP_DEVICE))
1000 break;
1001 VDBG(fsg, "get configuration\n");
1002 *(u8 *) req->buf = fsg->config;
1003 value = 1;
1004 break;
1005
1006 case USB_REQ_SET_INTERFACE:
1007 if (ctrl->bRequestType != (USB_DIR_OUT| USB_TYPE_STANDARD |
1008 USB_RECIP_INTERFACE))
1009 break;
1010 if (fsg->config && w_index == 0) {
1011
1012 /* Raise an exception to wipe out previous transaction
1013 * state (queued bufs, etc) and install the new
1014 * interface altsetting. */
1015 raise_exception(fsg, FSG_STATE_INTERFACE_CHANGE);
1016 value = DELAYED_STATUS;
1017 }
1018 break;
1019 case USB_REQ_GET_INTERFACE:
1020 if (ctrl->bRequestType != (USB_DIR_IN | USB_TYPE_STANDARD |
1021 USB_RECIP_INTERFACE))
1022 break;
1023 if (!fsg->config)
1024 break;
1025 if (w_index != 0) {
1026 value = -EDOM;
1027 break;
1028 }
1029 VDBG(fsg, "get interface\n");
1030 *(u8 *) req->buf = 0;
1031 value = 1;
1032 break;
1033
1034 default:
1035 VDBG(fsg,
1036 "unknown control req %02x.%02x v%04x i%04x l%u\n",
1037 ctrl->bRequestType, ctrl->bRequest,
1038 w_value, w_index, le16_to_cpu(ctrl->wLength));
1039 }
1040
1041 return value;
1042}
1043
1044
1045static int fsg_setup(struct usb_gadget *gadget,
1046 const struct usb_ctrlrequest *ctrl)
1047{
1048 struct fsg_dev *fsg = get_gadget_data(gadget);
1049 int rc;
1050 int w_length = le16_to_cpu(ctrl->wLength);
1051
1052 ++fsg->ep0_req_tag; // Record arrival of a new request
1053 fsg->ep0req->context = NULL;
1054 fsg->ep0req->length = 0;
1055 dump_msg(fsg, "ep0-setup", (u8 *) ctrl, sizeof(*ctrl));
1056
1057 if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_CLASS)
1058 rc = class_setup_req(fsg, ctrl);
1059 else
1060 rc = standard_setup_req(fsg, ctrl);
1061
1062 /* Respond with data/status or defer until later? */
1063 if (rc >= 0 && rc != DELAYED_STATUS) {
1064 rc = min(rc, w_length);
1065 fsg->ep0req->length = rc;
1066 fsg->ep0req->zero = rc < w_length;
1067 fsg->ep0req_name = (ctrl->bRequestType & USB_DIR_IN ?
1068 "ep0-in" : "ep0-out");
1069 rc = ep0_queue(fsg);
1070 }
1071
1072 /* Device either stalls (rc < 0) or reports success */
1073 return rc;
1074}
1075
1076
1077/*-------------------------------------------------------------------------*/
1078
1079/* All the following routines run in process context */
1080
1081
1082/* Use this for bulk or interrupt transfers, not ep0 */
1083static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep,
1084 struct usb_request *req, int *pbusy,
1085 enum fsg_buffer_state *state)
1086{
1087 int rc;
1088
1089 if (ep == fsg->bulk_in)
1090 dump_msg(fsg, "bulk-in", req->buf, req->length);
1091 else if (ep == fsg->intr_in)
1092 dump_msg(fsg, "intr-in", req->buf, req->length);
1093
1094 spin_lock_irq(&fsg->lock);
1095 *pbusy = 1;
1096 *state = BUF_STATE_BUSY;
1097 spin_unlock_irq(&fsg->lock);
1098 rc = usb_ep_queue(ep, req, GFP_KERNEL);
1099 if (rc != 0) {
1100 *pbusy = 0;
1101 *state = BUF_STATE_EMPTY;
1102
1103 /* We can't do much more than wait for a reset */
1104
1105 /* Note: currently the net2280 driver fails zero-length
1106 * submissions if DMA is enabled. */
1107 if (rc != -ESHUTDOWN && !(rc == -EOPNOTSUPP &&
1108 req->length == 0))
1109 WARNING(fsg, "error in submission: %s --> %d\n",
1110 ep->name, rc);
1111 }
1112}
1113
1114
1115static int sleep_thread(struct fsg_dev *fsg)
1116{
1117 int rc = 0;
1118
1119 /* Wait until a signal arrives or we are woken up */
1120 for (;;) {
1121 try_to_freeze();
1122 set_current_state(TASK_INTERRUPTIBLE);
1123 if (signal_pending(current)) {
1124 rc = -EINTR;
1125 break;
1126 }
1127 if (fsg->thread_wakeup_needed)
1128 break;
1129 schedule();
1130 }
1131 __set_current_state(TASK_RUNNING);
1132 fsg->thread_wakeup_needed = 0;
1133 return rc;
1134}
1135
1136
1137/*-------------------------------------------------------------------------*/
1138
1139static int do_read(struct fsg_dev *fsg)
1140{
1141 struct fsg_lun *curlun = fsg->curlun;
1142 u32 lba;
1143 struct fsg_buffhd *bh;
1144 int rc;
1145 u32 amount_left;
1146 loff_t file_offset, file_offset_tmp;
1147 unsigned int amount;
1148 ssize_t nread;
1149
1150 /* Get the starting Logical Block Address and check that it's
1151 * not too big */
1152 if (fsg->cmnd[0] == READ_6)
1153 lba = get_unaligned_be24(&fsg->cmnd[1]);
1154 else {
1155 lba = get_unaligned_be32(&fsg->cmnd[2]);
1156
1157 /* We allow DPO (Disable Page Out = don't save data in the
1158 * cache) and FUA (Force Unit Access = don't read from the
1159 * cache), but we don't implement them. */
1160 if ((fsg->cmnd[1] & ~0x18) != 0) {
1161 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1162 return -EINVAL;
1163 }
1164 }
1165 if (lba >= curlun->num_sectors) {
1166 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
1167 return -EINVAL;
1168 }
1169 file_offset = ((loff_t) lba) << curlun->blkbits;
1170
1171 /* Carry out the file reads */
1172 amount_left = fsg->data_size_from_cmnd;
1173 if (unlikely(amount_left == 0))
1174 return -EIO; // No default reply
1175
1176 for (;;) {
1177
1178 /* Figure out how much we need to read:
1179 * Try to read the remaining amount.
1180 * But don't read more than the buffer size.
1181 * And don't try to read past the end of the file.
1182 */
1183 amount = min((unsigned int) amount_left, mod_data.buflen);
1184 amount = min((loff_t) amount,
1185 curlun->file_length - file_offset);
1186
1187 /* Wait for the next buffer to become available */
1188 bh = fsg->next_buffhd_to_fill;
1189 while (bh->state != BUF_STATE_EMPTY) {
1190 rc = sleep_thread(fsg);
1191 if (rc)
1192 return rc;
1193 }
1194
1195 /* If we were asked to read past the end of file,
1196 * end with an empty buffer. */
1197 if (amount == 0) {
1198 curlun->sense_data =
1199 SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
1200 curlun->sense_data_info = file_offset >> curlun->blkbits;
1201 curlun->info_valid = 1;
1202 bh->inreq->length = 0;
1203 bh->state = BUF_STATE_FULL;
1204 break;
1205 }
1206
1207 /* Perform the read */
1208 file_offset_tmp = file_offset;
1209 nread = vfs_read(curlun->filp,
1210 (char __user *) bh->buf,
1211 amount, &file_offset_tmp);
1212 VLDBG(curlun, "file read %u @ %llu -> %d\n", amount,
1213 (unsigned long long) file_offset,
1214 (int) nread);
1215 if (signal_pending(current))
1216 return -EINTR;
1217
1218 if (nread < 0) {
1219 LDBG(curlun, "error in file read: %d\n",
1220 (int) nread);
1221 nread = 0;
1222 } else if (nread < amount) {
1223 LDBG(curlun, "partial file read: %d/%u\n",
1224 (int) nread, amount);
1225 nread = round_down(nread, curlun->blksize);
1226 }
1227 file_offset += nread;
1228 amount_left -= nread;
1229 fsg->residue -= nread;
1230
1231 /* Except at the end of the transfer, nread will be
1232 * equal to the buffer size, which is divisible by the
1233 * bulk-in maxpacket size.
1234 */
1235 bh->inreq->length = nread;
1236 bh->state = BUF_STATE_FULL;
1237
1238 /* If an error occurred, report it and its position */
1239 if (nread < amount) {
1240 curlun->sense_data = SS_UNRECOVERED_READ_ERROR;
1241 curlun->sense_data_info = file_offset >> curlun->blkbits;
1242 curlun->info_valid = 1;
1243 break;
1244 }
1245
1246 if (amount_left == 0)
1247 break; // No more left to read
1248
1249 /* Send this buffer and go read some more */
1250 bh->inreq->zero = 0;
1251 start_transfer(fsg, fsg->bulk_in, bh->inreq,
1252 &bh->inreq_busy, &bh->state);
1253 fsg->next_buffhd_to_fill = bh->next;
1254 }
1255
1256 return -EIO; // No default reply
1257}
1258
1259
1260/*-------------------------------------------------------------------------*/
1261
1262static int do_write(struct fsg_dev *fsg)
1263{
1264 struct fsg_lun *curlun = fsg->curlun;
1265 u32 lba;
1266 struct fsg_buffhd *bh;
1267 int get_some_more;
1268 u32 amount_left_to_req, amount_left_to_write;
1269 loff_t usb_offset, file_offset, file_offset_tmp;
1270 unsigned int amount;
1271 ssize_t nwritten;
1272 int rc;
1273
1274 if (curlun->ro) {
1275 curlun->sense_data = SS_WRITE_PROTECTED;
1276 return -EINVAL;
1277 }
1278 spin_lock(&curlun->filp->f_lock);
1279 curlun->filp->f_flags &= ~O_SYNC; // Default is not to wait
1280 spin_unlock(&curlun->filp->f_lock);
1281
1282 /* Get the starting Logical Block Address and check that it's
1283 * not too big */
1284 if (fsg->cmnd[0] == WRITE_6)
1285 lba = get_unaligned_be24(&fsg->cmnd[1]);
1286 else {
1287 lba = get_unaligned_be32(&fsg->cmnd[2]);
1288
1289 /* We allow DPO (Disable Page Out = don't save data in the
1290 * cache) and FUA (Force Unit Access = write directly to the
1291 * medium). We don't implement DPO; we implement FUA by
1292 * performing synchronous output. */
1293 if ((fsg->cmnd[1] & ~0x18) != 0) {
1294 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1295 return -EINVAL;
1296 }
1297 /* FUA */
1298 if (!curlun->nofua && (fsg->cmnd[1] & 0x08)) {
1299 spin_lock(&curlun->filp->f_lock);
1300 curlun->filp->f_flags |= O_DSYNC;
1301 spin_unlock(&curlun->filp->f_lock);
1302 }
1303 }
1304 if (lba >= curlun->num_sectors) {
1305 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
1306 return -EINVAL;
1307 }
1308
1309 /* Carry out the file writes */
1310 get_some_more = 1;
1311 file_offset = usb_offset = ((loff_t) lba) << curlun->blkbits;
1312 amount_left_to_req = amount_left_to_write = fsg->data_size_from_cmnd;
1313
1314 while (amount_left_to_write > 0) {
1315
1316 /* Queue a request for more data from the host */
1317 bh = fsg->next_buffhd_to_fill;
1318 if (bh->state == BUF_STATE_EMPTY && get_some_more) {
1319
1320 /* Figure out how much we want to get:
1321 * Try to get the remaining amount,
1322 * but not more than the buffer size.
1323 */
1324 amount = min(amount_left_to_req, mod_data.buflen);
1325
1326 /* Beyond the end of the backing file? */
1327 if (usb_offset >= curlun->file_length) {
1328 get_some_more = 0;
1329 curlun->sense_data =
1330 SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
1331 curlun->sense_data_info = usb_offset >> curlun->blkbits;
1332 curlun->info_valid = 1;
1333 continue;
1334 }
1335
1336 /* Get the next buffer */
1337 usb_offset += amount;
1338 fsg->usb_amount_left -= amount;
1339 amount_left_to_req -= amount;
1340 if (amount_left_to_req == 0)
1341 get_some_more = 0;
1342
1343 /* Except at the end of the transfer, amount will be
1344 * equal to the buffer size, which is divisible by
1345 * the bulk-out maxpacket size.
1346 */
1347 set_bulk_out_req_length(fsg, bh, amount);
1348 start_transfer(fsg, fsg->bulk_out, bh->outreq,
1349 &bh->outreq_busy, &bh->state);
1350 fsg->next_buffhd_to_fill = bh->next;
1351 continue;
1352 }
1353
1354 /* Write the received data to the backing file */
1355 bh = fsg->next_buffhd_to_drain;
1356 if (bh->state == BUF_STATE_EMPTY && !get_some_more)
1357 break; // We stopped early
1358 if (bh->state == BUF_STATE_FULL) {
1359 smp_rmb();
1360 fsg->next_buffhd_to_drain = bh->next;
1361 bh->state = BUF_STATE_EMPTY;
1362
1363 /* Did something go wrong with the transfer? */
1364 if (bh->outreq->status != 0) {
1365 curlun->sense_data = SS_COMMUNICATION_FAILURE;
1366 curlun->sense_data_info = file_offset >> curlun->blkbits;
1367 curlun->info_valid = 1;
1368 break;
1369 }
1370
1371 amount = bh->outreq->actual;
1372 if (curlun->file_length - file_offset < amount) {
1373 LERROR(curlun,
1374 "write %u @ %llu beyond end %llu\n",
1375 amount, (unsigned long long) file_offset,
1376 (unsigned long long) curlun->file_length);
1377 amount = curlun->file_length - file_offset;
1378 }
1379
1380 /* Don't accept excess data. The spec doesn't say
1381 * what to do in this case. We'll ignore the error.
1382 */
1383 amount = min(amount, bh->bulk_out_intended_length);
1384
1385 /* Don't write a partial block */
1386 amount = round_down(amount, curlun->blksize);
1387 if (amount == 0)
1388 goto empty_write;
1389
1390 /* Perform the write */
1391 file_offset_tmp = file_offset;
1392 nwritten = vfs_write(curlun->filp,
1393 (char __user *) bh->buf,
1394 amount, &file_offset_tmp);
1395 VLDBG(curlun, "file write %u @ %llu -> %d\n", amount,
1396 (unsigned long long) file_offset,
1397 (int) nwritten);
1398 if (signal_pending(current))
1399 return -EINTR; // Interrupted!
1400
1401 if (nwritten < 0) {
1402 LDBG(curlun, "error in file write: %d\n",
1403 (int) nwritten);
1404 nwritten = 0;
1405 } else if (nwritten < amount) {
1406 LDBG(curlun, "partial file write: %d/%u\n",
1407 (int) nwritten, amount);
1408 nwritten = round_down(nwritten, curlun->blksize);
1409 }
1410 file_offset += nwritten;
1411 amount_left_to_write -= nwritten;
1412 fsg->residue -= nwritten;
1413
1414 /* If an error occurred, report it and its position */
1415 if (nwritten < amount) {
1416 curlun->sense_data = SS_WRITE_ERROR;
1417 curlun->sense_data_info = file_offset >> curlun->blkbits;
1418 curlun->info_valid = 1;
1419 break;
1420 }
1421
1422 empty_write:
1423 /* Did the host decide to stop early? */
1424 if (bh->outreq->actual < bh->bulk_out_intended_length) {
1425 fsg->short_packet_received = 1;
1426 break;
1427 }
1428 continue;
1429 }
1430
1431 /* Wait for something to happen */
1432 rc = sleep_thread(fsg);
1433 if (rc)
1434 return rc;
1435 }
1436
1437 return -EIO; // No default reply
1438}
1439
1440
1441/*-------------------------------------------------------------------------*/
1442
1443static int do_synchronize_cache(struct fsg_dev *fsg)
1444{
1445 struct fsg_lun *curlun = fsg->curlun;
1446 int rc;
1447
1448 /* We ignore the requested LBA and write out all file's
1449 * dirty data buffers. */
1450 rc = fsg_lun_fsync_sub(curlun);
1451 if (rc)
1452 curlun->sense_data = SS_WRITE_ERROR;
1453 return 0;
1454}
1455
1456
1457/*-------------------------------------------------------------------------*/
1458
1459static void invalidate_sub(struct fsg_lun *curlun)
1460{
1461 struct file *filp = curlun->filp;
1462 struct inode *inode = filp->f_path.dentry->d_inode;
1463 unsigned long rc;
1464
1465 rc = invalidate_mapping_pages(inode->i_mapping, 0, -1);
1466 VLDBG(curlun, "invalidate_mapping_pages -> %ld\n", rc);
1467}
1468
1469static int do_verify(struct fsg_dev *fsg)
1470{
1471 struct fsg_lun *curlun = fsg->curlun;
1472 u32 lba;
1473 u32 verification_length;
1474 struct fsg_buffhd *bh = fsg->next_buffhd_to_fill;
1475 loff_t file_offset, file_offset_tmp;
1476 u32 amount_left;
1477 unsigned int amount;
1478 ssize_t nread;
1479
1480 /* Get the starting Logical Block Address and check that it's
1481 * not too big */
1482 lba = get_unaligned_be32(&fsg->cmnd[2]);
1483 if (lba >= curlun->num_sectors) {
1484 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
1485 return -EINVAL;
1486 }
1487
1488 /* We allow DPO (Disable Page Out = don't save data in the
1489 * cache) but we don't implement it. */
1490 if ((fsg->cmnd[1] & ~0x10) != 0) {
1491 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1492 return -EINVAL;
1493 }
1494
1495 verification_length = get_unaligned_be16(&fsg->cmnd[7]);
1496 if (unlikely(verification_length == 0))
1497 return -EIO; // No default reply
1498
1499 /* Prepare to carry out the file verify */
1500 amount_left = verification_length << curlun->blkbits;
1501 file_offset = ((loff_t) lba) << curlun->blkbits;
1502
1503 /* Write out all the dirty buffers before invalidating them */
1504 fsg_lun_fsync_sub(curlun);
1505 if (signal_pending(current))
1506 return -EINTR;
1507
1508 invalidate_sub(curlun);
1509 if (signal_pending(current))
1510 return -EINTR;
1511
1512 /* Just try to read the requested blocks */
1513 while (amount_left > 0) {
1514
1515 /* Figure out how much we need to read:
1516 * Try to read the remaining amount, but not more than
1517 * the buffer size.
1518 * And don't try to read past the end of the file.
1519 */
1520 amount = min((unsigned int) amount_left, mod_data.buflen);
1521 amount = min((loff_t) amount,
1522 curlun->file_length - file_offset);
1523 if (amount == 0) {
1524 curlun->sense_data =
1525 SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
1526 curlun->sense_data_info = file_offset >> curlun->blkbits;
1527 curlun->info_valid = 1;
1528 break;
1529 }
1530
1531 /* Perform the read */
1532 file_offset_tmp = file_offset;
1533 nread = vfs_read(curlun->filp,
1534 (char __user *) bh->buf,
1535 amount, &file_offset_tmp);
1536 VLDBG(curlun, "file read %u @ %llu -> %d\n", amount,
1537 (unsigned long long) file_offset,
1538 (int) nread);
1539 if (signal_pending(current))
1540 return -EINTR;
1541
1542 if (nread < 0) {
1543 LDBG(curlun, "error in file verify: %d\n",
1544 (int) nread);
1545 nread = 0;
1546 } else if (nread < amount) {
1547 LDBG(curlun, "partial file verify: %d/%u\n",
1548 (int) nread, amount);
1549 nread = round_down(nread, curlun->blksize);
1550 }
1551 if (nread == 0) {
1552 curlun->sense_data = SS_UNRECOVERED_READ_ERROR;
1553 curlun->sense_data_info = file_offset >> curlun->blkbits;
1554 curlun->info_valid = 1;
1555 break;
1556 }
1557 file_offset += nread;
1558 amount_left -= nread;
1559 }
1560 return 0;
1561}
1562
1563
1564/*-------------------------------------------------------------------------*/
1565
1566static int do_inquiry(struct fsg_dev *fsg, struct fsg_buffhd *bh)
1567{
1568 u8 *buf = (u8 *) bh->buf;
1569
1570 static char vendor_id[] = "Linux ";
1571 static char product_disk_id[] = "File-Stor Gadget";
1572 static char product_cdrom_id[] = "File-CD Gadget ";
1573
1574 if (!fsg->curlun) { // Unsupported LUNs are okay
1575 fsg->bad_lun_okay = 1;
1576 memset(buf, 0, 36);
1577 buf[0] = 0x7f; // Unsupported, no device-type
1578 buf[4] = 31; // Additional length
1579 return 36;
1580 }
1581
1582 memset(buf, 0, 8);
1583 buf[0] = (mod_data.cdrom ? TYPE_ROM : TYPE_DISK);
1584 if (mod_data.removable)
1585 buf[1] = 0x80;
1586 buf[2] = 2; // ANSI SCSI level 2
1587 buf[3] = 2; // SCSI-2 INQUIRY data format
1588 buf[4] = 31; // Additional length
1589 // No special options
1590 sprintf(buf + 8, "%-8s%-16s%04x", vendor_id,
1591 (mod_data.cdrom ? product_cdrom_id :
1592 product_disk_id),
1593 mod_data.release);
1594 return 36;
1595}
1596
1597
1598static int do_request_sense(struct fsg_dev *fsg, struct fsg_buffhd *bh)
1599{
1600 struct fsg_lun *curlun = fsg->curlun;
1601 u8 *buf = (u8 *) bh->buf;
1602 u32 sd, sdinfo;
1603 int valid;
1604
1605 /*
1606 * From the SCSI-2 spec., section 7.9 (Unit attention condition):
1607 *
1608 * If a REQUEST SENSE command is received from an initiator
1609 * with a pending unit attention condition (before the target
1610 * generates the contingent allegiance condition), then the
1611 * target shall either:
1612 * a) report any pending sense data and preserve the unit
1613 * attention condition on the logical unit, or,
1614 * b) report the unit attention condition, may discard any
1615 * pending sense data, and clear the unit attention
1616 * condition on the logical unit for that initiator.
1617 *
1618 * FSG normally uses option a); enable this code to use option b).
1619 */
1620#if 0
1621 if (curlun && curlun->unit_attention_data != SS_NO_SENSE) {
1622 curlun->sense_data = curlun->unit_attention_data;
1623 curlun->unit_attention_data = SS_NO_SENSE;
1624 }
1625#endif
1626
1627 if (!curlun) { // Unsupported LUNs are okay
1628 fsg->bad_lun_okay = 1;
1629 sd = SS_LOGICAL_UNIT_NOT_SUPPORTED;
1630 sdinfo = 0;
1631 valid = 0;
1632 } else {
1633 sd = curlun->sense_data;
1634 sdinfo = curlun->sense_data_info;
1635 valid = curlun->info_valid << 7;
1636 curlun->sense_data = SS_NO_SENSE;
1637 curlun->sense_data_info = 0;
1638 curlun->info_valid = 0;
1639 }
1640
1641 memset(buf, 0, 18);
1642 buf[0] = valid | 0x70; // Valid, current error
1643 buf[2] = SK(sd);
1644 put_unaligned_be32(sdinfo, &buf[3]); /* Sense information */
1645 buf[7] = 18 - 8; // Additional sense length
1646 buf[12] = ASC(sd);
1647 buf[13] = ASCQ(sd);
1648 return 18;
1649}
1650
1651
1652static int do_read_capacity(struct fsg_dev *fsg, struct fsg_buffhd *bh)
1653{
1654 struct fsg_lun *curlun = fsg->curlun;
1655 u32 lba = get_unaligned_be32(&fsg->cmnd[2]);
1656 int pmi = fsg->cmnd[8];
1657 u8 *buf = (u8 *) bh->buf;
1658
1659 /* Check the PMI and LBA fields */
1660 if (pmi > 1 || (pmi == 0 && lba != 0)) {
1661 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1662 return -EINVAL;
1663 }
1664
1665 put_unaligned_be32(curlun->num_sectors - 1, &buf[0]);
1666 /* Max logical block */
1667 put_unaligned_be32(curlun->blksize, &buf[4]); /* Block length */
1668 return 8;
1669}
1670
1671
1672static int do_read_header(struct fsg_dev *fsg, struct fsg_buffhd *bh)
1673{
1674 struct fsg_lun *curlun = fsg->curlun;
1675 int msf = fsg->cmnd[1] & 0x02;
1676 u32 lba = get_unaligned_be32(&fsg->cmnd[2]);
1677 u8 *buf = (u8 *) bh->buf;
1678
1679 if ((fsg->cmnd[1] & ~0x02) != 0) { /* Mask away MSF */
1680 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1681 return -EINVAL;
1682 }
1683 if (lba >= curlun->num_sectors) {
1684 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
1685 return -EINVAL;
1686 }
1687
1688 memset(buf, 0, 8);
1689 buf[0] = 0x01; /* 2048 bytes of user data, rest is EC */
1690 store_cdrom_address(&buf[4], msf, lba);
1691 return 8;
1692}
1693
1694
1695static int do_read_toc(struct fsg_dev *fsg, struct fsg_buffhd *bh)
1696{
1697 struct fsg_lun *curlun = fsg->curlun;
1698 int msf = fsg->cmnd[1] & 0x02;
1699 int start_track = fsg->cmnd[6];
1700 u8 *buf = (u8 *) bh->buf;
1701
1702 if ((fsg->cmnd[1] & ~0x02) != 0 || /* Mask away MSF */
1703 start_track > 1) {
1704 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1705 return -EINVAL;
1706 }
1707
1708 memset(buf, 0, 20);
1709 buf[1] = (20-2); /* TOC data length */
1710 buf[2] = 1; /* First track number */
1711 buf[3] = 1; /* Last track number */
1712 buf[5] = 0x16; /* Data track, copying allowed */
1713 buf[6] = 0x01; /* Only track is number 1 */
1714 store_cdrom_address(&buf[8], msf, 0);
1715
1716 buf[13] = 0x16; /* Lead-out track is data */
1717 buf[14] = 0xAA; /* Lead-out track number */
1718 store_cdrom_address(&buf[16], msf, curlun->num_sectors);
1719 return 20;
1720}
1721
1722
1723static int do_mode_sense(struct fsg_dev *fsg, struct fsg_buffhd *bh)
1724{
1725 struct fsg_lun *curlun = fsg->curlun;
1726 int mscmnd = fsg->cmnd[0];
1727 u8 *buf = (u8 *) bh->buf;
1728 u8 *buf0 = buf;
1729 int pc, page_code;
1730 int changeable_values, all_pages;
1731 int valid_page = 0;
1732 int len, limit;
1733
1734 if ((fsg->cmnd[1] & ~0x08) != 0) { // Mask away DBD
1735 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1736 return -EINVAL;
1737 }
1738 pc = fsg->cmnd[2] >> 6;
1739 page_code = fsg->cmnd[2] & 0x3f;
1740 if (pc == 3) {
1741 curlun->sense_data = SS_SAVING_PARAMETERS_NOT_SUPPORTED;
1742 return -EINVAL;
1743 }
1744 changeable_values = (pc == 1);
1745 all_pages = (page_code == 0x3f);
1746
1747 /* Write the mode parameter header. Fixed values are: default
1748 * medium type, no cache control (DPOFUA), and no block descriptors.
1749 * The only variable value is the WriteProtect bit. We will fill in
1750 * the mode data length later. */
1751 memset(buf, 0, 8);
1752 if (mscmnd == MODE_SENSE) {
1753 buf[2] = (curlun->ro ? 0x80 : 0x00); // WP, DPOFUA
1754 buf += 4;
1755 limit = 255;
1756 } else { // MODE_SENSE_10
1757 buf[3] = (curlun->ro ? 0x80 : 0x00); // WP, DPOFUA
1758 buf += 8;
1759 limit = 65535; // Should really be mod_data.buflen
1760 }
1761
1762 /* No block descriptors */
1763
1764 /* The mode pages, in numerical order. The only page we support
1765 * is the Caching page. */
1766 if (page_code == 0x08 || all_pages) {
1767 valid_page = 1;
1768 buf[0] = 0x08; // Page code
1769 buf[1] = 10; // Page length
1770 memset(buf+2, 0, 10); // None of the fields are changeable
1771
1772 if (!changeable_values) {
1773 buf[2] = 0x04; // Write cache enable,
1774 // Read cache not disabled
1775 // No cache retention priorities
1776 put_unaligned_be16(0xffff, &buf[4]);
1777 /* Don't disable prefetch */
1778 /* Minimum prefetch = 0 */
1779 put_unaligned_be16(0xffff, &buf[8]);
1780 /* Maximum prefetch */
1781 put_unaligned_be16(0xffff, &buf[10]);
1782 /* Maximum prefetch ceiling */
1783 }
1784 buf += 12;
1785 }
1786
1787 /* Check that a valid page was requested and the mode data length
1788 * isn't too long. */
1789 len = buf - buf0;
1790 if (!valid_page || len > limit) {
1791 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1792 return -EINVAL;
1793 }
1794
1795 /* Store the mode data length */
1796 if (mscmnd == MODE_SENSE)
1797 buf0[0] = len - 1;
1798 else
1799 put_unaligned_be16(len - 2, buf0);
1800 return len;
1801}
1802
1803
1804static int do_start_stop(struct fsg_dev *fsg)
1805{
1806 struct fsg_lun *curlun = fsg->curlun;
1807 int loej, start;
1808
1809 if (!mod_data.removable) {
1810 curlun->sense_data = SS_INVALID_COMMAND;
1811 return -EINVAL;
1812 }
1813
1814 // int immed = fsg->cmnd[1] & 0x01;
1815 loej = fsg->cmnd[4] & 0x02;
1816 start = fsg->cmnd[4] & 0x01;
1817
1818#ifdef CONFIG_USB_FILE_STORAGE_TEST
1819 if ((fsg->cmnd[1] & ~0x01) != 0 || // Mask away Immed
1820 (fsg->cmnd[4] & ~0x03) != 0) { // Mask LoEj, Start
1821 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1822 return -EINVAL;
1823 }
1824
1825 if (!start) {
1826
1827 /* Are we allowed to unload the media? */
1828 if (curlun->prevent_medium_removal) {
1829 LDBG(curlun, "unload attempt prevented\n");
1830 curlun->sense_data = SS_MEDIUM_REMOVAL_PREVENTED;
1831 return -EINVAL;
1832 }
1833 if (loej) { // Simulate an unload/eject
1834 up_read(&fsg->filesem);
1835 down_write(&fsg->filesem);
1836 fsg_lun_close(curlun);
1837 up_write(&fsg->filesem);
1838 down_read(&fsg->filesem);
1839 }
1840 } else {
1841
1842 /* Our emulation doesn't support mounting; the medium is
1843 * available for use as soon as it is loaded. */
1844 if (!fsg_lun_is_open(curlun)) {
1845 curlun->sense_data = SS_MEDIUM_NOT_PRESENT;
1846 return -EINVAL;
1847 }
1848 }
1849#endif
1850 return 0;
1851}
1852
1853
1854static int do_prevent_allow(struct fsg_dev *fsg)
1855{
1856 struct fsg_lun *curlun = fsg->curlun;
1857 int prevent;
1858
1859 if (!mod_data.removable) {
1860 curlun->sense_data = SS_INVALID_COMMAND;
1861 return -EINVAL;
1862 }
1863
1864 prevent = fsg->cmnd[4] & 0x01;
1865 if ((fsg->cmnd[4] & ~0x01) != 0) { // Mask away Prevent
1866 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1867 return -EINVAL;
1868 }
1869
1870 if (curlun->prevent_medium_removal && !prevent)
1871 fsg_lun_fsync_sub(curlun);
1872 curlun->prevent_medium_removal = prevent;
1873 return 0;
1874}
1875
1876
1877static int do_read_format_capacities(struct fsg_dev *fsg,
1878 struct fsg_buffhd *bh)
1879{
1880 struct fsg_lun *curlun = fsg->curlun;
1881 u8 *buf = (u8 *) bh->buf;
1882
1883 buf[0] = buf[1] = buf[2] = 0;
1884 buf[3] = 8; // Only the Current/Maximum Capacity Descriptor
1885 buf += 4;
1886
1887 put_unaligned_be32(curlun->num_sectors, &buf[0]);
1888 /* Number of blocks */
1889 put_unaligned_be32(curlun->blksize, &buf[4]); /* Block length */
1890 buf[4] = 0x02; /* Current capacity */
1891 return 12;
1892}
1893
1894
1895static int do_mode_select(struct fsg_dev *fsg, struct fsg_buffhd *bh)
1896{
1897 struct fsg_lun *curlun = fsg->curlun;
1898
1899 /* We don't support MODE SELECT */
1900 curlun->sense_data = SS_INVALID_COMMAND;
1901 return -EINVAL;
1902}
1903
1904
1905/*-------------------------------------------------------------------------*/
1906
1907static int halt_bulk_in_endpoint(struct fsg_dev *fsg)
1908{
1909 int rc;
1910
1911 rc = fsg_set_halt(fsg, fsg->bulk_in);
1912 if (rc == -EAGAIN)
1913 VDBG(fsg, "delayed bulk-in endpoint halt\n");
1914 while (rc != 0) {
1915 if (rc != -EAGAIN) {
1916 WARNING(fsg, "usb_ep_set_halt -> %d\n", rc);
1917 rc = 0;
1918 break;
1919 }
1920
1921 /* Wait for a short time and then try again */
1922 if (msleep_interruptible(100) != 0)
1923 return -EINTR;
1924 rc = usb_ep_set_halt(fsg->bulk_in);
1925 }
1926 return rc;
1927}
1928
1929static int wedge_bulk_in_endpoint(struct fsg_dev *fsg)
1930{
1931 int rc;
1932
1933 DBG(fsg, "bulk-in set wedge\n");
1934 rc = usb_ep_set_wedge(fsg->bulk_in);
1935 if (rc == -EAGAIN)
1936 VDBG(fsg, "delayed bulk-in endpoint wedge\n");
1937 while (rc != 0) {
1938 if (rc != -EAGAIN) {
1939 WARNING(fsg, "usb_ep_set_wedge -> %d\n", rc);
1940 rc = 0;
1941 break;
1942 }
1943
1944 /* Wait for a short time and then try again */
1945 if (msleep_interruptible(100) != 0)
1946 return -EINTR;
1947 rc = usb_ep_set_wedge(fsg->bulk_in);
1948 }
1949 return rc;
1950}
1951
1952static int throw_away_data(struct fsg_dev *fsg)
1953{
1954 struct fsg_buffhd *bh;
1955 u32 amount;
1956 int rc;
1957
1958 while ((bh = fsg->next_buffhd_to_drain)->state != BUF_STATE_EMPTY ||
1959 fsg->usb_amount_left > 0) {
1960
1961 /* Throw away the data in a filled buffer */
1962 if (bh->state == BUF_STATE_FULL) {
1963 smp_rmb();
1964 bh->state = BUF_STATE_EMPTY;
1965 fsg->next_buffhd_to_drain = bh->next;
1966
1967 /* A short packet or an error ends everything */
1968 if (bh->outreq->actual < bh->bulk_out_intended_length ||
1969 bh->outreq->status != 0) {
1970 raise_exception(fsg, FSG_STATE_ABORT_BULK_OUT);
1971 return -EINTR;
1972 }
1973 continue;
1974 }
1975
1976 /* Try to submit another request if we need one */
1977 bh = fsg->next_buffhd_to_fill;
1978 if (bh->state == BUF_STATE_EMPTY && fsg->usb_amount_left > 0) {
1979 amount = min(fsg->usb_amount_left,
1980 (u32) mod_data.buflen);
1981
1982 /* Except at the end of the transfer, amount will be
1983 * equal to the buffer size, which is divisible by
1984 * the bulk-out maxpacket size.
1985 */
1986 set_bulk_out_req_length(fsg, bh, amount);
1987 start_transfer(fsg, fsg->bulk_out, bh->outreq,
1988 &bh->outreq_busy, &bh->state);
1989 fsg->next_buffhd_to_fill = bh->next;
1990 fsg->usb_amount_left -= amount;
1991 continue;
1992 }
1993
1994 /* Otherwise wait for something to happen */
1995 rc = sleep_thread(fsg);
1996 if (rc)
1997 return rc;
1998 }
1999 return 0;
2000}
2001
2002
2003static int finish_reply(struct fsg_dev *fsg)
2004{
2005 struct fsg_buffhd *bh = fsg->next_buffhd_to_fill;
2006 int rc = 0;
2007
2008 switch (fsg->data_dir) {
2009 case DATA_DIR_NONE:
2010 break; // Nothing to send
2011
2012 /* If we don't know whether the host wants to read or write,
2013 * this must be CB or CBI with an unknown command. We mustn't
2014 * try to send or receive any data. So stall both bulk pipes
2015 * if we can and wait for a reset. */
2016 case DATA_DIR_UNKNOWN:
2017 if (mod_data.can_stall) {
2018 fsg_set_halt(fsg, fsg->bulk_out);
2019 rc = halt_bulk_in_endpoint(fsg);
2020 }
2021 break;
2022
2023 /* All but the last buffer of data must have already been sent */
2024 case DATA_DIR_TO_HOST:
2025 if (fsg->data_size == 0)
2026 ; // Nothing to send
2027
2028 /* If there's no residue, simply send the last buffer */
2029 else if (fsg->residue == 0) {
2030 bh->inreq->zero = 0;
2031 start_transfer(fsg, fsg->bulk_in, bh->inreq,
2032 &bh->inreq_busy, &bh->state);
2033 fsg->next_buffhd_to_fill = bh->next;
2034 }
2035
2036 /* There is a residue. For CB and CBI, simply mark the end
2037 * of the data with a short packet. However, if we are
2038 * allowed to stall, there was no data at all (residue ==
2039 * data_size), and the command failed (invalid LUN or
2040 * sense data is set), then halt the bulk-in endpoint
2041 * instead. */
2042 else if (!transport_is_bbb()) {
2043 if (mod_data.can_stall &&
2044 fsg->residue == fsg->data_size &&
2045 (!fsg->curlun || fsg->curlun->sense_data != SS_NO_SENSE)) {
2046 bh->state = BUF_STATE_EMPTY;
2047 rc = halt_bulk_in_endpoint(fsg);
2048 } else {
2049 bh->inreq->zero = 1;
2050 start_transfer(fsg, fsg->bulk_in, bh->inreq,
2051 &bh->inreq_busy, &bh->state);
2052 fsg->next_buffhd_to_fill = bh->next;
2053 }
2054 }
2055
2056 /*
2057 * For Bulk-only, mark the end of the data with a short
2058 * packet. If we are allowed to stall, halt the bulk-in
2059 * endpoint. (Note: This violates the Bulk-Only Transport
2060 * specification, which requires us to pad the data if we
2061 * don't halt the endpoint. Presumably nobody will mind.)
2062 */
2063 else {
2064 bh->inreq->zero = 1;
2065 start_transfer(fsg, fsg->bulk_in, bh->inreq,
2066 &bh->inreq_busy, &bh->state);
2067 fsg->next_buffhd_to_fill = bh->next;
2068 if (mod_data.can_stall)
2069 rc = halt_bulk_in_endpoint(fsg);
2070 }
2071 break;
2072
2073 /* We have processed all we want from the data the host has sent.
2074 * There may still be outstanding bulk-out requests. */
2075 case DATA_DIR_FROM_HOST:
2076 if (fsg->residue == 0)
2077 ; // Nothing to receive
2078
2079 /* Did the host stop sending unexpectedly early? */
2080 else if (fsg->short_packet_received) {
2081 raise_exception(fsg, FSG_STATE_ABORT_BULK_OUT);
2082 rc = -EINTR;
2083 }
2084
2085 /* We haven't processed all the incoming data. Even though
2086 * we may be allowed to stall, doing so would cause a race.
2087 * The controller may already have ACK'ed all the remaining
2088 * bulk-out packets, in which case the host wouldn't see a
2089 * STALL. Not realizing the endpoint was halted, it wouldn't
2090 * clear the halt -- leading to problems later on. */
2091#if 0
2092 else if (mod_data.can_stall) {
2093 fsg_set_halt(fsg, fsg->bulk_out);
2094 raise_exception(fsg, FSG_STATE_ABORT_BULK_OUT);
2095 rc = -EINTR;
2096 }
2097#endif
2098
2099 /* We can't stall. Read in the excess data and throw it
2100 * all away. */
2101 else
2102 rc = throw_away_data(fsg);
2103 break;
2104 }
2105 return rc;
2106}
2107
2108
2109static int send_status(struct fsg_dev *fsg)
2110{
2111 struct fsg_lun *curlun = fsg->curlun;
2112 struct fsg_buffhd *bh;
2113 int rc;
2114 u8 status = US_BULK_STAT_OK;
2115 u32 sd, sdinfo = 0;
2116
2117 /* Wait for the next buffer to become available */
2118 bh = fsg->next_buffhd_to_fill;
2119 while (bh->state != BUF_STATE_EMPTY) {
2120 rc = sleep_thread(fsg);
2121 if (rc)
2122 return rc;
2123 }
2124
2125 if (curlun) {
2126 sd = curlun->sense_data;
2127 sdinfo = curlun->sense_data_info;
2128 } else if (fsg->bad_lun_okay)
2129 sd = SS_NO_SENSE;
2130 else
2131 sd = SS_LOGICAL_UNIT_NOT_SUPPORTED;
2132
2133 if (fsg->phase_error) {
2134 DBG(fsg, "sending phase-error status\n");
2135 status = US_BULK_STAT_PHASE;
2136 sd = SS_INVALID_COMMAND;
2137 } else if (sd != SS_NO_SENSE) {
2138 DBG(fsg, "sending command-failure status\n");
2139 status = US_BULK_STAT_FAIL;
2140 VDBG(fsg, " sense data: SK x%02x, ASC x%02x, ASCQ x%02x;"
2141 " info x%x\n",
2142 SK(sd), ASC(sd), ASCQ(sd), sdinfo);
2143 }
2144
2145 if (transport_is_bbb()) {
2146 struct bulk_cs_wrap *csw = bh->buf;
2147
2148 /* Store and send the Bulk-only CSW */
2149 csw->Signature = cpu_to_le32(US_BULK_CS_SIGN);
2150 csw->Tag = fsg->tag;
2151 csw->Residue = cpu_to_le32(fsg->residue);
2152 csw->Status = status;
2153
2154 bh->inreq->length = US_BULK_CS_WRAP_LEN;
2155 bh->inreq->zero = 0;
2156 start_transfer(fsg, fsg->bulk_in, bh->inreq,
2157 &bh->inreq_busy, &bh->state);
2158
2159 } else if (mod_data.transport_type == USB_PR_CB) {
2160
2161 /* Control-Bulk transport has no status phase! */
2162 return 0;
2163
2164 } else { // USB_PR_CBI
2165 struct interrupt_data *buf = bh->buf;
2166
2167 /* Store and send the Interrupt data. UFI sends the ASC
2168 * and ASCQ bytes. Everything else sends a Type (which
2169 * is always 0) and the status Value. */
2170 if (mod_data.protocol_type == USB_SC_UFI) {
2171 buf->bType = ASC(sd);
2172 buf->bValue = ASCQ(sd);
2173 } else {
2174 buf->bType = 0;
2175 buf->bValue = status;
2176 }
2177 fsg->intreq->length = CBI_INTERRUPT_DATA_LEN;
2178
2179 fsg->intr_buffhd = bh; // Point to the right buffhd
2180 fsg->intreq->buf = bh->inreq->buf;
2181 fsg->intreq->context = bh;
2182 start_transfer(fsg, fsg->intr_in, fsg->intreq,
2183 &fsg->intreq_busy, &bh->state);
2184 }
2185
2186 fsg->next_buffhd_to_fill = bh->next;
2187 return 0;
2188}
2189
2190
2191/*-------------------------------------------------------------------------*/
2192
2193/* Check whether the command is properly formed and whether its data size
2194 * and direction agree with the values we already have. */
2195static int check_command(struct fsg_dev *fsg, int cmnd_size,
2196 enum data_direction data_dir, unsigned int mask,
2197 int needs_medium, const char *name)
2198{
2199 int i;
2200 int lun = fsg->cmnd[1] >> 5;
2201 static const char dirletter[4] = {'u', 'o', 'i', 'n'};
2202 char hdlen[20];
2203 struct fsg_lun *curlun;
2204
2205 /* Adjust the expected cmnd_size for protocol encapsulation padding.
2206 * Transparent SCSI doesn't pad. */
2207 if (protocol_is_scsi())
2208 ;
2209
2210 /* There's some disagreement as to whether RBC pads commands or not.
2211 * We'll play it safe and accept either form. */
2212 else if (mod_data.protocol_type == USB_SC_RBC) {
2213 if (fsg->cmnd_size == 12)
2214 cmnd_size = 12;
2215
2216 /* All the other protocols pad to 12 bytes */
2217 } else
2218 cmnd_size = 12;
2219
2220 hdlen[0] = 0;
2221 if (fsg->data_dir != DATA_DIR_UNKNOWN)
2222 sprintf(hdlen, ", H%c=%u", dirletter[(int) fsg->data_dir],
2223 fsg->data_size);
2224 VDBG(fsg, "SCSI command: %s; Dc=%d, D%c=%u; Hc=%d%s\n",
2225 name, cmnd_size, dirletter[(int) data_dir],
2226 fsg->data_size_from_cmnd, fsg->cmnd_size, hdlen);
2227
2228 /* We can't reply at all until we know the correct data direction
2229 * and size. */
2230 if (fsg->data_size_from_cmnd == 0)
2231 data_dir = DATA_DIR_NONE;
2232 if (fsg->data_dir == DATA_DIR_UNKNOWN) { // CB or CBI
2233 fsg->data_dir = data_dir;
2234 fsg->data_size = fsg->data_size_from_cmnd;
2235
2236 } else { // Bulk-only
2237 if (fsg->data_size < fsg->data_size_from_cmnd) {
2238
2239 /* Host data size < Device data size is a phase error.
2240 * Carry out the command, but only transfer as much
2241 * as we are allowed. */
2242 fsg->data_size_from_cmnd = fsg->data_size;
2243 fsg->phase_error = 1;
2244 }
2245 }
2246 fsg->residue = fsg->usb_amount_left = fsg->data_size;
2247
2248 /* Conflicting data directions is a phase error */
2249 if (fsg->data_dir != data_dir && fsg->data_size_from_cmnd > 0) {
2250 fsg->phase_error = 1;
2251 return -EINVAL;
2252 }
2253
2254 /* Verify the length of the command itself */
2255 if (cmnd_size != fsg->cmnd_size) {
2256
2257 /* Special case workaround: There are plenty of buggy SCSI
2258 * implementations. Many have issues with cbw->Length
2259 * field passing a wrong command size. For those cases we
2260 * always try to work around the problem by using the length
2261 * sent by the host side provided it is at least as large
2262 * as the correct command length.
2263 * Examples of such cases would be MS-Windows, which issues
2264 * REQUEST SENSE with cbw->Length == 12 where it should
2265 * be 6, and xbox360 issuing INQUIRY, TEST UNIT READY and
2266 * REQUEST SENSE with cbw->Length == 10 where it should
2267 * be 6 as well.
2268 */
2269 if (cmnd_size <= fsg->cmnd_size) {
2270 DBG(fsg, "%s is buggy! Expected length %d "
2271 "but we got %d\n", name,
2272 cmnd_size, fsg->cmnd_size);
2273 cmnd_size = fsg->cmnd_size;
2274 } else {
2275 fsg->phase_error = 1;
2276 return -EINVAL;
2277 }
2278 }
2279
2280 /* Check that the LUN values are consistent */
2281 if (transport_is_bbb()) {
2282 if (fsg->lun != lun)
2283 DBG(fsg, "using LUN %d from CBW, "
2284 "not LUN %d from CDB\n",
2285 fsg->lun, lun);
2286 }
2287
2288 /* Check the LUN */
2289 curlun = fsg->curlun;
2290 if (curlun) {
2291 if (fsg->cmnd[0] != REQUEST_SENSE) {
2292 curlun->sense_data = SS_NO_SENSE;
2293 curlun->sense_data_info = 0;
2294 curlun->info_valid = 0;
2295 }
2296 } else {
2297 fsg->bad_lun_okay = 0;
2298
2299 /* INQUIRY and REQUEST SENSE commands are explicitly allowed
2300 * to use unsupported LUNs; all others may not. */
2301 if (fsg->cmnd[0] != INQUIRY &&
2302 fsg->cmnd[0] != REQUEST_SENSE) {
2303 DBG(fsg, "unsupported LUN %d\n", fsg->lun);
2304 return -EINVAL;
2305 }
2306 }
2307
2308 /* If a unit attention condition exists, only INQUIRY and
2309 * REQUEST SENSE commands are allowed; anything else must fail. */
2310 if (curlun && curlun->unit_attention_data != SS_NO_SENSE &&
2311 fsg->cmnd[0] != INQUIRY &&
2312 fsg->cmnd[0] != REQUEST_SENSE) {
2313 curlun->sense_data = curlun->unit_attention_data;
2314 curlun->unit_attention_data = SS_NO_SENSE;
2315 return -EINVAL;
2316 }
2317
2318 /* Check that only command bytes listed in the mask are non-zero */
2319 fsg->cmnd[1] &= 0x1f; // Mask away the LUN
2320 for (i = 1; i < cmnd_size; ++i) {
2321 if (fsg->cmnd[i] && !(mask & (1 << i))) {
2322 if (curlun)
2323 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
2324 return -EINVAL;
2325 }
2326 }
2327
2328 /* If the medium isn't mounted and the command needs to access
2329 * it, return an error. */
2330 if (curlun && !fsg_lun_is_open(curlun) && needs_medium) {
2331 curlun->sense_data = SS_MEDIUM_NOT_PRESENT;
2332 return -EINVAL;
2333 }
2334
2335 return 0;
2336}
2337
2338/* wrapper of check_command for data size in blocks handling */
2339static int check_command_size_in_blocks(struct fsg_dev *fsg, int cmnd_size,
2340 enum data_direction data_dir, unsigned int mask,
2341 int needs_medium, const char *name)
2342{
2343 if (fsg->curlun)
2344 fsg->data_size_from_cmnd <<= fsg->curlun->blkbits;
2345 return check_command(fsg, cmnd_size, data_dir,
2346 mask, needs_medium, name);
2347}
2348
2349static int do_scsi_command(struct fsg_dev *fsg)
2350{
2351 struct fsg_buffhd *bh;
2352 int rc;
2353 int reply = -EINVAL;
2354 int i;
2355 static char unknown[16];
2356
2357 dump_cdb(fsg);
2358
2359 /* Wait for the next buffer to become available for data or status */
2360 bh = fsg->next_buffhd_to_drain = fsg->next_buffhd_to_fill;
2361 while (bh->state != BUF_STATE_EMPTY) {
2362 rc = sleep_thread(fsg);
2363 if (rc)
2364 return rc;
2365 }
2366 fsg->phase_error = 0;
2367 fsg->short_packet_received = 0;
2368
2369 down_read(&fsg->filesem); // We're using the backing file
2370 switch (fsg->cmnd[0]) {
2371
2372 case INQUIRY:
2373 fsg->data_size_from_cmnd = fsg->cmnd[4];
2374 if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST,
2375 (1<<4), 0,
2376 "INQUIRY")) == 0)
2377 reply = do_inquiry(fsg, bh);
2378 break;
2379
2380 case MODE_SELECT:
2381 fsg->data_size_from_cmnd = fsg->cmnd[4];
2382 if ((reply = check_command(fsg, 6, DATA_DIR_FROM_HOST,
2383 (1<<1) | (1<<4), 0,
2384 "MODE SELECT(6)")) == 0)
2385 reply = do_mode_select(fsg, bh);
2386 break;
2387
2388 case MODE_SELECT_10:
2389 fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
2390 if ((reply = check_command(fsg, 10, DATA_DIR_FROM_HOST,
2391 (1<<1) | (3<<7), 0,
2392 "MODE SELECT(10)")) == 0)
2393 reply = do_mode_select(fsg, bh);
2394 break;
2395
2396 case MODE_SENSE:
2397 fsg->data_size_from_cmnd = fsg->cmnd[4];
2398 if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST,
2399 (1<<1) | (1<<2) | (1<<4), 0,
2400 "MODE SENSE(6)")) == 0)
2401 reply = do_mode_sense(fsg, bh);
2402 break;
2403
2404 case MODE_SENSE_10:
2405 fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
2406 if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
2407 (1<<1) | (1<<2) | (3<<7), 0,
2408 "MODE SENSE(10)")) == 0)
2409 reply = do_mode_sense(fsg, bh);
2410 break;
2411
2412 case ALLOW_MEDIUM_REMOVAL:
2413 fsg->data_size_from_cmnd = 0;
2414 if ((reply = check_command(fsg, 6, DATA_DIR_NONE,
2415 (1<<4), 0,
2416 "PREVENT-ALLOW MEDIUM REMOVAL")) == 0)
2417 reply = do_prevent_allow(fsg);
2418 break;
2419
2420 case READ_6:
2421 i = fsg->cmnd[4];
2422 fsg->data_size_from_cmnd = (i == 0) ? 256 : i;
2423 if ((reply = check_command_size_in_blocks(fsg, 6,
2424 DATA_DIR_TO_HOST,
2425 (7<<1) | (1<<4), 1,
2426 "READ(6)")) == 0)
2427 reply = do_read(fsg);
2428 break;
2429
2430 case READ_10:
2431 fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
2432 if ((reply = check_command_size_in_blocks(fsg, 10,
2433 DATA_DIR_TO_HOST,
2434 (1<<1) | (0xf<<2) | (3<<7), 1,
2435 "READ(10)")) == 0)
2436 reply = do_read(fsg);
2437 break;
2438
2439 case READ_12:
2440 fsg->data_size_from_cmnd = get_unaligned_be32(&fsg->cmnd[6]);
2441 if ((reply = check_command_size_in_blocks(fsg, 12,
2442 DATA_DIR_TO_HOST,
2443 (1<<1) | (0xf<<2) | (0xf<<6), 1,
2444 "READ(12)")) == 0)
2445 reply = do_read(fsg);
2446 break;
2447
2448 case READ_CAPACITY:
2449 fsg->data_size_from_cmnd = 8;
2450 if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
2451 (0xf<<2) | (1<<8), 1,
2452 "READ CAPACITY")) == 0)
2453 reply = do_read_capacity(fsg, bh);
2454 break;
2455
2456 case READ_HEADER:
2457 if (!mod_data.cdrom)
2458 goto unknown_cmnd;
2459 fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
2460 if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
2461 (3<<7) | (0x1f<<1), 1,
2462 "READ HEADER")) == 0)
2463 reply = do_read_header(fsg, bh);
2464 break;
2465
2466 case READ_TOC:
2467 if (!mod_data.cdrom)
2468 goto unknown_cmnd;
2469 fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
2470 if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
2471 (7<<6) | (1<<1), 1,
2472 "READ TOC")) == 0)
2473 reply = do_read_toc(fsg, bh);
2474 break;
2475
2476 case READ_FORMAT_CAPACITIES:
2477 fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
2478 if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
2479 (3<<7), 1,
2480 "READ FORMAT CAPACITIES")) == 0)
2481 reply = do_read_format_capacities(fsg, bh);
2482 break;
2483
2484 case REQUEST_SENSE:
2485 fsg->data_size_from_cmnd = fsg->cmnd[4];
2486 if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST,
2487 (1<<4), 0,
2488 "REQUEST SENSE")) == 0)
2489 reply = do_request_sense(fsg, bh);
2490 break;
2491
2492 case START_STOP:
2493 fsg->data_size_from_cmnd = 0;
2494 if ((reply = check_command(fsg, 6, DATA_DIR_NONE,
2495 (1<<1) | (1<<4), 0,
2496 "START-STOP UNIT")) == 0)
2497 reply = do_start_stop(fsg);
2498 break;
2499
2500 case SYNCHRONIZE_CACHE:
2501 fsg->data_size_from_cmnd = 0;
2502 if ((reply = check_command(fsg, 10, DATA_DIR_NONE,
2503 (0xf<<2) | (3<<7), 1,
2504 "SYNCHRONIZE CACHE")) == 0)
2505 reply = do_synchronize_cache(fsg);
2506 break;
2507
2508 case TEST_UNIT_READY:
2509 fsg->data_size_from_cmnd = 0;
2510 reply = check_command(fsg, 6, DATA_DIR_NONE,
2511 0, 1,
2512 "TEST UNIT READY");
2513 break;
2514
2515 /* Although optional, this command is used by MS-Windows. We
2516 * support a minimal version: BytChk must be 0. */
2517 case VERIFY:
2518 fsg->data_size_from_cmnd = 0;
2519 if ((reply = check_command(fsg, 10, DATA_DIR_NONE,
2520 (1<<1) | (0xf<<2) | (3<<7), 1,
2521 "VERIFY")) == 0)
2522 reply = do_verify(fsg);
2523 break;
2524
2525 case WRITE_6:
2526 i = fsg->cmnd[4];
2527 fsg->data_size_from_cmnd = (i == 0) ? 256 : i;
2528 if ((reply = check_command_size_in_blocks(fsg, 6,
2529 DATA_DIR_FROM_HOST,
2530 (7<<1) | (1<<4), 1,
2531 "WRITE(6)")) == 0)
2532 reply = do_write(fsg);
2533 break;
2534
2535 case WRITE_10:
2536 fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
2537 if ((reply = check_command_size_in_blocks(fsg, 10,
2538 DATA_DIR_FROM_HOST,
2539 (1<<1) | (0xf<<2) | (3<<7), 1,
2540 "WRITE(10)")) == 0)
2541 reply = do_write(fsg);
2542 break;
2543
2544 case WRITE_12:
2545 fsg->data_size_from_cmnd = get_unaligned_be32(&fsg->cmnd[6]);
2546 if ((reply = check_command_size_in_blocks(fsg, 12,
2547 DATA_DIR_FROM_HOST,
2548 (1<<1) | (0xf<<2) | (0xf<<6), 1,
2549 "WRITE(12)")) == 0)
2550 reply = do_write(fsg);
2551 break;
2552
2553 /* Some mandatory commands that we recognize but don't implement.
2554 * They don't mean much in this setting. It's left as an exercise
2555 * for anyone interested to implement RESERVE and RELEASE in terms
2556 * of Posix locks. */
2557 case FORMAT_UNIT:
2558 case RELEASE:
2559 case RESERVE:
2560 case SEND_DIAGNOSTIC:
2561 // Fall through
2562
2563 default:
2564 unknown_cmnd:
2565 fsg->data_size_from_cmnd = 0;
2566 sprintf(unknown, "Unknown x%02x", fsg->cmnd[0]);
2567 if ((reply = check_command(fsg, fsg->cmnd_size,
2568 DATA_DIR_UNKNOWN, ~0, 0, unknown)) == 0) {
2569 fsg->curlun->sense_data = SS_INVALID_COMMAND;
2570 reply = -EINVAL;
2571 }
2572 break;
2573 }
2574 up_read(&fsg->filesem);
2575
2576 if (reply == -EINTR || signal_pending(current))
2577 return -EINTR;
2578
2579 /* Set up the single reply buffer for finish_reply() */
2580 if (reply == -EINVAL)
2581 reply = 0; // Error reply length
2582 if (reply >= 0 && fsg->data_dir == DATA_DIR_TO_HOST) {
2583 reply = min((u32) reply, fsg->data_size_from_cmnd);
2584 bh->inreq->length = reply;
2585 bh->state = BUF_STATE_FULL;
2586 fsg->residue -= reply;
2587 } // Otherwise it's already set
2588
2589 return 0;
2590}
2591
2592
2593/*-------------------------------------------------------------------------*/
2594
2595static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh)
2596{
2597 struct usb_request *req = bh->outreq;
2598 struct bulk_cb_wrap *cbw = req->buf;
2599
2600 /* Was this a real packet? Should it be ignored? */
2601 if (req->status || test_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags))
2602 return -EINVAL;
2603
2604 /* Is the CBW valid? */
2605 if (req->actual != US_BULK_CB_WRAP_LEN ||
2606 cbw->Signature != cpu_to_le32(
2607 US_BULK_CB_SIGN)) {
2608 DBG(fsg, "invalid CBW: len %u sig 0x%x\n",
2609 req->actual,
2610 le32_to_cpu(cbw->Signature));
2611
2612 /* The Bulk-only spec says we MUST stall the IN endpoint
2613 * (6.6.1), so it's unavoidable. It also says we must
2614 * retain this state until the next reset, but there's
2615 * no way to tell the controller driver it should ignore
2616 * Clear-Feature(HALT) requests.
2617 *
2618 * We aren't required to halt the OUT endpoint; instead
2619 * we can simply accept and discard any data received
2620 * until the next reset. */
2621 wedge_bulk_in_endpoint(fsg);
2622 set_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags);
2623 return -EINVAL;
2624 }
2625
2626 /* Is the CBW meaningful? */
2627 if (cbw->Lun >= FSG_MAX_LUNS || cbw->Flags & ~US_BULK_FLAG_IN ||
2628 cbw->Length <= 0 || cbw->Length > MAX_COMMAND_SIZE) {
2629 DBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, "
2630 "cmdlen %u\n",
2631 cbw->Lun, cbw->Flags, cbw->Length);
2632
2633 /* We can do anything we want here, so let's stall the
2634 * bulk pipes if we are allowed to. */
2635 if (mod_data.can_stall) {
2636 fsg_set_halt(fsg, fsg->bulk_out);
2637 halt_bulk_in_endpoint(fsg);
2638 }
2639 return -EINVAL;
2640 }
2641
2642 /* Save the command for later */
2643 fsg->cmnd_size = cbw->Length;
2644 memcpy(fsg->cmnd, cbw->CDB, fsg->cmnd_size);
2645 if (cbw->Flags & US_BULK_FLAG_IN)
2646 fsg->data_dir = DATA_DIR_TO_HOST;
2647 else
2648 fsg->data_dir = DATA_DIR_FROM_HOST;
2649 fsg->data_size = le32_to_cpu(cbw->DataTransferLength);
2650 if (fsg->data_size == 0)
2651 fsg->data_dir = DATA_DIR_NONE;
2652 fsg->lun = cbw->Lun;
2653 fsg->tag = cbw->Tag;
2654 return 0;
2655}
2656
2657
2658static int get_next_command(struct fsg_dev *fsg)
2659{
2660 struct fsg_buffhd *bh;
2661 int rc = 0;
2662
2663 if (transport_is_bbb()) {
2664
2665 /* Wait for the next buffer to become available */
2666 bh = fsg->next_buffhd_to_fill;
2667 while (bh->state != BUF_STATE_EMPTY) {
2668 rc = sleep_thread(fsg);
2669 if (rc)
2670 return rc;
2671 }
2672
2673 /* Queue a request to read a Bulk-only CBW */
2674 set_bulk_out_req_length(fsg, bh, US_BULK_CB_WRAP_LEN);
2675 start_transfer(fsg, fsg->bulk_out, bh->outreq,
2676 &bh->outreq_busy, &bh->state);
2677
2678 /* We will drain the buffer in software, which means we
2679 * can reuse it for the next filling. No need to advance
2680 * next_buffhd_to_fill. */
2681
2682 /* Wait for the CBW to arrive */
2683 while (bh->state != BUF_STATE_FULL) {
2684 rc = sleep_thread(fsg);
2685 if (rc)
2686 return rc;
2687 }
2688 smp_rmb();
2689 rc = received_cbw(fsg, bh);
2690 bh->state = BUF_STATE_EMPTY;
2691
2692 } else { // USB_PR_CB or USB_PR_CBI
2693
2694 /* Wait for the next command to arrive */
2695 while (fsg->cbbuf_cmnd_size == 0) {
2696 rc = sleep_thread(fsg);
2697 if (rc)
2698 return rc;
2699 }
2700
2701 /* Is the previous status interrupt request still busy?
2702 * The host is allowed to skip reading the status,
2703 * so we must cancel it. */
2704 if (fsg->intreq_busy)
2705 usb_ep_dequeue(fsg->intr_in, fsg->intreq);
2706
2707 /* Copy the command and mark the buffer empty */
2708 fsg->data_dir = DATA_DIR_UNKNOWN;
2709 spin_lock_irq(&fsg->lock);
2710 fsg->cmnd_size = fsg->cbbuf_cmnd_size;
2711 memcpy(fsg->cmnd, fsg->cbbuf_cmnd, fsg->cmnd_size);
2712 fsg->cbbuf_cmnd_size = 0;
2713 spin_unlock_irq(&fsg->lock);
2714
2715 /* Use LUN from the command */
2716 fsg->lun = fsg->cmnd[1] >> 5;
2717 }
2718
2719 /* Update current lun */
2720 if (fsg->lun >= 0 && fsg->lun < fsg->nluns)
2721 fsg->curlun = &fsg->luns[fsg->lun];
2722 else
2723 fsg->curlun = NULL;
2724
2725 return rc;
2726}
2727
2728
2729/*-------------------------------------------------------------------------*/
2730
2731static int enable_endpoint(struct fsg_dev *fsg, struct usb_ep *ep,
2732 const struct usb_endpoint_descriptor *d)
2733{
2734 int rc;
2735
2736 ep->driver_data = fsg;
2737 ep->desc = d;
2738 rc = usb_ep_enable(ep);
2739 if (rc)
2740 ERROR(fsg, "can't enable %s, result %d\n", ep->name, rc);
2741 return rc;
2742}
2743
2744static int alloc_request(struct fsg_dev *fsg, struct usb_ep *ep,
2745 struct usb_request **preq)
2746{
2747 *preq = usb_ep_alloc_request(ep, GFP_ATOMIC);
2748 if (*preq)
2749 return 0;
2750 ERROR(fsg, "can't allocate request for %s\n", ep->name);
2751 return -ENOMEM;
2752}
2753
2754/*
2755 * Reset interface setting and re-init endpoint state (toggle etc).
2756 * Call with altsetting < 0 to disable the interface. The only other
2757 * available altsetting is 0, which enables the interface.
2758 */
2759static int do_set_interface(struct fsg_dev *fsg, int altsetting)
2760{
2761 int rc = 0;
2762 int i;
2763 const struct usb_endpoint_descriptor *d;
2764
2765 if (fsg->running)
2766 DBG(fsg, "reset interface\n");
2767
2768reset:
2769 /* Deallocate the requests */
2770 for (i = 0; i < fsg_num_buffers; ++i) {
2771 struct fsg_buffhd *bh = &fsg->buffhds[i];
2772
2773 if (bh->inreq) {
2774 usb_ep_free_request(fsg->bulk_in, bh->inreq);
2775 bh->inreq = NULL;
2776 }
2777 if (bh->outreq) {
2778 usb_ep_free_request(fsg->bulk_out, bh->outreq);
2779 bh->outreq = NULL;
2780 }
2781 }
2782 if (fsg->intreq) {
2783 usb_ep_free_request(fsg->intr_in, fsg->intreq);
2784 fsg->intreq = NULL;
2785 }
2786
2787 /* Disable the endpoints */
2788 if (fsg->bulk_in_enabled) {
2789 usb_ep_disable(fsg->bulk_in);
2790 fsg->bulk_in_enabled = 0;
2791 }
2792 if (fsg->bulk_out_enabled) {
2793 usb_ep_disable(fsg->bulk_out);
2794 fsg->bulk_out_enabled = 0;
2795 }
2796 if (fsg->intr_in_enabled) {
2797 usb_ep_disable(fsg->intr_in);
2798 fsg->intr_in_enabled = 0;
2799 }
2800
2801 fsg->running = 0;
2802 if (altsetting < 0 || rc != 0)
2803 return rc;
2804
2805 DBG(fsg, "set interface %d\n", altsetting);
2806
2807 /* Enable the endpoints */
2808 d = fsg_ep_desc(fsg->gadget,
2809 &fsg_fs_bulk_in_desc, &fsg_hs_bulk_in_desc,
2810 &fsg_ss_bulk_in_desc);
2811 if ((rc = enable_endpoint(fsg, fsg->bulk_in, d)) != 0)
2812 goto reset;
2813 fsg->bulk_in_enabled = 1;
2814
2815 d = fsg_ep_desc(fsg->gadget,
2816 &fsg_fs_bulk_out_desc, &fsg_hs_bulk_out_desc,
2817 &fsg_ss_bulk_out_desc);
2818 if ((rc = enable_endpoint(fsg, fsg->bulk_out, d)) != 0)
2819 goto reset;
2820 fsg->bulk_out_enabled = 1;
2821 fsg->bulk_out_maxpacket = usb_endpoint_maxp(d);
2822 clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags);
2823
2824 if (transport_is_cbi()) {
2825 d = fsg_ep_desc(fsg->gadget,
2826 &fsg_fs_intr_in_desc, &fsg_hs_intr_in_desc,
2827 &fsg_ss_intr_in_desc);
2828 if ((rc = enable_endpoint(fsg, fsg->intr_in, d)) != 0)
2829 goto reset;
2830 fsg->intr_in_enabled = 1;
2831 }
2832
2833 /* Allocate the requests */
2834 for (i = 0; i < fsg_num_buffers; ++i) {
2835 struct fsg_buffhd *bh = &fsg->buffhds[i];
2836
2837 if ((rc = alloc_request(fsg, fsg->bulk_in, &bh->inreq)) != 0)
2838 goto reset;
2839 if ((rc = alloc_request(fsg, fsg->bulk_out, &bh->outreq)) != 0)
2840 goto reset;
2841 bh->inreq->buf = bh->outreq->buf = bh->buf;
2842 bh->inreq->context = bh->outreq->context = bh;
2843 bh->inreq->complete = bulk_in_complete;
2844 bh->outreq->complete = bulk_out_complete;
2845 }
2846 if (transport_is_cbi()) {
2847 if ((rc = alloc_request(fsg, fsg->intr_in, &fsg->intreq)) != 0)
2848 goto reset;
2849 fsg->intreq->complete = intr_in_complete;
2850 }
2851
2852 fsg->running = 1;
2853 for (i = 0; i < fsg->nluns; ++i)
2854 fsg->luns[i].unit_attention_data = SS_RESET_OCCURRED;
2855 return rc;
2856}
2857
2858
2859/*
2860 * Change our operational configuration. This code must agree with the code
2861 * that returns config descriptors, and with interface altsetting code.
2862 *
2863 * It's also responsible for power management interactions. Some
2864 * configurations might not work with our current power sources.
2865 * For now we just assume the gadget is always self-powered.
2866 */
2867static int do_set_config(struct fsg_dev *fsg, u8 new_config)
2868{
2869 int rc = 0;
2870
2871 /* Disable the single interface */
2872 if (fsg->config != 0) {
2873 DBG(fsg, "reset config\n");
2874 fsg->config = 0;
2875 rc = do_set_interface(fsg, -1);
2876 }
2877
2878 /* Enable the interface */
2879 if (new_config != 0) {
2880 fsg->config = new_config;
2881 if ((rc = do_set_interface(fsg, 0)) != 0)
2882 fsg->config = 0; // Reset on errors
2883 else
2884 INFO(fsg, "%s config #%d\n",
2885 usb_speed_string(fsg->gadget->speed),
2886 fsg->config);
2887 }
2888 return rc;
2889}
2890
2891
2892/*-------------------------------------------------------------------------*/
2893
2894static void handle_exception(struct fsg_dev *fsg)
2895{
2896 siginfo_t info;
2897 int sig;
2898 int i;
2899 int num_active;
2900 struct fsg_buffhd *bh;
2901 enum fsg_state old_state;
2902 u8 new_config;
2903 struct fsg_lun *curlun;
2904 unsigned int exception_req_tag;
2905 int rc;
2906
2907 /* Clear the existing signals. Anything but SIGUSR1 is converted
2908 * into a high-priority EXIT exception. */
2909 for (;;) {
2910 sig = dequeue_signal_lock(current, &current->blocked, &info);
2911 if (!sig)
2912 break;
2913 if (sig != SIGUSR1) {
2914 if (fsg->state < FSG_STATE_EXIT)
2915 DBG(fsg, "Main thread exiting on signal\n");
2916 raise_exception(fsg, FSG_STATE_EXIT);
2917 }
2918 }
2919
2920 /* Cancel all the pending transfers */
2921 if (fsg->intreq_busy)
2922 usb_ep_dequeue(fsg->intr_in, fsg->intreq);
2923 for (i = 0; i < fsg_num_buffers; ++i) {
2924 bh = &fsg->buffhds[i];
2925 if (bh->inreq_busy)
2926 usb_ep_dequeue(fsg->bulk_in, bh->inreq);
2927 if (bh->outreq_busy)
2928 usb_ep_dequeue(fsg->bulk_out, bh->outreq);
2929 }
2930
2931 /* Wait until everything is idle */
2932 for (;;) {
2933 num_active = fsg->intreq_busy;
2934 for (i = 0; i < fsg_num_buffers; ++i) {
2935 bh = &fsg->buffhds[i];
2936 num_active += bh->inreq_busy + bh->outreq_busy;
2937 }
2938 if (num_active == 0)
2939 break;
2940 if (sleep_thread(fsg))
2941 return;
2942 }
2943
2944 /* Clear out the controller's fifos */
2945 if (fsg->bulk_in_enabled)
2946 usb_ep_fifo_flush(fsg->bulk_in);
2947 if (fsg->bulk_out_enabled)
2948 usb_ep_fifo_flush(fsg->bulk_out);
2949 if (fsg->intr_in_enabled)
2950 usb_ep_fifo_flush(fsg->intr_in);
2951
2952 /* Reset the I/O buffer states and pointers, the SCSI
2953 * state, and the exception. Then invoke the handler. */
2954 spin_lock_irq(&fsg->lock);
2955
2956 for (i = 0; i < fsg_num_buffers; ++i) {
2957 bh = &fsg->buffhds[i];
2958 bh->state = BUF_STATE_EMPTY;
2959 }
2960 fsg->next_buffhd_to_fill = fsg->next_buffhd_to_drain =
2961 &fsg->buffhds[0];
2962
2963 exception_req_tag = fsg->exception_req_tag;
2964 new_config = fsg->new_config;
2965 old_state = fsg->state;
2966
2967 if (old_state == FSG_STATE_ABORT_BULK_OUT)
2968 fsg->state = FSG_STATE_STATUS_PHASE;
2969 else {
2970 for (i = 0; i < fsg->nluns; ++i) {
2971 curlun = &fsg->luns[i];
2972 curlun->prevent_medium_removal = 0;
2973 curlun->sense_data = curlun->unit_attention_data =
2974 SS_NO_SENSE;
2975 curlun->sense_data_info = 0;
2976 curlun->info_valid = 0;
2977 }
2978 fsg->state = FSG_STATE_IDLE;
2979 }
2980 spin_unlock_irq(&fsg->lock);
2981
2982 /* Carry out any extra actions required for the exception */
2983 switch (old_state) {
2984 default:
2985 break;
2986
2987 case FSG_STATE_ABORT_BULK_OUT:
2988 send_status(fsg);
2989 spin_lock_irq(&fsg->lock);
2990 if (fsg->state == FSG_STATE_STATUS_PHASE)
2991 fsg->state = FSG_STATE_IDLE;
2992 spin_unlock_irq(&fsg->lock);
2993 break;
2994
2995 case FSG_STATE_RESET:
2996 /* In case we were forced against our will to halt a
2997 * bulk endpoint, clear the halt now. (The SuperH UDC
2998 * requires this.) */
2999 if (test_and_clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags))
3000 usb_ep_clear_halt(fsg->bulk_in);
3001
3002 if (transport_is_bbb()) {
3003 if (fsg->ep0_req_tag == exception_req_tag)
3004 ep0_queue(fsg); // Complete the status stage
3005
3006 } else if (transport_is_cbi())
3007 send_status(fsg); // Status by interrupt pipe
3008
3009 /* Technically this should go here, but it would only be
3010 * a waste of time. Ditto for the INTERFACE_CHANGE and
3011 * CONFIG_CHANGE cases. */
3012 // for (i = 0; i < fsg->nluns; ++i)
3013 // fsg->luns[i].unit_attention_data = SS_RESET_OCCURRED;
3014 break;
3015
3016 case FSG_STATE_INTERFACE_CHANGE:
3017 rc = do_set_interface(fsg, 0);
3018 if (fsg->ep0_req_tag != exception_req_tag)
3019 break;
3020 if (rc != 0) // STALL on errors
3021 fsg_set_halt(fsg, fsg->ep0);
3022 else // Complete the status stage
3023 ep0_queue(fsg);
3024 break;
3025
3026 case FSG_STATE_CONFIG_CHANGE:
3027 rc = do_set_config(fsg, new_config);
3028 if (fsg->ep0_req_tag != exception_req_tag)
3029 break;
3030 if (rc != 0) // STALL on errors
3031 fsg_set_halt(fsg, fsg->ep0);
3032 else // Complete the status stage
3033 ep0_queue(fsg);
3034 break;
3035
3036 case FSG_STATE_DISCONNECT:
3037 for (i = 0; i < fsg->nluns; ++i)
3038 fsg_lun_fsync_sub(fsg->luns + i);
3039 do_set_config(fsg, 0); // Unconfigured state
3040 break;
3041
3042 case FSG_STATE_EXIT:
3043 case FSG_STATE_TERMINATED:
3044 do_set_config(fsg, 0); // Free resources
3045 spin_lock_irq(&fsg->lock);
3046 fsg->state = FSG_STATE_TERMINATED; // Stop the thread
3047 spin_unlock_irq(&fsg->lock);
3048 break;
3049 }
3050}
3051
3052
3053/*-------------------------------------------------------------------------*/
3054
3055static int fsg_main_thread(void *fsg_)
3056{
3057 struct fsg_dev *fsg = fsg_;
3058
3059 /* Allow the thread to be killed by a signal, but set the signal mask
3060 * to block everything but INT, TERM, KILL, and USR1. */
3061 allow_signal(SIGINT);
3062 allow_signal(SIGTERM);
3063 allow_signal(SIGKILL);
3064 allow_signal(SIGUSR1);
3065
3066 /* Allow the thread to be frozen */
3067 set_freezable();
3068
3069 /* Arrange for userspace references to be interpreted as kernel
3070 * pointers. That way we can pass a kernel pointer to a routine
3071 * that expects a __user pointer and it will work okay. */
3072 set_fs(get_ds());
3073
3074 /* The main loop */
3075 while (fsg->state != FSG_STATE_TERMINATED) {
3076 if (exception_in_progress(fsg) || signal_pending(current)) {
3077 handle_exception(fsg);
3078 continue;
3079 }
3080
3081 if (!fsg->running) {
3082 sleep_thread(fsg);
3083 continue;
3084 }
3085
3086 if (get_next_command(fsg))
3087 continue;
3088
3089 spin_lock_irq(&fsg->lock);
3090 if (!exception_in_progress(fsg))
3091 fsg->state = FSG_STATE_DATA_PHASE;
3092 spin_unlock_irq(&fsg->lock);
3093
3094 if (do_scsi_command(fsg) || finish_reply(fsg))
3095 continue;
3096
3097 spin_lock_irq(&fsg->lock);
3098 if (!exception_in_progress(fsg))
3099 fsg->state = FSG_STATE_STATUS_PHASE;
3100 spin_unlock_irq(&fsg->lock);
3101
3102 if (send_status(fsg))
3103 continue;
3104
3105 spin_lock_irq(&fsg->lock);
3106 if (!exception_in_progress(fsg))
3107 fsg->state = FSG_STATE_IDLE;
3108 spin_unlock_irq(&fsg->lock);
3109 }
3110
3111 spin_lock_irq(&fsg->lock);
3112 fsg->thread_task = NULL;
3113 spin_unlock_irq(&fsg->lock);
3114
3115 /* If we are exiting because of a signal, unregister the
3116 * gadget driver. */
3117 if (test_and_clear_bit(REGISTERED, &fsg->atomic_bitflags))
3118 usb_gadget_unregister_driver(&fsg_driver);
3119
3120 /* Let the unbind and cleanup routines know the thread has exited */
3121 complete_and_exit(&fsg->thread_notifier, 0);
3122}
3123
3124
3125/*-------------------------------------------------------------------------*/
3126
3127
3128/* The write permissions and store_xxx pointers are set in fsg_bind() */
3129static DEVICE_ATTR(ro, 0444, fsg_show_ro, NULL);
3130static DEVICE_ATTR(nofua, 0644, fsg_show_nofua, NULL);
3131static DEVICE_ATTR(file, 0444, fsg_show_file, NULL);
3132
3133
3134/*-------------------------------------------------------------------------*/
3135
3136static void fsg_release(struct kref *ref)
3137{
3138 struct fsg_dev *fsg = container_of(ref, struct fsg_dev, ref);
3139
3140 kfree(fsg->luns);
3141 kfree(fsg);
3142}
3143
3144static void lun_release(struct device *dev)
3145{
3146 struct rw_semaphore *filesem = dev_get_drvdata(dev);
3147 struct fsg_dev *fsg =
3148 container_of(filesem, struct fsg_dev, filesem);
3149
3150 kref_put(&fsg->ref, fsg_release);
3151}
3152
3153static void /* __init_or_exit */ fsg_unbind(struct usb_gadget *gadget)
3154{
3155 struct fsg_dev *fsg = get_gadget_data(gadget);
3156 int i;
3157 struct fsg_lun *curlun;
3158 struct usb_request *req = fsg->ep0req;
3159
3160 DBG(fsg, "unbind\n");
3161 clear_bit(REGISTERED, &fsg->atomic_bitflags);
3162
3163 /* If the thread isn't already dead, tell it to exit now */
3164 if (fsg->state != FSG_STATE_TERMINATED) {
3165 raise_exception(fsg, FSG_STATE_EXIT);
3166 wait_for_completion(&fsg->thread_notifier);
3167
3168 /* The cleanup routine waits for this completion also */
3169 complete(&fsg->thread_notifier);
3170 }
3171
3172 /* Unregister the sysfs attribute files and the LUNs */
3173 for (i = 0; i < fsg->nluns; ++i) {
3174 curlun = &fsg->luns[i];
3175 if (curlun->registered) {
3176 device_remove_file(&curlun->dev, &dev_attr_nofua);
3177 device_remove_file(&curlun->dev, &dev_attr_ro);
3178 device_remove_file(&curlun->dev, &dev_attr_file);
3179 fsg_lun_close(curlun);
3180 device_unregister(&curlun->dev);
3181 curlun->registered = 0;
3182 }
3183 }
3184
3185 /* Free the data buffers */
3186 for (i = 0; i < fsg_num_buffers; ++i)
3187 kfree(fsg->buffhds[i].buf);
3188
3189 /* Free the request and buffer for endpoint 0 */
3190 if (req) {
3191 kfree(req->buf);
3192 usb_ep_free_request(fsg->ep0, req);
3193 }
3194
3195 set_gadget_data(gadget, NULL);
3196}
3197
3198
3199static int __init check_parameters(struct fsg_dev *fsg)
3200{
3201 int prot;
3202
3203 /* Store the default values */
3204 mod_data.transport_type = USB_PR_BULK;
3205 mod_data.transport_name = "Bulk-only";
3206 mod_data.protocol_type = USB_SC_SCSI;
3207 mod_data.protocol_name = "Transparent SCSI";
3208
3209 /* Some peripheral controllers are known not to be able to
3210 * halt bulk endpoints correctly. If one of them is present,
3211 * disable stalls.
3212 */
3213 if (gadget_is_at91(fsg->gadget))
3214 mod_data.can_stall = 0;
3215
3216 if (mod_data.release == 0xffff)
3217 mod_data.release = get_default_bcdDevice();
3218
3219 prot = simple_strtol(mod_data.protocol_parm, NULL, 0);
3220
3221#ifdef CONFIG_USB_FILE_STORAGE_TEST
3222 if (strnicmp(mod_data.transport_parm, "BBB", 10) == 0) {
3223 ; // Use default setting
3224 } else if (strnicmp(mod_data.transport_parm, "CB", 10) == 0) {
3225 mod_data.transport_type = USB_PR_CB;
3226 mod_data.transport_name = "Control-Bulk";
3227 } else if (strnicmp(mod_data.transport_parm, "CBI", 10) == 0) {
3228 mod_data.transport_type = USB_PR_CBI;
3229 mod_data.transport_name = "Control-Bulk-Interrupt";
3230 } else {
3231 ERROR(fsg, "invalid transport: %s\n", mod_data.transport_parm);
3232 return -EINVAL;
3233 }
3234
3235 if (strnicmp(mod_data.protocol_parm, "SCSI", 10) == 0 ||
3236 prot == USB_SC_SCSI) {
3237 ; // Use default setting
3238 } else if (strnicmp(mod_data.protocol_parm, "RBC", 10) == 0 ||
3239 prot == USB_SC_RBC) {
3240 mod_data.protocol_type = USB_SC_RBC;
3241 mod_data.protocol_name = "RBC";
3242 } else if (strnicmp(mod_data.protocol_parm, "8020", 4) == 0 ||
3243 strnicmp(mod_data.protocol_parm, "ATAPI", 10) == 0 ||
3244 prot == USB_SC_8020) {
3245 mod_data.protocol_type = USB_SC_8020;
3246 mod_data.protocol_name = "8020i (ATAPI)";
3247 } else if (strnicmp(mod_data.protocol_parm, "QIC", 3) == 0 ||
3248 prot == USB_SC_QIC) {
3249 mod_data.protocol_type = USB_SC_QIC;
3250 mod_data.protocol_name = "QIC-157";
3251 } else if (strnicmp(mod_data.protocol_parm, "UFI", 10) == 0 ||
3252 prot == USB_SC_UFI) {
3253 mod_data.protocol_type = USB_SC_UFI;
3254 mod_data.protocol_name = "UFI";
3255 } else if (strnicmp(mod_data.protocol_parm, "8070", 4) == 0 ||
3256 prot == USB_SC_8070) {
3257 mod_data.protocol_type = USB_SC_8070;
3258 mod_data.protocol_name = "8070i";
3259 } else {
3260 ERROR(fsg, "invalid protocol: %s\n", mod_data.protocol_parm);
3261 return -EINVAL;
3262 }
3263
3264 mod_data.buflen &= PAGE_CACHE_MASK;
3265 if (mod_data.buflen <= 0) {
3266 ERROR(fsg, "invalid buflen\n");
3267 return -ETOOSMALL;
3268 }
3269
3270#endif /* CONFIG_USB_FILE_STORAGE_TEST */
3271
3272 /* Serial string handling.
3273 * On a real device, the serial string would be loaded
3274 * from permanent storage. */
3275 if (mod_data.serial) {
3276 const char *ch;
3277 unsigned len = 0;
3278
3279 /* Sanity check :
3280 * The CB[I] specification limits the serial string to
3281 * 12 uppercase hexadecimal characters.
3282 * BBB need at least 12 uppercase hexadecimal characters,
3283 * with a maximum of 126. */
3284 for (ch = mod_data.serial; *ch; ++ch) {
3285 ++len;
3286 if ((*ch < '0' || *ch > '9') &&
3287 (*ch < 'A' || *ch > 'F')) { /* not uppercase hex */
3288 WARNING(fsg,
3289 "Invalid serial string character: %c\n",
3290 *ch);
3291 goto no_serial;
3292 }
3293 }
3294 if (len > 126 ||
3295 (mod_data.transport_type == USB_PR_BULK && len < 12) ||
3296 (mod_data.transport_type != USB_PR_BULK && len > 12)) {
3297 WARNING(fsg, "Invalid serial string length!\n");
3298 goto no_serial;
3299 }
3300 fsg_strings[FSG_STRING_SERIAL - 1].s = mod_data.serial;
3301 } else {
3302 WARNING(fsg, "No serial-number string provided!\n");
3303 no_serial:
3304 device_desc.iSerialNumber = 0;
3305 }
3306
3307 return 0;
3308}
3309
3310
3311static int __init fsg_bind(struct usb_gadget *gadget,
3312 struct usb_gadget_driver *driver)
3313{
3314 struct fsg_dev *fsg = the_fsg;
3315 int rc;
3316 int i;
3317 struct fsg_lun *curlun;
3318 struct usb_ep *ep;
3319 struct usb_request *req;
3320 char *pathbuf, *p;
3321
3322 fsg->gadget = gadget;
3323 set_gadget_data(gadget, fsg);
3324 fsg->ep0 = gadget->ep0;
3325 fsg->ep0->driver_data = fsg;
3326
3327 if ((rc = check_parameters(fsg)) != 0)
3328 goto out;
3329
3330 if (mod_data.removable) { // Enable the store_xxx attributes
3331 dev_attr_file.attr.mode = 0644;
3332 dev_attr_file.store = fsg_store_file;
3333 if (!mod_data.cdrom) {
3334 dev_attr_ro.attr.mode = 0644;
3335 dev_attr_ro.store = fsg_store_ro;
3336 }
3337 }
3338
3339 /* Only for removable media? */
3340 dev_attr_nofua.attr.mode = 0644;
3341 dev_attr_nofua.store = fsg_store_nofua;
3342
3343 /* Find out how many LUNs there should be */
3344 i = mod_data.nluns;
3345 if (i == 0)
3346 i = max(mod_data.num_filenames, 1u);
3347 if (i > FSG_MAX_LUNS) {
3348 ERROR(fsg, "invalid number of LUNs: %d\n", i);
3349 rc = -EINVAL;
3350 goto out;
3351 }
3352
3353 /* Create the LUNs, open their backing files, and register the
3354 * LUN devices in sysfs. */
3355 fsg->luns = kzalloc(i * sizeof(struct fsg_lun), GFP_KERNEL);
3356 if (!fsg->luns) {
3357 rc = -ENOMEM;
3358 goto out;
3359 }
3360 fsg->nluns = i;
3361
3362 for (i = 0; i < fsg->nluns; ++i) {
3363 curlun = &fsg->luns[i];
3364 curlun->cdrom = !!mod_data.cdrom;
3365 curlun->ro = mod_data.cdrom || mod_data.ro[i];
3366 curlun->initially_ro = curlun->ro;
3367 curlun->removable = mod_data.removable;
3368 curlun->nofua = mod_data.nofua[i];
3369 curlun->dev.release = lun_release;
3370 curlun->dev.parent = &gadget->dev;
3371 curlun->dev.driver = &fsg_driver.driver;
3372 dev_set_drvdata(&curlun->dev, &fsg->filesem);
3373 dev_set_name(&curlun->dev,"%s-lun%d",
3374 dev_name(&gadget->dev), i);
3375
3376 kref_get(&fsg->ref);
3377 rc = device_register(&curlun->dev);
3378 if (rc) {
3379 INFO(fsg, "failed to register LUN%d: %d\n", i, rc);
3380 put_device(&curlun->dev);
3381 goto out;
3382 }
3383 curlun->registered = 1;
3384
3385 rc = device_create_file(&curlun->dev, &dev_attr_ro);
3386 if (rc)
3387 goto out;
3388 rc = device_create_file(&curlun->dev, &dev_attr_nofua);
3389 if (rc)
3390 goto out;
3391 rc = device_create_file(&curlun->dev, &dev_attr_file);
3392 if (rc)
3393 goto out;
3394
3395 if (mod_data.file[i] && *mod_data.file[i]) {
3396 rc = fsg_lun_open(curlun, mod_data.file[i]);
3397 if (rc)
3398 goto out;
3399 } else if (!mod_data.removable) {
3400 ERROR(fsg, "no file given for LUN%d\n", i);
3401 rc = -EINVAL;
3402 goto out;
3403 }
3404 }
3405
3406 /* Find all the endpoints we will use */
3407 usb_ep_autoconfig_reset(gadget);
3408 ep = usb_ep_autoconfig(gadget, &fsg_fs_bulk_in_desc);
3409 if (!ep)
3410 goto autoconf_fail;
3411 ep->driver_data = fsg; // claim the endpoint
3412 fsg->bulk_in = ep;
3413
3414 ep = usb_ep_autoconfig(gadget, &fsg_fs_bulk_out_desc);
3415 if (!ep)
3416 goto autoconf_fail;
3417 ep->driver_data = fsg; // claim the endpoint
3418 fsg->bulk_out = ep;
3419
3420 if (transport_is_cbi()) {
3421 ep = usb_ep_autoconfig(gadget, &fsg_fs_intr_in_desc);
3422 if (!ep)
3423 goto autoconf_fail;
3424 ep->driver_data = fsg; // claim the endpoint
3425 fsg->intr_in = ep;
3426 }
3427
3428 /* Fix up the descriptors */
3429 device_desc.idVendor = cpu_to_le16(mod_data.vendor);
3430 device_desc.idProduct = cpu_to_le16(mod_data.product);
3431 device_desc.bcdDevice = cpu_to_le16(mod_data.release);
3432
3433 i = (transport_is_cbi() ? 3 : 2); // Number of endpoints
3434 fsg_intf_desc.bNumEndpoints = i;
3435 fsg_intf_desc.bInterfaceSubClass = mod_data.protocol_type;
3436 fsg_intf_desc.bInterfaceProtocol = mod_data.transport_type;
3437 fsg_fs_function[i + FSG_FS_FUNCTION_PRE_EP_ENTRIES] = NULL;
3438
3439 if (gadget_is_dualspeed(gadget)) {
3440 fsg_hs_function[i + FSG_HS_FUNCTION_PRE_EP_ENTRIES] = NULL;
3441
3442 /* Assume endpoint addresses are the same for both speeds */
3443 fsg_hs_bulk_in_desc.bEndpointAddress =
3444 fsg_fs_bulk_in_desc.bEndpointAddress;
3445 fsg_hs_bulk_out_desc.bEndpointAddress =
3446 fsg_fs_bulk_out_desc.bEndpointAddress;
3447 fsg_hs_intr_in_desc.bEndpointAddress =
3448 fsg_fs_intr_in_desc.bEndpointAddress;
3449 }
3450
3451 if (gadget_is_superspeed(gadget)) {
3452 unsigned max_burst;
3453
3454 fsg_ss_function[i + FSG_SS_FUNCTION_PRE_EP_ENTRIES] = NULL;
3455
3456 /* Calculate bMaxBurst, we know packet size is 1024 */
3457 max_burst = min_t(unsigned, mod_data.buflen / 1024, 15);
3458
3459 /* Assume endpoint addresses are the same for both speeds */
3460 fsg_ss_bulk_in_desc.bEndpointAddress =
3461 fsg_fs_bulk_in_desc.bEndpointAddress;
3462 fsg_ss_bulk_in_comp_desc.bMaxBurst = max_burst;
3463
3464 fsg_ss_bulk_out_desc.bEndpointAddress =
3465 fsg_fs_bulk_out_desc.bEndpointAddress;
3466 fsg_ss_bulk_out_comp_desc.bMaxBurst = max_burst;
3467 }
3468
3469 if (gadget_is_otg(gadget))
3470 fsg_otg_desc.bmAttributes |= USB_OTG_HNP;
3471
3472 rc = -ENOMEM;
3473
3474 /* Allocate the request and buffer for endpoint 0 */
3475 fsg->ep0req = req = usb_ep_alloc_request(fsg->ep0, GFP_KERNEL);
3476 if (!req)
3477 goto out;
3478 req->buf = kmalloc(EP0_BUFSIZE, GFP_KERNEL);
3479 if (!req->buf)
3480 goto out;
3481 req->complete = ep0_complete;
3482
3483 /* Allocate the data buffers */
3484 for (i = 0; i < fsg_num_buffers; ++i) {
3485 struct fsg_buffhd *bh = &fsg->buffhds[i];
3486
3487 /* Allocate for the bulk-in endpoint. We assume that
3488 * the buffer will also work with the bulk-out (and
3489 * interrupt-in) endpoint. */
3490 bh->buf = kmalloc(mod_data.buflen, GFP_KERNEL);
3491 if (!bh->buf)
3492 goto out;
3493 bh->next = bh + 1;
3494 }
3495 fsg->buffhds[fsg_num_buffers - 1].next = &fsg->buffhds[0];
3496
3497 /* This should reflect the actual gadget power source */
3498 usb_gadget_set_selfpowered(gadget);
3499
3500 snprintf(fsg_string_manufacturer, sizeof fsg_string_manufacturer,
3501 "%s %s with %s",
3502 init_utsname()->sysname, init_utsname()->release,
3503 gadget->name);
3504
3505 fsg->thread_task = kthread_create(fsg_main_thread, fsg,
3506 "file-storage-gadget");
3507 if (IS_ERR(fsg->thread_task)) {
3508 rc = PTR_ERR(fsg->thread_task);
3509 goto out;
3510 }
3511
3512 INFO(fsg, DRIVER_DESC ", version: " DRIVER_VERSION "\n");
3513 INFO(fsg, "NOTE: This driver is deprecated. "
3514 "Consider using g_mass_storage instead.\n");
3515 INFO(fsg, "Number of LUNs=%d\n", fsg->nluns);
3516
3517 pathbuf = kmalloc(PATH_MAX, GFP_KERNEL);
3518 for (i = 0; i < fsg->nluns; ++i) {
3519 curlun = &fsg->luns[i];
3520 if (fsg_lun_is_open(curlun)) {
3521 p = NULL;
3522 if (pathbuf) {
3523 p = d_path(&curlun->filp->f_path,
3524 pathbuf, PATH_MAX);
3525 if (IS_ERR(p))
3526 p = NULL;
3527 }
3528 LINFO(curlun, "ro=%d, nofua=%d, file: %s\n",
3529 curlun->ro, curlun->nofua, (p ? p : "(error)"));
3530 }
3531 }
3532 kfree(pathbuf);
3533
3534 DBG(fsg, "transport=%s (x%02x)\n",
3535 mod_data.transport_name, mod_data.transport_type);
3536 DBG(fsg, "protocol=%s (x%02x)\n",
3537 mod_data.protocol_name, mod_data.protocol_type);
3538 DBG(fsg, "VendorID=x%04x, ProductID=x%04x, Release=x%04x\n",
3539 mod_data.vendor, mod_data.product, mod_data.release);
3540 DBG(fsg, "removable=%d, stall=%d, cdrom=%d, buflen=%u\n",
3541 mod_data.removable, mod_data.can_stall,
3542 mod_data.cdrom, mod_data.buflen);
3543 DBG(fsg, "I/O thread pid: %d\n", task_pid_nr(fsg->thread_task));
3544
3545 set_bit(REGISTERED, &fsg->atomic_bitflags);
3546
3547 /* Tell the thread to start working */
3548 wake_up_process(fsg->thread_task);
3549 return 0;
3550
3551autoconf_fail:
3552 ERROR(fsg, "unable to autoconfigure all endpoints\n");
3553 rc = -ENOTSUPP;
3554
3555out:
3556 fsg->state = FSG_STATE_TERMINATED; // The thread is dead
3557 fsg_unbind(gadget);
3558 complete(&fsg->thread_notifier);
3559 return rc;
3560}
3561
3562
3563/*-------------------------------------------------------------------------*/
3564
3565static void fsg_suspend(struct usb_gadget *gadget)
3566{
3567 struct fsg_dev *fsg = get_gadget_data(gadget);
3568
3569 DBG(fsg, "suspend\n");
3570 set_bit(SUSPENDED, &fsg->atomic_bitflags);
3571}
3572
3573static void fsg_resume(struct usb_gadget *gadget)
3574{
3575 struct fsg_dev *fsg = get_gadget_data(gadget);
3576
3577 DBG(fsg, "resume\n");
3578 clear_bit(SUSPENDED, &fsg->atomic_bitflags);
3579}
3580
3581
3582/*-------------------------------------------------------------------------*/
3583
3584static __refdata struct usb_gadget_driver fsg_driver = {
3585 .max_speed = USB_SPEED_SUPER,
3586 .function = (char *) fsg_string_product,
3587 .bind = fsg_bind,
3588 .unbind = fsg_unbind,
3589 .disconnect = fsg_disconnect,
3590 .setup = fsg_setup,
3591 .suspend = fsg_suspend,
3592 .resume = fsg_resume,
3593
3594 .driver = {
3595 .name = DRIVER_NAME,
3596 .owner = THIS_MODULE,
3597 // .release = ...
3598 // .suspend = ...
3599 // .resume = ...
3600 },
3601};
3602
3603
3604static int __init fsg_alloc(void)
3605{
3606 struct fsg_dev *fsg;
3607
3608 fsg = kzalloc(sizeof *fsg +
3609 fsg_num_buffers * sizeof *(fsg->buffhds), GFP_KERNEL);
3610
3611 if (!fsg)
3612 return -ENOMEM;
3613 spin_lock_init(&fsg->lock);
3614 init_rwsem(&fsg->filesem);
3615 kref_init(&fsg->ref);
3616 init_completion(&fsg->thread_notifier);
3617
3618 the_fsg = fsg;
3619 return 0;
3620}
3621
3622
3623static int __init fsg_init(void)
3624{
3625 int rc;
3626 struct fsg_dev *fsg;
3627
3628 rc = fsg_num_buffers_validate();
3629 if (rc != 0)
3630 return rc;
3631
3632 if ((rc = fsg_alloc()) != 0)
3633 return rc;
3634 fsg = the_fsg;
3635 rc = usb_gadget_probe_driver(&fsg_driver);
3636 if (rc != 0)
3637 kref_put(&fsg->ref, fsg_release);
3638 return rc;
3639}
3640module_init(fsg_init);
3641
3642
3643static void __exit fsg_cleanup(void)
3644{
3645 struct fsg_dev *fsg = the_fsg;
3646
3647 /* Unregister the driver iff the thread hasn't already done so */
3648 if (test_and_clear_bit(REGISTERED, &fsg->atomic_bitflags))
3649 usb_gadget_unregister_driver(&fsg_driver);
3650
3651 /* Wait for the thread to finish up */
3652 wait_for_completion(&fsg->thread_notifier);
3653
3654 kref_put(&fsg->ref, fsg_release);
3655}
3656module_exit(fsg_cleanup);
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c
index b09452d6f33a..ec50f18c8890 100644
--- a/drivers/usb/gadget/fsl_qe_udc.c
+++ b/drivers/usb/gadget/fsl_qe_udc.c
@@ -2347,7 +2347,7 @@ static int fsl_qe_stop(struct usb_gadget *gadget,
2347} 2347}
2348 2348
2349/* udc structure's alloc and setup, include ep-param alloc */ 2349/* udc structure's alloc and setup, include ep-param alloc */
2350static struct qe_udc __devinit *qe_udc_config(struct platform_device *ofdev) 2350static struct qe_udc *qe_udc_config(struct platform_device *ofdev)
2351{ 2351{
2352 struct qe_udc *udc; 2352 struct qe_udc *udc;
2353 struct device_node *np = ofdev->dev.of_node; 2353 struct device_node *np = ofdev->dev.of_node;
@@ -2402,7 +2402,7 @@ cleanup:
2402} 2402}
2403 2403
2404/* USB Controller register init */ 2404/* USB Controller register init */
2405static int __devinit qe_udc_reg_init(struct qe_udc *udc) 2405static int qe_udc_reg_init(struct qe_udc *udc)
2406{ 2406{
2407 struct usb_ctlr __iomem *qe_usbregs; 2407 struct usb_ctlr __iomem *qe_usbregs;
2408 qe_usbregs = udc->usb_regs; 2408 qe_usbregs = udc->usb_regs;
@@ -2420,7 +2420,7 @@ static int __devinit qe_udc_reg_init(struct qe_udc *udc)
2420 return 0; 2420 return 0;
2421} 2421}
2422 2422
2423static int __devinit qe_ep_config(struct qe_udc *udc, unsigned char pipe_num) 2423static int qe_ep_config(struct qe_udc *udc, unsigned char pipe_num)
2424{ 2424{
2425 struct qe_ep *ep = &udc->eps[pipe_num]; 2425 struct qe_ep *ep = &udc->eps[pipe_num];
2426 2426
@@ -2473,7 +2473,7 @@ static void qe_udc_release(struct device *dev)
2473 2473
2474/* Driver probe functions */ 2474/* Driver probe functions */
2475static const struct of_device_id qe_udc_match[]; 2475static const struct of_device_id qe_udc_match[];
2476static int __devinit qe_udc_probe(struct platform_device *ofdev) 2476static int qe_udc_probe(struct platform_device *ofdev)
2477{ 2477{
2478 struct qe_udc *udc; 2478 struct qe_udc *udc;
2479 const struct of_device_id *match; 2479 const struct of_device_id *match;
@@ -2651,7 +2651,7 @@ static int qe_udc_resume(struct platform_device *dev)
2651} 2651}
2652#endif 2652#endif
2653 2653
2654static int __devexit qe_udc_remove(struct platform_device *ofdev) 2654static int qe_udc_remove(struct platform_device *ofdev)
2655{ 2655{
2656 struct qe_udc *udc = dev_get_drvdata(&ofdev->dev); 2656 struct qe_udc *udc = dev_get_drvdata(&ofdev->dev);
2657 struct qe_ep *ep; 2657 struct qe_ep *ep;
@@ -2710,7 +2710,7 @@ static int __devexit qe_udc_remove(struct platform_device *ofdev)
2710} 2710}
2711 2711
2712/*-------------------------------------------------------------------------*/ 2712/*-------------------------------------------------------------------------*/
2713static const struct of_device_id qe_udc_match[] __devinitconst = { 2713static const struct of_device_id qe_udc_match[] = {
2714 { 2714 {
2715 .compatible = "fsl,mpc8323-qe-usb", 2715 .compatible = "fsl,mpc8323-qe-usb",
2716 .data = (void *)PORT_QE, 2716 .data = (void *)PORT_QE,
@@ -2735,7 +2735,7 @@ static struct platform_driver udc_driver = {
2735 .of_match_table = qe_udc_match, 2735 .of_match_table = qe_udc_match,
2736 }, 2736 },
2737 .probe = qe_udc_probe, 2737 .probe = qe_udc_probe,
2738 .remove = __devexit_p(qe_udc_remove), 2738 .remove = qe_udc_remove,
2739#ifdef CONFIG_PM 2739#ifdef CONFIG_PM
2740 .suspend = qe_udc_suspend, 2740 .suspend = qe_udc_suspend,
2741 .resume = qe_udc_resume, 2741 .resume = qe_udc_resume,
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index 6ae70cba0c4a..c19f7f13790b 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -2126,7 +2126,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count,
2126 2126
2127 tmp_reg = fsl_readl(&dr_regs->usbintr); 2127 tmp_reg = fsl_readl(&dr_regs->usbintr);
2128 t = scnprintf(next, size, 2128 t = scnprintf(next, size,
2129 "USB Intrrupt Enable Reg:\n" 2129 "USB Interrupt Enable Reg:\n"
2130 "Sleep Enable: %d SOF Received Enable: %d " 2130 "Sleep Enable: %d SOF Received Enable: %d "
2131 "Reset Enable: %d\n" 2131 "Reset Enable: %d\n"
2132 "System Error Enable: %d " 2132 "System Error Enable: %d "
diff --git a/drivers/usb/gadget/hid.c b/drivers/usb/gadget/hid.c
index 74130f6c12c0..c36260ea8bf2 100644
--- a/drivers/usb/gadget/hid.c
+++ b/drivers/usb/gadget/hid.c
@@ -203,7 +203,7 @@ static int __init hidg_plat_driver_probe(struct platform_device *pdev)
203 return 0; 203 return 0;
204} 204}
205 205
206static int __devexit hidg_plat_driver_remove(struct platform_device *pdev) 206static int hidg_plat_driver_remove(struct platform_device *pdev)
207{ 207{
208 struct hidg_func_node *e, *n; 208 struct hidg_func_node *e, *n;
209 209
@@ -229,7 +229,7 @@ static __refdata struct usb_composite_driver hidg_driver = {
229}; 229};
230 230
231static struct platform_driver hidg_plat_driver = { 231static struct platform_driver hidg_plat_driver = {
232 .remove = __devexit_p(hidg_plat_driver_remove), 232 .remove = hidg_plat_driver_remove,
233 .driver = { 233 .driver = {
234 .owner = THIS_MODULE, 234 .owner = THIS_MODULE,
235 .name = "hidg", 235 .name = "hidg",
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 76494cabf4e4..8ac840f25ba9 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -76,7 +76,6 @@ MODULE_LICENSE ("GPL");
76/*----------------------------------------------------------------------*/ 76/*----------------------------------------------------------------------*/
77 77
78#define GADGETFS_MAGIC 0xaee71ee7 78#define GADGETFS_MAGIC 0xaee71ee7
79#define DMA_ADDR_INVALID (~(dma_addr_t)0)
80 79
81/* /dev/gadget/$CHIP represents ep0 and the whole device */ 80/* /dev/gadget/$CHIP represents ep0 and the whole device */
82enum ep0_state { 81enum ep0_state {
@@ -918,7 +917,6 @@ static void clean_req (struct usb_ep *ep, struct usb_request *req)
918 if (req->buf != dev->rbuf) { 917 if (req->buf != dev->rbuf) {
919 kfree(req->buf); 918 kfree(req->buf);
920 req->buf = dev->rbuf; 919 req->buf = dev->rbuf;
921 req->dma = DMA_ADDR_INVALID;
922 } 920 }
923 req->complete = epio_complete; 921 req->complete = epio_complete;
924 dev->setup_out_ready = 0; 922 dev->setup_out_ready = 0;
@@ -1408,7 +1406,6 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1408 dev->setup_abort = 1; 1406 dev->setup_abort = 1;
1409 1407
1410 req->buf = dev->rbuf; 1408 req->buf = dev->rbuf;
1411 req->dma = DMA_ADDR_INVALID;
1412 req->context = NULL; 1409 req->context = NULL;
1413 value = -EOPNOTSUPP; 1410 value = -EOPNOTSUPP;
1414 switch (ctrl->bRequest) { 1411 switch (ctrl->bRequest) {
diff --git a/drivers/usb/gadget/lpc32xx_udc.c b/drivers/usb/gadget/lpc32xx_udc.c
index 21a9861dabf0..dd1c9b1fe528 100644
--- a/drivers/usb/gadget/lpc32xx_udc.c
+++ b/drivers/usb/gadget/lpc32xx_udc.c
@@ -2399,7 +2399,7 @@ static void udc_handle_ep0_setup(struct lpc32xx_udc *udc)
2399 2399
2400 if (i < 0) { 2400 if (i < 0) {
2401 /* setup processing failed, force stall */ 2401 /* setup processing failed, force stall */
2402 dev_err(udc->dev, 2402 dev_dbg(udc->dev,
2403 "req %02x.%02x protocol STALL; stat %d\n", 2403 "req %02x.%02x protocol STALL; stat %d\n",
2404 reqtype, req, i); 2404 reqtype, req, i);
2405 udc->ep0state = WAIT_FOR_SETUP; 2405 udc->ep0state = WAIT_FOR_SETUP;
@@ -3352,7 +3352,7 @@ phy_fail:
3352 return retval; 3352 return retval;
3353} 3353}
3354 3354
3355static int __devexit lpc32xx_udc_remove(struct platform_device *pdev) 3355static int lpc32xx_udc_remove(struct platform_device *pdev)
3356{ 3356{
3357 struct lpc32xx_udc *udc = platform_get_drvdata(pdev); 3357 struct lpc32xx_udc *udc = platform_get_drvdata(pdev);
3358 3358
@@ -3447,7 +3447,7 @@ MODULE_DEVICE_TABLE(of, lpc32xx_udc_of_match);
3447#endif 3447#endif
3448 3448
3449static struct platform_driver lpc32xx_udc_driver = { 3449static struct platform_driver lpc32xx_udc_driver = {
3450 .remove = __devexit_p(lpc32xx_udc_remove), 3450 .remove = lpc32xx_udc_remove,
3451 .shutdown = lpc32xx_udc_shutdown, 3451 .shutdown = lpc32xx_udc_shutdown,
3452 .suspend = lpc32xx_udc_suspend, 3452 .suspend = lpc32xx_udc_suspend,
3453 .resume = lpc32xx_udc_resume, 3453 .resume = lpc32xx_udc_resume,
diff --git a/drivers/usb/gadget/mv_u3d_core.c b/drivers/usb/gadget/mv_u3d_core.c
index 8cfd5b028dbd..b5cea273c957 100644
--- a/drivers/usb/gadget/mv_u3d_core.c
+++ b/drivers/usb/gadget/mv_u3d_core.c
@@ -1763,7 +1763,7 @@ static void mv_u3d_gadget_release(struct device *dev)
1763 dev_dbg(dev, "%s\n", __func__); 1763 dev_dbg(dev, "%s\n", __func__);
1764} 1764}
1765 1765
1766static __devexit int mv_u3d_remove(struct platform_device *dev) 1766static int mv_u3d_remove(struct platform_device *dev)
1767{ 1767{
1768 struct mv_u3d *u3d = platform_get_drvdata(dev); 1768 struct mv_u3d *u3d = platform_get_drvdata(dev);
1769 1769
diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c
index ea45224f78c8..379aac7b82fc 100644
--- a/drivers/usb/gadget/mv_udc_core.c
+++ b/drivers/usb/gadget/mv_udc_core.c
@@ -2128,7 +2128,7 @@ static void gadget_release(struct device *_dev)
2128 complete(udc->done); 2128 complete(udc->done);
2129} 2129}
2130 2130
2131static int __devexit mv_udc_remove(struct platform_device *dev) 2131static int mv_udc_remove(struct platform_device *dev)
2132{ 2132{
2133 struct mv_udc *udc = the_controller; 2133 struct mv_udc *udc = the_controller;
2134 int clk_i; 2134 int clk_i;
@@ -2188,7 +2188,7 @@ static int __devexit mv_udc_remove(struct platform_device *dev)
2188 return 0; 2188 return 0;
2189} 2189}
2190 2190
2191static int __devinit mv_udc_probe(struct platform_device *dev) 2191static int mv_udc_probe(struct platform_device *dev)
2192{ 2192{
2193 struct mv_usb_platform_data *pdata = dev->dev.platform_data; 2193 struct mv_usb_platform_data *pdata = dev->dev.platform_data;
2194 struct mv_udc *udc; 2194 struct mv_udc *udc;
diff --git a/drivers/usb/gadget/net2272.c b/drivers/usb/gadget/net2272.c
index c009263a47e3..d226058e3b88 100644
--- a/drivers/usb/gadget/net2272.c
+++ b/drivers/usb/gadget/net2272.c
@@ -2193,7 +2193,7 @@ net2272_gadget_release(struct device *_dev)
2193 2193
2194/*---------------------------------------------------------------------------*/ 2194/*---------------------------------------------------------------------------*/
2195 2195
2196static void __devexit 2196static void
2197net2272_remove(struct net2272 *dev) 2197net2272_remove(struct net2272 *dev)
2198{ 2198{
2199 usb_del_gadget_udc(&dev->gadget); 2199 usb_del_gadget_udc(&dev->gadget);
@@ -2215,8 +2215,7 @@ net2272_remove(struct net2272 *dev)
2215 dev_info(dev->dev, "unbind\n"); 2215 dev_info(dev->dev, "unbind\n");
2216} 2216}
2217 2217
2218static struct net2272 * __devinit 2218static struct net2272 *net2272_probe_init(struct device *dev, unsigned int irq)
2219net2272_probe_init(struct device *dev, unsigned int irq)
2220{ 2219{
2221 struct net2272 *ret; 2220 struct net2272 *ret;
2222 2221
@@ -2246,7 +2245,7 @@ net2272_probe_init(struct device *dev, unsigned int irq)
2246 return ret; 2245 return ret;
2247} 2246}
2248 2247
2249static int __devinit 2248static int
2250net2272_probe_fin(struct net2272 *dev, unsigned int irqflags) 2249net2272_probe_fin(struct net2272 *dev, unsigned int irqflags)
2251{ 2250{
2252 int ret; 2251 int ret;
@@ -2306,7 +2305,7 @@ err_add_udc:
2306 * don't respond over USB until a gadget driver binds to us 2305 * don't respond over USB until a gadget driver binds to us
2307 */ 2306 */
2308 2307
2309static int __devinit 2308static int
2310net2272_rdk1_probe(struct pci_dev *pdev, struct net2272 *dev) 2309net2272_rdk1_probe(struct pci_dev *pdev, struct net2272 *dev)
2311{ 2310{
2312 unsigned long resource, len, tmp; 2311 unsigned long resource, len, tmp;
@@ -2389,7 +2388,7 @@ net2272_rdk1_probe(struct pci_dev *pdev, struct net2272 *dev)
2389 return ret; 2388 return ret;
2390} 2389}
2391 2390
2392static int __devinit 2391static int
2393net2272_rdk2_probe(struct pci_dev *pdev, struct net2272 *dev) 2392net2272_rdk2_probe(struct pci_dev *pdev, struct net2272 *dev)
2394{ 2393{
2395 unsigned long resource, len; 2394 unsigned long resource, len;
@@ -2447,7 +2446,7 @@ net2272_rdk2_probe(struct pci_dev *pdev, struct net2272 *dev)
2447 return ret; 2446 return ret;
2448} 2447}
2449 2448
2450static int __devinit 2449static int
2451net2272_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) 2450net2272_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2452{ 2451{
2453 struct net2272 *dev; 2452 struct net2272 *dev;
@@ -2489,7 +2488,7 @@ net2272_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2489 return ret; 2488 return ret;
2490} 2489}
2491 2490
2492static void __devexit 2491static void
2493net2272_rdk1_remove(struct pci_dev *pdev, struct net2272 *dev) 2492net2272_rdk1_remove(struct pci_dev *pdev, struct net2272 *dev)
2494{ 2493{
2495 int i; 2494 int i;
@@ -2511,7 +2510,7 @@ net2272_rdk1_remove(struct pci_dev *pdev, struct net2272 *dev)
2511 } 2510 }
2512} 2511}
2513 2512
2514static void __devexit 2513static void
2515net2272_rdk2_remove(struct pci_dev *pdev, struct net2272 *dev) 2514net2272_rdk2_remove(struct pci_dev *pdev, struct net2272 *dev)
2516{ 2515{
2517 int i; 2516 int i;
@@ -2530,7 +2529,7 @@ net2272_rdk2_remove(struct pci_dev *pdev, struct net2272 *dev)
2530 pci_resource_len(pdev, i)); 2529 pci_resource_len(pdev, i));
2531} 2530}
2532 2531
2533static void __devexit 2532static void
2534net2272_pci_remove(struct pci_dev *pdev) 2533net2272_pci_remove(struct pci_dev *pdev)
2535{ 2534{
2536 struct net2272 *dev = pci_get_drvdata(pdev); 2535 struct net2272 *dev = pci_get_drvdata(pdev);
@@ -2549,7 +2548,7 @@ net2272_pci_remove(struct pci_dev *pdev)
2549} 2548}
2550 2549
2551/* Table of matching PCI IDs */ 2550/* Table of matching PCI IDs */
2552static struct pci_device_id __devinitdata pci_ids[] = { 2551static struct pci_device_id pci_ids[] = {
2553 { /* RDK 1 card */ 2552 { /* RDK 1 card */
2554 .class = ((PCI_CLASS_BRIDGE_OTHER << 8) | 0xfe), 2553 .class = ((PCI_CLASS_BRIDGE_OTHER << 8) | 0xfe),
2555 .class_mask = 0, 2554 .class_mask = 0,
@@ -2575,7 +2574,7 @@ static struct pci_driver net2272_pci_driver = {
2575 .id_table = pci_ids, 2574 .id_table = pci_ids,
2576 2575
2577 .probe = net2272_pci_probe, 2576 .probe = net2272_pci_probe,
2578 .remove = __devexit_p(net2272_pci_remove), 2577 .remove = net2272_pci_remove,
2579}; 2578};
2580 2579
2581static int net2272_pci_register(void) 2580static int net2272_pci_register(void)
@@ -2595,7 +2594,7 @@ static inline void net2272_pci_unregister(void) { }
2595 2594
2596/*---------------------------------------------------------------------------*/ 2595/*---------------------------------------------------------------------------*/
2597 2596
2598static int __devinit 2597static int
2599net2272_plat_probe(struct platform_device *pdev) 2598net2272_plat_probe(struct platform_device *pdev)
2600{ 2599{
2601 struct net2272 *dev; 2600 struct net2272 *dev;
@@ -2661,7 +2660,7 @@ net2272_plat_probe(struct platform_device *pdev)
2661 return ret; 2660 return ret;
2662} 2661}
2663 2662
2664static int __devexit 2663static int
2665net2272_plat_remove(struct platform_device *pdev) 2664net2272_plat_remove(struct platform_device *pdev)
2666{ 2665{
2667 struct net2272 *dev = platform_get_drvdata(pdev); 2666 struct net2272 *dev = platform_get_drvdata(pdev);
@@ -2678,7 +2677,7 @@ net2272_plat_remove(struct platform_device *pdev)
2678 2677
2679static struct platform_driver net2272_plat_driver = { 2678static struct platform_driver net2272_plat_driver = {
2680 .probe = net2272_plat_probe, 2679 .probe = net2272_plat_probe,
2681 .remove = __devexit_p(net2272_plat_remove), 2680 .remove = net2272_plat_remove,
2682 .driver = { 2681 .driver = {
2683 .name = driver_name, 2682 .name = driver_name,
2684 .owner = THIS_MODULE, 2683 .owner = THIS_MODULE,
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index ac335af154ba..708c0b55dcc8 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -9,7 +9,7 @@
9 * CODE STATUS HIGHLIGHTS 9 * CODE STATUS HIGHLIGHTS
10 * 10 *
11 * This driver should work well with most "gadget" drivers, including 11 * This driver should work well with most "gadget" drivers, including
12 * the File Storage, Serial, and Ethernet/RNDIS gadget drivers 12 * the Mass Storage, Serial, and Ethernet/RNDIS gadget drivers
13 * as well as Gadget Zero and Gadgetfs. 13 * as well as Gadget Zero and Gadgetfs.
14 * 14 *
15 * DMA is enabled by default. Drivers using transfer queues might use 15 * DMA is enabled by default. Drivers using transfer queues might use
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 2a4749c3eb3f..9412bf53b864 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -2506,7 +2506,7 @@ static inline void remove_proc_file(void) {}
2506 * UDC_SYSCON_1.CFG_LOCK is set can now work. We won't use that 2506 * UDC_SYSCON_1.CFG_LOCK is set can now work. We won't use that
2507 * capability yet though. 2507 * capability yet though.
2508 */ 2508 */
2509static unsigned __devinit 2509static unsigned
2510omap_ep_setup(char *name, u8 addr, u8 type, 2510omap_ep_setup(char *name, u8 addr, u8 type,
2511 unsigned buf, unsigned maxp, int dbuf) 2511 unsigned buf, unsigned maxp, int dbuf)
2512{ 2512{
@@ -2624,7 +2624,7 @@ static void omap_udc_release(struct device *dev)
2624 udc = NULL; 2624 udc = NULL;
2625} 2625}
2626 2626
2627static int __devinit 2627static int
2628omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv) 2628omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv)
2629{ 2629{
2630 unsigned tmp, buf; 2630 unsigned tmp, buf;
@@ -2761,7 +2761,7 @@ omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv)
2761 return 0; 2761 return 0;
2762} 2762}
2763 2763
2764static int __devinit omap_udc_probe(struct platform_device *pdev) 2764static int omap_udc_probe(struct platform_device *pdev)
2765{ 2765{
2766 int status = -ENODEV; 2766 int status = -ENODEV;
2767 int hmc; 2767 int hmc;
@@ -2974,7 +2974,7 @@ cleanup0:
2974 return status; 2974 return status;
2975} 2975}
2976 2976
2977static int __devexit omap_udc_remove(struct platform_device *pdev) 2977static int omap_udc_remove(struct platform_device *pdev)
2978{ 2978{
2979 DECLARE_COMPLETION_ONSTACK(done); 2979 DECLARE_COMPLETION_ONSTACK(done);
2980 2980
@@ -3060,7 +3060,7 @@ static int omap_udc_resume(struct platform_device *dev)
3060 3060
3061static struct platform_driver udc_driver = { 3061static struct platform_driver udc_driver = {
3062 .probe = omap_udc_probe, 3062 .probe = omap_udc_probe,
3063 .remove = __devexit_p(omap_udc_remove), 3063 .remove = omap_udc_remove,
3064 .suspend = omap_udc_suspend, 3064 .suspend = omap_udc_suspend,
3065 .resume = omap_udc_resume, 3065 .resume = omap_udc_resume,
3066 .driver = { 3066 .driver = {
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
index e156e3f26727..35bcc83d1e04 100644
--- a/drivers/usb/gadget/printer.c
+++ b/drivers/usb/gadget/printer.c
@@ -983,8 +983,10 @@ static int __init printer_func_bind(struct usb_configuration *c,
983{ 983{
984 struct printer_dev *dev = container_of(f, struct printer_dev, function); 984 struct printer_dev *dev = container_of(f, struct printer_dev, function);
985 struct usb_composite_dev *cdev = c->cdev; 985 struct usb_composite_dev *cdev = c->cdev;
986 struct usb_ep *in_ep, *out_ep; 986 struct usb_ep *in_ep;
987 struct usb_ep *out_ep = NULL;
987 int id; 988 int id;
989 int ret;
988 990
989 id = usb_interface_id(c, f); 991 id = usb_interface_id(c, f);
990 if (id < 0) 992 if (id < 0)
@@ -1010,6 +1012,11 @@ autoconf_fail:
1010 hs_ep_in_desc.bEndpointAddress = fs_ep_in_desc.bEndpointAddress; 1012 hs_ep_in_desc.bEndpointAddress = fs_ep_in_desc.bEndpointAddress;
1011 hs_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress; 1013 hs_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress;
1012 1014
1015 ret = usb_assign_descriptors(f, fs_printer_function,
1016 hs_printer_function, NULL);
1017 if (ret)
1018 return ret;
1019
1013 dev->in_ep = in_ep; 1020 dev->in_ep = in_ep;
1014 dev->out_ep = out_ep; 1021 dev->out_ep = out_ep;
1015 return 0; 1022 return 0;
@@ -1018,6 +1025,7 @@ autoconf_fail:
1018static void printer_func_unbind(struct usb_configuration *c, 1025static void printer_func_unbind(struct usb_configuration *c,
1019 struct usb_function *f) 1026 struct usb_function *f)
1020{ 1027{
1028 usb_free_all_descriptors(f);
1021} 1029}
1022 1030
1023static int printer_func_set_alt(struct usb_function *f, 1031static int printer_func_set_alt(struct usb_function *f,
@@ -1110,8 +1118,6 @@ static int __init printer_bind_config(struct usb_configuration *c)
1110 dev = &usb_printer_gadget; 1118 dev = &usb_printer_gadget;
1111 1119
1112 dev->function.name = shortname; 1120 dev->function.name = shortname;
1113 dev->function.descriptors = fs_printer_function;
1114 dev->function.hs_descriptors = hs_printer_function;
1115 dev->function.bind = printer_func_bind; 1121 dev->function.bind = printer_func_bind;
1116 dev->function.setup = printer_func_setup; 1122 dev->function.setup = printer_func_setup;
1117 dev->function.unbind = printer_func_unbind; 1123 dev->function.unbind = printer_func_unbind;
diff --git a/drivers/usb/gadget/pxa27x_udc.h b/drivers/usb/gadget/pxa27x_udc.h
index a1d268c6f2cc..79d81a4b2344 100644
--- a/drivers/usb/gadget/pxa27x_udc.h
+++ b/drivers/usb/gadget/pxa27x_udc.h
@@ -418,7 +418,7 @@ struct udc_stats {
418 * @irq: udc irq 418 * @irq: udc irq
419 * @clk: udc clock 419 * @clk: udc clock
420 * @usb_gadget: udc gadget structure 420 * @usb_gadget: udc gadget structure
421 * @driver: bound gadget (zero, g_ether, g_file_storage, ...) 421 * @driver: bound gadget (zero, g_ether, g_mass_storage, ...)
422 * @dev: device 422 * @dev: device
423 * @mach: machine info, used to activate specific GPIO 423 * @mach: machine info, used to activate specific GPIO
424 * @transceiver: external transceiver to handle vbus sense and D+ pullup 424 * @transceiver: external transceiver to handle vbus sense and D+ pullup
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 6f696ee8b817..141971d9051e 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -3072,7 +3072,7 @@ static struct usb_gadget_ops s3c_hsotg_gadget_ops = {
3072 * creation) to give to the gadget driver. Setup the endpoint name, any 3072 * creation) to give to the gadget driver. Setup the endpoint name, any
3073 * direction information and other state that may be required. 3073 * direction information and other state that may be required.
3074 */ 3074 */
3075static void __devinit s3c_hsotg_initep(struct s3c_hsotg *hsotg, 3075static void s3c_hsotg_initep(struct s3c_hsotg *hsotg,
3076 struct s3c_hsotg_ep *hs_ep, 3076 struct s3c_hsotg_ep *hs_ep,
3077 int epnum) 3077 int epnum)
3078{ 3078{
@@ -3414,7 +3414,7 @@ static const struct file_operations ep_fops = {
3414 * with the same name as the device itself, in case we end up 3414 * with the same name as the device itself, in case we end up
3415 * with multiple blocks in future systems. 3415 * with multiple blocks in future systems.
3416 */ 3416 */
3417static void __devinit s3c_hsotg_create_debug(struct s3c_hsotg *hsotg) 3417static void s3c_hsotg_create_debug(struct s3c_hsotg *hsotg)
3418{ 3418{
3419 struct dentry *root; 3419 struct dentry *root;
3420 unsigned epidx; 3420 unsigned epidx;
@@ -3460,7 +3460,7 @@ static void __devinit s3c_hsotg_create_debug(struct s3c_hsotg *hsotg)
3460 * 3460 *
3461 * Cleanup (remove) the debugfs files for use on module exit. 3461 * Cleanup (remove) the debugfs files for use on module exit.
3462 */ 3462 */
3463static void __devexit s3c_hsotg_delete_debug(struct s3c_hsotg *hsotg) 3463static void s3c_hsotg_delete_debug(struct s3c_hsotg *hsotg)
3464{ 3464{
3465 unsigned epidx; 3465 unsigned epidx;
3466 3466
@@ -3490,7 +3490,7 @@ static void s3c_hsotg_release(struct device *dev)
3490 * @pdev: The platform information for the driver 3490 * @pdev: The platform information for the driver
3491 */ 3491 */
3492 3492
3493static int __devinit s3c_hsotg_probe(struct platform_device *pdev) 3493static int s3c_hsotg_probe(struct platform_device *pdev)
3494{ 3494{
3495 struct s3c_hsotg_plat *plat = pdev->dev.platform_data; 3495 struct s3c_hsotg_plat *plat = pdev->dev.platform_data;
3496 struct device *dev = &pdev->dev; 3496 struct device *dev = &pdev->dev;
@@ -3675,7 +3675,7 @@ err_clk:
3675 * s3c_hsotg_remove - remove function for hsotg driver 3675 * s3c_hsotg_remove - remove function for hsotg driver
3676 * @pdev: The platform information for the driver 3676 * @pdev: The platform information for the driver
3677 */ 3677 */
3678static int __devexit s3c_hsotg_remove(struct platform_device *pdev) 3678static int s3c_hsotg_remove(struct platform_device *pdev)
3679{ 3679{
3680 struct s3c_hsotg *hsotg = platform_get_drvdata(pdev); 3680 struct s3c_hsotg *hsotg = platform_get_drvdata(pdev);
3681 3681
@@ -3708,7 +3708,7 @@ static struct platform_driver s3c_hsotg_driver = {
3708 .owner = THIS_MODULE, 3708 .owner = THIS_MODULE,
3709 }, 3709 },
3710 .probe = s3c_hsotg_probe, 3710 .probe = s3c_hsotg_probe,
3711 .remove = __devexit_p(s3c_hsotg_remove), 3711 .remove = s3c_hsotg_remove,
3712 .suspend = s3c_hsotg_suspend, 3712 .suspend = s3c_hsotg_suspend,
3713 .resume = s3c_hsotg_resume, 3713 .resume = s3c_hsotg_resume,
3714}; 3714};
diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c
index d8e785d4ad59..52379b11f080 100644
--- a/drivers/usb/gadget/s3c-hsudc.c
+++ b/drivers/usb/gadget/s3c-hsudc.c
@@ -1261,7 +1261,7 @@ static struct usb_gadget_ops s3c_hsudc_gadget_ops = {
1261 .vbus_draw = s3c_hsudc_vbus_draw, 1261 .vbus_draw = s3c_hsudc_vbus_draw,
1262}; 1262};
1263 1263
1264static int __devinit s3c_hsudc_probe(struct platform_device *pdev) 1264static int s3c_hsudc_probe(struct platform_device *pdev)
1265{ 1265{
1266 struct device *dev = &pdev->dev; 1266 struct device *dev = &pdev->dev;
1267 struct resource *res; 1267 struct resource *res;
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
index 8d9bcd8207c8..0e3ae43454a2 100644
--- a/drivers/usb/gadget/storage_common.c
+++ b/drivers/usb/gadget/storage_common.c
@@ -11,30 +11,10 @@
11 * (at your option) any later version. 11 * (at your option) any later version.
12 */ 12 */
13 13
14
15/* 14/*
16 * This file requires the following identifiers used in USB strings to 15 * This file requires the following identifiers used in USB strings to
17 * be defined (each of type pointer to char): 16 * be defined (each of type pointer to char):
18 * - fsg_string_manufacturer -- name of the manufacturer
19 * - fsg_string_product -- name of the product
20 * - fsg_string_config -- name of the configuration
21 * - fsg_string_interface -- name of the interface 17 * - fsg_string_interface -- name of the interface
22 * The first four are only needed when FSG_DESCRIPTORS_DEVICE_STRINGS
23 * macro is defined prior to including this file.
24 */
25
26/*
27 * When FSG_NO_INTR_EP is defined fsg_fs_intr_in_desc and
28 * fsg_hs_intr_in_desc objects as well as
29 * FSG_FS_FUNCTION_PRE_EP_ENTRIES and FSG_HS_FUNCTION_PRE_EP_ENTRIES
30 * macros are not defined.
31 *
32 * When FSG_NO_DEVICE_STRINGS is defined FSG_STRING_MANUFACTURER,
33 * FSG_STRING_PRODUCT, FSG_STRING_SERIAL and FSG_STRING_CONFIG are not
34 * defined (as well as corresponding entries in string tables are
35 * missing) and FSG_STRING_INTERFACE has value of zero.
36 *
37 * When FSG_NO_OTG is defined fsg_otg_desc won't be defined.
38 */ 18 */
39 19
40/* 20/*
@@ -78,34 +58,6 @@
78#define LWARN(lun, fmt, args...) dev_warn(&(lun)->dev, fmt, ## args) 58#define LWARN(lun, fmt, args...) dev_warn(&(lun)->dev, fmt, ## args)
79#define LINFO(lun, fmt, args...) dev_info(&(lun)->dev, fmt, ## args) 59#define LINFO(lun, fmt, args...) dev_info(&(lun)->dev, fmt, ## args)
80 60
81/*
82 * Keep those macros in sync with those in
83 * include/linux/usb/composite.h or else GCC will complain. If they
84 * are identical (the same names of arguments, white spaces in the
85 * same places) GCC will allow redefinition otherwise (even if some
86 * white space is removed or added) warning will be issued.
87 *
88 * Those macros are needed here because File Storage Gadget does not
89 * include the composite.h header. For composite gadgets those macros
90 * are redundant since composite.h is included any way.
91 *
92 * One could check whether those macros are already defined (which
93 * would indicate composite.h had been included) or not (which would
94 * indicate we were in FSG) but this is not done because a warning is
95 * desired if definitions here differ from the ones in composite.h.
96 *
97 * We want the definitions to match and be the same in File Storage
98 * Gadget as well as Mass Storage Function (and so composite gadgets
99 * using MSF). If someone changes them in composite.h it will produce
100 * a warning in this file when building MSF.
101 */
102#define DBG(d, fmt, args...) dev_dbg(&(d)->gadget->dev , fmt , ## args)
103#define VDBG(d, fmt, args...) dev_vdbg(&(d)->gadget->dev , fmt , ## args)
104#define ERROR(d, fmt, args...) dev_err(&(d)->gadget->dev , fmt , ## args)
105#define WARNING(d, fmt, args...) dev_warn(&(d)->gadget->dev , fmt , ## args)
106#define INFO(d, fmt, args...) dev_info(&(d)->gadget->dev , fmt , ## args)
107
108
109 61
110#ifdef DUMP_MSGS 62#ifdef DUMP_MSGS
111 63
@@ -203,9 +155,12 @@ struct fsg_lun {
203 struct device dev; 155 struct device dev;
204}; 156};
205 157
206#define fsg_lun_is_open(curlun) ((curlun)->filp != NULL) 158static inline bool fsg_lun_is_open(struct fsg_lun *curlun)
159{
160 return curlun->filp != NULL;
161}
207 162
208static struct fsg_lun *fsg_lun_from_dev(struct device *dev) 163static inline struct fsg_lun *fsg_lun_from_dev(struct device *dev)
209{ 164{
210 return container_of(dev, struct fsg_lun, dev); 165 return container_of(dev, struct fsg_lun, dev);
211} 166}
@@ -308,26 +263,10 @@ static inline u32 get_unaligned_be24(u8 *buf)
308 263
309 264
310enum { 265enum {
311#ifndef FSG_NO_DEVICE_STRINGS
312 FSG_STRING_MANUFACTURER = 1,
313 FSG_STRING_PRODUCT,
314 FSG_STRING_SERIAL,
315 FSG_STRING_CONFIG,
316#endif
317 FSG_STRING_INTERFACE 266 FSG_STRING_INTERFACE
318}; 267};
319 268
320 269
321#ifndef FSG_NO_OTG
322static struct usb_otg_descriptor
323fsg_otg_desc = {
324 .bLength = sizeof fsg_otg_desc,
325 .bDescriptorType = USB_DT_OTG,
326
327 .bmAttributes = USB_OTG_SRP,
328};
329#endif
330
331/* There is only one interface. */ 270/* There is only one interface. */
332 271
333static struct usb_interface_descriptor 272static struct usb_interface_descriptor
@@ -367,37 +306,10 @@ fsg_fs_bulk_out_desc = {
367 /* wMaxPacketSize set by autoconfiguration */ 306 /* wMaxPacketSize set by autoconfiguration */
368}; 307};
369 308
370#ifndef FSG_NO_INTR_EP
371
372static struct usb_endpoint_descriptor
373fsg_fs_intr_in_desc = {
374 .bLength = USB_DT_ENDPOINT_SIZE,
375 .bDescriptorType = USB_DT_ENDPOINT,
376
377 .bEndpointAddress = USB_DIR_IN,
378 .bmAttributes = USB_ENDPOINT_XFER_INT,
379 .wMaxPacketSize = cpu_to_le16(2),
380 .bInterval = 32, /* frames -> 32 ms */
381};
382
383#ifndef FSG_NO_OTG
384# define FSG_FS_FUNCTION_PRE_EP_ENTRIES 2
385#else
386# define FSG_FS_FUNCTION_PRE_EP_ENTRIES 1
387#endif
388
389#endif
390
391static struct usb_descriptor_header *fsg_fs_function[] = { 309static struct usb_descriptor_header *fsg_fs_function[] = {
392#ifndef FSG_NO_OTG
393 (struct usb_descriptor_header *) &fsg_otg_desc,
394#endif
395 (struct usb_descriptor_header *) &fsg_intf_desc, 310 (struct usb_descriptor_header *) &fsg_intf_desc,
396 (struct usb_descriptor_header *) &fsg_fs_bulk_in_desc, 311 (struct usb_descriptor_header *) &fsg_fs_bulk_in_desc,
397 (struct usb_descriptor_header *) &fsg_fs_bulk_out_desc, 312 (struct usb_descriptor_header *) &fsg_fs_bulk_out_desc,
398#ifndef FSG_NO_INTR_EP
399 (struct usb_descriptor_header *) &fsg_fs_intr_in_desc,
400#endif
401 NULL, 313 NULL,
402}; 314};
403 315
@@ -431,37 +343,11 @@ fsg_hs_bulk_out_desc = {
431 .bInterval = 1, /* NAK every 1 uframe */ 343 .bInterval = 1, /* NAK every 1 uframe */
432}; 344};
433 345
434#ifndef FSG_NO_INTR_EP
435
436static struct usb_endpoint_descriptor
437fsg_hs_intr_in_desc = {
438 .bLength = USB_DT_ENDPOINT_SIZE,
439 .bDescriptorType = USB_DT_ENDPOINT,
440
441 /* bEndpointAddress copied from fs_intr_in_desc during fsg_bind() */
442 .bmAttributes = USB_ENDPOINT_XFER_INT,
443 .wMaxPacketSize = cpu_to_le16(2),
444 .bInterval = 9, /* 2**(9-1) = 256 uframes -> 32 ms */
445};
446
447#ifndef FSG_NO_OTG
448# define FSG_HS_FUNCTION_PRE_EP_ENTRIES 2
449#else
450# define FSG_HS_FUNCTION_PRE_EP_ENTRIES 1
451#endif
452
453#endif
454 346
455static struct usb_descriptor_header *fsg_hs_function[] = { 347static struct usb_descriptor_header *fsg_hs_function[] = {
456#ifndef FSG_NO_OTG
457 (struct usb_descriptor_header *) &fsg_otg_desc,
458#endif
459 (struct usb_descriptor_header *) &fsg_intf_desc, 348 (struct usb_descriptor_header *) &fsg_intf_desc,
460 (struct usb_descriptor_header *) &fsg_hs_bulk_in_desc, 349 (struct usb_descriptor_header *) &fsg_hs_bulk_in_desc,
461 (struct usb_descriptor_header *) &fsg_hs_bulk_out_desc, 350 (struct usb_descriptor_header *) &fsg_hs_bulk_out_desc,
462#ifndef FSG_NO_INTR_EP
463 (struct usb_descriptor_header *) &fsg_hs_intr_in_desc,
464#endif
465 NULL, 351 NULL,
466}; 352};
467 353
@@ -499,34 +385,6 @@ static struct usb_ss_ep_comp_descriptor fsg_ss_bulk_out_comp_desc = {
499 /*.bMaxBurst = DYNAMIC, */ 385 /*.bMaxBurst = DYNAMIC, */
500}; 386};
501 387
502#ifndef FSG_NO_INTR_EP
503
504static struct usb_endpoint_descriptor
505fsg_ss_intr_in_desc = {
506 .bLength = USB_DT_ENDPOINT_SIZE,
507 .bDescriptorType = USB_DT_ENDPOINT,
508
509 /* bEndpointAddress copied from fs_intr_in_desc during fsg_bind() */
510 .bmAttributes = USB_ENDPOINT_XFER_INT,
511 .wMaxPacketSize = cpu_to_le16(2),
512 .bInterval = 9, /* 2**(9-1) = 256 uframes -> 32 ms */
513};
514
515static struct usb_ss_ep_comp_descriptor fsg_ss_intr_in_comp_desc = {
516 .bLength = sizeof(fsg_ss_bulk_in_comp_desc),
517 .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
518
519 .wBytesPerInterval = cpu_to_le16(2),
520};
521
522#ifndef FSG_NO_OTG
523# define FSG_SS_FUNCTION_PRE_EP_ENTRIES 2
524#else
525# define FSG_SS_FUNCTION_PRE_EP_ENTRIES 1
526#endif
527
528#endif
529
530static __maybe_unused struct usb_ext_cap_descriptor fsg_ext_cap_desc = { 388static __maybe_unused struct usb_ext_cap_descriptor fsg_ext_cap_desc = {
531 .bLength = USB_DT_USB_EXT_CAP_SIZE, 389 .bLength = USB_DT_USB_EXT_CAP_SIZE,
532 .bDescriptorType = USB_DT_DEVICE_CAPABILITY, 390 .bDescriptorType = USB_DT_DEVICE_CAPABILITY,
@@ -563,18 +421,11 @@ static __maybe_unused struct usb_bos_descriptor fsg_bos_desc = {
563}; 421};
564 422
565static struct usb_descriptor_header *fsg_ss_function[] = { 423static struct usb_descriptor_header *fsg_ss_function[] = {
566#ifndef FSG_NO_OTG
567 (struct usb_descriptor_header *) &fsg_otg_desc,
568#endif
569 (struct usb_descriptor_header *) &fsg_intf_desc, 424 (struct usb_descriptor_header *) &fsg_intf_desc,
570 (struct usb_descriptor_header *) &fsg_ss_bulk_in_desc, 425 (struct usb_descriptor_header *) &fsg_ss_bulk_in_desc,
571 (struct usb_descriptor_header *) &fsg_ss_bulk_in_comp_desc, 426 (struct usb_descriptor_header *) &fsg_ss_bulk_in_comp_desc,
572 (struct usb_descriptor_header *) &fsg_ss_bulk_out_desc, 427 (struct usb_descriptor_header *) &fsg_ss_bulk_out_desc,
573 (struct usb_descriptor_header *) &fsg_ss_bulk_out_comp_desc, 428 (struct usb_descriptor_header *) &fsg_ss_bulk_out_comp_desc,
574#ifndef FSG_NO_INTR_EP
575 (struct usb_descriptor_header *) &fsg_ss_intr_in_desc,
576 (struct usb_descriptor_header *) &fsg_ss_intr_in_comp_desc,
577#endif
578 NULL, 429 NULL,
579}; 430};
580 431
@@ -594,12 +445,6 @@ fsg_ep_desc(struct usb_gadget *g, struct usb_endpoint_descriptor *fs,
594 445
595/* Static strings, in UTF-8 (for simplicity we use only ASCII characters) */ 446/* Static strings, in UTF-8 (for simplicity we use only ASCII characters) */
596static struct usb_string fsg_strings[] = { 447static struct usb_string fsg_strings[] = {
597#ifndef FSG_NO_DEVICE_STRINGS
598 {FSG_STRING_MANUFACTURER, fsg_string_manufacturer},
599 {FSG_STRING_PRODUCT, fsg_string_product},
600 {FSG_STRING_SERIAL, ""},
601 {FSG_STRING_CONFIG, fsg_string_config},
602#endif
603 {FSG_STRING_INTERFACE, fsg_string_interface}, 448 {FSG_STRING_INTERFACE, fsg_string_interface},
604 {} 449 {}
605}; 450};
diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c
index 97e68b38cfdf..4f7f76f00c74 100644
--- a/drivers/usb/gadget/tcm_usb_gadget.c
+++ b/drivers/usb/gadget/tcm_usb_gadget.c
@@ -1384,7 +1384,7 @@ static struct se_node_acl *usbg_alloc_fabric_acl(struct se_portal_group *se_tpg)
1384 1384
1385 nacl = kzalloc(sizeof(struct usbg_nacl), GFP_KERNEL); 1385 nacl = kzalloc(sizeof(struct usbg_nacl), GFP_KERNEL);
1386 if (!nacl) { 1386 if (!nacl) {
1387 printk(KERN_ERR "Unable to alocate struct usbg_nacl\n"); 1387 printk(KERN_ERR "Unable to allocate struct usbg_nacl\n");
1388 return NULL; 1388 return NULL;
1389 } 1389 }
1390 1390
@@ -2139,6 +2139,7 @@ static struct usb_descriptor_header *uasp_fs_function_desc[] = {
2139 (struct usb_descriptor_header *) &uasp_status_pipe_desc, 2139 (struct usb_descriptor_header *) &uasp_status_pipe_desc,
2140 (struct usb_descriptor_header *) &uasp_fs_cmd_desc, 2140 (struct usb_descriptor_header *) &uasp_fs_cmd_desc,
2141 (struct usb_descriptor_header *) &uasp_cmd_pipe_desc, 2141 (struct usb_descriptor_header *) &uasp_cmd_pipe_desc,
2142 NULL,
2142}; 2143};
2143 2144
2144static struct usb_descriptor_header *uasp_hs_function_desc[] = { 2145static struct usb_descriptor_header *uasp_hs_function_desc[] = {
@@ -2239,6 +2240,7 @@ static int usbg_bind(struct usb_configuration *c, struct usb_function *f)
2239 struct usb_gadget *gadget = c->cdev->gadget; 2240 struct usb_gadget *gadget = c->cdev->gadget;
2240 struct usb_ep *ep; 2241 struct usb_ep *ep;
2241 int iface; 2242 int iface;
2243 int ret;
2242 2244
2243 iface = usb_interface_id(c, f); 2245 iface = usb_interface_id(c, f);
2244 if (iface < 0) 2246 if (iface < 0)
@@ -2289,6 +2291,11 @@ static int usbg_bind(struct usb_configuration *c, struct usb_function *f)
2289 uasp_ss_status_desc.bEndpointAddress; 2291 uasp_ss_status_desc.bEndpointAddress;
2290 uasp_fs_cmd_desc.bEndpointAddress = uasp_ss_cmd_desc.bEndpointAddress; 2292 uasp_fs_cmd_desc.bEndpointAddress = uasp_ss_cmd_desc.bEndpointAddress;
2291 2293
2294 ret = usb_assign_descriptors(f, uasp_fs_function_desc,
2295 uasp_hs_function_desc, uasp_ss_function_desc);
2296 if (ret)
2297 goto ep_fail;
2298
2292 return 0; 2299 return 0;
2293ep_fail: 2300ep_fail:
2294 pr_err("Can't claim all required eps\n"); 2301 pr_err("Can't claim all required eps\n");
@@ -2304,6 +2311,7 @@ static void usbg_unbind(struct usb_configuration *c, struct usb_function *f)
2304{ 2311{
2305 struct f_uas *fu = to_f_uas(f); 2312 struct f_uas *fu = to_f_uas(f);
2306 2313
2314 usb_free_all_descriptors(f);
2307 kfree(fu); 2315 kfree(fu);
2308} 2316}
2309 2317
@@ -2384,9 +2392,6 @@ static int usbg_cfg_bind(struct usb_configuration *c)
2384 if (!fu) 2392 if (!fu)
2385 return -ENOMEM; 2393 return -ENOMEM;
2386 fu->function.name = "Target Function"; 2394 fu->function.name = "Target Function";
2387 fu->function.descriptors = uasp_fs_function_desc;
2388 fu->function.hs_descriptors = uasp_hs_function_desc;
2389 fu->function.ss_descriptors = uasp_ss_function_desc;
2390 fu->function.bind = usbg_bind; 2395 fu->function.bind = usbg_bind;
2391 fu->function.unbind = usbg_unbind; 2396 fu->function.unbind = usbg_unbind;
2392 fu->function.set_alt = usbg_set_alt; 2397 fu->function.set_alt = usbg_set_alt;
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
index f3cd9690b101..4d90a800063c 100644
--- a/drivers/usb/gadget/udc-core.c
+++ b/drivers/usb/gadget/udc-core.c
@@ -439,16 +439,6 @@ static DEVICE_ATTR(name, S_IRUSR, usb_udc_##param##_show, NULL)
439static USB_UDC_SPEED_ATTR(current_speed, speed); 439static USB_UDC_SPEED_ATTR(current_speed, speed);
440static USB_UDC_SPEED_ATTR(maximum_speed, max_speed); 440static USB_UDC_SPEED_ATTR(maximum_speed, max_speed);
441 441
442/* TODO: Scheduled for removal in 3.8. */
443static ssize_t usb_udc_is_dualspeed_show(struct device *dev,
444 struct device_attribute *attr, char *buf)
445{
446 struct usb_udc *udc = container_of(dev, struct usb_udc, dev);
447 return snprintf(buf, PAGE_SIZE, "%d\n",
448 gadget_is_dualspeed(udc->gadget));
449}
450static DEVICE_ATTR(is_dualspeed, S_IRUSR, usb_udc_is_dualspeed_show, NULL);
451
452#define USB_UDC_ATTR(name) \ 442#define USB_UDC_ATTR(name) \
453ssize_t usb_udc_##name##_show(struct device *dev, \ 443ssize_t usb_udc_##name##_show(struct device *dev, \
454 struct device_attribute *attr, char *buf) \ 444 struct device_attribute *attr, char *buf) \
@@ -472,7 +462,6 @@ static struct attribute *usb_udc_attrs[] = {
472 &dev_attr_current_speed.attr, 462 &dev_attr_current_speed.attr,
473 &dev_attr_maximum_speed.attr, 463 &dev_attr_maximum_speed.attr,
474 464
475 &dev_attr_is_dualspeed.attr,
476 &dev_attr_is_otg.attr, 465 &dev_attr_is_otg.attr,
477 &dev_attr_is_a_peripheral.attr, 466 &dev_attr_is_a_peripheral.attr,
478 &dev_attr_b_hnp_enable.attr, 467 &dev_attr_b_hnp_enable.attr,
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 3f1431d37e1c..d6bb128ce21e 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -95,6 +95,11 @@ config USB_EHCI_TT_NEWSCHED
95 95
96 If unsure, say Y. 96 If unsure, say Y.
97 97
98config USB_EHCI_PCI
99 tristate
100 depends on USB_EHCI_HCD && PCI
101 default y
102
98config USB_EHCI_HCD_PMC_MSP 103config USB_EHCI_HCD_PMC_MSP
99 tristate "EHCI support for on-chip PMC MSP71xx USB controller" 104 tristate "EHCI support for on-chip PMC MSP71xx USB controller"
100 depends on USB_EHCI_HCD && MSP_HAS_USB 105 depends on USB_EHCI_HCD && MSP_HAS_USB
@@ -215,9 +220,13 @@ config USB_W90X900_EHCI
215 Enables support for the W90X900 USB controller 220 Enables support for the W90X900 USB controller
216 221
217config USB_CNS3XXX_EHCI 222config USB_CNS3XXX_EHCI
218 bool "Cavium CNS3XXX EHCI Module" 223 bool "Cavium CNS3XXX EHCI Module (DEPRECATED)"
219 depends on USB_EHCI_HCD && ARCH_CNS3XXX 224 depends on USB_EHCI_HCD && ARCH_CNS3XXX
225 select USB_EHCI_HCD_PLATFORM
220 ---help--- 226 ---help---
227 This option is deprecated now and the driver was removed, use
228 USB_EHCI_HCD_PLATFORM instead.
229
221 Enable support for the CNS3XXX SOC's on-chip EHCI controller. 230 Enable support for the CNS3XXX SOC's on-chip EHCI controller.
222 It is needed for high-speed (480Mbit/sec) USB 2.0 device 231 It is needed for high-speed (480Mbit/sec) USB 2.0 device
223 support. 232 support.
@@ -333,16 +342,6 @@ config USB_OHCI_ATH79
333 Enables support for the built-in OHCI controller present on the 342 Enables support for the built-in OHCI controller present on the
334 Atheros AR71XX/AR7240 SoCs. 343 Atheros AR71XX/AR7240 SoCs.
335 344
336config USB_OHCI_HCD_PPC_SOC
337 bool "OHCI support for on-chip PPC USB controller"
338 depends on USB_OHCI_HCD && (STB03xxx || PPC_MPC52xx)
339 default y
340 select USB_OHCI_BIG_ENDIAN_DESC
341 select USB_OHCI_BIG_ENDIAN_MMIO
342 ---help---
343 Enables support for the USB controller on the MPC52xx or
344 STB03xxx processor chip. If unsure, say Y.
345
346config USB_OHCI_HCD_PPC_OF_BE 345config USB_OHCI_HCD_PPC_OF_BE
347 bool "OHCI support for OF platform bus (big endian)" 346 bool "OHCI support for OF platform bus (big endian)"
348 depends on USB_OHCI_HCD && PPC_OF 347 depends on USB_OHCI_HCD && PPC_OF
@@ -393,9 +392,13 @@ config USB_OHCI_HCD_SSB
393 If unsure, say N. 392 If unsure, say N.
394 393
395config USB_OHCI_SH 394config USB_OHCI_SH
396 bool "OHCI support for SuperH USB controller" 395 bool "OHCI support for SuperH USB controller (DEPRECATED)"
397 depends on USB_OHCI_HCD && SUPERH 396 depends on USB_OHCI_HCD && SUPERH
397 select USB_OHCI_HCD_PLATFORM
398 ---help--- 398 ---help---
399 This option is deprecated now and the driver was removed, use
400 USB_OHCI_HCD_PLATFORM instead.
401
399 Enables support for the on-chip OHCI controller on the SuperH. 402 Enables support for the on-chip OHCI controller on the SuperH.
400 If you use the PCI OHCI controller, this option is not necessary. 403 If you use the PCI OHCI controller, this option is not necessary.
401 404
@@ -406,9 +409,13 @@ config USB_OHCI_EXYNOS
406 Enable support for the Samsung Exynos SOC's on-chip OHCI controller. 409 Enable support for the Samsung Exynos SOC's on-chip OHCI controller.
407 410
408config USB_CNS3XXX_OHCI 411config USB_CNS3XXX_OHCI
409 bool "Cavium CNS3XXX OHCI Module" 412 bool "Cavium CNS3XXX OHCI Module (DEPRECATED)"
410 depends on USB_OHCI_HCD && ARCH_CNS3XXX 413 depends on USB_OHCI_HCD && ARCH_CNS3XXX
414 select USB_OHCI_HCD_PLATFORM
411 ---help--- 415 ---help---
416 This option is deprecated now and the driver was removed, use
417 USB_OHCI_HCD_PLATFORM instead.
418
412 Enable support for the CNS3XXX SOC's on-chip OHCI controller. 419 Enable support for the CNS3XXX SOC's on-chip OHCI controller.
413 It is needed for low-speed USB 1.0 device support. 420 It is needed for low-speed USB 1.0 device support.
414 421
@@ -423,7 +430,7 @@ config USB_OHCI_HCD_PLATFORM
423 If unsure, say N. 430 If unsure, say N.
424 431
425config USB_EHCI_HCD_PLATFORM 432config USB_EHCI_HCD_PLATFORM
426 bool "Generic EHCI driver for a platform device" 433 tristate "Generic EHCI driver for a platform device"
427 depends on USB_EHCI_HCD 434 depends on USB_EHCI_HCD
428 default n 435 default n
429 ---help--- 436 ---help---
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 9e0a89ced15c..1eb4c3006e9e 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -24,6 +24,9 @@ obj-$(CONFIG_USB_WHCI_HCD) += whci/
24obj-$(CONFIG_PCI) += pci-quirks.o 24obj-$(CONFIG_PCI) += pci-quirks.o
25 25
26obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o 26obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o
27obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o
28obj-$(CONFIG_USB_EHCI_HCD_PLATFORM) += ehci-platform.o
29
27obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o 30obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
28obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o 31obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o
29obj-$(CONFIG_USB_ISP1362_HCD) += isp1362-hcd.o 32obj-$(CONFIG_USB_ISP1362_HCD) += isp1362-hcd.o
@@ -40,6 +43,5 @@ obj-$(CONFIG_USB_HWA_HCD) += hwa-hc.o
40obj-$(CONFIG_USB_IMX21_HCD) += imx21-hcd.o 43obj-$(CONFIG_USB_IMX21_HCD) += imx21-hcd.o
41obj-$(CONFIG_USB_FSL_MPH_DR_OF) += fsl-mph-dr-of.o 44obj-$(CONFIG_USB_FSL_MPH_DR_OF) += fsl-mph-dr-of.o
42obj-$(CONFIG_USB_OCTEON2_COMMON) += octeon2-common.o 45obj-$(CONFIG_USB_OCTEON2_COMMON) += octeon2-common.o
43obj-$(CONFIG_MIPS_ALCHEMY) += alchemy-common.o
44obj-$(CONFIG_USB_HCD_BCMA) += bcma-hcd.o 46obj-$(CONFIG_USB_HCD_BCMA) += bcma-hcd.o
45obj-$(CONFIG_USB_HCD_SSB) += ssb-hcd.o 47obj-$(CONFIG_USB_HCD_SSB) += ssb-hcd.o
diff --git a/drivers/usb/host/bcma-hcd.c b/drivers/usb/host/bcma-hcd.c
index 443da21d73ca..df13d425e9c5 100644
--- a/drivers/usb/host/bcma-hcd.c
+++ b/drivers/usb/host/bcma-hcd.c
@@ -54,7 +54,7 @@ static int bcma_wait_bits(struct bcma_device *dev, u16 reg, u32 bitmask,
54 return -ETIMEDOUT; 54 return -ETIMEDOUT;
55} 55}
56 56
57static void __devinit bcma_hcd_4716wa(struct bcma_device *dev) 57static void bcma_hcd_4716wa(struct bcma_device *dev)
58{ 58{
59#ifdef CONFIG_BCMA_DRIVER_MIPS 59#ifdef CONFIG_BCMA_DRIVER_MIPS
60 /* Work around for 4716 failures. */ 60 /* Work around for 4716 failures. */
@@ -88,7 +88,7 @@ static void __devinit bcma_hcd_4716wa(struct bcma_device *dev)
88} 88}
89 89
90/* based on arch/mips/brcm-boards/bcm947xx/pcibios.c */ 90/* based on arch/mips/brcm-boards/bcm947xx/pcibios.c */
91static void __devinit bcma_hcd_init_chip(struct bcma_device *dev) 91static void bcma_hcd_init_chip(struct bcma_device *dev)
92{ 92{
93 u32 tmp; 93 u32 tmp;
94 94
@@ -165,8 +165,7 @@ static const struct usb_ehci_pdata ehci_pdata = {
165static const struct usb_ohci_pdata ohci_pdata = { 165static const struct usb_ohci_pdata ohci_pdata = {
166}; 166};
167 167
168static struct platform_device * __devinit 168static struct platform_device *bcma_hcd_create_pdev(struct bcma_device *dev, bool ohci, u32 addr)
169bcma_hcd_create_pdev(struct bcma_device *dev, bool ohci, u32 addr)
170{ 169{
171 struct platform_device *hci_dev; 170 struct platform_device *hci_dev;
172 struct resource hci_res[2]; 171 struct resource hci_res[2];
@@ -212,7 +211,7 @@ err_alloc:
212 return ERR_PTR(ret); 211 return ERR_PTR(ret);
213} 212}
214 213
215static int __devinit bcma_hcd_probe(struct bcma_device *dev) 214static int bcma_hcd_probe(struct bcma_device *dev)
216{ 215{
217 int err; 216 int err;
218 u16 chipid_top; 217 u16 chipid_top;
@@ -266,7 +265,7 @@ err_free_usb_dev:
266 return err; 265 return err;
267} 266}
268 267
269static void __devexit bcma_hcd_remove(struct bcma_device *dev) 268static void bcma_hcd_remove(struct bcma_device *dev)
270{ 269{
271 struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev); 270 struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev);
272 struct platform_device *ohci_dev = usb_dev->ohci_dev; 271 struct platform_device *ohci_dev = usb_dev->ohci_dev;
@@ -306,7 +305,7 @@ static int bcma_hcd_resume(struct bcma_device *dev)
306#define bcma_hcd_resume NULL 305#define bcma_hcd_resume NULL
307#endif /* CONFIG_PM */ 306#endif /* CONFIG_PM */
308 307
309static const struct bcma_device_id bcma_hcd_table[] __devinitconst = { 308static const struct bcma_device_id bcma_hcd_table[] = {
310 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_USB20_HOST, BCMA_ANY_REV, BCMA_ANY_CLASS), 309 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_USB20_HOST, BCMA_ANY_REV, BCMA_ANY_CLASS),
311 BCMA_CORETABLE_END 310 BCMA_CORETABLE_END
312}; 311};
@@ -316,7 +315,7 @@ static struct bcma_driver bcma_hcd_driver = {
316 .name = KBUILD_MODNAME, 315 .name = KBUILD_MODNAME,
317 .id_table = bcma_hcd_table, 316 .id_table = bcma_hcd_table,
318 .probe = bcma_hcd_probe, 317 .probe = bcma_hcd_probe,
319 .remove = __devexit_p(bcma_hcd_remove), 318 .remove = bcma_hcd_remove,
320 .shutdown = bcma_hcd_shutdown, 319 .shutdown = bcma_hcd_shutdown,
321 .suspend = bcma_hcd_suspend, 320 .suspend = bcma_hcd_suspend,
322 .resume = bcma_hcd_resume, 321 .resume = bcma_hcd_resume,
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 411bb74152eb..27639487f7ac 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -53,18 +53,11 @@ static void atmel_stop_ehci(struct platform_device *pdev)
53static int ehci_atmel_setup(struct usb_hcd *hcd) 53static int ehci_atmel_setup(struct usb_hcd *hcd)
54{ 54{
55 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 55 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
56 int retval;
57 56
58 /* registers start at offset 0x0 */ 57 /* registers start at offset 0x0 */
59 ehci->caps = hcd->regs; 58 ehci->caps = hcd->regs;
60 59
61 retval = ehci_setup(hcd); 60 return ehci_setup(hcd);
62 if (retval)
63 return retval;
64
65 ehci_port_power(ehci, 0);
66
67 return retval;
68} 61}
69 62
70static const struct hc_driver ehci_atmel_hc_driver = { 63static const struct hc_driver ehci_atmel_hc_driver = {
@@ -104,7 +97,7 @@ static const struct hc_driver ehci_atmel_hc_driver = {
104 97
105static u64 at91_ehci_dma_mask = DMA_BIT_MASK(32); 98static u64 at91_ehci_dma_mask = DMA_BIT_MASK(32);
106 99
107static int __devinit ehci_atmel_drv_probe(struct platform_device *pdev) 100static int ehci_atmel_drv_probe(struct platform_device *pdev)
108{ 101{
109 struct usb_hcd *hcd; 102 struct usb_hcd *hcd;
110 const struct hc_driver *driver = &ehci_atmel_hc_driver; 103 const struct hc_driver *driver = &ehci_atmel_hc_driver;
@@ -189,7 +182,7 @@ fail_create_hcd:
189 return retval; 182 return retval;
190} 183}
191 184
192static int __devexit ehci_atmel_drv_remove(struct platform_device *pdev) 185static int ehci_atmel_drv_remove(struct platform_device *pdev)
193{ 186{
194 struct usb_hcd *hcd = platform_get_drvdata(pdev); 187 struct usb_hcd *hcd = platform_get_drvdata(pdev);
195 188
@@ -214,7 +207,7 @@ MODULE_DEVICE_TABLE(of, atmel_ehci_dt_ids);
214 207
215static struct platform_driver ehci_atmel_driver = { 208static struct platform_driver ehci_atmel_driver = {
216 .probe = ehci_atmel_drv_probe, 209 .probe = ehci_atmel_drv_probe,
217 .remove = __devexit_p(ehci_atmel_drv_remove), 210 .remove = ehci_atmel_drv_remove,
218 .shutdown = usb_hcd_platform_shutdown, 211 .shutdown = usb_hcd_platform_shutdown,
219 .driver = { 212 .driver = {
220 .name = "atmel-ehci", 213 .name = "atmel-ehci",
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c
deleted file mode 100644
index 65c945eb4144..000000000000
--- a/drivers/usb/host/ehci-au1xxx.c
+++ /dev/null
@@ -1,184 +0,0 @@
1/*
2 * EHCI HCD (Host Controller Driver) for USB.
3 *
4 * Bus Glue for AMD Alchemy Au1xxx
5 *
6 * Based on "ohci-au1xxx.c" by Matt Porter <mporter@kernel.crashing.org>
7 *
8 * Modified for AMD Alchemy Au1200 EHC
9 * by K.Boge <karsten.boge@amd.com>
10 *
11 * This file is licenced under the GPL.
12 */
13
14#include <linux/platform_device.h>
15#include <asm/mach-au1x00/au1000.h>
16
17
18extern int usb_disabled(void);
19
20static int au1xxx_ehci_setup(struct usb_hcd *hcd)
21{
22 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
23 int ret;
24
25 ehci->caps = hcd->regs;
26 ret = ehci_setup(hcd);
27
28 ehci->need_io_watchdog = 0;
29 return ret;
30}
31
32static const struct hc_driver ehci_au1xxx_hc_driver = {
33 .description = hcd_name,
34 .product_desc = "Au1xxx EHCI",
35 .hcd_priv_size = sizeof(struct ehci_hcd),
36
37 /*
38 * generic hardware linkage
39 */
40 .irq = ehci_irq,
41 .flags = HCD_MEMORY | HCD_USB2,
42
43 /*
44 * basic lifecycle operations
45 *
46 * FIXME -- ehci_init() doesn't do enough here.
47 * See ehci-ppc-soc for a complete implementation.
48 */
49 .reset = au1xxx_ehci_setup,
50 .start = ehci_run,
51 .stop = ehci_stop,
52 .shutdown = ehci_shutdown,
53
54 /*
55 * managing i/o requests and associated device resources
56 */
57 .urb_enqueue = ehci_urb_enqueue,
58 .urb_dequeue = ehci_urb_dequeue,
59 .endpoint_disable = ehci_endpoint_disable,
60 .endpoint_reset = ehci_endpoint_reset,
61
62 /*
63 * scheduling support
64 */
65 .get_frame_number = ehci_get_frame,
66
67 /*
68 * root hub support
69 */
70 .hub_status_data = ehci_hub_status_data,
71 .hub_control = ehci_hub_control,
72 .bus_suspend = ehci_bus_suspend,
73 .bus_resume = ehci_bus_resume,
74 .relinquish_port = ehci_relinquish_port,
75 .port_handed_over = ehci_port_handed_over,
76
77 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
78};
79
80static int ehci_hcd_au1xxx_drv_probe(struct platform_device *pdev)
81{
82 struct usb_hcd *hcd;
83 struct resource *res;
84 int ret;
85
86 if (usb_disabled())
87 return -ENODEV;
88
89 if (pdev->resource[1].flags != IORESOURCE_IRQ) {
90 pr_debug("resource[1] is not IORESOURCE_IRQ");
91 return -ENOMEM;
92 }
93 hcd = usb_create_hcd(&ehci_au1xxx_hc_driver, &pdev->dev, "Au1xxx");
94 if (!hcd)
95 return -ENOMEM;
96
97 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
98 hcd->rsrc_start = res->start;
99 hcd->rsrc_len = resource_size(res);
100
101 hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
102 if (!hcd->regs) {
103 pr_debug("devm_request_and_ioremap failed");
104 ret = -ENOMEM;
105 goto err1;
106 }
107
108 if (alchemy_usb_control(ALCHEMY_USB_EHCI0, 1)) {
109 printk(KERN_INFO "%s: controller init failed!\n", pdev->name);
110 ret = -ENODEV;
111 goto err1;
112 }
113
114 ret = usb_add_hcd(hcd, pdev->resource[1].start,
115 IRQF_SHARED);
116 if (ret == 0) {
117 platform_set_drvdata(pdev, hcd);
118 return ret;
119 }
120
121 alchemy_usb_control(ALCHEMY_USB_EHCI0, 0);
122err1:
123 usb_put_hcd(hcd);
124 return ret;
125}
126
127static int ehci_hcd_au1xxx_drv_remove(struct platform_device *pdev)
128{
129 struct usb_hcd *hcd = platform_get_drvdata(pdev);
130
131 usb_remove_hcd(hcd);
132 alchemy_usb_control(ALCHEMY_USB_EHCI0, 0);
133 usb_put_hcd(hcd);
134 platform_set_drvdata(pdev, NULL);
135
136 return 0;
137}
138
139#ifdef CONFIG_PM
140static int ehci_hcd_au1xxx_drv_suspend(struct device *dev)
141{
142 struct usb_hcd *hcd = dev_get_drvdata(dev);
143 bool do_wakeup = device_may_wakeup(dev);
144 int rc;
145
146 rc = ehci_suspend(hcd, do_wakeup);
147 alchemy_usb_control(ALCHEMY_USB_EHCI0, 0);
148
149 return rc;
150}
151
152static int ehci_hcd_au1xxx_drv_resume(struct device *dev)
153{
154 struct usb_hcd *hcd = dev_get_drvdata(dev);
155
156 alchemy_usb_control(ALCHEMY_USB_EHCI0, 1);
157 ehci_resume(hcd, false);
158
159 return 0;
160}
161
162static const struct dev_pm_ops au1xxx_ehci_pmops = {
163 .suspend = ehci_hcd_au1xxx_drv_suspend,
164 .resume = ehci_hcd_au1xxx_drv_resume,
165};
166
167#define AU1XXX_EHCI_PMOPS &au1xxx_ehci_pmops
168
169#else
170#define AU1XXX_EHCI_PMOPS NULL
171#endif
172
173static struct platform_driver ehci_hcd_au1xxx_driver = {
174 .probe = ehci_hcd_au1xxx_drv_probe,
175 .remove = ehci_hcd_au1xxx_drv_remove,
176 .shutdown = usb_hcd_platform_shutdown,
177 .driver = {
178 .name = "au1xxx-ehci",
179 .owner = THIS_MODULE,
180 .pm = AU1XXX_EHCI_PMOPS,
181 }
182};
183
184MODULE_ALIAS("platform:au1xxx-ehci");
diff --git a/drivers/usb/host/ehci-cns3xxx.c b/drivers/usb/host/ehci-cns3xxx.c
deleted file mode 100644
index d91708d2e729..000000000000
--- a/drivers/usb/host/ehci-cns3xxx.c
+++ /dev/null
@@ -1,155 +0,0 @@
1/*
2 * Copyright 2008 Cavium Networks
3 *
4 * This file is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, Version 2, as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/platform_device.h>
10#include <linux/atomic.h>
11#include <mach/cns3xxx.h>
12#include <mach/pm.h>
13
14static int cns3xxx_ehci_init(struct usb_hcd *hcd)
15{
16 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
17 int retval;
18
19 /*
20 * EHCI and OHCI share the same clock and power,
21 * resetting twice would cause the 1st controller been reset.
22 * Therefore only do power up at the first up device, and
23 * power down at the last down device.
24 *
25 * Set USB AHB INCR length to 16
26 */
27 if (atomic_inc_return(&usb_pwr_ref) == 1) {
28 cns3xxx_pwr_power_up(1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_PLL_USB);
29 cns3xxx_pwr_clk_en(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST);
30 cns3xxx_pwr_soft_rst(1 << PM_SOFT_RST_REG_OFFST_USB_HOST);
31 __raw_writel((__raw_readl(MISC_CHIP_CONFIG_REG) | (0X2 << 24)),
32 MISC_CHIP_CONFIG_REG);
33 }
34
35 ehci->caps = hcd->regs;
36
37 hcd->has_tt = 0;
38
39 retval = ehci_setup(hcd);
40 if (retval)
41 return retval;
42
43 ehci_port_power(ehci, 0);
44
45 return retval;
46}
47
48static const struct hc_driver cns3xxx_ehci_hc_driver = {
49 .description = hcd_name,
50 .product_desc = "CNS3XXX EHCI Host Controller",
51 .hcd_priv_size = sizeof(struct ehci_hcd),
52 .irq = ehci_irq,
53 .flags = HCD_MEMORY | HCD_USB2,
54 .reset = cns3xxx_ehci_init,
55 .start = ehci_run,
56 .stop = ehci_stop,
57 .shutdown = ehci_shutdown,
58 .urb_enqueue = ehci_urb_enqueue,
59 .urb_dequeue = ehci_urb_dequeue,
60 .endpoint_disable = ehci_endpoint_disable,
61 .endpoint_reset = ehci_endpoint_reset,
62 .get_frame_number = ehci_get_frame,
63 .hub_status_data = ehci_hub_status_data,
64 .hub_control = ehci_hub_control,
65#ifdef CONFIG_PM
66 .bus_suspend = ehci_bus_suspend,
67 .bus_resume = ehci_bus_resume,
68#endif
69 .relinquish_port = ehci_relinquish_port,
70 .port_handed_over = ehci_port_handed_over,
71
72 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
73};
74
75static int cns3xxx_ehci_probe(struct platform_device *pdev)
76{
77 struct device *dev = &pdev->dev;
78 struct usb_hcd *hcd;
79 const struct hc_driver *driver = &cns3xxx_ehci_hc_driver;
80 struct resource *res;
81 int irq;
82 int retval;
83
84 if (usb_disabled())
85 return -ENODEV;
86
87 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
88 if (!res) {
89 dev_err(dev, "Found HC with no IRQ.\n");
90 return -ENODEV;
91 }
92 irq = res->start;
93
94 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
95 if (!hcd)
96 return -ENOMEM;
97
98 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
99 if (!res) {
100 dev_err(dev, "Found HC with no register addr.\n");
101 retval = -ENODEV;
102 goto err1;
103 }
104
105 hcd->rsrc_start = res->start;
106 hcd->rsrc_len = resource_size(res);
107
108 hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
109 if (hcd->regs == NULL) {
110 dev_dbg(dev, "error mapping memory\n");
111 retval = -EFAULT;
112 goto err1;
113 }
114
115 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
116 if (retval == 0)
117 return retval;
118
119err1:
120 usb_put_hcd(hcd);
121
122 return retval;
123}
124
125static int cns3xxx_ehci_remove(struct platform_device *pdev)
126{
127 struct usb_hcd *hcd = platform_get_drvdata(pdev);
128
129 usb_remove_hcd(hcd);
130
131 /*
132 * EHCI and OHCI share the same clock and power,
133 * resetting twice would cause the 1st controller been reset.
134 * Therefore only do power up at the first up device, and
135 * power down at the last down device.
136 */
137 if (atomic_dec_return(&usb_pwr_ref) == 0)
138 cns3xxx_pwr_clk_dis(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST);
139
140 usb_put_hcd(hcd);
141
142 platform_set_drvdata(pdev, NULL);
143
144 return 0;
145}
146
147MODULE_ALIAS("platform:cns3xxx-ehci");
148
149static struct platform_driver cns3xxx_ehci_driver = {
150 .probe = cns3xxx_ehci_probe,
151 .remove = cns3xxx_ehci_remove,
152 .driver = {
153 .name = "cns3xxx-ehci",
154 },
155};
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 1599806e3d47..70b496dc18a0 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -18,21 +18,6 @@
18 18
19/* this file is part of ehci-hcd.c */ 19/* this file is part of ehci-hcd.c */
20 20
21#define ehci_dbg(ehci, fmt, args...) \
22 dev_dbg (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
23#define ehci_err(ehci, fmt, args...) \
24 dev_err (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
25#define ehci_info(ehci, fmt, args...) \
26 dev_info (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
27#define ehci_warn(ehci, fmt, args...) \
28 dev_warn (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
29
30#ifdef VERBOSE_DEBUG
31# define ehci_vdbg ehci_dbg
32#else
33 static inline void ehci_vdbg(struct ehci_hcd *ehci, ...) {}
34#endif
35
36#ifdef DEBUG 21#ifdef DEBUG
37 22
38/* check the values in the HCSPARAMS register 23/* check the values in the HCSPARAMS register
@@ -352,11 +337,6 @@ static int debug_async_open(struct inode *, struct file *);
352static int debug_periodic_open(struct inode *, struct file *); 337static int debug_periodic_open(struct inode *, struct file *);
353static int debug_registers_open(struct inode *, struct file *); 338static int debug_registers_open(struct inode *, struct file *);
354static int debug_async_open(struct inode *, struct file *); 339static int debug_async_open(struct inode *, struct file *);
355static ssize_t debug_lpm_read(struct file *file, char __user *user_buf,
356 size_t count, loff_t *ppos);
357static ssize_t debug_lpm_write(struct file *file, const char __user *buffer,
358 size_t count, loff_t *ppos);
359static int debug_lpm_close(struct inode *inode, struct file *file);
360 340
361static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*); 341static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*);
362static int debug_close(struct inode *, struct file *); 342static int debug_close(struct inode *, struct file *);
@@ -382,14 +362,6 @@ static const struct file_operations debug_registers_fops = {
382 .release = debug_close, 362 .release = debug_close,
383 .llseek = default_llseek, 363 .llseek = default_llseek,
384}; 364};
385static const struct file_operations debug_lpm_fops = {
386 .owner = THIS_MODULE,
387 .open = simple_open,
388 .read = debug_lpm_read,
389 .write = debug_lpm_write,
390 .release = debug_lpm_close,
391 .llseek = noop_llseek,
392};
393 365
394static struct dentry *ehci_debug_root; 366static struct dentry *ehci_debug_root;
395 367
@@ -971,86 +943,6 @@ static int debug_registers_open(struct inode *inode, struct file *file)
971 return file->private_data ? 0 : -ENOMEM; 943 return file->private_data ? 0 : -ENOMEM;
972} 944}
973 945
974static int debug_lpm_close(struct inode *inode, struct file *file)
975{
976 return 0;
977}
978
979static ssize_t debug_lpm_read(struct file *file, char __user *user_buf,
980 size_t count, loff_t *ppos)
981{
982 /* TODO: show lpm stats */
983 return 0;
984}
985
986static ssize_t debug_lpm_write(struct file *file, const char __user *user_buf,
987 size_t count, loff_t *ppos)
988{
989 struct usb_hcd *hcd;
990 struct ehci_hcd *ehci;
991 char buf[50];
992 size_t len;
993 u32 temp;
994 unsigned long port;
995 u32 __iomem *portsc ;
996 u32 params;
997
998 hcd = bus_to_hcd(file->private_data);
999 ehci = hcd_to_ehci(hcd);
1000
1001 len = min(count, sizeof(buf) - 1);
1002 if (copy_from_user(buf, user_buf, len))
1003 return -EFAULT;
1004 buf[len] = '\0';
1005 if (len > 0 && buf[len - 1] == '\n')
1006 buf[len - 1] = '\0';
1007
1008 if (strncmp(buf, "enable", 5) == 0) {
1009 if (strict_strtoul(buf + 7, 10, &port))
1010 return -EINVAL;
1011 params = ehci_readl(ehci, &ehci->caps->hcs_params);
1012 if (port > HCS_N_PORTS(params)) {
1013 ehci_dbg(ehci, "ERR: LPM on bad port %lu\n", port);
1014 return -ENODEV;
1015 }
1016 portsc = &ehci->regs->port_status[port-1];
1017 temp = ehci_readl(ehci, portsc);
1018 if (!(temp & PORT_DEV_ADDR)) {
1019 ehci_dbg(ehci, "LPM: no device attached\n");
1020 return -ENODEV;
1021 }
1022 temp |= PORT_LPM;
1023 ehci_writel(ehci, temp, portsc);
1024 printk(KERN_INFO "force enable LPM for port %lu\n", port);
1025 } else if (strncmp(buf, "hird=", 5) == 0) {
1026 unsigned long hird;
1027 if (strict_strtoul(buf + 5, 16, &hird))
1028 return -EINVAL;
1029 printk(KERN_INFO "setting hird %s %lu\n", buf + 6, hird);
1030 ehci->command = (ehci->command & ~CMD_HIRD) | (hird << 24);
1031 ehci_writel(ehci, ehci->command, &ehci->regs->command);
1032 } else if (strncmp(buf, "disable", 7) == 0) {
1033 if (strict_strtoul(buf + 8, 10, &port))
1034 return -EINVAL;
1035 params = ehci_readl(ehci, &ehci->caps->hcs_params);
1036 if (port > HCS_N_PORTS(params)) {
1037 ehci_dbg(ehci, "ERR: LPM off bad port %lu\n", port);
1038 return -ENODEV;
1039 }
1040 portsc = &ehci->regs->port_status[port-1];
1041 temp = ehci_readl(ehci, portsc);
1042 if (!(temp & PORT_DEV_ADDR)) {
1043 ehci_dbg(ehci, "ERR: no device attached\n");
1044 return -ENODEV;
1045 }
1046 temp &= ~PORT_LPM;
1047 ehci_writel(ehci, temp, portsc);
1048 printk(KERN_INFO "disabled LPM for port %lu\n", port);
1049 } else
1050 return -EOPNOTSUPP;
1051 return count;
1052}
1053
1054static inline void create_debug_files (struct ehci_hcd *ehci) 946static inline void create_debug_files (struct ehci_hcd *ehci)
1055{ 947{
1056 struct usb_bus *bus = &ehci_to_hcd(ehci)->self; 948 struct usb_bus *bus = &ehci_to_hcd(ehci)->self;
@@ -1071,10 +963,6 @@ static inline void create_debug_files (struct ehci_hcd *ehci)
1071 &debug_registers_fops)) 963 &debug_registers_fops))
1072 goto file_error; 964 goto file_error;
1073 965
1074 if (!debugfs_create_file("lpm", S_IRUGO|S_IWUSR, ehci->debug_dir, bus,
1075 &debug_lpm_fops))
1076 goto file_error;
1077
1078 return; 966 return;
1079 967
1080file_error: 968file_error:
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 0d2f35ca93f1..fd9b5424b860 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -349,7 +349,6 @@ static int ehci_fsl_reinit(struct ehci_hcd *ehci)
349{ 349{
350 if (ehci_fsl_usb_setup(ehci)) 350 if (ehci_fsl_usb_setup(ehci))
351 return -EINVAL; 351 return -EINVAL;
352 ehci_port_power(ehci, 0);
353 352
354 return 0; 353 return 0;
355} 354}
diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c
index 3180cb3624d9..1fc89292f5d6 100644
--- a/drivers/usb/host/ehci-grlib.c
+++ b/drivers/usb/host/ehci-grlib.c
@@ -34,22 +34,6 @@
34 34
35#define GRUSBHC_HCIVERSION 0x0100 /* Known value of cap. reg. HCIVERSION */ 35#define GRUSBHC_HCIVERSION 0x0100 /* Known value of cap. reg. HCIVERSION */
36 36
37/* called during probe() after chip reset completes */
38static int ehci_grlib_setup(struct usb_hcd *hcd)
39{
40 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
41 int retval;
42
43 retval = ehci_setup(hcd);
44 if (retval)
45 return retval;
46
47 ehci_port_power(ehci, 1);
48
49 return retval;
50}
51
52
53static const struct hc_driver ehci_grlib_hc_driver = { 37static const struct hc_driver ehci_grlib_hc_driver = {
54 .description = hcd_name, 38 .description = hcd_name,
55 .product_desc = "GRLIB GRUSBHC EHCI", 39 .product_desc = "GRLIB GRUSBHC EHCI",
@@ -64,7 +48,7 @@ static const struct hc_driver ehci_grlib_hc_driver = {
64 /* 48 /*
65 * basic lifecycle operations 49 * basic lifecycle operations
66 */ 50 */
67 .reset = ehci_grlib_setup, 51 .reset = ehci_setup,
68 .start = ehci_run, 52 .start = ehci_run,
69 .stop = ehci_stop, 53 .stop = ehci_stop,
70 .shutdown = ehci_shutdown, 54 .shutdown = ehci_shutdown,
@@ -98,7 +82,7 @@ static const struct hc_driver ehci_grlib_hc_driver = {
98}; 82};
99 83
100 84
101static int __devinit ehci_hcd_grlib_probe(struct platform_device *op) 85static int ehci_hcd_grlib_probe(struct platform_device *op)
102{ 86{
103 struct device_node *dn = op->dev.of_node; 87 struct device_node *dn = op->dev.of_node;
104 struct usb_hcd *hcd; 88 struct usb_hcd *hcd;
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 6bf6c42481e8..c97503bb0b0e 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -39,7 +39,6 @@
39#include <linux/dma-mapping.h> 39#include <linux/dma-mapping.h>
40#include <linux/debugfs.h> 40#include <linux/debugfs.h>
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <linux/uaccess.h>
43 42
44#include <asm/byteorder.h> 43#include <asm/byteorder.h>
45#include <asm/io.h> 44#include <asm/io.h>
@@ -108,19 +107,39 @@ static bool ignore_oc = 0;
108module_param (ignore_oc, bool, S_IRUGO); 107module_param (ignore_oc, bool, S_IRUGO);
109MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications"); 108MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications");
110 109
111/* for link power management(LPM) feature */
112static unsigned int hird;
113module_param(hird, int, S_IRUGO);
114MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us");
115
116#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) 110#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT)
117 111
118/*-------------------------------------------------------------------------*/ 112/*-------------------------------------------------------------------------*/
119 113
120#include "ehci.h" 114#include "ehci.h"
121#include "ehci-dbg.c"
122#include "pci-quirks.h" 115#include "pci-quirks.h"
123 116
117/*
118 * The MosChip MCS9990 controller updates its microframe counter
119 * a little before the frame counter, and occasionally we will read
120 * the invalid intermediate value. Avoid problems by checking the
121 * microframe number (the low-order 3 bits); if they are 0 then
122 * re-read the register to get the correct value.
123 */
124static unsigned ehci_moschip_read_frame_index(struct ehci_hcd *ehci)
125{
126 unsigned uf;
127
128 uf = ehci_readl(ehci, &ehci->regs->frame_index);
129 if (unlikely((uf & 7) == 0))
130 uf = ehci_readl(ehci, &ehci->regs->frame_index);
131 return uf;
132}
133
134static inline unsigned ehci_read_frame_index(struct ehci_hcd *ehci)
135{
136 if (ehci->frame_index_bug)
137 return ehci_moschip_read_frame_index(ehci);
138 return ehci_readl(ehci, &ehci->regs->frame_index);
139}
140
141#include "ehci-dbg.c"
142
124/*-------------------------------------------------------------------------*/ 143/*-------------------------------------------------------------------------*/
125 144
126/* 145/*
@@ -293,7 +312,6 @@ static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh);
293 312
294#include "ehci-timer.c" 313#include "ehci-timer.c"
295#include "ehci-hub.c" 314#include "ehci-hub.c"
296#include "ehci-lpm.c"
297#include "ehci-mem.c" 315#include "ehci-mem.c"
298#include "ehci-q.c" 316#include "ehci-q.c"
299#include "ehci-sched.c" 317#include "ehci-sched.c"
@@ -353,24 +371,6 @@ static void ehci_shutdown(struct usb_hcd *hcd)
353 hrtimer_cancel(&ehci->hrtimer); 371 hrtimer_cancel(&ehci->hrtimer);
354} 372}
355 373
356static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
357{
358 unsigned port;
359
360 if (!HCS_PPC (ehci->hcs_params))
361 return;
362
363 ehci_dbg (ehci, "...power%s ports...\n", is_on ? "up" : "down");
364 for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; )
365 (void) ehci_hub_control(ehci_to_hcd(ehci),
366 is_on ? SetPortFeature : ClearPortFeature,
367 USB_PORT_FEAT_POWER,
368 port--, NULL, 0);
369 /* Flush those writes */
370 ehci_readl(ehci, &ehci->regs->command);
371 msleep(20);
372}
373
374/*-------------------------------------------------------------------------*/ 374/*-------------------------------------------------------------------------*/
375 375
376/* 376/*
@@ -503,7 +503,7 @@ static int ehci_init(struct usb_hcd *hcd)
503 503
504 /* controllers may cache some of the periodic schedule ... */ 504 /* controllers may cache some of the periodic schedule ... */
505 if (HCC_ISOC_CACHE(hcc_params)) // full frame cache 505 if (HCC_ISOC_CACHE(hcc_params)) // full frame cache
506 ehci->i_thresh = 2 + 8; 506 ehci->i_thresh = 0;
507 else // N microframes cached 507 else // N microframes cached
508 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); 508 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params);
509 509
@@ -555,17 +555,6 @@ static int ehci_init(struct usb_hcd *hcd)
555 temp &= ~(3 << 2); 555 temp &= ~(3 << 2);
556 temp |= (EHCI_TUNE_FLS << 2); 556 temp |= (EHCI_TUNE_FLS << 2);
557 } 557 }
558 if (HCC_LPM(hcc_params)) {
559 /* support link power management EHCI 1.1 addendum */
560 ehci_dbg(ehci, "support lpm\n");
561 ehci->has_lpm = 1;
562 if (hird > 0xf) {
563 ehci_dbg(ehci, "hird %d invalid, use default 0",
564 hird);
565 hird = 0;
566 }
567 temp |= hird << 24;
568 }
569 ehci->command = temp; 558 ehci->command = temp;
570 559
571 /* Accept arbitrarily long scatter-gather lists */ 560 /* Accept arbitrarily long scatter-gather lists */
@@ -660,7 +649,7 @@ static int ehci_run (struct usb_hcd *hcd)
660 return 0; 649 return 0;
661} 650}
662 651
663static int ehci_setup(struct usb_hcd *hcd) 652int ehci_setup(struct usb_hcd *hcd)
664{ 653{
665 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 654 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
666 int retval; 655 int retval;
@@ -691,6 +680,7 @@ static int ehci_setup(struct usb_hcd *hcd)
691 680
692 return 0; 681 return 0;
693} 682}
683EXPORT_SYMBOL_GPL(ehci_setup);
694 684
695/*-------------------------------------------------------------------------*/ 685/*-------------------------------------------------------------------------*/
696 686
@@ -1096,7 +1086,7 @@ static int ehci_get_frame (struct usb_hcd *hcd)
1096 1086
1097/* These routines handle the generic parts of controller suspend/resume */ 1087/* These routines handle the generic parts of controller suspend/resume */
1098 1088
1099static int __maybe_unused ehci_suspend(struct usb_hcd *hcd, bool do_wakeup) 1089int ehci_suspend(struct usb_hcd *hcd, bool do_wakeup)
1100{ 1090{
1101 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 1091 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1102 1092
@@ -1119,9 +1109,10 @@ static int __maybe_unused ehci_suspend(struct usb_hcd *hcd, bool do_wakeup)
1119 1109
1120 return 0; 1110 return 0;
1121} 1111}
1112EXPORT_SYMBOL_GPL(ehci_suspend);
1122 1113
1123/* Returns 0 if power was preserved, 1 if power was lost */ 1114/* Returns 0 if power was preserved, 1 if power was lost */
1124static int __maybe_unused ehci_resume(struct usb_hcd *hcd, bool hibernated) 1115int ehci_resume(struct usb_hcd *hcd, bool hibernated)
1125{ 1116{
1126 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 1117 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1127 1118
@@ -1177,33 +1168,83 @@ static int __maybe_unused ehci_resume(struct usb_hcd *hcd, bool hibernated)
1177 ehci->rh_state = EHCI_RH_SUSPENDED; 1168 ehci->rh_state = EHCI_RH_SUSPENDED;
1178 spin_unlock_irq(&ehci->lock); 1169 spin_unlock_irq(&ehci->lock);
1179 1170
1180 /* here we "know" root ports should always stay powered */
1181 ehci_port_power(ehci, 1);
1182
1183 return 1; 1171 return 1;
1184} 1172}
1173EXPORT_SYMBOL_GPL(ehci_resume);
1185 1174
1186#endif 1175#endif
1187 1176
1188/*-------------------------------------------------------------------------*/ 1177/*-------------------------------------------------------------------------*/
1189 1178
1190/* 1179/*
1191 * The EHCI in ChipIdea HDRC cannot be a separate module or device, 1180 * Generic structure: This gets copied for platform drivers so that
1192 * because its registers (and irq) are shared between host/gadget/otg 1181 * individual entries can be overridden as needed.
1193 * functions and in order to facilitate role switching we cannot
1194 * give the ehci driver exclusive access to those.
1195 */ 1182 */
1196#ifndef CHIPIDEA_EHCI 1183
1184static const struct hc_driver ehci_hc_driver = {
1185 .description = hcd_name,
1186 .product_desc = "EHCI Host Controller",
1187 .hcd_priv_size = sizeof(struct ehci_hcd),
1188
1189 /*
1190 * generic hardware linkage
1191 */
1192 .irq = ehci_irq,
1193 .flags = HCD_MEMORY | HCD_USB2,
1194
1195 /*
1196 * basic lifecycle operations
1197 */
1198 .reset = ehci_setup,
1199 .start = ehci_run,
1200 .stop = ehci_stop,
1201 .shutdown = ehci_shutdown,
1202
1203 /*
1204 * managing i/o requests and associated device resources
1205 */
1206 .urb_enqueue = ehci_urb_enqueue,
1207 .urb_dequeue = ehci_urb_dequeue,
1208 .endpoint_disable = ehci_endpoint_disable,
1209 .endpoint_reset = ehci_endpoint_reset,
1210 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
1211
1212 /*
1213 * scheduling support
1214 */
1215 .get_frame_number = ehci_get_frame,
1216
1217 /*
1218 * root hub support
1219 */
1220 .hub_status_data = ehci_hub_status_data,
1221 .hub_control = ehci_hub_control,
1222 .bus_suspend = ehci_bus_suspend,
1223 .bus_resume = ehci_bus_resume,
1224 .relinquish_port = ehci_relinquish_port,
1225 .port_handed_over = ehci_port_handed_over,
1226};
1227
1228void ehci_init_driver(struct hc_driver *drv,
1229 const struct ehci_driver_overrides *over)
1230{
1231 /* Copy the generic table to drv and then apply the overrides */
1232 *drv = ehci_hc_driver;
1233
1234 if (over) {
1235 drv->hcd_priv_size += over->extra_priv_size;
1236 if (over->reset)
1237 drv->reset = over->reset;
1238 }
1239}
1240EXPORT_SYMBOL_GPL(ehci_init_driver);
1241
1242/*-------------------------------------------------------------------------*/
1197 1243
1198MODULE_DESCRIPTION(DRIVER_DESC); 1244MODULE_DESCRIPTION(DRIVER_DESC);
1199MODULE_AUTHOR (DRIVER_AUTHOR); 1245MODULE_AUTHOR (DRIVER_AUTHOR);
1200MODULE_LICENSE ("GPL"); 1246MODULE_LICENSE ("GPL");
1201 1247
1202#ifdef CONFIG_PCI
1203#include "ehci-pci.c"
1204#define PCI_DRIVER ehci_pci_driver
1205#endif
1206
1207#ifdef CONFIG_USB_EHCI_FSL 1248#ifdef CONFIG_USB_EHCI_FSL
1208#include "ehci-fsl.c" 1249#include "ehci-fsl.c"
1209#define PLATFORM_DRIVER ehci_fsl_driver 1250#define PLATFORM_DRIVER ehci_fsl_driver
@@ -1219,11 +1260,6 @@ MODULE_LICENSE ("GPL");
1219#define PLATFORM_DRIVER ehci_hcd_sh_driver 1260#define PLATFORM_DRIVER ehci_hcd_sh_driver
1220#endif 1261#endif
1221 1262
1222#ifdef CONFIG_MIPS_ALCHEMY
1223#include "ehci-au1xxx.c"
1224#define PLATFORM_DRIVER ehci_hcd_au1xxx_driver
1225#endif
1226
1227#ifdef CONFIG_USB_EHCI_HCD_OMAP 1263#ifdef CONFIG_USB_EHCI_HCD_OMAP
1228#include "ehci-omap.c" 1264#include "ehci-omap.c"
1229#define PLATFORM_DRIVER ehci_hcd_omap_driver 1265#define PLATFORM_DRIVER ehci_hcd_omap_driver
@@ -1249,11 +1285,6 @@ MODULE_LICENSE ("GPL");
1249#define PLATFORM_DRIVER ehci_orion_driver 1285#define PLATFORM_DRIVER ehci_orion_driver
1250#endif 1286#endif
1251 1287
1252#ifdef CONFIG_ARCH_IXP4XX
1253#include "ehci-ixp4xx.c"
1254#define PLATFORM_DRIVER ixp4xx_ehci_driver
1255#endif
1256
1257#ifdef CONFIG_USB_W90X900_EHCI 1288#ifdef CONFIG_USB_W90X900_EHCI
1258#include "ehci-w90x900.c" 1289#include "ehci-w90x900.c"
1259#define PLATFORM_DRIVER ehci_hcd_w90x900_driver 1290#define PLATFORM_DRIVER ehci_hcd_w90x900_driver
@@ -1269,11 +1300,6 @@ MODULE_LICENSE ("GPL");
1269#define PLATFORM_DRIVER ehci_octeon_driver 1300#define PLATFORM_DRIVER ehci_octeon_driver
1270#endif 1301#endif
1271 1302
1272#ifdef CONFIG_USB_CNS3XXX_EHCI
1273#include "ehci-cns3xxx.c"
1274#define PLATFORM_DRIVER cns3xxx_ehci_driver
1275#endif
1276
1277#ifdef CONFIG_ARCH_VT8500 1303#ifdef CONFIG_ARCH_VT8500
1278#include "ehci-vt8500.c" 1304#include "ehci-vt8500.c"
1279#define PLATFORM_DRIVER vt8500_ehci_driver 1305#define PLATFORM_DRIVER vt8500_ehci_driver
@@ -1314,34 +1340,23 @@ MODULE_LICENSE ("GPL");
1314#define PLATFORM_DRIVER ehci_grlib_driver 1340#define PLATFORM_DRIVER ehci_grlib_driver
1315#endif 1341#endif
1316 1342
1317#ifdef CONFIG_CPU_XLR
1318#include "ehci-xls.c"
1319#define PLATFORM_DRIVER ehci_xls_driver
1320#endif
1321
1322#ifdef CONFIG_USB_EHCI_MV 1343#ifdef CONFIG_USB_EHCI_MV
1323#include "ehci-mv.c" 1344#include "ehci-mv.c"
1324#define PLATFORM_DRIVER ehci_mv_driver 1345#define PLATFORM_DRIVER ehci_mv_driver
1325#endif 1346#endif
1326 1347
1327#ifdef CONFIG_MACH_LOONGSON1
1328#include "ehci-ls1x.c"
1329#define PLATFORM_DRIVER ehci_ls1x_driver
1330#endif
1331
1332#ifdef CONFIG_MIPS_SEAD3 1348#ifdef CONFIG_MIPS_SEAD3
1333#include "ehci-sead3.c" 1349#include "ehci-sead3.c"
1334#define PLATFORM_DRIVER ehci_hcd_sead3_driver 1350#define PLATFORM_DRIVER ehci_hcd_sead3_driver
1335#endif 1351#endif
1336 1352
1337#ifdef CONFIG_USB_EHCI_HCD_PLATFORM 1353#if !IS_ENABLED(CONFIG_USB_EHCI_PCI) && \
1338#include "ehci-platform.c" 1354 !IS_ENABLED(CONFIG_USB_EHCI_HCD_PLATFORM) && \
1339#define PLATFORM_DRIVER ehci_platform_driver 1355 !defined(CONFIG_USB_CHIPIDEA_HOST) && \
1340#endif 1356 !defined(PLATFORM_DRIVER) && \
1341 1357 !defined(PS3_SYSTEM_BUS_DRIVER) && \
1342#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ 1358 !defined(OF_PLATFORM_DRIVER) && \
1343 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ 1359 !defined(XILINX_OF_PLATFORM_DRIVER)
1344 !defined(XILINX_OF_PLATFORM_DRIVER)
1345#error "missing bus glue for ehci-hcd" 1360#error "missing bus glue for ehci-hcd"
1346#endif 1361#endif
1347 1362
@@ -1378,12 +1393,6 @@ static int __init ehci_hcd_init(void)
1378 goto clean0; 1393 goto clean0;
1379#endif 1394#endif
1380 1395
1381#ifdef PCI_DRIVER
1382 retval = pci_register_driver(&PCI_DRIVER);
1383 if (retval < 0)
1384 goto clean1;
1385#endif
1386
1387#ifdef PS3_SYSTEM_BUS_DRIVER 1396#ifdef PS3_SYSTEM_BUS_DRIVER
1388 retval = ps3_ehci_driver_register(&PS3_SYSTEM_BUS_DRIVER); 1397 retval = ps3_ehci_driver_register(&PS3_SYSTEM_BUS_DRIVER);
1389 if (retval < 0) 1398 if (retval < 0)
@@ -1415,10 +1424,6 @@ clean3:
1415 ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1424 ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
1416clean2: 1425clean2:
1417#endif 1426#endif
1418#ifdef PCI_DRIVER
1419 pci_unregister_driver(&PCI_DRIVER);
1420clean1:
1421#endif
1422#ifdef PLATFORM_DRIVER 1427#ifdef PLATFORM_DRIVER
1423 platform_driver_unregister(&PLATFORM_DRIVER); 1428 platform_driver_unregister(&PLATFORM_DRIVER);
1424clean0: 1429clean0:
@@ -1444,9 +1449,6 @@ static void __exit ehci_hcd_cleanup(void)
1444#ifdef PLATFORM_DRIVER 1449#ifdef PLATFORM_DRIVER
1445 platform_driver_unregister(&PLATFORM_DRIVER); 1450 platform_driver_unregister(&PLATFORM_DRIVER);
1446#endif 1451#endif
1447#ifdef PCI_DRIVER
1448 pci_unregister_driver(&PCI_DRIVER);
1449#endif
1450#ifdef PS3_SYSTEM_BUS_DRIVER 1452#ifdef PS3_SYSTEM_BUS_DRIVER
1451 ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1453 ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
1452#endif 1454#endif
@@ -1456,5 +1458,3 @@ static void __exit ehci_hcd_cleanup(void)
1456 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); 1458 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
1457} 1459}
1458module_exit(ehci_hcd_cleanup); 1460module_exit(ehci_hcd_cleanup);
1459
1460#endif /* CHIPIDEA_EHCI */
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 914ce9370e70..4ccb97c0678f 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -56,6 +56,19 @@ static void ehci_handover_companion_ports(struct ehci_hcd *ehci)
56 if (!ehci->owned_ports) 56 if (!ehci->owned_ports)
57 return; 57 return;
58 58
59 /* Make sure the ports are powered */
60 port = HCS_N_PORTS(ehci->hcs_params);
61 while (port--) {
62 if (test_bit(port, &ehci->owned_ports)) {
63 reg = &ehci->regs->port_status[port];
64 status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS;
65 if (!(status & PORT_POWER)) {
66 status |= PORT_POWER;
67 ehci_writel(ehci, status, reg);
68 }
69 }
70 }
71
59 /* Give the connections some time to appear */ 72 /* Give the connections some time to appear */
60 msleep(20); 73 msleep(20);
61 74
@@ -384,11 +397,24 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
384 ehci_writel(ehci, ehci->command, &ehci->regs->command); 397 ehci_writel(ehci, ehci->command, &ehci->regs->command);
385 ehci->rh_state = EHCI_RH_RUNNING; 398 ehci->rh_state = EHCI_RH_RUNNING;
386 399
387 /* Some controller/firmware combinations need a delay during which 400 /*
388 * they set up the port statuses. See Bugzilla #8190. */ 401 * According to Bugzilla #8190, the port status for some controllers
389 spin_unlock_irq(&ehci->lock); 402 * will be wrong without a delay. At their wrong status, the port
390 msleep(8); 403 * is enabled, but not suspended neither resumed.
391 spin_lock_irq(&ehci->lock); 404 */
405 i = HCS_N_PORTS(ehci->hcs_params);
406 while (i--) {
407 temp = ehci_readl(ehci, &ehci->regs->port_status[i]);
408 if ((temp & PORT_PE) &&
409 !(temp & (PORT_SUSPEND | PORT_RESUME))) {
410 ehci_dbg(ehci, "Port status(0x%x) is wrong\n", temp);
411 spin_unlock_irq(&ehci->lock);
412 msleep(8);
413 spin_lock_irq(&ehci->lock);
414 break;
415 }
416 }
417
392 if (ehci->shutdown) 418 if (ehci->shutdown)
393 goto shutdown; 419 goto shutdown;
394 420
@@ -764,11 +790,6 @@ static int ehci_hub_control (
764 status_reg); 790 status_reg);
765 break; 791 break;
766 case USB_PORT_FEAT_C_CONNECTION: 792 case USB_PORT_FEAT_C_CONNECTION:
767 if (ehci->has_lpm) {
768 /* clear PORTSC bits on disconnect */
769 temp &= ~PORT_LPM;
770 temp &= ~PORT_DEV_ADDR;
771 }
772 ehci_writel(ehci, temp | PORT_CSC, status_reg); 793 ehci_writel(ehci, temp | PORT_CSC, status_reg);
773 break; 794 break;
774 case USB_PORT_FEAT_C_OVER_CURRENT: 795 case USB_PORT_FEAT_C_OVER_CURRENT:
@@ -1088,8 +1109,7 @@ error_exit:
1088 return retval; 1109 return retval;
1089} 1110}
1090 1111
1091static void __maybe_unused ehci_relinquish_port(struct usb_hcd *hcd, 1112static void ehci_relinquish_port(struct usb_hcd *hcd, int portnum)
1092 int portnum)
1093{ 1113{
1094 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 1114 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1095 1115
@@ -1098,8 +1118,7 @@ static void __maybe_unused ehci_relinquish_port(struct usb_hcd *hcd,
1098 set_owner(ehci, --portnum, PORT_OWNER); 1118 set_owner(ehci, --portnum, PORT_OWNER);
1099} 1119}
1100 1120
1101static int __maybe_unused ehci_port_handed_over(struct usb_hcd *hcd, 1121static int ehci_port_handed_over(struct usb_hcd *hcd, int portnum)
1102 int portnum)
1103{ 1122{
1104 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 1123 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1105 u32 __iomem *reg; 1124 u32 __iomem *reg;
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c
deleted file mode 100644
index f224c0a48bed..000000000000
--- a/drivers/usb/host/ehci-ixp4xx.c
+++ /dev/null
@@ -1,139 +0,0 @@
1/*
2 * IXP4XX EHCI Host Controller Driver
3 *
4 * Author: Vladimir Barinov <vbarinov@embeddedalley.com>
5 *
6 * Based on "ehci-fsl.c" by Randy Vinson <rvinson@mvista.com>
7 *
8 * 2007 (c) MontaVista Software, Inc. This file is licensed under
9 * the terms of the GNU General Public License version 2. This program
10 * is licensed "as is" without any warranty of any kind, whether express
11 * or implied.
12 */
13
14#include <linux/platform_device.h>
15
16static int ixp4xx_ehci_init(struct usb_hcd *hcd)
17{
18 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
19 int retval = 0;
20
21 ehci->big_endian_desc = 1;
22 ehci->big_endian_mmio = 1;
23
24 ehci->caps = hcd->regs + 0x100;
25
26 hcd->has_tt = 1;
27
28 retval = ehci_setup(hcd);
29 if (retval)
30 return retval;
31
32 ehci_port_power(ehci, 0);
33
34 return retval;
35}
36
37static const struct hc_driver ixp4xx_ehci_hc_driver = {
38 .description = hcd_name,
39 .product_desc = "IXP4XX EHCI Host Controller",
40 .hcd_priv_size = sizeof(struct ehci_hcd),
41 .irq = ehci_irq,
42 .flags = HCD_MEMORY | HCD_USB2,
43 .reset = ixp4xx_ehci_init,
44 .start = ehci_run,
45 .stop = ehci_stop,
46 .shutdown = ehci_shutdown,
47 .urb_enqueue = ehci_urb_enqueue,
48 .urb_dequeue = ehci_urb_dequeue,
49 .endpoint_disable = ehci_endpoint_disable,
50 .endpoint_reset = ehci_endpoint_reset,
51 .get_frame_number = ehci_get_frame,
52 .hub_status_data = ehci_hub_status_data,
53 .hub_control = ehci_hub_control,
54#if defined(CONFIG_PM)
55 .bus_suspend = ehci_bus_suspend,
56 .bus_resume = ehci_bus_resume,
57#endif
58 .relinquish_port = ehci_relinquish_port,
59 .port_handed_over = ehci_port_handed_over,
60
61 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
62};
63
64static int ixp4xx_ehci_probe(struct platform_device *pdev)
65{
66 struct usb_hcd *hcd;
67 const struct hc_driver *driver = &ixp4xx_ehci_hc_driver;
68 struct resource *res;
69 int irq;
70 int retval;
71
72 if (usb_disabled())
73 return -ENODEV;
74
75 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
76 if (!res) {
77 dev_err(&pdev->dev,
78 "Found HC with no IRQ. Check %s setup!\n",
79 dev_name(&pdev->dev));
80 return -ENODEV;
81 }
82 irq = res->start;
83
84 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
85 if (!hcd) {
86 retval = -ENOMEM;
87 goto fail_create_hcd;
88 }
89
90 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
91 if (!res) {
92 dev_err(&pdev->dev,
93 "Found HC with no register addr. Check %s setup!\n",
94 dev_name(&pdev->dev));
95 retval = -ENODEV;
96 goto fail_request_resource;
97 }
98 hcd->rsrc_start = res->start;
99 hcd->rsrc_len = resource_size(res);
100
101 hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
102 if (hcd->regs == NULL) {
103 dev_dbg(&pdev->dev, "error mapping memory\n");
104 retval = -EFAULT;
105 goto fail_request_resource;
106 }
107
108 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
109 if (retval)
110 goto fail_request_resource;
111
112 return retval;
113
114fail_request_resource:
115 usb_put_hcd(hcd);
116fail_create_hcd:
117 dev_err(&pdev->dev, "init %s fail, %d\n", dev_name(&pdev->dev), retval);
118 return retval;
119}
120
121static int ixp4xx_ehci_remove(struct platform_device *pdev)
122{
123 struct usb_hcd *hcd = platform_get_drvdata(pdev);
124
125 usb_remove_hcd(hcd);
126 usb_put_hcd(hcd);
127
128 return 0;
129}
130
131MODULE_ALIAS("platform:ixp4xx-ehci");
132
133static struct platform_driver ixp4xx_ehci_driver = {
134 .probe = ixp4xx_ehci_probe,
135 .remove = ixp4xx_ehci_remove,
136 .driver = {
137 .name = "ixp4xx-ehci",
138 },
139};
diff --git a/drivers/usb/host/ehci-lpm.c b/drivers/usb/host/ehci-lpm.c
deleted file mode 100644
index 2111627a19de..000000000000
--- a/drivers/usb/host/ehci-lpm.c
+++ /dev/null
@@ -1,84 +0,0 @@
1/* ehci-lpm.c EHCI HCD LPM support code
2 * Copyright (c) 2008 - 2010, Intel Corporation.
3 * Author: Jacob Pan <jacob.jun.pan@intel.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17*/
18
19/* this file is part of ehci-hcd.c */
20static int __maybe_unused ehci_lpm_set_da(struct ehci_hcd *ehci,
21 int dev_addr, int port_num)
22{
23 u32 __iomem portsc;
24
25 ehci_dbg(ehci, "set dev address %d for port %d\n", dev_addr, port_num);
26 if (port_num > HCS_N_PORTS(ehci->hcs_params)) {
27 ehci_dbg(ehci, "invalid port number %d\n", port_num);
28 return -ENODEV;
29 }
30 portsc = ehci_readl(ehci, &ehci->regs->port_status[port_num-1]);
31 portsc &= ~PORT_DEV_ADDR;
32 portsc |= dev_addr<<25;
33 ehci_writel(ehci, portsc, &ehci->regs->port_status[port_num-1]);
34 return 0;
35}
36
37/*
38 * this function is used to check if the device support LPM
39 * if yes, mark the PORTSC register with PORT_LPM bit
40 */
41static int __maybe_unused ehci_lpm_check(struct ehci_hcd *ehci, int port)
42{
43 u32 __iomem *portsc ;
44 u32 val32;
45 int retval;
46
47 portsc = &ehci->regs->port_status[port-1];
48 val32 = ehci_readl(ehci, portsc);
49 if (!(val32 & PORT_DEV_ADDR)) {
50 ehci_dbg(ehci, "LPM: no device attached\n");
51 return -ENODEV;
52 }
53 val32 |= PORT_LPM;
54 ehci_writel(ehci, val32, portsc);
55 msleep(5);
56 val32 |= PORT_SUSPEND;
57 ehci_dbg(ehci, "Sending LPM 0x%08x to port %d\n", val32, port);
58 ehci_writel(ehci, val32, portsc);
59 /* wait for ACK */
60 msleep(10);
61 retval = handshake(ehci, &ehci->regs->port_status[port-1], PORT_SSTS,
62 PORTSC_SUSPEND_STS_ACK, 125);
63 dbg_port(ehci, "LPM", port, val32);
64 if (retval != -ETIMEDOUT) {
65 ehci_dbg(ehci, "LPM: device ACK for LPM\n");
66 val32 |= PORT_LPM;
67 /*
68 * now device should be in L1 sleep, let's wake up the device
69 * so that we can complete enumeration.
70 */
71 ehci_writel(ehci, val32, portsc);
72 msleep(10);
73 val32 |= PORT_RESUME;
74 ehci_writel(ehci, val32, portsc);
75 } else {
76 ehci_dbg(ehci, "LPM: device does not ACK, disable LPM %d\n",
77 retval);
78 val32 &= ~PORT_LPM;
79 retval = -ETIMEDOUT;
80 ehci_writel(ehci, val32, portsc);
81 }
82
83 return retval;
84}
diff --git a/drivers/usb/host/ehci-ls1x.c b/drivers/usb/host/ehci-ls1x.c
deleted file mode 100644
index aa0f328922df..000000000000
--- a/drivers/usb/host/ehci-ls1x.c
+++ /dev/null
@@ -1,147 +0,0 @@
1/*
2 * Bus Glue for Loongson LS1X built-in EHCI controller.
3 *
4 * Copyright (c) 2012 Zhang, Keguang <keguang.zhang@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 */
10
11
12#include <linux/platform_device.h>
13
14static int ehci_ls1x_reset(struct usb_hcd *hcd)
15{
16 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
17 int ret;
18
19 ehci->caps = hcd->regs;
20
21 ret = ehci_setup(hcd);
22 if (ret)
23 return ret;
24
25 ehci_port_power(ehci, 0);
26
27 return 0;
28}
29
30static const struct hc_driver ehci_ls1x_hc_driver = {
31 .description = hcd_name,
32 .product_desc = "LOONGSON1 EHCI",
33 .hcd_priv_size = sizeof(struct ehci_hcd),
34
35 /*
36 * generic hardware linkage
37 */
38 .irq = ehci_irq,
39 .flags = HCD_MEMORY | HCD_USB2,
40
41 /*
42 * basic lifecycle operations
43 */
44 .reset = ehci_ls1x_reset,
45 .start = ehci_run,
46 .stop = ehci_stop,
47 .shutdown = ehci_shutdown,
48
49 /*
50 * managing i/o requests and associated device resources
51 */
52 .urb_enqueue = ehci_urb_enqueue,
53 .urb_dequeue = ehci_urb_dequeue,
54 .endpoint_disable = ehci_endpoint_disable,
55 .endpoint_reset = ehci_endpoint_reset,
56
57 /*
58 * scheduling support
59 */
60 .get_frame_number = ehci_get_frame,
61
62 /*
63 * root hub support
64 */
65 .hub_status_data = ehci_hub_status_data,
66 .hub_control = ehci_hub_control,
67 .relinquish_port = ehci_relinquish_port,
68 .port_handed_over = ehci_port_handed_over,
69
70 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
71};
72
73static int ehci_hcd_ls1x_probe(struct platform_device *pdev)
74{
75 struct usb_hcd *hcd;
76 struct resource *res;
77 int irq;
78 int ret;
79
80 pr_debug("initializing loongson1 ehci USB Controller\n");
81
82 if (usb_disabled())
83 return -ENODEV;
84
85 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
86 if (!res) {
87 dev_err(&pdev->dev,
88 "Found HC with no IRQ. Check %s setup!\n",
89 dev_name(&pdev->dev));
90 return -ENODEV;
91 }
92 irq = res->start;
93
94 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
95 if (!res) {
96 dev_err(&pdev->dev,
97 "Found HC with no register addr. Check %s setup!\n",
98 dev_name(&pdev->dev));
99 return -ENODEV;
100 }
101
102 hcd = usb_create_hcd(&ehci_ls1x_hc_driver, &pdev->dev,
103 dev_name(&pdev->dev));
104 if (!hcd)
105 return -ENOMEM;
106 hcd->rsrc_start = res->start;
107 hcd->rsrc_len = resource_size(res);
108
109 hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
110 if (hcd->regs == NULL) {
111 dev_dbg(&pdev->dev, "error mapping memory\n");
112 ret = -EFAULT;
113 goto err_put_hcd;
114 }
115
116 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
117 if (ret)
118 goto err_put_hcd;
119
120 return ret;
121
122err_put_hcd:
123 usb_put_hcd(hcd);
124 return ret;
125}
126
127static int ehci_hcd_ls1x_remove(struct platform_device *pdev)
128{
129 struct usb_hcd *hcd = platform_get_drvdata(pdev);
130
131 usb_remove_hcd(hcd);
132 usb_put_hcd(hcd);
133
134 return 0;
135}
136
137static struct platform_driver ehci_ls1x_driver = {
138 .probe = ehci_hcd_ls1x_probe,
139 .remove = ehci_hcd_ls1x_remove,
140 .shutdown = usb_hcd_platform_shutdown,
141 .driver = {
142 .name = "ls1x-ehci",
143 .owner = THIS_MODULE,
144 },
145};
146
147MODULE_ALIAS(PLATFORM_MODULE_PREFIX "ls1x-ehci");
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index 4af4dc5b618c..88a49c87e748 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -53,7 +53,6 @@ static int ehci_msm_reset(struct usb_hcd *hcd)
53 /* Disable streaming mode and select host mode */ 53 /* Disable streaming mode and select host mode */
54 writel(0x13, USB_USBMODE); 54 writel(0x13, USB_USBMODE);
55 55
56 ehci_port_power(ehci, 1);
57 return 0; 56 return 0;
58} 57}
59 58
@@ -174,7 +173,7 @@ put_hcd:
174 return ret; 173 return ret;
175} 174}
176 175
177static int __devexit ehci_msm_remove(struct platform_device *pdev) 176static int ehci_msm_remove(struct platform_device *pdev)
178{ 177{
179 struct usb_hcd *hcd = platform_get_drvdata(pdev); 178 struct usb_hcd *hcd = platform_get_drvdata(pdev);
180 179
@@ -221,7 +220,7 @@ static const struct dev_pm_ops ehci_msm_dev_pm_ops = {
221 220
222static struct platform_driver ehci_msm_driver = { 221static struct platform_driver ehci_msm_driver = {
223 .probe = ehci_msm_probe, 222 .probe = ehci_msm_probe,
224 .remove = __devexit_p(ehci_msm_remove), 223 .remove = ehci_msm_remove,
225 .driver = { 224 .driver = {
226 .name = "msm_hsusb_host", 225 .name = "msm_hsusb_host",
227 .pm = &ehci_msm_dev_pm_ops, 226 .pm = &ehci_msm_dev_pm_ops,
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index 4a08fc0b27c9..8804f74689d7 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -39,17 +39,9 @@ struct ehci_mxc_priv {
39/* called during probe() after chip reset completes */ 39/* called during probe() after chip reset completes */
40static int ehci_mxc_setup(struct usb_hcd *hcd) 40static int ehci_mxc_setup(struct usb_hcd *hcd)
41{ 41{
42 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
43 int retval;
44
45 hcd->has_tt = 1; 42 hcd->has_tt = 1;
46 43
47 retval = ehci_setup(hcd); 44 return ehci_setup(hcd);
48 if (retval)
49 return retval;
50
51 ehci_port_power(ehci, 0);
52 return 0;
53} 45}
54 46
55static const struct hc_driver ehci_mxc_hc_driver = { 47static const struct hc_driver ehci_mxc_hc_driver = {
diff --git a/drivers/usb/host/ehci-octeon.c b/drivers/usb/host/ehci-octeon.c
index ba26957abf46..a89750fff4ff 100644
--- a/drivers/usb/host/ehci-octeon.c
+++ b/drivers/usb/host/ehci-octeon.c
@@ -159,9 +159,6 @@ static int ehci_octeon_drv_probe(struct platform_device *pdev)
159 159
160 platform_set_drvdata(pdev, hcd); 160 platform_set_drvdata(pdev, hcd);
161 161
162 /* root ports should always stay powered */
163 ehci_port_power(ehci, 1);
164
165 return 0; 162 return 0;
166err3: 163err3:
167 ehci_octeon_stop(); 164 ehci_octeon_stop();
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index d7fe287d0678..44e7d0f638e8 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -146,9 +146,6 @@ static int omap_ehci_init(struct usb_hcd *hcd)
146 gpio_set_value_cansleep(pdata->reset_gpio_port[1], 1); 146 gpio_set_value_cansleep(pdata->reset_gpio_port[1], 1);
147 } 147 }
148 148
149 /* root ports should always stay powered */
150 ehci_port_power(ehci, 1);
151
152 return rc; 149 return rc;
153} 150}
154 151
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 9c2717d66730..f74794c93152 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -101,20 +101,6 @@ static void orion_usb_phy_v1_setup(struct usb_hcd *hcd)
101 wrl(USB_MODE, 0x13); 101 wrl(USB_MODE, 0x13);
102} 102}
103 103
104static int ehci_orion_setup(struct usb_hcd *hcd)
105{
106 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
107 int retval;
108
109 retval = ehci_setup(hcd);
110 if (retval)
111 return retval;
112
113 ehci_port_power(ehci, 0);
114
115 return retval;
116}
117
118static const struct hc_driver ehci_orion_hc_driver = { 104static const struct hc_driver ehci_orion_hc_driver = {
119 .description = hcd_name, 105 .description = hcd_name,
120 .product_desc = "Marvell Orion EHCI", 106 .product_desc = "Marvell Orion EHCI",
@@ -129,7 +115,7 @@ static const struct hc_driver ehci_orion_hc_driver = {
129 /* 115 /*
130 * basic lifecycle operations 116 * basic lifecycle operations
131 */ 117 */
132 .reset = ehci_orion_setup, 118 .reset = ehci_setup,
133 .start = ehci_run, 119 .start = ehci_run,
134 .stop = ehci_stop, 120 .stop = ehci_stop,
135 .shutdown = ehci_shutdown, 121 .shutdown = ehci_shutdown,
@@ -160,7 +146,7 @@ static const struct hc_driver ehci_orion_hc_driver = {
160 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, 146 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
161}; 147};
162 148
163static void __devinit 149static void
164ehci_orion_conf_mbus_windows(struct usb_hcd *hcd, 150ehci_orion_conf_mbus_windows(struct usb_hcd *hcd,
165 const struct mbus_dram_target_info *dram) 151 const struct mbus_dram_target_info *dram)
166{ 152{
@@ -181,7 +167,7 @@ ehci_orion_conf_mbus_windows(struct usb_hcd *hcd,
181 } 167 }
182} 168}
183 169
184static int __devinit ehci_orion_drv_probe(struct platform_device *pdev) 170static int ehci_orion_drv_probe(struct platform_device *pdev)
185{ 171{
186 struct orion_ehci_data *pd = pdev->dev.platform_data; 172 struct orion_ehci_data *pd = pdev->dev.platform_data;
187 const struct mbus_dram_target_info *dram; 173 const struct mbus_dram_target_info *dram;
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 2cb7d370c4ef..dabb20494826 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -18,9 +18,18 @@
18 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 19 */
20 20
21#ifndef CONFIG_PCI 21#include <linux/kernel.h>
22#error "This file is PCI bus glue. CONFIG_PCI must be defined." 22#include <linux/module.h>
23#endif 23#include <linux/pci.h>
24#include <linux/usb.h>
25#include <linux/usb/hcd.h>
26
27#include "ehci.h"
28#include "pci-quirks.h"
29
30#define DRIVER_DESC "EHCI PCI platform driver"
31
32static const char hcd_name[] = "ehci-pci";
24 33
25/* defined here to avoid adding to pci_ids.h for single instance use */ 34/* defined here to avoid adding to pci_ids.h for single instance use */
26#define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70 35#define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70
@@ -103,7 +112,6 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
103 } 112 }
104 break; 113 break;
105 case PCI_VENDOR_ID_INTEL: 114 case PCI_VENDOR_ID_INTEL:
106 ehci->fs_i_thresh = 1;
107 if (pdev->device == PCI_DEVICE_ID_INTEL_CE4100_USB) 115 if (pdev->device == PCI_DEVICE_ID_INTEL_CE4100_USB)
108 hcd->has_tt = 1; 116 hcd->has_tt = 1;
109 break; 117 break;
@@ -203,11 +211,6 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
203 break; 211 break;
204 case PCI_VENDOR_ID_INTEL: 212 case PCI_VENDOR_ID_INTEL:
205 ehci->need_io_watchdog = 0; 213 ehci->need_io_watchdog = 0;
206 if (pdev->device == 0x0806 || pdev->device == 0x0811
207 || pdev->device == 0x0829) {
208 ehci_info(ehci, "disable lpm for langwell/penwell\n");
209 ehci->has_lpm = 0;
210 }
211 break; 214 break;
212 case PCI_VENDOR_ID_NVIDIA: 215 case PCI_VENDOR_ID_NVIDIA:
213 switch (pdev->device) { 216 switch (pdev->device) {
@@ -217,8 +220,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
217 * devices with PPCD enabled. 220 * devices with PPCD enabled.
218 */ 221 */
219 case 0x0d9d: 222 case 0x0d9d:
220 ehci_info(ehci, "disable lpm/ppcd for nvidia mcp89"); 223 ehci_info(ehci, "disable ppcd for nvidia mcp89\n");
221 ehci->has_lpm = 0;
222 ehci->has_ppcd = 0; 224 ehci->has_ppcd = 0;
223 ehci->command &= ~CMD_PPCEE; 225 ehci->command &= ~CMD_PPCEE;
224 break; 226 break;
@@ -304,7 +306,6 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
304 ehci_warn(ehci, "selective suspend/wakeup unavailable\n"); 306 ehci_warn(ehci, "selective suspend/wakeup unavailable\n");
305#endif 307#endif
306 308
307 ehci_port_power(ehci, 1);
308 retval = ehci_pci_reinit(ehci, pdev); 309 retval = ehci_pci_reinit(ehci, pdev);
309done: 310done:
310 return retval; 311 return retval;
@@ -323,18 +324,14 @@ done:
323 * Also they depend on separate root hub suspend/resume. 324 * Also they depend on separate root hub suspend/resume.
324 */ 325 */
325 326
326static int ehci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
327{
328 return ehci_suspend(hcd, do_wakeup);
329}
330
331static bool usb_is_intel_switchable_ehci(struct pci_dev *pdev) 327static bool usb_is_intel_switchable_ehci(struct pci_dev *pdev)
332{ 328{
333 return pdev->class == PCI_CLASS_SERIAL_USB_EHCI && 329 return pdev->class == PCI_CLASS_SERIAL_USB_EHCI &&
334 pdev->vendor == PCI_VENDOR_ID_INTEL && 330 pdev->vendor == PCI_VENDOR_ID_INTEL &&
335 (pdev->device == 0x1E26 || 331 (pdev->device == 0x1E26 ||
336 pdev->device == 0x8C2D || 332 pdev->device == 0x8C2D ||
337 pdev->device == 0x8C26); 333 pdev->device == 0x8C26 ||
334 pdev->device == 0x9C26);
338} 335}
339 336
340static void ehci_enable_xhci_companion(void) 337static void ehci_enable_xhci_companion(void)
@@ -378,76 +375,17 @@ static int ehci_pci_resume(struct usb_hcd *hcd, bool hibernated)
378 (void) ehci_pci_reinit(ehci, pdev); 375 (void) ehci_pci_reinit(ehci, pdev);
379 return 0; 376 return 0;
380} 377}
381#endif
382 378
383static int ehci_update_device(struct usb_hcd *hcd, struct usb_device *udev) 379#else
384{
385 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
386 int rc = 0;
387
388 if (!udev->parent) /* udev is root hub itself, impossible */
389 rc = -1;
390 /* we only support lpm device connected to root hub yet */
391 if (ehci->has_lpm && !udev->parent->parent) {
392 rc = ehci_lpm_set_da(ehci, udev->devnum, udev->portnum);
393 if (!rc)
394 rc = ehci_lpm_check(ehci, udev->portnum);
395 }
396 return rc;
397}
398 380
399static const struct hc_driver ehci_pci_hc_driver = { 381#define ehci_suspend NULL
400 .description = hcd_name, 382#define ehci_pci_resume NULL
401 .product_desc = "EHCI Host Controller", 383#endif /* CONFIG_PM */
402 .hcd_priv_size = sizeof(struct ehci_hcd),
403 384
404 /* 385static struct hc_driver __read_mostly ehci_pci_hc_driver;
405 * generic hardware linkage
406 */
407 .irq = ehci_irq,
408 .flags = HCD_MEMORY | HCD_USB2,
409 386
410 /* 387static const struct ehci_driver_overrides pci_overrides __initdata = {
411 * basic lifecycle operations
412 */
413 .reset = ehci_pci_setup, 388 .reset = ehci_pci_setup,
414 .start = ehci_run,
415#ifdef CONFIG_PM
416 .pci_suspend = ehci_pci_suspend,
417 .pci_resume = ehci_pci_resume,
418#endif
419 .stop = ehci_stop,
420 .shutdown = ehci_shutdown,
421
422 /*
423 * managing i/o requests and associated device resources
424 */
425 .urb_enqueue = ehci_urb_enqueue,
426 .urb_dequeue = ehci_urb_dequeue,
427 .endpoint_disable = ehci_endpoint_disable,
428 .endpoint_reset = ehci_endpoint_reset,
429
430 /*
431 * scheduling support
432 */
433 .get_frame_number = ehci_get_frame,
434
435 /*
436 * root hub support
437 */
438 .hub_status_data = ehci_hub_status_data,
439 .hub_control = ehci_hub_control,
440 .bus_suspend = ehci_bus_suspend,
441 .bus_resume = ehci_bus_resume,
442 .relinquish_port = ehci_relinquish_port,
443 .port_handed_over = ehci_port_handed_over,
444
445 /*
446 * call back when device connected and addressed
447 */
448 .update_device = ehci_update_device,
449
450 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
451}; 389};
452 390
453/*-------------------------------------------------------------------------*/ 391/*-------------------------------------------------------------------------*/
@@ -480,3 +418,31 @@ static struct pci_driver ehci_pci_driver = {
480 }, 418 },
481#endif 419#endif
482}; 420};
421
422static int __init ehci_pci_init(void)
423{
424 if (usb_disabled())
425 return -ENODEV;
426
427 pr_info("%s: " DRIVER_DESC "\n", hcd_name);
428
429 ehci_init_driver(&ehci_pci_hc_driver, &pci_overrides);
430
431 /* Entries for the PCI suspend/resume callbacks are special */
432 ehci_pci_hc_driver.pci_suspend = ehci_suspend;
433 ehci_pci_hc_driver.pci_resume = ehci_pci_resume;
434
435 return pci_register_driver(&ehci_pci_driver);
436}
437module_init(ehci_pci_init);
438
439static void __exit ehci_pci_cleanup(void)
440{
441 pci_unregister_driver(&ehci_pci_driver);
442}
443module_exit(ehci_pci_cleanup);
444
445MODULE_DESCRIPTION(DRIVER_DESC);
446MODULE_AUTHOR("David Brownell");
447MODULE_AUTHOR("Alan Stern");
448MODULE_LICENSE("GPL");
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index 764e0100b6f4..58fa0c90c7c7 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -18,9 +18,21 @@
18 * 18 *
19 * Licensed under the GNU/GPL. See COPYING for details. 19 * Licensed under the GNU/GPL. See COPYING for details.
20 */ 20 */
21#include <linux/kernel.h>
22#include <linux/hrtimer.h>
23#include <linux/io.h>
24#include <linux/module.h>
21#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/usb.h>
27#include <linux/usb/hcd.h>
22#include <linux/usb/ehci_pdriver.h> 28#include <linux/usb/ehci_pdriver.h>
23 29
30#include "ehci.h"
31
32#define DRIVER_DESC "EHCI generic platform driver"
33
34static const char hcd_name[] = "ehci-platform";
35
24static int ehci_platform_reset(struct usb_hcd *hcd) 36static int ehci_platform_reset(struct usb_hcd *hcd)
25{ 37{
26 struct platform_device *pdev = to_platform_device(hcd->self.controller); 38 struct platform_device *pdev = to_platform_device(hcd->self.controller);
@@ -38,47 +50,18 @@ static int ehci_platform_reset(struct usb_hcd *hcd)
38 if (retval) 50 if (retval)
39 return retval; 51 return retval;
40 52
41 if (pdata->port_power_on) 53 if (pdata->no_io_watchdog)
42 ehci_port_power(ehci, 1); 54 ehci->need_io_watchdog = 0;
43 if (pdata->port_power_off)
44 ehci_port_power(ehci, 0);
45
46 return 0; 55 return 0;
47} 56}
48 57
49static const struct hc_driver ehci_platform_hc_driver = { 58static struct hc_driver __read_mostly ehci_platform_hc_driver;
50 .description = hcd_name,
51 .product_desc = "Generic Platform EHCI Controller",
52 .hcd_priv_size = sizeof(struct ehci_hcd),
53
54 .irq = ehci_irq,
55 .flags = HCD_MEMORY | HCD_USB2,
56
57 .reset = ehci_platform_reset,
58 .start = ehci_run,
59 .stop = ehci_stop,
60 .shutdown = ehci_shutdown,
61
62 .urb_enqueue = ehci_urb_enqueue,
63 .urb_dequeue = ehci_urb_dequeue,
64 .endpoint_disable = ehci_endpoint_disable,
65 .endpoint_reset = ehci_endpoint_reset,
66 59
67 .get_frame_number = ehci_get_frame, 60static const struct ehci_driver_overrides platform_overrides __initdata = {
68 61 .reset = ehci_platform_reset,
69 .hub_status_data = ehci_hub_status_data,
70 .hub_control = ehci_hub_control,
71#if defined(CONFIG_PM)
72 .bus_suspend = ehci_bus_suspend,
73 .bus_resume = ehci_bus_resume,
74#endif
75 .relinquish_port = ehci_relinquish_port,
76 .port_handed_over = ehci_port_handed_over,
77
78 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
79}; 62};
80 63
81static int __devinit ehci_platform_probe(struct platform_device *dev) 64static int ehci_platform_probe(struct platform_device *dev)
82{ 65{
83 struct usb_hcd *hcd; 66 struct usb_hcd *hcd;
84 struct resource *res_mem; 67 struct resource *res_mem;
@@ -96,12 +79,12 @@ static int __devinit ehci_platform_probe(struct platform_device *dev)
96 79
97 irq = platform_get_irq(dev, 0); 80 irq = platform_get_irq(dev, 0);
98 if (irq < 0) { 81 if (irq < 0) {
99 pr_err("no irq provided"); 82 dev_err(&dev->dev, "no irq provided");
100 return irq; 83 return irq;
101 } 84 }
102 res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0); 85 res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
103 if (!res_mem) { 86 if (!res_mem) {
104 pr_err("no memory recourse provided"); 87 dev_err(&dev->dev, "no memory resource provided");
105 return -ENXIO; 88 return -ENXIO;
106 } 89 }
107 90
@@ -121,29 +104,19 @@ static int __devinit ehci_platform_probe(struct platform_device *dev)
121 hcd->rsrc_start = res_mem->start; 104 hcd->rsrc_start = res_mem->start;
122 hcd->rsrc_len = resource_size(res_mem); 105 hcd->rsrc_len = resource_size(res_mem);
123 106
124 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 107 hcd->regs = devm_request_and_ioremap(&dev->dev, res_mem);
125 pr_err("controller already in use");
126 err = -EBUSY;
127 goto err_put_hcd;
128 }
129
130 hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
131 if (!hcd->regs) { 108 if (!hcd->regs) {
132 err = -ENOMEM; 109 err = -ENOMEM;
133 goto err_release_region; 110 goto err_put_hcd;
134 } 111 }
135 err = usb_add_hcd(hcd, irq, IRQF_SHARED); 112 err = usb_add_hcd(hcd, irq, IRQF_SHARED);
136 if (err) 113 if (err)
137 goto err_iounmap; 114 goto err_put_hcd;
138 115
139 platform_set_drvdata(dev, hcd); 116 platform_set_drvdata(dev, hcd);
140 117
141 return err; 118 return err;
142 119
143err_iounmap:
144 iounmap(hcd->regs);
145err_release_region:
146 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
147err_put_hcd: 120err_put_hcd:
148 usb_put_hcd(hcd); 121 usb_put_hcd(hcd);
149err_power: 122err_power:
@@ -153,14 +126,12 @@ err_power:
153 return err; 126 return err;
154} 127}
155 128
156static int __devexit ehci_platform_remove(struct platform_device *dev) 129static int ehci_platform_remove(struct platform_device *dev)
157{ 130{
158 struct usb_hcd *hcd = platform_get_drvdata(dev); 131 struct usb_hcd *hcd = platform_get_drvdata(dev);
159 struct usb_ehci_pdata *pdata = dev->dev.platform_data; 132 struct usb_ehci_pdata *pdata = dev->dev.platform_data;
160 133
161 usb_remove_hcd(hcd); 134 usb_remove_hcd(hcd);
162 iounmap(hcd->regs);
163 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
164 usb_put_hcd(hcd); 135 usb_put_hcd(hcd);
165 platform_set_drvdata(dev, NULL); 136 platform_set_drvdata(dev, NULL);
166 137
@@ -225,7 +196,7 @@ static const struct dev_pm_ops ehci_platform_pm_ops = {
225static struct platform_driver ehci_platform_driver = { 196static struct platform_driver ehci_platform_driver = {
226 .id_table = ehci_platform_table, 197 .id_table = ehci_platform_table,
227 .probe = ehci_platform_probe, 198 .probe = ehci_platform_probe,
228 .remove = __devexit_p(ehci_platform_remove), 199 .remove = ehci_platform_remove,
229 .shutdown = usb_hcd_platform_shutdown, 200 .shutdown = usb_hcd_platform_shutdown,
230 .driver = { 201 .driver = {
231 .owner = THIS_MODULE, 202 .owner = THIS_MODULE,
@@ -233,3 +204,26 @@ static struct platform_driver ehci_platform_driver = {
233 .pm = &ehci_platform_pm_ops, 204 .pm = &ehci_platform_pm_ops,
234 } 205 }
235}; 206};
207
208static int __init ehci_platform_init(void)
209{
210 if (usb_disabled())
211 return -ENODEV;
212
213 pr_info("%s: " DRIVER_DESC "\n", hcd_name);
214
215 ehci_init_driver(&ehci_platform_hc_driver, &platform_overrides);
216 return platform_driver_register(&ehci_platform_driver);
217}
218module_init(ehci_platform_init);
219
220static void __exit ehci_platform_cleanup(void)
221{
222 platform_driver_unregister(&ehci_platform_driver);
223}
224module_exit(ehci_platform_cleanup);
225
226MODULE_DESCRIPTION(DRIVER_DESC);
227MODULE_AUTHOR("Hauke Mehrtens");
228MODULE_AUTHOR("Alan Stern");
229MODULE_LICENSE("GPL");
diff --git a/drivers/usb/host/ehci-pmcmsp.c b/drivers/usb/host/ehci-pmcmsp.c
index 087aee2a904f..363890ee41d2 100644
--- a/drivers/usb/host/ehci-pmcmsp.c
+++ b/drivers/usb/host/ehci-pmcmsp.c
@@ -90,7 +90,6 @@ static int ehci_msp_setup(struct usb_hcd *hcd)
90 return retval; 90 return retval;
91 91
92 usb_hcd_tdi_set_mode(ehci); 92 usb_hcd_tdi_set_mode(ehci);
93 ehci_port_power(ehci, 0);
94 93
95 return retval; 94 return retval;
96} 95}
diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c
index fa937d05a02b..45aceefd0c2b 100644
--- a/drivers/usb/host/ehci-ppc-of.c
+++ b/drivers/usb/host/ehci-ppc-of.c
@@ -71,7 +71,7 @@ static const struct hc_driver ehci_ppc_of_hc_driver = {
71 * Fix: Enable Break Memory Transfer (BMT) in INSNREG3 71 * Fix: Enable Break Memory Transfer (BMT) in INSNREG3
72 */ 72 */
73#define PPC440EPX_EHCI0_INSREG_BMT (0x1 << 0) 73#define PPC440EPX_EHCI0_INSREG_BMT (0x1 << 0)
74static int __devinit 74static int
75ppc44x_enable_bmt(struct device_node *dn) 75ppc44x_enable_bmt(struct device_node *dn)
76{ 76{
77 __iomem u32 *insreg_virt; 77 __iomem u32 *insreg_virt;
@@ -87,7 +87,7 @@ ppc44x_enable_bmt(struct device_node *dn)
87} 87}
88 88
89 89
90static int __devinit ehci_hcd_ppc_of_probe(struct platform_device *op) 90static int ehci_hcd_ppc_of_probe(struct platform_device *op)
91{ 91{
92 struct device_node *dn = op->dev.of_node; 92 struct device_node *dn = op->dev.of_node;
93 struct usb_hcd *hcd; 93 struct usb_hcd *hcd;
diff --git a/drivers/usb/host/ehci-ps3.c b/drivers/usb/host/ehci-ps3.c
index 45a356e9f138..df5925a4f0db 100644
--- a/drivers/usb/host/ehci-ps3.c
+++ b/drivers/usb/host/ehci-ps3.c
@@ -93,7 +93,7 @@ static const struct hc_driver ps3_ehci_hc_driver = {
93 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, 93 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
94}; 94};
95 95
96static int __devinit ps3_ehci_probe(struct ps3_system_bus_device *dev) 96static int ps3_ehci_probe(struct ps3_system_bus_device *dev)
97{ 97{
98 int result; 98 int result;
99 struct usb_hcd *hcd; 99 struct usb_hcd *hcd;
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 4b66374bdc8e..3d989028c836 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -264,15 +264,9 @@ ehci_urb_done(struct ehci_hcd *ehci, struct urb *urb, int status)
264__releases(ehci->lock) 264__releases(ehci->lock)
265__acquires(ehci->lock) 265__acquires(ehci->lock)
266{ 266{
267 if (likely (urb->hcpriv != NULL)) { 267 if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) {
268 struct ehci_qh *qh = (struct ehci_qh *) urb->hcpriv; 268 /* ... update hc-wide periodic stats */
269 269 ehci_to_hcd(ehci)->self.bandwidth_int_reqs--;
270 /* S-mask in a QH means it's an interrupt urb */
271 if ((qh->hw->hw_info2 & cpu_to_hc32(ehci, QH_SMASK)) != 0) {
272
273 /* ... update hc-wide periodic stats (for usbfs) */
274 ehci_to_hcd(ehci)->self.bandwidth_int_reqs--;
275 }
276 } 270 }
277 271
278 if (unlikely(urb->unlinked)) { 272 if (unlikely(urb->unlinked)) {
diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
index 85b74be202eb..319dcfaa8735 100644
--- a/drivers/usb/host/ehci-s5p.c
+++ b/drivers/usb/host/ehci-s5p.c
@@ -85,7 +85,7 @@ static void s5p_setup_vbus_gpio(struct platform_device *pdev)
85 85
86static u64 ehci_s5p_dma_mask = DMA_BIT_MASK(32); 86static u64 ehci_s5p_dma_mask = DMA_BIT_MASK(32);
87 87
88static int __devinit s5p_ehci_probe(struct platform_device *pdev) 88static int s5p_ehci_probe(struct platform_device *pdev)
89{ 89{
90 struct s5p_ehci_platdata *pdata; 90 struct s5p_ehci_platdata *pdata;
91 struct s5p_ehci_hcd *s5p_ehci; 91 struct s5p_ehci_hcd *s5p_ehci;
@@ -136,7 +136,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
136 goto fail_clk; 136 goto fail_clk;
137 } 137 }
138 138
139 err = clk_enable(s5p_ehci->clk); 139 err = clk_prepare_enable(s5p_ehci->clk);
140 if (err) 140 if (err)
141 goto fail_clk; 141 goto fail_clk;
142 142
@@ -183,13 +183,13 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
183 return 0; 183 return 0;
184 184
185fail_io: 185fail_io:
186 clk_disable(s5p_ehci->clk); 186 clk_disable_unprepare(s5p_ehci->clk);
187fail_clk: 187fail_clk:
188 usb_put_hcd(hcd); 188 usb_put_hcd(hcd);
189 return err; 189 return err;
190} 190}
191 191
192static int __devexit s5p_ehci_remove(struct platform_device *pdev) 192static int s5p_ehci_remove(struct platform_device *pdev)
193{ 193{
194 struct s5p_ehci_platdata *pdata = pdev->dev.platform_data; 194 struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
195 struct s5p_ehci_hcd *s5p_ehci = platform_get_drvdata(pdev); 195 struct s5p_ehci_hcd *s5p_ehci = platform_get_drvdata(pdev);
@@ -200,7 +200,7 @@ static int __devexit s5p_ehci_remove(struct platform_device *pdev)
200 if (pdata && pdata->phy_exit) 200 if (pdata && pdata->phy_exit)
201 pdata->phy_exit(pdev, S5P_USB_PHY_HOST); 201 pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
202 202
203 clk_disable(s5p_ehci->clk); 203 clk_disable_unprepare(s5p_ehci->clk);
204 204
205 usb_put_hcd(hcd); 205 usb_put_hcd(hcd);
206 206
@@ -231,7 +231,7 @@ static int s5p_ehci_suspend(struct device *dev)
231 if (pdata && pdata->phy_exit) 231 if (pdata && pdata->phy_exit)
232 pdata->phy_exit(pdev, S5P_USB_PHY_HOST); 232 pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
233 233
234 clk_disable(s5p_ehci->clk); 234 clk_disable_unprepare(s5p_ehci->clk);
235 235
236 return rc; 236 return rc;
237} 237}
@@ -243,7 +243,7 @@ static int s5p_ehci_resume(struct device *dev)
243 struct platform_device *pdev = to_platform_device(dev); 243 struct platform_device *pdev = to_platform_device(dev);
244 struct s5p_ehci_platdata *pdata = pdev->dev.platform_data; 244 struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
245 245
246 clk_enable(s5p_ehci->clk); 246 clk_prepare_enable(s5p_ehci->clk);
247 247
248 if (pdata && pdata->phy_init) 248 if (pdata && pdata->phy_init)
249 pdata->phy_init(pdev, S5P_USB_PHY_HOST); 249 pdata->phy_init(pdev, S5P_USB_PHY_HOST);
@@ -274,7 +274,7 @@ MODULE_DEVICE_TABLE(of, exynos_ehci_match);
274 274
275static struct platform_driver s5p_ehci_driver = { 275static struct platform_driver s5p_ehci_driver = {
276 .probe = s5p_ehci_probe, 276 .probe = s5p_ehci_probe,
277 .remove = __devexit_p(s5p_ehci_remove), 277 .remove = s5p_ehci_remove,
278 .shutdown = s5p_ehci_shutdown, 278 .shutdown = s5p_ehci_shutdown,
279 .driver = { 279 .driver = {
280 .name = "s5p-ehci", 280 .name = "s5p-ehci",
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index 7cf3da7babf0..69ebee73c0c1 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -36,29 +36,6 @@
36 36
37static int ehci_get_frame (struct usb_hcd *hcd); 37static int ehci_get_frame (struct usb_hcd *hcd);
38 38
39#ifdef CONFIG_PCI
40
41static unsigned ehci_read_frame_index(struct ehci_hcd *ehci)
42{
43 unsigned uf;
44
45 /*
46 * The MosChip MCS9990 controller updates its microframe counter
47 * a little before the frame counter, and occasionally we will read
48 * the invalid intermediate value. Avoid problems by checking the
49 * microframe number (the low-order 3 bits); if they are 0 then
50 * re-read the register to get the correct value.
51 */
52 uf = ehci_readl(ehci, &ehci->regs->frame_index);
53 if (unlikely(ehci->frame_index_bug && ((uf & 7) == 0)))
54 uf = ehci_readl(ehci, &ehci->regs->frame_index);
55 return uf;
56}
57
58#endif
59
60/*-------------------------------------------------------------------------*/
61
62/* 39/*
63 * periodic_next_shadow - return "next" pointer on shadow list 40 * periodic_next_shadow - return "next" pointer on shadow list
64 * @periodic: host pointer to qh/itd/sitd 41 * @periodic: host pointer to qh/itd/sitd
@@ -1361,7 +1338,7 @@ sitd_slot_ok (
1361 * given EHCI_TUNE_FLS and the slop). Or, write a smarter scheduler! 1338 * given EHCI_TUNE_FLS and the slop). Or, write a smarter scheduler!
1362 */ 1339 */
1363 1340
1364#define SCHEDULE_SLOP 80 /* microframes */ 1341#define SCHEDULING_DELAY 40 /* microframes */
1365 1342
1366static int 1343static int
1367iso_stream_schedule ( 1344iso_stream_schedule (
@@ -1370,7 +1347,7 @@ iso_stream_schedule (
1370 struct ehci_iso_stream *stream 1347 struct ehci_iso_stream *stream
1371) 1348)
1372{ 1349{
1373 u32 now, next, start, period, span; 1350 u32 now, base, next, start, period, span;
1374 int status; 1351 int status;
1375 unsigned mod = ehci->periodic_size << 3; 1352 unsigned mod = ehci->periodic_size << 3;
1376 struct ehci_iso_sched *sched = urb->hcpriv; 1353 struct ehci_iso_sched *sched = urb->hcpriv;
@@ -1382,62 +1359,72 @@ iso_stream_schedule (
1382 span <<= 3; 1359 span <<= 3;
1383 } 1360 }
1384 1361
1385 if (span > mod - SCHEDULE_SLOP) {
1386 ehci_dbg (ehci, "iso request %p too long\n", urb);
1387 status = -EFBIG;
1388 goto fail;
1389 }
1390
1391 now = ehci_read_frame_index(ehci) & (mod - 1); 1362 now = ehci_read_frame_index(ehci) & (mod - 1);
1392 1363
1393 /* Typical case: reuse current schedule, stream is still active. 1364 /* Typical case: reuse current schedule, stream is still active.
1394 * Hopefully there are no gaps from the host falling behind 1365 * Hopefully there are no gaps from the host falling behind
1395 * (irq delays etc), but if there are we'll take the next 1366 * (irq delays etc). If there are, the behavior depends on
1396 * slot in the schedule, implicitly assuming URB_ISO_ASAP. 1367 * whether URB_ISO_ASAP is set.
1397 */ 1368 */
1398 if (likely (!list_empty (&stream->td_list))) { 1369 if (likely (!list_empty (&stream->td_list))) {
1399 u32 excess;
1400 1370
1401 /* For high speed devices, allow scheduling within the 1371 /* Take the isochronous scheduling threshold into account */
1402 * isochronous scheduling threshold. For full speed devices 1372 if (ehci->i_thresh)
1403 * and Intel PCI-based controllers, don't (work around for 1373 next = now + ehci->i_thresh; /* uframe cache */
1404 * Intel ICH9 bug).
1405 */
1406 if (!stream->highspeed && ehci->fs_i_thresh)
1407 next = now + ehci->i_thresh;
1408 else 1374 else
1409 next = now; 1375 next = (now + 2 + 7) & ~0x07; /* full frame cache */
1410 1376
1411 /* Fell behind (by up to twice the slop amount)? 1377 /*
1412 * We decide based on the time of the last currently-scheduled 1378 * Use ehci->last_iso_frame as the base. There can't be any
1413 * slot, not the time of the next available slot. 1379 * TDs scheduled for earlier than that.
1414 */ 1380 */
1415 excess = (stream->next_uframe - period - next) & (mod - 1); 1381 base = ehci->last_iso_frame << 3;
1416 if (excess >= mod - 2 * SCHEDULE_SLOP) 1382 next = (next - base) & (mod - 1);
1417 start = next + excess - mod + period * 1383 start = (stream->next_uframe - base) & (mod - 1);
1418 DIV_ROUND_UP(mod - excess, period); 1384
1419 else 1385 /* Is the schedule already full? */
1420 start = next + excess + period; 1386 if (unlikely(start < period)) {
1421 if (start - now >= mod) { 1387 ehci_dbg(ehci, "iso sched full %p (%u-%u < %u mod %u)\n",
1422 ehci_dbg(ehci, "request %p would overflow (%d+%d >= %d)\n", 1388 urb, stream->next_uframe, base,
1423 urb, start - now - period, period, 1389 period, mod);
1424 mod); 1390 status = -ENOSPC;
1425 status = -EFBIG;
1426 goto fail; 1391 goto fail;
1427 } 1392 }
1393
1394 /* Behind the scheduling threshold? */
1395 if (unlikely(start < next)) {
1396
1397 /* USB_ISO_ASAP: Round up to the first available slot */
1398 if (urb->transfer_flags & URB_ISO_ASAP)
1399 start += (next - start + period - 1) & -period;
1400
1401 /*
1402 * Not ASAP: Use the next slot in the stream. If
1403 * the entire URB falls before the threshold, fail.
1404 */
1405 else if (start + span - period < next) {
1406 ehci_dbg(ehci, "iso urb late %p (%u+%u < %u)\n",
1407 urb, start + base,
1408 span - period, next + base);
1409 status = -EXDEV;
1410 goto fail;
1411 }
1412 }
1413
1414 start += base;
1428 } 1415 }
1429 1416
1430 /* need to schedule; when's the next (u)frame we could start? 1417 /* need to schedule; when's the next (u)frame we could start?
1431 * this is bigger than ehci->i_thresh allows; scheduling itself 1418 * this is bigger than ehci->i_thresh allows; scheduling itself
1432 * isn't free, the slop should handle reasonably slow cpus. it 1419 * isn't free, the delay should handle reasonably slow cpus. it
1433 * can also help high bandwidth if the dma and irq loads don't 1420 * can also help high bandwidth if the dma and irq loads don't
1434 * jump until after the queue is primed. 1421 * jump until after the queue is primed.
1435 */ 1422 */
1436 else { 1423 else {
1437 int done = 0; 1424 int done = 0;
1438 start = SCHEDULE_SLOP + (now & ~0x07);
1439 1425
1440 /* NOTE: assumes URB_ISO_ASAP, to limit complexity/bugs */ 1426 base = now & ~0x07;
1427 start = base + SCHEDULING_DELAY;
1441 1428
1442 /* find a uframe slot with enough bandwidth. 1429 /* find a uframe slot with enough bandwidth.
1443 * Early uframes are more precious because full-speed 1430 * Early uframes are more precious because full-speed
@@ -1464,19 +1451,16 @@ iso_stream_schedule (
1464 1451
1465 /* no room in the schedule */ 1452 /* no room in the schedule */
1466 if (!done) { 1453 if (!done) {
1467 ehci_dbg(ehci, "iso resched full %p (now %d max %d)\n", 1454 ehci_dbg(ehci, "iso sched full %p", urb);
1468 urb, now, now + mod);
1469 status = -ENOSPC; 1455 status = -ENOSPC;
1470 goto fail; 1456 goto fail;
1471 } 1457 }
1472 } 1458 }
1473 1459
1474 /* Tried to schedule too far into the future? */ 1460 /* Tried to schedule too far into the future? */
1475 if (unlikely(start - now + span - period 1461 if (unlikely(start - base + span - period >= mod)) {
1476 >= mod - 2 * SCHEDULE_SLOP)) { 1462 ehci_dbg(ehci, "request %p would overflow (%u+%u >= %u)\n",
1477 ehci_dbg(ehci, "request %p would overflow (%d+%d >= %d)\n", 1463 urb, start - base, span - period, mod);
1478 urb, start - now, span - period,
1479 mod - 2 * SCHEDULE_SLOP);
1480 status = -EFBIG; 1464 status = -EFBIG;
1481 goto fail; 1465 goto fail;
1482 } 1466 }
@@ -1490,7 +1474,7 @@ iso_stream_schedule (
1490 1474
1491 /* Make sure scan_isoc() sees these */ 1475 /* Make sure scan_isoc() sees these */
1492 if (ehci->isoc_count == 0) 1476 if (ehci->isoc_count == 0)
1493 ehci->next_frame = now >> 3; 1477 ehci->last_iso_frame = now >> 3;
1494 return 0; 1478 return 0;
1495 1479
1496 fail: 1480 fail:
@@ -1646,7 +1630,7 @@ static void itd_link_urb(
1646 1630
1647 /* don't need that schedule data any more */ 1631 /* don't need that schedule data any more */
1648 iso_sched_free (stream, iso_sched); 1632 iso_sched_free (stream, iso_sched);
1649 urb->hcpriv = NULL; 1633 urb->hcpriv = stream;
1650 1634
1651 ++ehci->isoc_count; 1635 ++ehci->isoc_count;
1652 enable_periodic(ehci); 1636 enable_periodic(ehci);
@@ -1708,7 +1692,7 @@ static bool itd_complete(struct ehci_hcd *ehci, struct ehci_itd *itd)
1708 urb->actual_length += desc->actual_length; 1692 urb->actual_length += desc->actual_length;
1709 } else { 1693 } else {
1710 /* URB was too late */ 1694 /* URB was too late */
1711 desc->status = -EXDEV; 1695 urb->error_count++;
1712 } 1696 }
1713 } 1697 }
1714 1698
@@ -2045,7 +2029,7 @@ static void sitd_link_urb(
2045 2029
2046 /* don't need that schedule data any more */ 2030 /* don't need that schedule data any more */
2047 iso_sched_free (stream, sched); 2031 iso_sched_free (stream, sched);
2048 urb->hcpriv = NULL; 2032 urb->hcpriv = stream;
2049 2033
2050 ++ehci->isoc_count; 2034 ++ehci->isoc_count;
2051 enable_periodic(ehci); 2035 enable_periodic(ehci);
@@ -2081,7 +2065,7 @@ static bool sitd_complete(struct ehci_hcd *ehci, struct ehci_sitd *sitd)
2081 t = hc32_to_cpup(ehci, &sitd->hw_results); 2065 t = hc32_to_cpup(ehci, &sitd->hw_results);
2082 2066
2083 /* report transfer status */ 2067 /* report transfer status */
2084 if (t & SITD_ERRS) { 2068 if (unlikely(t & SITD_ERRS)) {
2085 urb->error_count++; 2069 urb->error_count++;
2086 if (t & SITD_STS_DBE) 2070 if (t & SITD_STS_DBE)
2087 desc->status = usb_pipein (urb->pipe) 2071 desc->status = usb_pipein (urb->pipe)
@@ -2091,6 +2075,9 @@ static bool sitd_complete(struct ehci_hcd *ehci, struct ehci_sitd *sitd)
2091 desc->status = -EOVERFLOW; 2075 desc->status = -EOVERFLOW;
2092 else /* XACT, MMF, etc */ 2076 else /* XACT, MMF, etc */
2093 desc->status = -EPROTO; 2077 desc->status = -EPROTO;
2078 } else if (unlikely(t & SITD_STS_ACTIVE)) {
2079 /* URB was too late */
2080 urb->error_count++;
2094 } else { 2081 } else {
2095 desc->status = 0; 2082 desc->status = 0;
2096 desc->actual_length = desc->length - SITD_LENGTH(t); 2083 desc->actual_length = desc->length - SITD_LENGTH(t);
@@ -2220,16 +2207,16 @@ static void scan_isoc(struct ehci_hcd *ehci)
2220 now_frame = (uf >> 3) & fmask; 2207 now_frame = (uf >> 3) & fmask;
2221 live = true; 2208 live = true;
2222 } else { 2209 } else {
2223 now_frame = (ehci->next_frame - 1) & fmask; 2210 now_frame = (ehci->last_iso_frame - 1) & fmask;
2224 live = false; 2211 live = false;
2225 } 2212 }
2226 ehci->now_frame = now_frame; 2213 ehci->now_frame = now_frame;
2227 2214
2228 frame = ehci->next_frame;
2229 for (;;) { 2215 for (;;) {
2230 union ehci_shadow q, *q_p; 2216 union ehci_shadow q, *q_p;
2231 __hc32 type, *hw_p; 2217 __hc32 type, *hw_p;
2232 2218
2219 frame = ehci->last_iso_frame;
2233restart: 2220restart:
2234 /* scan each element in frame's queue for completions */ 2221 /* scan each element in frame's queue for completions */
2235 q_p = &ehci->pshadow [frame]; 2222 q_p = &ehci->pshadow [frame];
@@ -2334,7 +2321,6 @@ restart:
2334 /* Stop when we have reached the current frame */ 2321 /* Stop when we have reached the current frame */
2335 if (frame == now_frame) 2322 if (frame == now_frame)
2336 break; 2323 break;
2337 frame = (frame + 1) & fmask; 2324 ehci->last_iso_frame = (frame + 1) & fmask;
2338 } 2325 }
2339 ehci->next_frame = now_frame;
2340} 2326}
diff --git a/drivers/usb/host/ehci-sh.c b/drivers/usb/host/ehci-sh.c
index 6081e1ed3ac9..0c90a24fa989 100644
--- a/drivers/usb/host/ehci-sh.c
+++ b/drivers/usb/host/ehci-sh.c
@@ -21,17 +21,10 @@ struct ehci_sh_priv {
21static int ehci_sh_reset(struct usb_hcd *hcd) 21static int ehci_sh_reset(struct usb_hcd *hcd)
22{ 22{
23 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 23 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
24 int ret;
25 24
26 ehci->caps = hcd->regs; 25 ehci->caps = hcd->regs;
27 26
28 ret = ehci_setup(hcd); 27 return ehci_setup(hcd);
29 if (unlikely(ret))
30 return ret;
31
32 ehci_port_power(ehci, 0);
33
34 return ret;
35} 28}
36 29
37static const struct hc_driver ehci_sh_hc_driver = { 30static const struct hc_driver ehci_sh_hc_driver = {
diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c
index c718a065e154..466c1bb5b967 100644
--- a/drivers/usb/host/ehci-spear.c
+++ b/drivers/usb/host/ehci-spear.c
@@ -37,18 +37,11 @@ static void spear_stop_ehci(struct spear_ehci *ehci)
37static int ehci_spear_setup(struct usb_hcd *hcd) 37static int ehci_spear_setup(struct usb_hcd *hcd)
38{ 38{
39 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 39 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
40 int retval = 0;
41 40
42 /* registers start at offset 0x0 */ 41 /* registers start at offset 0x0 */
43 ehci->caps = hcd->regs; 42 ehci->caps = hcd->regs;
44 43
45 retval = ehci_setup(hcd); 44 return ehci_setup(hcd);
46 if (retval)
47 return retval;
48
49 ehci_port_power(ehci, 0);
50
51 return retval;
52} 45}
53 46
54static const struct hc_driver ehci_spear_hc_driver = { 47static const struct hc_driver ehci_spear_hc_driver = {
@@ -116,8 +109,6 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
116 struct clk *usbh_clk; 109 struct clk *usbh_clk;
117 const struct hc_driver *driver = &ehci_spear_hc_driver; 110 const struct hc_driver *driver = &ehci_spear_hc_driver;
118 int irq, retval; 111 int irq, retval;
119 char clk_name[20] = "usbh_clk";
120 static int instance = -1;
121 112
122 if (usb_disabled()) 113 if (usb_disabled())
123 return -ENODEV; 114 return -ENODEV;
@@ -125,7 +116,7 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
125 irq = platform_get_irq(pdev, 0); 116 irq = platform_get_irq(pdev, 0);
126 if (irq < 0) { 117 if (irq < 0) {
127 retval = irq; 118 retval = irq;
128 goto fail_irq_get; 119 goto fail;
129 } 120 }
130 121
131 /* 122 /*
@@ -136,47 +127,38 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
136 if (!pdev->dev.dma_mask) 127 if (!pdev->dev.dma_mask)
137 pdev->dev.dma_mask = &spear_ehci_dma_mask; 128 pdev->dev.dma_mask = &spear_ehci_dma_mask;
138 129
139 /* 130 usbh_clk = devm_clk_get(&pdev->dev, NULL);
140 * Increment the device instance, when probing via device-tree
141 */
142 if (pdev->id < 0)
143 instance++;
144 else
145 instance = pdev->id;
146 sprintf(clk_name, "usbh.%01d_clk", instance);
147
148 usbh_clk = clk_get(NULL, clk_name);
149 if (IS_ERR(usbh_clk)) { 131 if (IS_ERR(usbh_clk)) {
150 dev_err(&pdev->dev, "Error getting interface clock\n"); 132 dev_err(&pdev->dev, "Error getting interface clock\n");
151 retval = PTR_ERR(usbh_clk); 133 retval = PTR_ERR(usbh_clk);
152 goto fail_get_usbh_clk; 134 goto fail;
153 } 135 }
154 136
155 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); 137 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
156 if (!hcd) { 138 if (!hcd) {
157 retval = -ENOMEM; 139 retval = -ENOMEM;
158 goto fail_create_hcd; 140 goto fail;
159 } 141 }
160 142
161 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 143 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
162 if (!res) { 144 if (!res) {
163 retval = -ENODEV; 145 retval = -ENODEV;
164 goto fail_request_resource; 146 goto err_put_hcd;
165 } 147 }
166 148
167 hcd->rsrc_start = res->start; 149 hcd->rsrc_start = res->start;
168 hcd->rsrc_len = resource_size(res); 150 hcd->rsrc_len = resource_size(res);
169 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, 151 if (!devm_request_mem_region(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len,
170 driver->description)) { 152 driver->description)) {
171 retval = -EBUSY; 153 retval = -EBUSY;
172 goto fail_request_resource; 154 goto err_put_hcd;
173 } 155 }
174 156
175 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 157 hcd->regs = devm_ioremap(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len);
176 if (hcd->regs == NULL) { 158 if (hcd->regs == NULL) {
177 dev_dbg(&pdev->dev, "error mapping memory\n"); 159 dev_dbg(&pdev->dev, "error mapping memory\n");
178 retval = -ENOMEM; 160 retval = -ENOMEM;
179 goto fail_ioremap; 161 goto err_put_hcd;
180 } 162 }
181 163
182 ehci = (struct spear_ehci *)hcd_to_ehci(hcd); 164 ehci = (struct spear_ehci *)hcd_to_ehci(hcd);
@@ -185,21 +167,15 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
185 spear_start_ehci(ehci); 167 spear_start_ehci(ehci);
186 retval = usb_add_hcd(hcd, irq, IRQF_SHARED); 168 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
187 if (retval) 169 if (retval)
188 goto fail_add_hcd; 170 goto err_stop_ehci;
189 171
190 return retval; 172 return retval;
191 173
192fail_add_hcd: 174err_stop_ehci:
193 spear_stop_ehci(ehci); 175 spear_stop_ehci(ehci);
194 iounmap(hcd->regs); 176err_put_hcd:
195fail_ioremap:
196 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
197fail_request_resource:
198 usb_put_hcd(hcd); 177 usb_put_hcd(hcd);
199fail_create_hcd: 178fail:
200 clk_put(usbh_clk);
201fail_get_usbh_clk:
202fail_irq_get:
203 dev_err(&pdev->dev, "init fail, %d\n", retval); 179 dev_err(&pdev->dev, "init fail, %d\n", retval);
204 180
205 return retval ; 181 return retval ;
@@ -218,17 +194,12 @@ static int spear_ehci_hcd_drv_remove(struct platform_device *pdev)
218 194
219 if (ehci_p->clk) 195 if (ehci_p->clk)
220 spear_stop_ehci(ehci_p); 196 spear_stop_ehci(ehci_p);
221 iounmap(hcd->regs);
222 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
223 usb_put_hcd(hcd); 197 usb_put_hcd(hcd);
224 198
225 if (ehci_p->clk)
226 clk_put(ehci_p->clk);
227
228 return 0; 199 return 0;
229} 200}
230 201
231static struct of_device_id spear_ehci_id_table[] __devinitdata = { 202static struct of_device_id spear_ehci_id_table[] = {
232 { .compatible = "st,spear600-ehci", }, 203 { .compatible = "st,spear600-ehci", },
233 { }, 204 { },
234}; 205};
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 6223d1757848..acf17556bd87 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -28,7 +28,10 @@
28#include <linux/pm_runtime.h> 28#include <linux/pm_runtime.h>
29 29
30#include <linux/usb/tegra_usb_phy.h> 30#include <linux/usb/tegra_usb_phy.h>
31#include <mach/iomap.h> 31
32#define TEGRA_USB_BASE 0xC5000000
33#define TEGRA_USB2_BASE 0xC5004000
34#define TEGRA_USB3_BASE 0xC5008000
32 35
33#define TEGRA_USB_DMA_ALIGN 32 36#define TEGRA_USB_DMA_ALIGN 32
34 37
@@ -277,7 +280,6 @@ static void tegra_ehci_shutdown(struct usb_hcd *hcd)
277static int tegra_ehci_setup(struct usb_hcd *hcd) 280static int tegra_ehci_setup(struct usb_hcd *hcd)
278{ 281{
279 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 282 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
280 int retval;
281 283
282 /* EHCI registers start at offset 0x100 */ 284 /* EHCI registers start at offset 0x100 */
283 ehci->caps = hcd->regs + 0x100; 285 ehci->caps = hcd->regs + 0x100;
@@ -285,12 +287,7 @@ static int tegra_ehci_setup(struct usb_hcd *hcd)
285 /* switch to host mode */ 287 /* switch to host mode */
286 hcd->has_tt = 1; 288 hcd->has_tt = 1;
287 289
288 retval = ehci_setup(hcd); 290 return ehci_setup(hcd);
289 if (retval)
290 return retval;
291
292 ehci_port_power(ehci, 1);
293 return retval;
294} 291}
295 292
296struct dma_aligned_buffer { 293struct dma_aligned_buffer {
@@ -778,9 +775,6 @@ static int tegra_ehci_remove(struct platform_device *pdev)
778 struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); 775 struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev);
779 struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci); 776 struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci);
780 777
781 if (tegra == NULL || hcd == NULL)
782 return -EINVAL;
783
784 pm_runtime_get_sync(&pdev->dev); 778 pm_runtime_get_sync(&pdev->dev);
785 pm_runtime_disable(&pdev->dev); 779 pm_runtime_disable(&pdev->dev);
786 pm_runtime_put_noidle(&pdev->dev); 780 pm_runtime_put_noidle(&pdev->dev);
@@ -811,7 +805,7 @@ static void tegra_ehci_hcd_shutdown(struct platform_device *pdev)
811 hcd->driver->shutdown(hcd); 805 hcd->driver->shutdown(hcd);
812} 806}
813 807
814static struct of_device_id tegra_ehci_of_match[] __devinitdata = { 808static struct of_device_id tegra_ehci_of_match[] = {
815 { .compatible = "nvidia,tegra20-ehci", }, 809 { .compatible = "nvidia,tegra20-ehci", },
816 { }, 810 { },
817}; 811};
diff --git a/drivers/usb/host/ehci-vt8500.c b/drivers/usb/host/ehci-vt8500.c
index d3c9a3e397b9..11695d5b9d86 100644
--- a/drivers/usb/host/ehci-vt8500.c
+++ b/drivers/usb/host/ehci-vt8500.c
@@ -19,22 +19,6 @@
19#include <linux/of.h> 19#include <linux/of.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21 21
22static int ehci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
23{
24 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
25 int rc = 0;
26
27 if (!udev->parent) /* udev is root hub itself, impossible */
28 rc = -1;
29 /* we only support lpm device connected to root hub yet */
30 if (ehci->has_lpm && !udev->parent->parent) {
31 rc = ehci_lpm_set_da(ehci, udev->devnum, udev->portnum);
32 if (!rc)
33 rc = ehci_lpm_check(ehci, udev->portnum);
34 }
35 return rc;
36}
37
38static const struct hc_driver vt8500_ehci_hc_driver = { 22static const struct hc_driver vt8500_ehci_hc_driver = {
39 .description = hcd_name, 23 .description = hcd_name,
40 .product_desc = "VT8500 EHCI", 24 .product_desc = "VT8500 EHCI",
@@ -77,11 +61,6 @@ static const struct hc_driver vt8500_ehci_hc_driver = {
77 .relinquish_port = ehci_relinquish_port, 61 .relinquish_port = ehci_relinquish_port,
78 .port_handed_over = ehci_port_handed_over, 62 .port_handed_over = ehci_port_handed_over,
79 63
80 /*
81 * call back when device connected and addressed
82 */
83 .update_device = ehci_update_device,
84
85 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, 64 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
86}; 65};
87 66
diff --git a/drivers/usb/host/ehci-w90x900.c b/drivers/usb/host/ehci-w90x900.c
index ec598082c14b..59e0e24c753f 100644
--- a/drivers/usb/host/ehci-w90x900.c
+++ b/drivers/usb/host/ehci-w90x900.c
@@ -13,12 +13,12 @@
13 13
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15 15
16/*ebable phy0 and phy1 for w90p910*/ 16/* enable phy0 and phy1 for w90p910 */
17#define ENPHY (0x01<<8) 17#define ENPHY (0x01<<8)
18#define PHY0_CTR (0xA4) 18#define PHY0_CTR (0xA4)
19#define PHY1_CTR (0xA8) 19#define PHY1_CTR (0xA8)
20 20
21static int __devinit usb_w90x900_probe(const struct hc_driver *driver, 21static int usb_w90x900_probe(const struct hc_driver *driver,
22 struct platform_device *pdev) 22 struct platform_device *pdev)
23{ 23{
24 struct usb_hcd *hcd; 24 struct usb_hcd *hcd;
@@ -147,7 +147,7 @@ static const struct hc_driver ehci_w90x900_hc_driver = {
147 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, 147 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
148}; 148};
149 149
150static int __devinit ehci_w90x900_probe(struct platform_device *pdev) 150static int ehci_w90x900_probe(struct platform_device *pdev)
151{ 151{
152 if (usb_disabled()) 152 if (usb_disabled())
153 return -ENODEV; 153 return -ENODEV;
@@ -155,7 +155,7 @@ static int __devinit ehci_w90x900_probe(struct platform_device *pdev)
155 return usb_w90x900_probe(&ehci_w90x900_hc_driver, pdev); 155 return usb_w90x900_probe(&ehci_w90x900_hc_driver, pdev);
156} 156}
157 157
158static int __devexit ehci_w90x900_remove(struct platform_device *pdev) 158static int ehci_w90x900_remove(struct platform_device *pdev)
159{ 159{
160 struct usb_hcd *hcd = platform_get_drvdata(pdev); 160 struct usb_hcd *hcd = platform_get_drvdata(pdev);
161 161
@@ -166,7 +166,7 @@ static int __devexit ehci_w90x900_remove(struct platform_device *pdev)
166 166
167static struct platform_driver ehci_hcd_w90x900_driver = { 167static struct platform_driver ehci_hcd_w90x900_driver = {
168 .probe = ehci_w90x900_probe, 168 .probe = ehci_w90x900_probe,
169 .remove = __devexit_p(ehci_w90x900_remove), 169 .remove = ehci_w90x900_remove,
170 .driver = { 170 .driver = {
171 .name = "w90x900-ehci", 171 .name = "w90x900-ehci",
172 .owner = THIS_MODULE, 172 .owner = THIS_MODULE,
diff --git a/drivers/usb/host/ehci-xilinx-of.c b/drivers/usb/host/ehci-xilinx-of.c
index 6a3f921a5d76..4f285e8e404a 100644
--- a/drivers/usb/host/ehci-xilinx-of.c
+++ b/drivers/usb/host/ehci-xilinx-of.c
@@ -125,7 +125,7 @@ static const struct hc_driver ehci_xilinx_of_hc_driver = {
125 * as HS only or HS/FS only, it checks the configuration in the device tree 125 * as HS only or HS/FS only, it checks the configuration in the device tree
126 * entry, and sets an appropriate value for hcd->has_tt. 126 * entry, and sets an appropriate value for hcd->has_tt.
127 */ 127 */
128static int __devinit ehci_hcd_xilinx_of_probe(struct platform_device *op) 128static int ehci_hcd_xilinx_of_probe(struct platform_device *op)
129{ 129{
130 struct device_node *dn = op->dev.of_node; 130 struct device_node *dn = op->dev.of_node;
131 struct usb_hcd *hcd; 131 struct usb_hcd *hcd;
diff --git a/drivers/usb/host/ehci-xls.c b/drivers/usb/host/ehci-xls.c
deleted file mode 100644
index 8dc6a22d90b8..000000000000
--- a/drivers/usb/host/ehci-xls.c
+++ /dev/null
@@ -1,142 +0,0 @@
1/*
2 * EHCI HCD for Netlogic XLS processors.
3 *
4 * (C) Copyright 2011 Netlogic Microsystems Inc.
5 *
6 * Based on various ehci-*.c drivers
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive for
10 * more details.
11 */
12
13#include <linux/platform_device.h>
14
15static int ehci_xls_setup(struct usb_hcd *hcd)
16{
17 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
18
19 ehci->caps = hcd->regs;
20
21 return ehci_setup(hcd);
22}
23
24int ehci_xls_probe_internal(const struct hc_driver *driver,
25 struct platform_device *pdev)
26{
27 struct usb_hcd *hcd;
28 struct resource *res;
29 int retval, irq;
30
31 /* Get our IRQ from an earlier registered Platform Resource */
32 irq = platform_get_irq(pdev, 0);
33 if (irq < 0) {
34 dev_err(&pdev->dev, "Found HC with no IRQ. Check %s setup!\n",
35 dev_name(&pdev->dev));
36 return -ENODEV;
37 }
38
39 /* Get our Memory Handle */
40 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
41 if (!res) {
42 dev_err(&pdev->dev, "Error: MMIO Handle %s setup!\n",
43 dev_name(&pdev->dev));
44 return -ENODEV;
45 }
46 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
47 if (!hcd) {
48 retval = -ENOMEM;
49 goto err1;
50 }
51
52 hcd->rsrc_start = res->start;
53 hcd->rsrc_len = resource_size(res);
54
55 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
56 driver->description)) {
57 dev_dbg(&pdev->dev, "controller already in use\n");
58 retval = -EBUSY;
59 goto err2;
60 }
61 hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
62
63 if (hcd->regs == NULL) {
64 dev_dbg(&pdev->dev, "error mapping memory\n");
65 retval = -EFAULT;
66 goto err3;
67 }
68
69 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
70 if (retval != 0)
71 goto err4;
72 return retval;
73
74err4:
75 iounmap(hcd->regs);
76err3:
77 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
78err2:
79 usb_put_hcd(hcd);
80err1:
81 dev_err(&pdev->dev, "init %s fail, %d\n", dev_name(&pdev->dev),
82 retval);
83 return retval;
84}
85
86static struct hc_driver ehci_xls_hc_driver = {
87 .description = hcd_name,
88 .product_desc = "XLS EHCI Host Controller",
89 .hcd_priv_size = sizeof(struct ehci_hcd),
90 .irq = ehci_irq,
91 .flags = HCD_USB2 | HCD_MEMORY,
92 .reset = ehci_xls_setup,
93 .start = ehci_run,
94 .stop = ehci_stop,
95 .shutdown = ehci_shutdown,
96
97 .urb_enqueue = ehci_urb_enqueue,
98 .urb_dequeue = ehci_urb_dequeue,
99 .endpoint_disable = ehci_endpoint_disable,
100 .endpoint_reset = ehci_endpoint_reset,
101
102 .get_frame_number = ehci_get_frame,
103
104 .hub_status_data = ehci_hub_status_data,
105 .hub_control = ehci_hub_control,
106 .bus_suspend = ehci_bus_suspend,
107 .bus_resume = ehci_bus_resume,
108 .relinquish_port = ehci_relinquish_port,
109 .port_handed_over = ehci_port_handed_over,
110
111 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
112};
113
114static int ehci_xls_probe(struct platform_device *pdev)
115{
116 if (usb_disabled())
117 return -ENODEV;
118
119 return ehci_xls_probe_internal(&ehci_xls_hc_driver, pdev);
120}
121
122static int ehci_xls_remove(struct platform_device *pdev)
123{
124 struct usb_hcd *hcd = platform_get_drvdata(pdev);
125
126 usb_remove_hcd(hcd);
127 iounmap(hcd->regs);
128 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
129 usb_put_hcd(hcd);
130 return 0;
131}
132
133MODULE_ALIAS("ehci-xls");
134
135static struct platform_driver ehci_xls_driver = {
136 .probe = ehci_xls_probe,
137 .remove = ehci_xls_remove,
138 .shutdown = usb_hcd_platform_shutdown,
139 .driver = {
140 .name = "ehci-xls",
141 },
142};
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index da07d98f7d1d..9dadc7118d68 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -143,7 +143,7 @@ struct ehci_hcd { /* one per controller */
143 struct ehci_qh *intr_unlink_last; 143 struct ehci_qh *intr_unlink_last;
144 unsigned intr_unlink_cycle; 144 unsigned intr_unlink_cycle;
145 unsigned now_frame; /* frame from HC hardware */ 145 unsigned now_frame; /* frame from HC hardware */
146 unsigned next_frame; /* scan periodic, start here */ 146 unsigned last_iso_frame; /* last frame scanned for iso */
147 unsigned intr_count; /* intr activity count */ 147 unsigned intr_count; /* intr activity count */
148 unsigned isoc_count; /* isoc activity count */ 148 unsigned isoc_count; /* isoc activity count */
149 unsigned periodic_count; /* periodic activity count */ 149 unsigned periodic_count; /* periodic activity count */
@@ -193,7 +193,6 @@ struct ehci_hcd { /* one per controller */
193 unsigned has_amcc_usb23:1; 193 unsigned has_amcc_usb23:1;
194 unsigned need_io_watchdog:1; 194 unsigned need_io_watchdog:1;
195 unsigned amd_pll_fix:1; 195 unsigned amd_pll_fix:1;
196 unsigned fs_i_thresh:1; /* Intel iso scheduling */
197 unsigned use_dummy_qh:1; /* AMD Frame List table quirk*/ 196 unsigned use_dummy_qh:1; /* AMD Frame List table quirk*/
198 unsigned has_synopsys_hc_bug:1; /* Synopsys HC */ 197 unsigned has_synopsys_hc_bug:1; /* Synopsys HC */
199 unsigned frame_index_bug:1; /* MosChip (AKA NetMos) */ 198 unsigned frame_index_bug:1; /* MosChip (AKA NetMos) */
@@ -207,7 +206,6 @@ struct ehci_hcd { /* one per controller */
207 #define OHCI_HCCTRL_LEN 0x4 206 #define OHCI_HCCTRL_LEN 0x4
208 __hc32 *ohci_hcctrl_reg; 207 __hc32 *ohci_hcctrl_reg;
209 unsigned has_hostpc:1; 208 unsigned has_hostpc:1;
210 unsigned has_lpm:1; /* support link power management */
211 unsigned has_ppcd:1; /* support per-port change bits */ 209 unsigned has_ppcd:1; /* support per-port change bits */
212 u8 sbrn; /* packed release number */ 210 u8 sbrn; /* packed release number */
213 211
@@ -762,26 +760,41 @@ static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x)
762 760
763/*-------------------------------------------------------------------------*/ 761/*-------------------------------------------------------------------------*/
764 762
765#ifdef CONFIG_PCI 763#define ehci_dbg(ehci, fmt, args...) \
766 764 dev_dbg(ehci_to_hcd(ehci)->self.controller , fmt , ## args)
767/* For working around the MosChip frame-index-register bug */ 765#define ehci_err(ehci, fmt, args...) \
768static unsigned ehci_read_frame_index(struct ehci_hcd *ehci); 766 dev_err(ehci_to_hcd(ehci)->self.controller , fmt , ## args)
769 767#define ehci_info(ehci, fmt, args...) \
768 dev_info(ehci_to_hcd(ehci)->self.controller , fmt , ## args)
769#define ehci_warn(ehci, fmt, args...) \
770 dev_warn(ehci_to_hcd(ehci)->self.controller , fmt , ## args)
771
772#ifdef VERBOSE_DEBUG
773# define ehci_vdbg ehci_dbg
770#else 774#else
771 775 static inline void ehci_vdbg(struct ehci_hcd *ehci, ...) {}
772static inline unsigned ehci_read_frame_index(struct ehci_hcd *ehci)
773{
774 return ehci_readl(ehci, &ehci->regs->frame_index);
775}
776
777#endif 776#endif
778 777
779/*-------------------------------------------------------------------------*/
780
781#ifndef DEBUG 778#ifndef DEBUG
782#define STUB_DEBUG_FILES 779#define STUB_DEBUG_FILES
783#endif /* DEBUG */ 780#endif /* DEBUG */
784 781
785/*-------------------------------------------------------------------------*/ 782/*-------------------------------------------------------------------------*/
786 783
784/* Declarations of things exported for use by ehci platform drivers */
785
786struct ehci_driver_overrides {
787 size_t extra_priv_size;
788 int (*reset)(struct usb_hcd *hcd);
789};
790
791extern void ehci_init_driver(struct hc_driver *drv,
792 const struct ehci_driver_overrides *over);
793extern int ehci_setup(struct usb_hcd *hcd);
794
795#ifdef CONFIG_PM
796extern int ehci_suspend(struct usb_hcd *hcd, bool do_wakeup);
797extern int ehci_resume(struct usb_hcd *hcd, bool hibernated);
798#endif /* CONFIG_PM */
799
787#endif /* __LINUX_EHCI_HCD_H */ 800#endif /* __LINUX_EHCI_HCD_H */
diff --git a/drivers/usb/host/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c
index 7da1a26bed2e..0b46542591ff 100644
--- a/drivers/usb/host/fhci-hcd.c
+++ b/drivers/usb/host/fhci-hcd.c
@@ -561,7 +561,7 @@ static const struct hc_driver fhci_driver = {
561 .hub_control = fhci_hub_control, 561 .hub_control = fhci_hub_control,
562}; 562};
563 563
564static int __devinit of_fhci_probe(struct platform_device *ofdev) 564static int of_fhci_probe(struct platform_device *ofdev)
565{ 565{
566 struct device *dev = &ofdev->dev; 566 struct device *dev = &ofdev->dev;
567 struct device_node *node = dev->of_node; 567 struct device_node *node = dev->of_node;
@@ -780,7 +780,7 @@ err_regs:
780 return ret; 780 return ret;
781} 781}
782 782
783static int __devexit fhci_remove(struct device *dev) 783static int fhci_remove(struct device *dev)
784{ 784{
785 struct usb_hcd *hcd = dev_get_drvdata(dev); 785 struct usb_hcd *hcd = dev_get_drvdata(dev);
786 struct fhci_hcd *fhci = hcd_to_fhci(hcd); 786 struct fhci_hcd *fhci = hcd_to_fhci(hcd);
@@ -803,7 +803,7 @@ static int __devexit fhci_remove(struct device *dev)
803 return 0; 803 return 0;
804} 804}
805 805
806static int __devexit of_fhci_remove(struct platform_device *ofdev) 806static int of_fhci_remove(struct platform_device *ofdev)
807{ 807{
808 return fhci_remove(&ofdev->dev); 808 return fhci_remove(&ofdev->dev);
809} 809}
@@ -821,7 +821,7 @@ static struct platform_driver of_fhci_driver = {
821 .of_match_table = of_fhci_match, 821 .of_match_table = of_fhci_match,
822 }, 822 },
823 .probe = of_fhci_probe, 823 .probe = of_fhci_probe,
824 .remove = __devexit_p(of_fhci_remove), 824 .remove = of_fhci_remove,
825}; 825};
826 826
827module_platform_driver(of_fhci_driver); 827module_platform_driver(of_fhci_driver);
diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
index 1e771292383f..5105127c1d4b 100644
--- a/drivers/usb/host/fsl-mph-dr-of.c
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -24,7 +24,7 @@ struct fsl_usb2_dev_data {
24 enum fsl_usb2_operating_modes op_mode; /* operating mode */ 24 enum fsl_usb2_operating_modes op_mode; /* operating mode */
25}; 25};
26 26
27struct fsl_usb2_dev_data dr_mode_data[] __devinitdata = { 27struct fsl_usb2_dev_data dr_mode_data[] = {
28 { 28 {
29 .dr_mode = "host", 29 .dr_mode = "host",
30 .drivers = { "fsl-ehci", NULL, NULL, }, 30 .drivers = { "fsl-ehci", NULL, NULL, },
@@ -42,7 +42,7 @@ struct fsl_usb2_dev_data dr_mode_data[] __devinitdata = {
42 }, 42 },
43}; 43};
44 44
45struct fsl_usb2_dev_data * __devinit get_dr_mode_data(struct device_node *np) 45struct fsl_usb2_dev_data *get_dr_mode_data(struct device_node *np)
46{ 46{
47 const unsigned char *prop; 47 const unsigned char *prop;
48 int i; 48 int i;
@@ -59,7 +59,7 @@ struct fsl_usb2_dev_data * __devinit get_dr_mode_data(struct device_node *np)
59 return &dr_mode_data[0]; /* mode not specified, use host */ 59 return &dr_mode_data[0]; /* mode not specified, use host */
60} 60}
61 61
62static enum fsl_usb2_phy_modes __devinit determine_usb_phy(const char *phy_type) 62static enum fsl_usb2_phy_modes determine_usb_phy(const char *phy_type)
63{ 63{
64 if (!phy_type) 64 if (!phy_type)
65 return FSL_USB2_PHY_NONE; 65 return FSL_USB2_PHY_NONE;
@@ -75,7 +75,7 @@ static enum fsl_usb2_phy_modes __devinit determine_usb_phy(const char *phy_type)
75 return FSL_USB2_PHY_NONE; 75 return FSL_USB2_PHY_NONE;
76} 76}
77 77
78struct platform_device * __devinit fsl_usb2_device_register( 78struct platform_device *fsl_usb2_device_register(
79 struct platform_device *ofdev, 79 struct platform_device *ofdev,
80 struct fsl_usb2_platform_data *pdata, 80 struct fsl_usb2_platform_data *pdata,
81 const char *name, int id) 81 const char *name, int id)
@@ -154,7 +154,7 @@ static int usb_get_ver_info(struct device_node *np)
154 return ver; 154 return ver;
155} 155}
156 156
157static int __devinit fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev) 157static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
158{ 158{
159 struct device_node *np = ofdev->dev.of_node; 159 struct device_node *np = ofdev->dev.of_node;
160 struct platform_device *usb_dev; 160 struct platform_device *usb_dev;
@@ -224,13 +224,13 @@ static int __devinit fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
224 return 0; 224 return 0;
225} 225}
226 226
227static int __devexit __unregister_subdev(struct device *dev, void *d) 227static int __unregister_subdev(struct device *dev, void *d)
228{ 228{
229 platform_device_unregister(to_platform_device(dev)); 229 platform_device_unregister(to_platform_device(dev));
230 return 0; 230 return 0;
231} 231}
232 232
233static int __devexit fsl_usb2_mph_dr_of_remove(struct platform_device *ofdev) 233static int fsl_usb2_mph_dr_of_remove(struct platform_device *ofdev)
234{ 234{
235 device_for_each_child(&ofdev->dev, NULL, __unregister_subdev); 235 device_for_each_child(&ofdev->dev, NULL, __unregister_subdev);
236 return 0; 236 return 0;
@@ -336,7 +336,7 @@ static struct platform_driver fsl_usb2_mph_dr_driver = {
336 .of_match_table = fsl_usb2_mph_dr_of_match, 336 .of_match_table = fsl_usb2_mph_dr_of_match,
337 }, 337 },
338 .probe = fsl_usb2_mph_dr_of_probe, 338 .probe = fsl_usb2_mph_dr_of_probe,
339 .remove = __devexit_p(fsl_usb2_mph_dr_of_remove), 339 .remove = fsl_usb2_mph_dr_of_remove,
340}; 340};
341 341
342module_platform_driver(fsl_usb2_mph_dr_driver); 342module_platform_driver(fsl_usb2_mph_dr_driver);
diff --git a/drivers/usb/host/imx21-hcd.c b/drivers/usb/host/imx21-hcd.c
index f19e2690c232..bd6a7447ccc9 100644
--- a/drivers/usb/host/imx21-hcd.c
+++ b/drivers/usb/host/imx21-hcd.c
@@ -1680,7 +1680,7 @@ static int imx21_hc_reset(struct usb_hcd *hcd)
1680 return 0; 1680 return 0;
1681} 1681}
1682 1682
1683static int __devinit imx21_hc_start(struct usb_hcd *hcd) 1683static int imx21_hc_start(struct usb_hcd *hcd)
1684{ 1684{
1685 struct imx21 *imx21 = hcd_to_imx21(hcd); 1685 struct imx21 *imx21 = hcd_to_imx21(hcd);
1686 unsigned long flags; 1686 unsigned long flags;
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index 9e65e3091c8a..b64e661618bb 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -1557,7 +1557,7 @@ static int isp116x_remove(struct platform_device *pdev)
1557 return 0; 1557 return 0;
1558} 1558}
1559 1559
1560static int __devinit isp116x_probe(struct platform_device *pdev) 1560static int isp116x_probe(struct platform_device *pdev)
1561{ 1561{
1562 struct usb_hcd *hcd; 1562 struct usb_hcd *hcd;
1563 struct isp116x *isp116x; 1563 struct isp116x *isp116x;
diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c
index 256326322cfd..974480c516fa 100644
--- a/drivers/usb/host/isp1362-hcd.c
+++ b/drivers/usb/host/isp1362-hcd.c
@@ -2645,7 +2645,7 @@ static struct hc_driver isp1362_hc_driver = {
2645 2645
2646/*-------------------------------------------------------------------------*/ 2646/*-------------------------------------------------------------------------*/
2647 2647
2648static int __devexit isp1362_remove(struct platform_device *pdev) 2648static int isp1362_remove(struct platform_device *pdev)
2649{ 2649{
2650 struct usb_hcd *hcd = platform_get_drvdata(pdev); 2650 struct usb_hcd *hcd = platform_get_drvdata(pdev);
2651 struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd); 2651 struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
@@ -2680,7 +2680,7 @@ static int __devexit isp1362_remove(struct platform_device *pdev)
2680 return 0; 2680 return 0;
2681} 2681}
2682 2682
2683static int __devinit isp1362_probe(struct platform_device *pdev) 2683static int isp1362_probe(struct platform_device *pdev)
2684{ 2684{
2685 struct usb_hcd *hcd; 2685 struct usb_hcd *hcd;
2686 struct isp1362_hcd *isp1362_hcd; 2686 struct isp1362_hcd *isp1362_hcd;
@@ -2856,7 +2856,7 @@ static int isp1362_resume(struct platform_device *pdev)
2856 2856
2857static struct platform_driver isp1362_driver = { 2857static struct platform_driver isp1362_driver = {
2858 .probe = isp1362_probe, 2858 .probe = isp1362_probe,
2859 .remove = __devexit_p(isp1362_remove), 2859 .remove = isp1362_remove,
2860 2860
2861 .suspend = isp1362_suspend, 2861 .suspend = isp1362_suspend,
2862 .resume = isp1362_resume, 2862 .resume = isp1362_resume,
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index fff114fd5461..bbb791bd7617 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -43,7 +43,6 @@ static int of_isp1760_probe(struct platform_device *dev)
43 struct device_node *dp = dev->dev.of_node; 43 struct device_node *dp = dev->dev.of_node;
44 struct resource *res; 44 struct resource *res;
45 struct resource memory; 45 struct resource memory;
46 struct of_irq oirq;
47 int virq; 46 int virq;
48 resource_size_t res_len; 47 resource_size_t res_len;
49 int ret; 48 int ret;
@@ -69,14 +68,12 @@ static int of_isp1760_probe(struct platform_device *dev)
69 goto free_data; 68 goto free_data;
70 } 69 }
71 70
72 if (of_irq_map_one(dp, 0, &oirq)) { 71 virq = irq_of_parse_and_map(dp, 0);
72 if (!virq) {
73 ret = -ENODEV; 73 ret = -ENODEV;
74 goto release_reg; 74 goto release_reg;
75 } 75 }
76 76
77 virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
78 oirq.size);
79
80 if (of_device_is_compatible(dp, "nxp,usb-isp1761")) 77 if (of_device_is_compatible(dp, "nxp,usb-isp1761"))
81 devflags |= ISP1760_FLAG_ISP1761; 78 devflags |= ISP1760_FLAG_ISP1761;
82 79
@@ -175,7 +172,7 @@ static struct platform_driver isp1760_of_driver = {
175#endif 172#endif
176 173
177#ifdef CONFIG_PCI 174#ifdef CONFIG_PCI
178static int __devinit isp1761_pci_probe(struct pci_dev *dev, 175static int isp1761_pci_probe(struct pci_dev *dev,
179 const struct pci_device_id *id) 176 const struct pci_device_id *id)
180{ 177{
181 u8 latency, limit; 178 u8 latency, limit;
@@ -349,7 +346,7 @@ static struct pci_driver isp1761_pci_driver = {
349}; 346};
350#endif 347#endif
351 348
352static int __devinit isp1760_plat_probe(struct platform_device *pdev) 349static int isp1760_plat_probe(struct platform_device *pdev)
353{ 350{
354 int ret = 0; 351 int ret = 0;
355 struct usb_hcd *hcd; 352 struct usb_hcd *hcd;
@@ -416,7 +413,7 @@ out:
416 return ret; 413 return ret;
417} 414}
418 415
419static int __devexit isp1760_plat_remove(struct platform_device *pdev) 416static int isp1760_plat_remove(struct platform_device *pdev)
420{ 417{
421 struct resource *mem_res; 418 struct resource *mem_res;
422 resource_size_t mem_size; 419 resource_size_t mem_size;
@@ -435,7 +432,7 @@ static int __devexit isp1760_plat_remove(struct platform_device *pdev)
435 432
436static struct platform_driver isp1760_plat_driver = { 433static struct platform_driver isp1760_plat_driver = {
437 .probe = isp1760_plat_probe, 434 .probe = isp1760_plat_probe,
438 .remove = __devexit_p(isp1760_plat_remove), 435 .remove = isp1760_plat_remove,
439 .driver = { 436 .driver = {
440 .name = "isp1760", 437 .name = "isp1760",
441 }, 438 },
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 0bf72f943b00..221850a8c25f 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -94,7 +94,7 @@ static void at91_stop_hc(struct platform_device *pdev)
94 94
95/*-------------------------------------------------------------------------*/ 95/*-------------------------------------------------------------------------*/
96 96
97static void __devexit usb_hcd_at91_remove (struct usb_hcd *, struct platform_device *); 97static void usb_hcd_at91_remove (struct usb_hcd *, struct platform_device *);
98 98
99/* configure so an HC device and id are always provided */ 99/* configure so an HC device and id are always provided */
100/* always called with process context; sleeping is OK */ 100/* always called with process context; sleeping is OK */
@@ -108,7 +108,7 @@ static void __devexit usb_hcd_at91_remove (struct usb_hcd *, struct platform_dev
108 * then invokes the start() method for the HCD associated with it 108 * then invokes the start() method for the HCD associated with it
109 * through the hotplug entry's driver_data. 109 * through the hotplug entry's driver_data.
110 */ 110 */
111static int __devinit usb_hcd_at91_probe(const struct hc_driver *driver, 111static int usb_hcd_at91_probe(const struct hc_driver *driver,
112 struct platform_device *pdev) 112 struct platform_device *pdev)
113{ 113{
114 int retval; 114 int retval;
@@ -203,7 +203,7 @@ static int __devinit usb_hcd_at91_probe(const struct hc_driver *driver,
203 * context, "rmmod" or something similar. 203 * context, "rmmod" or something similar.
204 * 204 *
205 */ 205 */
206static void __devexit usb_hcd_at91_remove(struct usb_hcd *hcd, 206static void usb_hcd_at91_remove(struct usb_hcd *hcd,
207 struct platform_device *pdev) 207 struct platform_device *pdev)
208{ 208{
209 usb_remove_hcd(hcd); 209 usb_remove_hcd(hcd);
@@ -222,7 +222,7 @@ static void __devexit usb_hcd_at91_remove(struct usb_hcd *hcd,
222 222
223/*-------------------------------------------------------------------------*/ 223/*-------------------------------------------------------------------------*/
224 224
225static int __devinit 225static int
226ohci_at91_reset (struct usb_hcd *hcd) 226ohci_at91_reset (struct usb_hcd *hcd)
227{ 227{
228 struct at91_usbh_data *board = hcd->self.controller->platform_data; 228 struct at91_usbh_data *board = hcd->self.controller->platform_data;
@@ -236,7 +236,7 @@ ohci_at91_reset (struct usb_hcd *hcd)
236 return 0; 236 return 0;
237} 237}
238 238
239static int __devinit 239static int
240ohci_at91_start (struct usb_hcd *hcd) 240ohci_at91_start (struct usb_hcd *hcd)
241{ 241{
242 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 242 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
@@ -506,7 +506,7 @@ MODULE_DEVICE_TABLE(of, at91_ohci_dt_ids);
506 506
507static u64 at91_ohci_dma_mask = DMA_BIT_MASK(32); 507static u64 at91_ohci_dma_mask = DMA_BIT_MASK(32);
508 508
509static int __devinit ohci_at91_of_init(struct platform_device *pdev) 509static int ohci_at91_of_init(struct platform_device *pdev)
510{ 510{
511 struct device_node *np = pdev->dev.of_node; 511 struct device_node *np = pdev->dev.of_node;
512 int i, gpio; 512 int i, gpio;
@@ -548,7 +548,7 @@ static int __devinit ohci_at91_of_init(struct platform_device *pdev)
548 return 0; 548 return 0;
549} 549}
550#else 550#else
551static int __devinit ohci_at91_of_init(struct platform_device *pdev) 551static int ohci_at91_of_init(struct platform_device *pdev)
552{ 552{
553 return 0; 553 return 0;
554} 554}
@@ -556,7 +556,7 @@ static int __devinit ohci_at91_of_init(struct platform_device *pdev)
556 556
557/*-------------------------------------------------------------------------*/ 557/*-------------------------------------------------------------------------*/
558 558
559static int __devinit ohci_hcd_at91_drv_probe(struct platform_device *pdev) 559static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
560{ 560{
561 struct at91_usbh_data *pdata; 561 struct at91_usbh_data *pdata;
562 int i; 562 int i;
@@ -641,7 +641,7 @@ static int __devinit ohci_hcd_at91_drv_probe(struct platform_device *pdev)
641 return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev); 641 return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev);
642} 642}
643 643
644static int __devexit ohci_hcd_at91_drv_remove(struct platform_device *pdev) 644static int ohci_hcd_at91_drv_remove(struct platform_device *pdev)
645{ 645{
646 struct at91_usbh_data *pdata = pdev->dev.platform_data; 646 struct at91_usbh_data *pdata = pdev->dev.platform_data;
647 int i; 647 int i;
@@ -705,7 +705,7 @@ static int ohci_hcd_at91_drv_resume(struct platform_device *pdev)
705 if (!clocked) 705 if (!clocked)
706 at91_start_clock(); 706 at91_start_clock();
707 707
708 ohci_finish_controller_resume(hcd); 708 ohci_resume(hcd, false);
709 return 0; 709 return 0;
710} 710}
711#else 711#else
@@ -717,7 +717,7 @@ MODULE_ALIAS("platform:at91_ohci");
717 717
718static struct platform_driver ohci_hcd_at91_driver = { 718static struct platform_driver ohci_hcd_at91_driver = {
719 .probe = ohci_hcd_at91_drv_probe, 719 .probe = ohci_hcd_at91_drv_probe,
720 .remove = __devexit_p(ohci_hcd_at91_drv_remove), 720 .remove = ohci_hcd_at91_drv_remove,
721 .shutdown = usb_hcd_platform_shutdown, 721 .shutdown = usb_hcd_platform_shutdown,
722 .suspend = ohci_hcd_at91_drv_suspend, 722 .suspend = ohci_hcd_at91_drv_suspend,
723 .resume = ohci_hcd_at91_drv_resume, 723 .resume = ohci_hcd_at91_drv_resume,
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c
deleted file mode 100644
index c611699b4aa6..000000000000
--- a/drivers/usb/host/ohci-au1xxx.c
+++ /dev/null
@@ -1,234 +0,0 @@
1/*
2 * OHCI HCD (Host Controller Driver) for USB.
3 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * (C) Copyright 2002 Hewlett-Packard Company
7 *
8 * Bus Glue for AMD Alchemy Au1xxx
9 *
10 * Written by Christopher Hoover <ch@hpl.hp.com>
11 * Based on fragments of previous driver by Russell King et al.
12 *
13 * Modified for LH7A404 from ohci-sa1111.c
14 * by Durgesh Pattamatta <pattamattad@sharpsec.com>
15 * Modified for AMD Alchemy Au1xxx
16 * by Matt Porter <mporter@kernel.crashing.org>
17 *
18 * This file is licenced under the GPL.
19 */
20
21#include <linux/platform_device.h>
22#include <linux/signal.h>
23
24#include <asm/mach-au1x00/au1000.h>
25
26
27extern int usb_disabled(void);
28
29static int __devinit ohci_au1xxx_start(struct usb_hcd *hcd)
30{
31 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
32 int ret;
33
34 ohci_dbg(ohci, "ohci_au1xxx_start, ohci:%p", ohci);
35
36 if ((ret = ohci_init(ohci)) < 0)
37 return ret;
38
39 if ((ret = ohci_run(ohci)) < 0) {
40 dev_err(hcd->self.controller, "can't start %s",
41 hcd->self.bus_name);
42 ohci_stop(hcd);
43 return ret;
44 }
45
46 return 0;
47}
48
49static const struct hc_driver ohci_au1xxx_hc_driver = {
50 .description = hcd_name,
51 .product_desc = "Au1xxx OHCI",
52 .hcd_priv_size = sizeof(struct ohci_hcd),
53
54 /*
55 * generic hardware linkage
56 */
57 .irq = ohci_irq,
58 .flags = HCD_USB11 | HCD_MEMORY,
59
60 /*
61 * basic lifecycle operations
62 */
63 .start = ohci_au1xxx_start,
64 .stop = ohci_stop,
65 .shutdown = ohci_shutdown,
66
67 /*
68 * managing i/o requests and associated device resources
69 */
70 .urb_enqueue = ohci_urb_enqueue,
71 .urb_dequeue = ohci_urb_dequeue,
72 .endpoint_disable = ohci_endpoint_disable,
73
74 /*
75 * scheduling support
76 */
77 .get_frame_number = ohci_get_frame,
78
79 /*
80 * root hub support
81 */
82 .hub_status_data = ohci_hub_status_data,
83 .hub_control = ohci_hub_control,
84#ifdef CONFIG_PM
85 .bus_suspend = ohci_bus_suspend,
86 .bus_resume = ohci_bus_resume,
87#endif
88 .start_port_reset = ohci_start_port_reset,
89};
90
91static int ohci_hcd_au1xxx_drv_probe(struct platform_device *pdev)
92{
93 int ret, unit;
94 struct usb_hcd *hcd;
95
96 if (usb_disabled())
97 return -ENODEV;
98
99 if (pdev->resource[1].flags != IORESOURCE_IRQ) {
100 pr_debug("resource[1] is not IORESOURCE_IRQ\n");
101 return -ENOMEM;
102 }
103
104 hcd = usb_create_hcd(&ohci_au1xxx_hc_driver, &pdev->dev, "au1xxx");
105 if (!hcd)
106 return -ENOMEM;
107
108 hcd->rsrc_start = pdev->resource[0].start;
109 hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1;
110
111 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
112 pr_debug("request_mem_region failed\n");
113 ret = -EBUSY;
114 goto err1;
115 }
116
117 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
118 if (!hcd->regs) {
119 pr_debug("ioremap failed\n");
120 ret = -ENOMEM;
121 goto err2;
122 }
123
124 unit = (hcd->rsrc_start == AU1300_USB_OHCI1_PHYS_ADDR) ?
125 ALCHEMY_USB_OHCI1 : ALCHEMY_USB_OHCI0;
126 if (alchemy_usb_control(unit, 1)) {
127 printk(KERN_INFO "%s: controller init failed!\n", pdev->name);
128 ret = -ENODEV;
129 goto err3;
130 }
131
132 ohci_hcd_init(hcd_to_ohci(hcd));
133
134 ret = usb_add_hcd(hcd, pdev->resource[1].start,
135 IRQF_SHARED);
136 if (ret == 0) {
137 platform_set_drvdata(pdev, hcd);
138 return ret;
139 }
140
141 alchemy_usb_control(unit, 0);
142err3:
143 iounmap(hcd->regs);
144err2:
145 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
146err1:
147 usb_put_hcd(hcd);
148 return ret;
149}
150
151static int ohci_hcd_au1xxx_drv_remove(struct platform_device *pdev)
152{
153 struct usb_hcd *hcd = platform_get_drvdata(pdev);
154 int unit;
155
156 unit = (hcd->rsrc_start == AU1300_USB_OHCI1_PHYS_ADDR) ?
157 ALCHEMY_USB_OHCI1 : ALCHEMY_USB_OHCI0;
158 usb_remove_hcd(hcd);
159 alchemy_usb_control(unit, 0);
160 iounmap(hcd->regs);
161 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
162 usb_put_hcd(hcd);
163 platform_set_drvdata(pdev, NULL);
164
165 return 0;
166}
167
168#ifdef CONFIG_PM
169static int ohci_hcd_au1xxx_drv_suspend(struct device *dev)
170{
171 struct usb_hcd *hcd = dev_get_drvdata(dev);
172 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
173 unsigned long flags;
174 int rc;
175
176 rc = 0;
177
178 /* Root hub was already suspended. Disable irq emission and
179 * mark HW unaccessible, bail out if RH has been resumed. Use
180 * the spinlock to properly synchronize with possible pending
181 * RH suspend or resume activity.
182 */
183 spin_lock_irqsave(&ohci->lock, flags);
184 if (ohci->rh_state != OHCI_RH_SUSPENDED) {
185 rc = -EINVAL;
186 goto bail;
187 }
188 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
189 (void)ohci_readl(ohci, &ohci->regs->intrdisable);
190
191 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
192
193 alchemy_usb_control(ALCHEMY_USB_OHCI0, 0);
194bail:
195 spin_unlock_irqrestore(&ohci->lock, flags);
196
197 return rc;
198}
199
200static int ohci_hcd_au1xxx_drv_resume(struct device *dev)
201{
202 struct usb_hcd *hcd = dev_get_drvdata(dev);
203
204 alchemy_usb_control(ALCHEMY_USB_OHCI0, 1);
205
206 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
207 ohci_finish_controller_resume(hcd);
208
209 return 0;
210}
211
212static const struct dev_pm_ops au1xxx_ohci_pmops = {
213 .suspend = ohci_hcd_au1xxx_drv_suspend,
214 .resume = ohci_hcd_au1xxx_drv_resume,
215};
216
217#define AU1XXX_OHCI_PMOPS &au1xxx_ohci_pmops
218
219#else
220#define AU1XXX_OHCI_PMOPS NULL
221#endif
222
223static struct platform_driver ohci_hcd_au1xxx_driver = {
224 .probe = ohci_hcd_au1xxx_drv_probe,
225 .remove = ohci_hcd_au1xxx_drv_remove,
226 .shutdown = usb_hcd_platform_shutdown,
227 .driver = {
228 .name = "au1xxx-ohci",
229 .owner = THIS_MODULE,
230 .pm = AU1XXX_OHCI_PMOPS,
231 },
232};
233
234MODULE_ALIAS("platform:au1xxx-ohci");
diff --git a/drivers/usb/host/ohci-cns3xxx.c b/drivers/usb/host/ohci-cns3xxx.c
deleted file mode 100644
index 2c9f233047be..000000000000
--- a/drivers/usb/host/ohci-cns3xxx.c
+++ /dev/null
@@ -1,166 +0,0 @@
1/*
2 * Copyright 2008 Cavium Networks
3 *
4 * This file is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, Version 2, as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/platform_device.h>
10#include <linux/atomic.h>
11#include <mach/cns3xxx.h>
12#include <mach/pm.h>
13
14static int __devinit
15cns3xxx_ohci_start(struct usb_hcd *hcd)
16{
17 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
18 int ret;
19
20 /*
21 * EHCI and OHCI share the same clock and power,
22 * resetting twice would cause the 1st controller been reset.
23 * Therefore only do power up at the first up device, and
24 * power down at the last down device.
25 *
26 * Set USB AHB INCR length to 16
27 */
28 if (atomic_inc_return(&usb_pwr_ref) == 1) {
29 cns3xxx_pwr_power_up(1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_PLL_USB);
30 cns3xxx_pwr_clk_en(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST);
31 cns3xxx_pwr_soft_rst(1 << PM_SOFT_RST_REG_OFFST_USB_HOST);
32 __raw_writel((__raw_readl(MISC_CHIP_CONFIG_REG) | (0X2 << 24)),
33 MISC_CHIP_CONFIG_REG);
34 }
35
36 ret = ohci_init(ohci);
37 if (ret < 0)
38 return ret;
39
40 ohci->num_ports = 1;
41
42 ret = ohci_run(ohci);
43 if (ret < 0) {
44 dev_err(hcd->self.controller, "can't start %s\n",
45 hcd->self.bus_name);
46 ohci_stop(hcd);
47 return ret;
48 }
49 return 0;
50}
51
52static const struct hc_driver cns3xxx_ohci_hc_driver = {
53 .description = hcd_name,
54 .product_desc = "CNS3XXX OHCI Host controller",
55 .hcd_priv_size = sizeof(struct ohci_hcd),
56 .irq = ohci_irq,
57 .flags = HCD_USB11 | HCD_MEMORY,
58 .start = cns3xxx_ohci_start,
59 .stop = ohci_stop,
60 .shutdown = ohci_shutdown,
61 .urb_enqueue = ohci_urb_enqueue,
62 .urb_dequeue = ohci_urb_dequeue,
63 .endpoint_disable = ohci_endpoint_disable,
64 .get_frame_number = ohci_get_frame,
65 .hub_status_data = ohci_hub_status_data,
66 .hub_control = ohci_hub_control,
67#ifdef CONFIG_PM
68 .bus_suspend = ohci_bus_suspend,
69 .bus_resume = ohci_bus_resume,
70#endif
71 .start_port_reset = ohci_start_port_reset,
72};
73
74static int cns3xxx_ohci_probe(struct platform_device *pdev)
75{
76 struct device *dev = &pdev->dev;
77 struct usb_hcd *hcd;
78 const struct hc_driver *driver = &cns3xxx_ohci_hc_driver;
79 struct resource *res;
80 int irq;
81 int retval;
82
83 if (usb_disabled())
84 return -ENODEV;
85
86 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
87 if (!res) {
88 dev_err(dev, "Found HC with no IRQ.\n");
89 return -ENODEV;
90 }
91 irq = res->start;
92
93 hcd = usb_create_hcd(driver, dev, dev_name(dev));
94 if (!hcd)
95 return -ENOMEM;
96
97 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
98 if (!res) {
99 dev_err(dev, "Found HC with no register addr.\n");
100 retval = -ENODEV;
101 goto err1;
102 }
103 hcd->rsrc_start = res->start;
104 hcd->rsrc_len = resource_size(res);
105
106 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
107 driver->description)) {
108 dev_dbg(dev, "controller already in use\n");
109 retval = -EBUSY;
110 goto err1;
111 }
112
113 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
114 if (!hcd->regs) {
115 dev_dbg(dev, "error mapping memory\n");
116 retval = -EFAULT;
117 goto err2;
118 }
119
120 ohci_hcd_init(hcd_to_ohci(hcd));
121
122 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
123 if (retval == 0)
124 return retval;
125
126 iounmap(hcd->regs);
127err2:
128 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
129err1:
130 usb_put_hcd(hcd);
131 return retval;
132}
133
134static int cns3xxx_ohci_remove(struct platform_device *pdev)
135{
136 struct usb_hcd *hcd = platform_get_drvdata(pdev);
137
138 usb_remove_hcd(hcd);
139 iounmap(hcd->regs);
140 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
141
142 /*
143 * EHCI and OHCI share the same clock and power,
144 * resetting twice would cause the 1st controller been reset.
145 * Therefore only do power up at the first up device, and
146 * power down at the last down device.
147 */
148 if (atomic_dec_return(&usb_pwr_ref) == 0)
149 cns3xxx_pwr_clk_dis(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST);
150
151 usb_put_hcd(hcd);
152
153 platform_set_drvdata(pdev, NULL);
154
155 return 0;
156}
157
158MODULE_ALIAS("platform:cns3xxx-ohci");
159
160static struct platform_driver ohci_hcd_cns3xxx_driver = {
161 .probe = cns3xxx_ohci_probe,
162 .remove = cns3xxx_ohci_remove,
163 .driver = {
164 .name = "cns3xxx-ohci",
165 },
166};
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index dbfbd1dfd2e2..8704e9fa5a80 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -107,7 +107,7 @@ static void usb_hcd_ep93xx_remove(struct usb_hcd *hcd,
107 usb_put_hcd(hcd); 107 usb_put_hcd(hcd);
108} 108}
109 109
110static int __devinit ohci_ep93xx_start(struct usb_hcd *hcd) 110static int ohci_ep93xx_start(struct usb_hcd *hcd)
111{ 111{
112 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 112 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
113 int ret; 113 int ret;
@@ -194,7 +194,7 @@ static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev)
194 194
195 ep93xx_start_hc(&pdev->dev); 195 ep93xx_start_hc(&pdev->dev);
196 196
197 ohci_finish_controller_resume(hcd); 197 ohci_resume(hcd, false);
198 return 0; 198 return 0;
199} 199}
200#endif 200#endif
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index 20a50081f922..aa3b8844bb9f 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -23,6 +23,11 @@ struct exynos_ohci_hcd {
23 struct clk *clk; 23 struct clk *clk;
24}; 24};
25 25
26static int ohci_exynos_reset(struct usb_hcd *hcd)
27{
28 return ohci_init(hcd_to_ohci(hcd));
29}
30
26static int ohci_exynos_start(struct usb_hcd *hcd) 31static int ohci_exynos_start(struct usb_hcd *hcd)
27{ 32{
28 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 33 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
@@ -30,10 +35,6 @@ static int ohci_exynos_start(struct usb_hcd *hcd)
30 35
31 ohci_dbg(ohci, "ohci_exynos_start, ohci:%p", ohci); 36 ohci_dbg(ohci, "ohci_exynos_start, ohci:%p", ohci);
32 37
33 ret = ohci_init(ohci);
34 if (ret < 0)
35 return ret;
36
37 ret = ohci_run(ohci); 38 ret = ohci_run(ohci);
38 if (ret < 0) { 39 if (ret < 0) {
39 dev_err(hcd->self.controller, "can't start %s\n", 40 dev_err(hcd->self.controller, "can't start %s\n",
@@ -53,6 +54,7 @@ static const struct hc_driver exynos_ohci_hc_driver = {
53 .irq = ohci_irq, 54 .irq = ohci_irq,
54 .flags = HCD_MEMORY|HCD_USB11, 55 .flags = HCD_MEMORY|HCD_USB11,
55 56
57 .reset = ohci_exynos_reset,
56 .start = ohci_exynos_start, 58 .start = ohci_exynos_start,
57 .stop = ohci_stop, 59 .stop = ohci_stop,
58 .shutdown = ohci_shutdown, 60 .shutdown = ohci_shutdown,
@@ -74,7 +76,7 @@ static const struct hc_driver exynos_ohci_hc_driver = {
74 76
75static u64 ohci_exynos_dma_mask = DMA_BIT_MASK(32); 77static u64 ohci_exynos_dma_mask = DMA_BIT_MASK(32);
76 78
77static int __devinit exynos_ohci_probe(struct platform_device *pdev) 79static int exynos_ohci_probe(struct platform_device *pdev)
78{ 80{
79 struct exynos4_ohci_platdata *pdata; 81 struct exynos4_ohci_platdata *pdata;
80 struct exynos_ohci_hcd *exynos_ohci; 82 struct exynos_ohci_hcd *exynos_ohci;
@@ -115,7 +117,7 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
115 } 117 }
116 118
117 exynos_ohci->hcd = hcd; 119 exynos_ohci->hcd = hcd;
118 exynos_ohci->clk = clk_get(&pdev->dev, "usbhost"); 120 exynos_ohci->clk = devm_clk_get(&pdev->dev, "usbhost");
119 121
120 if (IS_ERR(exynos_ohci->clk)) { 122 if (IS_ERR(exynos_ohci->clk)) {
121 dev_err(&pdev->dev, "Failed to get usbhost clock\n"); 123 dev_err(&pdev->dev, "Failed to get usbhost clock\n");
@@ -123,9 +125,9 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
123 goto fail_clk; 125 goto fail_clk;
124 } 126 }
125 127
126 err = clk_enable(exynos_ohci->clk); 128 err = clk_prepare_enable(exynos_ohci->clk);
127 if (err) 129 if (err)
128 goto fail_clken; 130 goto fail_clk;
129 131
130 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 132 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
131 if (!res) { 133 if (!res) {
@@ -167,15 +169,13 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
167 return 0; 169 return 0;
168 170
169fail_io: 171fail_io:
170 clk_disable(exynos_ohci->clk); 172 clk_disable_unprepare(exynos_ohci->clk);
171fail_clken:
172 clk_put(exynos_ohci->clk);
173fail_clk: 173fail_clk:
174 usb_put_hcd(hcd); 174 usb_put_hcd(hcd);
175 return err; 175 return err;
176} 176}
177 177
178static int __devexit exynos_ohci_remove(struct platform_device *pdev) 178static int exynos_ohci_remove(struct platform_device *pdev)
179{ 179{
180 struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data; 180 struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
181 struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev); 181 struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev);
@@ -186,8 +186,7 @@ static int __devexit exynos_ohci_remove(struct platform_device *pdev)
186 if (pdata && pdata->phy_exit) 186 if (pdata && pdata->phy_exit)
187 pdata->phy_exit(pdev, S5P_USB_PHY_HOST); 187 pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
188 188
189 clk_disable(exynos_ohci->clk); 189 clk_disable_unprepare(exynos_ohci->clk);
190 clk_put(exynos_ohci->clk);
191 190
192 usb_put_hcd(hcd); 191 usb_put_hcd(hcd);
193 192
@@ -232,7 +231,7 @@ static int exynos_ohci_suspend(struct device *dev)
232 if (pdata && pdata->phy_exit) 231 if (pdata && pdata->phy_exit)
233 pdata->phy_exit(pdev, S5P_USB_PHY_HOST); 232 pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
234 233
235 clk_disable(exynos_ohci->clk); 234 clk_disable_unprepare(exynos_ohci->clk);
236 235
237fail: 236fail:
238 spin_unlock_irqrestore(&ohci->lock, flags); 237 spin_unlock_irqrestore(&ohci->lock, flags);
@@ -247,15 +246,12 @@ static int exynos_ohci_resume(struct device *dev)
247 struct platform_device *pdev = to_platform_device(dev); 246 struct platform_device *pdev = to_platform_device(dev);
248 struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data; 247 struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
249 248
250 clk_enable(exynos_ohci->clk); 249 clk_prepare_enable(exynos_ohci->clk);
251 250
252 if (pdata && pdata->phy_init) 251 if (pdata && pdata->phy_init)
253 pdata->phy_init(pdev, S5P_USB_PHY_HOST); 252 pdata->phy_init(pdev, S5P_USB_PHY_HOST);
254 253
255 /* Mark hardware accessible again as we are out of D3 state by now */ 254 ohci_resume(hcd, false);
256 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
257
258 ohci_finish_controller_resume(hcd);
259 255
260 return 0; 256 return 0;
261} 257}
@@ -279,7 +275,7 @@ MODULE_DEVICE_TABLE(of, exynos_ohci_match);
279 275
280static struct platform_driver exynos_ohci_driver = { 276static struct platform_driver exynos_ohci_driver = {
281 .probe = exynos_ohci_probe, 277 .probe = exynos_ohci_probe,
282 .remove = __devexit_p(exynos_ohci_remove), 278 .remove = exynos_ohci_remove,
283 .shutdown = exynos_ohci_shutdown, 279 .shutdown = exynos_ohci_shutdown,
284 .driver = { 280 .driver = {
285 .name = "exynos-ohci", 281 .name = "exynos-ohci",
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 4a1d64d92338..180a2b01db56 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -231,13 +231,41 @@ static int ohci_urb_enqueue (
231 frame &= ~(ed->interval - 1); 231 frame &= ~(ed->interval - 1);
232 frame |= ed->branch; 232 frame |= ed->branch;
233 urb->start_frame = frame; 233 urb->start_frame = frame;
234 }
235 } else if (ed->type == PIPE_ISOCHRONOUS) {
236 u16 next = ohci_frame_no(ohci) + 2;
237 u16 frame = ed->last_iso + ed->interval;
238
239 /* Behind the scheduling threshold? */
240 if (unlikely(tick_before(frame, next))) {
234 241
235 /* yes, only URB_ISO_ASAP is supported, and 242 /* USB_ISO_ASAP: Round up to the first available slot */
236 * urb->start_frame is never used as input. 243 if (urb->transfer_flags & URB_ISO_ASAP)
244 frame += (next - frame + ed->interval - 1) &
245 -ed->interval;
246
247 /*
248 * Not ASAP: Use the next slot in the stream. If
249 * the entire URB falls before the threshold, fail.
237 */ 250 */
251 else if (tick_before(frame + ed->interval *
252 (urb->number_of_packets - 1), next)) {
253 retval = -EXDEV;
254 usb_hcd_unlink_urb_from_ep(hcd, urb);
255 goto fail;
256 }
257
258 /*
259 * Some OHCI hardware doesn't handle late TDs
260 * correctly. After retiring them it proceeds to
261 * the next ED instead of the next TD. Therefore
262 * we have to omit the late TDs entirely.
263 */
264 urb_priv->td_cnt = DIV_ROUND_UP(next - frame,
265 ed->interval);
238 } 266 }
239 } else if (ed->type == PIPE_ISOCHRONOUS) 267 urb->start_frame = frame;
240 urb->start_frame = ed->last_iso + ed->interval; 268 }
241 269
242 /* fill the TDs and link them to the ed; and 270 /* fill the TDs and link them to the ed; and
243 * enable that part of the schedule, if needed 271 * enable that part of the schedule, if needed
@@ -983,6 +1011,79 @@ static int ohci_restart (struct ohci_hcd *ohci)
983 1011
984#endif 1012#endif
985 1013
1014#ifdef CONFIG_PM
1015
1016static int __maybe_unused ohci_suspend(struct usb_hcd *hcd, bool do_wakeup)
1017{
1018 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
1019 unsigned long flags;
1020
1021 /* Disable irq emission and mark HW unaccessible. Use
1022 * the spinlock to properly synchronize with possible pending
1023 * RH suspend or resume activity.
1024 */
1025 spin_lock_irqsave (&ohci->lock, flags);
1026 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
1027 (void)ohci_readl(ohci, &ohci->regs->intrdisable);
1028
1029 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
1030 spin_unlock_irqrestore (&ohci->lock, flags);
1031
1032 return 0;
1033}
1034
1035
1036static int __maybe_unused ohci_resume(struct usb_hcd *hcd, bool hibernated)
1037{
1038 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
1039 int port;
1040 bool need_reinit = false;
1041
1042 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
1043
1044 /* Make sure resume from hibernation re-enumerates everything */
1045 if (hibernated)
1046 ohci_usb_reset(ohci);
1047
1048 /* See if the controller is already running or has been reset */
1049 ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
1050 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) {
1051 need_reinit = true;
1052 } else {
1053 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
1054 case OHCI_USB_OPER:
1055 case OHCI_USB_RESET:
1056 need_reinit = true;
1057 }
1058 }
1059
1060 /* If needed, reinitialize and suspend the root hub */
1061 if (need_reinit) {
1062 spin_lock_irq(&ohci->lock);
1063 ohci_rh_resume(ohci);
1064 ohci_rh_suspend(ohci, 0);
1065 spin_unlock_irq(&ohci->lock);
1066 }
1067
1068 /* Normally just turn on port power and enable interrupts */
1069 else {
1070 ohci_dbg(ohci, "powerup ports\n");
1071 for (port = 0; port < ohci->num_ports; port++)
1072 ohci_writel(ohci, RH_PS_PPS,
1073 &ohci->regs->roothub.portstatus[port]);
1074
1075 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable);
1076 ohci_readl(ohci, &ohci->regs->intrenable);
1077 msleep(20);
1078 }
1079
1080 usb_hcd_resume_root_hub(hcd);
1081
1082 return 0;
1083}
1084
1085#endif
1086
986/*-------------------------------------------------------------------------*/ 1087/*-------------------------------------------------------------------------*/
987 1088
988MODULE_AUTHOR (DRIVER_AUTHOR); 1089MODULE_AUTHOR (DRIVER_AUTHOR);
@@ -1029,21 +1130,6 @@ MODULE_LICENSE ("GPL");
1029#define PLATFORM_DRIVER ohci_hcd_ep93xx_driver 1130#define PLATFORM_DRIVER ohci_hcd_ep93xx_driver
1030#endif 1131#endif
1031 1132
1032#ifdef CONFIG_MIPS_ALCHEMY
1033#include "ohci-au1xxx.c"
1034#define PLATFORM_DRIVER ohci_hcd_au1xxx_driver
1035#endif
1036
1037#ifdef CONFIG_PNX8550
1038#include "ohci-pnx8550.c"
1039#define PLATFORM_DRIVER ohci_hcd_pnx8550_driver
1040#endif
1041
1042#ifdef CONFIG_USB_OHCI_HCD_PPC_SOC
1043#include "ohci-ppc-soc.c"
1044#define PLATFORM_DRIVER ohci_hcd_ppc_soc_driver
1045#endif
1046
1047#ifdef CONFIG_ARCH_AT91 1133#ifdef CONFIG_ARCH_AT91
1048#include "ohci-at91.c" 1134#include "ohci-at91.c"
1049#define PLATFORM_DRIVER ohci_hcd_at91_driver 1135#define PLATFORM_DRIVER ohci_hcd_at91_driver
@@ -1059,11 +1145,6 @@ MODULE_LICENSE ("GPL");
1059#define PLATFORM_DRIVER ohci_hcd_da8xx_driver 1145#define PLATFORM_DRIVER ohci_hcd_da8xx_driver
1060#endif 1146#endif
1061 1147
1062#ifdef CONFIG_USB_OHCI_SH
1063#include "ohci-sh.c"
1064#define PLATFORM_DRIVER ohci_hcd_sh_driver
1065#endif
1066
1067 1148
1068#ifdef CONFIG_USB_OHCI_HCD_PPC_OF 1149#ifdef CONFIG_USB_OHCI_HCD_PPC_OF
1069#include "ohci-ppc-of.c" 1150#include "ohci-ppc-of.c"
@@ -1105,16 +1186,6 @@ MODULE_LICENSE ("GPL");
1105#define PLATFORM_DRIVER ohci_hcd_tilegx_driver 1186#define PLATFORM_DRIVER ohci_hcd_tilegx_driver
1106#endif 1187#endif
1107 1188
1108#ifdef CONFIG_USB_CNS3XXX_OHCI
1109#include "ohci-cns3xxx.c"
1110#define PLATFORM_DRIVER ohci_hcd_cns3xxx_driver
1111#endif
1112
1113#ifdef CONFIG_CPU_XLR
1114#include "ohci-xls.c"
1115#define PLATFORM_DRIVER ohci_xls_driver
1116#endif
1117
1118#ifdef CONFIG_USB_OHCI_HCD_PLATFORM 1189#ifdef CONFIG_USB_OHCI_HCD_PLATFORM
1119#include "ohci-platform.c" 1190#include "ohci-platform.c"
1120#define PLATFORM_DRIVER ohci_platform_driver 1191#define PLATFORM_DRIVER ohci_platform_driver
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 2f3619eefefa..db09dae7b557 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -316,48 +316,6 @@ static int ohci_bus_resume (struct usb_hcd *hcd)
316 return rc; 316 return rc;
317} 317}
318 318
319/* Carry out the final steps of resuming the controller device */
320static void __maybe_unused ohci_finish_controller_resume(struct usb_hcd *hcd)
321{
322 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
323 int port;
324 bool need_reinit = false;
325
326 /* See if the controller is already running or has been reset */
327 ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
328 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) {
329 need_reinit = true;
330 } else {
331 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
332 case OHCI_USB_OPER:
333 case OHCI_USB_RESET:
334 need_reinit = true;
335 }
336 }
337
338 /* If needed, reinitialize and suspend the root hub */
339 if (need_reinit) {
340 spin_lock_irq(&ohci->lock);
341 ohci_rh_resume(ohci);
342 ohci_rh_suspend(ohci, 0);
343 spin_unlock_irq(&ohci->lock);
344 }
345
346 /* Normally just turn on port power and enable interrupts */
347 else {
348 ohci_dbg(ohci, "powerup ports\n");
349 for (port = 0; port < ohci->num_ports; port++)
350 ohci_writel(ohci, RH_PS_PPS,
351 &ohci->regs->roothub.portstatus[port]);
352
353 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable);
354 ohci_readl(ohci, &ohci->regs->intrenable);
355 msleep(20);
356 }
357
358 usb_hcd_resume_root_hub(hcd);
359}
360
361/* Carry out polling-, autostop-, and autoresume-related state changes */ 319/* Carry out polling-, autostop-, and autoresume-related state changes */
362static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, 320static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
363 int any_connected, int rhsc_status) 321 int any_connected, int rhsc_status)
diff --git a/drivers/usb/host/ohci-jz4740.c b/drivers/usb/host/ohci-jz4740.c
index 931d588c3fb5..8062bb9dea16 100644
--- a/drivers/usb/host/ohci-jz4740.c
+++ b/drivers/usb/host/ohci-jz4740.c
@@ -145,7 +145,7 @@ static const struct hc_driver ohci_jz4740_hc_driver = {
145}; 145};
146 146
147 147
148static __devinit int jz4740_ohci_probe(struct platform_device *pdev) 148static int jz4740_ohci_probe(struct platform_device *pdev)
149{ 149{
150 int ret; 150 int ret;
151 struct usb_hcd *hcd; 151 struct usb_hcd *hcd;
@@ -239,7 +239,7 @@ err_free:
239 return ret; 239 return ret;
240} 240}
241 241
242static __devexit int jz4740_ohci_remove(struct platform_device *pdev) 242static int jz4740_ohci_remove(struct platform_device *pdev)
243{ 243{
244 struct usb_hcd *hcd = platform_get_drvdata(pdev); 244 struct usb_hcd *hcd = platform_get_drvdata(pdev);
245 struct jz4740_ohci_hcd *jz4740_ohci = hcd_to_jz4740_hcd(hcd); 245 struct jz4740_ohci_hcd *jz4740_ohci = hcd_to_jz4740_hcd(hcd);
@@ -266,7 +266,7 @@ static __devexit int jz4740_ohci_remove(struct platform_device *pdev)
266 266
267static struct platform_driver ohci_hcd_jz4740_driver = { 267static struct platform_driver ohci_hcd_jz4740_driver = {
268 .probe = jz4740_ohci_probe, 268 .probe = jz4740_ohci_probe,
269 .remove = __devexit_p(jz4740_ohci_remove), 269 .remove = jz4740_ohci_remove,
270 .driver = { 270 .driver = {
271 .name = "jz4740-ohci", 271 .name = "jz4740-ohci",
272 .owner = THIS_MODULE, 272 .owner = THIS_MODULE,
diff --git a/drivers/usb/host/ohci-nxp.c b/drivers/usb/host/ohci-nxp.c
index e068f034cb9b..2344040c16d2 100644
--- a/drivers/usb/host/ohci-nxp.c
+++ b/drivers/usb/host/ohci-nxp.c
@@ -147,7 +147,7 @@ static void nxp_stop_hc(void)
147 __raw_writel(tmp, USB_OTG_STAT_CONTROL); 147 __raw_writel(tmp, USB_OTG_STAT_CONTROL);
148} 148}
149 149
150static int __devinit ohci_nxp_start(struct usb_hcd *hcd) 150static int ohci_nxp_start(struct usb_hcd *hcd)
151{ 151{
152 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 152 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
153 int ret; 153 int ret;
@@ -205,7 +205,7 @@ static const struct hc_driver ohci_nxp_hc_driver = {
205 .start_port_reset = ohci_start_port_reset, 205 .start_port_reset = ohci_start_port_reset,
206}; 206};
207 207
208static int __devinit usb_hcd_nxp_probe(struct platform_device *pdev) 208static int usb_hcd_nxp_probe(struct platform_device *pdev)
209{ 209{
210 struct usb_hcd *hcd = 0; 210 struct usb_hcd *hcd = 0;
211 struct ohci_hcd *ohci; 211 struct ohci_hcd *ohci;
diff --git a/drivers/usb/host/ohci-octeon.c b/drivers/usb/host/ohci-octeon.c
index d469bf9b9e54..d44430d009f8 100644
--- a/drivers/usb/host/ohci-octeon.c
+++ b/drivers/usb/host/ohci-octeon.c
@@ -42,7 +42,7 @@ static void ohci_octeon_hw_stop(void)
42 octeon2_usb_clocks_stop(); 42 octeon2_usb_clocks_stop();
43} 43}
44 44
45static int __devinit ohci_octeon_start(struct usb_hcd *hcd) 45static int ohci_octeon_start(struct usb_hcd *hcd)
46{ 46{
47 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 47 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
48 int ret; 48 int ret;
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index 4531d03503c3..733c77c36355 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -530,7 +530,7 @@ static int ohci_omap_resume(struct platform_device *dev)
530 ohci->next_statechange = jiffies; 530 ohci->next_statechange = jiffies;
531 531
532 omap_ohci_clock_power(1); 532 omap_ohci_clock_power(1);
533 ohci_finish_controller_resume(hcd); 533 ohci_resume(hcd, false);
534 return 0; 534 return 0;
535} 535}
536 536
diff --git a/drivers/usb/host/ohci-omap3.c b/drivers/usb/host/ohci-omap3.c
index 1b8133b6e451..4382af3a45f9 100644
--- a/drivers/usb/host/ohci-omap3.c
+++ b/drivers/usb/host/ohci-omap3.c
@@ -125,7 +125,7 @@ static const struct hc_driver ohci_omap3_hc_driver = {
125 * then invokes the start() method for the HCD associated with it 125 * then invokes the start() method for the HCD associated with it
126 * through the hotplug entry's driver_data. 126 * through the hotplug entry's driver_data.
127 */ 127 */
128static int __devinit ohci_hcd_omap3_probe(struct platform_device *pdev) 128static int ohci_hcd_omap3_probe(struct platform_device *pdev)
129{ 129{
130 struct device *dev = &pdev->dev; 130 struct device *dev = &pdev->dev;
131 struct usb_hcd *hcd = NULL; 131 struct usb_hcd *hcd = NULL;
@@ -209,7 +209,7 @@ err_io:
209 * the HCD's stop() method. It is always called from a thread 209 * the HCD's stop() method. It is always called from a thread
210 * context, normally "rmmod", "apmd", or something similar. 210 * context, normally "rmmod", "apmd", or something similar.
211 */ 211 */
212static int __devexit ohci_hcd_omap3_remove(struct platform_device *pdev) 212static int ohci_hcd_omap3_remove(struct platform_device *pdev)
213{ 213{
214 struct device *dev = &pdev->dev; 214 struct device *dev = &pdev->dev;
215 struct usb_hcd *hcd = dev_get_drvdata(dev); 215 struct usb_hcd *hcd = dev_get_drvdata(dev);
@@ -232,7 +232,7 @@ static void ohci_hcd_omap3_shutdown(struct platform_device *pdev)
232 232
233static struct platform_driver ohci_hcd_omap3_driver = { 233static struct platform_driver ohci_hcd_omap3_driver = {
234 .probe = ohci_hcd_omap3_probe, 234 .probe = ohci_hcd_omap3_probe,
235 .remove = __devexit_p(ohci_hcd_omap3_remove), 235 .remove = ohci_hcd_omap3_remove,
236 .shutdown = ohci_hcd_omap3_shutdown, 236 .shutdown = ohci_hcd_omap3_shutdown,
237 .driver = { 237 .driver = {
238 .name = "ohci-omap3", 238 .name = "ohci-omap3",
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index 1843bb68ac7c..951514ef446d 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -270,7 +270,7 @@ static int ohci_pci_reset (struct usb_hcd *hcd)
270} 270}
271 271
272 272
273static int __devinit ohci_pci_start (struct usb_hcd *hcd) 273static int ohci_pci_start (struct usb_hcd *hcd)
274{ 274{
275 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 275 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
276 int ret; 276 int ret;
@@ -296,49 +296,6 @@ static int __devinit ohci_pci_start (struct usb_hcd *hcd)
296 return ret; 296 return ret;
297} 297}
298 298
299#ifdef CONFIG_PM
300
301static int ohci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
302{
303 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
304 unsigned long flags;
305 int rc = 0;
306
307 /* Root hub was already suspended. Disable irq emission and
308 * mark HW unaccessible, bail out if RH has been resumed. Use
309 * the spinlock to properly synchronize with possible pending
310 * RH suspend or resume activity.
311 */
312 spin_lock_irqsave (&ohci->lock, flags);
313 if (ohci->rh_state != OHCI_RH_SUSPENDED) {
314 rc = -EINVAL;
315 goto bail;
316 }
317 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
318 (void)ohci_readl(ohci, &ohci->regs->intrdisable);
319
320 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
321 bail:
322 spin_unlock_irqrestore (&ohci->lock, flags);
323
324 return rc;
325}
326
327
328static int ohci_pci_resume(struct usb_hcd *hcd, bool hibernated)
329{
330 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
331
332 /* Make sure resume from hibernation re-enumerates everything */
333 if (hibernated)
334 ohci_usb_reset(hcd_to_ohci(hcd));
335
336 ohci_finish_controller_resume(hcd);
337 return 0;
338}
339
340#endif /* CONFIG_PM */
341
342 299
343/*-------------------------------------------------------------------------*/ 300/*-------------------------------------------------------------------------*/
344 301
@@ -362,8 +319,8 @@ static const struct hc_driver ohci_pci_hc_driver = {
362 .shutdown = ohci_shutdown, 319 .shutdown = ohci_shutdown,
363 320
364#ifdef CONFIG_PM 321#ifdef CONFIG_PM
365 .pci_suspend = ohci_pci_suspend, 322 .pci_suspend = ohci_suspend,
366 .pci_resume = ohci_pci_resume, 323 .pci_resume = ohci_resume,
367#endif 324#endif
368 325
369 /* 326 /*
diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index e24ec9f79164..084503b03fcf 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -31,6 +31,10 @@ static int ohci_platform_reset(struct usb_hcd *hcd)
31 ohci->flags |= OHCI_QUIRK_FRAME_NO; 31 ohci->flags |= OHCI_QUIRK_FRAME_NO;
32 32
33 ohci_hcd_init(ohci); 33 ohci_hcd_init(ohci);
34
35 if (pdata->num_ports)
36 ohci->num_ports = pdata->num_ports;
37
34 err = ohci_init(ohci); 38 err = ohci_init(ohci);
35 39
36 return err; 40 return err;
@@ -79,7 +83,7 @@ static const struct hc_driver ohci_platform_hc_driver = {
79 .start_port_reset = ohci_start_port_reset, 83 .start_port_reset = ohci_start_port_reset,
80}; 84};
81 85
82static int __devinit ohci_platform_probe(struct platform_device *dev) 86static int ohci_platform_probe(struct platform_device *dev)
83{ 87{
84 struct usb_hcd *hcd; 88 struct usb_hcd *hcd;
85 struct resource *res_mem; 89 struct resource *res_mem;
@@ -97,13 +101,13 @@ static int __devinit ohci_platform_probe(struct platform_device *dev)
97 101
98 irq = platform_get_irq(dev, 0); 102 irq = platform_get_irq(dev, 0);
99 if (irq < 0) { 103 if (irq < 0) {
100 pr_err("no irq provided"); 104 dev_err(&dev->dev, "no irq provided");
101 return irq; 105 return irq;
102 } 106 }
103 107
104 res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0); 108 res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
105 if (!res_mem) { 109 if (!res_mem) {
106 pr_err("no memory recourse provided"); 110 dev_err(&dev->dev, "no memory resource provided");
107 return -ENXIO; 111 return -ENXIO;
108 } 112 }
109 113
@@ -123,29 +127,19 @@ static int __devinit ohci_platform_probe(struct platform_device *dev)
123 hcd->rsrc_start = res_mem->start; 127 hcd->rsrc_start = res_mem->start;
124 hcd->rsrc_len = resource_size(res_mem); 128 hcd->rsrc_len = resource_size(res_mem);
125 129
126 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 130 hcd->regs = devm_request_and_ioremap(&dev->dev, res_mem);
127 pr_err("controller already in use");
128 err = -EBUSY;
129 goto err_put_hcd;
130 }
131
132 hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
133 if (!hcd->regs) { 131 if (!hcd->regs) {
134 err = -ENOMEM; 132 err = -ENOMEM;
135 goto err_release_region; 133 goto err_put_hcd;
136 } 134 }
137 err = usb_add_hcd(hcd, irq, IRQF_SHARED); 135 err = usb_add_hcd(hcd, irq, IRQF_SHARED);
138 if (err) 136 if (err)
139 goto err_iounmap; 137 goto err_put_hcd;
140 138
141 platform_set_drvdata(dev, hcd); 139 platform_set_drvdata(dev, hcd);
142 140
143 return err; 141 return err;
144 142
145err_iounmap:
146 iounmap(hcd->regs);
147err_release_region:
148 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
149err_put_hcd: 143err_put_hcd:
150 usb_put_hcd(hcd); 144 usb_put_hcd(hcd);
151err_power: 145err_power:
@@ -155,14 +149,12 @@ err_power:
155 return err; 149 return err;
156} 150}
157 151
158static int __devexit ohci_platform_remove(struct platform_device *dev) 152static int ohci_platform_remove(struct platform_device *dev)
159{ 153{
160 struct usb_hcd *hcd = platform_get_drvdata(dev); 154 struct usb_hcd *hcd = platform_get_drvdata(dev);
161 struct usb_ohci_pdata *pdata = dev->dev.platform_data; 155 struct usb_ohci_pdata *pdata = dev->dev.platform_data;
162 156
163 usb_remove_hcd(hcd); 157 usb_remove_hcd(hcd);
164 iounmap(hcd->regs);
165 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
166 usb_put_hcd(hcd); 158 usb_put_hcd(hcd);
167 platform_set_drvdata(dev, NULL); 159 platform_set_drvdata(dev, NULL);
168 160
@@ -199,7 +191,7 @@ static int ohci_platform_resume(struct device *dev)
199 return err; 191 return err;
200 } 192 }
201 193
202 ohci_finish_controller_resume(hcd); 194 ohci_resume(hcd, false);
203 return 0; 195 return 0;
204} 196}
205 197
@@ -222,7 +214,7 @@ static const struct dev_pm_ops ohci_platform_pm_ops = {
222static struct platform_driver ohci_platform_driver = { 214static struct platform_driver ohci_platform_driver = {
223 .id_table = ohci_platform_table, 215 .id_table = ohci_platform_table,
224 .probe = ohci_platform_probe, 216 .probe = ohci_platform_probe,
225 .remove = __devexit_p(ohci_platform_remove), 217 .remove = ohci_platform_remove,
226 .shutdown = usb_hcd_platform_shutdown, 218 .shutdown = usb_hcd_platform_shutdown,
227 .driver = { 219 .driver = {
228 .owner = THIS_MODULE, 220 .owner = THIS_MODULE,
diff --git a/drivers/usb/host/ohci-pnx8550.c b/drivers/usb/host/ohci-pnx8550.c
deleted file mode 100644
index 148d27d6a67c..000000000000
--- a/drivers/usb/host/ohci-pnx8550.c
+++ /dev/null
@@ -1,243 +0,0 @@
1/*
2 * OHCI HCD (Host Controller Driver) for USB.
3 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * (C) Copyright 2002 Hewlett-Packard Company
7 * (C) Copyright 2005 Embedded Alley Solutions, Inc.
8 *
9 * Bus Glue for PNX8550
10 *
11 * Written by Christopher Hoover <ch@hpl.hp.com>
12 * Based on fragments of previous driver by Russell King et al.
13 *
14 * Modified for LH7A404 from ohci-sa1111.c
15 * by Durgesh Pattamatta <pattamattad@sharpsec.com>
16 *
17 * Modified for PNX8550 from ohci-sa1111.c and sa-omap.c
18 * by Vitaly Wool <vitalywool@gmail.com>
19 *
20 * This file is licenced under the GPL.
21 */
22
23#include <linux/device.h>
24#include <linux/platform_device.h>
25#include <asm/mach-pnx8550/usb.h>
26#include <asm/mach-pnx8550/int.h>
27#include <asm/mach-pnx8550/pci.h>
28
29#ifndef CONFIG_PNX8550
30#error "This file is PNX8550 bus glue. CONFIG_PNX8550 must be defined."
31#endif
32
33extern int usb_disabled(void);
34
35/*-------------------------------------------------------------------------*/
36
37static void pnx8550_start_hc(struct platform_device *dev)
38{
39 /*
40 * Set register CLK48CTL to enable and 48MHz
41 */
42 outl(0x00000003, PCI_BASE | 0x0004770c);
43
44 /*
45 * Set register CLK12CTL to enable and 48MHz
46 */
47 outl(0x00000003, PCI_BASE | 0x00047710);
48
49 udelay(100);
50}
51
52static void pnx8550_stop_hc(struct platform_device *dev)
53{
54 udelay(10);
55}
56
57
58/*-------------------------------------------------------------------------*/
59
60/* configure so an HC device and id are always provided */
61/* always called with process context; sleeping is OK */
62
63
64/**
65 * usb_hcd_pnx8550_probe - initialize pnx8550-based HCDs
66 * Context: !in_interrupt()
67 *
68 * Allocates basic resources for this USB host controller, and
69 * then invokes the start() method for the HCD associated with it
70 * through the hotplug entry's driver_data.
71 *
72 */
73int usb_hcd_pnx8550_probe (const struct hc_driver *driver,
74 struct platform_device *dev)
75{
76 int retval;
77 struct usb_hcd *hcd;
78
79 if (dev->resource[0].flags != IORESOURCE_MEM ||
80 dev->resource[1].flags != IORESOURCE_IRQ) {
81 dev_err (&dev->dev,"invalid resource type\n");
82 return -ENOMEM;
83 }
84
85 hcd = usb_create_hcd (driver, &dev->dev, "pnx8550");
86 if (!hcd)
87 return -ENOMEM;
88 hcd->rsrc_start = dev->resource[0].start;
89 hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1;
90
91 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
92 dev_err(&dev->dev, "request_mem_region [0x%08llx, 0x%08llx] "
93 "failed\n", hcd->rsrc_start, hcd->rsrc_len);
94 retval = -EBUSY;
95 goto err1;
96 }
97
98 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
99 if (!hcd->regs) {
100 dev_err(&dev->dev, "ioremap [[0x%08llx, 0x%08llx] failed\n",
101 hcd->rsrc_start, hcd->rsrc_len);
102 retval = -ENOMEM;
103 goto err2;
104 }
105
106 pnx8550_start_hc(dev);
107
108 ohci_hcd_init(hcd_to_ohci(hcd));
109
110 retval = usb_add_hcd(hcd, dev->resource[1].start, 0);
111 if (retval == 0)
112 return retval;
113
114 pnx8550_stop_hc(dev);
115 iounmap(hcd->regs);
116 err2:
117 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
118 err1:
119 usb_put_hcd(hcd);
120 return retval;
121}
122
123
124/* may be called without controller electrically present */
125/* may be called with controller, bus, and devices active */
126
127/**
128 * usb_hcd_pnx8550_remove - shutdown processing for pnx8550-based HCDs
129 * @dev: USB Host Controller being removed
130 * Context: !in_interrupt()
131 *
132 * Reverses the effect of usb_hcd_pnx8550_probe(), first invoking
133 * the HCD's stop() method. It is always called from a thread
134 * context, normally "rmmod", "apmd", or something similar.
135 *
136 */
137void usb_hcd_pnx8550_remove (struct usb_hcd *hcd, struct platform_device *dev)
138{
139 usb_remove_hcd(hcd);
140 pnx8550_stop_hc(dev);
141 iounmap(hcd->regs);
142 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
143 usb_put_hcd(hcd);
144}
145
146/*-------------------------------------------------------------------------*/
147
148static int __devinit
149ohci_pnx8550_start (struct usb_hcd *hcd)
150{
151 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
152 int ret;
153
154 ohci_dbg (ohci, "ohci_pnx8550_start, ohci:%p", ohci);
155
156 if ((ret = ohci_init(ohci)) < 0)
157 return ret;
158
159 if ((ret = ohci_run (ohci)) < 0) {
160 dev_err(hcd->self.controller, "can't start %s",
161 hcd->self.bus_name);
162 ohci_stop (hcd);
163 return ret;
164 }
165
166 return 0;
167}
168
169/*-------------------------------------------------------------------------*/
170
171static const struct hc_driver ohci_pnx8550_hc_driver = {
172 .description = hcd_name,
173 .product_desc = "PNX8550 OHCI",
174 .hcd_priv_size = sizeof(struct ohci_hcd),
175
176 /*
177 * generic hardware linkage
178 */
179 .irq = ohci_irq,
180 .flags = HCD_USB11 | HCD_MEMORY,
181
182 /*
183 * basic lifecycle operations
184 */
185 .start = ohci_pnx8550_start,
186 .stop = ohci_stop,
187
188 /*
189 * managing i/o requests and associated device resources
190 */
191 .urb_enqueue = ohci_urb_enqueue,
192 .urb_dequeue = ohci_urb_dequeue,
193 .endpoint_disable = ohci_endpoint_disable,
194
195 /*
196 * scheduling support
197 */
198 .get_frame_number = ohci_get_frame,
199
200 /*
201 * root hub support
202 */
203 .hub_status_data = ohci_hub_status_data,
204 .hub_control = ohci_hub_control,
205#ifdef CONFIG_PM
206 .bus_suspend = ohci_bus_suspend,
207 .bus_resume = ohci_bus_resume,
208#endif
209 .start_port_reset = ohci_start_port_reset,
210};
211
212/*-------------------------------------------------------------------------*/
213
214static int ohci_hcd_pnx8550_drv_probe(struct platform_device *pdev)
215{
216 int ret;
217
218 if (usb_disabled())
219 return -ENODEV;
220
221 ret = usb_hcd_pnx8550_probe(&ohci_pnx8550_hc_driver, pdev);
222 return ret;
223}
224
225static int ohci_hcd_pnx8550_drv_remove(struct platform_device *pdev)
226{
227 struct usb_hcd *hcd = platform_get_drvdata(pdev);
228
229 usb_hcd_pnx8550_remove(hcd, pdev);
230 return 0;
231}
232
233MODULE_ALIAS("platform:pnx8550-ohci");
234
235static struct platform_driver ohci_hcd_pnx8550_driver = {
236 .driver = {
237 .name = "pnx8550-ohci",
238 .owner = THIS_MODULE,
239 },
240 .probe = ohci_hcd_pnx8550_drv_probe,
241 .remove = ohci_hcd_pnx8550_drv_remove,
242};
243
diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c
index e27d5ae2b9eb..64c2ed9ff95e 100644
--- a/drivers/usb/host/ohci-ppc-of.c
+++ b/drivers/usb/host/ohci-ppc-of.c
@@ -19,7 +19,7 @@
19#include <asm/prom.h> 19#include <asm/prom.h>
20 20
21 21
22static int __devinit 22static int
23ohci_ppc_of_start(struct usb_hcd *hcd) 23ohci_ppc_of_start(struct usb_hcd *hcd)
24{ 24{
25 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 25 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
@@ -81,7 +81,7 @@ static const struct hc_driver ohci_ppc_of_hc_driver = {
81}; 81};
82 82
83 83
84static int __devinit ohci_hcd_ppc_of_probe(struct platform_device *op) 84static int ohci_hcd_ppc_of_probe(struct platform_device *op)
85{ 85{
86 struct device_node *dn = op->dev.of_node; 86 struct device_node *dn = op->dev.of_node;
87 struct usb_hcd *hcd; 87 struct usb_hcd *hcd;
diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c
deleted file mode 100644
index 185c39ed81b7..000000000000
--- a/drivers/usb/host/ohci-ppc-soc.c
+++ /dev/null
@@ -1,216 +0,0 @@
1/*
2 * OHCI HCD (Host Controller Driver) for USB.
3 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * (C) Copyright 2002 Hewlett-Packard Company
7 * (C) Copyright 2003-2005 MontaVista Software Inc.
8 *
9 * Bus Glue for PPC On-Chip OHCI driver
10 * Tested on Freescale MPC5200 and IBM STB04xxx
11 *
12 * Modified by Dale Farnsworth <dale@farnsworth.org> from ohci-sa1111.c
13 *
14 * This file is licenced under the GPL.
15 */
16
17#include <linux/platform_device.h>
18#include <linux/signal.h>
19
20/* configure so an HC device and id are always provided */
21/* always called with process context; sleeping is OK */
22
23/**
24 * usb_hcd_ppc_soc_probe - initialize On-Chip HCDs
25 * Context: !in_interrupt()
26 *
27 * Allocates basic resources for this USB host controller.
28 *
29 * Store this function in the HCD's struct pci_driver as probe().
30 */
31static int usb_hcd_ppc_soc_probe(const struct hc_driver *driver,
32 struct platform_device *pdev)
33{
34 int retval;
35 struct usb_hcd *hcd;
36 struct ohci_hcd *ohci;
37 struct resource *res;
38 int irq;
39
40 pr_debug("initializing PPC-SOC USB Controller\n");
41
42 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
43 if (!res) {
44 pr_debug("%s: no irq\n", __FILE__);
45 return -ENODEV;
46 }
47 irq = res->start;
48
49 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
50 if (!res) {
51 pr_debug("%s: no reg addr\n", __FILE__);
52 return -ENODEV;
53 }
54
55 hcd = usb_create_hcd(driver, &pdev->dev, "PPC-SOC USB");
56 if (!hcd)
57 return -ENOMEM;
58 hcd->rsrc_start = res->start;
59 hcd->rsrc_len = resource_size(res);
60
61 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
62 pr_debug("%s: request_mem_region failed\n", __FILE__);
63 retval = -EBUSY;
64 goto err1;
65 }
66
67 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
68 if (!hcd->regs) {
69 pr_debug("%s: ioremap failed\n", __FILE__);
70 retval = -ENOMEM;
71 goto err2;
72 }
73
74 ohci = hcd_to_ohci(hcd);
75 ohci->flags |= OHCI_QUIRK_BE_MMIO | OHCI_QUIRK_BE_DESC;
76
77#ifdef CONFIG_PPC_MPC52xx
78 /* MPC52xx doesn't need frame_no shift */
79 ohci->flags |= OHCI_QUIRK_FRAME_NO;
80#endif
81 ohci_hcd_init(ohci);
82
83 retval = usb_add_hcd(hcd, irq, 0);
84 if (retval == 0)
85 return retval;
86
87 pr_debug("Removing PPC-SOC USB Controller\n");
88
89 iounmap(hcd->regs);
90 err2:
91 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
92 err1:
93 usb_put_hcd(hcd);
94 return retval;
95}
96
97
98/* may be called without controller electrically present */
99/* may be called with controller, bus, and devices active */
100
101/**
102 * usb_hcd_ppc_soc_remove - shutdown processing for On-Chip HCDs
103 * @pdev: USB Host Controller being removed
104 * Context: !in_interrupt()
105 *
106 * Reverses the effect of usb_hcd_ppc_soc_probe().
107 * It is always called from a thread
108 * context, normally "rmmod", "apmd", or something similar.
109 *
110 */
111static void usb_hcd_ppc_soc_remove(struct usb_hcd *hcd,
112 struct platform_device *pdev)
113{
114 usb_remove_hcd(hcd);
115
116 pr_debug("stopping PPC-SOC USB Controller\n");
117
118 iounmap(hcd->regs);
119 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
120 usb_put_hcd(hcd);
121}
122
123static int __devinit
124ohci_ppc_soc_start(struct usb_hcd *hcd)
125{
126 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
127 int ret;
128
129 if ((ret = ohci_init(ohci)) < 0)
130 return ret;
131
132 if ((ret = ohci_run(ohci)) < 0) {
133 dev_err(hcd->self.controller, "can't start %s\n",
134 hcd->self.bus_name);
135 ohci_stop(hcd);
136 return ret;
137 }
138
139 return 0;
140}
141
142static const struct hc_driver ohci_ppc_soc_hc_driver = {
143 .description = hcd_name,
144 .hcd_priv_size = sizeof(struct ohci_hcd),
145
146 /*
147 * generic hardware linkage
148 */
149 .irq = ohci_irq,
150 .flags = HCD_USB11 | HCD_MEMORY,
151
152 /*
153 * basic lifecycle operations
154 */
155 .start = ohci_ppc_soc_start,
156 .stop = ohci_stop,
157 .shutdown = ohci_shutdown,
158
159 /*
160 * managing i/o requests and associated device resources
161 */
162 .urb_enqueue = ohci_urb_enqueue,
163 .urb_dequeue = ohci_urb_dequeue,
164 .endpoint_disable = ohci_endpoint_disable,
165
166 /*
167 * scheduling support
168 */
169 .get_frame_number = ohci_get_frame,
170
171 /*
172 * root hub support
173 */
174 .hub_status_data = ohci_hub_status_data,
175 .hub_control = ohci_hub_control,
176#ifdef CONFIG_PM
177 .bus_suspend = ohci_bus_suspend,
178 .bus_resume = ohci_bus_resume,
179#endif
180 .start_port_reset = ohci_start_port_reset,
181};
182
183static int ohci_hcd_ppc_soc_drv_probe(struct platform_device *pdev)
184{
185 int ret;
186
187 if (usb_disabled())
188 return -ENODEV;
189
190 ret = usb_hcd_ppc_soc_probe(&ohci_ppc_soc_hc_driver, pdev);
191 return ret;
192}
193
194static int ohci_hcd_ppc_soc_drv_remove(struct platform_device *pdev)
195{
196 struct usb_hcd *hcd = platform_get_drvdata(pdev);
197
198 usb_hcd_ppc_soc_remove(hcd, pdev);
199 return 0;
200}
201
202static struct platform_driver ohci_hcd_ppc_soc_driver = {
203 .probe = ohci_hcd_ppc_soc_drv_probe,
204 .remove = ohci_hcd_ppc_soc_drv_remove,
205 .shutdown = usb_hcd_platform_shutdown,
206#ifdef CONFIG_PM
207 /*.suspend = ohci_hcd_ppc_soc_drv_suspend,*/
208 /*.resume = ohci_hcd_ppc_soc_drv_resume,*/
209#endif
210 .driver = {
211 .name = "ppc-soc-ohci",
212 .owner = THIS_MODULE,
213 },
214};
215
216MODULE_ALIAS("platform:ppc-soc-ohci");
diff --git a/drivers/usb/host/ohci-ps3.c b/drivers/usb/host/ohci-ps3.c
index 2ee1d8d713d2..7d35cd9e2862 100644
--- a/drivers/usb/host/ohci-ps3.c
+++ b/drivers/usb/host/ohci-ps3.c
@@ -30,7 +30,7 @@ static int ps3_ohci_hc_reset(struct usb_hcd *hcd)
30 return ohci_init(ohci); 30 return ohci_init(ohci);
31} 31}
32 32
33static int __devinit ps3_ohci_hc_start(struct usb_hcd *hcd) 33static int ps3_ohci_hc_start(struct usb_hcd *hcd)
34{ 34{
35 int result; 35 int result;
36 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 36 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
@@ -76,7 +76,7 @@ static const struct hc_driver ps3_ohci_hc_driver = {
76#endif 76#endif
77}; 77};
78 78
79static int __devinit ps3_ohci_probe(struct ps3_system_bus_device *dev) 79static int ps3_ohci_probe(struct ps3_system_bus_device *dev)
80{ 80{
81 int result; 81 int result;
82 struct usb_hcd *hcd; 82 struct usb_hcd *hcd;
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index 2bf11440b010..efe71f3ca477 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -284,7 +284,7 @@ MODULE_DEVICE_TABLE(of, pxa_ohci_dt_ids);
284 284
285static u64 pxa_ohci_dma_mask = DMA_BIT_MASK(32); 285static u64 pxa_ohci_dma_mask = DMA_BIT_MASK(32);
286 286
287static int __devinit ohci_pxa_of_init(struct platform_device *pdev) 287static int ohci_pxa_of_init(struct platform_device *pdev)
288{ 288{
289 struct device_node *np = pdev->dev.of_node; 289 struct device_node *np = pdev->dev.of_node;
290 struct pxaohci_platform_data *pdata; 290 struct pxaohci_platform_data *pdata;
@@ -330,7 +330,7 @@ static int __devinit ohci_pxa_of_init(struct platform_device *pdev)
330 return 0; 330 return 0;
331} 331}
332#else 332#else
333static int __devinit ohci_pxa_of_init(struct platform_device *pdev) 333static int ohci_pxa_of_init(struct platform_device *pdev)
334{ 334{
335 return 0; 335 return 0;
336} 336}
@@ -471,7 +471,7 @@ void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *pdev)
471 471
472/*-------------------------------------------------------------------------*/ 472/*-------------------------------------------------------------------------*/
473 473
474static int __devinit 474static int
475ohci_pxa27x_start (struct usb_hcd *hcd) 475ohci_pxa27x_start (struct usb_hcd *hcd)
476{ 476{
477 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 477 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
@@ -591,7 +591,7 @@ static int ohci_hcd_pxa27x_drv_resume(struct device *dev)
591 /* Select Power Management Mode */ 591 /* Select Power Management Mode */
592 pxa27x_ohci_select_pmm(ohci, inf->port_mode); 592 pxa27x_ohci_select_pmm(ohci, inf->port_mode);
593 593
594 ohci_finish_controller_resume(hcd); 594 ohci_resume(hcd, false);
595 return 0; 595 return 0;
596} 596}
597 597
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index c5a1ea9145fa..7482cfbe8c5e 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -596,7 +596,6 @@ static void td_submit_urb (
596 urb_priv->ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_C); 596 urb_priv->ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_C);
597 } 597 }
598 598
599 urb_priv->td_cnt = 0;
600 list_add (&urb_priv->pending, &ohci->pending); 599 list_add (&urb_priv->pending, &ohci->pending);
601 600
602 if (data_len) 601 if (data_len)
@@ -672,7 +671,8 @@ static void td_submit_urb (
672 * we could often reduce the number of TDs here. 671 * we could often reduce the number of TDs here.
673 */ 672 */
674 case PIPE_ISOCHRONOUS: 673 case PIPE_ISOCHRONOUS:
675 for (cnt = 0; cnt < urb->number_of_packets; cnt++) { 674 for (cnt = urb_priv->td_cnt; cnt < urb->number_of_packets;
675 cnt++) {
676 int frame = urb->start_frame; 676 int frame = urb->start_frame;
677 677
678 // FIXME scheduling should handle frame counter 678 // FIXME scheduling should handle frame counter
@@ -1128,6 +1128,25 @@ dl_done_list (struct ohci_hcd *ohci)
1128 1128
1129 while (td) { 1129 while (td) {
1130 struct td *td_next = td->next_dl_td; 1130 struct td *td_next = td->next_dl_td;
1131 struct ed *ed = td->ed;
1132
1133 /*
1134 * Some OHCI controllers (NVIDIA for sure, maybe others)
1135 * occasionally forget to add TDs to the done queue. Since
1136 * TDs for a given endpoint are always processed in order,
1137 * if we find a TD on the donelist then all of its
1138 * predecessors must be finished as well.
1139 */
1140 for (;;) {
1141 struct td *td2;
1142
1143 td2 = list_first_entry(&ed->td_list, struct td,
1144 td_list);
1145 if (td2 == td)
1146 break;
1147 takeback_td(ohci, td2);
1148 }
1149
1131 takeback_td(ohci, td); 1150 takeback_td(ohci, td);
1132 td = td_next; 1151 td = td_next;
1133 } 1152 }
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index 0d2309ca471e..ad0f55269603 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -323,8 +323,6 @@ usb_hcd_s3c2410_remove(struct usb_hcd *hcd, struct platform_device *dev)
323{ 323{
324 usb_remove_hcd(hcd); 324 usb_remove_hcd(hcd);
325 s3c2410_stop_hc(dev); 325 s3c2410_stop_hc(dev);
326 iounmap(hcd->regs);
327 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
328 usb_put_hcd(hcd); 326 usb_put_hcd(hcd);
329} 327}
330 328
@@ -353,35 +351,29 @@ static int usb_hcd_s3c2410_probe(const struct hc_driver *driver,
353 hcd->rsrc_start = dev->resource[0].start; 351 hcd->rsrc_start = dev->resource[0].start;
354 hcd->rsrc_len = resource_size(&dev->resource[0]); 352 hcd->rsrc_len = resource_size(&dev->resource[0]);
355 353
356 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 354 hcd->regs = devm_request_and_ioremap(&dev->dev, &dev->resource[0]);
357 dev_err(&dev->dev, "request_mem_region failed\n"); 355 if (!hcd->regs) {
358 retval = -EBUSY; 356 dev_err(&dev->dev, "devm_request_and_ioremap failed\n");
357 retval = -ENOMEM;
359 goto err_put; 358 goto err_put;
360 } 359 }
361 360
362 clk = clk_get(&dev->dev, "usb-host"); 361 clk = devm_clk_get(&dev->dev, "usb-host");
363 if (IS_ERR(clk)) { 362 if (IS_ERR(clk)) {
364 dev_err(&dev->dev, "cannot get usb-host clock\n"); 363 dev_err(&dev->dev, "cannot get usb-host clock\n");
365 retval = PTR_ERR(clk); 364 retval = PTR_ERR(clk);
366 goto err_mem; 365 goto err_put;
367 } 366 }
368 367
369 usb_clk = clk_get(&dev->dev, "usb-bus-host"); 368 usb_clk = devm_clk_get(&dev->dev, "usb-bus-host");
370 if (IS_ERR(usb_clk)) { 369 if (IS_ERR(usb_clk)) {
371 dev_err(&dev->dev, "cannot get usb-bus-host clock\n"); 370 dev_err(&dev->dev, "cannot get usb-bus-host clock\n");
372 retval = PTR_ERR(usb_clk); 371 retval = PTR_ERR(usb_clk);
373 goto err_clk; 372 goto err_put;
374 } 373 }
375 374
376 s3c2410_start_hc(dev, hcd); 375 s3c2410_start_hc(dev, hcd);
377 376
378 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
379 if (!hcd->regs) {
380 dev_err(&dev->dev, "ioremap failed\n");
381 retval = -ENOMEM;
382 goto err_ioremap;
383 }
384
385 ohci_hcd_init(hcd_to_ohci(hcd)); 377 ohci_hcd_init(hcd_to_ohci(hcd));
386 378
387 retval = usb_add_hcd(hcd, dev->resource[1].start, 0); 379 retval = usb_add_hcd(hcd, dev->resource[1].start, 0);
@@ -392,14 +384,6 @@ static int usb_hcd_s3c2410_probe(const struct hc_driver *driver,
392 384
393 err_ioremap: 385 err_ioremap:
394 s3c2410_stop_hc(dev); 386 s3c2410_stop_hc(dev);
395 iounmap(hcd->regs);
396 clk_put(usb_clk);
397
398 err_clk:
399 clk_put(clk);
400
401 err_mem:
402 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
403 387
404 err_put: 388 err_put:
405 usb_put_hcd(hcd); 389 usb_put_hcd(hcd);
@@ -474,12 +458,12 @@ static const struct hc_driver ohci_s3c2410_hc_driver = {
474 458
475/* device driver */ 459/* device driver */
476 460
477static int __devinit ohci_hcd_s3c2410_drv_probe(struct platform_device *pdev) 461static int ohci_hcd_s3c2410_drv_probe(struct platform_device *pdev)
478{ 462{
479 return usb_hcd_s3c2410_probe(&ohci_s3c2410_hc_driver, pdev); 463 return usb_hcd_s3c2410_probe(&ohci_s3c2410_hc_driver, pdev);
480} 464}
481 465
482static int __devexit ohci_hcd_s3c2410_drv_remove(struct platform_device *pdev) 466static int ohci_hcd_s3c2410_drv_remove(struct platform_device *pdev)
483{ 467{
484 struct usb_hcd *hcd = platform_get_drvdata(pdev); 468 struct usb_hcd *hcd = platform_get_drvdata(pdev);
485 469
@@ -524,8 +508,7 @@ static int ohci_hcd_s3c2410_drv_resume(struct device *dev)
524 508
525 s3c2410_start_hc(pdev, hcd); 509 s3c2410_start_hc(pdev, hcd);
526 510
527 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 511 ohci_resume(hcd, false);
528 ohci_finish_controller_resume(hcd);
529 512
530 return 0; 513 return 0;
531} 514}
@@ -541,7 +524,7 @@ static const struct dev_pm_ops ohci_hcd_s3c2410_pm_ops = {
541 524
542static struct platform_driver ohci_hcd_s3c2410_driver = { 525static struct platform_driver ohci_hcd_s3c2410_driver = {
543 .probe = ohci_hcd_s3c2410_drv_probe, 526 .probe = ohci_hcd_s3c2410_drv_probe,
544 .remove = __devexit_p(ohci_hcd_s3c2410_drv_remove), 527 .remove = ohci_hcd_s3c2410_drv_remove,
545 .shutdown = usb_hcd_platform_shutdown, 528 .shutdown = usb_hcd_platform_shutdown,
546 .driver = { 529 .driver = {
547 .owner = THIS_MODULE, 530 .owner = THIS_MODULE,
diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c
index b6cc92520924..17b2a7dad77b 100644
--- a/drivers/usb/host/ohci-sa1111.c
+++ b/drivers/usb/host/ohci-sa1111.c
@@ -63,7 +63,7 @@ static int ohci_sa1111_reset(struct usb_hcd *hcd)
63 return ohci_init(ohci); 63 return ohci_init(ohci);
64} 64}
65 65
66static int __devinit ohci_sa1111_start(struct usb_hcd *hcd) 66static int ohci_sa1111_start(struct usb_hcd *hcd)
67{ 67{
68 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 68 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
69 int ret; 69 int ret;
diff --git a/drivers/usb/host/ohci-sh.c b/drivers/usb/host/ohci-sh.c
deleted file mode 100644
index 76a20c278362..000000000000
--- a/drivers/usb/host/ohci-sh.c
+++ /dev/null
@@ -1,141 +0,0 @@
1/*
2 * OHCI HCD (Host Controller Driver) for USB.
3 *
4 * Copyright (C) 2008 Renesas Solutions Corp.
5 *
6 * Author : Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 *
21 */
22
23#include <linux/platform_device.h>
24
25static int ohci_sh_start(struct usb_hcd *hcd)
26{
27 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
28
29 ohci_hcd_init(ohci);
30 ohci_init(ohci);
31 ohci_run(ohci);
32 return 0;
33}
34
35static const struct hc_driver ohci_sh_hc_driver = {
36 .description = hcd_name,
37 .product_desc = "SuperH OHCI",
38 .hcd_priv_size = sizeof(struct ohci_hcd),
39
40 /*
41 * generic hardware linkage
42 */
43 .irq = ohci_irq,
44 .flags = HCD_USB11 | HCD_MEMORY,
45
46 /*
47 * basic lifecycle operations
48 */
49 .start = ohci_sh_start,
50 .stop = ohci_stop,
51 .shutdown = ohci_shutdown,
52
53 /*
54 * managing i/o requests and associated device resources
55 */
56 .urb_enqueue = ohci_urb_enqueue,
57 .urb_dequeue = ohci_urb_dequeue,
58 .endpoint_disable = ohci_endpoint_disable,
59
60 /*
61 * scheduling support
62 */
63 .get_frame_number = ohci_get_frame,
64
65 /*
66 * root hub support
67 */
68 .hub_status_data = ohci_hub_status_data,
69 .hub_control = ohci_hub_control,
70#ifdef CONFIG_PM
71 .bus_suspend = ohci_bus_suspend,
72 .bus_resume = ohci_bus_resume,
73#endif
74 .start_port_reset = ohci_start_port_reset,
75};
76
77/*-------------------------------------------------------------------------*/
78
79static int ohci_hcd_sh_probe(struct platform_device *pdev)
80{
81 struct resource *res = NULL;
82 struct usb_hcd *hcd = NULL;
83 int irq = -1;
84 int ret;
85
86 if (usb_disabled())
87 return -ENODEV;
88
89 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
90 if (!res) {
91 dev_err(&pdev->dev, "platform_get_resource error.\n");
92 return -ENODEV;
93 }
94
95 irq = platform_get_irq(pdev, 0);
96 if (irq < 0) {
97 dev_err(&pdev->dev, "platform_get_irq error.\n");
98 return -ENODEV;
99 }
100
101 /* initialize hcd */
102 hcd = usb_create_hcd(&ohci_sh_hc_driver, &pdev->dev, (char *)hcd_name);
103 if (!hcd) {
104 dev_err(&pdev->dev, "Failed to create hcd\n");
105 return -ENOMEM;
106 }
107
108 hcd->regs = (void __iomem *)res->start;
109 hcd->rsrc_start = res->start;
110 hcd->rsrc_len = resource_size(res);
111 ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
112 if (ret != 0) {
113 dev_err(&pdev->dev, "Failed to add hcd\n");
114 usb_put_hcd(hcd);
115 return ret;
116 }
117
118 return ret;
119}
120
121static int ohci_hcd_sh_remove(struct platform_device *pdev)
122{
123 struct usb_hcd *hcd = platform_get_drvdata(pdev);
124
125 usb_remove_hcd(hcd);
126 usb_put_hcd(hcd);
127
128 return 0;
129}
130
131static struct platform_driver ohci_hcd_sh_driver = {
132 .probe = ohci_hcd_sh_probe,
133 .remove = ohci_hcd_sh_remove,
134 .shutdown = usb_hcd_platform_shutdown,
135 .driver = {
136 .name = "sh_ohci",
137 .owner = THIS_MODULE,
138 },
139};
140
141MODULE_ALIAS("platform:sh_ohci");
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c
index 5596ac2ba1ca..3b5b908fd47b 100644
--- a/drivers/usb/host/ohci-sm501.c
+++ b/drivers/usb/host/ohci-sm501.c
@@ -238,7 +238,7 @@ static int ohci_sm501_resume(struct platform_device *pdev)
238 ohci->next_statechange = jiffies; 238 ohci->next_statechange = jiffies;
239 239
240 sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 1); 240 sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 1);
241 ohci_finish_controller_resume(hcd); 241 ohci_resume(hcd, false);
242 return 0; 242 return 0;
243} 243}
244#else 244#else
diff --git a/drivers/usb/host/ohci-spear.c b/drivers/usb/host/ohci-spear.c
index fc7305ee3c9c..9020bf0e2eca 100644
--- a/drivers/usb/host/ohci-spear.c
+++ b/drivers/usb/host/ohci-spear.c
@@ -33,7 +33,7 @@ static void spear_stop_ohci(struct spear_ohci *ohci)
33 clk_disable_unprepare(ohci->clk); 33 clk_disable_unprepare(ohci->clk);
34} 34}
35 35
36static int __devinit ohci_spear_start(struct usb_hcd *hcd) 36static int ohci_spear_start(struct usb_hcd *hcd)
37{ 37{
38 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 38 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
39 int ret; 39 int ret;
@@ -101,13 +101,11 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
101 struct spear_ohci *ohci_p; 101 struct spear_ohci *ohci_p;
102 struct resource *res; 102 struct resource *res;
103 int retval, irq; 103 int retval, irq;
104 char clk_name[20] = "usbh_clk";
105 static int instance = -1;
106 104
107 irq = platform_get_irq(pdev, 0); 105 irq = platform_get_irq(pdev, 0);
108 if (irq < 0) { 106 if (irq < 0) {
109 retval = irq; 107 retval = irq;
110 goto fail_irq_get; 108 goto fail;
111 } 109 }
112 110
113 /* 111 /*
@@ -118,47 +116,39 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
118 if (!pdev->dev.dma_mask) 116 if (!pdev->dev.dma_mask)
119 pdev->dev.dma_mask = &spear_ohci_dma_mask; 117 pdev->dev.dma_mask = &spear_ohci_dma_mask;
120 118
121 /* 119 usbh_clk = devm_clk_get(&pdev->dev, NULL);
122 * Increment the device instance, when probing via device-tree
123 */
124 if (pdev->id < 0)
125 instance++;
126 else
127 instance = pdev->id;
128 sprintf(clk_name, "usbh.%01d_clk", instance);
129
130 usbh_clk = clk_get(NULL, clk_name);
131 if (IS_ERR(usbh_clk)) { 120 if (IS_ERR(usbh_clk)) {
132 dev_err(&pdev->dev, "Error getting interface clock\n"); 121 dev_err(&pdev->dev, "Error getting interface clock\n");
133 retval = PTR_ERR(usbh_clk); 122 retval = PTR_ERR(usbh_clk);
134 goto fail_get_usbh_clk; 123 goto fail;
135 } 124 }
136 125
137 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); 126 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
138 if (!hcd) { 127 if (!hcd) {
139 retval = -ENOMEM; 128 retval = -ENOMEM;
140 goto fail_create_hcd; 129 goto fail;
141 } 130 }
142 131
143 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 132 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
144 if (!res) { 133 if (!res) {
145 retval = -ENODEV; 134 retval = -ENODEV;
146 goto fail_request_resource; 135 goto err_put_hcd;
147 } 136 }
148 137
149 hcd->rsrc_start = pdev->resource[0].start; 138 hcd->rsrc_start = pdev->resource[0].start;
150 hcd->rsrc_len = resource_size(res); 139 hcd->rsrc_len = resource_size(res);
151 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 140 if (!devm_request_mem_region(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len,
141 hcd_name)) {
152 dev_dbg(&pdev->dev, "request_mem_region failed\n"); 142 dev_dbg(&pdev->dev, "request_mem_region failed\n");
153 retval = -EBUSY; 143 retval = -EBUSY;
154 goto fail_request_resource; 144 goto err_put_hcd;
155 } 145 }
156 146
157 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 147 hcd->regs = devm_ioremap(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len);
158 if (!hcd->regs) { 148 if (!hcd->regs) {
159 dev_dbg(&pdev->dev, "ioremap failed\n"); 149 dev_dbg(&pdev->dev, "ioremap failed\n");
160 retval = -ENOMEM; 150 retval = -ENOMEM;
161 goto fail_ioremap; 151 goto err_put_hcd;
162 } 152 }
163 153
164 ohci_p = (struct spear_ohci *)hcd_to_ohci(hcd); 154 ohci_p = (struct spear_ohci *)hcd_to_ohci(hcd);
@@ -171,15 +161,9 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
171 return retval; 161 return retval;
172 162
173 spear_stop_ohci(ohci_p); 163 spear_stop_ohci(ohci_p);
174 iounmap(hcd->regs); 164err_put_hcd:
175fail_ioremap:
176 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
177fail_request_resource:
178 usb_put_hcd(hcd); 165 usb_put_hcd(hcd);
179fail_create_hcd: 166fail:
180 clk_put(usbh_clk);
181fail_get_usbh_clk:
182fail_irq_get:
183 dev_err(&pdev->dev, "init fail, %d\n", retval); 167 dev_err(&pdev->dev, "init fail, %d\n", retval);
184 168
185 return retval; 169 return retval;
@@ -194,12 +178,8 @@ static int spear_ohci_hcd_drv_remove(struct platform_device *pdev)
194 if (ohci_p->clk) 178 if (ohci_p->clk)
195 spear_stop_ohci(ohci_p); 179 spear_stop_ohci(ohci_p);
196 180
197 iounmap(hcd->regs);
198 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
199 usb_put_hcd(hcd); 181 usb_put_hcd(hcd);
200 182
201 if (ohci_p->clk)
202 clk_put(ohci_p->clk);
203 platform_set_drvdata(pdev, NULL); 183 platform_set_drvdata(pdev, NULL);
204 return 0; 184 return 0;
205} 185}
@@ -231,12 +211,12 @@ static int spear_ohci_hcd_drv_resume(struct platform_device *dev)
231 ohci->next_statechange = jiffies; 211 ohci->next_statechange = jiffies;
232 212
233 spear_start_ohci(ohci_p); 213 spear_start_ohci(ohci_p);
234 ohci_finish_controller_resume(hcd); 214 ohci_resume(hcd, false);
235 return 0; 215 return 0;
236} 216}
237#endif 217#endif
238 218
239static struct of_device_id spear_ohci_id_table[] __devinitdata = { 219static struct of_device_id spear_ohci_id_table[] = {
240 { .compatible = "st,spear600-ohci", }, 220 { .compatible = "st,spear600-ohci", },
241 { }, 221 { },
242}; 222};
diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c
index 60c2b0722f2e..d370245a4ee2 100644
--- a/drivers/usb/host/ohci-tmio.c
+++ b/drivers/usb/host/ohci-tmio.c
@@ -184,7 +184,7 @@ static const struct hc_driver ohci_tmio_hc_driver = {
184/*-------------------------------------------------------------------------*/ 184/*-------------------------------------------------------------------------*/
185static struct platform_driver ohci_hcd_tmio_driver; 185static struct platform_driver ohci_hcd_tmio_driver;
186 186
187static int __devinit ohci_hcd_tmio_drv_probe(struct platform_device *dev) 187static int ohci_hcd_tmio_drv_probe(struct platform_device *dev)
188{ 188{
189 const struct mfd_cell *cell = mfd_get_cell(dev); 189 const struct mfd_cell *cell = mfd_get_cell(dev);
190 struct resource *regs = platform_get_resource(dev, IORESOURCE_MEM, 0); 190 struct resource *regs = platform_get_resource(dev, IORESOURCE_MEM, 0);
@@ -271,7 +271,7 @@ err_usb_create_hcd:
271 return ret; 271 return ret;
272} 272}
273 273
274static int __devexit ohci_hcd_tmio_drv_remove(struct platform_device *dev) 274static int ohci_hcd_tmio_drv_remove(struct platform_device *dev)
275{ 275{
276 struct usb_hcd *hcd = platform_get_drvdata(dev); 276 struct usb_hcd *hcd = platform_get_drvdata(dev);
277 struct tmio_hcd *tmio = hcd_to_tmio(hcd); 277 struct tmio_hcd *tmio = hcd_to_tmio(hcd);
@@ -352,7 +352,7 @@ static int ohci_hcd_tmio_drv_resume(struct platform_device *dev)
352 352
353 spin_unlock_irqrestore(&tmio->lock, flags); 353 spin_unlock_irqrestore(&tmio->lock, flags);
354 354
355 ohci_finish_controller_resume(hcd); 355 ohci_resume(hcd, false);
356 356
357 return 0; 357 return 0;
358} 358}
@@ -363,7 +363,7 @@ static int ohci_hcd_tmio_drv_resume(struct platform_device *dev)
363 363
364static struct platform_driver ohci_hcd_tmio_driver = { 364static struct platform_driver ohci_hcd_tmio_driver = {
365 .probe = ohci_hcd_tmio_drv_probe, 365 .probe = ohci_hcd_tmio_drv_probe,
366 .remove = __devexit_p(ohci_hcd_tmio_drv_remove), 366 .remove = ohci_hcd_tmio_drv_remove,
367 .shutdown = usb_hcd_platform_shutdown, 367 .shutdown = usb_hcd_platform_shutdown,
368 .suspend = ohci_hcd_tmio_drv_suspend, 368 .suspend = ohci_hcd_tmio_drv_suspend,
369 .resume = ohci_hcd_tmio_drv_resume, 369 .resume = ohci_hcd_tmio_drv_resume,
diff --git a/drivers/usb/host/ohci-xls.c b/drivers/usb/host/ohci-xls.c
deleted file mode 100644
index 41e378f17c66..000000000000
--- a/drivers/usb/host/ohci-xls.c
+++ /dev/null
@@ -1,152 +0,0 @@
1/*
2 * OHCI HCD for Netlogic XLS processors.
3 *
4 * (C) Copyright 2011 Netlogic Microsystems Inc.
5 *
6 * Based on ohci-au1xxx.c, and other Linux OHCI drivers.
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive for
10 * more details.
11 */
12
13#include <linux/platform_device.h>
14#include <linux/signal.h>
15
16static int ohci_xls_probe_internal(const struct hc_driver *driver,
17 struct platform_device *dev)
18{
19 struct resource *res;
20 struct usb_hcd *hcd;
21 int retval, irq;
22
23 /* Get our IRQ from an earlier registered Platform Resource */
24 irq = platform_get_irq(dev, 0);
25 if (irq < 0) {
26 dev_err(&dev->dev, "Found HC with no IRQ\n");
27 return -ENODEV;
28 }
29
30 /* Get our Memory Handle */
31 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
32 if (!res) {
33 dev_err(&dev->dev, "MMIO Handle incorrect!\n");
34 return -ENODEV;
35 }
36
37 hcd = usb_create_hcd(driver, &dev->dev, "XLS");
38 if (!hcd) {
39 retval = -ENOMEM;
40 goto err1;
41 }
42 hcd->rsrc_start = res->start;
43 hcd->rsrc_len = resource_size(res);
44
45 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
46 driver->description)) {
47 dev_dbg(&dev->dev, "Controller already in use\n");
48 retval = -EBUSY;
49 goto err2;
50 }
51
52 hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
53 if (hcd->regs == NULL) {
54 dev_dbg(&dev->dev, "error mapping memory\n");
55 retval = -EFAULT;
56 goto err3;
57 }
58
59 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
60 if (retval != 0)
61 goto err4;
62 return retval;
63
64err4:
65 iounmap(hcd->regs);
66err3:
67 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
68err2:
69 usb_put_hcd(hcd);
70err1:
71 dev_err(&dev->dev, "init fail, %d\n", retval);
72 return retval;
73}
74
75static int ohci_xls_reset(struct usb_hcd *hcd)
76{
77 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
78
79 ohci_hcd_init(ohci);
80 return ohci_init(ohci);
81}
82
83static int __devinit ohci_xls_start(struct usb_hcd *hcd)
84{
85 struct ohci_hcd *ohci;
86 int ret;
87
88 ohci = hcd_to_ohci(hcd);
89 ret = ohci_run(ohci);
90 if (ret < 0) {
91 dev_err(hcd->self.controller, "can't start %s\n",
92 hcd->self.bus_name);
93 ohci_stop(hcd);
94 return ret;
95 }
96 return 0;
97}
98
99static struct hc_driver ohci_xls_hc_driver = {
100 .description = hcd_name,
101 .product_desc = "XLS OHCI Host Controller",
102 .hcd_priv_size = sizeof(struct ohci_hcd),
103 .irq = ohci_irq,
104 .flags = HCD_MEMORY | HCD_USB11,
105 .reset = ohci_xls_reset,
106 .start = ohci_xls_start,
107 .stop = ohci_stop,
108 .shutdown = ohci_shutdown,
109 .urb_enqueue = ohci_urb_enqueue,
110 .urb_dequeue = ohci_urb_dequeue,
111 .endpoint_disable = ohci_endpoint_disable,
112 .get_frame_number = ohci_get_frame,
113 .hub_status_data = ohci_hub_status_data,
114 .hub_control = ohci_hub_control,
115#ifdef CONFIG_PM
116 .bus_suspend = ohci_bus_suspend,
117 .bus_resume = ohci_bus_resume,
118#endif
119 .start_port_reset = ohci_start_port_reset,
120};
121
122static int ohci_xls_probe(struct platform_device *dev)
123{
124 int ret;
125
126 pr_debug("In ohci_xls_probe");
127 if (usb_disabled())
128 return -ENODEV;
129 ret = ohci_xls_probe_internal(&ohci_xls_hc_driver, dev);
130 return ret;
131}
132
133static int ohci_xls_remove(struct platform_device *dev)
134{
135 struct usb_hcd *hcd = platform_get_drvdata(dev);
136
137 usb_remove_hcd(hcd);
138 iounmap(hcd->regs);
139 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
140 usb_put_hcd(hcd);
141 return 0;
142}
143
144static struct platform_driver ohci_xls_driver = {
145 .probe = ohci_xls_probe,
146 .remove = ohci_xls_remove,
147 .shutdown = usb_hcd_platform_shutdown,
148 .driver = {
149 .name = "ohci-xls-0",
150 .owner = THIS_MODULE,
151 },
152};
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 39f9e4a9a2d3..a3b6d7104ae2 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -443,7 +443,7 @@ static inline int io_type_enabled(struct pci_dev *pdev, unsigned int mask)
443#define pio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_IO) 443#define pio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_IO)
444#define mmio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_MEMORY) 444#define mmio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_MEMORY)
445 445
446static void __devinit quirk_usb_handoff_uhci(struct pci_dev *pdev) 446static void quirk_usb_handoff_uhci(struct pci_dev *pdev)
447{ 447{
448 unsigned long base = 0; 448 unsigned long base = 0;
449 int i; 449 int i;
@@ -461,12 +461,12 @@ static void __devinit quirk_usb_handoff_uhci(struct pci_dev *pdev)
461 uhci_check_and_reset_hc(pdev, base); 461 uhci_check_and_reset_hc(pdev, base);
462} 462}
463 463
464static int __devinit mmio_resource_enabled(struct pci_dev *pdev, int idx) 464static int mmio_resource_enabled(struct pci_dev *pdev, int idx)
465{ 465{
466 return pci_resource_start(pdev, idx) && mmio_enabled(pdev); 466 return pci_resource_start(pdev, idx) && mmio_enabled(pdev);
467} 467}
468 468
469static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev) 469static void quirk_usb_handoff_ohci(struct pci_dev *pdev)
470{ 470{
471 void __iomem *base; 471 void __iomem *base;
472 u32 control; 472 u32 control;
@@ -533,7 +533,7 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
533 iounmap(base); 533 iounmap(base);
534} 534}
535 535
536static const struct dmi_system_id __devinitconst ehci_dmi_nohandoff_table[] = { 536static const struct dmi_system_id ehci_dmi_nohandoff_table[] = {
537 { 537 {
538 /* Pegatron Lucid (ExoPC) */ 538 /* Pegatron Lucid (ExoPC) */
539 .matches = { 539 .matches = {
@@ -558,7 +558,7 @@ static const struct dmi_system_id __devinitconst ehci_dmi_nohandoff_table[] = {
558 { } 558 { }
559}; 559};
560 560
561static void __devinit ehci_bios_handoff(struct pci_dev *pdev, 561static void ehci_bios_handoff(struct pci_dev *pdev,
562 void __iomem *op_reg_base, 562 void __iomem *op_reg_base,
563 u32 cap, u8 offset) 563 u32 cap, u8 offset)
564{ 564{
@@ -626,7 +626,7 @@ static void __devinit ehci_bios_handoff(struct pci_dev *pdev,
626 writel(0, op_reg_base + EHCI_CONFIGFLAG); 626 writel(0, op_reg_base + EHCI_CONFIGFLAG);
627} 627}
628 628
629static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev) 629static void quirk_usb_disable_ehci(struct pci_dev *pdev)
630{ 630{
631 void __iomem *base, *op_reg_base; 631 void __iomem *base, *op_reg_base;
632 u32 hcc_params, cap, val; 632 u32 hcc_params, cap, val;
@@ -723,6 +723,7 @@ static int handshake(void __iomem *ptr, u32 mask, u32 done,
723} 723}
724 724
725#define PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI 0x8C31 725#define PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI 0x8C31
726#define PCI_DEVICE_ID_INTEL_LYNX_POINT_LP_XHCI 0x9C31
726 727
727bool usb_is_intel_ppt_switchable_xhci(struct pci_dev *pdev) 728bool usb_is_intel_ppt_switchable_xhci(struct pci_dev *pdev)
728{ 729{
@@ -736,7 +737,8 @@ bool usb_is_intel_lpt_switchable_xhci(struct pci_dev *pdev)
736{ 737{
737 return pdev->class == PCI_CLASS_SERIAL_USB_XHCI && 738 return pdev->class == PCI_CLASS_SERIAL_USB_XHCI &&
738 pdev->vendor == PCI_VENDOR_ID_INTEL && 739 pdev->vendor == PCI_VENDOR_ID_INTEL &&
739 pdev->device == PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI; 740 (pdev->device == PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI ||
741 pdev->device == PCI_DEVICE_ID_INTEL_LYNX_POINT_LP_XHCI);
740} 742}
741 743
742bool usb_is_intel_switchable_xhci(struct pci_dev *pdev) 744bool usb_is_intel_switchable_xhci(struct pci_dev *pdev)
@@ -841,7 +843,7 @@ EXPORT_SYMBOL_GPL(usb_disable_xhci_ports);
841 * and then waits 5 seconds for the BIOS to hand over control. 843 * and then waits 5 seconds for the BIOS to hand over control.
842 * If we timeout, assume the BIOS is broken and take control anyway. 844 * If we timeout, assume the BIOS is broken and take control anyway.
843 */ 845 */
844static void __devinit quirk_usb_handoff_xhci(struct pci_dev *pdev) 846static void quirk_usb_handoff_xhci(struct pci_dev *pdev)
845{ 847{
846 void __iomem *base; 848 void __iomem *base;
847 int ext_cap_offset; 849 int ext_cap_offset;
@@ -941,7 +943,7 @@ hc_init:
941 iounmap(base); 943 iounmap(base);
942} 944}
943 945
944static void __devinit quirk_usb_early_handoff(struct pci_dev *pdev) 946static void quirk_usb_early_handoff(struct pci_dev *pdev)
945{ 947{
946 /* Skip Netlogic mips SoC's internal PCI USB controller. 948 /* Skip Netlogic mips SoC's internal PCI USB controller.
947 * This device does not need/support EHCI/OHCI handoff 949 * This device does not need/support EHCI/OHCI handoff
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index fcc09e5ec0ad..a6fd8f5371df 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -2036,10 +2036,8 @@ static void collect_usb_address_map(struct usb_device *udev, unsigned long *map)
2036 udev->parent->descriptor.bDeviceClass == USB_CLASS_HUB) 2036 udev->parent->descriptor.bDeviceClass == USB_CLASS_HUB)
2037 map[udev->devnum/32] |= (1 << (udev->devnum % 32)); 2037 map[udev->devnum/32] |= (1 << (udev->devnum % 32));
2038 2038
2039 usb_hub_for_each_child(udev, chix, childdev) { 2039 usb_hub_for_each_child(udev, chix, childdev)
2040 if (childdev) 2040 collect_usb_address_map(childdev, map);
2041 collect_usb_address_map(childdev, map);
2042 }
2043} 2041}
2044 2042
2045/* this function must be called with interrupt disabled */ 2043/* this function must be called with interrupt disabled */
@@ -2393,7 +2391,7 @@ static const struct dev_pm_ops r8a66597_dev_pm_ops = {
2393#define R8A66597_DEV_PM_OPS NULL 2391#define R8A66597_DEV_PM_OPS NULL
2394#endif 2392#endif
2395 2393
2396static int __devexit r8a66597_remove(struct platform_device *pdev) 2394static int r8a66597_remove(struct platform_device *pdev)
2397{ 2395{
2398 struct r8a66597 *r8a66597 = dev_get_drvdata(&pdev->dev); 2396 struct r8a66597 *r8a66597 = dev_get_drvdata(&pdev->dev);
2399 struct usb_hcd *hcd = r8a66597_to_hcd(r8a66597); 2397 struct usb_hcd *hcd = r8a66597_to_hcd(r8a66597);
@@ -2407,7 +2405,7 @@ static int __devexit r8a66597_remove(struct platform_device *pdev)
2407 return 0; 2405 return 0;
2408} 2406}
2409 2407
2410static int __devinit r8a66597_probe(struct platform_device *pdev) 2408static int r8a66597_probe(struct platform_device *pdev)
2411{ 2409{
2412 char clk_name[8]; 2410 char clk_name[8];
2413 struct resource *res = NULL, *ires; 2411 struct resource *res = NULL, *ires;
@@ -2534,7 +2532,7 @@ clean_up:
2534 2532
2535static struct platform_driver r8a66597_driver = { 2533static struct platform_driver r8a66597_driver = {
2536 .probe = r8a66597_probe, 2534 .probe = r8a66597_probe,
2537 .remove = __devexit_p(r8a66597_remove), 2535 .remove = r8a66597_remove,
2538 .driver = { 2536 .driver = {
2539 .name = (char *) hcd_name, 2537 .name = (char *) hcd_name,
2540 .owner = THIS_MODULE, 2538 .owner = THIS_MODULE,
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index 619b05f42d4f..d62f0404baaa 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -1595,7 +1595,7 @@ static struct hc_driver sl811h_hc_driver = {
1595 1595
1596/*-------------------------------------------------------------------------*/ 1596/*-------------------------------------------------------------------------*/
1597 1597
1598static int __devexit 1598static int
1599sl811h_remove(struct platform_device *dev) 1599sl811h_remove(struct platform_device *dev)
1600{ 1600{
1601 struct usb_hcd *hcd = platform_get_drvdata(dev); 1601 struct usb_hcd *hcd = platform_get_drvdata(dev);
@@ -1618,7 +1618,7 @@ sl811h_remove(struct platform_device *dev)
1618 return 0; 1618 return 0;
1619} 1619}
1620 1620
1621static int __devinit 1621static int
1622sl811h_probe(struct platform_device *dev) 1622sl811h_probe(struct platform_device *dev)
1623{ 1623{
1624 struct usb_hcd *hcd; 1624 struct usb_hcd *hcd;
@@ -1808,7 +1808,7 @@ sl811h_resume(struct platform_device *dev)
1808/* this driver is exported so sl811_cs can depend on it */ 1808/* this driver is exported so sl811_cs can depend on it */
1809struct platform_driver sl811h_driver = { 1809struct platform_driver sl811h_driver = {
1810 .probe = sl811h_probe, 1810 .probe = sl811h_probe,
1811 .remove = __devexit_p(sl811h_remove), 1811 .remove = sl811h_remove,
1812 1812
1813 .suspend = sl811h_suspend, 1813 .suspend = sl811h_suspend,
1814 .resume = sl811h_resume, 1814 .resume = sl811h_resume,
diff --git a/drivers/usb/host/ssb-hcd.c b/drivers/usb/host/ssb-hcd.c
index c2a29faba076..74af2c6287d2 100644
--- a/drivers/usb/host/ssb-hcd.c
+++ b/drivers/usb/host/ssb-hcd.c
@@ -39,7 +39,7 @@ struct ssb_hcd_device {
39 u32 enable_flags; 39 u32 enable_flags;
40}; 40};
41 41
42static void __devinit ssb_hcd_5354wa(struct ssb_device *dev) 42static void ssb_hcd_5354wa(struct ssb_device *dev)
43{ 43{
44#ifdef CONFIG_SSB_DRIVER_MIPS 44#ifdef CONFIG_SSB_DRIVER_MIPS
45 /* Work around for 5354 failures */ 45 /* Work around for 5354 failures */
@@ -53,7 +53,7 @@ static void __devinit ssb_hcd_5354wa(struct ssb_device *dev)
53#endif 53#endif
54} 54}
55 55
56static void __devinit ssb_hcd_usb20wa(struct ssb_device *dev) 56static void ssb_hcd_usb20wa(struct ssb_device *dev)
57{ 57{
58 if (dev->id.coreid == SSB_DEV_USB20_HOST) { 58 if (dev->id.coreid == SSB_DEV_USB20_HOST) {
59 /* 59 /*
@@ -80,7 +80,7 @@ static void __devinit ssb_hcd_usb20wa(struct ssb_device *dev)
80} 80}
81 81
82/* based on arch/mips/brcm-boards/bcm947xx/pcibios.c */ 82/* based on arch/mips/brcm-boards/bcm947xx/pcibios.c */
83static u32 __devinit ssb_hcd_init_chip(struct ssb_device *dev) 83static u32 ssb_hcd_init_chip(struct ssb_device *dev)
84{ 84{
85 u32 flags = 0; 85 u32 flags = 0;
86 86
@@ -101,8 +101,7 @@ static const struct usb_ehci_pdata ehci_pdata = {
101static const struct usb_ohci_pdata ohci_pdata = { 101static const struct usb_ohci_pdata ohci_pdata = {
102}; 102};
103 103
104static struct platform_device * __devinit 104static struct platform_device *ssb_hcd_create_pdev(struct ssb_device *dev, bool ohci, u32 addr, u32 len)
105ssb_hcd_create_pdev(struct ssb_device *dev, bool ohci, u32 addr, u32 len)
106{ 105{
107 struct platform_device *hci_dev; 106 struct platform_device *hci_dev;
108 struct resource hci_res[2]; 107 struct resource hci_res[2];
@@ -148,7 +147,7 @@ err_alloc:
148 return ERR_PTR(ret); 147 return ERR_PTR(ret);
149} 148}
150 149
151static int __devinit ssb_hcd_probe(struct ssb_device *dev, 150static int ssb_hcd_probe(struct ssb_device *dev,
152 const struct ssb_device_id *id) 151 const struct ssb_device_id *id)
153{ 152{
154 int err, tmp; 153 int err, tmp;
@@ -207,7 +206,7 @@ err_free_usb_dev:
207 return err; 206 return err;
208} 207}
209 208
210static void __devexit ssb_hcd_remove(struct ssb_device *dev) 209static void ssb_hcd_remove(struct ssb_device *dev)
211{ 210{
212 struct ssb_hcd_device *usb_dev = ssb_get_drvdata(dev); 211 struct ssb_hcd_device *usb_dev = ssb_get_drvdata(dev);
213 struct platform_device *ohci_dev = usb_dev->ohci_dev; 212 struct platform_device *ohci_dev = usb_dev->ohci_dev;
@@ -221,7 +220,7 @@ static void __devexit ssb_hcd_remove(struct ssb_device *dev)
221 ssb_device_disable(dev, 0); 220 ssb_device_disable(dev, 0);
222} 221}
223 222
224static void __devexit ssb_hcd_shutdown(struct ssb_device *dev) 223static void ssb_hcd_shutdown(struct ssb_device *dev)
225{ 224{
226 ssb_device_disable(dev, 0); 225 ssb_device_disable(dev, 0);
227} 226}
@@ -249,7 +248,7 @@ static int ssb_hcd_resume(struct ssb_device *dev)
249#define ssb_hcd_resume NULL 248#define ssb_hcd_resume NULL
250#endif /* CONFIG_PM */ 249#endif /* CONFIG_PM */
251 250
252static const struct ssb_device_id ssb_hcd_table[] __devinitconst = { 251static const struct ssb_device_id ssb_hcd_table[] = {
253 SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOSTDEV, SSB_ANY_REV), 252 SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOSTDEV, SSB_ANY_REV),
254 SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOST, SSB_ANY_REV), 253 SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOST, SSB_ANY_REV),
255 SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB20_HOST, SSB_ANY_REV), 254 SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB20_HOST, SSB_ANY_REV),
@@ -261,7 +260,7 @@ static struct ssb_driver ssb_hcd_driver = {
261 .name = KBUILD_MODNAME, 260 .name = KBUILD_MODNAME,
262 .id_table = ssb_hcd_table, 261 .id_table = ssb_hcd_table,
263 .probe = ssb_hcd_probe, 262 .probe = ssb_hcd_probe,
264 .remove = __devexit_p(ssb_hcd_remove), 263 .remove = ssb_hcd_remove,
265 .shutdown = ssb_hcd_shutdown, 264 .shutdown = ssb_hcd_shutdown,
266 .suspend = ssb_hcd_suspend, 265 .suspend = ssb_hcd_suspend,
267 .resume = ssb_hcd_resume, 266 .resume = ssb_hcd_resume,
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index dbbd1ba25224..5efdffe32365 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -2990,7 +2990,7 @@ static struct hc_driver u132_hc_driver = {
2990* synchronously - but instead should immediately stop activity to the 2990* synchronously - but instead should immediately stop activity to the
2991* device and asynchronously call usb_remove_hcd() 2991* device and asynchronously call usb_remove_hcd()
2992*/ 2992*/
2993static int __devexit u132_remove(struct platform_device *pdev) 2993static int u132_remove(struct platform_device *pdev)
2994{ 2994{
2995 struct usb_hcd *hcd = platform_get_drvdata(pdev); 2995 struct usb_hcd *hcd = platform_get_drvdata(pdev);
2996 if (hcd) { 2996 if (hcd) {
@@ -3084,7 +3084,7 @@ static void u132_initialise(struct u132 *u132, struct platform_device *pdev)
3084 mutex_unlock(&u132->sw_lock); 3084 mutex_unlock(&u132->sw_lock);
3085} 3085}
3086 3086
3087static int __devinit u132_probe(struct platform_device *pdev) 3087static int u132_probe(struct platform_device *pdev)
3088{ 3088{
3089 struct usb_hcd *hcd; 3089 struct usb_hcd *hcd;
3090 int retval; 3090 int retval;
@@ -3212,7 +3212,7 @@ static int u132_resume(struct platform_device *pdev)
3212*/ 3212*/
3213static struct platform_driver u132_platform_driver = { 3213static struct platform_driver u132_platform_driver = {
3214 .probe = u132_probe, 3214 .probe = u132_probe,
3215 .remove = __devexit_p(u132_remove), 3215 .remove = u132_remove,
3216 .suspend = u132_suspend, 3216 .suspend = u132_suspend,
3217 .resume = u132_resume, 3217 .resume = u132_resume,
3218 .driver = { 3218 .driver = {
diff --git a/drivers/usb/host/uhci-grlib.c b/drivers/usb/host/uhci-grlib.c
index f7a62138e3e0..511bfc46dd78 100644
--- a/drivers/usb/host/uhci-grlib.c
+++ b/drivers/usb/host/uhci-grlib.c
@@ -85,7 +85,7 @@ static const struct hc_driver uhci_grlib_hc_driver = {
85}; 85};
86 86
87 87
88static int __devinit uhci_hcd_grlib_probe(struct platform_device *op) 88static int uhci_hcd_grlib_probe(struct platform_device *op)
89{ 89{
90 struct device_node *dn = op->dev.of_node; 90 struct device_node *dn = op->dev.of_node;
91 struct usb_hcd *hcd; 91 struct usb_hcd *hcd;
diff --git a/drivers/usb/host/uhci-platform.c b/drivers/usb/host/uhci-platform.c
index 68ebf20e1519..8c4dace4b14a 100644
--- a/drivers/usb/host/uhci-platform.c
+++ b/drivers/usb/host/uhci-platform.c
@@ -62,7 +62,7 @@ static const struct hc_driver uhci_platform_hc_driver = {
62 62
63static u64 platform_uhci_dma_mask = DMA_BIT_MASK(32); 63static u64 platform_uhci_dma_mask = DMA_BIT_MASK(32);
64 64
65static int __devinit uhci_hcd_platform_probe(struct platform_device *pdev) 65static int uhci_hcd_platform_probe(struct platform_device *pdev)
66{ 66{
67 struct usb_hcd *hcd; 67 struct usb_hcd *hcd;
68 struct uhci_hcd *uhci; 68 struct uhci_hcd *uhci;
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index d2c6f5ac4626..15921fd55048 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -1256,7 +1256,8 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb,
1256 struct uhci_qh *qh) 1256 struct uhci_qh *qh)
1257{ 1257{
1258 struct uhci_td *td = NULL; /* Since urb->number_of_packets > 0 */ 1258 struct uhci_td *td = NULL; /* Since urb->number_of_packets > 0 */
1259 int i, frame; 1259 int i;
1260 unsigned frame, next;
1260 unsigned long destination, status; 1261 unsigned long destination, status;
1261 struct urb_priv *urbp = (struct urb_priv *) urb->hcpriv; 1262 struct urb_priv *urbp = (struct urb_priv *) urb->hcpriv;
1262 1263
@@ -1265,37 +1266,29 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb,
1265 urb->number_of_packets >= UHCI_NUMFRAMES) 1266 urb->number_of_packets >= UHCI_NUMFRAMES)
1266 return -EFBIG; 1267 return -EFBIG;
1267 1268
1269 uhci_get_current_frame_number(uhci);
1270
1268 /* Check the period and figure out the starting frame number */ 1271 /* Check the period and figure out the starting frame number */
1269 if (!qh->bandwidth_reserved) { 1272 if (!qh->bandwidth_reserved) {
1270 qh->period = urb->interval; 1273 qh->period = urb->interval;
1271 if (urb->transfer_flags & URB_ISO_ASAP) { 1274 qh->phase = -1; /* Find the best phase */
1272 qh->phase = -1; /* Find the best phase */ 1275 i = uhci_check_bandwidth(uhci, qh);
1273 i = uhci_check_bandwidth(uhci, qh); 1276 if (i)
1274 if (i) 1277 return i;
1275 return i; 1278
1276 1279 /* Allow a little time to allocate the TDs */
1277 /* Allow a little time to allocate the TDs */ 1280 next = uhci->frame_number + 10;
1278 uhci_get_current_frame_number(uhci); 1281 frame = qh->phase;
1279 frame = uhci->frame_number + 10; 1282
1280 1283 /* Round up to the first available slot */
1281 /* Move forward to the first frame having the 1284 frame += (next - frame + qh->period - 1) & -qh->period;
1282 * correct phase */
1283 urb->start_frame = frame + ((qh->phase - frame) &
1284 (qh->period - 1));
1285 } else {
1286 i = urb->start_frame - uhci->last_iso_frame;
1287 if (i <= 0 || i >= UHCI_NUMFRAMES)
1288 return -EINVAL;
1289 qh->phase = urb->start_frame & (qh->period - 1);
1290 i = uhci_check_bandwidth(uhci, qh);
1291 if (i)
1292 return i;
1293 }
1294 1285
1295 } else if (qh->period != urb->interval) { 1286 } else if (qh->period != urb->interval) {
1296 return -EINVAL; /* Can't change the period */ 1287 return -EINVAL; /* Can't change the period */
1297 1288
1298 } else { 1289 } else {
1290 next = uhci->frame_number + 2;
1291
1299 /* Find the next unused frame */ 1292 /* Find the next unused frame */
1300 if (list_empty(&qh->queue)) { 1293 if (list_empty(&qh->queue)) {
1301 frame = qh->iso_frame; 1294 frame = qh->iso_frame;
@@ -1308,25 +1301,31 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb,
1308 lurb->number_of_packets * 1301 lurb->number_of_packets *
1309 lurb->interval; 1302 lurb->interval;
1310 } 1303 }
1311 if (urb->transfer_flags & URB_ISO_ASAP) { 1304
1312 /* Skip some frames if necessary to insure 1305 /* Fell behind? */
1313 * the start frame is in the future. 1306 if (uhci_frame_before_eq(frame, next)) {
1307
1308 /* USB_ISO_ASAP: Round up to the first available slot */
1309 if (urb->transfer_flags & URB_ISO_ASAP)
1310 frame += (next - frame + qh->period - 1) &
1311 -qh->period;
1312
1313 /*
1314 * Not ASAP: Use the next slot in the stream. If
1315 * the entire URB falls before the threshold, fail.
1314 */ 1316 */
1315 uhci_get_current_frame_number(uhci); 1317 else if (!uhci_frame_before_eq(next,
1316 if (uhci_frame_before_eq(frame, uhci->frame_number)) { 1318 frame + (urb->number_of_packets - 1) *
1317 frame = uhci->frame_number + 1; 1319 qh->period))
1318 frame += ((qh->phase - frame) & 1320 return -EXDEV;
1319 (qh->period - 1)); 1321 }
1320 }
1321 } /* Otherwise pick up where the last URB leaves off */
1322 urb->start_frame = frame;
1323 } 1322 }
1324 1323
1325 /* Make sure we won't have to go too far into the future */ 1324 /* Make sure we won't have to go too far into the future */
1326 if (uhci_frame_before_eq(uhci->last_iso_frame + UHCI_NUMFRAMES, 1325 if (uhci_frame_before_eq(uhci->last_iso_frame + UHCI_NUMFRAMES,
1327 urb->start_frame + urb->number_of_packets * 1326 frame + urb->number_of_packets * urb->interval))
1328 urb->interval))
1329 return -EFBIG; 1327 return -EFBIG;
1328 urb->start_frame = frame;
1330 1329
1331 status = TD_CTRL_ACTIVE | TD_CTRL_IOS; 1330 status = TD_CTRL_ACTIVE | TD_CTRL_IOS;
1332 destination = (urb->pipe & PIPE_DEVEP_MASK) | usb_packetid(urb->pipe); 1331 destination = (urb->pipe & PIPE_DEVEP_MASK) | usb_packetid(urb->pipe);
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 487bc083dead..fb51c7085ad0 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -205,7 +205,12 @@ static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci,
205 205
206 next = xhci_segment_alloc(xhci, cycle_state, flags); 206 next = xhci_segment_alloc(xhci, cycle_state, flags);
207 if (!next) { 207 if (!next) {
208 xhci_free_segments_for_ring(xhci, *first); 208 prev = *first;
209 while (prev) {
210 next = prev->next;
211 xhci_segment_free(xhci, prev);
212 prev = next;
213 }
209 return -ENOMEM; 214 return -ENOMEM;
210 } 215 }
211 xhci_link_segments(xhci, prev, next, type); 216 xhci_link_segments(xhci, prev, next, type);
@@ -258,7 +263,7 @@ static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci,
258 return ring; 263 return ring;
259 264
260fail: 265fail:
261 xhci_ring_free(xhci, ring); 266 kfree(ring);
262 return NULL; 267 return NULL;
263} 268}
264 269
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 8345d7c23061..af259e0ec172 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -29,6 +29,7 @@
29/* Device for a quirk */ 29/* Device for a quirk */
30#define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73 30#define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73
31#define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000 31#define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000
32#define PCI_DEVICE_ID_FRESCO_LOGIC_FL1400 0x1400
32 33
33#define PCI_VENDOR_ID_ETRON 0x1b6f 34#define PCI_VENDOR_ID_ETRON 0x1b6f
34#define PCI_DEVICE_ID_ASROCK_P67 0x7023 35#define PCI_DEVICE_ID_ASROCK_P67 0x7023
@@ -58,8 +59,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
58 59
59 /* Look for vendor-specific quirks */ 60 /* Look for vendor-specific quirks */
60 if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC && 61 if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC &&
61 pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK) { 62 (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK ||
62 if (pdev->revision == 0x0) { 63 pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1400)) {
64 if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK &&
65 pdev->revision == 0x0) {
63 xhci->quirks |= XHCI_RESET_EP_QUIRK; 66 xhci->quirks |= XHCI_RESET_EP_QUIRK;
64 xhci_dbg(xhci, "QUIRK: Fresco Logic xHC needs configure" 67 xhci_dbg(xhci, "QUIRK: Fresco Logic xHC needs configure"
65 " endpoint cmd after reset endpoint\n"); 68 " endpoint cmd after reset endpoint\n");
@@ -218,15 +221,8 @@ static void xhci_pci_remove(struct pci_dev *dev)
218static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) 221static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
219{ 222{
220 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 223 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
221 int retval = 0;
222 224
223 if (hcd->state != HC_STATE_SUSPENDED || 225 return xhci_suspend(xhci);
224 xhci->shared_hcd->state != HC_STATE_SUSPENDED)
225 return -EINVAL;
226
227 retval = xhci_suspend(xhci);
228
229 return retval;
230} 226}
231 227
232static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated) 228static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 4e1a8946b8d1..cbb44b7b9d65 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -318,7 +318,7 @@ static int xhci_abort_cmd_ring(struct xhci_hcd *xhci)
318 * seconds), then it should assume that the there are 318 * seconds), then it should assume that the there are
319 * larger problems with the xHC and assert HCRST. 319 * larger problems with the xHC and assert HCRST.
320 */ 320 */
321 ret = handshake(xhci, &xhci->op_regs->cmd_ring, 321 ret = xhci_handshake(xhci, &xhci->op_regs->cmd_ring,
322 CMD_RING_RUNNING, 0, 5 * 1000 * 1000); 322 CMD_RING_RUNNING, 0, 5 * 1000 * 1000);
323 if (ret < 0) { 323 if (ret < 0) {
324 xhci_err(xhci, "Stopped the command ring failed, " 324 xhci_err(xhci, "Stopped the command ring failed, "
@@ -3071,11 +3071,11 @@ static u32 xhci_td_remainder(unsigned int remainder)
3071} 3071}
3072 3072
3073/* 3073/*
3074 * For xHCI 1.0 host controllers, TD size is the number of packets remaining in 3074 * For xHCI 1.0 host controllers, TD size is the number of max packet sized
3075 * the TD (*not* including this TRB). 3075 * packets remaining in the TD (*not* including this TRB).
3076 * 3076 *
3077 * Total TD packet count = total_packet_count = 3077 * Total TD packet count = total_packet_count =
3078 * roundup(TD size in bytes / wMaxPacketSize) 3078 * DIV_ROUND_UP(TD size in bytes / wMaxPacketSize)
3079 * 3079 *
3080 * Packets transferred up to and including this TRB = packets_transferred = 3080 * Packets transferred up to and including this TRB = packets_transferred =
3081 * rounddown(total bytes transferred including this TRB / wMaxPacketSize) 3081 * rounddown(total bytes transferred including this TRB / wMaxPacketSize)
@@ -3083,15 +3083,16 @@ static u32 xhci_td_remainder(unsigned int remainder)
3083 * TD size = total_packet_count - packets_transferred 3083 * TD size = total_packet_count - packets_transferred
3084 * 3084 *
3085 * It must fit in bits 21:17, so it can't be bigger than 31. 3085 * It must fit in bits 21:17, so it can't be bigger than 31.
3086 * The last TRB in a TD must have the TD size set to zero.
3086 */ 3087 */
3087
3088static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len, 3088static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len,
3089 unsigned int total_packet_count, struct urb *urb) 3089 unsigned int total_packet_count, struct urb *urb,
3090 unsigned int num_trbs_left)
3090{ 3091{
3091 int packets_transferred; 3092 int packets_transferred;
3092 3093
3093 /* One TRB with a zero-length data packet. */ 3094 /* One TRB with a zero-length data packet. */
3094 if (running_total == 0 && trb_buff_len == 0) 3095 if (num_trbs_left == 0 || (running_total == 0 && trb_buff_len == 0))
3095 return 0; 3096 return 0;
3096 3097
3097 /* All the TRB queueing functions don't count the current TRB in 3098 /* All the TRB queueing functions don't count the current TRB in
@@ -3100,7 +3101,9 @@ static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len,
3100 packets_transferred = (running_total + trb_buff_len) / 3101 packets_transferred = (running_total + trb_buff_len) /
3101 usb_endpoint_maxp(&urb->ep->desc); 3102 usb_endpoint_maxp(&urb->ep->desc);
3102 3103
3103 return xhci_td_remainder(total_packet_count - packets_transferred); 3104 if ((total_packet_count - packets_transferred) > 31)
3105 return 31 << 17;
3106 return (total_packet_count - packets_transferred) << 17;
3104} 3107}
3105 3108
3106static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, 3109static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
@@ -3127,7 +3130,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3127 3130
3128 num_trbs = count_sg_trbs_needed(xhci, urb); 3131 num_trbs = count_sg_trbs_needed(xhci, urb);
3129 num_sgs = urb->num_mapped_sgs; 3132 num_sgs = urb->num_mapped_sgs;
3130 total_packet_count = roundup(urb->transfer_buffer_length, 3133 total_packet_count = DIV_ROUND_UP(urb->transfer_buffer_length,
3131 usb_endpoint_maxp(&urb->ep->desc)); 3134 usb_endpoint_maxp(&urb->ep->desc));
3132 3135
3133 trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id], 3136 trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id],
@@ -3210,7 +3213,8 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3210 running_total); 3213 running_total);
3211 } else { 3214 } else {
3212 remainder = xhci_v1_0_td_remainder(running_total, 3215 remainder = xhci_v1_0_td_remainder(running_total,
3213 trb_buff_len, total_packet_count, urb); 3216 trb_buff_len, total_packet_count, urb,
3217 num_trbs - 1);
3214 } 3218 }
3215 length_field = TRB_LEN(trb_buff_len) | 3219 length_field = TRB_LEN(trb_buff_len) |
3216 remainder | 3220 remainder |
@@ -3318,7 +3322,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3318 start_cycle = ep_ring->cycle_state; 3322 start_cycle = ep_ring->cycle_state;
3319 3323
3320 running_total = 0; 3324 running_total = 0;
3321 total_packet_count = roundup(urb->transfer_buffer_length, 3325 total_packet_count = DIV_ROUND_UP(urb->transfer_buffer_length,
3322 usb_endpoint_maxp(&urb->ep->desc)); 3326 usb_endpoint_maxp(&urb->ep->desc));
3323 /* How much data is in the first TRB? */ 3327 /* How much data is in the first TRB? */
3324 addr = (u64) urb->transfer_dma; 3328 addr = (u64) urb->transfer_dma;
@@ -3364,7 +3368,8 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3364 running_total); 3368 running_total);
3365 } else { 3369 } else {
3366 remainder = xhci_v1_0_td_remainder(running_total, 3370 remainder = xhci_v1_0_td_remainder(running_total,
3367 trb_buff_len, total_packet_count, urb); 3371 trb_buff_len, total_packet_count, urb,
3372 num_trbs - 1);
3368 } 3373 }
3369 length_field = TRB_LEN(trb_buff_len) | 3374 length_field = TRB_LEN(trb_buff_len) |
3370 remainder | 3375 remainder |
@@ -3627,7 +3632,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3627 addr = start_addr + urb->iso_frame_desc[i].offset; 3632 addr = start_addr + urb->iso_frame_desc[i].offset;
3628 td_len = urb->iso_frame_desc[i].length; 3633 td_len = urb->iso_frame_desc[i].length;
3629 td_remain_len = td_len; 3634 td_remain_len = td_len;
3630 total_packet_count = roundup(td_len, 3635 total_packet_count = DIV_ROUND_UP(td_len,
3631 usb_endpoint_maxp(&urb->ep->desc)); 3636 usb_endpoint_maxp(&urb->ep->desc));
3632 /* A zero-length transfer still involves at least one packet. */ 3637 /* A zero-length transfer still involves at least one packet. */
3633 if (total_packet_count == 0) 3638 if (total_packet_count == 0)
@@ -3706,7 +3711,8 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3706 } else { 3711 } else {
3707 remainder = xhci_v1_0_td_remainder( 3712 remainder = xhci_v1_0_td_remainder(
3708 running_total, trb_buff_len, 3713 running_total, trb_buff_len,
3709 total_packet_count, urb); 3714 total_packet_count, urb,
3715 (trbs_per_td - j - 1));
3710 } 3716 }
3711 length_field = TRB_LEN(trb_buff_len) | 3717 length_field = TRB_LEN(trb_buff_len) |
3712 remainder | 3718 remainder |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index c9e419f29b74..5c72c431bab1 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -40,7 +40,7 @@ MODULE_PARM_DESC(link_quirk, "Don't clear the chain bit on a link TRB");
40 40
41/* TODO: copied from ehci-hcd.c - can this be refactored? */ 41/* TODO: copied from ehci-hcd.c - can this be refactored? */
42/* 42/*
43 * handshake - spin reading hc until handshake completes or fails 43 * xhci_handshake - spin reading hc until handshake completes or fails
44 * @ptr: address of hc register to be read 44 * @ptr: address of hc register to be read
45 * @mask: bits to look at in result of read 45 * @mask: bits to look at in result of read
46 * @done: value of those bits when handshake succeeds 46 * @done: value of those bits when handshake succeeds
@@ -52,7 +52,7 @@ MODULE_PARM_DESC(link_quirk, "Don't clear the chain bit on a link TRB");
52 * handshake done). There are two failure modes: "usec" have passed (major 52 * handshake done). There are two failure modes: "usec" have passed (major
53 * hardware flakeout), or the register reads as all-ones (hardware removed). 53 * hardware flakeout), or the register reads as all-ones (hardware removed).
54 */ 54 */
55int handshake(struct xhci_hcd *xhci, void __iomem *ptr, 55int xhci_handshake(struct xhci_hcd *xhci, void __iomem *ptr,
56 u32 mask, u32 done, int usec) 56 u32 mask, u32 done, int usec)
57{ 57{
58 u32 result; 58 u32 result;
@@ -103,7 +103,7 @@ int xhci_halt(struct xhci_hcd *xhci)
103 xhci_dbg(xhci, "// Halt the HC\n"); 103 xhci_dbg(xhci, "// Halt the HC\n");
104 xhci_quiesce(xhci); 104 xhci_quiesce(xhci);
105 105
106 ret = handshake(xhci, &xhci->op_regs->status, 106 ret = xhci_handshake(xhci, &xhci->op_regs->status,
107 STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC); 107 STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC);
108 if (!ret) { 108 if (!ret) {
109 xhci->xhc_state |= XHCI_STATE_HALTED; 109 xhci->xhc_state |= XHCI_STATE_HALTED;
@@ -132,7 +132,7 @@ static int xhci_start(struct xhci_hcd *xhci)
132 * Wait for the HCHalted Status bit to be 0 to indicate the host is 132 * Wait for the HCHalted Status bit to be 0 to indicate the host is
133 * running. 133 * running.
134 */ 134 */
135 ret = handshake(xhci, &xhci->op_regs->status, 135 ret = xhci_handshake(xhci, &xhci->op_regs->status,
136 STS_HALT, 0, XHCI_MAX_HALT_USEC); 136 STS_HALT, 0, XHCI_MAX_HALT_USEC);
137 if (ret == -ETIMEDOUT) 137 if (ret == -ETIMEDOUT)
138 xhci_err(xhci, "Host took too long to start, " 138 xhci_err(xhci, "Host took too long to start, "
@@ -167,7 +167,7 @@ int xhci_reset(struct xhci_hcd *xhci)
167 command |= CMD_RESET; 167 command |= CMD_RESET;
168 xhci_writel(xhci, command, &xhci->op_regs->command); 168 xhci_writel(xhci, command, &xhci->op_regs->command);
169 169
170 ret = handshake(xhci, &xhci->op_regs->command, 170 ret = xhci_handshake(xhci, &xhci->op_regs->command,
171 CMD_RESET, 0, 10 * 1000 * 1000); 171 CMD_RESET, 0, 10 * 1000 * 1000);
172 if (ret) 172 if (ret)
173 return ret; 173 return ret;
@@ -177,7 +177,7 @@ int xhci_reset(struct xhci_hcd *xhci)
177 * xHCI cannot write to any doorbells or operational registers other 177 * xHCI cannot write to any doorbells or operational registers other
178 * than status until the "Controller Not Ready" flag is cleared. 178 * than status until the "Controller Not Ready" flag is cleared.
179 */ 179 */
180 ret = handshake(xhci, &xhci->op_regs->status, 180 ret = xhci_handshake(xhci, &xhci->op_regs->status,
181 STS_CNR, 0, 10 * 1000 * 1000); 181 STS_CNR, 0, 10 * 1000 * 1000);
182 182
183 for (i = 0; i < 2; ++i) { 183 for (i = 0; i < 2; ++i) {
@@ -480,7 +480,7 @@ static bool compliance_mode_recovery_timer_quirk_check(void)
480 if (strstr(dmi_product_name, "Z420") || 480 if (strstr(dmi_product_name, "Z420") ||
481 strstr(dmi_product_name, "Z620") || 481 strstr(dmi_product_name, "Z620") ||
482 strstr(dmi_product_name, "Z820") || 482 strstr(dmi_product_name, "Z820") ||
483 strstr(dmi_product_name, "Z1")) 483 strstr(dmi_product_name, "Z1 Workstation"))
484 return true; 484 return true;
485 485
486 return false; 486 return false;
@@ -880,6 +880,10 @@ int xhci_suspend(struct xhci_hcd *xhci)
880 struct usb_hcd *hcd = xhci_to_hcd(xhci); 880 struct usb_hcd *hcd = xhci_to_hcd(xhci);
881 u32 command; 881 u32 command;
882 882
883 if (hcd->state != HC_STATE_SUSPENDED ||
884 xhci->shared_hcd->state != HC_STATE_SUSPENDED)
885 return -EINVAL;
886
883 spin_lock_irq(&xhci->lock); 887 spin_lock_irq(&xhci->lock);
884 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 888 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
885 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); 889 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags);
@@ -890,7 +894,7 @@ int xhci_suspend(struct xhci_hcd *xhci)
890 command = xhci_readl(xhci, &xhci->op_regs->command); 894 command = xhci_readl(xhci, &xhci->op_regs->command);
891 command &= ~CMD_RUN; 895 command &= ~CMD_RUN;
892 xhci_writel(xhci, command, &xhci->op_regs->command); 896 xhci_writel(xhci, command, &xhci->op_regs->command);
893 if (handshake(xhci, &xhci->op_regs->status, 897 if (xhci_handshake(xhci, &xhci->op_regs->status,
894 STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC)) { 898 STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC)) {
895 xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n"); 899 xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n");
896 spin_unlock_irq(&xhci->lock); 900 spin_unlock_irq(&xhci->lock);
@@ -905,7 +909,8 @@ int xhci_suspend(struct xhci_hcd *xhci)
905 command = xhci_readl(xhci, &xhci->op_regs->command); 909 command = xhci_readl(xhci, &xhci->op_regs->command);
906 command |= CMD_CSS; 910 command |= CMD_CSS;
907 xhci_writel(xhci, command, &xhci->op_regs->command); 911 xhci_writel(xhci, command, &xhci->op_regs->command);
908 if (handshake(xhci, &xhci->op_regs->status, STS_SAVE, 0, 10 * 1000)) { 912 if (xhci_handshake(xhci, &xhci->op_regs->status,
913 STS_SAVE, 0, 10 * 1000)) {
909 xhci_warn(xhci, "WARN: xHC save state timeout\n"); 914 xhci_warn(xhci, "WARN: xHC save state timeout\n");
910 spin_unlock_irq(&xhci->lock); 915 spin_unlock_irq(&xhci->lock);
911 return -ETIMEDOUT; 916 return -ETIMEDOUT;
@@ -967,7 +972,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
967 command = xhci_readl(xhci, &xhci->op_regs->command); 972 command = xhci_readl(xhci, &xhci->op_regs->command);
968 command |= CMD_CRS; 973 command |= CMD_CRS;
969 xhci_writel(xhci, command, &xhci->op_regs->command); 974 xhci_writel(xhci, command, &xhci->op_regs->command);
970 if (handshake(xhci, &xhci->op_regs->status, 975 if (xhci_handshake(xhci, &xhci->op_regs->status,
971 STS_RESTORE, 0, 10 * 1000)) { 976 STS_RESTORE, 0, 10 * 1000)) {
972 xhci_warn(xhci, "WARN: xHC restore state timeout\n"); 977 xhci_warn(xhci, "WARN: xHC restore state timeout\n");
973 spin_unlock_irq(&xhci->lock); 978 spin_unlock_irq(&xhci->lock);
@@ -1035,7 +1040,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1035 command = xhci_readl(xhci, &xhci->op_regs->command); 1040 command = xhci_readl(xhci, &xhci->op_regs->command);
1036 command |= CMD_RUN; 1041 command |= CMD_RUN;
1037 xhci_writel(xhci, command, &xhci->op_regs->command); 1042 xhci_writel(xhci, command, &xhci->op_regs->command);
1038 handshake(xhci, &xhci->op_regs->status, STS_HALT, 1043 xhci_handshake(xhci, &xhci->op_regs->status, STS_HALT,
1039 0, 250 * 1000); 1044 0, 250 * 1000);
1040 1045
1041 /* step 5: walk topology and initialize portsc, 1046 /* step 5: walk topology and initialize portsc,
@@ -2254,7 +2259,7 @@ static bool xhci_is_async_ep(unsigned int ep_type)
2254 2259
2255static bool xhci_is_sync_in_ep(unsigned int ep_type) 2260static bool xhci_is_sync_in_ep(unsigned int ep_type)
2256{ 2261{
2257 return (ep_type == ISOC_IN_EP || ep_type != INT_IN_EP); 2262 return (ep_type == ISOC_IN_EP || ep_type == INT_IN_EP);
2258} 2263}
2259 2264
2260static unsigned int xhci_get_ss_bw_consumed(struct xhci_bw_info *ep_bw) 2265static unsigned int xhci_get_ss_bw_consumed(struct xhci_bw_info *ep_bw)
@@ -3874,7 +3879,8 @@ static int xhci_usb2_software_lpm_test(struct usb_hcd *hcd,
3874 spin_lock_irqsave(&xhci->lock, flags); 3879 spin_lock_irqsave(&xhci->lock, flags);
3875 3880
3876 /* Check L1 Status */ 3881 /* Check L1 Status */
3877 ret = handshake(xhci, pm_addr, PORT_L1S_MASK, PORT_L1S_SUCCESS, 125); 3882 ret = xhci_handshake(xhci, pm_addr,
3883 PORT_L1S_MASK, PORT_L1S_SUCCESS, 125);
3878 if (ret != -ETIMEDOUT) { 3884 if (ret != -ETIMEDOUT) {
3879 /* enter L1 successfully */ 3885 /* enter L1 successfully */
3880 temp = xhci_readl(xhci, addr); 3886 temp = xhci_readl(xhci, addr);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 53df4e70ca07..f791bd0aee6c 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1720,7 +1720,7 @@ static inline void xhci_unregister_plat(void)
1720 1720
1721/* xHCI host controller glue */ 1721/* xHCI host controller glue */
1722typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *); 1722typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *);
1723int handshake(struct xhci_hcd *xhci, void __iomem *ptr, 1723int xhci_handshake(struct xhci_hcd *xhci, void __iomem *ptr,
1724 u32 mask, u32 done, int usec); 1724 u32 mask, u32 done, int usec);
1725void xhci_quiesce(struct xhci_hcd *xhci); 1725void xhci_quiesce(struct xhci_hcd *xhci);
1726int xhci_halt(struct xhci_hcd *xhci); 1726int xhci_halt(struct xhci_hcd *xhci);
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index a8f05239350e..fecde69bfa7d 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -246,6 +246,7 @@ config USB_YUREX
246 246
247config USB_EZUSB_FX2 247config USB_EZUSB_FX2
248 tristate "Functions for loading firmware on EZUSB chips" 248 tristate "Functions for loading firmware on EZUSB chips"
249 depends on USB
249 help 250 help
250 Say Y here if you need EZUSB device support. 251 Say Y here if you need EZUSB device support.
251 (Cypress FX/FX2/FX2LP microcontrollers) 252 (Cypress FX/FX2/FX2LP microcontrollers)
diff --git a/drivers/usb/misc/ezusb.c b/drivers/usb/misc/ezusb.c
index 6589268a6515..e712afed947c 100644
--- a/drivers/usb/misc/ezusb.c
+++ b/drivers/usb/misc/ezusb.c
@@ -15,6 +15,7 @@
15#include <linux/usb.h> 15#include <linux/usb.h>
16#include <linux/firmware.h> 16#include <linux/firmware.h>
17#include <linux/ihex.h> 17#include <linux/ihex.h>
18#include <linux/usb/ezusb.h>
18 19
19struct ezusb_fx_type { 20struct ezusb_fx_type {
20 /* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */ 21 /* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */
@@ -22,21 +23,16 @@ struct ezusb_fx_type {
22 unsigned short max_internal_adress; 23 unsigned short max_internal_adress;
23}; 24};
24 25
25struct ezusb_fx_type ezusb_fx1 = { 26static struct ezusb_fx_type ezusb_fx1 = {
26 .cpucs_reg = 0x7F92, 27 .cpucs_reg = 0x7F92,
27 .max_internal_adress = 0x1B3F, 28 .max_internal_adress = 0x1B3F,
28}; 29};
29 30
30struct ezusb_fx_type ezusb_fx2 = {
31 .cpucs_reg = 0xE600,
32 .max_internal_adress = 0x3FFF,
33};
34
35/* Commands for writing to memory */ 31/* Commands for writing to memory */
36#define WRITE_INT_RAM 0xA0 32#define WRITE_INT_RAM 0xA0
37#define WRITE_EXT_RAM 0xA3 33#define WRITE_EXT_RAM 0xA3
38 34
39int ezusb_writememory(struct usb_device *dev, int address, 35static int ezusb_writememory(struct usb_device *dev, int address,
40 unsigned char *data, int length, __u8 request) 36 unsigned char *data, int length, __u8 request)
41{ 37{
42 int result; 38 int result;
@@ -58,10 +54,9 @@ int ezusb_writememory(struct usb_device *dev, int address,
58 kfree(transfer_buffer); 54 kfree(transfer_buffer);
59 return result; 55 return result;
60} 56}
61EXPORT_SYMBOL_GPL(ezusb_writememory);
62 57
63int ezusb_set_reset(struct usb_device *dev, unsigned short cpucs_reg, 58static int ezusb_set_reset(struct usb_device *dev, unsigned short cpucs_reg,
64 unsigned char reset_bit) 59 unsigned char reset_bit)
65{ 60{
66 int response = ezusb_writememory(dev, cpucs_reg, &reset_bit, 1, WRITE_INT_RAM); 61 int response = ezusb_writememory(dev, cpucs_reg, &reset_bit, 1, WRITE_INT_RAM);
67 if (response < 0) 62 if (response < 0)
@@ -76,12 +71,6 @@ int ezusb_fx1_set_reset(struct usb_device *dev, unsigned char reset_bit)
76} 71}
77EXPORT_SYMBOL_GPL(ezusb_fx1_set_reset); 72EXPORT_SYMBOL_GPL(ezusb_fx1_set_reset);
78 73
79int ezusb_fx2_set_reset(struct usb_device *dev, unsigned char reset_bit)
80{
81 return ezusb_set_reset(dev, ezusb_fx2.cpucs_reg, reset_bit);
82}
83EXPORT_SYMBOL_GPL(ezusb_fx2_set_reset);
84
85static int ezusb_ihex_firmware_download(struct usb_device *dev, 74static int ezusb_ihex_firmware_download(struct usb_device *dev,
86 struct ezusb_fx_type fx, 75 struct ezusb_fx_type fx,
87 const char *firmware_path) 76 const char *firmware_path)
@@ -151,11 +140,28 @@ int ezusb_fx1_ihex_firmware_download(struct usb_device *dev,
151} 140}
152EXPORT_SYMBOL_GPL(ezusb_fx1_ihex_firmware_download); 141EXPORT_SYMBOL_GPL(ezusb_fx1_ihex_firmware_download);
153 142
143#if 0
144/*
145 * Once someone one needs these fx2 functions, uncomment them
146 * and add them to ezusb.h and all should be good.
147 */
148static struct ezusb_fx_type ezusb_fx2 = {
149 .cpucs_reg = 0xE600,
150 .max_internal_adress = 0x3FFF,
151};
152
153int ezusb_fx2_set_reset(struct usb_device *dev, unsigned char reset_bit)
154{
155 return ezusb_set_reset(dev, ezusb_fx2.cpucs_reg, reset_bit);
156}
157EXPORT_SYMBOL_GPL(ezusb_fx2_set_reset);
158
154int ezusb_fx2_ihex_firmware_download(struct usb_device *dev, 159int ezusb_fx2_ihex_firmware_download(struct usb_device *dev,
155 const char *firmware_path) 160 const char *firmware_path)
156{ 161{
157 return ezusb_ihex_firmware_download(dev, ezusb_fx2, firmware_path); 162 return ezusb_ihex_firmware_download(dev, ezusb_fx2, firmware_path);
158} 163}
159EXPORT_SYMBOL_GPL(ezusb_fx2_ihex_firmware_download); 164EXPORT_SYMBOL_GPL(ezusb_fx2_ihex_firmware_download);
165#endif
160 166
161MODULE_LICENSE("GPL"); 167MODULE_LICENSE("GPL");
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 055b84adedac..7667b12f2ff5 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -423,6 +423,9 @@ alloc_sglist(int nents, int max, int vary)
423 unsigned i; 423 unsigned i;
424 unsigned size = max; 424 unsigned size = max;
425 425
426 if (max == 0)
427 return NULL;
428
426 sg = kmalloc_array(nents, sizeof *sg, GFP_KERNEL); 429 sg = kmalloc_array(nents, sizeof *sg, GFP_KERNEL);
427 if (!sg) 430 if (!sg)
428 return NULL; 431 return NULL;
@@ -2386,6 +2389,7 @@ static struct usbtest_info gz_info = {
2386 .name = "Linux gadget zero", 2389 .name = "Linux gadget zero",
2387 .autoconf = 1, 2390 .autoconf = 1,
2388 .ctrl_out = 1, 2391 .ctrl_out = 1,
2392 .iso = 1,
2389 .alt = 0, 2393 .alt = 0,
2390}; 2394};
2391 2395
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index c964d6af178b..3d1c71b50f76 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -455,7 +455,7 @@ static const struct musb_platform_ops am35x_ops = {
455 455
456static u64 am35x_dmamask = DMA_BIT_MASK(32); 456static u64 am35x_dmamask = DMA_BIT_MASK(32);
457 457
458static int __devinit am35x_probe(struct platform_device *pdev) 458static int am35x_probe(struct platform_device *pdev)
459{ 459{
460 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; 460 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
461 struct platform_device *musb; 461 struct platform_device *musb;
@@ -465,7 +465,6 @@ static int __devinit am35x_probe(struct platform_device *pdev)
465 struct clk *clk; 465 struct clk *clk;
466 466
467 int ret = -ENOMEM; 467 int ret = -ENOMEM;
468 int musbid;
469 468
470 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 469 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
471 if (!glue) { 470 if (!glue) {
@@ -473,18 +472,10 @@ static int __devinit am35x_probe(struct platform_device *pdev)
473 goto err0; 472 goto err0;
474 } 473 }
475 474
476 /* get the musb id */ 475 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
477 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
478 if (musbid < 0) {
479 dev_err(&pdev->dev, "failed to allocate musb id\n");
480 ret = -ENOMEM;
481 goto err1;
482 }
483
484 musb = platform_device_alloc("musb-hdrc", musbid);
485 if (!musb) { 476 if (!musb) {
486 dev_err(&pdev->dev, "failed to allocate musb device\n"); 477 dev_err(&pdev->dev, "failed to allocate musb device\n");
487 goto err2; 478 goto err1;
488 } 479 }
489 480
490 phy_clk = clk_get(&pdev->dev, "fck"); 481 phy_clk = clk_get(&pdev->dev, "fck");
@@ -513,7 +504,6 @@ static int __devinit am35x_probe(struct platform_device *pdev)
513 goto err6; 504 goto err6;
514 } 505 }
515 506
516 musb->id = musbid;
517 musb->dev.parent = &pdev->dev; 507 musb->dev.parent = &pdev->dev;
518 musb->dev.dma_mask = &am35x_dmamask; 508 musb->dev.dma_mask = &am35x_dmamask;
519 musb->dev.coherent_dma_mask = am35x_dmamask; 509 musb->dev.coherent_dma_mask = am35x_dmamask;
@@ -563,9 +553,6 @@ err4:
563err3: 553err3:
564 platform_device_put(musb); 554 platform_device_put(musb);
565 555
566err2:
567 musb_put_id(&pdev->dev, musbid);
568
569err1: 556err1:
570 kfree(glue); 557 kfree(glue);
571 558
@@ -573,13 +560,11 @@ err0:
573 return ret; 560 return ret;
574} 561}
575 562
576static int __devexit am35x_remove(struct platform_device *pdev) 563static int am35x_remove(struct platform_device *pdev)
577{ 564{
578 struct am35x_glue *glue = platform_get_drvdata(pdev); 565 struct am35x_glue *glue = platform_get_drvdata(pdev);
579 566
580 musb_put_id(&pdev->dev, glue->musb->id); 567 platform_device_unregister(glue->musb);
581 platform_device_del(glue->musb);
582 platform_device_put(glue->musb);
583 clk_disable(glue->clk); 568 clk_disable(glue->clk);
584 clk_disable(glue->phy_clk); 569 clk_disable(glue->phy_clk);
585 clk_put(glue->clk); 570 clk_put(glue->clk);
@@ -644,7 +629,7 @@ static struct dev_pm_ops am35x_pm_ops = {
644 629
645static struct platform_driver am35x_driver = { 630static struct platform_driver am35x_driver = {
646 .probe = am35x_probe, 631 .probe = am35x_probe,
647 .remove = __devexit_p(am35x_remove), 632 .remove = am35x_remove,
648 .driver = { 633 .driver = {
649 .name = "musb-am35x", 634 .name = "musb-am35x",
650 .pm = DEV_PM_OPS, 635 .pm = DEV_PM_OPS,
@@ -654,15 +639,4 @@ static struct platform_driver am35x_driver = {
654MODULE_DESCRIPTION("AM35x MUSB Glue Layer"); 639MODULE_DESCRIPTION("AM35x MUSB Glue Layer");
655MODULE_AUTHOR("Ajay Kumar Gupta <ajay.gupta@ti.com>"); 640MODULE_AUTHOR("Ajay Kumar Gupta <ajay.gupta@ti.com>");
656MODULE_LICENSE("GPL v2"); 641MODULE_LICENSE("GPL v2");
657 642module_platform_driver(am35x_driver);
658static int __init am35x_init(void)
659{
660 return platform_driver_register(&am35x_driver);
661}
662module_init(am35x_init);
663
664static void __exit am35x_exit(void)
665{
666 platform_driver_unregister(&am35x_driver);
667}
668module_exit(am35x_exit);
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index e8cff9bb9d23..14dab9f9b3d0 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -448,14 +448,13 @@ static const struct musb_platform_ops bfin_ops = {
448 448
449static u64 bfin_dmamask = DMA_BIT_MASK(32); 449static u64 bfin_dmamask = DMA_BIT_MASK(32);
450 450
451static int __devinit bfin_probe(struct platform_device *pdev) 451static int bfin_probe(struct platform_device *pdev)
452{ 452{
453 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; 453 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
454 struct platform_device *musb; 454 struct platform_device *musb;
455 struct bfin_glue *glue; 455 struct bfin_glue *glue;
456 456
457 int ret = -ENOMEM; 457 int ret = -ENOMEM;
458 int musbid;
459 458
460 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 459 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
461 if (!glue) { 460 if (!glue) {
@@ -463,21 +462,12 @@ static int __devinit bfin_probe(struct platform_device *pdev)
463 goto err0; 462 goto err0;
464 } 463 }
465 464
466 /* get the musb id */ 465 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
467 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
468 if (musbid < 0) {
469 dev_err(&pdev->dev, "failed to allocate musb id\n");
470 ret = -ENOMEM;
471 goto err1;
472 }
473
474 musb = platform_device_alloc("musb-hdrc", musbid);
475 if (!musb) { 466 if (!musb) {
476 dev_err(&pdev->dev, "failed to allocate musb device\n"); 467 dev_err(&pdev->dev, "failed to allocate musb device\n");
477 goto err2; 468 goto err1;
478 } 469 }
479 470
480 musb->id = musbid;
481 musb->dev.parent = &pdev->dev; 471 musb->dev.parent = &pdev->dev;
482 musb->dev.dma_mask = &bfin_dmamask; 472 musb->dev.dma_mask = &bfin_dmamask;
483 musb->dev.coherent_dma_mask = bfin_dmamask; 473 musb->dev.coherent_dma_mask = bfin_dmamask;
@@ -513,9 +503,6 @@ static int __devinit bfin_probe(struct platform_device *pdev)
513err3: 503err3:
514 platform_device_put(musb); 504 platform_device_put(musb);
515 505
516err2:
517 musb_put_id(&pdev->dev, musbid);
518
519err1: 506err1:
520 kfree(glue); 507 kfree(glue);
521 508
@@ -523,13 +510,11 @@ err0:
523 return ret; 510 return ret;
524} 511}
525 512
526static int __devexit bfin_remove(struct platform_device *pdev) 513static int bfin_remove(struct platform_device *pdev)
527{ 514{
528 struct bfin_glue *glue = platform_get_drvdata(pdev); 515 struct bfin_glue *glue = platform_get_drvdata(pdev);
529 516
530 musb_put_id(&pdev->dev, glue->musb->id); 517 platform_device_unregister(glue->musb);
531 platform_device_del(glue->musb);
532 platform_device_put(glue->musb);
533 kfree(glue); 518 kfree(glue);
534 519
535 return 0; 520 return 0;
@@ -585,15 +570,4 @@ static struct platform_driver bfin_driver = {
585MODULE_DESCRIPTION("Blackfin MUSB Glue Layer"); 570MODULE_DESCRIPTION("Blackfin MUSB Glue Layer");
586MODULE_AUTHOR("Bryan Wy <cooloney@kernel.org>"); 571MODULE_AUTHOR("Bryan Wy <cooloney@kernel.org>");
587MODULE_LICENSE("GPL v2"); 572MODULE_LICENSE("GPL v2");
588 573module_platform_driver(bfin_driver);
589static int __init bfin_init(void)
590{
591 return platform_driver_register(&bfin_driver);
592}
593module_init(bfin_init);
594
595static void __exit bfin_exit(void)
596{
597 platform_driver_unregister(&bfin_driver);
598}
599module_exit(bfin_exit);
diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
index e19da82b4782..0968dd7a859d 100644
--- a/drivers/usb/musb/cppi_dma.c
+++ b/drivers/usb/musb/cppi_dma.c
@@ -1314,10 +1314,10 @@ irqreturn_t cppi_interrupt(int irq, void *dev_id)
1314 1314
1315 return IRQ_HANDLED; 1315 return IRQ_HANDLED;
1316} 1316}
1317EXPORT_SYMBOL_GPL(cppi_interrupt);
1317 1318
1318/* Instantiate a software object representing a DMA controller. */ 1319/* Instantiate a software object representing a DMA controller. */
1319struct dma_controller *__devinit 1320struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *mregs)
1320dma_controller_create(struct musb *musb, void __iomem *mregs)
1321{ 1321{
1322 struct cppi *controller; 1322 struct cppi *controller;
1323 struct device *dev = musb->controller; 1323 struct device *dev = musb->controller;
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 8bc44b76eec2..97996af2646e 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -471,7 +471,7 @@ static const struct musb_platform_ops da8xx_ops = {
471 471
472static u64 da8xx_dmamask = DMA_BIT_MASK(32); 472static u64 da8xx_dmamask = DMA_BIT_MASK(32);
473 473
474static int __devinit da8xx_probe(struct platform_device *pdev) 474static int da8xx_probe(struct platform_device *pdev)
475{ 475{
476 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; 476 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
477 struct platform_device *musb; 477 struct platform_device *musb;
@@ -480,7 +480,6 @@ static int __devinit da8xx_probe(struct platform_device *pdev)
480 struct clk *clk; 480 struct clk *clk;
481 481
482 int ret = -ENOMEM; 482 int ret = -ENOMEM;
483 int musbid;
484 483
485 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 484 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
486 if (!glue) { 485 if (!glue) {
@@ -488,18 +487,10 @@ static int __devinit da8xx_probe(struct platform_device *pdev)
488 goto err0; 487 goto err0;
489 } 488 }
490 489
491 /* get the musb id */ 490 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
492 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
493 if (musbid < 0) {
494 dev_err(&pdev->dev, "failed to allocate musb id\n");
495 ret = -ENOMEM;
496 goto err1;
497 }
498
499 musb = platform_device_alloc("musb-hdrc", musbid);
500 if (!musb) { 491 if (!musb) {
501 dev_err(&pdev->dev, "failed to allocate musb device\n"); 492 dev_err(&pdev->dev, "failed to allocate musb device\n");
502 goto err2; 493 goto err1;
503 } 494 }
504 495
505 clk = clk_get(&pdev->dev, "usb20"); 496 clk = clk_get(&pdev->dev, "usb20");
@@ -515,7 +506,6 @@ static int __devinit da8xx_probe(struct platform_device *pdev)
515 goto err4; 506 goto err4;
516 } 507 }
517 508
518 musb->id = musbid;
519 musb->dev.parent = &pdev->dev; 509 musb->dev.parent = &pdev->dev;
520 musb->dev.dma_mask = &da8xx_dmamask; 510 musb->dev.dma_mask = &da8xx_dmamask;
521 musb->dev.coherent_dma_mask = da8xx_dmamask; 511 musb->dev.coherent_dma_mask = da8xx_dmamask;
@@ -558,9 +548,6 @@ err4:
558err3: 548err3:
559 platform_device_put(musb); 549 platform_device_put(musb);
560 550
561err2:
562 musb_put_id(&pdev->dev, musbid);
563
564err1: 551err1:
565 kfree(glue); 552 kfree(glue);
566 553
@@ -568,13 +555,11 @@ err0:
568 return ret; 555 return ret;
569} 556}
570 557
571static int __devexit da8xx_remove(struct platform_device *pdev) 558static int da8xx_remove(struct platform_device *pdev)
572{ 559{
573 struct da8xx_glue *glue = platform_get_drvdata(pdev); 560 struct da8xx_glue *glue = platform_get_drvdata(pdev);
574 561
575 musb_put_id(&pdev->dev, glue->musb->id); 562 platform_device_unregister(glue->musb);
576 platform_device_del(glue->musb);
577 platform_device_put(glue->musb);
578 clk_disable(glue->clk); 563 clk_disable(glue->clk);
579 clk_put(glue->clk); 564 clk_put(glue->clk);
580 kfree(glue); 565 kfree(glue);
@@ -584,7 +569,7 @@ static int __devexit da8xx_remove(struct platform_device *pdev)
584 569
585static struct platform_driver da8xx_driver = { 570static struct platform_driver da8xx_driver = {
586 .probe = da8xx_probe, 571 .probe = da8xx_probe,
587 .remove = __devexit_p(da8xx_remove), 572 .remove = da8xx_remove,
588 .driver = { 573 .driver = {
589 .name = "musb-da8xx", 574 .name = "musb-da8xx",
590 }, 575 },
@@ -593,15 +578,4 @@ static struct platform_driver da8xx_driver = {
593MODULE_DESCRIPTION("DA8xx/OMAP-L1x MUSB Glue Layer"); 578MODULE_DESCRIPTION("DA8xx/OMAP-L1x MUSB Glue Layer");
594MODULE_AUTHOR("Sergei Shtylyov <sshtylyov@ru.mvista.com>"); 579MODULE_AUTHOR("Sergei Shtylyov <sshtylyov@ru.mvista.com>");
595MODULE_LICENSE("GPL v2"); 580MODULE_LICENSE("GPL v2");
596 581module_platform_driver(da8xx_driver);
597static int __init da8xx_init(void)
598{
599 return platform_driver_register(&da8xx_driver);
600}
601module_init(da8xx_init);
602
603static void __exit da8xx_exit(void)
604{
605 platform_driver_unregister(&da8xx_driver);
606}
607module_exit(da8xx_exit);
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 606bfd00cde6..b1c01cad28b2 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -504,7 +504,7 @@ static const struct musb_platform_ops davinci_ops = {
504 504
505static u64 davinci_dmamask = DMA_BIT_MASK(32); 505static u64 davinci_dmamask = DMA_BIT_MASK(32);
506 506
507static int __devinit davinci_probe(struct platform_device *pdev) 507static int davinci_probe(struct platform_device *pdev)
508{ 508{
509 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; 509 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
510 struct platform_device *musb; 510 struct platform_device *musb;
@@ -512,7 +512,6 @@ static int __devinit davinci_probe(struct platform_device *pdev)
512 struct clk *clk; 512 struct clk *clk;
513 513
514 int ret = -ENOMEM; 514 int ret = -ENOMEM;
515 int musbid;
516 515
517 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 516 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
518 if (!glue) { 517 if (!glue) {
@@ -520,18 +519,10 @@ static int __devinit davinci_probe(struct platform_device *pdev)
520 goto err0; 519 goto err0;
521 } 520 }
522 521
523 /* get the musb id */ 522 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
524 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
525 if (musbid < 0) {
526 dev_err(&pdev->dev, "failed to allocate musb id\n");
527 ret = -ENOMEM;
528 goto err1;
529 }
530
531 musb = platform_device_alloc("musb-hdrc", musbid);
532 if (!musb) { 523 if (!musb) {
533 dev_err(&pdev->dev, "failed to allocate musb device\n"); 524 dev_err(&pdev->dev, "failed to allocate musb device\n");
534 goto err2; 525 goto err1;
535 } 526 }
536 527
537 clk = clk_get(&pdev->dev, "usb"); 528 clk = clk_get(&pdev->dev, "usb");
@@ -547,7 +538,6 @@ static int __devinit davinci_probe(struct platform_device *pdev)
547 goto err4; 538 goto err4;
548 } 539 }
549 540
550 musb->id = musbid;
551 musb->dev.parent = &pdev->dev; 541 musb->dev.parent = &pdev->dev;
552 musb->dev.dma_mask = &davinci_dmamask; 542 musb->dev.dma_mask = &davinci_dmamask;
553 musb->dev.coherent_dma_mask = davinci_dmamask; 543 musb->dev.coherent_dma_mask = davinci_dmamask;
@@ -590,9 +580,6 @@ err4:
590err3: 580err3:
591 platform_device_put(musb); 581 platform_device_put(musb);
592 582
593err2:
594 musb_put_id(&pdev->dev, musbid);
595
596err1: 583err1:
597 kfree(glue); 584 kfree(glue);
598 585
@@ -600,13 +587,11 @@ err0:
600 return ret; 587 return ret;
601} 588}
602 589
603static int __devexit davinci_remove(struct platform_device *pdev) 590static int davinci_remove(struct platform_device *pdev)
604{ 591{
605 struct davinci_glue *glue = platform_get_drvdata(pdev); 592 struct davinci_glue *glue = platform_get_drvdata(pdev);
606 593
607 musb_put_id(&pdev->dev, glue->musb->id); 594 platform_device_unregister(glue->musb);
608 platform_device_del(glue->musb);
609 platform_device_put(glue->musb);
610 clk_disable(glue->clk); 595 clk_disable(glue->clk);
611 clk_put(glue->clk); 596 clk_put(glue->clk);
612 kfree(glue); 597 kfree(glue);
@@ -616,7 +601,7 @@ static int __devexit davinci_remove(struct platform_device *pdev)
616 601
617static struct platform_driver davinci_driver = { 602static struct platform_driver davinci_driver = {
618 .probe = davinci_probe, 603 .probe = davinci_probe,
619 .remove = __devexit_p(davinci_remove), 604 .remove = davinci_remove,
620 .driver = { 605 .driver = {
621 .name = "musb-davinci", 606 .name = "musb-davinci",
622 }, 607 },
@@ -625,15 +610,4 @@ static struct platform_driver davinci_driver = {
625MODULE_DESCRIPTION("DaVinci MUSB Glue Layer"); 610MODULE_DESCRIPTION("DaVinci MUSB Glue Layer");
626MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); 611MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
627MODULE_LICENSE("GPL v2"); 612MODULE_LICENSE("GPL v2");
628 613module_platform_driver(davinci_driver);
629static int __init davinci_init(void)
630{
631 return platform_driver_register(&davinci_driver);
632}
633module_init(davinci_init);
634
635static void __exit davinci_exit(void)
636{
637 platform_driver_unregister(&davinci_driver);
638}
639module_exit(davinci_exit);
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index bb56a0e8b23b..57cc9c6eaa9f 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -116,7 +116,6 @@
116 116
117#define MUSB_DRIVER_NAME "musb-hdrc" 117#define MUSB_DRIVER_NAME "musb-hdrc"
118const char musb_driver_name[] = MUSB_DRIVER_NAME; 118const char musb_driver_name[] = MUSB_DRIVER_NAME;
119static DEFINE_IDA(musb_ida);
120 119
121MODULE_DESCRIPTION(DRIVER_INFO); 120MODULE_DESCRIPTION(DRIVER_INFO);
122MODULE_AUTHOR(DRIVER_AUTHOR); 121MODULE_AUTHOR(DRIVER_AUTHOR);
@@ -133,35 +132,6 @@ static inline struct musb *dev_to_musb(struct device *dev)
133 132
134/*-------------------------------------------------------------------------*/ 133/*-------------------------------------------------------------------------*/
135 134
136int musb_get_id(struct device *dev, gfp_t gfp_mask)
137{
138 int ret;
139 int id;
140
141 ret = ida_pre_get(&musb_ida, gfp_mask);
142 if (!ret) {
143 dev_err(dev, "failed to reserve resource for id\n");
144 return -ENOMEM;
145 }
146
147 ret = ida_get_new(&musb_ida, &id);
148 if (ret < 0) {
149 dev_err(dev, "failed to allocate a new id\n");
150 return ret;
151 }
152
153 return id;
154}
155EXPORT_SYMBOL_GPL(musb_get_id);
156
157void musb_put_id(struct device *dev, int id)
158{
159
160 dev_dbg(dev, "removing id %d\n", id);
161 ida_remove(&musb_ida, id);
162}
163EXPORT_SYMBOL_GPL(musb_put_id);
164
165#ifndef CONFIG_BLACKFIN 135#ifndef CONFIG_BLACKFIN
166static int musb_ulpi_read(struct usb_phy *phy, u32 offset) 136static int musb_ulpi_read(struct usb_phy *phy, u32 offset)
167{ 137{
@@ -467,12 +437,12 @@ void musb_hnp_stop(struct musb *musb)
467 */ 437 */
468 438
469static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, 439static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
470 u8 devctl, u8 power) 440 u8 devctl)
471{ 441{
472 struct usb_otg *otg = musb->xceiv->otg; 442 struct usb_otg *otg = musb->xceiv->otg;
473 irqreturn_t handled = IRQ_NONE; 443 irqreturn_t handled = IRQ_NONE;
474 444
475 dev_dbg(musb->controller, "<== Power=%02x, DevCtl=%02x, int_usb=0x%x\n", power, devctl, 445 dev_dbg(musb->controller, "<== DevCtl=%02x, int_usb=0x%x\n", devctl,
476 int_usb); 446 int_usb);
477 447
478 /* in host mode, the peripheral may issue remote wakeup. 448 /* in host mode, the peripheral may issue remote wakeup.
@@ -485,6 +455,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
485 455
486 if (devctl & MUSB_DEVCTL_HM) { 456 if (devctl & MUSB_DEVCTL_HM) {
487 void __iomem *mbase = musb->mregs; 457 void __iomem *mbase = musb->mregs;
458 u8 power;
488 459
489 switch (musb->xceiv->state) { 460 switch (musb->xceiv->state) {
490 case OTG_STATE_A_SUSPEND: 461 case OTG_STATE_A_SUSPEND:
@@ -492,6 +463,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
492 * will stop RESUME signaling 463 * will stop RESUME signaling
493 */ 464 */
494 465
466 power = musb_readb(musb->mregs, MUSB_POWER);
495 if (power & MUSB_POWER_SUSPENDM) { 467 if (power & MUSB_POWER_SUSPENDM) {
496 /* spurious */ 468 /* spurious */
497 musb->int_usb &= ~MUSB_INTR_SUSPEND; 469 musb->int_usb &= ~MUSB_INTR_SUSPEND;
@@ -655,8 +627,8 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
655 } 627 }
656 628
657 if (int_usb & MUSB_INTR_SUSPEND) { 629 if (int_usb & MUSB_INTR_SUSPEND) {
658 dev_dbg(musb->controller, "SUSPEND (%s) devctl %02x power %02x\n", 630 dev_dbg(musb->controller, "SUSPEND (%s) devctl %02x\n",
659 otg_state_string(musb->xceiv->state), devctl, power); 631 otg_state_string(musb->xceiv->state), devctl);
660 handled = IRQ_HANDLED; 632 handled = IRQ_HANDLED;
661 633
662 switch (musb->xceiv->state) { 634 switch (musb->xceiv->state) {
@@ -722,8 +694,10 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
722 if (is_peripheral_active(musb)) { 694 if (is_peripheral_active(musb)) {
723 /* REVISIT HNP; just force disconnect */ 695 /* REVISIT HNP; just force disconnect */
724 } 696 }
725 musb_writew(musb->mregs, MUSB_INTRTXE, musb->epmask); 697 musb->intrtxe = musb->epmask;
726 musb_writew(musb->mregs, MUSB_INTRRXE, musb->epmask & 0xfffe); 698 musb_writew(musb->mregs, MUSB_INTRTXE, musb->intrtxe);
699 musb->intrrxe = musb->epmask & 0xfffe;
700 musb_writew(musb->mregs, MUSB_INTRRXE, musb->intrrxe);
727 musb_writeb(musb->mregs, MUSB_INTRUSBE, 0xf7); 701 musb_writeb(musb->mregs, MUSB_INTRUSBE, 0xf7);
728 musb->port1_status &= ~(USB_PORT_STAT_LOW_SPEED 702 musb->port1_status &= ~(USB_PORT_STAT_LOW_SPEED
729 |USB_PORT_STAT_HIGH_SPEED 703 |USB_PORT_STAT_HIGH_SPEED
@@ -944,8 +918,10 @@ void musb_start(struct musb *musb)
944 dev_dbg(musb->controller, "<== devctl %02x\n", devctl); 918 dev_dbg(musb->controller, "<== devctl %02x\n", devctl);
945 919
946 /* Set INT enable registers, enable interrupts */ 920 /* Set INT enable registers, enable interrupts */
947 musb_writew(regs, MUSB_INTRTXE, musb->epmask); 921 musb->intrtxe = musb->epmask;
948 musb_writew(regs, MUSB_INTRRXE, musb->epmask & 0xfffe); 922 musb_writew(regs, MUSB_INTRTXE, musb->intrtxe);
923 musb->intrrxe = musb->epmask & 0xfffe;
924 musb_writew(regs, MUSB_INTRRXE, musb->intrrxe);
949 musb_writeb(regs, MUSB_INTRUSBE, 0xf7); 925 musb_writeb(regs, MUSB_INTRUSBE, 0xf7);
950 926
951 musb_writeb(regs, MUSB_TESTMODE, 0); 927 musb_writeb(regs, MUSB_TESTMODE, 0);
@@ -983,7 +959,9 @@ static void musb_generic_disable(struct musb *musb)
983 959
984 /* disable interrupts */ 960 /* disable interrupts */
985 musb_writeb(mbase, MUSB_INTRUSBE, 0); 961 musb_writeb(mbase, MUSB_INTRUSBE, 0);
962 musb->intrtxe = 0;
986 musb_writew(mbase, MUSB_INTRTXE, 0); 963 musb_writew(mbase, MUSB_INTRTXE, 0);
964 musb->intrrxe = 0;
987 musb_writew(mbase, MUSB_INTRRXE, 0); 965 musb_writew(mbase, MUSB_INTRRXE, 0);
988 966
989 /* off */ 967 /* off */
@@ -1062,12 +1040,12 @@ static void musb_shutdown(struct platform_device *pdev)
1062 || defined(CONFIG_USB_MUSB_AM35X_MODULE) \ 1040 || defined(CONFIG_USB_MUSB_AM35X_MODULE) \
1063 || defined(CONFIG_USB_MUSB_DSPS) \ 1041 || defined(CONFIG_USB_MUSB_DSPS) \
1064 || defined(CONFIG_USB_MUSB_DSPS_MODULE) 1042 || defined(CONFIG_USB_MUSB_DSPS_MODULE)
1065static ushort __devinitdata fifo_mode = 4; 1043static ushort fifo_mode = 4;
1066#elif defined(CONFIG_USB_MUSB_UX500) \ 1044#elif defined(CONFIG_USB_MUSB_UX500) \
1067 || defined(CONFIG_USB_MUSB_UX500_MODULE) 1045 || defined(CONFIG_USB_MUSB_UX500_MODULE)
1068static ushort __devinitdata fifo_mode = 5; 1046static ushort fifo_mode = 5;
1069#else 1047#else
1070static ushort __devinitdata fifo_mode = 2; 1048static ushort fifo_mode = 2;
1071#endif 1049#endif
1072 1050
1073/* "modprobe ... fifo_mode=1" etc */ 1051/* "modprobe ... fifo_mode=1" etc */
@@ -1080,7 +1058,7 @@ MODULE_PARM_DESC(fifo_mode, "initial endpoint configuration");
1080 */ 1058 */
1081 1059
1082/* mode 0 - fits in 2KB */ 1060/* mode 0 - fits in 2KB */
1083static struct musb_fifo_cfg __devinitdata mode_0_cfg[] = { 1061static struct musb_fifo_cfg mode_0_cfg[] = {
1084{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, 1062{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
1085{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, 1063{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
1086{ .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, }, 1064{ .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, },
@@ -1089,7 +1067,7 @@ static struct musb_fifo_cfg __devinitdata mode_0_cfg[] = {
1089}; 1067};
1090 1068
1091/* mode 1 - fits in 4KB */ 1069/* mode 1 - fits in 4KB */
1092static struct musb_fifo_cfg __devinitdata mode_1_cfg[] = { 1070static struct musb_fifo_cfg mode_1_cfg[] = {
1093{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, }, 1071{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, },
1094{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, }, 1072{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, },
1095{ .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, .mode = BUF_DOUBLE, }, 1073{ .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, .mode = BUF_DOUBLE, },
@@ -1098,7 +1076,7 @@ static struct musb_fifo_cfg __devinitdata mode_1_cfg[] = {
1098}; 1076};
1099 1077
1100/* mode 2 - fits in 4KB */ 1078/* mode 2 - fits in 4KB */
1101static struct musb_fifo_cfg __devinitdata mode_2_cfg[] = { 1079static struct musb_fifo_cfg mode_2_cfg[] = {
1102{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, 1080{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
1103{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, 1081{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
1104{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, 1082{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
@@ -1108,7 +1086,7 @@ static struct musb_fifo_cfg __devinitdata mode_2_cfg[] = {
1108}; 1086};
1109 1087
1110/* mode 3 - fits in 4KB */ 1088/* mode 3 - fits in 4KB */
1111static struct musb_fifo_cfg __devinitdata mode_3_cfg[] = { 1089static struct musb_fifo_cfg mode_3_cfg[] = {
1112{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, }, 1090{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, },
1113{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, }, 1091{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, },
1114{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, 1092{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
@@ -1118,7 +1096,7 @@ static struct musb_fifo_cfg __devinitdata mode_3_cfg[] = {
1118}; 1096};
1119 1097
1120/* mode 4 - fits in 16KB */ 1098/* mode 4 - fits in 16KB */
1121static struct musb_fifo_cfg __devinitdata mode_4_cfg[] = { 1099static struct musb_fifo_cfg mode_4_cfg[] = {
1122{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, 1100{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
1123{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, 1101{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
1124{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, 1102{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
@@ -1149,7 +1127,7 @@ static struct musb_fifo_cfg __devinitdata mode_4_cfg[] = {
1149}; 1127};
1150 1128
1151/* mode 5 - fits in 8KB */ 1129/* mode 5 - fits in 8KB */
1152static struct musb_fifo_cfg __devinitdata mode_5_cfg[] = { 1130static struct musb_fifo_cfg mode_5_cfg[] = {
1153{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, 1131{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
1154{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, 1132{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
1155{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, 1133{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
@@ -1185,7 +1163,7 @@ static struct musb_fifo_cfg __devinitdata mode_5_cfg[] = {
1185 * 1163 *
1186 * returns negative errno or offset for next fifo. 1164 * returns negative errno or offset for next fifo.
1187 */ 1165 */
1188static int __devinit 1166static int
1189fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep, 1167fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep,
1190 const struct musb_fifo_cfg *cfg, u16 offset) 1168 const struct musb_fifo_cfg *cfg, u16 offset)
1191{ 1169{
@@ -1256,11 +1234,11 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep,
1256 return offset + (maxpacket << ((c_size & MUSB_FIFOSZ_DPB) ? 1 : 0)); 1234 return offset + (maxpacket << ((c_size & MUSB_FIFOSZ_DPB) ? 1 : 0));
1257} 1235}
1258 1236
1259static struct musb_fifo_cfg __devinitdata ep0_cfg = { 1237static struct musb_fifo_cfg ep0_cfg = {
1260 .style = FIFO_RXTX, .maxpacket = 64, 1238 .style = FIFO_RXTX, .maxpacket = 64,
1261}; 1239};
1262 1240
1263static int __devinit ep_config_from_table(struct musb *musb) 1241static int ep_config_from_table(struct musb *musb)
1264{ 1242{
1265 const struct musb_fifo_cfg *cfg; 1243 const struct musb_fifo_cfg *cfg;
1266 unsigned i, n; 1244 unsigned i, n;
@@ -1351,7 +1329,7 @@ done:
1351 * ep_config_from_hw - when MUSB_C_DYNFIFO_DEF is false 1329 * ep_config_from_hw - when MUSB_C_DYNFIFO_DEF is false
1352 * @param musb the controller 1330 * @param musb the controller
1353 */ 1331 */
1354static int __devinit ep_config_from_hw(struct musb *musb) 1332static int ep_config_from_hw(struct musb *musb)
1355{ 1333{
1356 u8 epnum = 0; 1334 u8 epnum = 0;
1357 struct musb_hw_ep *hw_ep; 1335 struct musb_hw_ep *hw_ep;
@@ -1398,7 +1376,7 @@ enum { MUSB_CONTROLLER_MHDRC, MUSB_CONTROLLER_HDRC, };
1398/* Initialize MUSB (M)HDRC part of the USB hardware subsystem; 1376/* Initialize MUSB (M)HDRC part of the USB hardware subsystem;
1399 * configure endpoints, or take their config from silicon 1377 * configure endpoints, or take their config from silicon
1400 */ 1378 */
1401static int __devinit musb_core_init(u16 musb_type, struct musb *musb) 1379static int musb_core_init(u16 musb_type, struct musb *musb)
1402{ 1380{
1403 u8 reg; 1381 u8 reg;
1404 char *type; 1382 char *type;
@@ -1523,33 +1501,6 @@ static int __devinit musb_core_init(u16 musb_type, struct musb *musb)
1523 1501
1524/*-------------------------------------------------------------------------*/ 1502/*-------------------------------------------------------------------------*/
1525 1503
1526#if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_SOC_OMAP3430) || \
1527 defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_ARCH_U8500)
1528
1529static irqreturn_t generic_interrupt(int irq, void *__hci)
1530{
1531 unsigned long flags;
1532 irqreturn_t retval = IRQ_NONE;
1533 struct musb *musb = __hci;
1534
1535 spin_lock_irqsave(&musb->lock, flags);
1536
1537 musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB);
1538 musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX);
1539 musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX);
1540
1541 if (musb->int_usb || musb->int_tx || musb->int_rx)
1542 retval = musb_interrupt(musb);
1543
1544 spin_unlock_irqrestore(&musb->lock, flags);
1545
1546 return retval;
1547}
1548
1549#else
1550#define generic_interrupt NULL
1551#endif
1552
1553/* 1504/*
1554 * handle all the irqs defined by the HDRC core. for now we expect: other 1505 * handle all the irqs defined by the HDRC core. for now we expect: other
1555 * irq sources (phy, dma, etc) will be handled first, musb->int_* values 1506 * irq sources (phy, dma, etc) will be handled first, musb->int_* values
@@ -1560,12 +1511,11 @@ static irqreturn_t generic_interrupt(int irq, void *__hci)
1560irqreturn_t musb_interrupt(struct musb *musb) 1511irqreturn_t musb_interrupt(struct musb *musb)
1561{ 1512{
1562 irqreturn_t retval = IRQ_NONE; 1513 irqreturn_t retval = IRQ_NONE;
1563 u8 devctl, power; 1514 u8 devctl;
1564 int ep_num; 1515 int ep_num;
1565 u32 reg; 1516 u32 reg;
1566 1517
1567 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); 1518 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
1568 power = musb_readb(musb->mregs, MUSB_POWER);
1569 1519
1570 dev_dbg(musb->controller, "** IRQ %s usb%04x tx%04x rx%04x\n", 1520 dev_dbg(musb->controller, "** IRQ %s usb%04x tx%04x rx%04x\n",
1571 (devctl & MUSB_DEVCTL_HM) ? "host" : "peripheral", 1521 (devctl & MUSB_DEVCTL_HM) ? "host" : "peripheral",
@@ -1576,7 +1526,7 @@ irqreturn_t musb_interrupt(struct musb *musb)
1576 */ 1526 */
1577 if (musb->int_usb) 1527 if (musb->int_usb)
1578 retval |= musb_stage0_irq(musb, musb->int_usb, 1528 retval |= musb_stage0_irq(musb, musb->int_usb,
1579 devctl, power); 1529 devctl);
1580 1530
1581 /* "stage 1" is handling endpoint irqs */ 1531 /* "stage 1" is handling endpoint irqs */
1582 1532
@@ -1628,7 +1578,7 @@ irqreturn_t musb_interrupt(struct musb *musb)
1628EXPORT_SYMBOL_GPL(musb_interrupt); 1578EXPORT_SYMBOL_GPL(musb_interrupt);
1629 1579
1630#ifndef CONFIG_MUSB_PIO_ONLY 1580#ifndef CONFIG_MUSB_PIO_ONLY
1631static bool __devinitdata use_dma = 1; 1581static bool use_dma = 1;
1632 1582
1633/* "modprobe ... use_dma=0" etc */ 1583/* "modprobe ... use_dma=0" etc */
1634module_param(use_dma, bool, 0); 1584module_param(use_dma, bool, 0);
@@ -1809,8 +1759,7 @@ static void musb_irq_work(struct work_struct *data)
1809 * Init support 1759 * Init support
1810 */ 1760 */
1811 1761
1812static struct musb *__devinit 1762static struct musb *allocate_instance(struct device *dev,
1813allocate_instance(struct device *dev,
1814 struct musb_hdrc_config *config, void __iomem *mbase) 1763 struct musb_hdrc_config *config, void __iomem *mbase)
1815{ 1764{
1816 struct musb *musb; 1765 struct musb *musb;
@@ -1885,7 +1834,7 @@ static void musb_free(struct musb *musb)
1885 * @ctrl: virtual address of controller registers, 1834 * @ctrl: virtual address of controller registers,
1886 * not yet corrected for platform-specific offsets 1835 * not yet corrected for platform-specific offsets
1887 */ 1836 */
1888static int __devinit 1837static int
1889musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) 1838musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
1890{ 1839{
1891 int status; 1840 int status;
@@ -1919,7 +1868,8 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
1919 musb->ops = plat->platform_ops; 1868 musb->ops = plat->platform_ops;
1920 1869
1921 /* The musb_platform_init() call: 1870 /* The musb_platform_init() call:
1922 * - adjusts musb->mregs and musb->isr if needed, 1871 * - adjusts musb->mregs
1872 * - sets the musb->isr
1923 * - may initialize an integrated tranceiver 1873 * - may initialize an integrated tranceiver
1924 * - initializes musb->xceiv, usually by otg_get_phy() 1874 * - initializes musb->xceiv, usually by otg_get_phy()
1925 * - stops powering VBUS 1875 * - stops powering VBUS
@@ -1929,7 +1879,6 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
1929 * external/discrete ones in various flavors (twl4030 family, 1879 * external/discrete ones in various flavors (twl4030 family,
1930 * isp1504, non-OTG, etc) mostly hooking up through ULPI. 1880 * isp1504, non-OTG, etc) mostly hooking up through ULPI.
1931 */ 1881 */
1932 musb->isr = generic_interrupt;
1933 status = musb_platform_init(musb); 1882 status = musb_platform_init(musb);
1934 if (status < 0) 1883 if (status < 0)
1935 goto fail1; 1884 goto fail1;
@@ -2060,7 +2009,7 @@ fail0:
2060/* all implementations (PCI bridge to FPGA, VLYNQ, etc) should just 2009/* all implementations (PCI bridge to FPGA, VLYNQ, etc) should just
2061 * bridge to a platform device; this driver then suffices. 2010 * bridge to a platform device; this driver then suffices.
2062 */ 2011 */
2063static int __devinit musb_probe(struct platform_device *pdev) 2012static int musb_probe(struct platform_device *pdev)
2064{ 2013{
2065 struct device *dev = &pdev->dev; 2014 struct device *dev = &pdev->dev;
2066 int irq = platform_get_irq_byname(pdev, "mc"); 2015 int irq = platform_get_irq_byname(pdev, "mc");
@@ -2085,7 +2034,7 @@ static int __devinit musb_probe(struct platform_device *pdev)
2085 return status; 2034 return status;
2086} 2035}
2087 2036
2088static int __devexit musb_remove(struct platform_device *pdev) 2037static int musb_remove(struct platform_device *pdev)
2089{ 2038{
2090 struct device *dev = &pdev->dev; 2039 struct device *dev = &pdev->dev;
2091 struct musb *musb = dev_to_musb(dev); 2040 struct musb *musb = dev_to_musb(dev);
@@ -2120,8 +2069,6 @@ static void musb_save_context(struct musb *musb)
2120 musb->context.testmode = musb_readb(musb_base, MUSB_TESTMODE); 2069 musb->context.testmode = musb_readb(musb_base, MUSB_TESTMODE);
2121 musb->context.busctl = musb_read_ulpi_buscontrol(musb->mregs); 2070 musb->context.busctl = musb_read_ulpi_buscontrol(musb->mregs);
2122 musb->context.power = musb_readb(musb_base, MUSB_POWER); 2071 musb->context.power = musb_readb(musb_base, MUSB_POWER);
2123 musb->context.intrtxe = musb_readw(musb_base, MUSB_INTRTXE);
2124 musb->context.intrrxe = musb_readw(musb_base, MUSB_INTRRXE);
2125 musb->context.intrusbe = musb_readb(musb_base, MUSB_INTRUSBE); 2072 musb->context.intrusbe = musb_readb(musb_base, MUSB_INTRUSBE);
2126 musb->context.index = musb_readb(musb_base, MUSB_INDEX); 2073 musb->context.index = musb_readb(musb_base, MUSB_INDEX);
2127 musb->context.devctl = musb_readb(musb_base, MUSB_DEVCTL); 2074 musb->context.devctl = musb_readb(musb_base, MUSB_DEVCTL);
@@ -2194,8 +2141,8 @@ static void musb_restore_context(struct musb *musb)
2194 musb_writeb(musb_base, MUSB_TESTMODE, musb->context.testmode); 2141 musb_writeb(musb_base, MUSB_TESTMODE, musb->context.testmode);
2195 musb_write_ulpi_buscontrol(musb->mregs, musb->context.busctl); 2142 musb_write_ulpi_buscontrol(musb->mregs, musb->context.busctl);
2196 musb_writeb(musb_base, MUSB_POWER, musb->context.power); 2143 musb_writeb(musb_base, MUSB_POWER, musb->context.power);
2197 musb_writew(musb_base, MUSB_INTRTXE, musb->context.intrtxe); 2144 musb_writew(musb_base, MUSB_INTRTXE, musb->intrtxe);
2198 musb_writew(musb_base, MUSB_INTRRXE, musb->context.intrrxe); 2145 musb_writew(musb_base, MUSB_INTRRXE, musb->intrrxe);
2199 musb_writeb(musb_base, MUSB_INTRUSBE, musb->context.intrusbe); 2146 musb_writeb(musb_base, MUSB_INTRUSBE, musb->context.intrusbe);
2200 musb_writeb(musb_base, MUSB_DEVCTL, musb->context.devctl); 2147 musb_writeb(musb_base, MUSB_DEVCTL, musb->context.devctl);
2201 2148
@@ -2340,7 +2287,7 @@ static struct platform_driver musb_driver = {
2340 .pm = MUSB_DEV_PM_OPS, 2287 .pm = MUSB_DEV_PM_OPS,
2341 }, 2288 },
2342 .probe = musb_probe, 2289 .probe = musb_probe,
2343 .remove = __devexit_p(musb_remove), 2290 .remove = musb_remove,
2344 .shutdown = musb_shutdown, 2291 .shutdown = musb_shutdown,
2345}; 2292};
2346 2293
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index c158aacd6de8..7fb4819a6f11 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -288,7 +288,6 @@ struct musb_csr_regs {
288struct musb_context_registers { 288struct musb_context_registers {
289 289
290 u8 power; 290 u8 power;
291 u16 intrtxe, intrrxe;
292 u8 intrusbe; 291 u8 intrusbe;
293 u16 frame; 292 u16 frame;
294 u8 index, testmode; 293 u8 index, testmode;
@@ -313,6 +312,8 @@ struct musb {
313 struct work_struct irq_work; 312 struct work_struct irq_work;
314 u16 hwvers; 313 u16 hwvers;
315 314
315 u16 intrrxe;
316 u16 intrtxe;
316/* this hub status bit is reserved by USB 2.0 and not seen by usbcore */ 317/* this hub status bit is reserved by USB 2.0 and not seen by usbcore */
317#define MUSB_PORT_STAT_RESUME (1 << 31) 318#define MUSB_PORT_STAT_RESUME (1 << 31)
318 319
@@ -521,8 +522,6 @@ extern const char musb_driver_name[];
521 522
522extern void musb_start(struct musb *musb); 523extern void musb_start(struct musb *musb);
523extern void musb_stop(struct musb *musb); 524extern void musb_stop(struct musb *musb);
524extern int musb_get_id(struct device *dev, gfp_t gfp_mask);
525extern void musb_put_id(struct device *dev, int id);
526 525
527extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src); 526extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src);
528extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst); 527extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst);
diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c
index 1d6e8af94c06..4c216790e86b 100644
--- a/drivers/usb/musb/musb_debugfs.c
+++ b/drivers/usb/musb/musb_debugfs.c
@@ -233,7 +233,7 @@ static const struct file_operations musb_test_mode_fops = {
233 .release = single_release, 233 .release = single_release,
234}; 234};
235 235
236int __devinit musb_init_debugfs(struct musb *musb) 236int musb_init_debugfs(struct musb *musb)
237{ 237{
238 struct dentry *root; 238 struct dentry *root;
239 struct dentry *file; 239 struct dentry *file;
diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h
index 24d39210d4ab..1b6b827b769f 100644
--- a/drivers/usb/musb/musb_dma.h
+++ b/drivers/usb/musb/musb_dma.h
@@ -178,8 +178,7 @@ struct dma_controller {
178extern void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit); 178extern void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit);
179 179
180 180
181extern struct dma_controller *__devinit 181extern struct dma_controller *dma_controller_create(struct musb *, void __iomem *);
182dma_controller_create(struct musb *, void __iomem *);
183 182
184extern void dma_controller_destroy(struct dma_controller *); 183extern void dma_controller_destroy(struct dma_controller *);
185 184
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index ff5f112053d2..9a975aa0dee2 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -124,8 +124,44 @@ struct dsps_glue {
124 const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */ 124 const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */
125 struct timer_list timer[2]; /* otg_workaround timer */ 125 struct timer_list timer[2]; /* otg_workaround timer */
126 unsigned long last_timer[2]; /* last timer data for each instance */ 126 unsigned long last_timer[2]; /* last timer data for each instance */
127 u32 __iomem *usb_ctrl[2];
127}; 128};
128 129
130#define DSPS_AM33XX_CONTROL_MODULE_PHYS_0 0x44e10620
131#define DSPS_AM33XX_CONTROL_MODULE_PHYS_1 0x44e10628
132
133static const resource_size_t dsps_control_module_phys[] = {
134 DSPS_AM33XX_CONTROL_MODULE_PHYS_0,
135 DSPS_AM33XX_CONTROL_MODULE_PHYS_1,
136};
137
138/**
139 * musb_dsps_phy_control - phy on/off
140 * @glue: struct dsps_glue *
141 * @id: musb instance
142 * @on: flag for phy to be switched on or off
143 *
144 * This is to enable the PHY using usb_ctrl register in system control
145 * module space.
146 *
147 * XXX: This function will be removed once we have a seperate driver for
148 * control module
149 */
150static void musb_dsps_phy_control(struct dsps_glue *glue, u8 id, u8 on)
151{
152 u32 usbphycfg;
153
154 usbphycfg = readl(glue->usb_ctrl[id]);
155
156 if (on) {
157 usbphycfg &= ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN);
158 usbphycfg |= USBPHY_OTGVDET_EN | USBPHY_OTGSESSEND_EN;
159 } else {
160 usbphycfg |= USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN;
161 }
162
163 writel(usbphycfg, glue->usb_ctrl[id]);
164}
129/** 165/**
130 * dsps_musb_enable - enable interrupts 166 * dsps_musb_enable - enable interrupts
131 */ 167 */
@@ -296,7 +332,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
296 * Also, DRVVBUS pulses for SRP (but not at 5V) ... 332 * Also, DRVVBUS pulses for SRP (but not at 5V) ...
297 */ 333 */
298 if (usbintr & MUSB_INTR_BABBLE) 334 if (usbintr & MUSB_INTR_BABBLE)
299 pr_info("CAUTION: musb: Babble Interrupt Occured\n"); 335 pr_info("CAUTION: musb: Babble Interrupt Occurred\n");
300 336
301 if (usbintr & ((1 << wrp->drvvbus) << wrp->usb_shift)) { 337 if (usbintr & ((1 << wrp->drvvbus) << wrp->usb_shift)) {
302 int drvvbus = dsps_readl(reg_base, wrp->status); 338 int drvvbus = dsps_readl(reg_base, wrp->status);
@@ -365,11 +401,9 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
365static int dsps_musb_init(struct musb *musb) 401static int dsps_musb_init(struct musb *musb)
366{ 402{
367 struct device *dev = musb->controller; 403 struct device *dev = musb->controller;
368 struct musb_hdrc_platform_data *plat = dev->platform_data;
369 struct platform_device *pdev = to_platform_device(dev); 404 struct platform_device *pdev = to_platform_device(dev);
370 struct dsps_glue *glue = dev_get_drvdata(dev->parent); 405 struct dsps_glue *glue = dev_get_drvdata(dev->parent);
371 const struct dsps_musb_wrapper *wrp = glue->wrp; 406 const struct dsps_musb_wrapper *wrp = glue->wrp;
372 struct omap_musb_board_data *data = plat->board_data;
373 void __iomem *reg_base = musb->ctrl_base; 407 void __iomem *reg_base = musb->ctrl_base;
374 u32 rev, val; 408 u32 rev, val;
375 int status; 409 int status;
@@ -377,7 +411,8 @@ static int dsps_musb_init(struct musb *musb)
377 /* mentor core register starts at offset of 0x400 from musb base */ 411 /* mentor core register starts at offset of 0x400 from musb base */
378 musb->mregs += wrp->musb_core_offset; 412 musb->mregs += wrp->musb_core_offset;
379 413
380 /* Get the NOP PHY */ 414 /* NOP driver needs change if supporting dual instance */
415 usb_nop_xceiv_register();
381 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); 416 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
382 if (IS_ERR_OR_NULL(musb->xceiv)) 417 if (IS_ERR_OR_NULL(musb->xceiv))
383 return -ENODEV; 418 return -ENODEV;
@@ -395,8 +430,7 @@ static int dsps_musb_init(struct musb *musb)
395 dsps_writel(reg_base, wrp->control, (1 << wrp->reset)); 430 dsps_writel(reg_base, wrp->control, (1 << wrp->reset));
396 431
397 /* Start the on-chip PHY and its PLL. */ 432 /* Start the on-chip PHY and its PLL. */
398 if (data->set_phy_power) 433 musb_dsps_phy_control(glue, pdev->id, 1);
399 data->set_phy_power(1);
400 434
401 musb->isr = dsps_interrupt; 435 musb->isr = dsps_interrupt;
402 436
@@ -418,16 +452,13 @@ err0:
418static int dsps_musb_exit(struct musb *musb) 452static int dsps_musb_exit(struct musb *musb)
419{ 453{
420 struct device *dev = musb->controller; 454 struct device *dev = musb->controller;
421 struct musb_hdrc_platform_data *plat = dev->platform_data;
422 struct omap_musb_board_data *data = plat->board_data;
423 struct platform_device *pdev = to_platform_device(dev); 455 struct platform_device *pdev = to_platform_device(dev);
424 struct dsps_glue *glue = dev_get_drvdata(dev->parent); 456 struct dsps_glue *glue = dev_get_drvdata(dev->parent);
425 457
426 del_timer_sync(&glue->timer[pdev->id]); 458 del_timer_sync(&glue->timer[pdev->id]);
427 459
428 /* Shutdown the on-chip PHY and its PLL. */ 460 /* Shutdown the on-chip PHY and its PLL. */
429 if (data->set_phy_power) 461 musb_dsps_phy_control(glue, pdev->id, 0);
430 data->set_phy_power(0);
431 462
432 /* NOP driver needs change if supporting dual instance */ 463 /* NOP driver needs change if supporting dual instance */
433 usb_put_phy(musb->xceiv); 464 usb_put_phy(musb->xceiv);
@@ -448,7 +479,7 @@ static struct musb_platform_ops dsps_ops = {
448 479
449static u64 musb_dmamask = DMA_BIT_MASK(32); 480static u64 musb_dmamask = DMA_BIT_MASK(32);
450 481
451static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id) 482static int dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
452{ 483{
453 struct device *dev = glue->dev; 484 struct device *dev = glue->dev;
454 struct platform_device *pdev = to_platform_device(dev); 485 struct platform_device *pdev = to_platform_device(dev);
@@ -459,24 +490,33 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
459 struct resource *res; 490 struct resource *res;
460 struct resource resources[2]; 491 struct resource resources[2];
461 char res_name[11]; 492 char res_name[11];
462 int ret, musbid; 493 int ret;
463 494
464 /* get memory resource */ 495 resources[0].start = dsps_control_module_phys[id];
465 snprintf(res_name, sizeof(res_name), "musb%d", id); 496 resources[0].end = resources[0].start + SZ_4 - 1;
466 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, res_name); 497 resources[0].flags = IORESOURCE_MEM;
498
499 glue->usb_ctrl[id] = devm_request_and_ioremap(&pdev->dev, resources);
500 if (glue->usb_ctrl[id] == NULL) {
501 dev_err(dev, "Failed to obtain usb_ctrl%d memory\n", id);
502 ret = -ENODEV;
503 goto err0;
504 }
505
506 /* first resource is for usbss, so start index from 1 */
507 res = platform_get_resource(pdev, IORESOURCE_MEM, id + 1);
467 if (!res) { 508 if (!res) {
468 dev_err(dev, "%s get mem resource failed\n", res_name); 509 dev_err(dev, "failed to get memory for instance %d\n", id);
469 ret = -ENODEV; 510 ret = -ENODEV;
470 goto err0; 511 goto err0;
471 } 512 }
472 res->parent = NULL; 513 res->parent = NULL;
473 resources[0] = *res; 514 resources[0] = *res;
474 515
475 /* get irq resource */ 516 /* first resource is for usbss, so start index from 1 */
476 snprintf(res_name, sizeof(res_name), "musb%d-irq", id); 517 res = platform_get_resource(pdev, IORESOURCE_IRQ, id + 1);
477 res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, res_name);
478 if (!res) { 518 if (!res) {
479 dev_err(dev, "%s get irq resource failed\n", res_name); 519 dev_err(dev, "failed to get irq for instance %d\n", id);
480 ret = -ENODEV; 520 ret = -ENODEV;
481 goto err0; 521 goto err0;
482 } 522 }
@@ -484,22 +524,14 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
484 resources[1] = *res; 524 resources[1] = *res;
485 resources[1].name = "mc"; 525 resources[1].name = "mc";
486 526
487 /* get the musb id */
488 musbid = musb_get_id(dev, GFP_KERNEL);
489 if (musbid < 0) {
490 dev_err(dev, "failed to allocate musb id\n");
491 ret = -ENOMEM;
492 goto err0;
493 }
494 /* allocate the child platform device */ 527 /* allocate the child platform device */
495 musb = platform_device_alloc("musb-hdrc", musbid); 528 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
496 if (!musb) { 529 if (!musb) {
497 dev_err(dev, "failed to allocate musb device\n"); 530 dev_err(dev, "failed to allocate musb device\n");
498 ret = -ENOMEM; 531 ret = -ENOMEM;
499 goto err1; 532 goto err0;
500 } 533 }
501 534
502 musb->id = musbid;
503 musb->dev.parent = dev; 535 musb->dev.parent = dev;
504 musb->dev.dma_mask = &musb_dmamask; 536 musb->dev.dma_mask = &musb_dmamask;
505 musb->dev.coherent_dma_mask = musb_dmamask; 537 musb->dev.coherent_dma_mask = musb_dmamask;
@@ -556,20 +588,11 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
556 588
557err2: 589err2:
558 platform_device_put(musb); 590 platform_device_put(musb);
559err1:
560 musb_put_id(dev, musbid);
561err0: 591err0:
562 return ret; 592 return ret;
563} 593}
564 594
565static void dsps_delete_musb_pdev(struct dsps_glue *glue, u8 id) 595static int dsps_probe(struct platform_device *pdev)
566{
567 musb_put_id(glue->dev, glue->musb[id]->id);
568 platform_device_del(glue->musb[id]);
569 platform_device_put(glue->musb[id]);
570}
571
572static int __devinit dsps_probe(struct platform_device *pdev)
573{ 596{
574 struct device_node *np = pdev->dev.of_node; 597 struct device_node *np = pdev->dev.of_node;
575 const struct of_device_id *match; 598 const struct of_device_id *match;
@@ -628,7 +651,7 @@ static int __devinit dsps_probe(struct platform_device *pdev)
628 dev_err(&pdev->dev, "failed to create child pdev\n"); 651 dev_err(&pdev->dev, "failed to create child pdev\n");
629 /* release resources of previously created instances */ 652 /* release resources of previously created instances */
630 for (i--; i >= 0 ; i--) 653 for (i--; i >= 0 ; i--)
631 dsps_delete_musb_pdev(glue, i); 654 platform_device_unregister(glue->musb[i]);
632 goto err3; 655 goto err3;
633 } 656 }
634 } 657 }
@@ -645,7 +668,7 @@ err1:
645err0: 668err0:
646 return ret; 669 return ret;
647} 670}
648static int __devexit dsps_remove(struct platform_device *pdev) 671static int dsps_remove(struct platform_device *pdev)
649{ 672{
650 struct dsps_glue *glue = platform_get_drvdata(pdev); 673 struct dsps_glue *glue = platform_get_drvdata(pdev);
651 const struct dsps_musb_wrapper *wrp = glue->wrp; 674 const struct dsps_musb_wrapper *wrp = glue->wrp;
@@ -653,7 +676,7 @@ static int __devexit dsps_remove(struct platform_device *pdev)
653 676
654 /* delete the child platform device */ 677 /* delete the child platform device */
655 for (i = 0; i < wrp->instances ; i++) 678 for (i = 0; i < wrp->instances ; i++)
656 dsps_delete_musb_pdev(glue, i); 679 platform_device_unregister(glue->musb[i]);
657 680
658 /* disable usbss clocks */ 681 /* disable usbss clocks */
659 pm_runtime_put(&pdev->dev); 682 pm_runtime_put(&pdev->dev);
@@ -666,24 +689,26 @@ static int __devexit dsps_remove(struct platform_device *pdev)
666#ifdef CONFIG_PM_SLEEP 689#ifdef CONFIG_PM_SLEEP
667static int dsps_suspend(struct device *dev) 690static int dsps_suspend(struct device *dev)
668{ 691{
669 struct musb_hdrc_platform_data *plat = dev->platform_data; 692 struct platform_device *pdev = to_platform_device(dev->parent);
670 struct omap_musb_board_data *data = plat->board_data; 693 struct dsps_glue *glue = platform_get_drvdata(pdev);
694 const struct dsps_musb_wrapper *wrp = glue->wrp;
695 int i;
671 696
672 /* Shutdown the on-chip PHY and its PLL. */ 697 for (i = 0; i < wrp->instances; i++)
673 if (data->set_phy_power) 698 musb_dsps_phy_control(glue, i, 0);
674 data->set_phy_power(0);
675 699
676 return 0; 700 return 0;
677} 701}
678 702
679static int dsps_resume(struct device *dev) 703static int dsps_resume(struct device *dev)
680{ 704{
681 struct musb_hdrc_platform_data *plat = dev->platform_data; 705 struct platform_device *pdev = to_platform_device(dev->parent);
682 struct omap_musb_board_data *data = plat->board_data; 706 struct dsps_glue *glue = platform_get_drvdata(pdev);
707 const struct dsps_musb_wrapper *wrp = glue->wrp;
708 int i;
683 709
684 /* Start the on-chip PHY and its PLL. */ 710 for (i = 0; i < wrp->instances; i++)
685 if (data->set_phy_power) 711 musb_dsps_phy_control(glue, i, 1);
686 data->set_phy_power(1);
687 712
688 return 0; 713 return 0;
689} 714}
@@ -691,7 +716,7 @@ static int dsps_resume(struct device *dev)
691 716
692static SIMPLE_DEV_PM_OPS(dsps_pm_ops, dsps_suspend, dsps_resume); 717static SIMPLE_DEV_PM_OPS(dsps_pm_ops, dsps_suspend, dsps_resume);
693 718
694static const struct dsps_musb_wrapper ti81xx_driver_data __devinitconst = { 719static const struct dsps_musb_wrapper ti81xx_driver_data = {
695 .revision = 0x00, 720 .revision = 0x00,
696 .control = 0x14, 721 .control = 0x14,
697 .status = 0x18, 722 .status = 0x18,
@@ -719,10 +744,10 @@ static const struct dsps_musb_wrapper ti81xx_driver_data __devinitconst = {
719 .rxep_bitmap = (0xfffe << 16), 744 .rxep_bitmap = (0xfffe << 16),
720 .musb_core_offset = 0x400, 745 .musb_core_offset = 0x400,
721 .poll_seconds = 2, 746 .poll_seconds = 2,
722 .instances = 2, 747 .instances = 1,
723}; 748};
724 749
725static const struct platform_device_id musb_dsps_id_table[] __devinitconst = { 750static const struct platform_device_id musb_dsps_id_table[] = {
726 { 751 {
727 .name = "musb-ti81xx", 752 .name = "musb-ti81xx",
728 .driver_data = (kernel_ulong_t) &ti81xx_driver_data, 753 .driver_data = (kernel_ulong_t) &ti81xx_driver_data,
@@ -732,7 +757,7 @@ static const struct platform_device_id musb_dsps_id_table[] __devinitconst = {
732MODULE_DEVICE_TABLE(platform, musb_dsps_id_table); 757MODULE_DEVICE_TABLE(platform, musb_dsps_id_table);
733 758
734#ifdef CONFIG_OF 759#ifdef CONFIG_OF
735static const struct of_device_id musb_dsps_of_match[] __devinitconst = { 760static const struct of_device_id musb_dsps_of_match[] = {
736 { .compatible = "ti,musb-am33xx", 761 { .compatible = "ti,musb-am33xx",
737 .data = (void *) &ti81xx_driver_data, }, 762 .data = (void *) &ti81xx_driver_data, },
738 { }, 763 { },
@@ -742,7 +767,7 @@ MODULE_DEVICE_TABLE(of, musb_dsps_of_match);
742 767
743static struct platform_driver dsps_usbss_driver = { 768static struct platform_driver dsps_usbss_driver = {
744 .probe = dsps_probe, 769 .probe = dsps_probe,
745 .remove = __devexit_p(dsps_remove), 770 .remove = dsps_remove,
746 .driver = { 771 .driver = {
747 .name = "musb-dsps", 772 .name = "musb-dsps",
748 .pm = &dsps_pm_ops, 773 .pm = &dsps_pm_ops,
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index b6b84dacc791..876787438c2f 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1090,7 +1090,6 @@ static int musb_gadget_enable(struct usb_ep *ep,
1090 */ 1090 */
1091 musb_ep_select(mbase, epnum); 1091 musb_ep_select(mbase, epnum);
1092 if (usb_endpoint_dir_in(desc)) { 1092 if (usb_endpoint_dir_in(desc)) {
1093 u16 int_txe = musb_readw(mbase, MUSB_INTRTXE);
1094 1093
1095 if (hw_ep->is_shared_fifo) 1094 if (hw_ep->is_shared_fifo)
1096 musb_ep->is_in = 1; 1095 musb_ep->is_in = 1;
@@ -1102,8 +1101,8 @@ static int musb_gadget_enable(struct usb_ep *ep,
1102 goto fail; 1101 goto fail;
1103 } 1102 }
1104 1103
1105 int_txe |= (1 << epnum); 1104 musb->intrtxe |= (1 << epnum);
1106 musb_writew(mbase, MUSB_INTRTXE, int_txe); 1105 musb_writew(mbase, MUSB_INTRTXE, musb->intrtxe);
1107 1106
1108 /* REVISIT if can_bulk_split(), use by updating "tmp"; 1107 /* REVISIT if can_bulk_split(), use by updating "tmp";
1109 * likewise high bandwidth periodic tx 1108 * likewise high bandwidth periodic tx
@@ -1130,7 +1129,6 @@ static int musb_gadget_enable(struct usb_ep *ep,
1130 musb_writew(regs, MUSB_TXCSR, csr); 1129 musb_writew(regs, MUSB_TXCSR, csr);
1131 1130
1132 } else { 1131 } else {
1133 u16 int_rxe = musb_readw(mbase, MUSB_INTRRXE);
1134 1132
1135 if (hw_ep->is_shared_fifo) 1133 if (hw_ep->is_shared_fifo)
1136 musb_ep->is_in = 0; 1134 musb_ep->is_in = 0;
@@ -1142,8 +1140,8 @@ static int musb_gadget_enable(struct usb_ep *ep,
1142 goto fail; 1140 goto fail;
1143 } 1141 }
1144 1142
1145 int_rxe |= (1 << epnum); 1143 musb->intrrxe |= (1 << epnum);
1146 musb_writew(mbase, MUSB_INTRRXE, int_rxe); 1144 musb_writew(mbase, MUSB_INTRRXE, musb->intrrxe);
1147 1145
1148 /* REVISIT if can_bulk_combine() use by updating "tmp" 1146 /* REVISIT if can_bulk_combine() use by updating "tmp"
1149 * likewise high bandwidth periodic rx 1147 * likewise high bandwidth periodic rx
@@ -1231,14 +1229,12 @@ static int musb_gadget_disable(struct usb_ep *ep)
1231 1229
1232 /* zero the endpoint sizes */ 1230 /* zero the endpoint sizes */
1233 if (musb_ep->is_in) { 1231 if (musb_ep->is_in) {
1234 u16 int_txe = musb_readw(musb->mregs, MUSB_INTRTXE); 1232 musb->intrtxe &= ~(1 << epnum);
1235 int_txe &= ~(1 << epnum); 1233 musb_writew(musb->mregs, MUSB_INTRTXE, musb->intrtxe);
1236 musb_writew(musb->mregs, MUSB_INTRTXE, int_txe);
1237 musb_writew(epio, MUSB_TXMAXP, 0); 1234 musb_writew(epio, MUSB_TXMAXP, 0);
1238 } else { 1235 } else {
1239 u16 int_rxe = musb_readw(musb->mregs, MUSB_INTRRXE); 1236 musb->intrrxe &= ~(1 << epnum);
1240 int_rxe &= ~(1 << epnum); 1237 musb_writew(musb->mregs, MUSB_INTRRXE, musb->intrrxe);
1241 musb_writew(musb->mregs, MUSB_INTRRXE, int_rxe);
1242 musb_writew(epio, MUSB_RXMAXP, 0); 1238 musb_writew(epio, MUSB_RXMAXP, 0);
1243 } 1239 }
1244 1240
@@ -1554,7 +1550,7 @@ static void musb_gadget_fifo_flush(struct usb_ep *ep)
1554 void __iomem *epio = musb->endpoints[epnum].regs; 1550 void __iomem *epio = musb->endpoints[epnum].regs;
1555 void __iomem *mbase; 1551 void __iomem *mbase;
1556 unsigned long flags; 1552 unsigned long flags;
1557 u16 csr, int_txe; 1553 u16 csr;
1558 1554
1559 mbase = musb->mregs; 1555 mbase = musb->mregs;
1560 1556
@@ -1562,8 +1558,7 @@ static void musb_gadget_fifo_flush(struct usb_ep *ep)
1562 musb_ep_select(mbase, (u8) epnum); 1558 musb_ep_select(mbase, (u8) epnum);
1563 1559
1564 /* disable interrupts */ 1560 /* disable interrupts */
1565 int_txe = musb_readw(mbase, MUSB_INTRTXE); 1561 musb_writew(mbase, MUSB_INTRTXE, musb->intrtxe & ~(1 << epnum));
1566 musb_writew(mbase, MUSB_INTRTXE, int_txe & ~(1 << epnum));
1567 1562
1568 if (musb_ep->is_in) { 1563 if (musb_ep->is_in) {
1569 csr = musb_readw(epio, MUSB_TXCSR); 1564 csr = musb_readw(epio, MUSB_TXCSR);
@@ -1587,7 +1582,7 @@ static void musb_gadget_fifo_flush(struct usb_ep *ep)
1587 } 1582 }
1588 1583
1589 /* re-enable interrupt */ 1584 /* re-enable interrupt */
1590 musb_writew(mbase, MUSB_INTRTXE, int_txe); 1585 musb_writew(mbase, MUSB_INTRTXE, musb->intrtxe);
1591 spin_unlock_irqrestore(&musb->lock, flags); 1586 spin_unlock_irqrestore(&musb->lock, flags);
1592} 1587}
1593 1588
@@ -1792,7 +1787,7 @@ static void musb_gadget_release(struct device *dev)
1792} 1787}
1793 1788
1794 1789
1795static void __devinit 1790static void
1796init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in) 1791init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in)
1797{ 1792{
1798 struct musb_hw_ep *hw_ep = musb->endpoints + epnum; 1793 struct musb_hw_ep *hw_ep = musb->endpoints + epnum;
@@ -1829,7 +1824,7 @@ init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in)
1829 * Initialize the endpoints exposed to peripheral drivers, with backlinks 1824 * Initialize the endpoints exposed to peripheral drivers, with backlinks
1830 * to the rest of the driver state. 1825 * to the rest of the driver state.
1831 */ 1826 */
1832static inline void __devinit musb_g_init_endpoints(struct musb *musb) 1827static inline void musb_g_init_endpoints(struct musb *musb)
1833{ 1828{
1834 u8 epnum; 1829 u8 epnum;
1835 struct musb_hw_ep *hw_ep; 1830 struct musb_hw_ep *hw_ep;
@@ -1862,7 +1857,7 @@ static inline void __devinit musb_g_init_endpoints(struct musb *musb)
1862/* called once during driver setup to initialize and link into 1857/* called once during driver setup to initialize and link into
1863 * the driver model; memory is zeroed. 1858 * the driver model; memory is zeroed.
1864 */ 1859 */
1865int __devinit musb_gadget_setup(struct musb *musb) 1860int musb_gadget_setup(struct musb *musb)
1866{ 1861{
1867 int status; 1862 int status;
1868 1863
@@ -2176,10 +2171,9 @@ __acquires(musb->lock)
2176 u8 devctl = musb_readb(mbase, MUSB_DEVCTL); 2171 u8 devctl = musb_readb(mbase, MUSB_DEVCTL);
2177 u8 power; 2172 u8 power;
2178 2173
2179 dev_dbg(musb->controller, "<== %s addr=%x driver '%s'\n", 2174 dev_dbg(musb->controller, "<== %s driver '%s'\n",
2180 (devctl & MUSB_DEVCTL_BDEVICE) 2175 (devctl & MUSB_DEVCTL_BDEVICE)
2181 ? "B-Device" : "A-Device", 2176 ? "B-Device" : "A-Device",
2182 musb_readb(mbase, MUSB_FADDR),
2183 musb->gadget_driver 2177 musb->gadget_driver
2184 ? musb->gadget_driver->driver.name 2178 ? musb->gadget_driver->driver.name
2185 : NULL 2179 : NULL
diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c
index e40d7647caf1..c9c1ac4e075f 100644
--- a/drivers/usb/musb/musb_gadget_ep0.c
+++ b/drivers/usb/musb/musb_gadget_ep0.c
@@ -673,10 +673,8 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
673 csr = musb_readw(regs, MUSB_CSR0); 673 csr = musb_readw(regs, MUSB_CSR0);
674 len = musb_readb(regs, MUSB_COUNT0); 674 len = musb_readb(regs, MUSB_COUNT0);
675 675
676 dev_dbg(musb->controller, "csr %04x, count %d, myaddr %d, ep0stage %s\n", 676 dev_dbg(musb->controller, "csr %04x, count %d, ep0stage %s\n",
677 csr, len, 677 csr, len, decode_ep0stage(musb->ep0_state));
678 musb_readb(mbase, MUSB_FADDR),
679 decode_ep0stage(musb->ep0_state));
680 678
681 if (csr & MUSB_CSR0_P_DATAEND) { 679 if (csr & MUSB_CSR0_P_DATAEND) {
682 /* 680 /*
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 3df6a76b851d..e9f0fd9ddd2d 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -740,7 +740,7 @@ static void musb_ep_program(struct musb *musb, u8 epnum,
740 csr = musb_readw(epio, MUSB_TXCSR); 740 csr = musb_readw(epio, MUSB_TXCSR);
741 741
742 /* disable interrupt in case we flush */ 742 /* disable interrupt in case we flush */
743 int_txe = musb_readw(mbase, MUSB_INTRTXE); 743 int_txe = musb->intrtxe;
744 musb_writew(mbase, MUSB_INTRTXE, int_txe & ~(1 << epnum)); 744 musb_writew(mbase, MUSB_INTRTXE, int_txe & ~(1 << epnum));
745 745
746 /* general endpoint setup */ 746 /* general endpoint setup */
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index 0fc6ca6bc60a..3d1fd52a15a9 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -380,8 +380,7 @@ void dma_controller_destroy(struct dma_controller *c)
380 kfree(controller); 380 kfree(controller);
381} 381}
382 382
383struct dma_controller *__devinit 383struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *base)
384dma_controller_create(struct musb *musb, void __iomem *base)
385{ 384{
386 struct musb_dma_controller *controller; 385 struct musb_dma_controller *controller;
387 struct device *dev = musb->controller; 386 struct device *dev = musb->controller;
diff --git a/drivers/usb/musb/musbhsdma.h b/drivers/usb/musb/musbhsdma.h
index 320fd4afb93f..f7b13fd25257 100644
--- a/drivers/usb/musb/musbhsdma.h
+++ b/drivers/usb/musb/musbhsdma.h
@@ -31,10 +31,6 @@
31 * 31 *
32 */ 32 */
33 33
34#if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_SOC_OMAP3430)
35#include "omap2430.h"
36#endif
37
38#ifndef CONFIG_BLACKFIN 34#ifndef CONFIG_BLACKFIN
39 35
40#define MUSB_HSDMA_BASE 0x200 36#define MUSB_HSDMA_BASE 0x200
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index a538fe17a966..da00af460794 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -333,6 +333,26 @@ static void omap_musb_mailbox_work(struct work_struct *mailbox_work)
333 omap_musb_set_mailbox(glue); 333 omap_musb_set_mailbox(glue);
334} 334}
335 335
336static irqreturn_t omap2430_musb_interrupt(int irq, void *__hci)
337{
338 unsigned long flags;
339 irqreturn_t retval = IRQ_NONE;
340 struct musb *musb = __hci;
341
342 spin_lock_irqsave(&musb->lock, flags);
343
344 musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB);
345 musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX);
346 musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX);
347
348 if (musb->int_usb || musb->int_tx || musb->int_rx)
349 retval = musb_interrupt(musb);
350
351 spin_unlock_irqrestore(&musb->lock, flags);
352
353 return retval;
354}
355
336static int omap2430_musb_init(struct musb *musb) 356static int omap2430_musb_init(struct musb *musb)
337{ 357{
338 u32 l; 358 u32 l;
@@ -352,6 +372,8 @@ static int omap2430_musb_init(struct musb *musb)
352 return -ENODEV; 372 return -ENODEV;
353 } 373 }
354 374
375 musb->isr = omap2430_musb_interrupt;
376
355 status = pm_runtime_get_sync(dev); 377 status = pm_runtime_get_sync(dev);
356 if (status < 0) { 378 if (status < 0) {
357 dev_err(dev, "pm_runtime_get_sync FAILED %d\n", status); 379 dev_err(dev, "pm_runtime_get_sync FAILED %d\n", status);
@@ -468,7 +490,7 @@ static const struct musb_platform_ops omap2430_ops = {
468 490
469static u64 omap2430_dmamask = DMA_BIT_MASK(32); 491static u64 omap2430_dmamask = DMA_BIT_MASK(32);
470 492
471static int __devinit omap2430_probe(struct platform_device *pdev) 493static int omap2430_probe(struct platform_device *pdev)
472{ 494{
473 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; 495 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
474 struct omap_musb_board_data *data; 496 struct omap_musb_board_data *data;
@@ -478,7 +500,6 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
478 struct musb_hdrc_config *config; 500 struct musb_hdrc_config *config;
479 struct resource *res; 501 struct resource *res;
480 int ret = -ENOMEM; 502 int ret = -ENOMEM;
481 int musbid;
482 503
483 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); 504 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
484 if (!glue) { 505 if (!glue) {
@@ -486,21 +507,12 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
486 goto err0; 507 goto err0;
487 } 508 }
488 509
489 /* get the musb id */ 510 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
490 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
491 if (musbid < 0) {
492 dev_err(&pdev->dev, "failed to allocate musb id\n");
493 ret = -ENOMEM;
494 goto err0;
495 }
496
497 musb = platform_device_alloc("musb-hdrc", musbid);
498 if (!musb) { 511 if (!musb) {
499 dev_err(&pdev->dev, "failed to allocate musb device\n"); 512 dev_err(&pdev->dev, "failed to allocate musb device\n");
500 goto err1; 513 goto err0;
501 } 514 }
502 515
503 musb->id = musbid;
504 musb->dev.parent = &pdev->dev; 516 musb->dev.parent = &pdev->dev;
505 musb->dev.dma_mask = &omap2430_dmamask; 517 musb->dev.dma_mask = &omap2430_dmamask;
506 musb->dev.coherent_dma_mask = omap2430_dmamask; 518 musb->dev.coherent_dma_mask = omap2430_dmamask;
@@ -521,7 +533,7 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
521 dev_err(&pdev->dev, 533 dev_err(&pdev->dev,
522 "failed to allocate musb platfrom data\n"); 534 "failed to allocate musb platfrom data\n");
523 ret = -ENOMEM; 535 ret = -ENOMEM;
524 goto err1; 536 goto err2;
525 } 537 }
526 538
527 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 539 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
@@ -529,14 +541,14 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
529 dev_err(&pdev->dev, 541 dev_err(&pdev->dev,
530 "failed to allocate musb board data\n"); 542 "failed to allocate musb board data\n");
531 ret = -ENOMEM; 543 ret = -ENOMEM;
532 goto err1; 544 goto err2;
533 } 545 }
534 546
535 config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL); 547 config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL);
536 if (!data) { 548 if (!data) {
537 dev_err(&pdev->dev, 549 dev_err(&pdev->dev,
538 "failed to allocate musb hdrc config\n"); 550 "failed to allocate musb hdrc config\n");
539 goto err1; 551 goto err2;
540 } 552 }
541 553
542 of_property_read_u32(np, "mode", (u32 *)&pdata->mode); 554 of_property_read_u32(np, "mode", (u32 *)&pdata->mode);
@@ -589,19 +601,15 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
589err2: 601err2:
590 platform_device_put(musb); 602 platform_device_put(musb);
591 603
592err1:
593 musb_put_id(&pdev->dev, musbid);
594
595err0: 604err0:
596 return ret; 605 return ret;
597} 606}
598 607
599static int __devexit omap2430_remove(struct platform_device *pdev) 608static int omap2430_remove(struct platform_device *pdev)
600{ 609{
601 struct omap2430_glue *glue = platform_get_drvdata(pdev); 610 struct omap2430_glue *glue = platform_get_drvdata(pdev);
602 611
603 cancel_work_sync(&glue->omap_musb_mailbox_work); 612 cancel_work_sync(&glue->omap_musb_mailbox_work);
604 musb_put_id(&pdev->dev, glue->musb->id);
605 platform_device_unregister(glue->musb); 613 platform_device_unregister(glue->musb);
606 614
607 return 0; 615 return 0;
@@ -666,7 +674,7 @@ MODULE_DEVICE_TABLE(of, omap2430_id_table);
666 674
667static struct platform_driver omap2430_driver = { 675static struct platform_driver omap2430_driver = {
668 .probe = omap2430_probe, 676 .probe = omap2430_probe,
669 .remove = __devexit_p(omap2430_remove), 677 .remove = omap2430_remove,
670 .driver = { 678 .driver = {
671 .name = "musb-omap2430", 679 .name = "musb-omap2430",
672 .pm = DEV_PM_OPS, 680 .pm = DEV_PM_OPS,
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index dc4d75ea13ad..8bde6fc5eb75 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -1153,14 +1153,13 @@ static const struct musb_platform_ops tusb_ops = {
1153 1153
1154static u64 tusb_dmamask = DMA_BIT_MASK(32); 1154static u64 tusb_dmamask = DMA_BIT_MASK(32);
1155 1155
1156static int __devinit tusb_probe(struct platform_device *pdev) 1156static int tusb_probe(struct platform_device *pdev)
1157{ 1157{
1158 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; 1158 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
1159 struct platform_device *musb; 1159 struct platform_device *musb;
1160 struct tusb6010_glue *glue; 1160 struct tusb6010_glue *glue;
1161 1161
1162 int ret = -ENOMEM; 1162 int ret = -ENOMEM;
1163 int musbid;
1164 1163
1165 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 1164 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
1166 if (!glue) { 1165 if (!glue) {
@@ -1168,21 +1167,12 @@ static int __devinit tusb_probe(struct platform_device *pdev)
1168 goto err0; 1167 goto err0;
1169 } 1168 }
1170 1169
1171 /* get the musb id */ 1170 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
1172 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
1173 if (musbid < 0) {
1174 dev_err(&pdev->dev, "failed to allocate musb id\n");
1175 ret = -ENOMEM;
1176 goto err1;
1177 }
1178
1179 musb = platform_device_alloc("musb-hdrc", musbid);
1180 if (!musb) { 1171 if (!musb) {
1181 dev_err(&pdev->dev, "failed to allocate musb device\n"); 1172 dev_err(&pdev->dev, "failed to allocate musb device\n");
1182 goto err2; 1173 goto err1;
1183 } 1174 }
1184 1175
1185 musb->id = musbid;
1186 musb->dev.parent = &pdev->dev; 1176 musb->dev.parent = &pdev->dev;
1187 musb->dev.dma_mask = &tusb_dmamask; 1177 musb->dev.dma_mask = &tusb_dmamask;
1188 musb->dev.coherent_dma_mask = tusb_dmamask; 1178 musb->dev.coherent_dma_mask = tusb_dmamask;
@@ -1218,9 +1208,6 @@ static int __devinit tusb_probe(struct platform_device *pdev)
1218err3: 1208err3:
1219 platform_device_put(musb); 1209 platform_device_put(musb);
1220 1210
1221err2:
1222 musb_put_id(&pdev->dev, musbid);
1223
1224err1: 1211err1:
1225 kfree(glue); 1212 kfree(glue);
1226 1213
@@ -1228,13 +1215,11 @@ err0:
1228 return ret; 1215 return ret;
1229} 1216}
1230 1217
1231static int __devexit tusb_remove(struct platform_device *pdev) 1218static int tusb_remove(struct platform_device *pdev)
1232{ 1219{
1233 struct tusb6010_glue *glue = platform_get_drvdata(pdev); 1220 struct tusb6010_glue *glue = platform_get_drvdata(pdev);
1234 1221
1235 musb_put_id(&pdev->dev, glue->musb->id); 1222 platform_device_unregister(glue->musb);
1236 platform_device_del(glue->musb);
1237 platform_device_put(glue->musb);
1238 kfree(glue); 1223 kfree(glue);
1239 1224
1240 return 0; 1225 return 0;
@@ -1242,7 +1227,7 @@ static int __devexit tusb_remove(struct platform_device *pdev)
1242 1227
1243static struct platform_driver tusb_driver = { 1228static struct platform_driver tusb_driver = {
1244 .probe = tusb_probe, 1229 .probe = tusb_probe,
1245 .remove = __devexit_p(tusb_remove), 1230 .remove = tusb_remove,
1246 .driver = { 1231 .driver = {
1247 .name = "musb-tusb", 1232 .name = "musb-tusb",
1248 }, 1233 },
@@ -1251,15 +1236,4 @@ static struct platform_driver tusb_driver = {
1251MODULE_DESCRIPTION("TUSB6010 MUSB Glue Layer"); 1236MODULE_DESCRIPTION("TUSB6010 MUSB Glue Layer");
1252MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); 1237MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
1253MODULE_LICENSE("GPL v2"); 1238MODULE_LICENSE("GPL v2");
1254 1239module_platform_driver(tusb_driver);
1255static int __init tusb_init(void)
1256{
1257 return platform_driver_register(&tusb_driver);
1258}
1259module_init(tusb_init);
1260
1261static void __exit tusb_exit(void)
1262{
1263 platform_driver_unregister(&tusb_driver);
1264}
1265module_exit(tusb_exit);
diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
index 7a62b95dac24..2c46d42e6618 100644
--- a/drivers/usb/musb/tusb6010_omap.c
+++ b/drivers/usb/musb/tusb6010_omap.c
@@ -661,8 +661,7 @@ void dma_controller_destroy(struct dma_controller *c)
661 kfree(tusb_dma); 661 kfree(tusb_dma);
662} 662}
663 663
664struct dma_controller *__devinit 664struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *base)
665dma_controller_create(struct musb *musb, void __iomem *base)
666{ 665{
667 void __iomem *tbase = musb->ctrl_base; 666 void __iomem *tbase = musb->ctrl_base;
668 struct tusb_omap_dma *tusb_dma; 667 struct tusb_omap_dma *tusb_dma;
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index 0e62f504410e..a27ca1a9c994 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -36,6 +36,26 @@ struct ux500_glue {
36}; 36};
37#define glue_to_musb(g) platform_get_drvdata(g->musb) 37#define glue_to_musb(g) platform_get_drvdata(g->musb)
38 38
39static irqreturn_t ux500_musb_interrupt(int irq, void *__hci)
40{
41 unsigned long flags;
42 irqreturn_t retval = IRQ_NONE;
43 struct musb *musb = __hci;
44
45 spin_lock_irqsave(&musb->lock, flags);
46
47 musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB);
48 musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX);
49 musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX);
50
51 if (musb->int_usb || musb->int_tx || musb->int_rx)
52 retval = musb_interrupt(musb);
53
54 spin_unlock_irqrestore(&musb->lock, flags);
55
56 return retval;
57}
58
39static int ux500_musb_init(struct musb *musb) 59static int ux500_musb_init(struct musb *musb)
40{ 60{
41 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); 61 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
@@ -44,6 +64,8 @@ static int ux500_musb_init(struct musb *musb)
44 return -ENODEV; 64 return -ENODEV;
45 } 65 }
46 66
67 musb->isr = ux500_musb_interrupt;
68
47 return 0; 69 return 0;
48} 70}
49 71
@@ -59,13 +81,12 @@ static const struct musb_platform_ops ux500_ops = {
59 .exit = ux500_musb_exit, 81 .exit = ux500_musb_exit,
60}; 82};
61 83
62static int __devinit ux500_probe(struct platform_device *pdev) 84static int ux500_probe(struct platform_device *pdev)
63{ 85{
64 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; 86 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
65 struct platform_device *musb; 87 struct platform_device *musb;
66 struct ux500_glue *glue; 88 struct ux500_glue *glue;
67 struct clk *clk; 89 struct clk *clk;
68 int musbid;
69 int ret = -ENOMEM; 90 int ret = -ENOMEM;
70 91
71 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 92 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
@@ -74,18 +95,10 @@ static int __devinit ux500_probe(struct platform_device *pdev)
74 goto err0; 95 goto err0;
75 } 96 }
76 97
77 /* get the musb id */ 98 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
78 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
79 if (musbid < 0) {
80 dev_err(&pdev->dev, "failed to allocate musb id\n");
81 ret = -ENOMEM;
82 goto err1;
83 }
84
85 musb = platform_device_alloc("musb-hdrc", musbid);
86 if (!musb) { 99 if (!musb) {
87 dev_err(&pdev->dev, "failed to allocate musb device\n"); 100 dev_err(&pdev->dev, "failed to allocate musb device\n");
88 goto err2; 101 goto err1;
89 } 102 }
90 103
91 clk = clk_get(&pdev->dev, "usb"); 104 clk = clk_get(&pdev->dev, "usb");
@@ -101,7 +114,6 @@ static int __devinit ux500_probe(struct platform_device *pdev)
101 goto err4; 114 goto err4;
102 } 115 }
103 116
104 musb->id = musbid;
105 musb->dev.parent = &pdev->dev; 117 musb->dev.parent = &pdev->dev;
106 musb->dev.dma_mask = pdev->dev.dma_mask; 118 musb->dev.dma_mask = pdev->dev.dma_mask;
107 musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask; 119 musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask;
@@ -144,9 +156,6 @@ err4:
144err3: 156err3:
145 platform_device_put(musb); 157 platform_device_put(musb);
146 158
147err2:
148 musb_put_id(&pdev->dev, musbid);
149
150err1: 159err1:
151 kfree(glue); 160 kfree(glue);
152 161
@@ -154,13 +163,11 @@ err0:
154 return ret; 163 return ret;
155} 164}
156 165
157static int __devexit ux500_remove(struct platform_device *pdev) 166static int ux500_remove(struct platform_device *pdev)
158{ 167{
159 struct ux500_glue *glue = platform_get_drvdata(pdev); 168 struct ux500_glue *glue = platform_get_drvdata(pdev);
160 169
161 musb_put_id(&pdev->dev, glue->musb->id); 170 platform_device_unregister(glue->musb);
162 platform_device_del(glue->musb);
163 platform_device_put(glue->musb);
164 clk_disable(glue->clk); 171 clk_disable(glue->clk);
165 clk_put(glue->clk); 172 clk_put(glue->clk);
166 kfree(glue); 173 kfree(glue);
@@ -209,7 +216,7 @@ static const struct dev_pm_ops ux500_pm_ops = {
209 216
210static struct platform_driver ux500_driver = { 217static struct platform_driver ux500_driver = {
211 .probe = ux500_probe, 218 .probe = ux500_probe,
212 .remove = __devexit_p(ux500_remove), 219 .remove = ux500_remove,
213 .driver = { 220 .driver = {
214 .name = "musb-ux500", 221 .name = "musb-ux500",
215 .pm = DEV_PM_OPS, 222 .pm = DEV_PM_OPS,
@@ -219,15 +226,4 @@ static struct platform_driver ux500_driver = {
219MODULE_DESCRIPTION("UX500 MUSB Glue Layer"); 226MODULE_DESCRIPTION("UX500 MUSB Glue Layer");
220MODULE_AUTHOR("Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>"); 227MODULE_AUTHOR("Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>");
221MODULE_LICENSE("GPL v2"); 228MODULE_LICENSE("GPL v2");
222 229module_platform_driver(ux500_driver);
223static int __init ux500_init(void)
224{
225 return platform_driver_register(&ux500_driver);
226}
227module_init(ux500_init);
228
229static void __exit ux500_exit(void)
230{
231 platform_driver_unregister(&ux500_driver);
232}
233module_exit(ux500_exit);
diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
index f1059e725ea8..039e567dd3b6 100644
--- a/drivers/usb/musb/ux500_dma.c
+++ b/drivers/usb/musb/ux500_dma.c
@@ -364,8 +364,7 @@ void dma_controller_destroy(struct dma_controller *c)
364 kfree(controller); 364 kfree(controller);
365} 365}
366 366
367struct dma_controller *__devinit 367struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *base)
368dma_controller_create(struct musb *musb, void __iomem *base)
369{ 368{
370 struct ux500_dma_controller *controller; 369 struct ux500_dma_controller *controller;
371 struct platform_device *pdev = to_platform_device(musb->controller); 370 struct platform_device *pdev = to_platform_device(musb->controller);
diff --git a/drivers/usb/otg/ab8500-usb.c b/drivers/usb/otg/ab8500-usb.c
index ae8ad561f083..2d86f26a0183 100644
--- a/drivers/usb/otg/ab8500-usb.c
+++ b/drivers/usb/otg/ab8500-usb.c
@@ -468,7 +468,7 @@ static int ab8500_usb_v2_res_setup(struct platform_device *pdev,
468 return 0; 468 return 0;
469} 469}
470 470
471static int __devinit ab8500_usb_probe(struct platform_device *pdev) 471static int ab8500_usb_probe(struct platform_device *pdev)
472{ 472{
473 struct ab8500_usb *ab; 473 struct ab8500_usb *ab;
474 struct usb_otg *otg; 474 struct usb_otg *otg;
@@ -546,7 +546,7 @@ fail0:
546 return err; 546 return err;
547} 547}
548 548
549static int __devexit ab8500_usb_remove(struct platform_device *pdev) 549static int ab8500_usb_remove(struct platform_device *pdev)
550{ 550{
551 struct ab8500_usb *ab = platform_get_drvdata(pdev); 551 struct ab8500_usb *ab = platform_get_drvdata(pdev);
552 552
@@ -571,7 +571,7 @@ static int __devexit ab8500_usb_remove(struct platform_device *pdev)
571 571
572static struct platform_driver ab8500_usb_driver = { 572static struct platform_driver ab8500_usb_driver = {
573 .probe = ab8500_usb_probe, 573 .probe = ab8500_usb_probe,
574 .remove = __devexit_p(ab8500_usb_remove), 574 .remove = ab8500_usb_remove,
575 .driver = { 575 .driver = {
576 .name = "ab8500-usb", 576 .name = "ab8500-usb",
577 .owner = THIS_MODULE, 577 .owner = THIS_MODULE,
diff --git a/drivers/usb/otg/fsl_otg.c b/drivers/usb/otg/fsl_otg.c
index c19d1d7173a9..d16adb41eb21 100644
--- a/drivers/usb/otg/fsl_otg.c
+++ b/drivers/usb/otg/fsl_otg.c
@@ -1110,7 +1110,7 @@ static const struct file_operations otg_fops = {
1110 .release = fsl_otg_release, 1110 .release = fsl_otg_release,
1111}; 1111};
1112 1112
1113static int __devinit fsl_otg_probe(struct platform_device *pdev) 1113static int fsl_otg_probe(struct platform_device *pdev)
1114{ 1114{
1115 int ret; 1115 int ret;
1116 1116
@@ -1144,7 +1144,7 @@ static int __devinit fsl_otg_probe(struct platform_device *pdev)
1144 return ret; 1144 return ret;
1145} 1145}
1146 1146
1147static int __devexit fsl_otg_remove(struct platform_device *pdev) 1147static int fsl_otg_remove(struct platform_device *pdev)
1148{ 1148{
1149 struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; 1149 struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
1150 1150
@@ -1169,7 +1169,7 @@ static int __devexit fsl_otg_remove(struct platform_device *pdev)
1169 1169
1170struct platform_driver fsl_otg_driver = { 1170struct platform_driver fsl_otg_driver = {
1171 .probe = fsl_otg_probe, 1171 .probe = fsl_otg_probe,
1172 .remove = __devexit_p(fsl_otg_remove), 1172 .remove = fsl_otg_remove,
1173 .driver = { 1173 .driver = {
1174 .name = driver_name, 1174 .name = driver_name,
1175 .owner = THIS_MODULE, 1175 .owner = THIS_MODULE,
diff --git a/drivers/usb/otg/isp1301_omap.c b/drivers/usb/otg/isp1301_omap.c
index ceee2119bffa..af9cb11626b2 100644
--- a/drivers/usb/otg/isp1301_omap.c
+++ b/drivers/usb/otg/isp1301_omap.c
@@ -1493,7 +1493,7 @@ isp1301_start_hnp(struct usb_otg *otg)
1493 1493
1494/*-------------------------------------------------------------------------*/ 1494/*-------------------------------------------------------------------------*/
1495 1495
1496static int __devinit 1496static int
1497isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id) 1497isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
1498{ 1498{
1499 int status; 1499 int status;
diff --git a/drivers/usb/otg/msm_otg.c b/drivers/usb/otg/msm_otg.c
index 9f5fc906041a..3b9f0d951132 100644
--- a/drivers/usb/otg/msm_otg.c
+++ b/drivers/usb/otg/msm_otg.c
@@ -1606,7 +1606,7 @@ free_motg:
1606 return ret; 1606 return ret;
1607} 1607}
1608 1608
1609static int __devexit msm_otg_remove(struct platform_device *pdev) 1609static int msm_otg_remove(struct platform_device *pdev)
1610{ 1610{
1611 struct msm_otg *motg = platform_get_drvdata(pdev); 1611 struct msm_otg *motg = platform_get_drvdata(pdev);
1612 struct usb_phy *phy = &motg->phy; 1612 struct usb_phy *phy = &motg->phy;
@@ -1746,7 +1746,7 @@ static const struct dev_pm_ops msm_otg_dev_pm_ops = {
1746#endif 1746#endif
1747 1747
1748static struct platform_driver msm_otg_driver = { 1748static struct platform_driver msm_otg_driver = {
1749 .remove = __devexit_p(msm_otg_remove), 1749 .remove = msm_otg_remove,
1750 .driver = { 1750 .driver = {
1751 .name = DRIVER_NAME, 1751 .name = DRIVER_NAME,
1752 .owner = THIS_MODULE, 1752 .owner = THIS_MODULE,
diff --git a/drivers/usb/otg/mv_otg.c b/drivers/usb/otg/mv_otg.c
index 3f124e8f5792..1dd57504186d 100644
--- a/drivers/usb/otg/mv_otg.c
+++ b/drivers/usb/otg/mv_otg.c
@@ -958,16 +958,4 @@ static struct platform_driver mv_otg_driver = {
958 .resume = mv_otg_resume, 958 .resume = mv_otg_resume,
959#endif 959#endif
960}; 960};
961 961module_platform_driver(mv_otg_driver);
962static int __init mv_otg_init(void)
963{
964 return platform_driver_register(&mv_otg_driver);
965}
966
967static void __exit mv_otg_exit(void)
968{
969 platform_driver_unregister(&mv_otg_driver);
970}
971
972module_init(mv_otg_init);
973module_exit(mv_otg_exit);
diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
index 88db976647cf..76302720055a 100644
--- a/drivers/usb/otg/mxs-phy.c
+++ b/drivers/usb/otg/mxs-phy.c
@@ -20,7 +20,6 @@
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/workqueue.h>
24 23
25#define DRIVER_NAME "mxs_phy" 24#define DRIVER_NAME "mxs_phy"
26 25
@@ -35,16 +34,9 @@
35#define BM_USBPHY_CTRL_ENUTMILEVEL2 BIT(14) 34#define BM_USBPHY_CTRL_ENUTMILEVEL2 BIT(14)
36#define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1) 35#define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1)
37 36
38/*
39 * Amount of delay in miliseconds to safely enable ENHOSTDISCONDETECT bit
40 * so that connection and reset processing can be completed for the root hub.
41 */
42#define MXY_PHY_ENHOSTDISCONDETECT_DELAY 250
43
44struct mxs_phy { 37struct mxs_phy {
45 struct usb_phy phy; 38 struct usb_phy phy;
46 struct clk *clk; 39 struct clk *clk;
47 struct delayed_work enhostdiscondetect_work;
48}; 40};
49 41
50#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) 42#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
@@ -70,7 +62,6 @@ static int mxs_phy_init(struct usb_phy *phy)
70 62
71 clk_prepare_enable(mxs_phy->clk); 63 clk_prepare_enable(mxs_phy->clk);
72 mxs_phy_hw_init(mxs_phy); 64 mxs_phy_hw_init(mxs_phy);
73 INIT_DELAYED_WORK(&mxs_phy->enhostdiscondetect_work, NULL);
74 65
75 return 0; 66 return 0;
76} 67}
@@ -85,46 +76,28 @@ static void mxs_phy_shutdown(struct usb_phy *phy)
85 clk_disable_unprepare(mxs_phy->clk); 76 clk_disable_unprepare(mxs_phy->clk);
86} 77}
87 78
88static void mxs_phy_enhostdiscondetect_delay(struct work_struct *ws) 79static int mxs_phy_on_connect(struct usb_phy *phy,
80 enum usb_device_speed speed)
89{ 81{
90 struct mxs_phy *mxs_phy = container_of(ws, struct mxs_phy, 82 dev_dbg(phy->dev, "%s speed device has connected\n",
91 enhostdiscondetect_work.work); 83 (speed == USB_SPEED_HIGH) ? "high" : "non-high");
92
93 /* Enable HOSTDISCONDETECT after delay. */
94 dev_dbg(mxs_phy->phy.dev, "Setting ENHOSTDISCONDETECT\n");
95 writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
96 mxs_phy->phy.io_priv + HW_USBPHY_CTRL_SET);
97}
98
99static int mxs_phy_on_connect(struct usb_phy *phy, int port)
100{
101 struct mxs_phy *mxs_phy = to_mxs_phy(phy);
102
103 dev_dbg(phy->dev, "Connect on port %d\n", port);
104
105 mxs_phy_hw_init(mxs_phy);
106 84
107 /* 85 if (speed == USB_SPEED_HIGH)
108 * Delay enabling ENHOSTDISCONDETECT so that connection and 86 writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
109 * reset processing can be completed for the root hub. 87 phy->io_priv + HW_USBPHY_CTRL_SET);
110 */
111 dev_dbg(phy->dev, "Delaying setting ENHOSTDISCONDETECT\n");
112 PREPARE_DELAYED_WORK(&mxs_phy->enhostdiscondetect_work,
113 mxs_phy_enhostdiscondetect_delay);
114 schedule_delayed_work(&mxs_phy->enhostdiscondetect_work,
115 msecs_to_jiffies(MXY_PHY_ENHOSTDISCONDETECT_DELAY));
116 88
117 return 0; 89 return 0;
118} 90}
119 91
120static int mxs_phy_on_disconnect(struct usb_phy *phy, int port) 92static int mxs_phy_on_disconnect(struct usb_phy *phy,
93 enum usb_device_speed speed)
121{ 94{
122 dev_dbg(phy->dev, "Disconnect on port %d\n", port); 95 dev_dbg(phy->dev, "%s speed device has disconnected\n",
96 (speed == USB_SPEED_HIGH) ? "high" : "non-high");
123 97
124 /* No need to delay before clearing ENHOSTDISCONDETECT. */ 98 if (speed == USB_SPEED_HIGH)
125 dev_dbg(phy->dev, "Clearing ENHOSTDISCONDETECT\n"); 99 writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
126 writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, 100 phy->io_priv + HW_USBPHY_CTRL_CLR);
127 phy->io_priv + HW_USBPHY_CTRL_CLR);
128 101
129 return 0; 102 return 0;
130} 103}
@@ -176,7 +149,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
176 return 0; 149 return 0;
177} 150}
178 151
179static int __devexit mxs_phy_remove(struct platform_device *pdev) 152static int mxs_phy_remove(struct platform_device *pdev)
180{ 153{
181 platform_set_drvdata(pdev, NULL); 154 platform_set_drvdata(pdev, NULL);
182 155
@@ -191,7 +164,7 @@ MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids);
191 164
192static struct platform_driver mxs_phy_driver = { 165static struct platform_driver mxs_phy_driver = {
193 .probe = mxs_phy_probe, 166 .probe = mxs_phy_probe,
194 .remove = __devexit_p(mxs_phy_remove), 167 .remove = mxs_phy_remove,
195 .driver = { 168 .driver = {
196 .name = DRIVER_NAME, 169 .name = DRIVER_NAME,
197 .owner = THIS_MODULE, 170 .owner = THIS_MODULE,
diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index e52e35e7adaf..a3ce24b94a73 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -93,7 +93,7 @@ static int nop_set_host(struct usb_otg *otg, struct usb_bus *host)
93 return 0; 93 return 0;
94} 94}
95 95
96static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev) 96static int nop_usb_xceiv_probe(struct platform_device *pdev)
97{ 97{
98 struct nop_usb_xceiv_platform_data *pdata = pdev->dev.platform_data; 98 struct nop_usb_xceiv_platform_data *pdata = pdev->dev.platform_data;
99 struct nop_usb_xceiv *nop; 99 struct nop_usb_xceiv *nop;
@@ -141,7 +141,7 @@ exit:
141 return err; 141 return err;
142} 142}
143 143
144static int __devexit nop_usb_xceiv_remove(struct platform_device *pdev) 144static int nop_usb_xceiv_remove(struct platform_device *pdev)
145{ 145{
146 struct nop_usb_xceiv *nop = platform_get_drvdata(pdev); 146 struct nop_usb_xceiv *nop = platform_get_drvdata(pdev);
147 147
@@ -156,7 +156,7 @@ static int __devexit nop_usb_xceiv_remove(struct platform_device *pdev)
156 156
157static struct platform_driver nop_usb_xceiv_driver = { 157static struct platform_driver nop_usb_xceiv_driver = {
158 .probe = nop_usb_xceiv_probe, 158 .probe = nop_usb_xceiv_probe,
159 .remove = __devexit_p(nop_usb_xceiv_remove), 159 .remove = nop_usb_xceiv_remove,
160 .driver = { 160 .driver = {
161 .name = "nop_usb_xceiv", 161 .name = "nop_usb_xceiv",
162 .owner = THIS_MODULE, 162 .owner = THIS_MODULE,
diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c
index f0d2e7530cfe..0a701938ab53 100644
--- a/drivers/usb/otg/twl4030-usb.c
+++ b/drivers/usb/otg/twl4030-usb.c
@@ -123,10 +123,10 @@
123#define PHY_CLK_CTRL_STS 0xFF 123#define PHY_CLK_CTRL_STS 0xFF
124#define PHY_DPLL_CLK (1 << 0) 124#define PHY_DPLL_CLK (1 << 0)
125 125
126/* In module TWL4030_MODULE_PM_MASTER */ 126/* In module TWL_MODULE_PM_MASTER */
127#define STS_HW_CONDITIONS 0x0F 127#define STS_HW_CONDITIONS 0x0F
128 128
129/* In module TWL4030_MODULE_PM_RECEIVER */ 129/* In module TWL_MODULE_PM_RECEIVER */
130#define VUSB_DEDICATED1 0x7D 130#define VUSB_DEDICATED1 0x7D
131#define VUSB_DEDICATED2 0x7E 131#define VUSB_DEDICATED2 0x7E
132#define VUSB1V5_DEV_GRP 0x71 132#define VUSB1V5_DEV_GRP 0x71
@@ -195,14 +195,14 @@ static int twl4030_i2c_write_u8_verify(struct twl4030_usb *twl,
195} 195}
196 196
197#define twl4030_usb_write_verify(twl, address, data) \ 197#define twl4030_usb_write_verify(twl, address, data) \
198 twl4030_i2c_write_u8_verify(twl, TWL4030_MODULE_USB, (data), (address)) 198 twl4030_i2c_write_u8_verify(twl, TWL_MODULE_USB, (data), (address))
199 199
200static inline int twl4030_usb_write(struct twl4030_usb *twl, 200static inline int twl4030_usb_write(struct twl4030_usb *twl,
201 u8 address, u8 data) 201 u8 address, u8 data)
202{ 202{
203 int ret = 0; 203 int ret = 0;
204 204
205 ret = twl_i2c_write_u8(TWL4030_MODULE_USB, data, address); 205 ret = twl_i2c_write_u8(TWL_MODULE_USB, data, address);
206 if (ret < 0) 206 if (ret < 0)
207 dev_dbg(twl->dev, 207 dev_dbg(twl->dev,
208 "TWL4030:USB:Write[0x%x] Error %d\n", address, ret); 208 "TWL4030:USB:Write[0x%x] Error %d\n", address, ret);
@@ -227,7 +227,7 @@ static inline int twl4030_readb(struct twl4030_usb *twl, u8 module, u8 address)
227 227
228static inline int twl4030_usb_read(struct twl4030_usb *twl, u8 address) 228static inline int twl4030_usb_read(struct twl4030_usb *twl, u8 address)
229{ 229{
230 return twl4030_readb(twl, TWL4030_MODULE_USB, address); 230 return twl4030_readb(twl, TWL_MODULE_USB, address);
231} 231}
232 232
233/*-------------------------------------------------------------------------*/ 233/*-------------------------------------------------------------------------*/
@@ -264,8 +264,7 @@ static enum omap_musb_vbus_id_status
264 * signal is active, the OTG module is activated, and 264 * signal is active, the OTG module is activated, and
265 * its interrupt may be raised (may wake the system). 265 * its interrupt may be raised (may wake the system).
266 */ 266 */
267 status = twl4030_readb(twl, TWL4030_MODULE_PM_MASTER, 267 status = twl4030_readb(twl, TWL_MODULE_PM_MASTER, STS_HW_CONDITIONS);
268 STS_HW_CONDITIONS);
269 if (status < 0) 268 if (status < 0)
270 dev_err(twl->dev, "USB link status err %d\n", status); 269 dev_err(twl->dev, "USB link status err %d\n", status);
271 else if (status & (BIT(7) | BIT(2))) { 270 else if (status & (BIT(7) | BIT(2))) {
@@ -372,8 +371,7 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on)
372 * SLEEP. We work around this by clearing the bit after usv3v1 371 * SLEEP. We work around this by clearing the bit after usv3v1
373 * is re-activated. This ensures that VUSB3V1 is really active. 372 * is re-activated. This ensures that VUSB3V1 is really active.
374 */ 373 */
375 twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, 374 twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);
376 VUSB_DEDICATED2);
377 regulator_enable(twl->usb1v5); 375 regulator_enable(twl->usb1v5);
378 __twl4030_phy_power(twl, 1); 376 __twl4030_phy_power(twl, 1);
379 twl4030_usb_write(twl, PHY_CLK_CTRL, 377 twl4030_usb_write(twl, PHY_CLK_CTRL,
@@ -419,50 +417,48 @@ static void twl4030_phy_resume(struct twl4030_usb *twl)
419static int twl4030_usb_ldo_init(struct twl4030_usb *twl) 417static int twl4030_usb_ldo_init(struct twl4030_usb *twl)
420{ 418{
421 /* Enable writing to power configuration registers */ 419 /* Enable writing to power configuration registers */
422 twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 420 twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1,
423 TWL4030_PM_MASTER_KEY_CFG1, 421 TWL4030_PM_MASTER_PROTECT_KEY);
424 TWL4030_PM_MASTER_PROTECT_KEY);
425 422
426 twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 423 twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG2,
427 TWL4030_PM_MASTER_KEY_CFG2, 424 TWL4030_PM_MASTER_PROTECT_KEY);
428 TWL4030_PM_MASTER_PROTECT_KEY);
429 425
430 /* Keep VUSB3V1 LDO in sleep state until VBUS/ID change detected*/ 426 /* Keep VUSB3V1 LDO in sleep state until VBUS/ID change detected*/
431 /*twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);*/ 427 /*twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);*/
432 428
433 /* input to VUSB3V1 LDO is from VBAT, not VBUS */ 429 /* input to VUSB3V1 LDO is from VBAT, not VBUS */
434 twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1); 430 twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1);
435 431
436 /* Initialize 3.1V regulator */ 432 /* Initialize 3.1V regulator */
437 twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_DEV_GRP); 433 twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB3V1_DEV_GRP);
438 434
439 twl->usb3v1 = regulator_get(twl->dev, "usb3v1"); 435 twl->usb3v1 = regulator_get(twl->dev, "usb3v1");
440 if (IS_ERR(twl->usb3v1)) 436 if (IS_ERR(twl->usb3v1))
441 return -ENODEV; 437 return -ENODEV;
442 438
443 twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_TYPE); 439 twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB3V1_TYPE);
444 440
445 /* Initialize 1.5V regulator */ 441 /* Initialize 1.5V regulator */
446 twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V5_DEV_GRP); 442 twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V5_DEV_GRP);
447 443
448 twl->usb1v5 = regulator_get(twl->dev, "usb1v5"); 444 twl->usb1v5 = regulator_get(twl->dev, "usb1v5");
449 if (IS_ERR(twl->usb1v5)) 445 if (IS_ERR(twl->usb1v5))
450 goto fail1; 446 goto fail1;
451 447
452 twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V5_TYPE); 448 twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V5_TYPE);
453 449
454 /* Initialize 1.8V regulator */ 450 /* Initialize 1.8V regulator */
455 twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V8_DEV_GRP); 451 twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V8_DEV_GRP);
456 452
457 twl->usb1v8 = regulator_get(twl->dev, "usb1v8"); 453 twl->usb1v8 = regulator_get(twl->dev, "usb1v8");
458 if (IS_ERR(twl->usb1v8)) 454 if (IS_ERR(twl->usb1v8))
459 goto fail2; 455 goto fail2;
460 456
461 twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V8_TYPE); 457 twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V8_TYPE);
462 458
463 /* disable access to power configuration registers */ 459 /* disable access to power configuration registers */
464 twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, 460 twl_i2c_write_u8(TWL_MODULE_PM_MASTER, 0,
465 TWL4030_PM_MASTER_PROTECT_KEY); 461 TWL4030_PM_MASTER_PROTECT_KEY);
466 462
467 return 0; 463 return 0;
468 464
@@ -579,7 +575,7 @@ static int twl4030_set_host(struct usb_otg *otg, struct usb_bus *host)
579 return 0; 575 return 0;
580} 576}
581 577
582static int __devinit twl4030_usb_probe(struct platform_device *pdev) 578static int twl4030_usb_probe(struct platform_device *pdev)
583{ 579{
584 struct twl4030_usb_data *pdata = pdev->dev.platform_data; 580 struct twl4030_usb_data *pdata = pdev->dev.platform_data;
585 struct twl4030_usb *twl; 581 struct twl4030_usb *twl;
diff --git a/drivers/usb/otg/twl6030-usb.c b/drivers/usb/otg/twl6030-usb.c
index fcadef7864f1..8cd6cf49bdbd 100644
--- a/drivers/usb/otg/twl6030-usb.c
+++ b/drivers/usb/otg/twl6030-usb.c
@@ -310,7 +310,7 @@ static int twl6030_set_vbus(struct phy_companion *comparator, bool enabled)
310 return 0; 310 return 0;
311} 311}
312 312
313static int __devinit twl6030_usb_probe(struct platform_device *pdev) 313static int twl6030_usb_probe(struct platform_device *pdev)
314{ 314{
315 u32 ret; 315 u32 ret;
316 struct twl6030_usb *twl; 316 struct twl6030_usb *twl;
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 63c339b3e676..7eb73c561bd2 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -32,3 +32,15 @@ config MV_U3D_PHY
32 help 32 help
33 Enable this to support Marvell USB 3.0 phy controller for Marvell 33 Enable this to support Marvell USB 3.0 phy controller for Marvell
34 SoC. 34 SoC.
35
36config USB_RCAR_PHY
37 tristate "Renesas R-Car USB phy support"
38 depends on USB || USB_GADGET
39 select USB_OTG_UTILS
40 help
41 Say Y here to add support for the Renesas R-Car USB phy driver.
42 This chip is typically used as USB phy for USB host, gadget.
43 This driver supports: R8A7779
44
45 To compile this driver as a module, choose M here: the
46 module will be called rcar-phy.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b069f29f1225..1a579a860a03 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o
8obj-$(CONFIG_USB_ISP1301) += isp1301.o 8obj-$(CONFIG_USB_ISP1301) += isp1301.o
9obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o 9obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o
10obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o 10obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o
11obj-$(CONFIG_USB_RCAR_PHY) += rcar-phy.o
diff --git a/drivers/usb/phy/mv_u3d_phy.c b/drivers/usb/phy/mv_u3d_phy.c
index 9f1c5d3c60ec..eaddbe3d4304 100644
--- a/drivers/usb/phy/mv_u3d_phy.c
+++ b/drivers/usb/phy/mv_u3d_phy.c
@@ -262,7 +262,7 @@ calstart:
262 return 0; 262 return 0;
263} 263}
264 264
265static int __devinit mv_u3d_phy_probe(struct platform_device *pdev) 265static int mv_u3d_phy_probe(struct platform_device *pdev)
266{ 266{
267 struct mv_u3d_phy *mv_u3d_phy; 267 struct mv_u3d_phy *mv_u3d_phy;
268 struct mv_usb_platform_data *pdata; 268 struct mv_usb_platform_data *pdata;
@@ -331,7 +331,7 @@ static int __exit mv_u3d_phy_remove(struct platform_device *pdev)
331 331
332static struct platform_driver mv_u3d_phy_driver = { 332static struct platform_driver mv_u3d_phy_driver = {
333 .probe = mv_u3d_phy_probe, 333 .probe = mv_u3d_phy_probe,
334 .remove = __devexit_p(mv_u3d_phy_remove), 334 .remove = mv_u3d_phy_remove,
335 .driver = { 335 .driver = {
336 .name = "mv-u3d-phy", 336 .name = "mv-u3d-phy",
337 .owner = THIS_MODULE, 337 .owner = THIS_MODULE,
diff --git a/drivers/usb/phy/omap-usb2.c b/drivers/usb/phy/omap-usb2.c
index 15ab3d6f2e8c..26ae8f49225c 100644
--- a/drivers/usb/phy/omap-usb2.c
+++ b/drivers/usb/phy/omap-usb2.c
@@ -141,7 +141,7 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend)
141 return 0; 141 return 0;
142} 142}
143 143
144static int __devinit omap_usb2_probe(struct platform_device *pdev) 144static int omap_usb2_probe(struct platform_device *pdev)
145{ 145{
146 struct omap_usb *phy; 146 struct omap_usb *phy;
147 struct usb_otg *otg; 147 struct usb_otg *otg;
@@ -199,7 +199,7 @@ static int __devinit omap_usb2_probe(struct platform_device *pdev)
199 return 0; 199 return 0;
200} 200}
201 201
202static int __devexit omap_usb2_remove(struct platform_device *pdev) 202static int omap_usb2_remove(struct platform_device *pdev)
203{ 203{
204 struct omap_usb *phy = platform_get_drvdata(pdev); 204 struct omap_usb *phy = platform_get_drvdata(pdev);
205 205
@@ -254,7 +254,7 @@ MODULE_DEVICE_TABLE(of, omap_usb2_id_table);
254 254
255static struct platform_driver omap_usb2_driver = { 255static struct platform_driver omap_usb2_driver = {
256 .probe = omap_usb2_probe, 256 .probe = omap_usb2_probe,
257 .remove = __devexit_p(omap_usb2_remove), 257 .remove = omap_usb2_remove,
258 .driver = { 258 .driver = {
259 .name = "omap-usb2", 259 .name = "omap-usb2",
260 .owner = THIS_MODULE, 260 .owner = THIS_MODULE,
diff --git a/drivers/usb/phy/rcar-phy.c b/drivers/usb/phy/rcar-phy.c
new file mode 100644
index 000000000000..a35681b0c501
--- /dev/null
+++ b/drivers/usb/phy/rcar-phy.c
@@ -0,0 +1,220 @@
1/*
2 * Renesas R-Car USB phy driver
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/delay.h>
13#include <linux/io.h>
14#include <linux/usb/otg.h>
15#include <linux/platform_device.h>
16#include <linux/spinlock.h>
17#include <linux/module.h>
18
19/* USBH common register */
20#define USBPCTRL0 0x0800
21#define USBPCTRL1 0x0804
22#define USBST 0x0808
23#define USBEH0 0x080C
24#define USBOH0 0x081C
25#define USBCTL0 0x0858
26#define EIIBC1 0x0094
27#define EIIBC2 0x009C
28
29/* USBPCTRL1 */
30#define PHY_RST (1 << 2)
31#define PLL_ENB (1 << 1)
32#define PHY_ENB (1 << 0)
33
34/* USBST */
35#define ST_ACT (1 << 31)
36#define ST_PLL (1 << 30)
37
38struct rcar_usb_phy_priv {
39 struct usb_phy phy;
40 spinlock_t lock;
41
42 void __iomem *reg0;
43 void __iomem *reg1;
44 int counter;
45};
46
47#define usb_phy_to_priv(p) container_of(p, struct rcar_usb_phy_priv, phy)
48
49
50/*
51 * USB initial/install operation.
52 *
53 * This function setup USB phy.
54 * The used value and setting order came from
55 * [USB :: Initial setting] on datasheet.
56 */
57static int rcar_usb_phy_init(struct usb_phy *phy)
58{
59 struct rcar_usb_phy_priv *priv = usb_phy_to_priv(phy);
60 struct device *dev = phy->dev;
61 void __iomem *reg0 = priv->reg0;
62 void __iomem *reg1 = priv->reg1;
63 int i;
64 u32 val;
65 unsigned long flags;
66
67 spin_lock_irqsave(&priv->lock, flags);
68 if (priv->counter++ == 0) {
69
70 /*
71 * USB phy start-up
72 */
73
74 /* (1) USB-PHY standby release */
75 iowrite32(PHY_ENB, (reg0 + USBPCTRL1));
76
77 /* (2) start USB-PHY internal PLL */
78 iowrite32(PHY_ENB | PLL_ENB, (reg0 + USBPCTRL1));
79
80 /* (3) USB module status check */
81 for (i = 0; i < 1024; i++) {
82 udelay(10);
83 val = ioread32(reg0 + USBST);
84 if (val == (ST_ACT | ST_PLL))
85 break;
86 }
87
88 if (val != (ST_ACT | ST_PLL)) {
89 dev_err(dev, "USB phy not ready\n");
90 goto phy_init_end;
91 }
92
93 /* (4) USB-PHY reset clear */
94 iowrite32(PHY_ENB | PLL_ENB | PHY_RST, (reg0 + USBPCTRL1));
95
96 /* set platform specific port settings */
97 iowrite32(0x00000000, (reg0 + USBPCTRL0));
98
99 /*
100 * EHCI IP internal buffer setting
101 * EHCI IP internal buffer enable
102 *
103 * These are recommended value of a datasheet
104 * see [USB :: EHCI internal buffer setting]
105 */
106 iowrite32(0x00ff0040, (reg0 + EIIBC1));
107 iowrite32(0x00ff0040, (reg1 + EIIBC1));
108
109 iowrite32(0x00000001, (reg0 + EIIBC2));
110 iowrite32(0x00000001, (reg1 + EIIBC2));
111
112 /*
113 * Bus alignment settings
114 */
115
116 /* (1) EHCI bus alignment (little endian) */
117 iowrite32(0x00000000, (reg0 + USBEH0));
118
119 /* (1) OHCI bus alignment (little endian) */
120 iowrite32(0x00000000, (reg0 + USBOH0));
121 }
122
123phy_init_end:
124 spin_unlock_irqrestore(&priv->lock, flags);
125
126 return 0;
127}
128
129static void rcar_usb_phy_shutdown(struct usb_phy *phy)
130{
131 struct rcar_usb_phy_priv *priv = usb_phy_to_priv(phy);
132 void __iomem *reg0 = priv->reg0;
133 unsigned long flags;
134
135 spin_lock_irqsave(&priv->lock, flags);
136
137 if (priv->counter-- == 1) { /* last user */
138 iowrite32(0x00000000, (reg0 + USBPCTRL0));
139 iowrite32(0x00000000, (reg0 + USBPCTRL1));
140 }
141
142 spin_unlock_irqrestore(&priv->lock, flags);
143}
144
145static int rcar_usb_phy_probe(struct platform_device *pdev)
146{
147 struct rcar_usb_phy_priv *priv;
148 struct resource *res0, *res1;
149 struct device *dev = &pdev->dev;
150 void __iomem *reg0, *reg1;
151 int ret;
152
153 res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
154 res1 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
155 if (!res0 || !res1) {
156 dev_err(dev, "Not enough platform resources\n");
157 return -EINVAL;
158 }
159
160 /*
161 * CAUTION
162 *
163 * Because this phy address is also mapped under OHCI/EHCI address area,
164 * this driver can't use devm_request_and_ioremap(dev, res) here
165 */
166 reg0 = devm_ioremap_nocache(dev, res0->start, resource_size(res0));
167 reg1 = devm_ioremap_nocache(dev, res1->start, resource_size(res1));
168 if (!reg0 || !reg1) {
169 dev_err(dev, "ioremap error\n");
170 return -ENOMEM;
171 }
172
173 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
174 if (!priv) {
175 dev_err(dev, "priv data allocation error\n");
176 return -ENOMEM;
177 }
178
179 priv->reg0 = reg0;
180 priv->reg1 = reg1;
181 priv->counter = 0;
182 priv->phy.dev = dev;
183 priv->phy.label = dev_name(dev);
184 priv->phy.init = rcar_usb_phy_init;
185 priv->phy.shutdown = rcar_usb_phy_shutdown;
186 spin_lock_init(&priv->lock);
187
188 ret = usb_add_phy(&priv->phy, USB_PHY_TYPE_USB2);
189 if (ret < 0) {
190 dev_err(dev, "usb phy addition error\n");
191 return ret;
192 }
193
194 platform_set_drvdata(pdev, priv);
195
196 return ret;
197}
198
199static int rcar_usb_phy_remove(struct platform_device *pdev)
200{
201 struct rcar_usb_phy_priv *priv = platform_get_drvdata(pdev);
202
203 usb_remove_phy(&priv->phy);
204
205 return 0;
206}
207
208static struct platform_driver rcar_usb_phy_driver = {
209 .driver = {
210 .name = "rcar_usb_phy",
211 },
212 .probe = rcar_usb_phy_probe,
213 .remove = rcar_usb_phy_remove,
214};
215
216module_platform_driver(rcar_usb_phy_driver);
217
218MODULE_LICENSE("GPL v2");
219MODULE_DESCRIPTION("Renesas R-Car USB phy");
220MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index 987116f9efcd..9d13c81754e0 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -29,7 +29,9 @@
29#include <linux/usb/ulpi.h> 29#include <linux/usb/ulpi.h>
30#include <asm/mach-types.h> 30#include <asm/mach-types.h>
31#include <linux/usb/tegra_usb_phy.h> 31#include <linux/usb/tegra_usb_phy.h>
32#include <mach/iomap.h> 32
33#define TEGRA_USB_BASE 0xC5000000
34#define TEGRA_USB_SIZE SZ_16K
33 35
34#define ULPI_VIEWPORT 0x170 36#define ULPI_VIEWPORT 0x170
35 37
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 072edc1cc55f..38bce046f4d0 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -132,6 +132,11 @@ void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable)
132 usbhs_bset(priv, SYSCFG, mask, enable ? val : 0); 132 usbhs_bset(priv, SYSCFG, mask, enable ? val : 0);
133} 133}
134 134
135void usbhs_sys_function_pullup(struct usbhs_priv *priv, int enable)
136{
137 usbhs_bset(priv, SYSCFG, DPRPU, enable ? DPRPU : 0);
138}
139
135void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode) 140void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode)
136{ 141{
137 usbhs_write(priv, TESTMODE, mode); 142 usbhs_write(priv, TESTMODE, mode);
@@ -551,7 +556,7 @@ probe_end_pipe_exit:
551 return ret; 556 return ret;
552} 557}
553 558
554static int __devexit usbhs_remove(struct platform_device *pdev) 559static int usbhs_remove(struct platform_device *pdev)
555{ 560{
556 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); 561 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
557 struct renesas_usbhs_platform_info *info = pdev->dev.platform_data; 562 struct renesas_usbhs_platform_info *info = pdev->dev.platform_data;
@@ -631,7 +636,7 @@ static struct platform_driver renesas_usbhs_driver = {
631 .pm = &usbhsc_pm_ops, 636 .pm = &usbhsc_pm_ops,
632 }, 637 },
633 .probe = usbhs_probe, 638 .probe = usbhs_probe,
634 .remove = __devexit_p(usbhs_remove), 639 .remove = usbhs_remove,
635}; 640};
636 641
637module_platform_driver(renesas_usbhs_driver); 642module_platform_driver(renesas_usbhs_driver);
diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h
index dddf40a59ded..c69dd2fba360 100644
--- a/drivers/usb/renesas_usbhs/common.h
+++ b/drivers/usb/renesas_usbhs/common.h
@@ -285,6 +285,7 @@ void usbhs_bset(struct usbhs_priv *priv, u32 reg, u16 mask, u16 data);
285 */ 285 */
286void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable); 286void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable);
287void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable); 287void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable);
288void usbhs_sys_function_pullup(struct usbhs_priv *priv, int enable);
288void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode); 289void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode);
289 290
290/* 291/*
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index c021b202c0f3..9538f0feafe2 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -163,7 +163,7 @@ static int usbhsf_pkt_handler(struct usbhs_pipe *pipe, int type)
163 func = pkt->handler->dma_done; 163 func = pkt->handler->dma_done;
164 break; 164 break;
165 default: 165 default:
166 dev_err(dev, "unknown pkt hander\n"); 166 dev_err(dev, "unknown pkt handler\n");
167 goto __usbhs_pkt_handler_end; 167 goto __usbhs_pkt_handler_end;
168 } 168 }
169 169
@@ -192,8 +192,8 @@ void usbhs_pkt_start(struct usbhs_pipe *pipe)
192/* 192/*
193 * irq enable/disable function 193 * irq enable/disable function
194 */ 194 */
195#define usbhsf_irq_empty_ctrl(p, e) usbhsf_irq_callback_ctrl(p, bempsts, e) 195#define usbhsf_irq_empty_ctrl(p, e) usbhsf_irq_callback_ctrl(p, irq_bempsts, e)
196#define usbhsf_irq_ready_ctrl(p, e) usbhsf_irq_callback_ctrl(p, brdysts, e) 196#define usbhsf_irq_ready_ctrl(p, e) usbhsf_irq_callback_ctrl(p, irq_brdysts, e)
197#define usbhsf_irq_callback_ctrl(pipe, status, enable) \ 197#define usbhsf_irq_callback_ctrl(pipe, status, enable) \
198 ({ \ 198 ({ \
199 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); \ 199 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); \
@@ -202,9 +202,9 @@ void usbhs_pkt_start(struct usbhs_pipe *pipe)
202 if (!mod) \ 202 if (!mod) \
203 return; \ 203 return; \
204 if (enable) \ 204 if (enable) \
205 mod->irq_##status |= status; \ 205 mod->status |= status; \
206 else \ 206 else \
207 mod->irq_##status &= ~status; \ 207 mod->status &= ~status; \
208 usbhs_irq_callback_update(priv, mod); \ 208 usbhs_irq_callback_update(priv, mod); \
209 }) 209 })
210 210
@@ -488,6 +488,8 @@ static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int *is_done)
488 usbhs_pipe_data_sequence(pipe, pkt->sequence); 488 usbhs_pipe_data_sequence(pipe, pkt->sequence);
489 pkt->sequence = -1; /* -1 sequence will be ignored */ 489 pkt->sequence = -1; /* -1 sequence will be ignored */
490 490
491 usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->length);
492
491 ret = usbhsf_fifo_select(pipe, fifo, 1); 493 ret = usbhsf_fifo_select(pipe, fifo, 1);
492 if (ret < 0) 494 if (ret < 0)
493 return 0; 495 return 0;
@@ -594,6 +596,7 @@ static int usbhsf_prepare_pop(struct usbhs_pkt *pkt, int *is_done)
594 usbhs_pipe_data_sequence(pipe, pkt->sequence); 596 usbhs_pipe_data_sequence(pipe, pkt->sequence);
595 pkt->sequence = -1; /* -1 sequence will be ignored */ 597 pkt->sequence = -1; /* -1 sequence will be ignored */
596 598
599 usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->length);
597 usbhs_pipe_enable(pipe); 600 usbhs_pipe_enable(pipe);
598 usbhsf_rx_irq_ctrl(pipe, 1); 601 usbhsf_rx_irq_ctrl(pipe, 1);
599 602
@@ -795,6 +798,7 @@ static void xfer_work(struct work_struct *work)
795 dev_dbg(dev, " %s %d (%d/ %d)\n", 798 dev_dbg(dev, " %s %d (%d/ %d)\n",
796 fifo->name, usbhs_pipe_number(pipe), pkt->length, pkt->zero); 799 fifo->name, usbhs_pipe_number(pipe), pkt->length, pkt->zero);
797 800
801 usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->trans);
798 usbhs_pipe_enable(pipe); 802 usbhs_pipe_enable(pipe);
799 usbhsf_dma_start(pipe, fifo); 803 usbhsf_dma_start(pipe, fifo);
800 dma_async_issue_pending(chan); 804 dma_async_issue_pending(chan);
diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c
index 61933a90e5bf..6a030b931a3b 100644
--- a/drivers/usb/renesas_usbhs/mod.c
+++ b/drivers/usb/renesas_usbhs/mod.c
@@ -151,7 +151,7 @@ int usbhs_mod_probe(struct usbhs_priv *priv)
151 goto mod_init_host_err; 151 goto mod_init_host_err;
152 152
153 /* irq settings */ 153 /* irq settings */
154 ret = request_irq(priv->irq, usbhs_interrupt, 154 ret = devm_request_irq(dev, priv->irq, usbhs_interrupt,
155 priv->irqflags, dev_name(dev), priv); 155 priv->irqflags, dev_name(dev), priv);
156 if (ret) { 156 if (ret) {
157 dev_err(dev, "irq request err\n"); 157 dev_err(dev, "irq request err\n");
@@ -172,7 +172,6 @@ void usbhs_mod_remove(struct usbhs_priv *priv)
172{ 172{
173 usbhs_mod_host_remove(priv); 173 usbhs_mod_host_remove(priv);
174 usbhs_mod_gadget_remove(priv); 174 usbhs_mod_gadget_remove(priv);
175 free_irq(priv->irq, priv);
176} 175}
177 176
178/* 177/*
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
index 28478ce26c34..dd41f61893ef 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -883,6 +883,16 @@ static int usbhsg_get_frame(struct usb_gadget *gadget)
883 return usbhs_frame_get_num(priv); 883 return usbhs_frame_get_num(priv);
884} 884}
885 885
886static int usbhsg_pullup(struct usb_gadget *gadget, int is_on)
887{
888 struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget);
889 struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
890
891 usbhs_sys_function_pullup(priv, is_on);
892
893 return 0;
894}
895
886static int usbhsg_set_selfpowered(struct usb_gadget *gadget, int is_self) 896static int usbhsg_set_selfpowered(struct usb_gadget *gadget, int is_self)
887{ 897{
888 struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); 898 struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget);
@@ -900,6 +910,7 @@ static struct usb_gadget_ops usbhsg_gadget_ops = {
900 .set_selfpowered = usbhsg_set_selfpowered, 910 .set_selfpowered = usbhsg_set_selfpowered,
901 .udc_start = usbhsg_gadget_start, 911 .udc_start = usbhsg_gadget_start,
902 .udc_stop = usbhsg_gadget_stop, 912 .udc_stop = usbhsg_gadget_stop,
913 .pullup = usbhsg_pullup,
903}; 914};
904 915
905static int usbhsg_start(struct usbhs_priv *priv) 916static int usbhsg_start(struct usbhs_priv *priv)
diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c
index 069cd765400c..3d3cd6ca2689 100644
--- a/drivers/usb/renesas_usbhs/mod_host.c
+++ b/drivers/usb/renesas_usbhs/mod_host.c
@@ -85,6 +85,7 @@ struct usbhsh_ep {
85 struct usbhsh_device *udev; /* attached udev */ 85 struct usbhsh_device *udev; /* attached udev */
86 struct usb_host_endpoint *ep; 86 struct usb_host_endpoint *ep;
87 struct list_head ep_list; /* list to usbhsh_device */ 87 struct list_head ep_list; /* list to usbhsh_device */
88 unsigned int counter; /* pipe attach counter */
88}; 89};
89 90
90#define USBHSH_DEVICE_MAX 10 /* see DEVADDn / DCPMAXP / PIPEMAXP */ 91#define USBHSH_DEVICE_MAX 10 /* see DEVADDn / DCPMAXP / PIPEMAXP */
@@ -271,8 +272,12 @@ static int usbhsh_pipe_attach(struct usbhsh_hpriv *hpriv,
271 /******************** spin lock ********************/ 272 /******************** spin lock ********************/
272 usbhs_lock(priv, flags); 273 usbhs_lock(priv, flags);
273 274
274 if (unlikely(usbhsh_uep_to_pipe(uep))) { 275 /*
275 dev_err(dev, "uep already has pipe\n"); 276 * if uep has been attached to pipe,
277 * reuse it
278 */
279 if (usbhsh_uep_to_pipe(uep)) {
280 ret = 0;
276 goto usbhsh_pipe_attach_done; 281 goto usbhsh_pipe_attach_done;
277 } 282 }
278 283
@@ -320,6 +325,9 @@ static int usbhsh_pipe_attach(struct usbhsh_hpriv *hpriv,
320 } 325 }
321 326
322usbhsh_pipe_attach_done: 327usbhsh_pipe_attach_done:
328 if (0 == ret)
329 uep->counter++;
330
323 usbhs_unlock(priv, flags); 331 usbhs_unlock(priv, flags);
324 /******************** spin unlock ******************/ 332 /******************** spin unlock ******************/
325 333
@@ -346,7 +354,7 @@ static void usbhsh_pipe_detach(struct usbhsh_hpriv *hpriv,
346 354
347 if (unlikely(!pipe)) { 355 if (unlikely(!pipe)) {
348 dev_err(dev, "uep doens't have pipe\n"); 356 dev_err(dev, "uep doens't have pipe\n");
349 } else { 357 } else if (1 == uep->counter--) { /* last user */
350 struct usb_host_endpoint *ep = usbhsh_uep_to_ep(uep); 358 struct usb_host_endpoint *ep = usbhsh_uep_to_ep(uep);
351 struct usbhsh_device *udev = usbhsh_uep_to_udev(uep); 359 struct usbhsh_device *udev = usbhsh_uep_to_udev(uep);
352 360
@@ -391,6 +399,7 @@ static int usbhsh_endpoint_attach(struct usbhsh_hpriv *hpriv,
391 /* 399 /*
392 * init endpoint 400 * init endpoint
393 */ 401 */
402 uep->counter = 0;
394 INIT_LIST_HEAD(&uep->ep_list); 403 INIT_LIST_HEAD(&uep->ep_list);
395 list_add_tail(&uep->ep_list, &udev->ep_list_head); 404 list_add_tail(&uep->ep_list, &udev->ep_list_head);
396 405
@@ -686,9 +695,9 @@ static int usbhsh_queue_push(struct usb_hcd *hcd,
686 } 695 }
687 696
688 if (usb_pipein(urb->pipe)) 697 if (usb_pipein(urb->pipe))
689 pipe->handler = &usbhs_fifo_pio_pop_handler; 698 pipe->handler = &usbhs_fifo_dma_pop_handler;
690 else 699 else
691 pipe->handler = &usbhs_fifo_pio_push_handler; 700 pipe->handler = &usbhs_fifo_dma_push_handler;
692 701
693 buf = (void *)(urb->transfer_buffer + urb->actual_length); 702 buf = (void *)(urb->transfer_buffer + urb->actual_length);
694 len = urb->transfer_buffer_length - urb->actual_length; 703 len = urb->transfer_buffer_length - urb->actual_length;
@@ -921,6 +930,19 @@ static int usbhsh_dcp_queue_push(struct usb_hcd *hcd,
921 */ 930 */
922static int usbhsh_dma_map_ctrl(struct usbhs_pkt *pkt, int map) 931static int usbhsh_dma_map_ctrl(struct usbhs_pkt *pkt, int map)
923{ 932{
933 if (map) {
934 struct usbhsh_request *ureq = usbhsh_pkt_to_ureq(pkt);
935 struct urb *urb = ureq->urb;
936
937 /* it can not use scatter/gather */
938 if (urb->num_sgs)
939 return -EINVAL;
940
941 pkt->dma = urb->transfer_dma;
942 if (!pkt->dma)
943 return -EINVAL;
944 }
945
924 return 0; 946 return 0;
925} 947}
926 948
@@ -946,7 +968,6 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd,
946 struct usb_host_endpoint *ep = urb->ep; 968 struct usb_host_endpoint *ep = urb->ep;
947 struct usbhsh_device *new_udev = NULL; 969 struct usbhsh_device *new_udev = NULL;
948 int is_dir_in = usb_pipein(urb->pipe); 970 int is_dir_in = usb_pipein(urb->pipe);
949 int i;
950 int ret; 971 int ret;
951 972
952 dev_dbg(dev, "%s (%s)\n", __func__, is_dir_in ? "in" : "out"); 973 dev_dbg(dev, "%s (%s)\n", __func__, is_dir_in ? "in" : "out");
@@ -992,13 +1013,7 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd,
992 * attach pipe to endpoint 1013 * attach pipe to endpoint
993 * see [image of mod_host] 1014 * see [image of mod_host]
994 */ 1015 */
995 for (i = 0; i < 1024; i++) { 1016 ret = usbhsh_pipe_attach(hpriv, urb);
996 ret = usbhsh_pipe_attach(hpriv, urb);
997 if (ret < 0)
998 msleep(100);
999 else
1000 break;
1001 }
1002 if (ret < 0) { 1017 if (ret < 0) {
1003 dev_err(dev, "pipe attach failed\n"); 1018 dev_err(dev, "pipe attach failed\n");
1004 goto usbhsh_urb_enqueue_error_free_endpoint; 1019 goto usbhsh_urb_enqueue_error_free_endpoint;
@@ -1072,8 +1087,6 @@ static void usbhsh_endpoint_disable(struct usb_hcd *hcd,
1072static int usbhsh_hub_status_data(struct usb_hcd *hcd, char *buf) 1087static int usbhsh_hub_status_data(struct usb_hcd *hcd, char *buf)
1073{ 1088{
1074 struct usbhsh_hpriv *hpriv = usbhsh_hcd_to_hpriv(hcd); 1089 struct usbhsh_hpriv *hpriv = usbhsh_hcd_to_hpriv(hcd);
1075 struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv);
1076 struct device *dev = usbhs_priv_to_dev(priv);
1077 int roothub_id = 1; /* only 1 root hub */ 1090 int roothub_id = 1; /* only 1 root hub */
1078 1091
1079 /* 1092 /*
@@ -1085,8 +1098,6 @@ static int usbhsh_hub_status_data(struct usb_hcd *hcd, char *buf)
1085 else 1098 else
1086 *buf = 0; 1099 *buf = 0;
1087 1100
1088 dev_dbg(dev, "%s (%02x)\n", __func__, *buf);
1089
1090 return !!(*buf); 1101 return !!(*buf);
1091} 1102}
1092 1103
diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c
index 122526cfd32b..7926e1c700f1 100644
--- a/drivers/usb/renesas_usbhs/pipe.c
+++ b/drivers/usb/renesas_usbhs/pipe.c
@@ -93,6 +93,82 @@ static void usbhsp_pipe_cfg_set(struct usbhs_pipe *pipe, u16 mask, u16 val)
93} 93}
94 94
95/* 95/*
96 * PIPEnTRN/PIPEnTRE functions
97 */
98static void usbhsp_pipe_trn_set(struct usbhs_pipe *pipe, u16 mask, u16 val)
99{
100 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
101 struct device *dev = usbhs_priv_to_dev(priv);
102 int num = usbhs_pipe_number(pipe);
103 u16 reg;
104
105 /*
106 * It is impossible to calculate address,
107 * since PIPEnTRN addresses were mapped randomly.
108 */
109#define CASE_PIPExTRN(a) \
110 case 0x ## a: \
111 reg = PIPE ## a ## TRN; \
112 break;
113
114 switch (num) {
115 CASE_PIPExTRN(1);
116 CASE_PIPExTRN(2);
117 CASE_PIPExTRN(3);
118 CASE_PIPExTRN(4);
119 CASE_PIPExTRN(5);
120 CASE_PIPExTRN(B);
121 CASE_PIPExTRN(C);
122 CASE_PIPExTRN(D);
123 CASE_PIPExTRN(E);
124 CASE_PIPExTRN(F);
125 CASE_PIPExTRN(9);
126 CASE_PIPExTRN(A);
127 default:
128 dev_err(dev, "unknown pipe (%d)\n", num);
129 return;
130 }
131 __usbhsp_pipe_xxx_set(pipe, 0, reg, mask, val);
132}
133
134static void usbhsp_pipe_tre_set(struct usbhs_pipe *pipe, u16 mask, u16 val)
135{
136 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
137 struct device *dev = usbhs_priv_to_dev(priv);
138 int num = usbhs_pipe_number(pipe);
139 u16 reg;
140
141 /*
142 * It is impossible to calculate address,
143 * since PIPEnTRE addresses were mapped randomly.
144 */
145#define CASE_PIPExTRE(a) \
146 case 0x ## a: \
147 reg = PIPE ## a ## TRE; \
148 break;
149
150 switch (num) {
151 CASE_PIPExTRE(1);
152 CASE_PIPExTRE(2);
153 CASE_PIPExTRE(3);
154 CASE_PIPExTRE(4);
155 CASE_PIPExTRE(5);
156 CASE_PIPExTRE(B);
157 CASE_PIPExTRE(C);
158 CASE_PIPExTRE(D);
159 CASE_PIPExTRE(E);
160 CASE_PIPExTRE(F);
161 CASE_PIPExTRE(9);
162 CASE_PIPExTRE(A);
163 default:
164 dev_err(dev, "unknown pipe (%d)\n", num);
165 return;
166 }
167
168 __usbhsp_pipe_xxx_set(pipe, 0, reg, mask, val);
169}
170
171/*
96 * PIPEBUF 172 * PIPEBUF
97 */ 173 */
98static void usbhsp_pipe_buf_set(struct usbhs_pipe *pipe, u16 mask, u16 val) 174static void usbhsp_pipe_buf_set(struct usbhs_pipe *pipe, u16 mask, u16 val)
@@ -264,6 +340,31 @@ int usbhs_pipe_is_stall(struct usbhs_pipe *pipe)
264 return (int)(pid == PID_STALL10 || pid == PID_STALL11); 340 return (int)(pid == PID_STALL10 || pid == PID_STALL11);
265} 341}
266 342
343void usbhs_pipe_set_trans_count_if_bulk(struct usbhs_pipe *pipe, int len)
344{
345 if (!usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_BULK))
346 return;
347
348 /*
349 * clear and disable transfer counter for IN/OUT pipe
350 */
351 usbhsp_pipe_tre_set(pipe, TRCLR | TRENB, TRCLR);
352
353 /*
354 * Only IN direction bulk pipe can use transfer count.
355 * Without using this function,
356 * received data will break if it was large data size.
357 * see PIPEnTRN/PIPEnTRE for detail
358 */
359 if (usbhs_pipe_is_dir_in(pipe)) {
360 int maxp = usbhs_pipe_get_maxpacket(pipe);
361
362 usbhsp_pipe_trn_set(pipe, 0xffff, DIV_ROUND_UP(len, maxp));
363 usbhsp_pipe_tre_set(pipe, TRENB, TRENB); /* enable */
364 }
365}
366
367
267/* 368/*
268 * pipe setup 369 * pipe setup
269 */ 370 */
diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h
index 3d80c7b1fd1b..b476fde955bf 100644
--- a/drivers/usb/renesas_usbhs/pipe.h
+++ b/drivers/usb/renesas_usbhs/pipe.h
@@ -88,6 +88,7 @@ void usbhs_pipe_enable(struct usbhs_pipe *pipe);
88void usbhs_pipe_disable(struct usbhs_pipe *pipe); 88void usbhs_pipe_disable(struct usbhs_pipe *pipe);
89void usbhs_pipe_stall(struct usbhs_pipe *pipe); 89void usbhs_pipe_stall(struct usbhs_pipe *pipe);
90int usbhs_pipe_is_stall(struct usbhs_pipe *pipe); 90int usbhs_pipe_is_stall(struct usbhs_pipe *pipe);
91void usbhs_pipe_set_trans_count_if_bulk(struct usbhs_pipe *pipe, int len);
91void usbhs_pipe_select_fifo(struct usbhs_pipe *pipe, struct usbhs_fifo *fifo); 92void usbhs_pipe_select_fifo(struct usbhs_pipe *pipe, struct usbhs_fifo *fifo);
92void usbhs_pipe_config_update(struct usbhs_pipe *pipe, u16 devsel, 93void usbhs_pipe_config_update(struct usbhs_pipe *pipe, u16 devsel,
93 u16 epnum, u16 maxp); 94 u16 epnum, u16 maxp);
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index 54e1bb6372e7..6d110a3bc7e7 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -68,10 +68,6 @@
68#define THROTTLED 0x01 68#define THROTTLED 0x01
69#define ACTUALLY_THROTTLED 0x02 69#define ACTUALLY_THROTTLED 0x02
70 70
71/*
72 * Version Information
73 */
74#define DRIVER_VERSION "v2.0"
75#define DRIVER_AUTHOR "Naranjo, Manuel Francisco <naranjo.manuel@gmail.com>, Johan Hovold <jhovold@gmail.com>" 71#define DRIVER_AUTHOR "Naranjo, Manuel Francisco <naranjo.manuel@gmail.com>, Johan Hovold <jhovold@gmail.com>"
76#define DRIVER_DESC "AIRcable USB Driver" 72#define DRIVER_DESC "AIRcable USB Driver"
77 73
@@ -192,5 +188,4 @@ module_usb_serial_driver(serial_drivers, id_table);
192 188
193MODULE_AUTHOR(DRIVER_AUTHOR); 189MODULE_AUTHOR(DRIVER_AUTHOR);
194MODULE_DESCRIPTION(DRIVER_DESC); 190MODULE_DESCRIPTION(DRIVER_DESC);
195MODULE_VERSION(DRIVER_VERSION);
196MODULE_LICENSE("GPL"); 191MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index bd50a8a41a0f..a88882c0e237 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -37,11 +37,6 @@
37#include <linux/mutex.h> 37#include <linux/mutex.h>
38#include <linux/spinlock.h> 38#include <linux/spinlock.h>
39 39
40/*
41 * Version information
42 */
43
44#define DRIVER_VERSION "v0.7"
45#define DRIVER_AUTHOR "Bart Hartgers <bart.hartgers+ark3116@gmail.com>" 40#define DRIVER_AUTHOR "Bart Hartgers <bart.hartgers+ark3116@gmail.com>"
46#define DRIVER_DESC "USB ARK3116 serial/IrDA driver" 41#define DRIVER_DESC "USB ARK3116 serial/IrDA driver"
47#define DRIVER_DEV_DESC "ARK3116 RS232/IrDA" 42#define DRIVER_DEV_DESC "ARK3116 RS232/IrDA"
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index ea29556f0d72..b72a4c166705 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -37,10 +37,6 @@
37#include <linux/usb/serial.h> 37#include <linux/usb/serial.h>
38#include "belkin_sa.h" 38#include "belkin_sa.h"
39 39
40/*
41 * Version Information
42 */
43#define DRIVER_VERSION "v1.3"
44#define DRIVER_AUTHOR "William Greathouse <wgreathouse@smva.com>" 40#define DRIVER_AUTHOR "William Greathouse <wgreathouse@smva.com>"
45#define DRIVER_DESC "USB Belkin Serial converter driver" 41#define DRIVER_DESC "USB Belkin Serial converter driver"
46 42
@@ -509,5 +505,4 @@ module_usb_serial_driver(serial_drivers, id_table);
509 505
510MODULE_AUTHOR(DRIVER_AUTHOR); 506MODULE_AUTHOR(DRIVER_AUTHOR);
511MODULE_DESCRIPTION(DRIVER_DESC); 507MODULE_DESCRIPTION(DRIVER_DESC);
512MODULE_VERSION(DRIVER_VERSION);
513MODULE_LICENSE("GPL"); 508MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index c15f2e7cefc7..37decb13d7eb 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -121,7 +121,6 @@ static int usb_serial_device_remove(struct device *dev)
121 return retval; 121 return retval;
122} 122}
123 123
124#ifdef CONFIG_HOTPLUG
125static ssize_t store_new_id(struct device_driver *driver, 124static ssize_t store_new_id(struct device_driver *driver,
126 const char *buf, size_t count) 125 const char *buf, size_t count)
127{ 126{
@@ -159,15 +158,6 @@ static void free_dynids(struct usb_serial_driver *drv)
159 spin_unlock(&drv->dynids.lock); 158 spin_unlock(&drv->dynids.lock);
160} 159}
161 160
162#else
163static struct driver_attribute drv_attrs[] = {
164 __ATTR_NULL,
165};
166static inline void free_dynids(struct usb_serial_driver *drv)
167{
168}
169#endif
170
171struct bus_type usb_serial_bus_type = { 161struct bus_type usb_serial_bus_type = {
172 .name = "usb-serial", 162 .name = "usb-serial",
173 .match = usb_serial_device_match, 163 .match = usb_serial_device_match,
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index eb033fc92a15..f14736f647ff 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -24,10 +24,6 @@
24#include <linux/uaccess.h> 24#include <linux/uaccess.h>
25#include <linux/usb/serial.h> 25#include <linux/usb/serial.h>
26 26
27/*
28 * Version Information
29 */
30#define DRIVER_VERSION "v0.09"
31#define DRIVER_DESC "Silicon Labs CP210x RS232 serial adaptor driver" 27#define DRIVER_DESC "Silicon Labs CP210x RS232 serial adaptor driver"
32 28
33/* 29/*
@@ -35,8 +31,7 @@
35 */ 31 */
36static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *); 32static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *);
37static void cp210x_close(struct usb_serial_port *); 33static void cp210x_close(struct usb_serial_port *);
38static void cp210x_get_termios(struct tty_struct *, 34static void cp210x_get_termios(struct tty_struct *, struct usb_serial_port *);
39 struct usb_serial_port *port);
40static void cp210x_get_termios_port(struct usb_serial_port *port, 35static void cp210x_get_termios_port(struct usb_serial_port *port,
41 unsigned int *cflagp, unsigned int *baudp); 36 unsigned int *cflagp, unsigned int *baudp);
42static void cp210x_change_speed(struct tty_struct *, struct usb_serial_port *, 37static void cp210x_change_speed(struct tty_struct *, struct usb_serial_port *,
@@ -118,6 +113,7 @@ static const struct usb_device_id id_table[] = {
118 { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */ 113 { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */
119 { USB_DEVICE(0x10C4, 0x85EA) }, /* AC-Services IBUS-IF */ 114 { USB_DEVICE(0x10C4, 0x85EA) }, /* AC-Services IBUS-IF */
120 { USB_DEVICE(0x10C4, 0x85EB) }, /* AC-Services CIS-IBUS */ 115 { USB_DEVICE(0x10C4, 0x85EB) }, /* AC-Services CIS-IBUS */
116 { USB_DEVICE(0x10C4, 0x85F8) }, /* Virtenio Preon32 */
121 { USB_DEVICE(0x10C4, 0x8664) }, /* AC-Services CAN-IF */ 117 { USB_DEVICE(0x10C4, 0x8664) }, /* AC-Services CAN-IF */
122 { USB_DEVICE(0x10C4, 0x8665) }, /* AC-Services OBD-IF */ 118 { USB_DEVICE(0x10C4, 0x8665) }, /* AC-Services OBD-IF */
123 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 119 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
@@ -169,7 +165,7 @@ struct cp210x_serial_private {
169static struct usb_serial_driver cp210x_device = { 165static struct usb_serial_driver cp210x_device = {
170 .driver = { 166 .driver = {
171 .owner = THIS_MODULE, 167 .owner = THIS_MODULE,
172 .name = "cp210x", 168 .name = "cp210x",
173 }, 169 },
174 .id_table = id_table, 170 .id_table = id_table,
175 .num_ports = 1, 171 .num_ports = 1,
@@ -179,7 +175,7 @@ static struct usb_serial_driver cp210x_device = {
179 .close = cp210x_close, 175 .close = cp210x_close,
180 .break_ctl = cp210x_break_ctl, 176 .break_ctl = cp210x_break_ctl,
181 .set_termios = cp210x_set_termios, 177 .set_termios = cp210x_set_termios,
182 .tiocmget = cp210x_tiocmget, 178 .tiocmget = cp210x_tiocmget,
183 .tiocmset = cp210x_tiocmset, 179 .tiocmset = cp210x_tiocmset,
184 .attach = cp210x_startup, 180 .attach = cp210x_startup,
185 .release = cp210x_release, 181 .release = cp210x_release,
@@ -281,7 +277,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request,
281 int result, i, length; 277 int result, i, length;
282 278
283 /* Number of integers required to contain the array */ 279 /* Number of integers required to contain the array */
284 length = (((size - 1) | 3) + 1)/4; 280 length = (((size - 1) | 3) + 1) / 4;
285 281
286 buf = kcalloc(length, sizeof(__le32), GFP_KERNEL); 282 buf = kcalloc(length, sizeof(__le32), GFP_KERNEL);
287 if (!buf) { 283 if (!buf) {
@@ -328,12 +324,11 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
328 int result, i, length; 324 int result, i, length;
329 325
330 /* Number of integers required to contain the array */ 326 /* Number of integers required to contain the array */
331 length = (((size - 1) | 3) + 1)/4; 327 length = (((size - 1) | 3) + 1) / 4;
332 328
333 buf = kmalloc(length * sizeof(__le32), GFP_KERNEL); 329 buf = kmalloc(length * sizeof(__le32), GFP_KERNEL);
334 if (!buf) { 330 if (!buf) {
335 dev_err(&port->dev, "%s - out of memory.\n", 331 dev_err(&port->dev, "%s - out of memory.\n", __func__);
336 __func__);
337 return -ENOMEM; 332 return -ENOMEM;
338 } 333 }
339 334
@@ -384,7 +379,8 @@ static inline int cp210x_set_config_single(struct usb_serial_port *port,
384 * cp210x_quantise_baudrate 379 * cp210x_quantise_baudrate
385 * Quantises the baud rate as per AN205 Table 1 380 * Quantises the baud rate as per AN205 Table 1
386 */ 381 */
387static unsigned int cp210x_quantise_baudrate(unsigned int baud) { 382static unsigned int cp210x_quantise_baudrate(unsigned int baud)
383{
388 if (baud <= 300) 384 if (baud <= 300)
389 baud = 300; 385 baud = 300;
390 else if (baud <= 600) baud = 600; 386 else if (baud <= 600) baud = 600;
@@ -467,9 +463,7 @@ static void cp210x_get_termios(struct tty_struct *tty,
467 cp210x_get_termios_port(tty->driver_data, 463 cp210x_get_termios_port(tty->driver_data,
468 &tty->termios.c_cflag, &baud); 464 &tty->termios.c_cflag, &baud);
469 tty_encode_baud_rate(tty, baud, baud); 465 tty_encode_baud_rate(tty, baud, baud);
470 } 466 } else {
471
472 else {
473 unsigned int cflag; 467 unsigned int cflag;
474 cflag = 0; 468 cflag = 0;
475 cp210x_get_termios_port(port, &cflag, &baud); 469 cp210x_get_termios_port(port, &cflag, &baud);
@@ -693,8 +687,8 @@ static void cp210x_set_termios(struct tty_struct *tty,
693 break;*/ 687 break;*/
694 default: 688 default:
695 dev_dbg(dev, "cp210x driver does not support the number of bits requested, using 8 bit mode\n"); 689 dev_dbg(dev, "cp210x driver does not support the number of bits requested, using 8 bit mode\n");
696 bits |= BITS_DATA_8; 690 bits |= BITS_DATA_8;
697 break; 691 break;
698 } 692 }
699 if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) 693 if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2))
700 dev_dbg(dev, "Number of data bits requested not supported by device\n"); 694 dev_dbg(dev, "Number of data bits requested not supported by device\n");
@@ -767,7 +761,7 @@ static void cp210x_set_termios(struct tty_struct *tty,
767 761
768} 762}
769 763
770static int cp210x_tiocmset (struct tty_struct *tty, 764static int cp210x_tiocmset(struct tty_struct *tty,
771 unsigned int set, unsigned int clear) 765 unsigned int set, unsigned int clear)
772{ 766{
773 struct usb_serial_port *port = tty->driver_data; 767 struct usb_serial_port *port = tty->driver_data;
@@ -809,7 +803,7 @@ static void cp210x_dtr_rts(struct usb_serial_port *p, int on)
809 cp210x_tiocmset_port(p, 0, TIOCM_DTR|TIOCM_RTS); 803 cp210x_tiocmset_port(p, 0, TIOCM_DTR|TIOCM_RTS);
810} 804}
811 805
812static int cp210x_tiocmget (struct tty_struct *tty) 806static int cp210x_tiocmget(struct tty_struct *tty)
813{ 807{
814 struct usb_serial_port *port = tty->driver_data; 808 struct usb_serial_port *port = tty->driver_data;
815 unsigned int control; 809 unsigned int control;
@@ -829,7 +823,7 @@ static int cp210x_tiocmget (struct tty_struct *tty)
829 return result; 823 return result;
830} 824}
831 825
832static void cp210x_break_ctl (struct tty_struct *tty, int break_state) 826static void cp210x_break_ctl(struct tty_struct *tty, int break_state)
833{ 827{
834 struct usb_serial_port *port = tty->driver_data; 828 struct usb_serial_port *port = tty->driver_data;
835 unsigned int state; 829 unsigned int state;
@@ -874,5 +868,4 @@ static void cp210x_release(struct usb_serial *serial)
874module_usb_serial_driver(serial_drivers, id_table); 868module_usb_serial_driver(serial_drivers, id_table);
875 869
876MODULE_DESCRIPTION(DRIVER_DESC); 870MODULE_DESCRIPTION(DRIVER_DESC);
877MODULE_VERSION(DRIVER_VERSION);
878MODULE_LICENSE("GPL"); 871MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index 4ee77dcbe690..69a4fa1cee25 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -43,10 +43,6 @@
43 43
44#define CYBERJACK_LOCAL_BUF_SIZE 32 44#define CYBERJACK_LOCAL_BUF_SIZE 32
45 45
46/*
47 * Version Information
48 */
49#define DRIVER_VERSION "v1.01"
50#define DRIVER_AUTHOR "Matthias Bruestle" 46#define DRIVER_AUTHOR "Matthias Bruestle"
51#define DRIVER_DESC "REINER SCT cyberJack pinpad/e-com USB Chipcard Reader Driver" 47#define DRIVER_DESC "REINER SCT cyberJack pinpad/e-com USB Chipcard Reader Driver"
52 48
@@ -441,5 +437,4 @@ module_usb_serial_driver(serial_drivers, id_table);
441 437
442MODULE_AUTHOR(DRIVER_AUTHOR); 438MODULE_AUTHOR(DRIVER_AUTHOR);
443MODULE_DESCRIPTION(DRIVER_DESC); 439MODULE_DESCRIPTION(DRIVER_DESC);
444MODULE_VERSION(DRIVER_VERSION);
445MODULE_LICENSE("GPL"); 440MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index f0da1279c114..fd8c35fd452e 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -50,10 +50,6 @@ static bool stats;
50static int interval; 50static int interval;
51static bool unstable_bauds; 51static bool unstable_bauds;
52 52
53/*
54 * Version Information
55 */
56#define DRIVER_VERSION "v1.10"
57#define DRIVER_AUTHOR "Lonnie Mendez <dignome@gmail.com>, Neil Whelchel <koyama@firstlight.net>" 53#define DRIVER_AUTHOR "Lonnie Mendez <dignome@gmail.com>, Neil Whelchel <koyama@firstlight.net>"
58#define DRIVER_DESC "Cypress USB to Serial Driver" 54#define DRIVER_DESC "Cypress USB to Serial Driver"
59 55
@@ -1303,7 +1299,6 @@ module_usb_serial_driver(serial_drivers, id_table_combined);
1303 1299
1304MODULE_AUTHOR(DRIVER_AUTHOR); 1300MODULE_AUTHOR(DRIVER_AUTHOR);
1305MODULE_DESCRIPTION(DRIVER_DESC); 1301MODULE_DESCRIPTION(DRIVER_DESC);
1306MODULE_VERSION(DRIVER_VERSION);
1307MODULE_LICENSE("GPL"); 1302MODULE_LICENSE("GPL");
1308 1303
1309module_param(stats, bool, S_IRUGO | S_IWUSR); 1304module_param(stats, bool, S_IRUGO | S_IWUSR);
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index b50fa1c6d885..45d4af62967f 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -32,10 +32,6 @@
32 32
33/* Defines */ 33/* Defines */
34 34
35/*
36 * Version Information
37 */
38#define DRIVER_VERSION "v1.80.1.2"
39#define DRIVER_AUTHOR "Peter Berger <pberger@brimson.com>, Al Borchers <borchers@steinerpoint.com>" 35#define DRIVER_AUTHOR "Peter Berger <pberger@brimson.com>, Al Borchers <borchers@steinerpoint.com>"
40#define DRIVER_DESC "Digi AccelePort USB-2/USB-4 Serial Converter driver" 36#define DRIVER_DESC "Digi AccelePort USB-2/USB-4 Serial Converter driver"
41 37
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
index 43ede4a1e12c..0f658618db13 100644
--- a/drivers/usb/serial/empeg.c
+++ b/drivers/usb/serial/empeg.c
@@ -28,10 +28,6 @@
28#include <linux/usb.h> 28#include <linux/usb.h>
29#include <linux/usb/serial.h> 29#include <linux/usb/serial.h>
30 30
31/*
32 * Version Information
33 */
34#define DRIVER_VERSION "v1.3"
35#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>" 31#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>"
36#define DRIVER_DESC "USB Empeg Mark I/II Driver" 32#define DRIVER_DESC "USB Empeg Mark I/II Driver"
37 33
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index be845873e23d..0a373b3ae96a 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -73,7 +73,6 @@ struct ftdi_private {
73 char prev_status; /* Used for TIOCMIWAIT */ 73 char prev_status; /* Used for TIOCMIWAIT */
74 bool dev_gone; /* Used to abort TIOCMIWAIT */ 74 bool dev_gone; /* Used to abort TIOCMIWAIT */
75 char transmit_empty; /* If transmitter is empty or not */ 75 char transmit_empty; /* If transmitter is empty or not */
76 struct usb_serial_port *port;
77 __u16 interface; /* FT2232C, FT2232H or FT4232H port interface 76 __u16 interface; /* FT2232C, FT2232H or FT4232H port interface
78 (0 for FT232/245) */ 77 (0 for FT232/245) */
79 78
@@ -192,6 +191,7 @@ static struct usb_device_id id_table_combined [] = {
192 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_THROTTLE_PID) }, 191 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_THROTTLE_PID) },
193 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GATEWAY_PID) }, 192 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GATEWAY_PID) },
194 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GBM_PID) }, 193 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GBM_PID) },
194 { USB_DEVICE(NEWPORT_VID, NEWPORT_AGILIS_PID) },
195 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) }, 195 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
196 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) }, 196 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) },
197 { USB_DEVICE(FTDI_VID, FTDI_SPROG_II) }, 197 { USB_DEVICE(FTDI_VID, FTDI_SPROG_II) },
@@ -923,6 +923,9 @@ static int ftdi_get_icount(struct tty_struct *tty,
923static int ftdi_ioctl(struct tty_struct *tty, 923static int ftdi_ioctl(struct tty_struct *tty,
924 unsigned int cmd, unsigned long arg); 924 unsigned int cmd, unsigned long arg);
925static void ftdi_break_ctl(struct tty_struct *tty, int break_state); 925static void ftdi_break_ctl(struct tty_struct *tty, int break_state);
926static int ftdi_chars_in_buffer(struct tty_struct *tty);
927static int ftdi_get_modem_status(struct tty_struct *tty,
928 unsigned char status[2]);
926 929
927static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base); 930static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base);
928static unsigned short int ftdi_232am_baud_to_divisor(int baud); 931static unsigned short int ftdi_232am_baud_to_divisor(int baud);
@@ -957,6 +960,7 @@ static struct usb_serial_driver ftdi_sio_device = {
957 .ioctl = ftdi_ioctl, 960 .ioctl = ftdi_ioctl,
958 .set_termios = ftdi_set_termios, 961 .set_termios = ftdi_set_termios,
959 .break_ctl = ftdi_break_ctl, 962 .break_ctl = ftdi_break_ctl,
963 .chars_in_buffer = ftdi_chars_in_buffer,
960}; 964};
961 965
962static struct usb_serial_driver * const serial_drivers[] = { 966static struct usb_serial_driver * const serial_drivers[] = {
@@ -1090,6 +1094,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set,
1090 __func__, 1094 __func__,
1091 (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged", 1095 (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged",
1092 (set & TIOCM_RTS) ? "HIGH" : (clear & TIOCM_RTS) ? "LOW" : "unchanged"); 1096 (set & TIOCM_RTS) ? "HIGH" : (clear & TIOCM_RTS) ? "LOW" : "unchanged");
1097 rv = usb_translate_errors(rv);
1093 } else { 1098 } else {
1094 dev_dbg(dev, "%s - DTR %s, RTS %s\n", __func__, 1099 dev_dbg(dev, "%s - DTR %s, RTS %s\n", __func__,
1095 (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged", 1100 (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged",
@@ -1682,7 +1687,6 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1682 1687
1683 kref_init(&priv->kref); 1688 kref_init(&priv->kref);
1684 mutex_init(&priv->cfg_lock); 1689 mutex_init(&priv->cfg_lock);
1685 memset(&priv->icount, 0x00, sizeof(priv->icount));
1686 init_waitqueue_head(&priv->delta_msr_wait); 1690 init_waitqueue_head(&priv->delta_msr_wait);
1687 1691
1688 priv->flags = ASYNC_LOW_LATENCY; 1692 priv->flags = ASYNC_LOW_LATENCY;
@@ -1691,7 +1695,6 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1691 if (quirk && quirk->port_probe) 1695 if (quirk && quirk->port_probe)
1692 quirk->port_probe(priv); 1696 quirk->port_probe(priv);
1693 1697
1694 priv->port = port;
1695 usb_set_serial_port_data(port, priv); 1698 usb_set_serial_port_data(port, priv);
1696 1699
1697 ftdi_determine_type(port); 1700 ftdi_determine_type(port);
@@ -1781,7 +1784,7 @@ static int ftdi_8u2232c_probe(struct usb_serial *serial)
1781 struct usb_device *udev = serial->dev; 1784 struct usb_device *udev = serial->dev;
1782 1785
1783 if ((udev->manufacturer && !strcmp(udev->manufacturer, "CALAO Systems")) || 1786 if ((udev->manufacturer && !strcmp(udev->manufacturer, "CALAO Systems")) ||
1784 (udev->product && !strcmp(udev->product, "BeagleBone/XDS100"))) 1787 (udev->product && !strcmp(udev->product, "BeagleBone/XDS100V2")))
1785 return ftdi_jtag_probe(serial); 1788 return ftdi_jtag_probe(serial);
1786 1789
1787 return 0; 1790 return 0;
@@ -2089,6 +2092,29 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
2089 2092
2090} 2093}
2091 2094
2095static int ftdi_chars_in_buffer(struct tty_struct *tty)
2096{
2097 struct usb_serial_port *port = tty->driver_data;
2098 int chars;
2099 unsigned char buf[2];
2100 int ret;
2101
2102 chars = usb_serial_generic_chars_in_buffer(tty);
2103 if (chars)
2104 goto out;
2105
2106 /* Check if hardware buffer is empty. */
2107 ret = ftdi_get_modem_status(tty, buf);
2108 if (ret == 2) {
2109 if (!(buf[1] & FTDI_RS_TEMT))
2110 chars = 1;
2111 }
2112out:
2113 dev_dbg(&port->dev, "%s - %d\n", __func__, chars);
2114
2115 return chars;
2116}
2117
2092/* old_termios contains the original termios settings and tty->termios contains 2118/* old_termios contains the original termios settings and tty->termios contains
2093 * the new setting to be used 2119 * the new setting to be used
2094 * WARNING: set_termios calls this with old_termios in kernel space 2120 * WARNING: set_termios calls this with old_termios in kernel space
@@ -2272,7 +2298,14 @@ no_c_cflag_changes:
2272 } 2298 }
2273} 2299}
2274 2300
2275static int ftdi_tiocmget(struct tty_struct *tty) 2301/*
2302 * Get modem-control status.
2303 *
2304 * Returns the number of status bytes retrieved (device dependant), or
2305 * negative error code.
2306 */
2307static int ftdi_get_modem_status(struct tty_struct *tty,
2308 unsigned char status[2])
2276{ 2309{
2277 struct usb_serial_port *port = tty->driver_data; 2310 struct usb_serial_port *port = tty->driver_data;
2278 struct ftdi_private *priv = usb_get_serial_port_data(port); 2311 struct ftdi_private *priv = usb_get_serial_port_data(port);
@@ -2312,16 +2345,43 @@ static int ftdi_tiocmget(struct tty_struct *tty)
2312 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2345 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2313 0, priv->interface, 2346 0, priv->interface,
2314 buf, len, WDR_TIMEOUT); 2347 buf, len, WDR_TIMEOUT);
2315 if (ret < 0) 2348 if (ret < 0) {
2349 dev_err(&port->dev, "failed to get modem status: %d\n", ret);
2350 ret = usb_translate_errors(ret);
2316 goto out; 2351 goto out;
2352 }
2317 2353
2318 ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) | 2354 status[0] = buf[0];
2319 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) | 2355 if (ret > 1)
2320 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) | 2356 status[1] = buf[1];
2321 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) | 2357 else
2322 priv->last_dtr_rts; 2358 status[1] = 0;
2359
2360 dev_dbg(&port->dev, "%s - 0x%02x%02x\n", __func__, status[0],
2361 status[1]);
2323out: 2362out:
2324 kfree(buf); 2363 kfree(buf);
2364
2365 return ret;
2366}
2367
2368static int ftdi_tiocmget(struct tty_struct *tty)
2369{
2370 struct usb_serial_port *port = tty->driver_data;
2371 struct ftdi_private *priv = usb_get_serial_port_data(port);
2372 unsigned char buf[2];
2373 int ret;
2374
2375 ret = ftdi_get_modem_status(tty, buf);
2376 if (ret < 0)
2377 return ret;
2378
2379 ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) |
2380 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) |
2381 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) |
2382 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) |
2383 priv->last_dtr_rts;
2384
2325 return ret; 2385 return ret;
2326} 2386}
2327 2387
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 57c12ef6625e..049b6e715fa4 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -752,6 +752,12 @@
752#define TTI_VID 0x103E /* Vendor Id */ 752#define TTI_VID 0x103E /* Vendor Id */
753#define TTI_QL355P_PID 0x03E8 /* TTi QL355P power supply */ 753#define TTI_QL355P_PID 0x03E8 /* TTi QL355P power supply */
754 754
755/*
756 * Newport Cooperation (www.newport.com)
757 */
758#define NEWPORT_VID 0x104D
759#define NEWPORT_AGILIS_PID 0x3000
760
755/* Interbiometrics USB I/O Board */ 761/* Interbiometrics USB I/O Board */
756/* Developed for Interbiometrics by Rudolf Gugler */ 762/* Developed for Interbiometrics by Rudolf Gugler */
757#define INTERBIOMETRICS_VID 0x1209 763#define INTERBIOMETRICS_VID 0x1209
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 296612153ea2..2ea70a631996 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -262,6 +262,7 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty)
262 dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars); 262 dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars);
263 return chars; 263 return chars;
264} 264}
265EXPORT_SYMBOL_GPL(usb_serial_generic_chars_in_buffer);
265 266
266static int usb_serial_generic_submit_read_urb(struct usb_serial_port *port, 267static int usb_serial_generic_submit_read_urb(struct usb_serial_port *port,
267 int index, gfp_t mem_flags) 268 int index, gfp_t mem_flags)
diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c
index 0bbaf21a9d1e..2cba60d90c79 100644
--- a/drivers/usb/serial/hp4x.c
+++ b/drivers/usb/serial/hp4x.c
@@ -20,10 +20,6 @@
20#include <linux/usb.h> 20#include <linux/usb.h>
21#include <linux/usb/serial.h> 21#include <linux/usb/serial.h>
22 22
23/*
24 * Version Information
25 */
26#define DRIVER_VERSION "v1.00"
27#define DRIVER_DESC "HP4x (48/49) Generic Serial driver" 23#define DRIVER_DESC "HP4x (48/49) Generic Serial driver"
28 24
29#define HP_VENDOR_ID 0x03f0 25#define HP_VENDOR_ID 0x03f0
@@ -52,5 +48,4 @@ static struct usb_serial_driver * const serial_drivers[] = {
52module_usb_serial_driver(serial_drivers, id_table); 48module_usb_serial_driver(serial_drivers, id_table);
53 49
54MODULE_DESCRIPTION(DRIVER_DESC); 50MODULE_DESCRIPTION(DRIVER_DESC);
55MODULE_VERSION(DRIVER_VERSION);
56MODULE_LICENSE("GPL"); 51MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index 5acc0d13864a..7b770c7f8b11 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -51,10 +51,6 @@
51#include "io_ionsp.h" /* info for the iosp messages */ 51#include "io_ionsp.h" /* info for the iosp messages */
52#include "io_16654.h" /* 16654 UART defines */ 52#include "io_16654.h" /* 16654 UART defines */
53 53
54/*
55 * Version Information
56 */
57#define DRIVER_VERSION "v2.7"
58#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com> and David Iacovelli" 54#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com> and David Iacovelli"
59#define DRIVER_DESC "Edgeport USB Serial Driver" 55#define DRIVER_DESC "Edgeport USB Serial Driver"
60 56
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 60023c2d2a31..58184f3de686 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -40,10 +40,6 @@
40#include "io_usbvend.h" 40#include "io_usbvend.h"
41#include "io_ti.h" 41#include "io_ti.h"
42 42
43/*
44 * Version Information
45 */
46#define DRIVER_VERSION "v0.7mode043006"
47#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com> and David Iacovelli" 43#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com> and David Iacovelli"
48#define DRIVER_DESC "Edgeport USB Serial Driver" 44#define DRIVER_DESC "Edgeport USB Serial Driver"
49 45
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index 1068bf22e27e..76c9a847da5d 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -25,11 +25,6 @@
25 25
26#define KP_RETRIES 100 26#define KP_RETRIES 100
27 27
28/*
29 * Version Information
30 */
31
32#define DRIVER_VERSION "v1.0"
33#define DRIVER_AUTHOR "Ganesh Varadarajan <ganesh@veritas.com>" 28#define DRIVER_AUTHOR "Ganesh Varadarajan <ganesh@veritas.com>"
34#define DRIVER_DESC "USB PocketPC PDA driver" 29#define DRIVER_DESC "USB PocketPC PDA driver"
35 30
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index 4264821a3b34..155eab14b30e 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -49,10 +49,6 @@
49#include <linux/uaccess.h> 49#include <linux/uaccess.h>
50#include "usb-wwan.h" 50#include "usb-wwan.h"
51 51
52/*
53 * Version Information
54 */
55#define DRIVER_VERSION "v0.4"
56#define DRIVER_AUTHOR "Roelf Diedericks" 52#define DRIVER_AUTHOR "Roelf Diedericks"
57#define DRIVER_DESC "IPWireless tty driver" 53#define DRIVER_DESC "IPWireless tty driver"
58 54
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index cd5533e81de7..1e1fbed65ef2 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -32,10 +32,6 @@
32#include "iuu_phoenix.h" 32#include "iuu_phoenix.h"
33#include <linux/random.h> 33#include <linux/random.h>
34 34
35/*
36 * Version Information
37 */
38#define DRIVER_VERSION "v0.12"
39#define DRIVER_DESC "Infinity USB Unlimited Phoenix driver" 35#define DRIVER_DESC "Infinity USB Unlimited Phoenix driver"
40 36
41static const struct usb_device_id id_table[] = { 37static const struct usb_device_id id_table[] = {
@@ -1164,7 +1160,7 @@ static ssize_t store_vcc_mode(struct device *dev,
1164 struct iuu_private *priv = usb_get_serial_port_data(port); 1160 struct iuu_private *priv = usb_get_serial_port_data(port);
1165 unsigned long v; 1161 unsigned long v;
1166 1162
1167 if (strict_strtoul(buf, 10, &v)) { 1163 if (kstrtoul(buf, 10, &v)) {
1168 dev_err(dev, "%s - vcc_mode: %s is not a unsigned long\n", 1164 dev_err(dev, "%s - vcc_mode: %s is not a unsigned long\n",
1169 __func__, buf); 1165 __func__, buf);
1170 goto fail_store_vcc_mode; 1166 goto fail_store_vcc_mode;
@@ -1232,8 +1228,6 @@ MODULE_AUTHOR("Alain Degreffe eczema@ecze.com");
1232MODULE_DESCRIPTION(DRIVER_DESC); 1228MODULE_DESCRIPTION(DRIVER_DESC);
1233MODULE_LICENSE("GPL"); 1229MODULE_LICENSE("GPL");
1234 1230
1235MODULE_VERSION(DRIVER_VERSION);
1236
1237module_param(xmas, bool, S_IRUGO | S_IWUSR); 1231module_param(xmas, bool, S_IRUGO | S_IWUSR);
1238MODULE_PARM_DESC(xmas, "Xmas colors enabled or not"); 1232MODULE_PARM_DESC(xmas, "Xmas colors enabled or not");
1239 1233
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index cff8dd5b462d..97bc49f68efd 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -44,10 +44,6 @@
44#include <linux/usb/ezusb.h> 44#include <linux/usb/ezusb.h>
45#include "keyspan.h" 45#include "keyspan.h"
46 46
47/*
48 * Version Information
49 */
50#define DRIVER_VERSION "v1.1.5"
51#define DRIVER_AUTHOR "Hugh Blemings <hugh@misc.nu" 47#define DRIVER_AUTHOR "Hugh Blemings <hugh@misc.nu"
52#define DRIVER_DESC "Keyspan USB to Serial Converter Driver" 48#define DRIVER_DESC "Keyspan USB to Serial Converter Driver"
53 49
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index bb87e29c4ac2..41b01092af07 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -42,10 +42,6 @@
42 #undef XIRCOM 42 #undef XIRCOM
43#endif 43#endif
44 44
45/*
46 * Version Information
47 */
48#define DRIVER_VERSION "v1.1"
49#define DRIVER_AUTHOR "Brian Warner <warner@lothar.com>" 45#define DRIVER_AUTHOR "Brian Warner <warner@lothar.com>"
50#define DRIVER_DESC "USB Keyspan PDA Converter driver" 46#define DRIVER_DESC "USB Keyspan PDA Converter driver"
51 47
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index 1f4517864cd2..fc9e14a1e9b3 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -49,10 +49,6 @@
49#include <linux/usb/serial.h> 49#include <linux/usb/serial.h>
50#include "kl5kusb105.h" 50#include "kl5kusb105.h"
51 51
52/*
53 * Version Information
54 */
55#define DRIVER_VERSION "v0.4"
56#define DRIVER_AUTHOR "Utz-Uwe Haus <haus@uuhaus.de>, Johan Hovold <jhovold@gmail.com>" 52#define DRIVER_AUTHOR "Utz-Uwe Haus <haus@uuhaus.de>, Johan Hovold <jhovold@gmail.com>"
57#define DRIVER_DESC "KLSI KL5KUSB105 chipset USB->Serial Converter driver" 53#define DRIVER_DESC "KLSI KL5KUSB105 chipset USB->Serial Converter driver"
58 54
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index c9ca7a5b12e0..b747ba615d0b 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -38,8 +38,6 @@
38#include <linux/ioctl.h> 38#include <linux/ioctl.h>
39#include "kobil_sct.h" 39#include "kobil_sct.h"
40 40
41/* Version Information */
42#define DRIVER_VERSION "21/05/2004"
43#define DRIVER_AUTHOR "KOBIL Systems GmbH - http://www.kobil.com" 41#define DRIVER_AUTHOR "KOBIL Systems GmbH - http://www.kobil.com"
44#define DRIVER_DESC "KOBIL USB Smart Card Terminal Driver (experimental)" 42#define DRIVER_DESC "KOBIL USB Smart Card Terminal Driver (experimental)"
45 43
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index 8a2081004107..b6911757c855 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -38,10 +38,6 @@
38#include <linux/ioctl.h> 38#include <linux/ioctl.h>
39#include "mct_u232.h" 39#include "mct_u232.h"
40 40
41/*
42 * Version Information
43 */
44#define DRIVER_VERSION "z2.1" /* Linux in-kernel version */
45#define DRIVER_AUTHOR "Wolfgang Grandegger <wolfgang@ces.ch>" 41#define DRIVER_AUTHOR "Wolfgang Grandegger <wolfgang@ces.ch>"
46#define DRIVER_DESC "Magic Control Technology USB-RS232 converter driver" 42#define DRIVER_DESC "Magic Control Technology USB-RS232 converter driver"
47 43
diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c
index 6f29c74eb769..3d258448c29a 100644
--- a/drivers/usb/serial/metro-usb.c
+++ b/drivers/usb/serial/metro-usb.c
@@ -20,8 +20,6 @@
20#include <linux/uaccess.h> 20#include <linux/uaccess.h>
21#include <linux/usb/serial.h> 21#include <linux/usb/serial.h>
22 22
23/* Version Information */
24#define DRIVER_VERSION "v1.2.0.0"
25#define DRIVER_DESC "Metrologic Instruments Inc. - USB-POS driver" 23#define DRIVER_DESC "Metrologic Instruments Inc. - USB-POS driver"
26 24
27/* Product information. */ 25/* Product information. */
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 75267421aad8..f57a6b1fe787 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -36,10 +36,6 @@
36#include <linux/uaccess.h> 36#include <linux/uaccess.h>
37#include <linux/parport.h> 37#include <linux/parport.h>
38 38
39/*
40 * Version Information
41 */
42#define DRIVER_VERSION "2.1"
43#define DRIVER_AUTHOR "Aspire Communications pvt Ltd." 39#define DRIVER_AUTHOR "Aspire Communications pvt Ltd."
44#define DRIVER_DESC "Moschip USB Serial Driver" 40#define DRIVER_DESC "Moschip USB Serial Driver"
45 41
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 1cf3375ec1af..66d9e088d9d9 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -35,10 +35,6 @@
35#include <linux/usb/serial.h> 35#include <linux/usb/serial.h>
36#include <linux/uaccess.h> 36#include <linux/uaccess.h>
37 37
38/*
39 * Version Information
40 */
41#define DRIVER_VERSION "1.3.2"
42#define DRIVER_DESC "Moschip 7840/7820 USB Serial Driver" 38#define DRIVER_DESC "Moschip 7840/7820 USB Serial Driver"
43 39
44/* 40/*
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index 9ab73d295774..7818af931a48 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -23,10 +23,6 @@
23#include <linux/usb.h> 23#include <linux/usb.h>
24#include <linux/usb/serial.h> 24#include <linux/usb/serial.h>
25 25
26/*
27 * Version Information
28 */
29#define DRIVER_VERSION "v1.1"
30#define DRIVER_AUTHOR "Alessandro Zummo" 26#define DRIVER_AUTHOR "Alessandro Zummo"
31#define DRIVER_DESC "USB ZyXEL omni.net LCD PLUS Driver" 27#define DRIVER_DESC "USB ZyXEL omni.net LCD PLUS Driver"
32 28
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index 6aba731d4864..c6bfb83efb1e 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * Opticon USB barcode to serial driver 2 * Opticon USB barcode to serial driver
3 * 3 *
4 * Copyright (C) 2011 - 2012 Johan Hovold <jhovold@gmail.com>
4 * Copyright (C) 2011 Martin Jansen <martin.jansen@opticon.com> 5 * Copyright (C) 2011 Martin Jansen <martin.jansen@opticon.com>
5 * Copyright (C) 2008 - 2009 Greg Kroah-Hartman <gregkh@suse.de> 6 * Copyright (C) 2008 - 2009 Greg Kroah-Hartman <gregkh@suse.de>
6 * Copyright (C) 2008 - 2009 Novell Inc. 7 * Copyright (C) 2008 - 2009 Novell Inc.
@@ -40,114 +41,70 @@ MODULE_DEVICE_TABLE(usb, id_table);
40 41
41/* This structure holds all of the individual device information */ 42/* This structure holds all of the individual device information */
42struct opticon_private { 43struct opticon_private {
43 struct usb_device *udev;
44 struct usb_serial *serial;
45 struct usb_serial_port *port;
46 unsigned char *bulk_in_buffer;
47 struct urb *bulk_read_urb;
48 int buffer_size;
49 u8 bulk_address;
50 spinlock_t lock; /* protects the following flags */ 44 spinlock_t lock; /* protects the following flags */
51 bool throttled;
52 bool actually_throttled;
53 bool rts; 45 bool rts;
54 bool cts; 46 bool cts;
55 int outstanding_urbs; 47 int outstanding_urbs;
56}; 48};
57 49
58 50
59 51static void opticon_process_data_packet(struct usb_serial_port *port,
60static void opticon_read_bulk_callback(struct urb *urb) 52 const unsigned char *buf, size_t len)
61{ 53{
62 struct opticon_private *priv = urb->context;
63 unsigned char *data = urb->transfer_buffer;
64 struct usb_serial_port *port = priv->port;
65 int status = urb->status;
66 struct tty_struct *tty; 54 struct tty_struct *tty;
67 int result; 55
68 int data_length; 56 tty = tty_port_tty_get(&port->port);
57 if (!tty)
58 return;
59
60 tty_insert_flip_string(tty, buf, len);
61 tty_flip_buffer_push(tty);
62 tty_kref_put(tty);
63}
64
65static void opticon_process_status_packet(struct usb_serial_port *port,
66 const unsigned char *buf, size_t len)
67{
68 struct opticon_private *priv = usb_get_serial_port_data(port);
69 unsigned long flags; 69 unsigned long flags;
70 70
71 switch (status) { 71 spin_lock_irqsave(&priv->lock, flags);
72 case 0: 72 if (buf[0] == 0x00)
73 /* success */ 73 priv->cts = false;
74 break; 74 else
75 case -ECONNRESET: 75 priv->cts = true;
76 case -ENOENT: 76 spin_unlock_irqrestore(&priv->lock, flags);
77 case -ESHUTDOWN: 77}
78 /* this urb is terminated, clean up */ 78
79 dev_dbg(&priv->udev->dev, "%s - urb shutting down with status: %d\n", 79static void opticon_process_read_urb(struct urb *urb)
80 __func__, status); 80{
81 struct usb_serial_port *port = urb->context;
82 const unsigned char *hdr = urb->transfer_buffer;
83 const unsigned char *data = hdr + 2;
84 size_t data_len = urb->actual_length - 2;
85
86 if (urb->actual_length <= 2) {
87 dev_dbg(&port->dev, "malformed packet received: %d bytes\n",
88 urb->actual_length);
81 return; 89 return;
82 default:
83 dev_dbg(&priv->udev->dev, "%s - nonzero urb status received: %d\n",
84 __func__, status);
85 goto exit;
86 } 90 }
87 91 /*
88 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); 92 * Data from the device comes with a 2 byte header:
89 93 *
90 if (urb->actual_length > 2) { 94 * <0x00><0x00>data...
91 data_length = urb->actual_length - 2; 95 * This is real data to be sent to the tty layer
92 96 * <0x00><0x01>level
93 /* 97 * This is a CTS level change, the third byte is the CTS
94 * Data from the device comes with a 2 byte header: 98 * value (0 for low, 1 for high).
95 * 99 */
96 * <0x00><0x00>data... 100 if ((hdr[0] == 0x00) && (hdr[1] == 0x00)) {
97 * This is real data to be sent to the tty layer 101 opticon_process_data_packet(port, data, data_len);
98 * <0x00><0x01)level 102 } else if ((hdr[0] == 0x00) && (hdr[1] == 0x01)) {
99 * This is a CTS level change, the third byte is the CTS 103 opticon_process_status_packet(port, data, data_len);
100 * value (0 for low, 1 for high).
101 */
102 if ((data[0] == 0x00) && (data[1] == 0x00)) {
103 /* real data, send it to the tty layer */
104 tty = tty_port_tty_get(&port->port);
105 if (tty) {
106 tty_insert_flip_string(tty, data + 2,
107 data_length);
108 tty_flip_buffer_push(tty);
109 tty_kref_put(tty);
110 }
111 } else {
112 if ((data[0] == 0x00) && (data[1] == 0x01)) {
113 spin_lock_irqsave(&priv->lock, flags);
114 /* CTS status information package */
115 if (data[2] == 0x00)
116 priv->cts = false;
117 else
118 priv->cts = true;
119 spin_unlock_irqrestore(&priv->lock, flags);
120 } else {
121 dev_dbg(&priv->udev->dev,
122 "Unknown data packet received from the device:"
123 " %2x %2x\n",
124 data[0], data[1]);
125 }
126 }
127 } else { 104 } else {
128 dev_dbg(&priv->udev->dev, 105 dev_dbg(&port->dev, "unknown packet received: %02x %02x\n",
129 "Improper amount of data received from the device, " 106 hdr[0], hdr[1]);
130 "%d bytes", urb->actual_length);
131 } 107 }
132
133exit:
134 spin_lock(&priv->lock);
135
136 /* Continue trying to always read if we should */
137 if (!priv->throttled) {
138 usb_fill_bulk_urb(priv->bulk_read_urb, priv->udev,
139 usb_rcvbulkpipe(priv->udev,
140 priv->bulk_address),
141 priv->bulk_in_buffer, priv->buffer_size,
142 opticon_read_bulk_callback, priv);
143 result = usb_submit_urb(priv->bulk_read_urb, GFP_ATOMIC);
144 if (result)
145 dev_err(&port->dev,
146 "%s - failed resubmitting read urb, error %d\n",
147 __func__, result);
148 } else
149 priv->actually_throttled = true;
150 spin_unlock(&priv->lock);
151} 108}
152 109
153static int send_control_msg(struct usb_serial_port *port, u8 requesttype, 110static int send_control_msg(struct usb_serial_port *port, u8 requesttype,
@@ -175,52 +132,35 @@ static int send_control_msg(struct usb_serial_port *port, u8 requesttype,
175 132
176static int opticon_open(struct tty_struct *tty, struct usb_serial_port *port) 133static int opticon_open(struct tty_struct *tty, struct usb_serial_port *port)
177{ 134{
178 struct opticon_private *priv = usb_get_serial_data(port->serial); 135 struct opticon_private *priv = usb_get_serial_port_data(port);
179 unsigned long flags; 136 unsigned long flags;
180 int result = 0; 137 int res;
181 138
182 spin_lock_irqsave(&priv->lock, flags); 139 spin_lock_irqsave(&priv->lock, flags);
183 priv->throttled = false;
184 priv->actually_throttled = false;
185 priv->port = port;
186 priv->rts = false; 140 priv->rts = false;
187 spin_unlock_irqrestore(&priv->lock, flags); 141 spin_unlock_irqrestore(&priv->lock, flags);
188 142
189 /* Clear RTS line */ 143 /* Clear RTS line */
190 send_control_msg(port, CONTROL_RTS, 0); 144 send_control_msg(port, CONTROL_RTS, 0);
191 145
192 /* Setup the read URB and start reading from the device */
193 usb_fill_bulk_urb(priv->bulk_read_urb, priv->udev,
194 usb_rcvbulkpipe(priv->udev,
195 priv->bulk_address),
196 priv->bulk_in_buffer, priv->buffer_size,
197 opticon_read_bulk_callback, priv);
198
199 /* clear the halt status of the enpoint */ 146 /* clear the halt status of the enpoint */
200 usb_clear_halt(priv->udev, priv->bulk_read_urb->pipe); 147 usb_clear_halt(port->serial->dev, port->read_urb->pipe);
148
149 res = usb_serial_generic_open(tty, port);
150 if (!res)
151 return res;
201 152
202 result = usb_submit_urb(priv->bulk_read_urb, GFP_KERNEL);
203 if (result)
204 dev_err(&port->dev,
205 "%s - failed resubmitting read urb, error %d\n",
206 __func__, result);
207 /* Request CTS line state, sometimes during opening the current 153 /* Request CTS line state, sometimes during opening the current
208 * CTS state can be missed. */ 154 * CTS state can be missed. */
209 send_control_msg(port, RESEND_CTS_STATE, 1); 155 send_control_msg(port, RESEND_CTS_STATE, 1);
210 return result;
211}
212
213static void opticon_close(struct usb_serial_port *port)
214{
215 struct opticon_private *priv = usb_get_serial_data(port->serial);
216 156
217 /* shutdown our urbs */ 157 return res;
218 usb_kill_urb(priv->bulk_read_urb);
219} 158}
220 159
221static void opticon_write_control_callback(struct urb *urb) 160static void opticon_write_control_callback(struct urb *urb)
222{ 161{
223 struct opticon_private *priv = urb->context; 162 struct usb_serial_port *port = urb->context;
163 struct opticon_private *priv = usb_get_serial_port_data(port);
224 int status = urb->status; 164 int status = urb->status;
225 unsigned long flags; 165 unsigned long flags;
226 166
@@ -231,20 +171,21 @@ static void opticon_write_control_callback(struct urb *urb)
231 kfree(urb->setup_packet); 171 kfree(urb->setup_packet);
232 172
233 if (status) 173 if (status)
234 dev_dbg(&priv->udev->dev, "%s - nonzero write bulk status received: %d\n", 174 dev_dbg(&port->dev,
175 "%s - non-zero urb status received: %d\n",
235 __func__, status); 176 __func__, status);
236 177
237 spin_lock_irqsave(&priv->lock, flags); 178 spin_lock_irqsave(&priv->lock, flags);
238 --priv->outstanding_urbs; 179 --priv->outstanding_urbs;
239 spin_unlock_irqrestore(&priv->lock, flags); 180 spin_unlock_irqrestore(&priv->lock, flags);
240 181
241 usb_serial_port_softint(priv->port); 182 usb_serial_port_softint(port);
242} 183}
243 184
244static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port, 185static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
245 const unsigned char *buf, int count) 186 const unsigned char *buf, int count)
246{ 187{
247 struct opticon_private *priv = usb_get_serial_data(port->serial); 188 struct opticon_private *priv = usb_get_serial_port_data(port);
248 struct usb_serial *serial = port->serial; 189 struct usb_serial *serial = port->serial;
249 struct urb *urb; 190 struct urb *urb;
250 unsigned char *buffer; 191 unsigned char *buffer;
@@ -298,7 +239,7 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
298 usb_fill_control_urb(urb, serial->dev, 239 usb_fill_control_urb(urb, serial->dev,
299 usb_sndctrlpipe(serial->dev, 0), 240 usb_sndctrlpipe(serial->dev, 0),
300 (unsigned char *)dr, buffer, count, 241 (unsigned char *)dr, buffer, count,
301 opticon_write_control_callback, priv); 242 opticon_write_control_callback, port);
302 243
303 /* send it down the pipe */ 244 /* send it down the pipe */
304 status = usb_submit_urb(urb, GFP_ATOMIC); 245 status = usb_submit_urb(urb, GFP_ATOMIC);
@@ -331,7 +272,7 @@ error_no_buffer:
331static int opticon_write_room(struct tty_struct *tty) 272static int opticon_write_room(struct tty_struct *tty)
332{ 273{
333 struct usb_serial_port *port = tty->driver_data; 274 struct usb_serial_port *port = tty->driver_data;
334 struct opticon_private *priv = usb_get_serial_data(port->serial); 275 struct opticon_private *priv = usb_get_serial_port_data(port);
335 unsigned long flags; 276 unsigned long flags;
336 277
337 /* 278 /*
@@ -350,44 +291,10 @@ static int opticon_write_room(struct tty_struct *tty)
350 return 2048; 291 return 2048;
351} 292}
352 293
353static void opticon_throttle(struct tty_struct *tty)
354{
355 struct usb_serial_port *port = tty->driver_data;
356 struct opticon_private *priv = usb_get_serial_data(port->serial);
357 unsigned long flags;
358
359 spin_lock_irqsave(&priv->lock, flags);
360 priv->throttled = true;
361 spin_unlock_irqrestore(&priv->lock, flags);
362}
363
364
365static void opticon_unthrottle(struct tty_struct *tty)
366{
367 struct usb_serial_port *port = tty->driver_data;
368 struct opticon_private *priv = usb_get_serial_data(port->serial);
369 unsigned long flags;
370 int result, was_throttled;
371
372 spin_lock_irqsave(&priv->lock, flags);
373 priv->throttled = false;
374 was_throttled = priv->actually_throttled;
375 priv->actually_throttled = false;
376 spin_unlock_irqrestore(&priv->lock, flags);
377
378 if (was_throttled) {
379 result = usb_submit_urb(priv->bulk_read_urb, GFP_ATOMIC);
380 if (result)
381 dev_err(&port->dev,
382 "%s - failed submitting read urb, error %d\n",
383 __func__, result);
384 }
385}
386
387static int opticon_tiocmget(struct tty_struct *tty) 294static int opticon_tiocmget(struct tty_struct *tty)
388{ 295{
389 struct usb_serial_port *port = tty->driver_data; 296 struct usb_serial_port *port = tty->driver_data;
390 struct opticon_private *priv = usb_get_serial_data(port->serial); 297 struct opticon_private *priv = usb_get_serial_port_data(port);
391 unsigned long flags; 298 unsigned long flags;
392 int result = 0; 299 int result = 0;
393 300
@@ -407,7 +314,7 @@ static int opticon_tiocmset(struct tty_struct *tty,
407{ 314{
408 struct usb_serial_port *port = tty->driver_data; 315 struct usb_serial_port *port = tty->driver_data;
409 struct usb_serial *serial = port->serial; 316 struct usb_serial *serial = port->serial;
410 struct opticon_private *priv = usb_get_serial_data(port->serial); 317 struct opticon_private *priv = usb_get_serial_port_data(port);
411 unsigned long flags; 318 unsigned long flags;
412 bool rts; 319 bool rts;
413 bool changed = false; 320 bool changed = false;
@@ -438,7 +345,7 @@ static int opticon_tiocmset(struct tty_struct *tty,
438 return ret; 345 return ret;
439} 346}
440 347
441static int get_serial_info(struct opticon_private *priv, 348static int get_serial_info(struct usb_serial_port *port,
442 struct serial_struct __user *serial) 349 struct serial_struct __user *serial)
443{ 350{
444 struct serial_struct tmp; 351 struct serial_struct tmp;
@@ -450,7 +357,7 @@ static int get_serial_info(struct opticon_private *priv,
450 357
451 /* fake emulate a 16550 uart to make userspace code happy */ 358 /* fake emulate a 16550 uart to make userspace code happy */
452 tmp.type = PORT_16550A; 359 tmp.type = PORT_16550A;
453 tmp.line = priv->serial->minor; 360 tmp.line = port->serial->minor;
454 tmp.port = 0; 361 tmp.port = 0;
455 tmp.irq = 0; 362 tmp.irq = 0;
456 tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; 363 tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
@@ -468,13 +375,12 @@ static int opticon_ioctl(struct tty_struct *tty,
468 unsigned int cmd, unsigned long arg) 375 unsigned int cmd, unsigned long arg)
469{ 376{
470 struct usb_serial_port *port = tty->driver_data; 377 struct usb_serial_port *port = tty->driver_data;
471 struct opticon_private *priv = usb_get_serial_data(port->serial);
472 378
473 dev_dbg(&port->dev, "%s - port %d, cmd = 0x%x\n", __func__, port->number, cmd); 379 dev_dbg(&port->dev, "%s - port %d, cmd = 0x%x\n", __func__, port->number, cmd);
474 380
475 switch (cmd) { 381 switch (cmd) {
476 case TIOCGSERIAL: 382 case TIOCGSERIAL:
477 return get_serial_info(priv, 383 return get_serial_info(port,
478 (struct serial_struct __user *)arg); 384 (struct serial_struct __user *)arg);
479 } 385 }
480 386
@@ -483,106 +389,36 @@ static int opticon_ioctl(struct tty_struct *tty,
483 389
484static int opticon_startup(struct usb_serial *serial) 390static int opticon_startup(struct usb_serial *serial)
485{ 391{
486 struct opticon_private *priv; 392 if (!serial->num_bulk_in) {
487 struct usb_host_interface *intf; 393 dev_err(&serial->dev->dev, "no bulk in endpoint\n");
488 int i; 394 return -ENODEV;
489 int retval = -ENOMEM;
490 bool bulk_in_found = false;
491
492 /* create our private serial structure */
493 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
494 if (priv == NULL) {
495 dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__);
496 return -ENOMEM;
497 }
498 spin_lock_init(&priv->lock);
499 priv->serial = serial;
500 priv->port = serial->port[0];
501 priv->udev = serial->dev;
502 priv->outstanding_urbs = 0; /* Init the outstanding urbs */
503
504 /* find our bulk endpoint */
505 intf = serial->interface->altsetting;
506 for (i = 0; i < intf->desc.bNumEndpoints; ++i) {
507 struct usb_endpoint_descriptor *endpoint;
508
509 endpoint = &intf->endpoint[i].desc;
510 if (!usb_endpoint_is_bulk_in(endpoint))
511 continue;
512
513 priv->bulk_read_urb = usb_alloc_urb(0, GFP_KERNEL);
514 if (!priv->bulk_read_urb) {
515 dev_err(&priv->udev->dev, "out of memory\n");
516 goto error;
517 }
518
519 priv->buffer_size = usb_endpoint_maxp(endpoint) * 2;
520 priv->bulk_in_buffer = kmalloc(priv->buffer_size, GFP_KERNEL);
521 if (!priv->bulk_in_buffer) {
522 dev_err(&priv->udev->dev, "out of memory\n");
523 goto error;
524 }
525
526 priv->bulk_address = endpoint->bEndpointAddress;
527
528 bulk_in_found = true;
529 break;
530 }
531
532 if (!bulk_in_found) {
533 dev_err(&priv->udev->dev,
534 "Error - the proper endpoints were not found!\n");
535 goto error;
536 } 395 }
537 396
538 usb_set_serial_data(serial, priv);
539 return 0; 397 return 0;
540
541error:
542 usb_free_urb(priv->bulk_read_urb);
543 kfree(priv->bulk_in_buffer);
544 kfree(priv);
545 return retval;
546} 398}
547 399
548static void opticon_disconnect(struct usb_serial *serial) 400static int opticon_port_probe(struct usb_serial_port *port)
549{ 401{
550 struct opticon_private *priv = usb_get_serial_data(serial); 402 struct opticon_private *priv;
551
552 usb_kill_urb(priv->bulk_read_urb);
553 usb_free_urb(priv->bulk_read_urb);
554}
555 403
556static void opticon_release(struct usb_serial *serial) 404 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
557{ 405 if (!priv)
558 struct opticon_private *priv = usb_get_serial_data(serial); 406 return -ENOMEM;
559 407
560 kfree(priv->bulk_in_buffer); 408 spin_lock_init(&priv->lock);
561 kfree(priv);
562}
563 409
564static int opticon_suspend(struct usb_serial *serial, pm_message_t message) 410 usb_set_serial_port_data(port, priv);
565{
566 struct opticon_private *priv = usb_get_serial_data(serial);
567 411
568 usb_kill_urb(priv->bulk_read_urb);
569 return 0; 412 return 0;
570} 413}
571 414
572static int opticon_resume(struct usb_serial *serial) 415static int opticon_port_remove(struct usb_serial_port *port)
573{ 416{
574 struct opticon_private *priv = usb_get_serial_data(serial); 417 struct opticon_private *priv = usb_get_serial_port_data(port);
575 struct usb_serial_port *port = serial->port[0]; 418
576 int result; 419 kfree(priv);
577 420
578 mutex_lock(&port->port.mutex); 421 return 0;
579 /* This is protected by the port mutex against close/open */
580 if (test_bit(ASYNCB_INITIALIZED, &port->port.flags))
581 result = usb_submit_urb(priv->bulk_read_urb, GFP_NOIO);
582 else
583 result = 0;
584 mutex_unlock(&port->port.mutex);
585 return result;
586} 422}
587 423
588static struct usb_serial_driver opticon_device = { 424static struct usb_serial_driver opticon_device = {
@@ -592,20 +428,19 @@ static struct usb_serial_driver opticon_device = {
592 }, 428 },
593 .id_table = id_table, 429 .id_table = id_table,
594 .num_ports = 1, 430 .num_ports = 1,
431 .bulk_in_size = 256,
595 .attach = opticon_startup, 432 .attach = opticon_startup,
433 .port_probe = opticon_port_probe,
434 .port_remove = opticon_port_remove,
596 .open = opticon_open, 435 .open = opticon_open,
597 .close = opticon_close,
598 .write = opticon_write, 436 .write = opticon_write,
599 .write_room = opticon_write_room, 437 .write_room = opticon_write_room,
600 .disconnect = opticon_disconnect, 438 .throttle = usb_serial_generic_throttle,
601 .release = opticon_release, 439 .unthrottle = usb_serial_generic_unthrottle,
602 .throttle = opticon_throttle,
603 .unthrottle = opticon_unthrottle,
604 .ioctl = opticon_ioctl, 440 .ioctl = opticon_ioctl,
605 .tiocmget = opticon_tiocmget, 441 .tiocmget = opticon_tiocmget,
606 .tiocmset = opticon_tiocmset, 442 .tiocmset = opticon_tiocmset,
607 .suspend = opticon_suspend, 443 .process_read_urb = opticon_process_read_urb,
608 .resume = opticon_resume,
609}; 444};
610 445
611static struct usb_serial_driver * const serial_drivers[] = { 446static struct usb_serial_driver * const serial_drivers[] = {
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index edc64bb6f457..e6f87b76c715 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -28,7 +28,6 @@
28 device features. 28 device features.
29*/ 29*/
30 30
31#define DRIVER_VERSION "v0.7.2"
32#define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>" 31#define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>"
33#define DRIVER_DESC "USB Driver for GSM modems" 32#define DRIVER_DESC "USB Driver for GSM modems"
34 33
@@ -81,6 +80,7 @@ static void option_instat_callback(struct urb *urb);
81#define OPTION_PRODUCT_GTM380_MODEM 0x7201 80#define OPTION_PRODUCT_GTM380_MODEM 0x7201
82 81
83#define HUAWEI_VENDOR_ID 0x12D1 82#define HUAWEI_VENDOR_ID 0x12D1
83#define HUAWEI_PRODUCT_E173 0x140C
84#define HUAWEI_PRODUCT_K4505 0x1464 84#define HUAWEI_PRODUCT_K4505 0x1464
85#define HUAWEI_PRODUCT_K3765 0x1465 85#define HUAWEI_PRODUCT_K3765 0x1465
86#define HUAWEI_PRODUCT_K4605 0x14C6 86#define HUAWEI_PRODUCT_K4605 0x14C6
@@ -553,6 +553,8 @@ static const struct usb_device_id option_ids[] = {
553 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLX) }, 553 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLX) },
554 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GKE) }, 554 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GKE) },
555 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLE) }, 555 { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLE) },
556 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173, 0xff, 0xff, 0xff),
557 .driver_info = (kernel_ulong_t) &net_intf1_blacklist },
556 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4505, 0xff, 0xff, 0xff), 558 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4505, 0xff, 0xff, 0xff),
557 .driver_info = (kernel_ulong_t) &huawei_cdc12_blacklist }, 559 .driver_info = (kernel_ulong_t) &huawei_cdc12_blacklist },
558 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K3765, 0xff, 0xff, 0xff), 560 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K3765, 0xff, 0xff, 0xff),
@@ -741,23 +743,23 @@ static const struct usb_device_id option_ids[] = {
741 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, 743 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) },
742 { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, 744 { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) },
743 { USB_DEVICE(YISO_VENDOR_ID, YISO_PRODUCT_U893) }, 745 { USB_DEVICE(YISO_VENDOR_ID, YISO_PRODUCT_U893) },
744 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, 746 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1, 0xff) },
745 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, 747 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2, 0xff) },
746 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1004) }, 748 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1004, 0xff) },
747 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1005) }, 749 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1005, 0xff) },
748 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1006) }, 750 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1006, 0xff) },
749 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1007) }, 751 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1007, 0xff) },
750 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1008) }, 752 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1008, 0xff) },
751 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1009) }, 753 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1009, 0xff) },
752 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100A) }, 754 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100A, 0xff) },
753 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100B) }, 755 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100B, 0xff) },
754 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100C) }, 756 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100C, 0xff) },
755 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100D) }, 757 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100D, 0xff) },
756 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100E) }, 758 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100E, 0xff) },
757 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100F) }, 759 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100F, 0xff) },
758 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1010) }, 760 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1010, 0xff) },
759 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1011) }, 761 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1011, 0xff) },
760 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1012) }, 762 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1012, 0xff) },
761 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) }, 763 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) },
762 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, 764 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) },
763 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */ 765 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */
@@ -884,6 +886,10 @@ static const struct usb_device_id option_ids[] = {
884 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0126, 0xff, 0xff, 0xff), 886 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0126, 0xff, 0xff, 0xff),
885 .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 887 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
886 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0128, 0xff, 0xff, 0xff) }, 888 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0128, 0xff, 0xff, 0xff) },
889 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0135, 0xff, 0xff, 0xff) },
890 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0136, 0xff, 0xff, 0xff) },
891 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0137, 0xff, 0xff, 0xff) },
892 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0139, 0xff, 0xff, 0xff) },
887 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0142, 0xff, 0xff, 0xff) }, 893 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0142, 0xff, 0xff, 0xff) },
888 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0143, 0xff, 0xff, 0xff) }, 894 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0143, 0xff, 0xff, 0xff) },
889 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0144, 0xff, 0xff, 0xff) }, 895 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0144, 0xff, 0xff, 0xff) },
@@ -904,20 +910,34 @@ static const struct usb_device_id option_ids[] = {
904 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) }, 910 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) },
905 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff), 911 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff),
906 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 912 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
913 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0189, 0xff, 0xff, 0xff) },
907 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0191, 0xff, 0xff, 0xff), /* ZTE EuFi890 */ 914 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0191, 0xff, 0xff, 0xff), /* ZTE EuFi890 */
908 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 915 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
916 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0196, 0xff, 0xff, 0xff) },
917 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0197, 0xff, 0xff, 0xff) },
909 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0199, 0xff, 0xff, 0xff), /* ZTE MF820S */ 918 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0199, 0xff, 0xff, 0xff), /* ZTE MF820S */
910 .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, 919 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
920 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0200, 0xff, 0xff, 0xff) },
921 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0201, 0xff, 0xff, 0xff) },
922 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0254, 0xff, 0xff, 0xff) },
911 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0257, 0xff, 0xff, 0xff), /* ZTE MF821 */ 923 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0257, 0xff, 0xff, 0xff), /* ZTE MF821 */
912 .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, 924 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
925 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0265, 0xff, 0xff, 0xff) },
926 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0284, 0xff, 0xff, 0xff) },
927 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0317, 0xff, 0xff, 0xff) },
913 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0326, 0xff, 0xff, 0xff), 928 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0326, 0xff, 0xff, 0xff),
914 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 929 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
930 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0330, 0xff, 0xff, 0xff) },
931 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0395, 0xff, 0xff, 0xff) },
932 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0414, 0xff, 0xff, 0xff) },
933 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0417, 0xff, 0xff, 0xff) },
915 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff), 934 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff),
916 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 935 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
917 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff), 936 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff),
918 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 937 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
919 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff), 938 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff),
920 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 939 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
940 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1018, 0xff, 0xff, 0xff) },
921 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1021, 0xff, 0xff, 0xff), 941 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1021, 0xff, 0xff, 0xff),
922 .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, 942 .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
923 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) }, 943 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) },
@@ -1097,6 +1117,10 @@ static const struct usb_device_id option_ids[] = {
1097 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1298, 0xff, 0xff, 0xff) }, 1117 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1298, 0xff, 0xff, 0xff) },
1098 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1299, 0xff, 0xff, 0xff) }, 1118 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1299, 0xff, 0xff, 0xff) },
1099 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1300, 0xff, 0xff, 0xff) }, 1119 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1300, 0xff, 0xff, 0xff) },
1120 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1301, 0xff, 0xff, 0xff) },
1121 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1302, 0xff, 0xff, 0xff) },
1122 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1303, 0xff, 0xff, 0xff) },
1123 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1333, 0xff, 0xff, 0xff) },
1100 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1401, 0xff, 0xff, 0xff), 1124 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1401, 0xff, 0xff, 0xff),
1101 .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, 1125 .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
1102 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1402, 0xff, 0xff, 0xff), 1126 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1402, 0xff, 0xff, 0xff),
@@ -1174,22 +1198,22 @@ static const struct usb_device_id option_ids[] = {
1174 { USB_DEVICE(LONGCHEER_VENDOR_ID, ZOOM_PRODUCT_4597) }, 1198 { USB_DEVICE(LONGCHEER_VENDOR_ID, ZOOM_PRODUCT_4597) },
1175 { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) }, 1199 { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) },
1176 /* Pirelli */ 1200 /* Pirelli */
1177 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1)}, 1201 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1, 0xff) },
1178 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2)}, 1202 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2, 0xff) },
1179 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1004)}, 1203 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1004, 0xff) },
1180 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1005)}, 1204 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1005, 0xff) },
1181 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1006)}, 1205 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1006, 0xff) },
1182 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1007)}, 1206 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1007, 0xff) },
1183 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1008)}, 1207 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1008, 0xff) },
1184 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1009)}, 1208 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1009, 0xff) },
1185 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100A)}, 1209 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100A, 0xff) },
1186 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100B) }, 1210 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100B, 0xff) },
1187 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100C) }, 1211 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100C, 0xff) },
1188 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100D) }, 1212 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100D, 0xff) },
1189 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100E) }, 1213 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100E, 0xff) },
1190 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100F) }, 1214 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100F, 0xff) },
1191 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1011)}, 1215 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1011, 0xff) },
1192 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1012)}, 1216 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1012, 0xff) },
1193 /* Cinterion */ 1217 /* Cinterion */
1194 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_E) }, 1218 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_E) },
1195 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_P) }, 1219 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_P) },
@@ -1350,20 +1374,10 @@ static int option_probe(struct usb_serial *serial,
1350 &serial->interface->cur_altsetting->desc; 1374 &serial->interface->cur_altsetting->desc;
1351 struct usb_device_descriptor *dev_desc = &serial->dev->descriptor; 1375 struct usb_device_descriptor *dev_desc = &serial->dev->descriptor;
1352 1376
1353 /* 1377 /* Never bind to the CD-Rom emulation interface */
1354 * D-Link DWM 652 still exposes CD-Rom emulation interface in modem 1378 if (iface_desc->bInterfaceClass == 0x08)
1355 * mode.
1356 */
1357 if (dev_desc->idVendor == DLINK_VENDOR_ID &&
1358 dev_desc->idProduct == DLINK_PRODUCT_DWM_652 &&
1359 iface_desc->bInterfaceClass == 0x08)
1360 return -ENODEV; 1379 return -ENODEV;
1361 1380
1362 /* Bandrich modem and AT command interface is 0xff */
1363 if ((dev_desc->idVendor == BANDRICH_VENDOR_ID ||
1364 dev_desc->idVendor == PIRELLI_VENDOR_ID) &&
1365 iface_desc->bInterfaceClass != 0xff)
1366 return -ENODEV;
1367 /* 1381 /*
1368 * Don't bind reserved interfaces (like network ones) which often have 1382 * Don't bind reserved interfaces (like network ones) which often have
1369 * the same class/subclass/protocol as the serial interfaces. Look at 1383 * the same class/subclass/protocol as the serial interfaces. Look at
@@ -1378,9 +1392,9 @@ static int option_probe(struct usb_serial *serial,
1378 * Don't bind network interface on Samsung GT-B3730, it is handled by 1392 * Don't bind network interface on Samsung GT-B3730, it is handled by
1379 * a separate module. 1393 * a separate module.
1380 */ 1394 */
1381 if (dev_desc->idVendor == SAMSUNG_VENDOR_ID && 1395 if (dev_desc->idVendor == cpu_to_le16(SAMSUNG_VENDOR_ID) &&
1382 dev_desc->idProduct == SAMSUNG_PRODUCT_GT_B3730 && 1396 dev_desc->idProduct == cpu_to_le16(SAMSUNG_PRODUCT_GT_B3730) &&
1383 iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA) 1397 iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA)
1384 return -ENODEV; 1398 return -ENODEV;
1385 1399
1386 /* Store device id so we can use it during attach. */ 1400 /* Store device id so we can use it during attach. */
@@ -1518,5 +1532,4 @@ static int option_send_setup(struct usb_serial_port *port)
1518 1532
1519MODULE_AUTHOR(DRIVER_AUTHOR); 1533MODULE_AUTHOR(DRIVER_AUTHOR);
1520MODULE_DESCRIPTION(DRIVER_DESC); 1534MODULE_DESCRIPTION(DRIVER_DESC);
1521MODULE_VERSION(DRIVER_VERSION);
1522MODULE_LICENSE("GPL"); 1535MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index cee9a52ca891..d217fd6ee43f 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -57,7 +57,6 @@
57#define OTI6858_DESCRIPTION \ 57#define OTI6858_DESCRIPTION \
58 "Ours Technology Inc. OTi-6858 USB to serial adapter driver" 58 "Ours Technology Inc. OTi-6858 USB to serial adapter driver"
59#define OTI6858_AUTHOR "Tomasz Michal Lukaszewski <FIXME@FIXME>" 59#define OTI6858_AUTHOR "Tomasz Michal Lukaszewski <FIXME@FIXME>"
60#define OTI6858_VERSION "0.2"
61 60
62static const struct usb_device_id id_table[] = { 61static const struct usb_device_id id_table[] = {
63 { USB_DEVICE(OTI6858_VENDOR_ID, OTI6858_PRODUCT_ID) }, 62 { USB_DEVICE(OTI6858_VENDOR_ID, OTI6858_PRODUCT_ID) },
@@ -899,5 +898,4 @@ module_usb_serial_driver(serial_drivers, id_table);
899 898
900MODULE_DESCRIPTION(OTI6858_DESCRIPTION); 899MODULE_DESCRIPTION(OTI6858_DESCRIPTION);
901MODULE_AUTHOR(OTI6858_AUTHOR); 900MODULE_AUTHOR(OTI6858_AUTHOR);
902MODULE_VERSION(OTI6858_VERSION);
903MODULE_LICENSE("GPL"); 901MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
index ffcfc962ab10..d152be97d041 100644
--- a/drivers/usb/serial/quatech2.c
+++ b/drivers/usb/serial/quatech2.c
@@ -65,8 +65,6 @@
65#define QT2_WRITE_BUFFER_SIZE 512 /* size of write buffer */ 65#define QT2_WRITE_BUFFER_SIZE 512 /* size of write buffer */
66#define QT2_WRITE_CONTROL_SIZE 5 /* control bytes used for a write */ 66#define QT2_WRITE_CONTROL_SIZE 5 /* control bytes used for a write */
67 67
68/* Version Information */
69#define DRIVER_VERSION "v0.1"
70#define DRIVER_DESC "Quatech 2nd gen USB to Serial Driver" 68#define DRIVER_DESC "Quatech 2nd gen USB to Serial Driver"
71 69
72#define USB_VENDOR_ID_QUATECH 0x061d 70#define USB_VENDOR_ID_QUATECH 0x061d
diff --git a/drivers/usb/serial/siemens_mpi.c b/drivers/usb/serial/siemens_mpi.c
index e4a1787cdbac..a76b1ae54a2a 100644
--- a/drivers/usb/serial/siemens_mpi.c
+++ b/drivers/usb/serial/siemens_mpi.c
@@ -16,8 +16,6 @@
16#include <linux/usb.h> 16#include <linux/usb.h>
17#include <linux/usb/serial.h> 17#include <linux/usb/serial.h>
18 18
19/* Version Information */
20#define DRIVER_VERSION "Version 0.1 09/26/2005"
21#define DRIVER_AUTHOR "Thomas Hergenhahn@web.de http://libnodave.sf.net" 19#define DRIVER_AUTHOR "Thomas Hergenhahn@web.de http://libnodave.sf.net"
22#define DRIVER_DESC "Driver for Siemens USB/MPI adapter" 20#define DRIVER_DESC "Driver for Siemens USB/MPI adapter"
23 21
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 270860f6bb2a..af06f2f5f38b 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -18,7 +18,7 @@
18*/ 18*/
19/* Uncomment to log function calls */ 19/* Uncomment to log function calls */
20/* #define DEBUG */ 20/* #define DEBUG */
21#define DRIVER_VERSION "v.1.7.16" 21
22#define DRIVER_AUTHOR "Kevin Lloyd, Elina Pasheva, Matthew Safar, Rory Filer" 22#define DRIVER_AUTHOR "Kevin Lloyd, Elina Pasheva, Matthew Safar, Rory Filer"
23#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" 23#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
24 24
@@ -1078,7 +1078,6 @@ module_usb_serial_driver(serial_drivers, id_table);
1078 1078
1079MODULE_AUTHOR(DRIVER_AUTHOR); 1079MODULE_AUTHOR(DRIVER_AUTHOR);
1080MODULE_DESCRIPTION(DRIVER_DESC); 1080MODULE_DESCRIPTION(DRIVER_DESC);
1081MODULE_VERSION(DRIVER_VERSION);
1082MODULE_LICENSE("GPL"); 1081MODULE_LICENSE("GPL");
1083 1082
1084module_param(nmea, bool, S_IRUGO | S_IWUSR); 1083module_param(nmea, bool, S_IRUGO | S_IWUSR);
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index 769c137f8975..a42536af1256 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -28,9 +28,6 @@
28#include <linux/usb.h> 28#include <linux/usb.h>
29#include <linux/usb/serial.h> 29#include <linux/usb/serial.h>
30 30
31
32/* Version Information */
33#define DRIVER_VERSION "v0.10"
34#define DRIVER_DESC "SPCP8x5 USB to serial adaptor driver" 31#define DRIVER_DESC "SPCP8x5 USB to serial adaptor driver"
35 32
36#define SPCP8x5_007_VID 0x04FC 33#define SPCP8x5_007_VID 0x04FC
@@ -651,5 +648,4 @@ static struct usb_serial_driver * const serial_drivers[] = {
651module_usb_serial_driver(serial_drivers, id_table); 648module_usb_serial_driver(serial_drivers, id_table);
652 649
653MODULE_DESCRIPTION(DRIVER_DESC); 650MODULE_DESCRIPTION(DRIVER_DESC);
654MODULE_VERSION(DRIVER_VERSION);
655MODULE_LICENSE("GPL"); 651MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c
index 868d1e6852e2..4543ea350229 100644
--- a/drivers/usb/serial/ssu100.c
+++ b/drivers/usb/serial/ssu100.c
@@ -46,8 +46,6 @@
46#define FULLPWRBIT 0x00000080 46#define FULLPWRBIT 0x00000080
47#define NEXT_BOARD_POWER_BIT 0x00000004 47#define NEXT_BOARD_POWER_BIT 0x00000004
48 48
49/* Version Information */
50#define DRIVER_VERSION "v0.1"
51#define DRIVER_DESC "Quatech SSU-100 USB to Serial Driver" 49#define DRIVER_DESC "Quatech SSU-100 USB to Serial Driver"
52 50
53#define USB_VENDOR_ID_QUATECH 0x061d /* Quatech VID */ 51#define USB_VENDOR_ID_QUATECH 0x061d /* Quatech VID */
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index a3e9c095f0d8..01c94aada56c 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -19,7 +19,6 @@
19 - controlling the baud rate doesn't make sense 19 - controlling the baud rate doesn't make sense
20*/ 20*/
21 21
22#define DRIVER_VERSION "v0.7.2"
23#define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>" 22#define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>"
24#define DRIVER_DESC "USB Driver for GSM modems" 23#define DRIVER_DESC "USB Driver for GSM modems"
25 24
@@ -710,5 +709,4 @@ EXPORT_SYMBOL(usb_wwan_resume);
710 709
711MODULE_AUTHOR(DRIVER_AUTHOR); 710MODULE_AUTHOR(DRIVER_AUTHOR);
712MODULE_DESCRIPTION(DRIVER_DESC); 711MODULE_DESCRIPTION(DRIVER_DESC);
713MODULE_VERSION(DRIVER_VERSION);
714MODULE_LICENSE("GPL"); 712MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/vivopay-serial.c b/drivers/usb/serial/vivopay-serial.c
index 0c0aa876c209..6299526ff8c3 100644
--- a/drivers/usb/serial/vivopay-serial.c
+++ b/drivers/usb/serial/vivopay-serial.c
@@ -10,8 +10,6 @@
10#include <linux/usb.h> 10#include <linux/usb.h>
11#include <linux/usb/serial.h> 11#include <linux/usb/serial.h>
12 12
13
14#define DRIVER_VERSION "v1.0"
15#define DRIVER_DESC "ViVOpay USB Serial Driver" 13#define DRIVER_DESC "ViVOpay USB Serial Driver"
16 14
17#define VIVOPAY_VENDOR_ID 0x1d5f 15#define VIVOPAY_VENDOR_ID 0x1d5f
@@ -42,5 +40,4 @@ module_usb_serial_driver(serial_drivers, id_table);
42 40
43MODULE_AUTHOR("Forest Bond <forest.bond@outpostembedded.com>"); 41MODULE_AUTHOR("Forest Bond <forest.bond@outpostembedded.com>");
44MODULE_DESCRIPTION(DRIVER_DESC); 42MODULE_DESCRIPTION(DRIVER_DESC);
45MODULE_VERSION(DRIVER_VERSION);
46MODULE_LICENSE("GPL"); 43MODULE_LICENSE("GPL");
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig
index 0ae7bb64b5ea..eab04a6b5fbc 100644
--- a/drivers/usb/storage/Kconfig
+++ b/drivers/usb/storage/Kconfig
@@ -203,7 +203,7 @@ config USB_STORAGE_ENE_UB6250
203 203
204config USB_UAS 204config USB_UAS
205 tristate "USB Attached SCSI" 205 tristate "USB Attached SCSI"
206 depends on USB && SCSI 206 depends on USB && SCSI && BROKEN
207 help 207 help
208 The USB Attached SCSI protocol is supported by some USB 208 The USB Attached SCSI protocol is supported by some USB
209 storage devices. It permits higher performance by supporting 209 storage devices. It permits higher performance by supporting
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
index d36446dd7ae8..ea5f2586fbdd 100644
--- a/drivers/usb/storage/realtek_cr.c
+++ b/drivers/usb/storage/realtek_cr.c
@@ -455,7 +455,7 @@ static int rts51x_check_status(struct us_data *us, u8 lun)
455 u8 buf[16]; 455 u8 buf[16];
456 456
457 retval = rts51x_read_status(us, lun, buf, 16, &(chip->status_len)); 457 retval = rts51x_read_status(us, lun, buf, 16, &(chip->status_len));
458 if (retval < 0) 458 if (retval != STATUS_SUCCESS)
459 return -EIO; 459 return -EIO;
460 460
461 US_DEBUGP("chip->status_len = %d\n", chip->status_len); 461 US_DEBUGP("chip->status_len = %d\n", chip->status_len);
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 12aa72630aed..31b3e1a61bbd 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -925,7 +925,6 @@ int usb_stor_probe1(struct us_data **pus,
925 host->max_cmd_len = 16; 925 host->max_cmd_len = 16;
926 host->sg_tablesize = usb_stor_sg_tablesize(intf); 926 host->sg_tablesize = usb_stor_sg_tablesize(intf);
927 *pus = us = host_to_us(host); 927 *pus = us = host_to_us(host);
928 memset(us, 0, sizeof(struct us_data));
929 mutex_init(&(us->dev_mutex)); 928 mutex_init(&(us->dev_mutex));
930 us_set_lock_class(&us->dev_mutex, intf); 929 us_set_lock_class(&us->dev_mutex, intf);
931 init_completion(&us->cmnd_ready); 930 init_completion(&us->cmnd_ready);
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index 0616f235bd6b..ce310170829f 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -105,20 +105,15 @@ static int skel_open(struct inode *inode, struct file *file)
105 goto exit; 105 goto exit;
106 } 106 }
107 107
108 /* increment our usage count for the device */
109 kref_get(&dev->kref);
110
111 /* lock the device to allow correctly handling errors
112 * in resumption */
113 mutex_lock(&dev->io_mutex);
114
115 retval = usb_autopm_get_interface(interface); 108 retval = usb_autopm_get_interface(interface);
116 if (retval) 109 if (retval)
117 goto out_err; 110 goto exit;
111
112 /* increment our usage count for the device */
113 kref_get(&dev->kref);
118 114
119 /* save our object in the file's private structure */ 115 /* save our object in the file's private structure */
120 file->private_data = dev; 116 file->private_data = dev;
121 mutex_unlock(&dev->io_mutex);
122 117
123exit: 118exit:
124 return retval; 119 return retval;
diff --git a/drivers/usb/wusbcore/devconnect.c b/drivers/usb/wusbcore/devconnect.c
index 231009af65a3..1d365316960c 100644
--- a/drivers/usb/wusbcore/devconnect.c
+++ b/drivers/usb/wusbcore/devconnect.c
@@ -847,19 +847,6 @@ static void wusb_dev_bos_rm(struct wusb_dev *wusb_dev)
847 wusb_dev->wusb_cap_descr = NULL; 847 wusb_dev->wusb_cap_descr = NULL;
848}; 848};
849 849
850static struct usb_wireless_cap_descriptor wusb_cap_descr_default = {
851 .bLength = sizeof(wusb_cap_descr_default),
852 .bDescriptorType = USB_DT_DEVICE_CAPABILITY,
853 .bDevCapabilityType = USB_CAP_TYPE_WIRELESS_USB,
854
855 .bmAttributes = USB_WIRELESS_BEACON_NONE,
856 .wPHYRates = cpu_to_le16(USB_WIRELESS_PHY_53),
857 .bmTFITXPowerInfo = 0,
858 .bmFFITXPowerInfo = 0,
859 .bmBandGroup = cpu_to_le16(0x0001), /* WUSB1.0[7.4.1] bottom */
860 .bReserved = 0
861};
862
863/* 850/*
864 * USB stack's device addition Notifier Callback 851 * USB stack's device addition Notifier Callback
865 * 852 *
diff --git a/drivers/uwb/Kconfig b/drivers/uwb/Kconfig
index d100f54ed650..2431eedbe6a5 100644
--- a/drivers/uwb/Kconfig
+++ b/drivers/uwb/Kconfig
@@ -3,8 +3,7 @@
3# 3#
4 4
5menuconfig UWB 5menuconfig UWB
6 tristate "Ultra Wideband devices (EXPERIMENTAL)" 6 tristate "Ultra Wideband devices"
7 depends on EXPERIMENTAL
8 depends on PCI 7 depends on PCI
9 default n 8 default n
10 help 9 help
diff --git a/drivers/uwb/reset.c b/drivers/uwb/reset.c
index 703228559e89..8b47c9cdd642 100644
--- a/drivers/uwb/reset.c
+++ b/drivers/uwb/reset.c
@@ -97,6 +97,7 @@ int uwb_rc_cmd_async(struct uwb_rc *rc, const char *cmd_name,
97 neh = uwb_rc_neh_add(rc, cmd, expected_type, expected_event, cb, arg); 97 neh = uwb_rc_neh_add(rc, cmd, expected_type, expected_event, cb, arg);
98 if (IS_ERR(neh)) { 98 if (IS_ERR(neh)) {
99 result = PTR_ERR(neh); 99 result = PTR_ERR(neh);
100 uwb_dev_unlock(&rc->uwb_dev);
100 goto out; 101 goto out;
101 } 102 }
102 103
diff --git a/drivers/uwb/umc-bus.c b/drivers/uwb/umc-bus.c
index 82a84d53120f..5c5b3fc9088a 100644
--- a/drivers/uwb/umc-bus.c
+++ b/drivers/uwb/umc-bus.c
@@ -63,7 +63,7 @@ int umc_controller_reset(struct umc_dev *umc)
63 struct device *parent = umc->dev.parent; 63 struct device *parent = umc->dev.parent;
64 int ret = 0; 64 int ret = 0;
65 65
66 if (device_trylock(parent)) 66 if (!device_trylock(parent))
67 return -EAGAIN; 67 return -EAGAIN;
68 ret = device_for_each_child(parent, parent, umc_bus_pre_reset_helper); 68 ret = device_for_each_child(parent, parent, umc_bus_pre_reset_helper);
69 if (ret >= 0) 69 if (ret >= 0)
diff --git a/firmware/Makefile b/firmware/Makefile
index eeb14030d8a2..cbb09ce9730a 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -97,7 +97,6 @@ fw-shipped-$(CONFIG_TEHUTI) += tehuti/bdx.bin
97fw-shipped-$(CONFIG_TIGON3) += tigon/tg3.bin tigon/tg3_tso.bin \ 97fw-shipped-$(CONFIG_TIGON3) += tigon/tg3.bin tigon/tg3_tso.bin \
98 tigon/tg3_tso5.bin 98 tigon/tg3_tso5.bin
99fw-shipped-$(CONFIG_TYPHOON) += 3com/typhoon.bin 99fw-shipped-$(CONFIG_TYPHOON) += 3com/typhoon.bin
100fw-shipped-$(CONFIG_USB_DABUSB) += dabusb/firmware.fw dabusb/bitstream.bin
101fw-shipped-$(CONFIG_USB_EMI26) += emi26/loader.fw emi26/firmware.fw \ 100fw-shipped-$(CONFIG_USB_EMI26) += emi26/loader.fw emi26/firmware.fw \
102 emi26/bitstream.fw 101 emi26/bitstream.fw
103fw-shipped-$(CONFIG_USB_EMI62) += emi62/loader.fw emi62/bitstream.fw \ 102fw-shipped-$(CONFIG_USB_EMI62) += emi62/loader.fw emi62/bitstream.fw \
diff --git a/firmware/dabusb/bitstream.bin.ihex b/firmware/dabusb/bitstream.bin.ihex
deleted file mode 100644
index 5021a4b1e63f..000000000000
--- a/firmware/dabusb/bitstream.bin.ihex
+++ /dev/null
@@ -1,761 +0,0 @@
1:1000000000090FF00FF00FF00FF000000161000D7C
2:1000100064616275736274722E6E63640062000BB9
3:10002000733130786C76713130300063000B3139C8
4:1000300039392F30392F32340064000931303A34E5
5:10004000323A3436006500002EC0FF20175F9F5BF8
6:10005000FEFBBBB7BBBBFBBFAFEFFBDFB7FBFB7F61
7:10006000BFB7EFF2FFFBFEFFFFEFFFFEFFBFFFFF9B
8:10007000FFFFAFFFFAFFFFFFC9FFFFFFDFFFFFFF3B
9:10008000FFFFFFFFFFFFFFFFFFFFFFFBFFA3FFFBE4
10:10009000FEFFBFEFE3FEFFBFE3FEFFBF6FFBF6FF18
11:1000A000BFFF47FFFF9FEEF9FECF9FEFFBCF9BEE19
12:1000B000F8FEEF8FEEFBFE0BFFFFFFFFFFFFFFFFE2
13:1000C000FFFFBFFFFFFBFFFFBFFFFFFC17FFFFFFAF
14:1000D000FFFFFF7FFFFFFF7FFFFFFBFFFF7FFFFFB4
15:1000E000FC3FFFFFFFFFFFFFFFFFFFFBFFFFFFFFE7
16:1000F000FFFFFFFFFFFE5FFFFFFDFFFFDBFFFDFFD9
17:1001000077FFFDFFFFDFFEFDFFFFF2FFFFFFFFFFB9
18:10011000FFFDFFFFFFFDFFFFFFFFFFFFFFFFFFE111
19:100120007FFFFFFFFFFFFFFFFFFFFFFFFF3FFFFF1F
20:10013000FFFFFFFFE3FFFFFFFFFFFFFFFFFFFFBF2B
21:10014000FFFEFFFFFFFFFFFFFF67FFFFFFFFFFFF58
22:100150007FFFFFFF7FFFFFFFFFFFDFFFFFFF2FFF9F
23:10016000F3FDFF7FDEF7FDFF7FF77DFF7FDFF7BD4C
24:10017000FF7FFF1FFFEFFBFEFFBFEFFBFEFFEFFB6D
25:10018000FEFFBFEFFBFEFFFF3FFE7F9FE7F9FE7F15
26:100190009FE7FA7F9FE7F9FE7F9FE7FFFC7FBFBFE6
27:1001A000EFFBFEFFBFEFFBB7BFEFFBFEFFBFEFFBB9
28:1001B000FFE0FDF9FE7F9FE7F9FE7F9DF9FE7D9D43
29:1001C000E7F9FE7F9FEDEDFFFDFF7FDFF7FDFF7F8E
30:1001D000DFFDFF7FDFF7FDFF7FDFFF9BFFEFFBFE14
31:1001E000FBBFEFBBFEFFAFBBBEFFBFEFFBFEFFFFE2
32:1001F000B7BFDBF6BDBF6BDBF6F9BF5BD6F9BF6FF0
33:10020000DBF6FDBFFF0EFFFFFFFF5FFFF7FFFF7F86
34:10021000F7BDFFFFFFFFFFFFFFDF9FFFFFFFFEFFB9
35:10022000FFEFFEFEFFFF77FFFBFBFFFFFFFFF83F47
36:10023000FFFDFFFFFFFDFFFFFFFFFFFFFFFFFFFFD2
37:10024000FFFFFFF47FFFFEFDBEFFDFFEFFFFEF7F3E
38:10025000FFCFFFCFFFFFFFDFE6FFFF7FDFF7DD7F91
39:100260007FDFF7FF7FDFD7FDFF7FDFF7FFCDFFF2F7
40:10027000FFFF4F7FF4FFFFFFE7EFFFFFFFFFFFFFF1
41:10028000FFFFBBFFEFFFFEFFFFFFEFFFFFEFFFFBF7
42:10029000FFFFFFFFFFFFFF65EFFFFF7FFFFDEFFFAA
43:1002A000FFFFFEFFFFFFFFFFFFFFFFFECFDFFEFFB1
44:1002B000FFFBFFFFFFFFF3FFFFFFFFFFFFFFFFFF5E
45:1002C000FEDFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5F
46:1002D000FFFFFFFFFFFEBFFFFFFFE37FFFFFFFFF0B
47:1002E000FFFFEFEBFFFEBFFFEBFFFC7FFFFFFFEE2B
48:1002F000FFFFFFFFFFFFDDFFD6FFFDBFFFFBFFFEA0
49:10030000FDFFFFFDEFFFFFFFFFFFFFDEFFFFFFFF32
50:10031000FFFFBFFFFDFF7FBFFF5FDFFFFFBF77FF77
51:10032000FFFF7FD7FFFFFFFFFFC3FFFFFFFFDFEFF1
52:10033000FFFFFEFBFFFFDFBFFFFFFFFFEDFFB7FF8C
53:10034000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBD
54:10035000FFFFFFAF7FFFFFFFFFFFFFFFFFFFFFFF7D
55:10036000FFFFFFFFFFFFFFFFDFBFDFF3FDFBFF5BD3
56:10037000FDFFBFEFF7FFFF7DFFFFFFFFF83BFFBF74
57:100380006FFFFEFFBFFFEB7DFFEFFBFEFFFFFFFFF9
58:10039000FFF27FFCFF3FDFEDFEFFFFFFFFEF5FF7A8
59:1003A000B5FFEFFFFFFFE03F9F9EFFFFEFFFDFFF87
60:1003B000BF5FBFCFF3FFFFFFFFFFFF69AF33FDFF5D
61:1003C000FBFFFFFFFFFCFF7FD9FFDFFFFFFFFFF514
62:1003D000A3DF6EDEFFFFBDFFFFFEFFFFFFFEE7FDB9
63:1003E000FFFFFFF9EFC6FEB7ADE5F9FFFFFFCFFF57
64:1003F000FFFFCDFB7FFFFFFFF9F60FDFECCF7FFFA5
65:10040000FB7FFFFFFFFDFFFEF9FD7FFF7FFFF95B35
66:10041000FF73DCFD7BDFFFFFFF7BFFFFF753D6FFA2
67:10042000FFFFFFD89FFEFFEF7FEEFFFFFFFBEDED2D
68:10043000FDFFFEFFFFFB7FFFE27FFF6FD857F7FF57
69:10044000FFFFDFFFE8FFFFFDFFFFFC7FFFE4FFFB97
70:10045000EFFBFEDFB7EDFFFEDF7FFFFE7FB7FFFFA5
71:10046000FFFF89FFFFCFF3FE7FFFEFFFFE7E7FFBE5
72:10047000FFFFFFFFFFFFFFF1FFEB7AD5BF6FDBBE92
73:10048000FDB7D8F6E5BF6FFBFEF5BD7E06FFDFF7D3
74:10049000FBF6FF3FFFDBFFFF6FFBF7FFFFFFFBFEFE
75:1004A000F7AFFFB7EDEFF7FEFFFFDFFFFEFFEFFF58
76:1004B000FFFFFFBFF7FC1FEEFBFEBDFF7F5FD7FD19
77:1004C000FB43FFFFFDFF5FFFF7FFF93FFFCFF3FDAA
78:1004D000F77EEFA7F9FE8FA7E9F37E9FFBF8FFFFFA
79:1004E0003FFD7F5FDFFDFFFF5FFFFD5FFFFF7FFDE4
80:1004F0007FFD9FFFE0FFFAF8BE6F9FE6F8BE3F9AD0
81:10050000F9BE6F9FE2F9FE6F9FF9FFF5FD7FCFDF28
82:10051000FDFD7FFFF5FFFFFFF7F5FD0FDBFFD3FFCD
83:10052000EBFAFFFFBFFFFAFFFFCBFBFEFFFFEBFA8B
84:10053000FEFFFFB7FFFFFFFFBFFFDFF5FFFFD7FFA6
85:10054000FFFFDFD7F5FF7FFE4FFFFDFF7F7FFFAD92
86:10055000EBFBFFADFFFFFFFFAFEBFBFFFC0DFFFF72
87:10056000DFD2FDFFFFFDF6FFFF7FFFFF1FFFFFFF55
88:10057000FFFB3F7DEB32FEBF2FEBFAAEBDE0FA7E14
89:10058000BFADEBFAFEBFF57FFFDEFEE3FBFFFFFF33
90:10059000DFEF4FDFFF7FDFFFF7FFFFF87FFFFFEFAA
91:1005A000FBFFFFFFEFFFFFDFEDFBDFFFBFFFFFFF05
92:1005B00081FFFFFFFF3FFFFFFFFFFEDDFEEFFDFFBF
93:1005C000FFFBFEF7FF93FDFB7EFFFE87E9FF7FB396
94:1005D0009FFEFEFFAFFDFE7E3FFE67FFFFF7FFFFC2
95:1005E000FCF7DFFDFF7FFFFF7F6DFFFFFEFFFF2FAB
96:1005F000FFBFFFFFEEFFBEFFFFFEFFEFFFFFFEFFAF
97:10060000EFFFFFFA5FFFFFFBFFFFEFFFFBFEFDFFCA
98:10061000FEFFFBFFFFFF7FFFFEBFDFFFFBFFFFF7DC
99:10062000FCFDFFFFFFFFFF7FFFFFFFFFFFF27FFFEC
100:10063000FFFFFF7FFFFFFFFFF3FFFFFFEFFBFFFF6A
101:10064000FFDFE2FFFFFBFFFFFFFFFFFFFBE7FFFD19
102:10065000FFFFFFBFFFFFFFEDEFFDFFFFDFD7F5FD62
103:100660007F5DFDFF7FDF97F4FD7B5FFFC9FFFBFE32
104:10067000FFBFFF5FFFFFF7FFEFFDFFEFFFFFFFFF94
105:10068000FFF7FFD7FD7D7FFFFFFFFFEFDFF7FDFFE8
106:10069000BBFFFF7FFFFEE3FFF9FE7FBFEFFBFEFF27
107:1006A000BFF9FEFF9FEFF9FEFFBFF3DAFF37CDF38F
108:1006B0007CDF37CDF37F37CDF37CDF37CCF37F5A48
109:1006C000BDF6FDBF6FDBF6FDBF6FDEFDBF6FDBF676
110:1006D000FDBF6FFEF16FEB7ADEB7ADEB7ADEB7AF41
111:1006E0007ADEB7ADEB7ADEB7FF7EFFFECDB36CDB13
112:1006F00036CDB36CDECDB36CDB36CDB36CDFC9BFAA
113:10070000F7BDEF7A9EA7A9EA7AB7BDEA7BDEA7BD5F
114:10071000CA728D91FFEFFBFEFFBFEFFBFEF7EFFB11
115:10072000FEFFBFEFFBFEFFFE87FFF6FDBF6FDBF6B0
116:10073000FDBF6FF6FDBF6FDBF6FDBF6FFE4FFFBF66
117:10074000EFBBEEFBBEEFBBEFBEEFBBEEFBBEEFBB06
118:10075000EFFC5FFFFFFF3FCFF3FCFF3FCFFCFF3F0E
119:10076000CFF3FCFF3FCFFD9FFEBFAFEBFAFEBFAF65
120:10077000EBFEBFAFEBFAFEBFAFEBFFE16FFDFF7F1C
121:10078000DFF7FDFF7FDFFDFF7FDFF7FDFF7FDFFF8F
122:100790007ABFFBFEDFB7EDFB7EDFB7FB7EDFB7ED99
123:1007A000FB7EDFB7FFC9FFFFBFEFFBFEFFBFEFFB25
124:1007B000FFBFEFFBFEFFBFEEFBFEBBFFFEFFBFEF89
125:1007C000FBFEFFBFEFFEFFBFEFFBFEFF3FCFFFE7EC
126:1007D000FEFFF5FD775DD735DD77D7F5CD7B5DD7AE
127:1007E000F5DD77FE27FFFF8BE2F8BE2F8BE2F9AF36
128:1007F0008BE2F8BE2F8BE2F9FE1FFF5FD7F5FD7F7E
129:100800005FD7F5FF5FD7F5FD7F5FD7F5FFFA3FFEB6
130:10081000BFAFEBFAFEBFAFEBECBFAFEBFAFEBFAF83
131:10082000EBFFFE7FFD7FFFFFFFFFFFFFFFFFFFFFEF
132:10083000FFFFFFFFFFFFFFE6FFFADFF7FDFF7FDFB0
133:10084000F7FCFFDFF7FDFF7FDFF7FDFFF5FFFFFFA1
134:10085000FFFFFFFFFFFFFBFFFFFFFFFFFFFFFFFFAC
135:10086000FF02FFFEBFABEBFABEBF23EBDE1FAFEA1A
136:10087000FAFEAFAFEBFD97FFF3FC7B1FCFF1FC7FE0
137:100880001FF1FC771FCDF1FCFF1FFE87FFAFEFFAD2
138:10089000FEFFAFEFFAFDBF2BFB7EBFBFEBFBFBFB09
139:1008A000DFFFFBF7FFFF7FF7F7FFFDDFFEFCDFFF5A
140:1008B000DFFFFDFFDABFFFBBEFFBF9FFBEEFFBFB86
141:1008C000BFEFFBFEFFBFEFFBFFF77FFDD7FFFF7F13
142:1008D000FFFFFFFEF7FFFEFFF7FFFF7FFFFFECFFCD
143:1008E000FFFEDFBFFFFBFEFFBB68AE1FAEFBFBFFE3
144:1008F000FFBFFFD5FF7FFFFFF7FEFEFFBFEF9FFDAE
145:100900007FFFCBFFFFDFFFFFBBF7BFFFFFFFFFDF77
146:10091000FFBFFBFFFFFFDE3FFFFFFFFFFFA7FFFF64
147:10092000FFFFEFFF7FFBFDFB7FFFFFFFFFCFF37CB0
148:10093000FF7F8D7FFFFFFFFFFBFFF7FBFEFDFFFF4C
149:10094000FFFFF7FDFF7FFD1FFDFFFFFFFFBFDFFF85
150:10095000FFFE5CFF6DFF7FABE7F1FFFD9FFFFFAD8B
151:10096000EB7A3F1FFFFFFEBFAFF3DEF5FF8FFBDF2C
152:10097000E67FFFDFF3FDFF7EFFFFFFFFFFFDF7F3E5
153:100980007FDFF7EFFFF63F9FDFFFFFEEFFFFEFFB9D
154:10099000FFFFF9FBFE4FBFEFBBFF69AFAFFCFF3FAF
155:1009A000DDFFFCBF8FFFFDF3BFED9EFCBF6FF5D3F6
156:1009B000DFFFDBD6F5EFFDFEFFB9FF1FD2A9AFFFCA
157:1009C000DBF7BFEF46FFFFADEB7ADFEFF7FF7FF717
158:1009D0009FEDFF7FFFADEB7FF56FFFFDFBD6F4F7DB
159:1009E000FBF97E7FFF5FC2FEBFFDFB33DFF95BFFDC
160:1009F000FFDD677DCFEFDBECFF77DDF7FDFFFFDE8F
161:100A0000A7BFD49FFFFFBFEFFEFFDFEFBBFFFFEFEE
162:100A1000EBFAFFEFBDFBFFE27FFFDFDFF7FDBFBBC0
163:100A200073F7FD7FDFDEF7BFEADBF6FFD6FFFF6679
164:100A3000FFBEFFBF6BD9F6DFFFFB7E7FB77EFFFEF9
165:100A4000FFCDFFFE7FFFFCFD3FFBFBF7FFFFFBF64B
166:100A50007DFE7FFFFCFFB9FFF9FAFEBFAF5BD6ED6D
167:100A6000AD7BF6F9BFEFF8FAFEBFFEE6FFFFF7FD3C
168:100A7000FF7FBFEFF3FFFF6FF7FEFFFFF7FDFEF70E
169:100A8000EFFFFBEFFB7EDEFEFFBFFFFEFFFFFBFF86
170:100A9000FFEFFB6FFC1FFEE7FFFFFFEFFFD3B4BBD1
171:100AA000FFFFFDBF6FE3FEFFBFFCBFF7CFF7FDFF0A
172:100AB0002FDFABEAFFDFE7EA9AAFEFFBFEFFF53F80
173:100AC000FD7EFFD7F5FBFFFDF7FF7FFEF7FDFFD7AC
174:100AD000FFD77FEE7FFA79FE2F8BE6F9FE3F9EF976
175:100AE000BE2F0BE7F9FE2F9FFDFFFE7D7F5FD7FF37
176:100AF000FF7FFFFDFF7F5F97FFFD7F5FFFE3FFFF4E
177:100B0000FAFEBFAFFBFBFFFFCFEBFEBFAFFFFAFE6E
178:100B1000BFFF87FFFFF5FFFFFFFFFDFF7FFFFFFF29
179:100B2000FBFFFFF5FFFFFE0FFFFDEBFFFFF7FFEF02
180:100B30007BDFFEFFFFDFF7FDEB7FDFFF5FFFFFFFE8
181:100B4000FFFDBFFF7EFABFC7DBF7BD3FFBFFF6FF30
182:100B5000FAAFFFEBFAFE3F2FEAFA3EADC9BAF6ADA7
183:100B6000AFEBFAF6BFFE7FFFFFFDFFF17F3FCFF156
184:100B7000EFFF7FFFBCDFDFF7DDFFE07FFFFFFEFF62
185:100B8000FAECBB7F5FFFFBECFFEFB7FFF7FFFFB5B2
186:100B9000FFFF7FFFFFFFEEDF5FDFDEFFAEE777FFE8
187:100BA000FFDFF7FFE3FFFABBFEFFAFFDFBFEBFABCE
188:100BB000F9FEFFBF7FBFFEBDFED7FF9FFDFFBEEF6B
189:100BC000FFEEFDBB5BEFFF7FEFFFEFFF7FFF4FFF10
190:100BD000EFFBBCFCFFFFFFFEFEFDFAFEFBFFFDF39B
191:100BE000FBFFF85FFFFFD7F5FDDFEFFFF3DC5FCE24
192:100BF000F5BDFFFFD7FFFFF93FFFDFF7FFFEFFFD6A
193:100C0000FFFBFFF7B97DFEDFFFFFFFFFF97FFFFE70
194:100C1000FFFF7FFFFEFFFFF7F6FFBFF1F8FFFFFFCB
195:100C2000FFE0FFFFFFFFF9FFFFFFFFFFEFEFFFFF19
196:100C30009BFB7FFFFFFFC1FFDFFF3F5FD7BFEFBB26
197:100C4000DEEEFF7FDFFFFEF57FDFFF99FFFFFAFF9C
198:100C5000BFFDEB7AFFB7FEFEFFFFEFFFFFFDBFFF1B
199:100C600097FFFDF7FF7FF7FFFFFD5FFEF3F9DFDF83
200:100C7000FFFFFCFFFF83FFFFFEFF9EECFBEEFF9FED
201:100C8000BFEFFFFEED7BFFFFFFF15AFFFFFDFF7C93
202:100C9000693BDFFF7F1FDFFFFDBAFFFFFBFF5BBD8F
203:100CA000FFFFFFFFD7B6EDE9FFD6BD6F5FFBFFEF9C
204:100CB000FF5FFEF66FFFFFFFFFF7EB7ADFFF9F7F1F
205:100CC0007FFFB7FFFFFEDFFF6CFFFBFFBB6FEBFE9D
206:100CD000CCF7A5FA5CF575BBB7DFFE6F5FC5BFFD4E
207:100CE0007BFEFF95E729CF4FF591EE6BDFEFFD54CB
208:100CF000F5BDB1FFEFEEFBBEBFAFFEDEBD6FDAF2BA
209:100D0000FFAFBEFFFFFD7EA7FFF7FFBFEF7BF6FD46
210:100D1000BD4AF28585BF5BFEB5FDFAFF4FFFFEDFE2
211:100D2000FFEDFFBFFFBF7FFEFFB76DFFF7BFBFEF58
212:100D3000FD1FFFFE7DFF67FFFFFF3F7FFEBFFFE759
213:100D4000DFE7FFEF6BFC1FFFBFEFFBFEDEBFAFFA7D
214:100D5000FFB6EFF9FEFF8FEFDBEFAB6FFBFEFFFFA0
215:100D6000EFFDFF7FFFFFDEFFFFEFFFFFFF3FFF6CA9
216:100D7000FFBFFBFFFEFFFBFEDFFFFFEFFFFFBFFF3D
217:100D8000FFFEFBFFD57FFFFFEFFBFFFFBFEF43B58C
218:100D9000FD6FCFD6BE3F7FDBFEC3FFFDFFAFEBFB9A
219:100DA000FCFF3EEFE8FABDCDAAFEFE7DCFFFB7FF08
220:100DB000F7FFFFFFFDFF75CD52D7FDFBF7DDFBEF22
221:100DC000EBFFFF4FFFBF9FE7F9FC7F8BC3F9AF8FAE
222:100DD000E7E9BE7F9FE6F9FC5FFFFFF7FDFF7A5F63
223:100DE000D7EDFFFFD7FFDD7FE7FFFCFFFC3FFFFFF5
224:100DF000FFFBFFFEBFAFFFFDFFEFFFEBFFFFFFFFBE
225:100E0000FFF77FFF7FDFFFFDFD7FFEF7FD7FDFFF49
226:100E1000FDFFFFDFFBFFEEFFFBFFF7FDFF7ADFF5D6
227:100E2000FDFADFF7FCFF7FDFBFEDFFC9FFDFFFBF8C
228:100E30002FFBFFBCADFFF7FFFFEFD3FF7DBF6FFFC1
229:100E4000FAFFFEBFAEEAFABEADA5EBCEBFA7EB5AE6
230:100E5000DEBDAF6BFD57FFFFF47F1F7FFDFF7F36C9
231:100E6000F0DF79FFFFFFF7FDBFFF87FFFBF3FCFF1C
232:100E7000FFFFFF7EFFBFDFFFFFFFFFFFFDBFF89F0C
233:100E8000FFFFFFFFBFFFFFFDF7FCBDFFFEFFFFFF02
234:100E9000FFFFFBF9BFFFFFEBE2FEFFBFEFA9BA2F99
235:100EA000EBF9FE77DFF7FFFFF97FFFFF7FEFD7FF5B
236:100EB000FDFFFBF5FFBF6FDFFFFFFDFFFFF0FFFF53
237:100EC000FF3FCFFFBAEE9BBFEED7FECDEFFFDFBFF8
238:100ED000FFFFC5FFFFFD7F4FFDF6D9FF4FD6FDBFDA
239:100EE0006EFFFFF47FFF7F8BFFFFFFFFF7FFF9FE31
240:100EF00037FFD9FBF5AFFDFFFFFBFFFF07FFFFFF4C
241:100F0000FBF7FFFDFF7CFA7E4FFCDF1DC7FFFFFFF5
242:100F1000FFAEFFFFFFFFFDFBFFFFFEFEFCFF7F7F3D
243:100F2000BFEFFEFFFFFF5FFDFFFFFFFD6F5AD77BA7
244:100F3000BE5FFE39FFF7FFF7FDFEAA1FFFFFFFFFB1
245:100F4000FEFEABAFFDFEBFFFF7FF7FFE8FE3FBEEC4
246:100F50007FFFFFFFFFEBFBFFFDBFEFDFFFFFFFFFAB
247:100F6000FFFFFFFBE43FFFDFFFFFFFFFF3EFBBFBF4
248:100F7000BFEFBBFFD7BFFFFFFF29AFF7FFFFFBFFAF
249:100F8000FBE6FF0FFB3FDF0FFFAFFFFFFFF5C3DF08
250:100F90005FFFFFFFFE6BCABEBCFF9FF2BFFFFEFA02
251:100FA000FFFFEF16FFFFFFFFFFFCDF97FD79FF3725
252:100FB000E77FFFFFB5FFFFF62FFFFDFBFEFFFFFD05
253:100FC0005F575FFFDB52DFFFFDBFFFFFFCDBFF7BF7
254:100FD000B5FD7FFF719C6EFFF635A59BFFFFFDFF02
255:100FE000FFDB9E7FFEEFFBFFFFBDEFFFDEB7F94BA0
256:100FF000FFF5EFFFFFFFE87EFFEADFF7FFFD695B2C
257:10100000FC9FEF78D6FFEBEFFFFFFFE8FFFFEDFF60
258:10101000FFFFFFE3F9F6BFFFFFFEDFFF7FFFFFFFEC
259:10102000D1FFFFE7FFFFFFFFE7F9FFBF7FD9FFFD1C
260:10103000FE7FFFFEFFF9FFFBD6DFBFEF5BD6FFBFF2
261:10104000FBF6FFBFEFF8F6DDBEFE16FFBFEFFFFEBB
262:10105000FFBFEFFFFFFF6FFBFFFFFF6FF3FFF7EF38
263:10106000FBFFBFFFEFFEFFBFFFFFFFBEBFFFEFFFB6
264:101070007FEFFFFD17FB7BFFFFFD7FDBF6F47FFAC1
265:10108000FEF5BFEBE3F7FFFFE9BFFFAFF7FDF37E30
266:101090008FA3EAFFCBF3EEFFBFEFF7F9FFFE7FFF71
267:1010A000FFFFFFF5FBF6FFF52FFEFBD7BFFFBEDF0F
268:1010B0009FFFF0FFFFF9FE7F8FA3F8FE6F9FF9F609
269:1010C0002F9FE7F9FE2F9FE1FFFFFF7FDFF7F5FD81
270:1010D0007F7FF5FF9F5FFBFEFF7FFFFFCBFFFFFBE7
271:1010E000FEFFBFAFFBFEFFDFFEFEBFF7FFFFFFFF10
272:1010F000FFC7FFFFFDFF7FDDF7FDFFFFD7FFFD7F90
273:10110000FFFBFDFFFFFEEF7FFDEFFBFEFBFDFF7F23
274:10111000DFFDFF7ADFF7FDFFFFFFFF1FFFFFD3F7C4
275:10112000FFFF6FDBFFFFEFCBF4FFFFFFFFFFFFFED3
276:1011300029FFE8DA769FAF6ADAFE35EBDAD6BFAB85
277:10114000EB7ADEBFD77FFFFEFFBFEFFDDF77BFFD8E
278:1011500037EFFFEFFF3FFFFFFFFE7FFFFFFFF77E51
279:10116000DFFFFFFFFAB77FFFFFFEFFFFFFFF89FFF3
280:10117000FFFFFFFFFFFFFFFFFF9FFBFFFFFFE7FFFB
281:10118000FFFFFFAAFFABFBFAEFBFFFDFFA7BB9FE61
282:10119000FEFFFDFFF7FE3FFFB7FFF7EEFF7FEFFF1C
283:1011A000FF7FFF1FFBFFBFFBFEFFBDFFFF2FFFBF4A
284:1011B000FF7FDFFAFFFFFCEEF5F3BEFB0FEFF3BEA0
285:1011C000EFFC5FFF5AFFF7DFFFFFFED5FC5FFBF28E
286:1011D000FFFF2FBBF3FFFFBFFFEFFFEFFFFFFFFF9F
287:1011E000BFFFFFFD7BFFDFB9FFFBFFD87FFFFFFFE6
288:1011F000FBFFFC7F1FBFE0DFF7EFFFFD7FFEDFFFA0
289:10120000E0FFFFFDEFFBFFFEF7DFFFEB5FFFF7FF08
290:10121000FFFFFFBFFFFDFFFDFFFFFFF7FDFF3BDC13
291:10122000FD6D7B5F57F5FD7F5FFFB1FFEBFFFFFFBC
292:10123000FBFBFEFFBFFBBEFFBFEFFBFEFFAFFEF7FA
293:10124000DFDFFFFFFF7FCFF3F8FFD7FBFF5FBFF7C5
294:10125000FBFF7FFE23FFFFFE7FF3FFFBFEFFFFF39D
295:10126000FFFFF5F9FF3FFFFFF09AFFBE7FFFFCF99C
296:10127000FFFDAFEBFEBFFFCFF3FE7FFFFF5BBDFFC8
297:10128000BCEBFFD7D4AFAFFDFFCFF7FDFF7FDFF79C
298:10129000FDFEFF6FFFFBFFFFFFFD7F5EFDBFDBF687
299:1012A000FDBF6FFBEEFDFF7AFFFAFBFF3FFBB75F71
300:1012B000D6F71F71DC771DC731DC77DFF9BFF55B2F
301:1012C000F4D79DAEFFBFFDBFDBF6FDBF6FDBF6FEC3
302:1012D0003D81FFEBFEFEFEFFEB7ADF7D777DF5794A
303:1012E000DF57DDF57D7EE6FFD63FBF7FFFD4F53FBC
304:1012F000BFFBBEEFB3EEFB9EEFBBFE8BFFFEDFB787
305:10130000EDFFF7FDFEFFEFBBEEFFBEEFBBEEEBFC2C
306:101310001FFFFFFDFFE7FFF7FDFFEFFEFFBFEFFB46
307:10132000FEFFBFEBFA1FFFB7EF5BFEFFAFEBDDE7A2
308:10133000DE779DE779DE779DBFE66FFFFEFFBFEFAB
309:10134000FBFEFDBF6FF6FDBF6FDBF6FDBFFF7EFF4F
310:10135000FFFBFEFEFFEFFBFDEF7EF7BDEF7BDEF751
311:10136000BDEFFFD5FFBFFFEFFEFFFC3F0FE7FE7FA6
312:101370009FE7F9FE7F9FE7FEF3FFFEDFADDF67EE3D
313:10138000FBBFEFFEFFBFEFFBFEFFBFEFFF23FFFF43
314:10139000FFFF7FFFF3BCDBFEFBFFFBBEF7FBFF7F26
315:1013A000DFFFCFFBFF9FE3F9BE3F8FE779FF9DE7AC
316:1013B000F9FE7F9FE7F9FE5FFFCFF7FFFFFFDFF743
317:1013C000FE7FE7F9FE7FFFFFFBFEFFFFBFFFBFBF12
318:1013D000FFFEFFBFEFFFFDFFFFFFFFFFFFF7FDFF7A
319:1013E000FF3FFFBFFFF7FFFF7FDFFFFFFFFFFFFFB5
320:1013F000FFFFFFFFFFE8EFFF5FF7BFF9FEDFB7FD7D
321:10140000FFDFF7FDFF7FDFF7FDFFDDFFF2FFBFFF2F
322:10141000FFBFFFFF2FF2FFBF2F7BD2F7BF2FFFBB16
323:10142000FFEE8FAFEBFAFE3FA769CE8FA4EAFAEE8C
324:10143000B7AEEBFDC7FFF7F7FFFFFFFFFF7F3EF300
325:1014400074FF3F4FFFE7FF3FFEA7FFFFDFF7B7FF48
326:10145000F7FFBAEF37EBFBFEBFFBFEF3FFF9DFFF51
327:10146000BFFFFFFFBFFFFFFFFDDFFFFDFFFFFBFE35
328:10147000FDFFFBBFFE3FEDFFDFBE3DA7FBFA3FE6F2
329:10148000E1FEFE3FEFE3DFF57FFEFF7EFFFFFFFFA4
330:10149000EF6FF6FF7DEFD7DEFF7DEFFFF2FFFFFF7F
331:1014A000FFFFFF7BDEFBE6EEEF376EF37EEB37EF01
332:1014B000FFC1FFFEFFF7EFFFFFFFBF3FD2DFBF2FF0
333:1014C0007BE2FFFE3BBDDBFFFEFFFFFFFFFFEFFE0A
334:1014D000FFFBFFFFBFFFFBDFFFBFFFB7FFFFBFEF5C
335:1014E000FFFFFFFFFFFF0FFF7FFF1FEFF1FDFFF685
336:1014F000AFFFFFFFFFFFEFFFFFFFFE9FFFFFFF7745
337:10150000EFF7FBFFFE5FFFFFBFCFFBF7DDF7F5FF58
338:101510005FD5F5FD7F5FD7F5FFFB0FFFFFA9EA7AE7
339:10152000FFAF8FFEDFAFEFFBFEFFBFEFFBDFE55F3F
340:10153000FFFFFFFFFFBD57FFFF6F77BFF7FBFF7F89
341:10154000BFF7FFFCBFFF9FFFFFEFFFFEFFFFFF1F87
342:10155000CFFFFCFFFFFFFFFB65AFF37CFF3FDFFF2B
343:10156000FDE9FE7FE7FFFE7FFFFFFFFFFDE3DFFBFF
344:10157000DBF6FDEF5BFBFFDFFCFF3FDFF3FDFF7FF3
345:10158000DFEF66FFDFADEB7ADEF7F7E7D9FD9F67A8
346:10159000D9F67D9FE7DFF547FD655BD6F4FEFFEFEB
347:1015A000FF6DF6DDB76DDB76DCB77DFA9BF66D9DE2
348:1015B0006759DFF7DDFFEBFEBFAFEBFAFEBFAFE32E
349:1015C000D19FFFBDBFEFFEF7BFBFF7D77FDDF79D10
350:1015D000DF7FDFF7FFE07FFDC1DFF7FDC77F7FFB28
351:1015E000FFBBECFB3EFFBFECFBFFD87FBF6CFFBE39
352:1015F000FFBFEDFFEFFEFBBFEFFBFEFFBFEEFFC542
353:10160000FFAF6FFFFCFD3FE7FFFEFFEFFBFEFFBFFD
354:10161000EFFBFEBF89FEFABAFEBFAFFBF6F5D97D40
355:101620009765D9745D9765D3FED6FFBFF7FDFF7F41
356:10163000BFCFFBFEFFEFFBFEFFBFEFFBFFF68FFB15
357:10164000FFEFFB7EDBFEFFBEEFEEFBBEEFBBEEFB74
358:10165000BEFFFFDFFF43FFFFFBEF5FB7FE7FE7F952
359:10166000FE7F9FE7F9FE7FF9BFFEAF77FDFF2FAF4B
360:10167000A7FEFFEFFBFEFFBFEFFBFEFFF17FEFDFFB
361:10168000FF97F5EFFFDFFFFFBFFFBFFFFFFEFFFF8D
362:10169000FFE0FFFFF9FE2F8BE3F8BE779FF9DA77C3
363:1016A0009DE779DE779FDDFFFDFD7F5FD7FDFF7F43
364:1016B000E7FE7F97E7FBFEFFBFEFFFABFFEFFAFE12
365:1016C000BFAFFFFAFFFFDFFFFBFFF7FDFF7FDFFF8D
366:1016D00067FFF7F5FFFFFFDFFDFFFFFFFFFFFFFFE6
367:1016E000FFFFFFFFFFEFFFBDEBFFFFF7ADEBFFDFFE
368:1016F000FDFF3FDFF7FDFF7FDFFF5FFFF7FFFFFD30
369:10170000BFFFCBF4FF7FD3F7FD3F7FD3F7FFFC3F55
370:10171000FFEAFABEAFABEBBAF4956B52D4AD2F4AE9
371:10172000D2F6BFD27FF73FFFFFF37FFFFFF7FFBA8D
372:10173000DFFBFDFFBFFFFBFFF87FEAFFFEFEDFFFE1
373:10174000F7FF7FBBFFFFBFDFFBFFFFBFFFB17FFFE7
374:10175000FBEFFFFFFFFFFFBFCFFEFFFFEFFFF7FF36
375:10176000FFFFF1FF69BEFABFAFE2FFFEFDAFF3FE80
376:10177000FFBFEFFBFCFFFF07FD95DBDF7FDFAFFF68
377:10178000F7AF36FEBF65EBF6FE9F6FFE07FFCFFF9C
378:10179000F8FEFFCFFFF6FAE7FBFEFFBBEDF9FFFF18
379:1017A000FF5FFFFFFF75FFEF7EFDE0E85ED3E5F929
380:1017B0003E5FD7F7FFFA2FFBFFFFFFFFFEFFFF7F24
381:1017C0007FD7F57D5F57D5F5EFFFF37FFC7FFFC730
382:1017D000F1FFFF1FCFB0FF3FCFF3FCFF3FCEFFE491
383:1017E000FFDF7FFEF7BBFFFFDFEFEEFFBFEFFBFE8C
384:1017F000BFBFEFFFD1FFFFFFFDFBFFFDFFFB9FE939
385:10180000FE7F9FE7F9FE7FBFFFB3FFFFF7FFFFAF4C
386:10181000F7FFB63FEBFAFEBFAFEBFAFEBFFEA7FF46
387:10182000FFFFFFFFF7FFFFFFFE9FF7F9FF7F9FE737
388:10183000FFFFFEAF6FFFFFFF9FFFDFFF7D5FDDFF5D
389:10184000FBBFE7BBFFFBDF6D5F7EFFFFFFFFFFFF1F
390:10185000EBF7FFE7EFF7FFFF7FFFF7FFFC8FFFEFEF
391:10186000FDFEFFBEF4F27DD7CFFF3FFFFFFFFFFF7E
392:10187000FFCF6BFFBF3FFBF2FC7FEBFF9FFAFFFF49
393:101880003FFFF3FFFFFD70F7FFFFBFFFFBD7FEF544
394:1018900077FF15DD77FDFF7FDFF7FBCDBFFFFDFF96
395:1018A000FFDF37CDF9ECFEEFBBF4FB3F4FB3FFFD9D
396:1018B000CBFFE97E549FE54BB7FFDD7DC771DD7738
397:1018C0005DD775CD7FD6FFD3F6F93F6D95AF7FFE1F
398:1018D000FFEFFBFEFFBFEFFBFEF6C7FFAD7BCAFFCE
399:1018E000BFBFEFFDE3DFB7EDFB7EDF37EDE3FBDFEF
400:1018F000FF525C15FDCF7FDFFEEFEFFBFEFFBFEC7D
401:101900007BFEFFFE3E7FDAF7FDFF7FFFFFFBEFBBB5
402:101910006FFBFEFFBFEFFBFFF77DFFD8FFFDBF7F33
403:10192000FBFFFF9FFBFE7F9FE7F9FE7F9FEA7FF6AD
404:10193000BFBD6A5AF6E5BF775F6DDD775DD775DDB0
405:1019400077FFA5BFCFFBFFFFBFCFFBFDFFBFF3FEC0
406:10195000FFBFEFFBFEFFFDABFFBFBFFFFBFF7FEF56
407:10196000FFBEFBEEFBBEEFBBEEFBBFFFB5FFD0BC87
408:10197000FD2F4BF7FFFF9FF9FE7F9FE7F9FE7F9F4B
409:10198000FA8FFDABFADABFAFB3FDFFBFFBFEFFBFBF
410:10199000EFFBFEF7BFFF9FFF77F7BDFD77DFFF7E11
411:1019A000DFEDBBFEFFBEEFFBFEFFFA3FFFBE6F8F1A
412:1019B000E6F9FE7F9FC7FE7F9FE7F9FE7F9FE7FB6B
413:1019C0007FFF7FCFFFFDFFFFDFFBAFBFEFFFFEFF1E
414:1019D0009FEFFBFFFCFFFBFEFFFFFFFFFEFFFFF79C
415:1019E000FFFFFFFFFFFFFFFFFFF5FFFFFF3FDFF7F9
416:1019F000FFFF7FEFFEFFBFFFFBFFFFBFEFFFB37FE8
417:101A0000FF7B5EF7FDFF7B7FF7FF7FDFF7FDFF7F4B
418:101A1000DFF7FF17FFFFFF7FFFFFDDF6FCBFCBF215
419:101A2000BCBF2FCBF2FCBFFE8FFFFA7EBFA7EBDA65
420:101A3000FCBFAF7AFEBFAFEAFAFEBFAFF4DFFEFF36
421:101A4000F33C7F3EFFCFF8BF8FE3F8FE3F8FE7E820
422:101A5000FFFC9FFFFFCFEBB3E7FB7BF3FEFFCFDB8A
423:101A6000FBFBBF6F6FDFEC7FFFFFF7FDFDFFFFFFAD
424:101A7000FFB2BFFFDEFDBDEFFBF6DFEAE7DBFEBB3B
425:101A8000FFEBFBBF9F8FE8FE3F8FA3F8FE3F8FFF6A
426:101A9000F87EFDFD7FFFFBCDFFFDFF5FEFFDFFFF4C
427:101AA000DFF7FDFFBE90FFFFEEFF3FBFF3BBFEB7CA
428:101AB000ABFAFEAFADEAFADEABFF63FFFEF2FFB3B7
429:101AC000FFDFEE7DFF03F1F43F1FC3F1EC7FFE6FFC
430:101AD000FFFBFBFF9FFFBFFF7B5FFDFFDFF7FDFD10
431:101AE0007F7FDFFECFFBFFFFAFFBFF1FEFA5FDBF3B
432:101AF000DFFB7DFFBFDFFBFFFD3BFFFFFFFFFFFDC8
433:101B0000AFF3FFFB7FBFD7FBBF7FBBF7FFF87FFFC4
434:101B1000FA5FD7FFDF7FEFFFFF7FDBF7FDFF7FDFA0
435:101B2000B7FBECFFFFF7BFEFFDFCFBFFEFF0FE3F65
436:101B30008FE3F8FE3F8FEF8DFFFFEF7FBFFFFBFFCF
437:101B4000DBBFFFFFFFFFFFFFFFFFFFEFD8FF2E7F91
438:101B5000BEEFFE6EFFBFF9FFFFF3FFFFFFFFFFFFCA
439:101B6000FC66BE47F37FDFFE879FFFFFFFFFE7FFB7
440:101B7000FFFFFFFFFFD66F7CFB4FD2FFFD2BFEFF69
441:101B8000FFFD5FD7D5F57DFFFFFFBF9BFFFFDFB7F1
442:101B9000FFFFDFFF3FCFFE7FBFEFFBFCFF3FFFD923
443:101BA000BFFE97EC8FB7FE9B7DFDB7DD771DC7713C
444:101BB000DD775DD7F36FFD3F73DDAFFD7AFFFFAFDC
445:101BC000FEFDBFEFFBFEFFBFEF667FFFFFBFBFFF66
446:101BD000FBFFF7DFFDFB7DDFB7CDF37C5F3F913F80
447:101BE000FF3DEF7BFFFCFFCAEFFEFFBDEFFB1EE7F3
448:101BF000BBEC7FB3FFFD9FFFFFFEFFFF7FBFFBFE40
449:101C0000FFBFEFFBEEFBBFDF67FFFFBFEFDBFFBCFC
450:101C1000FE7FFBFF9FEFF9FE7F9FE7F9FE87FFEE58
451:101C2000FBBEE5BFEFF9D765F7DDE77DDF775DD771
452:101C30007FF89BFEFFBFEFFBFFFFBFEFFBFF7FCFF8
453:101C4000F3FCFFBFEFFFDB3FEFFBFEFFDFFFFEFB21
454:101C5000BBEFBFEFBBEEFBBEEFBBFFFC7FFD3B5B13
455:101C6000D6E5FD4FC3FBFFBFEFFBFEFFBFEFFBFF62
456:101C7000B4FFFABC8FB2E9D22ECFFBFFBFEFFBFE61
457:101C8000FFBFEFFBFFECFFFDFD7FDFF7E4DF5FFF52
458:101C9000FFFBFFFFFFFFFFFFFFFFC3FFEFE6F8FEC5
459:101CA0003F8B83F9FE7FE7F9FE7F9FE7F9FE7F1701
460:101CB000FDFFFFFF7F5FF72CFFFFFFFE7FFFE7F9D0
461:101CC000FE7F9FFE2FFFFFEFFFFEBFEFADFFFF7F09
462:101CD000FFFFFFFFFFFFFFFFFEDFFFDFFFFDFD7FD9
463:101CE000DFF7FFFFFFFFFFFFFFFFFFFFFFFA3FFEF2
464:101CF000F7FDEF7AFFB1BDFF7FF7FDFF7FDFF7FD57
465:101D0000FF7FF327FFDFFFDDFFFC9BFFCBFCBF2F37
466:101D1000CBF2FCBF2FC9FFDEFFDFAFEBDAFEBBAFBC
467:101D2000EBF8F7AFE8FAFEBFAFEBF2FFFDFFFFEF16
468:101D3000BDD7BFFFFFDE8FB8DE378DA378DA3F8FC8
469:101D4000FFA1FFFFFBFBFFFFFFFFA7BDFB76FDBF72
470:101D5000EFDBFEBBBFFE277FFFFEFEFDF5FFEFF5CD
471:101D6000DF1FE7FDFF7FDFF7FDFFFFCDFDAEFFFAD1
472:101D70003E3FABFDF87E8FE3F8FE3E8FE3F8FFFEBB
473:101D80001FEFDFBFFEDEDFD9FFDFBCFFFF7FFFEF0E
474:101D9000FD7FDFF7F93FFEFFFF6FFEDEBFF7EDEAE5
475:101DA000FD8F83F8EA3F8FEFFFF47FFFEFEF7BF3C8
476:101DB000F15FFFFFF13B7FDFF7FDFFFFFFFFE0FF7C
477:101DC000FFFFF7FF6FFF7FFFFFF7DEF7BFEFFBF7C8
478:101DD000FDFFFFF5FAFFFFFBE7FFF3F87FF3DFFFFF
479:101DE000FFFFFFFFFFFF1FEFBBFFFFFFFFFFFFFD39
480:101DF000FF7FFF9FFFFFFFFFFFFFFFCFFF37FFFFCB
481:101E00007FDF775DE7FCFFBFF7F5FBFFFFD7F5FB53
482:101E1000FFFF45FD7FEAFDBEBFDFF7FFFFDBFBFEF7
483:101E2000FFBFEFFFFFFFFB5F7FFFFEFFFFFFFFFF37
484:101E3000FFFEFFEFFDFF7FDFFFEFFBF80FF3FFF982
485:101E40002EFBFEFCF3EFFFFFBFFFFBE7FFFE7EFF75
486:101E5000C06BCFFF34DFF1FDFFEFFFFFFFDFF7FDCA
487:101E6000CF7F9CFDFD6CF7FFF6FDEB2B9FFFFCFE8B
488:101E70007EFFFFFFFFD7F3F7FFFBE1BFFFEB7ADE4B
489:101E8000D7FBFFF9FEFFFFF3DE7FFDE77FFFFDBB22
490:101E9000FFFF7ECCF6AF5F7FFEF47DF7FDBB6EDB10
491:101EA000B7FFF7DF66FFFFF73DCFDEBDFFFFDEDBED
492:101EB0008DF77EDFB7EF7FFFF687FFFFEFFEDEBF18
493:101EC000FFFFFFBBEFFDFF7BDEF73FFFBFFBDBFF4D
494:101ED000F2B6FDBD7FE7FFFFFF6FF7FFFFFFFE7765
495:101EE000FFBFF8AFFFDFBFFFBF7FFBFFFFFFDBFEE2
496:101EF000FFBFFFFAFFFDFFF67FFF9FFFFF3FEFF8F9
497:101F0000EE7E9FBAFEBF8FEFFEFEF9FFFA7FFE7EE8
498:101F1000BFAFFB96FD9FEF5E65BEEF5BB6FFBEE316
499:101F2000FFB5BFFFFDFF7FFFEFDFFEFFBFFBFEFF43
500:101F3000BFCFFFFFFFFD9BFFFEFBFEDFFF7FFFF735
501:101F4000FEFFDFFBFBFEFFFFFFFFFFB7FEFAFFAB6D
502:101F5000EFFFFDB57B7FFBF7FDFFFFDDFFEF8FFFA1
503:101F60002FFFFB7CFF3FDF73EBFE3FFFEFFBFEFF2E
504:101F7000EFFDFFBFFD0FFFFFFFF5F9FF7FD7FDFF6F
505:101F8000DFFFF7FBFF7FBFFFFFF09FFFFE7F8BE3CD
506:101F9000F9DE279BE6BE7F9BC3F8DE7F9DE7FE7FD1
507:101FA000FFFF5FD7FFFFFF4FFBFFFF7FFFAFFF9FED
508:101FB0007FFBFFE8FFFFFEBFAFFFFFFEBFEFF7FFB6
509:101FC000BFFFFFFFFFFFF7FFFCFFFFFD7FFFFFFFEE
510:101FD000FD3FCFFFFFFFFFF7FFFD7FFFFF93FFFFF9
511:101FE0007ADFF7FFFF7B7FB7EFFFFFFDBFFDFBFF52
512:101FF000F7FFD7FFFFFFFC9F6FCBFFF4BBDFD6FDE2
513:10200000BF2FD3F7FFDFFFCFFFFABEBDAF6ADABE47
514:10201000BBAB3ABE2DAEEBDAF63FADF5DDFFCFF14F
515:10202000FFF97FFF73FEFFCFC3F4F72FF3FFFCFF31
516:102030007C1FFF3F4FFF7EFFEFBDF6FEFF2BEFDC67
517:10204000FBFDFFFBFFEA7BFFFFFFFFFFFBF7DFFF6F
518:10205000E37DFFB7FFBFFFFFDFFFF8FFBFFFBFEB71
519:10206000E7FAFE3DBFE9FCBFFFFAFBFEFFFFFFD929
520:10207000FFFFFFF67FFFF67DFFDFCFFDBFFBEF7EAB
521:10208000FF7FFFFFD3FFFDFBFFFBFFFFFFEFFFBF66
522:10209000FEFFF7EFFFFFFFFBFF87FFFDFFFFFFFFE7
523:1020A0007BFEFFFE3BF7F7FF3FFFFFFFFFFF0FFF4A
524:1020B000FFFFFFFBFFFFFFF7FFFFADFFFEF7FFFF97
525:1020C0005FFFFFDFFFFDFFF5FFDFFFBDFFE9FFC79C
526:1020D000F3FFFFF7FFF3FFF83BFFFF7BDFBFFBEFF3
527:1020E000FBFFFBF7F7BBFFFFFFFFFBFFFE7FF37F6D
528:1020F0005EB7BFFD7FFFF97FFBFFEBFD7F7FFFEF4B
529:10210000FBE03FFEBFBFDFFF7EFFF7FFFFFEBFFF2D
530:10211000DB78FFFFFFEEA1BFF5DEFBF7FFFBFFFF64
531:10212000FFFFFBFFFFD7FFFFFFFFEFF0FFFFFFF316
532:10213000F7FFEFFFE7CFFFFBFFEFFFFF9F9FEFFCF6
533:1021400016BFFEF3E4FFFFC6FFE7FFFFFDFFBFFF83
534:10215000FF3FFFBFD6AF7FFE6B7E7FFFAFFFFFBFAE
535:10216000FF5FFFFEFFFFFEFFFFBDDBFFFE5FF2FF35
536:10217000FF5FFFFFFFFFFFFFEF7FFFFFFFFFDEBF00
537:10218000FFFFEFFB77FEBD7F5FFFFFFFDF6FEDFF20
538:10219000FDFF7FFD6FFFFF77DACFFD5FFFBFFFFF22
539:1021A000DF7FFFFBFFFFFFFF667FFFFEBFE7BFFA9A
540:1021B000FFFEFFFFFFDFFF59EFFFEFFB7F89FFFF10
541:1021C000E9FF6FFFF5FFFFFFFFFF7FF2F7FFFFEF74
542:1021D000F87FFBFFFDFFFFD9FFEFBBFFFFFFBFEF66
543:1021E000DEFFFF9F7FDFFFF7FFFFFFFFDFFFFFAF98
544:1021F000FFFFF73FEB9FFE7F9E7F9FFE87FFEDDB9C
545:1022000056FFBFAF0BD2FFEFDB6E7DBD6FF8FE3F19
546:10221000FA5BFFFDBFEFFFBF6FDBE6FFFF3FFFDFB6
547:10222000FEFFFFFFFFDA3FFFFBFEFEFFFFDFF7BD14
548:10223000FFFDFFFEFFFBFFFFFFFFF15FFD9FDFFDE7
549:10224000FFFD7FFFFFFFFF76FAFFFF7FE3F8FFAEA2
550:10225000FFFB7E9D73FFFA7FDFFFFF7FFFFBCDFF5C
551:102260007FEFFBFFFDFFF77F7FEFFFEDFFFFFFB588
552:10227000FFBFFFBFFDEFDBF7FF93FFEFE2F9BE7F8C
553:102280008BE7F9FE6BE7F9FE7F9FE7F9FE7F47FFDB
554:10229000FFFDFF9FFFD7FFFFFFFFF5FF9FFFF7FE4B
555:1022A000FFBFFE6FFFFFFBFFFFFFAFFFFFFF7FFBE7
556:1022B000FFFEFFFFFFFFFFFDDFFFFFF7FFFFFFDF79
557:1022C000FFFFFF5FFFFFFFFF5FFBFEFFF837FFFF32
558:1022D000EFFF7FFEBFFFFFFEBFFFFF7FFFBFFDFFE2
559:1022E0007FFA7FFFFF6FFFFF7DFFCFFFFFFF4FFFF5
560:1022F000F2FFFFFFFFFFFABFFFAEEBFAFEBBADEB55
561:10230000FAF7AF6BFAF6BF25E9F27F45FFFFFDF75D
562:10231000F7BFFFDFFFFFBFFBFFDFF3FFF73FCFFF9D
563:10232000A1FFFFBFE7FFFF7FFF3DFFFFFFF7FF2F8D
564:10233000FFFBF57FFE57FFFFFFFFFFFFFFFFFFF7EC
565:102340003FFFFEFFFFFFFDFEF7EEAFFEEEE7FAFFF9
566:10235000FE9DF95EFEFFEBFFFFDFA7FFFFFFFCDB4B
567:10236000FFFFFF7EFBFFFFEFFBFDFFDBFFFFFFEF4C
568:10237000FFFFFFFDBFFEBFFF6F7FFFF7FFFFF9FF0E
569:10238000F7FFBFDEF7FFFFFFFA7FFDBF5FFFFFBF75
570:10239000FFEDFFF7BFFFFFEFFFDFFFFFFFE6FFFBF4
571:1023A0007FFFFFFFFFFFF7FFFFFFFFFFFFFFEBFFD9
572:1023B000FDFFF5FFF67FDFBDCFFFFFFFFFDFFFFF74
573:1023C000FFF9FFFFFFFFFFE3FFEEBFFF7DEFFEFF23
574:1023D000FFFFBFFFFFFFFFFEFFFFFFFFE7FFB5AE01
575:1023E000FFFFB6FEBFFFFFBFFFFFFFFFFFFFFFFFC7
576:1023F000FF27FFEFFE7FDFFF7EFFFFFFFFFFFFFFF7
577:10240000FFFFFDFFF7F99FFF5FFFFFFFFFFFFF7F6C
578:10241000FFFFFEFFFFFFFFFFFFFFFF0FFFE7BFFE16
579:10242000FFBFFFFFFFFFFCBFFFFFFEFFFFFFFFC47B
580:102430006BFF291FFBAFFFFFFFFFFFEF1BFEFFFC42
581:102440006FFFFFFD6AF7D7F5BFFFFEFFFFFFFFFF3E
582:10245000FEBFFFFFFAFFFFF7FBDDBFFFE7FFFFFF58
583:10246000FFFFFFFFFFFD7FFFFFF5FFFFF7FDB3EF6E
584:10247000FD7E5DFFFDFFFFFFFD7FD2F5FB7ECBB74D
585:10248000FFFFFFC6FFFDEE63FFFFFFFFFFF6FD65E9
586:102490005BDFFFD5FFFFFFF6E7BFF7A9FFFFEDFF0B
587:1024A000FFFFFFFFEBFFFFFFAFFFFFFFF81BFFE3A7
588:1024B000D0BFFFE1FFFFFFFFFFD7FFFFFF5FFFFF81
589:1024C000FFFFAFFFDB76BFFF7FFFBFEFFEFFBFEF7A
590:1024D000FBFEFFFFFFBFF27FFF9FFEBDFE7FFFFF02
591:1024E000FFFFFFFFFFFFFFFFFFF73FEC7FF695BB0E
592:1024F000EFF8FEFCBF2FDAFCBF2FCBF2FCBFEFFFE3
593:10250000A9BFCFFBFFFFFFFEDDB76DF6D9B66D9B10
594:1025100076D9BFFBFDA3FFBFEFFFEFFFFFFF7FDF1C
595:10252000FDEF7BDEF7FDEF7FFFFF05FFFAFE7FEF9C
596:10253000E3FFFFFD7FFFFFFFFF5FFFFFFD7FFBAFBF
597:10254000FF63C8FFBFEFFFFFFA7FFFFFFFFE9FF7AC
598:10255000FFFABFFE9FFB7FFFFFEFD7FFFFF5FFFFF7
599:10256000FFFFFD7FFFFFBFFFF9BFFFBE279FE7F91A
600:10257000FE7F8BE7FE7F9FE2F9FE7F9FE7F17FFF03
601:10258000FFFFFBFEFFFFFFD7FFFFFFFFF5FFFFFF92
602:10259000D7FFFAFFFEFFFFFFFDFFFFFFAFF7FFFFD3
603:1025A000FFEBFFFFFFAFFFC4FFF7FFFFEFFFFFFFF2
604:1025B000FF5FFFFFFFFFD7FFFFFFFFFFEBFFFB7A90
605:1025C000DFF7FDFFFFFEBFFFFF7FFFAFFFFFFFF75E
606:1025D000EFE3FFDDD2FFDFFFFFF2FCBFCBF6FDBF75
607:1025E0002FCBFF7FDFDEAFFFDAEEBFAFE9FAF4BD3E
608:1025F000AF5AAEBBAB6BDADEBFADD75EFFFFBFFC41
609:10260000FFDFFDFFFFFFFFDFF7FFFFFFFFFDFFFA2B
610:102610001FFFFEFBEFBFFDFFFDBD77FFFFFFFF9D2F
611:10262000EFFFFFFFEF7DFFFBFEEFFFFFFFFFFFF779
612:10263000FFFFFFFFFFFFFFEEBFE4FBFFFE3FFEFFDC
613:10264000FFFFFFAFEAFEBFAFEBFAFEFFFFFF55F65D
614:10265000FFFEF7FF7FFFEBF75FC5FD7F5FD7F5FF5D
615:102660006FFBFF8AFFFFFFFFEBFFFFFFFFFBBFBF1B
616:10267000EFFBFFFFFFFFFBFF77DFFBFFFD7FEFFFC0
617:10268000FFFFBF7FFFDFBFFFFBFFFFFFFEEFDFFFAF
618:10269000FEFF9FEF7DFFF7FF7FFFFFDFF7FDFFEFFF
619:1026A000DFFFDFFFFFFFFFFFFFFFFFFFFDFFFFFB80
620:1026B000FDFFBFDFD1FFF83BFFFFFFFFFFFFFFFF85
621:1026C0007EDBFDFF77DBB77DBFFBFFF87FED7B5E39
622:1026D000FFFEFFFF4FD7FD7FDFD7F5FF7FFFFFFF37
623:1026E000F23FFEFFBFFFFFFFFFBFEFFEFF3BEEFF2E
624:1026F000FCEFFFFFFF85FFFDFEFFF5FFFFFEFFDFA5
625:10270000FBFF5FBFFFFDFFFFFFFFA8FFFF9F9EFFD7
626:10271000FFFF7FF3FFFFCFFFF7FDFF7FFFFFFC16FB
627:10272000BFCFA3E5EF7FFFF3E4FFCF93FCFF3FCFE5
628:10273000FFFFFFD60F7DBF6EFBF4FCAF6DDB77B7FD
629:102740006DDBF6FDBFFFFFFFBF9BFADEB7B7EDF90C
630:102750007EB7ACEBD6B3ADEB7ADFFFFFFFD8BFFFA0
631:10276000B7ED9F6FDDF768DB37B36CDB36CDB37F3A
632:10277000FF7FF56FFDEF793DF793E47A9EADEA7A3E
633:102780009EF7BDEFFFFFFF767FFBC6FFBBEFDAFED4
634:10279000FDBFFBFEFFBFEFFBFFFFFBFFA5FFFDAB98
635:1027A0006F78DE178F79DFFDFF7FDFF7FDFFFFFB1F
636:1027B000FFFBFFEFFBEFFBFEFFBBDAF3EF3BCEF3DC
637:1027C000BCEF3FCFDFFFB7FFFFFFCF73FFBFEFFFD0
638:1027D000F3FF3FCFF3FCFF3DCF9FFE07FFAFEBFEC4
639:1027E000FDBFEFEBFAFFAFEBFAFEBFAFFBFE3FFB27
640:1027F0009BFF7FDFFFF3FEFFDEF7BF7BDEF7BDEF62
641:102800007BFEFFFFDF3FFEFFB7FFEFF7FFBFEDFEF1
642:10281000DFB7EDFB7EDFFFFFFFFD5FEFEBFAFEF5BD
643:10282000BF6FFFFFFFFFFFFFFFFFFFFEF8FFA8FFE7
644:10283000FFBFEFFB6AFBB7EFFBFFBFEFFBFEFFBF86
645:10284000EFFBFFE0FFFFFD7F5CD77DDFF35CF5CDA5
646:10285000735ED7B5FD7FEFFFDBFFFFE2F8BE2F8F82
647:10286000E7F8BE6BE2F8BE2F8BE2F9FE7FE7FFD7F9
648:10287000F5FD7FFFF7F5FD7FD7F5FD7F5FD7F5FF0E
649:10288000FFFF8FFFAFEBFAFFFFBFEBFAFF2FEBFA73
650:10289000FEBFAFEBFFFFFE5FFF5FFFFFFDFFFFD758
651:1028A000FFFFFFFFFFFFFFFFFFFFFFFFBFFEB7FDC3
652:1028B000FF7EDFF7ADFF7FF7FDFF7FDFF7FDFF7FD7
653:1028C000F67FFFFFFFDBF6FCAFFFFFFFFFF7FFFF29
654:1028D000FFFFFFFFFFECBFFFAFEBFAF6AB8FEBFAAA
655:1028E000F7A5EBFABEBFAFEBFAFF6DFFFF7FDF335B
656:1028F000DDFF7FFEF7FC7FFBFFFFFFFFFFFFFFA970
657:10290000FFFDFFFFFEFFFFDFFFFFEFEFFDFF7FFF9C
658:10291000FFFFFFFEA7FFFFFF77DFF7FD9F7FFE773B
659:10292000EFFFFFFFFFFFFFFFFFAFBFAFFFF9BEBF2E
660:102930008FFBFEFEEFFBFEFFBFEFFBFFFFFDDF6F38
661:10294000EFFF7FFFBFBFDFFFFCFFDFF7FDEF7FDFA4
662:10295000FFFFFF3FF6FFCFFFDBFBF7FFEB7AFFFF49
663:10296000FFBFEFFBFFFFFFFE6DFDFF5FFBFFFFF70C
664:10297000FF5FF5FFFFFFFFFFFFFFFFFFF8FFFBFF1C
665:10298000FFFDFFFFFFFFE7F6BFFFFFFFFFFBFFFFBE
666:10299000FFC9FFFFFFBDFFBFAFEFEF3FD1FC7FFBE4
667:1029A000C7FFFFFFFFFFE3FFFFFFFFFDFFFF77FF15
668:1029B000DFB7FDF7FDF7FFFFFFFFFF57FFF7A5FDAF
669:1029C0003FDFBFBFFE7FFFFFFFDFFAFDFFFFFFFE20
670:1029D00087FFE9FFFEEFBFEFFEFEFFEFFFFFFFFF08
671:1029E000FFFFFFFFFA9FFF3FFFFDFD57DFFDF3FFF6
672:1029F000DFFDFF5FDFF5FDFFFFF98FFFFFFFEE7FDC
673:102A0000FFFFBF5EFEECFB3F7F9FEFF9FFFFCD6B4B
674:102A1000FFFFFFC5F3FCFA38FFAF3FEE7F9FFFD902
675:102A2000FFFFFD7AF7FFF3FFAF6FDBF2B9E9FBFFC2
676:102A3000FFFFFEFFFFEFFFFBC5BFFFEFFF5EB7AD80
677:102A4000CD797CFFFFFFFFFFFFFFFFFFFD93FFEF4F
678:102A5000EAFEBFEF5BD2CDF56D77DFF7FDFF7FDFDD
679:102A6000FFFF66FFD5657D5F759D657FD6FB4FFFD8
680:102A7000FFFFFFFFFFFFF6C7FFBFEFFAFEFFBFEB51
681:102A8000FFDFFF7EFFFFEFFD7ED7FF78DFFF5FDF19
682:102A9000F5BF7FDFC5FF3FF67EFF0FEFF23EBFFFC2
683:102AA000FB3FFFFB7FFFB3FEFBF6FDFFDAF7FDFF09
684:102AB0007FDFF7BFFFFA7FFFFFFFFF9FFFF3DCF928
685:102AC000BFCEE7F9FE7F9FE7FFFFE27FFEFFBFEF8C
686:102AD000EBFAFF9F671EFF8FE7F8FE7F8FEFFFBDCA
687:102AE000BFFFFBFFFFDFF7FFFCFFBFFFFFFFFFFFA5
688:102AF000FFFFFFFDB3FFFFEFFFFFBFEDFFFBEEFEAC
689:102B0000FFFFEFFFFEFFFFFFFFB5FFB7FDFD6EFF0D
690:102B1000FFFEFD2FD8FEBF8FEBF9FE3FFFFACFFF80
691:102B2000E7D9FABFDF77FCFB3FABFEFFBFEFFBFE51
692:102B3000FFFFEE1FFFDFF7FFFFFF5F9735BF5EFE72
693:102B4000BFEFFFF7FDFFFFFABFFFBE6F9FE7F8BEC5
694:102B50002F8B66947D9DE7F9FE7F9FE7F17FFFFF56
695:102B6000FFF7F5FD7F5FFBFD9EFFFBFEFFFFEFFF25
696:102B7000FFA0FFFFFFBFEFEBFAFEBFB7F7F7FFFFC6
697:102B8000FDFFFFFFFFFFDDFFFDFFFFFFD7FFFFFFA3
698:102B90007FF5FFFFEFFFFFFFBFFFFFABFEFBFEFF79
699:102BA000F7AFFFFFDEF7EB5FDFF7FDFF7FDFFFFF34
700:102BB000B3FFC9FEFFFFFFFFD6FFFFCBFFFFDFFF25
701:102BC000FFFFFFFFFC8FFFBABEBFAFEB78FEB7ADD4
702:102BD0003AFEB7AFEB7AFEBFAFFF9FFFFFDFFCFF10
703:102BE000FFFEC3FEFFFF33FCFFBFDFF3FFFFBB9F12
704:102BF000FFFFFFEBDFFFFFAFF76FF9BFEFFDFFFF59
705:102C0000FFFFFFE37FFFFFFFFBFFFFBFFDFBF7FFC2
706:102C1000DFF7FFFEEF5FBDFFFAFFF8FFBFAFFBFE80
707:102C2000FE3FEFE8FFDFF3FDFFFFFFFFFFEDFFFBE0
708:102C3000FDFFAFFFFFFEFEBFDBFFFFFFBFFFDFFFBC
709:102C4000FDFFCBFFFFFFFFFFBF6FFF7FB7B3FFFFAE
710:102C5000DFFFFBEFFFFFFF07FFFBFFFFFFEDFFF5D0
711:102C60007CFF7FFEFFFFEFCFFFFBFFFF2FFFFFFF8C
712:102C7000FFF3FFFBFFFEFFFFFFFFFFFFBFFFFFFFB5
713:102C8000FD1BFFFFFFFFFFFFFFFFFE7CFFFFFFFFBE
714:102C9000EFFFFFFFFFFBBF7FFDFFFFFFFFFFFFFF1A
715:102CA000DBFFFFFFFFFFFFFDFFFFF07FFFFFFFFFE9
716:102CB000FFFFFFFFFFFBFFDFFFFFFFFFFFFDBFFE8B
717:102CC0007FFFFFFFFFFFFFFFFFEFFEFFBFFFFFFFE5
718:102CD000FFFFEFFAB5FFFFFFF7F7FFFFFFFFDFFB97
719:102CE000FCFFFFFEFF7FDFBFFFCBBFF9FE7F9FE74B
720:102CF000F9FE7F97E1FE799FE7FDFE7FDFFE37FF5C
721:102D0000FBDEDEBDEFF3FEFBAFEBFEFFFFCFFFFE12
722:102D1000FFBFFF8FFFEFFBFEFFBFE7F95E7FEFFB1B
723:102D2000DAFFBFEFFBFEFFFD1FFFFFFFFFFFFFDF2F
724:102D3000FFFF7FFFFFF7FB7FFFFFFFFFFC3FFFBFB2
725:102D4000EFFBFEFFBFEF7B7FBFEFFBFEFFB5EFFBAF
726:102D5000BFFA7FFCFF3FCFF3FCFF3FCFBCFF3FEF4D
727:102D6000F3FCFE3FCFFFEEEFFBFEFFBFEFFB6AD7AA
728:102D7000B7FBF8FFB7EFBAFEFFBF7FE9FFF97E5F51
729:102D800097E5F9FE7FBFF97E5F9FE5FBFE5FB7FF2A
730:102D9000A3FFF7FDFF7FDFF7FDFF5EF77DFF77DF26
731:102DA000F7FDFF7FFFD7FFFFFFFFFFFFFDDFFB7F8B
732:102DB000FFFFEFFFFEFBFFFFBFFE8FFFDFF7FDFD15
733:102DC0007FDFF7FD3EDFF5BDFF7FDFF7FDF7FF9FFC
734:102DD000FFFFFFFFFFFFFFFFFFFDFFBEFFFFFFFF46
735:102DE000FFFFFFFD3FFFDFF7FDFF7FDFF7FDFFCFB9
736:102DF00077FCFF5FDFF7FDFFF47FFFFFFFFFFFFFC3
737:102E0000FFFFFFFFFFFFFFFFFFFDFFFFFFEEFFFFE5
738:102E1000FFFFFFFFFFFFFFFFEDFBFFFFBFFFFFFF18
739:102E2000FFFFE9FFFFFFFFFFFFFBFFFFFFD3FFFFF8
740:102E3000BF3FFBFFFFFFFBF3FFFFFFFFFFFFFFFFB6
741:102E4000FFFFFFFFFFFEFFF7FFFFFFFF17FFFFFF83
742:102E5000DFFFFDFFFFFFFFFFDFDFFFFDFFFFDFF70E
743:102E6000FF4FFFFFFFFFFFFFFFFFFFFEFFFFFFFD25
744:102E7000FFFFFFFFFEFF9FFFFFFFFFFFFFFFFFFFC3
745:102E8000FDFFFFFFFFFF7FFFFFFF7A3FFFFFFFFF19
746:102E9000FFFFFF7FFFFFFFFFFFFFFFFFFFFFFFF2CF
747:102EA0007FFFFBFEFFBFEFF8FEFFBFFBFEFF8FECD7
748:102EB000FBFEFFBFF8F7FEFFBFEFFBFEFDBFCFEC51
749:102EC000FF3FEFDBF8FFBFCFFFF9FFFFBFFFFBFFC7
750:102ED000FFFFEFFBDFFFFFFFFFFFBFFFFFFFBBFFBA
751:102EE000EFFBFEEFBFEEEBFBFEFFEFFEEEBFFEEBF8
752:102EF000FFEFFF17FF7EEBBBFEBFBEFBEF5BF7BD37
753:0A2F0000FBCFBFBFBBFB7ECCEFFF91
754:00000001FF
755
756 * Copyright (C) 1999 BayCom GmbH
757 *
758 * Redistribution and use in source and binary forms, with or without
759 * modification, are permitted provided that redistributions of source
760 * code retain the above copyright notice and this comment without
761 * modification.
diff --git a/firmware/dabusb/firmware.HEX b/firmware/dabusb/firmware.HEX
deleted file mode 100644
index 7c258df2b0a7..000000000000
--- a/firmware/dabusb/firmware.HEX
+++ /dev/null
@@ -1,649 +0,0 @@
1:02000000215786
2:0300030002016691
3:03000B0002016689
4:0300130002016681
5:03001B0002016679
6:0300230002016671
7:03002B0002016669
8:0300330002030FB6
9:03003B0002016659
10:03004300020100B7
11:03004B0002016649
12:0300530002016641
13:03005B000204BDDF
14:0300630002016730
15:03010000020C5A94
16:030104000201ED08
17:030108000202519F
18:03010C0002027C70
19:030110000202E404
20:0101140032B8
21:0101180032B4
22:03011C000205FDDC
23:03012000020000DA
24:03012400020000D6
25:0301280002043C92
26:03012C0002046A60
27:03013000020000CA
28:03013400020000C6
29:03013800020000C2
30:03013C00020000BE
31:03014000020000BA
32:03014400020000B6
33:03014800020000B2
34:03014C00020000AE
35:03015000020000AA
36:03015400020000A6
37:0A01570075817FE5826003020161FB
38:0501610012076F21648C
39:010166003266
40:0E016700C0D0C086C082C083C0E0907F97E009
41:0E0175004480F0907F69F0F0F0F0F0F0F0F0D0
42:0E018300F0F0F0F0F0F0F0F0F0F0F0F0F0F04E
43:0E019100F0F0F0F0F0F0F0F0F0F0907F97E07A
44:03019F00557FF099
45:0E01A200907F9AE030E423907F68F0F0F0F058
46:0E01B000F0F0F0F0F0F0F0F0F0F0F0F0F0F021
47:0E01BE00F0F0F0F0F0F0F0F0F0F0F0F0F0F013
48:0E01CC00E5D8C2E3F5D8D0E0D083D082D0864B
49:0301DA00D0D03250
50:0801DD0075860090FFC37C054C
51:0701E500A3E582458370F9D8
52:0101EC0022F0
53:0E01ED00C0E0C0F0C082C083C002C003C0D01A
54:0E01FB0075D000C086758600E591C2E4F591CE
55:0D020900908800E0F541907FAB7402F0900A
56:090216007FAB7402F0E5326021B7
57:04021F007A007B00E6
58:0B022300C3EA9418EB64809480501232
59:0E022E00907F69F0F0F0F0F0F0F0F00ABA0006
60:02023C00010BB4
61:02023E0080E35B
62:02024000D08666
63:0E024200D0D0D003D002D083D082D0F0D0E054
64:01025000327B
65:0E025100C0E0C0F0C082C083C0D075D000C035
66:0E025F0086758600E591C2E4F591907FAB7440
67:04026D0004F0D08643
68:0B027100D0D0D083D082D0F0D0E0329B
69:0E027C00C0E0C0F0C082C083C002C003C00456
70:0E028A00C005C006C007C000C001C0D075D0BE
71:0D02980000C086758600E591C2E4F59190E6
72:0C02A5007FAB7408F0756E00756F0212DC
73:0602B1001144757039755F
74:0602B700710C75720212C9
75:0C02BD001175907FD6E4F075D820D08633
76:0E02C900D0D0D001D000D007D006D005D00490
77:0D02D700D003D002D083D082D0F0D0E0322E
78:0E02E400C0E0C0F0C082C083C0D075D000C0A2
79:0E02F20086758600E591C2E4F591907FAB74AD
80:0403000010F0D086A3
81:0B030400D0D0D083D082D0F0D0E03207
82:0E030F00C0E0C0F0C082C083C002C003C004C2
83:0E031D00C005C006C007C000C001C0D075D02A
84:0C032B0000C086758600756E00756F02BC
85:0703370012114475704075BE
86:06033E00710C7572021241
87:0E0344001175907FD67402F0907FD67406F08B
88:0503520075D810D086F3
89:0E035700D0D0D001D000D007D006D005D00401
90:0D036500D003D002D083D082D0F0D0E0329F
91:0D037200907FA57480F0907FA6749AF01221
92:0C037F00101B907FA6E542F012101B90AE
93:0D038B007FA6E543F012101B907FA5744083
94:01039800F074
95:010399002241
96:0D039A00907FA57480F0907FA6749AF012F9
97:0C03A700101B907FA6E544F012101B9084
98:0C03B3007FA6E545F012101B907FA6E528
99:0B03BF0046F012101B907FA57440F068
100:0103CA002210
101:0A03CB0075440275450075460012E6
102:0903D500039A75420375430012FE
103:0203DE000372A8
104:0103E00022FA
105:0C03E100908800E536F09088007410252C
106:0903ED0036F01201DD75420175C4
107:0903F600431812037275440275EC
108:0903FF00450075460012039A75D1
109:08040800420375434412037224
110:0104100022C9
111:0E041100C0E0C0F0C082C083C0D075D000C073
112:0E041F0086758600E591C2E4F591907FAA747F
113:04042D0002F0D08683
114:0B043100D0D0D083D082D0F0D0E032D9
115:0E043C00C0E0C0F0C082C083C0D075D000C048
116:0E044A0086758600E591C2E4F591907FA97455
117:0704580004F0753001D086AD
118:0B045F00D0D0D083D082D0F0D0E032AB
119:0E046A00C0E0C0F0C082C083C0D075D000C01A
120:0E04780086758600E591C2E4F591907FAA7426
121:0704860004F0753101D0867E
122:0B048D00D0D0D083D082D0F0D0E0327D
123:0E049800C0E0C0F0C082C083C0D075D000C0EC
124:0C04A60086758600E591C2E5F591D086D0
125:0B04B200D0D0D083D082D0F0D0E03258
126:0E04BD00C0E0C0F0C082C083C0D075D000C0C7
127:0C04CB0086758600E591C2E7F591D086A9
128:0B04D700D0D0D083D082D0F0D0E03233
129:0C04E200907FEAE0FA8A20907F96E4F018
130:0104EE0022EB
131:0704EF00907FEAE0FA8A2188
132:0104F60022E3
133:0E04F700901713E0FA901715E0FB74802AFAB4
134:0E05050074802BFBEA0303543FFCEAC423542A
135:0E0513001FFA2CFAEB0303543FFCEBC42354F5
136:0B0521001FFB2CFB90170AE0FC60029F
137:02052C007A0053
138:07052E0090170CE0FC6002D5
139:020535007B0049
140:0B053700EA2BFCC313F53A7544028B5D
141:07054200458A4612039A7579
142:090549006E08756F001211447573
143:040552007047757108
144:080556000C757202121175858B
145:05055E003A731211A028
146:010563002275
147:0E056400907F96E0FA907F9674806502F0908A
148:0E0572007FEBE0FA907FEAE0FB907FEFE0FC89
149:0E0580003395E0FD8C057C00907FEEE0FE33AD
150:0E058E0095E0FFEC2EFCED3FFD907FE9E0FED6
151:05059C00BE0102800316
152:0305A1000205F957
153:0605A400BC0121BD001E98
154:0E05AA00EAC40354F8FCEB25E0FD2C2400FC11
155:0E05B800E43417FD907EC0E0FE8C828D83F04F
156:0205C600803182
157:0E05C800EAC40354F8FAEB25E0FB2AFA2400FB
158:0E05D600FBE43417FC907EC0E0FD8B828C832A
159:0E05E400F074012A2400FAE43417FB907EC163
160:0705F200E0FC8A828B83F01C
161:0305F90075380151
162:0105FC0022DC
163:0E05FD00C0E0C0F0C082C083C002C003C004D2
164:0E060B00C005C006C007C000C001C0D075D039
165:0D06190000C086758600E591C2E4F5919061
166:0D0626007FAA7401F0120564753700D086BC
167:0E063300D0D0D001D000D007D006D005D00422
168:0D064100D003D002D083D082D0F0D0E032C0
169:0E064E00907FEBE0FA907FEAE0FB907FEEE019
170:0E065C00FC3395E0FD907F96E0FE907F967453
171:0E066A00806506F0907F007401F0EAC403542E
172:0E067800F8FEEB25E0FB2EFE2400FBE4341719
173:0E068600FF8B828F83E0FB74012E2400FEE4C4
174:0E0694003417FF8E828F83E0FE907FE9E0FF37
175:0306A200BF810A0B
176:0A06A500907F00EBF0907F01EEF073
177:0806AF00907FE9E0FBBB821A19
178:0306B700BA010C79
179:0C06BA00907F00E4F0907F01E4F0800BE2
180:0B06C600907F00E4F0907F0174B5F01D
181:0806D100907FE9E0FBBB831BF5
182:0306D900BA010D56
183:0D06DC00907F007401F0907F01E4F0800B2E
184:0B06E900907F00E4F0907F017412F09D
185:0806F400907FE9E0FBBB841CD0
186:0306FC00BA010D33
187:0D06FF00907F007401F0907F01E4F0800C0A
188:0C070C00907F007480F0907F017401F079
189:05071800907FB5ECF03C
190:01071D0022B9
191:0C071E0075360D908800741DF0756B801E
192:0A072A00756C3C1210E2756B8075CF
193:090734006C0F1210E2756B807568
194:09073D006C061210E2756B807568
195:070746006C011210E27A00C1
196:03074D00BAFF00F0
197:02075000500A4D
198:0A075200C0021201DDD0020A80F19E
199:0A075C00756B80756C3C1210E2759D
200:080766006B80756C0F1210E2AC
201:01076E002268
202:0E076F00907FA1E4F0907FAF7401F0907F9234
203:0E077D007402F0758E3175892175880075C87B
204:0E078B0000758D4075984075C04075870075EB
205:0907990020007521007522007595
206:0507A200230075470073
207:0707A700C3E5479420501147
208:0D07AE00E5472400F582E43417F583E4F0FC
209:0407BB00054780E886
210:0907BF00E4F540F53FE4F53CF5DA
211:0707C8003BE4F53EF53D7531
212:0B07CF003200753700753900907F93F1
213:0E07DA00743CF0907F9C74FFF0907F967480CA
214:0E07E800F0907F947470F0907F9D748FF0906D
215:0E07F6007F97E4F0907F9574C2F0907F987426
216:0E08040028F0907F9E7428F0907FF0E4F09032
217:0E0812007FF1E4F0907FF2E4F0907FF3E4F0E9
218:0E082000907FF4E4F0907FF5E4F0907FF6E432
219:0E082E00F0907FF7E4F0907FF8E4F0907FF90F
220:0E083C007438F0907FFA74A0F0907FFB74A0E7
221:0E084A00F0907FFC74A0F0907FFD74A0F09001
222:0E0858007FFE74A0F0907FFF74A0F0907FE010
223:0E0866007403F0907FE17401F0907FDD7480E8
224:0B087400F012124312071E7A007B00F6
225:09087F00C3EA941EEB940050172B
226:0C088800908800E0F54790880BE0F547F1
227:09089400907F68F00ABA00010B24
228:02089D0080E0F9
229:0C089F001203E1907FD6E4F07A007B00A9
230:0D08AB008A048B05C3EA94E0EB942E501AEA
231:0E08B800C002C003C004C0051201DDD005D08F
232:0A08C60004D003D0020ABA00010BAF
233:0208D00080D9CD
234:0D08D200907FD67402F0907FD67406F090EF
235:0E08DF007FDE7405F0907FDF7405F0907FAC33
236:0E08ED00E4F0907FAD7405F075A88075F810EA
237:0D08FB00907FAE740BF0907FE27488F09057
238:0C0908007FAB7408F075E81175320175C2
239:0C0914003100753000C004C0051204F76B
240:0A092000D005D004753400753501D0
241:0D092A00907FAE7403F08C02BA00028003CF
242:03093700020A3F72
243:0C093A00853334907F9D748FF0907F9780
244:0E0946007408F0907F9D7488F0907F9AE0FA1C
245:0C09540074055AF533907F9D748FF0906D
246:0D0960007F977402F0907F9D7482F0E53364
247:0D096D0025E0FA907F9AE05405FB4AF5332F
248:02097A00600C0F
249:0C097C00907F96E0FA907F9674804AF01D
250:0B098800756E00756F00C004C0051202
251:0E0993001144D005D004901713E0FA74802AA6
252:0609A100FAE533B404295D
253:0309A700BAA000F3
254:0209AA005024D7
255:0D09AC00901713E004FB0B901713EBF09075
256:0E09B9001713E0FB901715F0C002C004C00534
257:0909C7001204F7D005D004D0029F
258:0509D000E533B402262E
259:0609D500C374049A5020D7
260:0D09DB00901713E0FA1A1A901713EAF09023
261:0D09E8001713E0FA901715F0C004C00512B7
262:0609F50004F7D005D00458
263:0509FB00E533B4081D06
264:040A0000E534701950
265:0A0A040074012535540FF5358535D2
266:0C0A0E0075757600C004C0051213FED000
267:030A1A0005D00400
268:050A1D00E533B4011DEA
269:040A2200E53470192E
270:0A0A2600E53524FF540FF535853542
271:0C0A300075757600C004C0051213FED0DE
272:030A3C0005D004DE
273:0E0A3F00C004C0051201DDD005D004907F96E2
274:0E0A4D00E0FA907F96747F5AF0907F977408BD
275:0A0A5B00F0C3EC9400ED9402400893
276:080A6500907F96E0FA20E608FC
277:080A6D00C3E49C74089D5013C2
278:0E0A7500907F96E0FA907F9674406502F07CC8
279:050A8300007D0080056C
280:050A88000CBC00010D93
281:050A8D00E538B4010E84
282:0D0A9200C004C0051204F7D005D00475386B
283:010A9F000056
284:070AA000E531700302092A91
285:0A0AA700907FC9E0FA7003020C2DE5
286:0E0AB100907F96E0FA907F9674806502F09038
287:090ABF007DC0E0FABA2C028003AC
288:030AC800020B36E8
289:050ACB007532007B0004
290:030AD000BB640004
291:020AD300501CB5
292:0E0AD500C002C003C004C0051201DDD005D070
293:0D0AE30004D003D00290880FE0F5470B808F
294:010AF000DF26
295:0D0AF100C002C004C00512071E1203E1126E
296:0C0AFE0004F7D005D004D002756E00751E
297:0D0B0A006F01C002C004C005121144D005E7
298:090B1700D004D00275704D757117
299:0B0B20000C757202C002C004C0051278
300:0B0B2B001175D005D004D002020C2D83
301:030B3600BA2A3B9D
302:0D0B3900907F987420F0C002C004C0051227
303:0E0B460001DDD005D004D002907F987428F015
304:020B54007B0024
305:030B5600BB0A00D7
306:050B59004003020C2D19
307:0E0B5E00C002C003C004C0051201DDD005D0E6
308:080B6C0004D003D0020B80E26B
309:030B7400BA2B1A7F
310:080B7700907FC9E0FBBB4012B6
311:0E0B7F00C002C004C005121205D005D004D07B
312:040B8D0002020C2D27
313:030B9100BA101F78
314:0E0B9400907F96E0FB907F9674806503F0C022
315:0E0BA20002C004C00512103DD005D004D002E0
316:030BB000020C2D07
317:030BB300BA111262
318:0E0BB600C002C004C00512106AD005D004D0E1
319:040BC40002020C2DF0
320:030BC800BA12124C
321:0E0BCB00C002C004C00512108FD005D004D0A7
322:040BD90002020C2DDB
323:030BDD00BA130B3D
324:0B0BE000907DC1E0FB908800F0804297
325:030BEB00BA141128
326:0E0BEE00C002C004C0051211DDD005D004D035
327:030BFC0002802E46
328:030BFF00BA151D07
329:0C0C0200907DC1E0F575907DC2E0F576B4
330:0E0C0E00C002C004C0051213FED005D004D0F1
331:030C1C0002800E45
332:030C1F00BA160BF7
333:0B0C2200C004C0051213A3D005D004CD
334:0B0C2D00907FC9E4F075310002092A35
335:010C38002299
336:070C3900535550454E4400E5
337:070C4000524553554D4500DC
338:060C470020566F6C200036
339:0D0C4D004441425553422076312E30300094
340:0E0C5A00C0E0C0F0C082C083C002C003C0046E
341:0E0C6800C005C006C007C000C001C0D075D0D6
342:0D0C760000C086758600E591C2E4F59190FE
343:0E0C83007FAB7401F0907FE8E0FA907FE9E02B
344:060C9100FBBB0002800322
345:030C9700020D3813
346:030C9A00BA801409
347:0E0C9D00907F007401F0907F01E4F0907FB52D
348:060CAB007402F0020ECD00
349:050CB100BA820280037D
350:030CB600020D1D0F
351:080CB900907FECE0FCBC01009F
352:020CC1004021D0
353:060CC300C374079C401BF6
354:0E0CC900EC24FF25E0FD24C6F582E4347FF51F
355:0D0CD70083E0FD530501907F00EDF0802BC0
356:030CE400BC8100D0
357:020CE7004021AA
358:060CE900C374879C401B50
359:0E0CEF00EC247F25E0FC24B6F582E4347FF58A
360:0D0CFD0083E0FC530401907F00ECF08005C3
361:050D0A00907F00E4F001
362:0E0D0F00907F01E4F0907FB57402F0020ECDEB
363:050D1D00BA8102800311
364:030D2200020EC5F9
365:0E0D2500907F00E4F0907F01E4F0907FB574C1
366:050D330002F0020ECDEC
367:030D3800BB012DCF
368:060D3B00BA0003020ECD18
369:030D4100BA0211E2
370:0D0D4400755900C002C003120EF0D003D09C
371:040D510002020ECDBF
372:050D5500BA2102800339
373:030D5A00020ECDB9
374:0B0D5D00753701907FC5E4F0020ECD59
375:030D6800BB031FAB
376:060D6B00BA0003020ECDE8
377:050D7100BA020280033C
378:030D7600020ECD9D
379:0D0D7900755901C002C003120EF0D003D066
380:040D860002020ECD8A
381:030D8A00BB065451
382:050D8D00BA80028003A2
383:030D9200020EC589
384:080D9500907FEBE0FCBC0115AE
385:0C0D9D007CFB7D0F8D067F00907FD4EE64
386:090DA900F0907FD5ECF0020ECDB4
387:0A0DB200907FEBE0FCBC020280031E
388:030DBC00020EC55F
389:0A0DBF00907FEAE0FCBC0002800314
390:030DC900020EC552
391:0C0DCC007C3B7D0F8D067F00907FD4EEF5
392:090DD800F0907FD5ECF0020ECD85
393:060DE100BB0703020EC572
394:030DE700BB081036
395:0D0DEA00AC48907F00ECF0907FB57401F0F4
396:030DF700020ECD1C
397:030DFA00BB093101
398:050DFD00BA00028003B2
399:030E0200020EC518
400:0E0E0500907FEAE0FCC374019C5003020EC50E
401:080E1300907FEAE0FCBC000A3C
402:0A0E1B00901721E4F0901722E4F094
403:090E2500907FEAE0F548020ECDD1
404:030E2E00BB0A27D5
405:050E3100BA81028003FC
406:030E3600020EC5E4
407:0E0E3900907FECE0FA2420FAE43417FC8A8261
408:0E0E47008C83E0FA907F00F0907FB57401F08C
409:030E5500020ECDBD
410:050E5800BB0B0280034A
411:030E5D00020EA9D9
412:0D0E6000901720E4F0907FECE0FABA011A40
413:080E6D00907FEDE0FABA0012DB
414:0E0E7500907FEAE0FA901721F0C0031204E229
415:040E8300D0038046D2
416:080E8700907FECE0FABA023E94
417:080E8F00907FEDE0FABA003695
418:0D0E9700C0031204EFD003907FEAE0FA9050
419:050EA4001722F080247C
420:050EA900BB12028017DE
421:050EAE00BB8102800D74
422:050EB300BB8302800872
423:050EB800BB8202800373
424:030EBD00BB8405EE
425:050EC00012064E80083F
426:080EC500907FB47403F0800675
427:060ECD00907FB47402F0F6
428:020ED300D086C7
429:0E0ED500D0D0D001D000D007D006D005D00478
430:0D0EE300D003D002D083D082D0F0D0E03216
431:0B0EF000907FECE0F55AC39401401D18
432:070EFB00C37407955A40166D
433:0D0F0200E55A24FF25E0FA24C6F582E43408
434:090F0F007FF583AA59EAF0802263
435:070F1800C3E55A9481401B60
436:070F1F00C37487955A4014CA
437:0D0F2600E55A24FF25E0FA24B6F582E434F4
438:070F33007FF583AA59EAF0E3
439:010F3A002294
440:0E0F3B000902BA000301004000090400000092
441:0E0F49000101000009240100013D0001010C1E
442:0E0F570024020110070002030000000D240612
443:0E0F650003010215000300030000092403022B
444:0E0F7300010100010009240304020300030031
445:0E0F8100092403050306000100090401000015
446:0E0F8F00010200000904010101010200000737
447:0E0F9D002401020101000B24020102021001D6
448:0E0FAB0080BB00090588050001010000072534
449:0E0FB900010000000009040200020000000018
450:0E0FC7000705820240000007050202400000FC
451:0E0FD50009040201030000000007058202402B
452:0E0FE30000000705020240000009058905A074
453:0A0FF1000101000000FFFFFFFF00F8
454:0E0FFB00120100010000004047059999000115
455:0E10090000000001000000000000000902BA13
456:0410170000030100D1
457:02101B007A0059
458:03101D00BA050011
459:02102000501767
460:08102200907FA5E0FB30E00522
461:05102A00900001800DA3
462:0A102F00C0021201DDD0020A80E4C5
463:0310390090000123
464:01103C002291
465:0E103D00907DC1E0F9A3E0FAA3E0FB7C007D0A
466:04104B007EEB6012C6
467:0E104F0089828A83E0A3A982AA838C828D8382
468:04105D00F00CDBEECA
469:08106100907DC3E0907FB9F01F
470:011069002264
471:0E106A00907DC1E0F9A3E0FAA3E0FB7CC47D19
472:041078007DEB60E5C7
473:0E107C008C828D83E00C89828A83F0A3A98286
474:04108A00AA83DBEE6C
475:01108E00223F
476:0E108F00907FA57480F00586907DC1E00586F7
477:0E109D00A3F012101B907FA60586A3A3E0F916
478:0510AB006016A305869C
479:0D10B000907FA60586E0A30586F0C0011222
480:0610BD00101BD001D9ED6B
481:0610C300907FA57440F0CF
482:0110C9002204
483:0810CA009088027401F07A0025
484:0310D200BAFF0062
485:0210D500500ABF
486:0A10D700C0021201DDD0020A80F110
487:0110E10022EC
488:0510E200E56BB4C0083D
489:0810E700908803E56CF080061F
490:0610EF00908802E56CF0A0
491:0410F5007A007B0002
492:0B10F900C3EA9432EB6480948050073F
493:051104000ABA00010B16
494:0211090080EE76
495:01110B0022C1
496:0A110C00908803E56DF005397A00C4
497:03111600BA2800F4
498:02111900500381
499:03111B000A80F84F
500:05111E00E539B41008E2
501:0811230090880274C0F0800EF8
502:05112B00E539B42009C4
503:091130009088027480F07539000A
504:021139007A003A
505:03113B00BA2800CF
506:02113E0050035C
507:031140000A80F82A
508:011143002289
509:04114400E56F6002F1
510:0211480080071E
511:07114A007A007539008005F1
512:051151007A4075391021
513:09115600E56E2AFAE56E2539F573
514:0A115F003990880274802AF07A00AB
515:08116900C3EA648094A850035E
516:031171000A80F5FC
517:011174002258
518:06117500AA70AB71AC7220
519:0C117B008A828B838CF01214EEFD601849
520:0D1187008D6DC002C003C00412110CD00415
521:09119400D003D0020ABA00010BDD
522:02119D0080DCF4
523:01119F00222D
524:0D11A000E573C4540FFA53020FC374099A8B
525:0211AD005006EA
526:0611AF0074372AFB8004E6
527:0411B50074302AFB6D
528:0C11B9008B6DC00312110CD003AA7353FD
529:0811C500020FC374099A5006E1
530:0611CD0074372AFB8004C8
531:0411D30074302AFB4F
532:0511D7008B6D12110CEC
533:0111DC0022F0
534:0711DD00907DC3E0FA600FF2
535:0C11E400907DC1E0F56E907DC2E0F56FDB
536:0311F00012114495
537:0C11F300907DFFE4F07570C475717D758F
538:0511FF007201121175E0
539:0112040022C7
540:021205007A0469
541:03120700BA4000EA
542:02120A0050365C
543:0E120C00EA24C0F582E4347DF583E0FB7C002B
544:03121A00BC08000D
545:02121D0050205F
546:06121F008B05ED30E70B2A
547:0B122500907F967442F074C3F08008C4
548:08123000907F96E4F07481F058
549:07123800EB25E0FB0C80DB5D
550:03123F000A80C55D
551:011242002289
552:041243007A007BEFC3
553:03124700BA1000DA
554:02124A00502032
555:0E124C0074112BFB2400FCE43418FD8C828D01
556:0E125A0083E4F0EA2400F582E43419F583E41D
557:04126800F00A80DB2D
558:01126C00225F
559:0E126D0074F82400F58274033484F583E4F0F1
560:0E127B0074F92400F58274033484F583E4F0E2
561:0E12890074FA2400F58274033484F583E4F0D3
562:0E12970074FB2400F58274033484F583E4F0C4
563:0E12A50074FF2400F58274033484F583E4F0B2
564:0112B3002218
565:0E12B4001203CB12126D7AC07B877C0174018D
566:0E12C2002AFDE43BFE8C078A828B838CF0743D
567:0E12D000011214BF2DFAE43EFB8F048D828EB6
568:0E12DE00838FF074061214BF74012AFDE43BE6
569:0E12EC00FE8C078A828B838CF0E41214BF7490
570:0E12FA00012DFAE43EFB8F048D828E838FF06F
571:0E130800740B1214BF74012AFDE43BFE8C0727
572:0E1316008A828B838CF074081214BF74012D30
573:0E132400FAE43EFB8F048D828E838FF07401FD
574:0E1332001214BF2AFDE43BFE8C078A828B83D7
575:0E1340008CF0E41214BF74012DFAE43EFB8F12
576:0E134E00048D828E838FF074031214BF7D0015
577:03135C00BD0600CB
578:02135F0050122A
579:0B1361008A828B838CF00ABA00010B1B
580:07136C00E41214BF0D80E93B
581:0D1373008A828B838CF0E5741214BF74F92C
582:0E1380002400F58274033484F583740FF07436
583:0E138E00FE2400F58274033484F5837401F0AC
584:06139C001203E11204F748
585:0113A2002228
586:0D13A300907DC1E0FA2400FBE43419FC90B9
587:0E13B0007DC2E0FD8B828C83F075F011EAA403
588:0313BE00FA7B00B7
589:0313C100BB10005E
590:0213C4005024B3
591:0E13C600EA2400FCE43418FDEB2CFCE43DFDB1
592:0E13D40074042B24C0F582E4347DF583E0FE22
593:0813E2008C828D83F00B80D793
594:0E13EA00EA2400FAE43418FB74102AF582E4B9
595:0513F8003BF583E4F069
596:0113FD0022CD
597:0413FE00E57660022E
598:02140200801652
599:0C140400740F5575FA8A752400F582E417
600:0A1410003419F583E0F5741212B4EC
601:0A141A001210CA756E00756F001203
602:0614240011447570B9755A
603:06142A007114757202123C
604:0B1430001175E576B402047401800120
605:01143B00E4CC
606:03143C00FA700F34
607:0C143F0074012575F573C0021211A0D0D5
608:03144B0002800A12
609:0A144E00857573C0021211A0D002D0
610:0C145800756E00756F01C002121144D0C7
611:0414640002EA701A0E
612:0D14680075F011E575A4FA2400FAE43418BB
613:09147500FB8A708B717572011283
614:04147E00117580362E
615:021482007A00EE
616:03148400BA10009B
617:02148700502FE4
618:0D148900EA2400F582E43419F583E0FBE568
619:0414960075B5031B0A
620:0E149A0075F011EAA4FB2400FBE43418FC8B6F
621:0914A800708C71757201C0021212
622:0414B1001175D002DF
623:0314B5000A80CCDE
624:0114B8002211
625:0614B90050726F67200075
626:0E14BF00C8C0E0C8C0E0E5F0600B14600F1478
627:0714CD00601114601280158C
628:0714D400D0E0A882F6800EB3
629:0514DB00D0E0F08009E3
630:0414E000D0E08005D3
631:0514E400D0E0A882F237
632:0414E900C8D0E0C8BF
633:0114ED0022DC
634:0E14EE00C8C0E0E5F0600D14600F14600F142C
635:0614FC00601074FF800F78
636:05150200A882E6800A4A
637:03150700E080077A
638:04150A00E4938003E3
639:03150E00A882E2CE
640:04151100F8D0E0C866
641:0115150022B3
642:00000001FF
643
644 * Copyright (C) 1999 BayCom GmbH
645 *
646 * Redistribution and use in source and binary forms, with or without
647 * modification, are permitted provided that redistributions of source
648 * code retain the above copyright notice and this comment without
649 * modification.
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 10278d18709c..689b14b26c8d 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -482,6 +482,7 @@ struct usb3_lpm_parameters {
482 * @connect_time: time device was first connected 482 * @connect_time: time device was first connected
483 * @do_remote_wakeup: remote wakeup should be enabled 483 * @do_remote_wakeup: remote wakeup should be enabled
484 * @reset_resume: needs reset instead of resume 484 * @reset_resume: needs reset instead of resume
485 * @port_is_suspended: the upstream port is suspended (L2 or U3)
485 * @wusb_dev: if this is a Wireless USB device, link to the WUSB 486 * @wusb_dev: if this is a Wireless USB device, link to the WUSB
486 * specific data for the device. 487 * specific data for the device.
487 * @slot_id: Slot ID assigned by xHCI 488 * @slot_id: Slot ID assigned by xHCI
@@ -560,6 +561,7 @@ struct usb_device {
560 561
561 unsigned do_remote_wakeup:1; 562 unsigned do_remote_wakeup:1;
562 unsigned reset_resume:1; 563 unsigned reset_resume:1;
564 unsigned port_is_suspended:1;
563#endif 565#endif
564 struct wusb_dev *wusb_dev; 566 struct wusb_dev *wusb_dev;
565 int slot_id; 567 int slot_id;
@@ -588,8 +590,9 @@ extern struct usb_device *usb_hub_find_child(struct usb_device *hdev,
588 */ 590 */
589#define usb_hub_for_each_child(hdev, port1, child) \ 591#define usb_hub_for_each_child(hdev, port1, child) \
590 for (port1 = 1, child = usb_hub_find_child(hdev, port1); \ 592 for (port1 = 1, child = usb_hub_find_child(hdev, port1); \
591 port1 <= hdev->maxchild; \ 593 port1 <= hdev->maxchild; \
592 child = usb_hub_find_child(hdev, ++port1)) 594 child = usb_hub_find_child(hdev, ++port1)) \
595 if (!child) continue; else
593 596
594/* USB device locking */ 597/* USB device locking */
595#define usb_lock_device(udev) device_lock(&(udev)->dev) 598#define usb_lock_device(udev) device_lock(&(udev)->dev)
@@ -805,6 +808,22 @@ static inline int usb_make_path(struct usb_device *dev, char *buf, size_t size)
805 .bcdDevice_hi = (hi) 808 .bcdDevice_hi = (hi)
806 809
807/** 810/**
811 * USB_DEVICE_INTERFACE_CLASS - describe a usb device with a specific interface class
812 * @vend: the 16 bit USB Vendor ID
813 * @prod: the 16 bit USB Product ID
814 * @cl: bInterfaceClass value
815 *
816 * This macro is used to create a struct usb_device_id that matches a
817 * specific interface class of devices.
818 */
819#define USB_DEVICE_INTERFACE_CLASS(vend, prod, cl) \
820 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
821 USB_DEVICE_ID_MATCH_INT_CLASS, \
822 .idVendor = (vend), \
823 .idProduct = (prod), \
824 .bInterfaceClass = (cl)
825
826/**
808 * USB_DEVICE_INTERFACE_PROTOCOL - describe a usb device with a specific interface protocol 827 * USB_DEVICE_INTERFACE_PROTOCOL - describe a usb device with a specific interface protocol
809 * @vend: the 16 bit USB Vendor ID 828 * @vend: the 16 bit USB Vendor ID
810 * @prod: the 16 bit USB Product ID 829 * @prod: the 16 bit USB Product ID
@@ -1129,8 +1148,8 @@ extern int usb_disabled(void);
1129 * Note: URB_DIR_IN/OUT is automatically set in usb_submit_urb(). 1148 * Note: URB_DIR_IN/OUT is automatically set in usb_submit_urb().
1130 */ 1149 */
1131#define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */ 1150#define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */
1132#define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame 1151#define URB_ISO_ASAP 0x0002 /* iso-only; use the first unexpired
1133 * ignored */ 1152 * slot in the schedule */
1134#define URB_NO_TRANSFER_DMA_MAP 0x0004 /* urb->transfer_dma valid on submit */ 1153#define URB_NO_TRANSFER_DMA_MAP 0x0004 /* urb->transfer_dma valid on submit */
1135#define URB_NO_FSBR 0x0020 /* UHCI-specific */ 1154#define URB_NO_FSBR 0x0020 /* UHCI-specific */
1136#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */ 1155#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */
@@ -1309,15 +1328,20 @@ typedef void (*usb_complete_t)(struct urb *);
1309 * the transfer interval in the endpoint descriptor is logarithmic. 1328 * the transfer interval in the endpoint descriptor is logarithmic.
1310 * Device drivers must convert that value to linear units themselves.) 1329 * Device drivers must convert that value to linear units themselves.)
1311 * 1330 *
1312 * Isochronous URBs normally use the URB_ISO_ASAP transfer flag, telling 1331 * If an isochronous endpoint queue isn't already running, the host
1313 * the host controller to schedule the transfer as soon as bandwidth 1332 * controller will schedule a new URB to start as soon as bandwidth
1314 * utilization allows, and then set start_frame to reflect the actual frame 1333 * utilization allows. If the queue is running then a new URB will be
1315 * selected during submission. Otherwise drivers must specify the start_frame 1334 * scheduled to start in the first transfer slot following the end of the
1316 * and handle the case where the transfer can't begin then. However, drivers 1335 * preceding URB, if that slot has not already expired. If the slot has
1317 * won't know how bandwidth is currently allocated, and while they can 1336 * expired (which can happen when IRQ delivery is delayed for a long time),
1318 * find the current frame using usb_get_current_frame_number () they can't 1337 * the scheduling behavior depends on the URB_ISO_ASAP flag. If the flag
1319 * know the range for that frame number. (Ranges for frame counter values 1338 * is clear then the URB will be scheduled to start in the expired slot,
1320 * are HC-specific, and can go from 256 to 65536 frames from "now".) 1339 * implying that some of its packets will not be transferred; if the flag
1340 * is set then the URB will be scheduled in the first unexpired slot,
1341 * breaking the queue's synchronization. Upon URB completion, the
1342 * start_frame field will be set to the (micro)frame number in which the
1343 * transfer was scheduled. Ranges for frame counter values are HC-specific
1344 * and can go from as low as 256 to as high as 65536 frames.
1321 * 1345 *
1322 * Isochronous URBs have a different data transfer model, in part because 1346 * Isochronous URBs have a different data transfer model, in part because
1323 * the quality of service is only "best effort". Callers provide specially 1347 * the quality of service is only "best effort". Callers provide specially
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index f8dda0621800..b09c37e04a91 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -38,6 +38,7 @@
38#include <linux/version.h> 38#include <linux/version.h>
39#include <linux/usb/ch9.h> 39#include <linux/usb/ch9.h>
40#include <linux/usb/gadget.h> 40#include <linux/usb/gadget.h>
41#include <linux/log2.h>
41 42
42/* 43/*
43 * USB function drivers should return USB_GADGET_DELAYED_STATUS if they 44 * USB function drivers should return USB_GADGET_DELAYED_STATUS if they
@@ -51,6 +52,7 @@
51/* big enough to hold our biggest descriptor */ 52/* big enough to hold our biggest descriptor */
52#define USB_COMP_EP0_BUFSIZ 1024 53#define USB_COMP_EP0_BUFSIZ 1024
53 54
55#define USB_MS_TO_HS_INTERVAL(x) (ilog2((x * 1000 / 125)) + 1)
54struct usb_configuration; 56struct usb_configuration;
55 57
56/** 58/**
@@ -117,7 +119,7 @@ struct usb_configuration;
117struct usb_function { 119struct usb_function {
118 const char *name; 120 const char *name;
119 struct usb_gadget_strings **strings; 121 struct usb_gadget_strings **strings;
120 struct usb_descriptor_header **descriptors; 122 struct usb_descriptor_header **fs_descriptors;
121 struct usb_descriptor_header **hs_descriptors; 123 struct usb_descriptor_header **hs_descriptors;
122 struct usb_descriptor_header **ss_descriptors; 124 struct usb_descriptor_header **ss_descriptors;
123 125
diff --git a/include/linux/usb/ehci_pdriver.h b/include/linux/usb/ehci_pdriver.h
index c9d09f8b7ff2..99238b096f7e 100644
--- a/include/linux/usb/ehci_pdriver.h
+++ b/include/linux/usb/ehci_pdriver.h
@@ -29,6 +29,8 @@
29 * initialization. 29 * initialization.
30 * @port_power_off: set to 1 if the controller needs to be powered down 30 * @port_power_off: set to 1 if the controller needs to be powered down
31 * after initialization. 31 * after initialization.
32 * @no_io_watchdog: set to 1 if the controller does not need the I/O
33 * watchdog to run.
32 * 34 *
33 * These are general configuration options for the EHCI controller. All of 35 * These are general configuration options for the EHCI controller. All of
34 * these options are activating more or less workarounds for some hardware. 36 * these options are activating more or less workarounds for some hardware.
@@ -39,8 +41,7 @@ struct usb_ehci_pdata {
39 unsigned has_synopsys_hc_bug:1; 41 unsigned has_synopsys_hc_bug:1;
40 unsigned big_endian_desc:1; 42 unsigned big_endian_desc:1;
41 unsigned big_endian_mmio:1; 43 unsigned big_endian_mmio:1;
42 unsigned port_power_on:1; 44 unsigned no_io_watchdog:1;
43 unsigned port_power_off:1;
44 45
45 /* Turn on all power and clocks */ 46 /* Turn on all power and clocks */
46 int (*power_on)(struct platform_device *pdev); 47 int (*power_on)(struct platform_device *pdev);
diff --git a/include/linux/usb/ezusb.h b/include/linux/usb/ezusb.h
index fc618d8d1e92..639ee45779fb 100644
--- a/include/linux/usb/ezusb.h
+++ b/include/linux/usb/ezusb.h
@@ -1,16 +1,8 @@
1#ifndef __EZUSB_H 1#ifndef __EZUSB_H
2#define __EZUSB_H 2#define __EZUSB_H
3 3
4
5extern int ezusb_writememory(struct usb_device *dev, int address,
6 unsigned char *data, int length, __u8 bRequest);
7
8extern int ezusb_fx1_set_reset(struct usb_device *dev, unsigned char reset_bit); 4extern int ezusb_fx1_set_reset(struct usb_device *dev, unsigned char reset_bit);
9extern int ezusb_fx2_set_reset(struct usb_device *dev, unsigned char reset_bit);
10
11extern int ezusb_fx1_ihex_firmware_download(struct usb_device *dev, 5extern int ezusb_fx1_ihex_firmware_download(struct usb_device *dev,
12 const char *firmware_path); 6 const char *firmware_path);
13extern int ezusb_fx2_ihex_firmware_download(struct usb_device *dev,
14 const char *firmware_path);
15 7
16#endif /* __EZUSB_H */ 8#endif /* __EZUSB_H */
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 5b6e50888248..0af6569b8cc6 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -939,6 +939,13 @@ static inline void usb_free_descriptors(struct usb_descriptor_header **v)
939 kfree(v); 939 kfree(v);
940} 940}
941 941
942struct usb_function;
943int usb_assign_descriptors(struct usb_function *f,
944 struct usb_descriptor_header **fs,
945 struct usb_descriptor_header **hs,
946 struct usb_descriptor_header **ss);
947void usb_free_all_descriptors(struct usb_function *f);
948
942/*-------------------------------------------------------------------------*/ 949/*-------------------------------------------------------------------------*/
943 950
944/* utility to simplify map/unmap of usb_requests to/from DMA */ 951/* utility to simplify map/unmap of usb_requests to/from DMA */
diff --git a/include/linux/usb/ohci_pdriver.h b/include/linux/usb/ohci_pdriver.h
index 74e7755168b7..012f2b7eb2b6 100644
--- a/include/linux/usb/ohci_pdriver.h
+++ b/include/linux/usb/ohci_pdriver.h
@@ -25,6 +25,7 @@
25 * @big_endian_desc: BE descriptors 25 * @big_endian_desc: BE descriptors
26 * @big_endian_mmio: BE registers 26 * @big_endian_mmio: BE registers
27 * @no_big_frame_no: no big endian frame_no shift 27 * @no_big_frame_no: no big endian frame_no shift
28 * @num_ports: number of ports
28 * 29 *
29 * These are general configuration options for the OHCI controller. All of 30 * These are general configuration options for the OHCI controller. All of
30 * these options are activating more or less workarounds for some hardware. 31 * these options are activating more or less workarounds for some hardware.
@@ -33,6 +34,7 @@ struct usb_ohci_pdata {
33 unsigned big_endian_desc:1; 34 unsigned big_endian_desc:1;
34 unsigned big_endian_mmio:1; 35 unsigned big_endian_mmio:1;
35 unsigned no_big_frame_no:1; 36 unsigned no_big_frame_no:1;
37 unsigned int num_ports;
36 38
37 /* Turn on all power and clocks */ 39 /* Turn on all power and clocks */
38 int (*power_on)(struct platform_device *pdev); 40 int (*power_on)(struct platform_device *pdev);
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index 06b5bae35b29..a29ae1eb9346 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -10,6 +10,7 @@
10#define __LINUX_USB_PHY_H 10#define __LINUX_USB_PHY_H
11 11
12#include <linux/notifier.h> 12#include <linux/notifier.h>
13#include <linux/usb.h>
13 14
14enum usb_phy_events { 15enum usb_phy_events {
15 USB_EVENT_NONE, /* no events or cable disconnected */ 16 USB_EVENT_NONE, /* no events or cable disconnected */
@@ -99,8 +100,10 @@ struct usb_phy {
99 int suspend); 100 int suspend);
100 101
101 /* notify phy connect status change */ 102 /* notify phy connect status change */
102 int (*notify_connect)(struct usb_phy *x, int port); 103 int (*notify_connect)(struct usb_phy *x,
103 int (*notify_disconnect)(struct usb_phy *x, int port); 104 enum usb_device_speed speed);
105 int (*notify_disconnect)(struct usb_phy *x,
106 enum usb_device_speed speed);
104}; 107};
105 108
106 109
@@ -189,19 +192,19 @@ usb_phy_set_suspend(struct usb_phy *x, int suspend)
189} 192}
190 193
191static inline int 194static inline int
192usb_phy_notify_connect(struct usb_phy *x, int port) 195usb_phy_notify_connect(struct usb_phy *x, enum usb_device_speed speed)
193{ 196{
194 if (x->notify_connect) 197 if (x->notify_connect)
195 return x->notify_connect(x, port); 198 return x->notify_connect(x, speed);
196 else 199 else
197 return 0; 200 return 0;
198} 201}
199 202
200static inline int 203static inline int
201usb_phy_notify_disconnect(struct usb_phy *x, int port) 204usb_phy_notify_disconnect(struct usb_phy *x, enum usb_device_speed speed)
202{ 205{
203 if (x->notify_disconnect) 206 if (x->notify_disconnect)
204 return x->notify_disconnect(x, port); 207 return x->notify_disconnect(x, speed);
205 else 208 else
206 return 0; 209 return 0;
207} 210}