From 871480933a1c28f8a9fed4c4d34d06c439a7a422 Mon Sep 17 00:00:00 2001
From: Srikant Patnaik
Date: Sun, 11 Jan 2015 12:28:04 +0530
Subject: Moved, renamed, and deleted files
The original directory structure was scattered and unorganized.
Changes are basically to make it look like kernel structure.
---
ANDROID_3.4.5/drivers/usb/Kconfig | 186 -
ANDROID_3.4.5/drivers/usb/Makefile | 58 -
ANDROID_3.4.5/drivers/usb/README | 54 -
ANDROID_3.4.5/drivers/usb/atm/Kconfig | 68 -
ANDROID_3.4.5/drivers/usb/atm/Makefile | 11 -
ANDROID_3.4.5/drivers/usb/atm/cxacru.c | 1380 ------
ANDROID_3.4.5/drivers/usb/atm/speedtch.c | 961 ----
ANDROID_3.4.5/drivers/usb/atm/ueagle-atm.c | 2760 ------------
ANDROID_3.4.5/drivers/usb/atm/usbatm.c | 1388 ------
ANDROID_3.4.5/drivers/usb/atm/usbatm.h | 222 -
ANDROID_3.4.5/drivers/usb/atm/xusbatm.c | 233 -
ANDROID_3.4.5/drivers/usb/c67x00/Makefile | 9 -
ANDROID_3.4.5/drivers/usb/c67x00/c67x00-drv.c | 234 -
ANDROID_3.4.5/drivers/usb/c67x00/c67x00-hcd.c | 411 --
ANDROID_3.4.5/drivers/usb/c67x00/c67x00-hcd.h | 133 -
ANDROID_3.4.5/drivers/usb/c67x00/c67x00-ll-hpi.c | 481 --
ANDROID_3.4.5/drivers/usb/c67x00/c67x00-sched.c | 1171 -----
ANDROID_3.4.5/drivers/usb/c67x00/c67x00.h | 294 --
ANDROID_3.4.5/drivers/usb/class/Kconfig | 52 -
ANDROID_3.4.5/drivers/usb/class/Makefile | 9 -
ANDROID_3.4.5/drivers/usb/class/cdc-acm.c | 1752 --------
ANDROID_3.4.5/drivers/usb/class/cdc-acm.h | 130 -
ANDROID_3.4.5/drivers/usb/class/cdc-wdm.c | 1048 -----
ANDROID_3.4.5/drivers/usb/class/usblp.c | 1421 ------
ANDROID_3.4.5/drivers/usb/class/usbtmc.c | 1121 -----
ANDROID_3.4.5/drivers/usb/core/Kconfig | 150 -
ANDROID_3.4.5/drivers/usb/core/Makefile | 14 -
ANDROID_3.4.5/drivers/usb/core/buffer.c | 151 -
ANDROID_3.4.5/drivers/usb/core/config.c | 860 ----
ANDROID_3.4.5/drivers/usb/core/devices.c | 688 ---
ANDROID_3.4.5/drivers/usb/core/devio.c | 2181 ---------
ANDROID_3.4.5/drivers/usb/core/driver.c | 1741 --------
ANDROID_3.4.5/drivers/usb/core/endpoint.c | 218 -
ANDROID_3.4.5/drivers/usb/core/file.c | 253 --
ANDROID_3.4.5/drivers/usb/core/generic.c | 247 -
ANDROID_3.4.5/drivers/usb/core/hcd-pci.c | 602 ---
ANDROID_3.4.5/drivers/usb/core/hcd.c | 2656 -----------
ANDROID_3.4.5/drivers/usb/core/hub.c | 4284 ------------------
ANDROID_3.4.5/drivers/usb/core/inode.c | 748 ----
ANDROID_3.4.5/drivers/usb/core/message.c | 1952 --------
ANDROID_3.4.5/drivers/usb/core/notify.c | 69 -
ANDROID_3.4.5/drivers/usb/core/otg_whitelist.h | 112 -
ANDROID_3.4.5/drivers/usb/core/quirks.c | 199 -
ANDROID_3.4.5/drivers/usb/core/sysfs.c | 947 ----
ANDROID_3.4.5/drivers/usb/core/urb.c | 888 ----
ANDROID_3.4.5/drivers/usb/core/usb.c | 1131 -----
ANDROID_3.4.5/drivers/usb/core/usb.h | 158 -
ANDROID_3.4.5/drivers/usb/dwc3/Kconfig | 28 -
ANDROID_3.4.5/drivers/usb/dwc3/Makefile | 47 -
ANDROID_3.4.5/drivers/usb/dwc3/core.c | 605 ---
ANDROID_3.4.5/drivers/usb/dwc3/core.h | 784 ----
ANDROID_3.4.5/drivers/usb/dwc3/debug.h | 50 -
ANDROID_3.4.5/drivers/usb/dwc3/debugfs.c | 710 ---
ANDROID_3.4.5/drivers/usb/dwc3/dwc3-exynos.c | 151 -
ANDROID_3.4.5/drivers/usb/dwc3/dwc3-omap.c | 392 --
ANDROID_3.4.5/drivers/usb/dwc3/dwc3-pci.c | 173 -
ANDROID_3.4.5/drivers/usb/dwc3/ep0.c | 873 ----
ANDROID_3.4.5/drivers/usb/dwc3/gadget.c | 2396 ----------
ANDROID_3.4.5/drivers/usb/dwc3/gadget.h | 187 -
ANDROID_3.4.5/drivers/usb/dwc3/host.c | 102 -
ANDROID_3.4.5/drivers/usb/dwc3/io.h | 54 -
ANDROID_3.4.5/drivers/usb/early/Makefile | 5 -
ANDROID_3.4.5/drivers/usb/early/ehci-dbgp.c | 1089 -----
ANDROID_3.4.5/drivers/usb/gadget/Kconfig | 1000 -----
ANDROID_3.4.5/drivers/usb/gadget/Makefile | 78 -
ANDROID_3.4.5/drivers/usb/gadget/acm_ms.c | 256 --
ANDROID_3.4.5/drivers/usb/gadget/amd5536udc.c | 3422 --------------
ANDROID_3.4.5/drivers/usb/gadget/amd5536udc.h | 617 ---
ANDROID_3.4.5/drivers/usb/gadget/android.c | 1691 -------
ANDROID_3.4.5/drivers/usb/gadget/at91_udc.c | 2035 ---------
ANDROID_3.4.5/drivers/usb/gadget/at91_udc.h | 172 -
ANDROID_3.4.5/drivers/usb/gadget/atmel_usba_udc.c | 2118 ---------
ANDROID_3.4.5/drivers/usb/gadget/atmel_usba_udc.h | 359 --
ANDROID_3.4.5/drivers/usb/gadget/audio.c | 224 -
ANDROID_3.4.5/drivers/usb/gadget/cdc2.c | 257 --
ANDROID_3.4.5/drivers/usb/gadget/ci13xxx_msm.c | 126 -
ANDROID_3.4.5/drivers/usb/gadget/ci13xxx_pci.c | 176 -
ANDROID_3.4.5/drivers/usb/gadget/ci13xxx_udc.c | 2996 -------------
ANDROID_3.4.5/drivers/usb/gadget/ci13xxx_udc.h | 227 -
ANDROID_3.4.5/drivers/usb/gadget/composite.c | 1674 -------
ANDROID_3.4.5/drivers/usb/gadget/config.c | 158 -
ANDROID_3.4.5/drivers/usb/gadget/dbgp.c | 433 --
ANDROID_3.4.5/drivers/usb/gadget/dummy_hcd.c | 2673 -----------
ANDROID_3.4.5/drivers/usb/gadget/epautoconf.c | 430 --
ANDROID_3.4.5/drivers/usb/gadget/ether.c | 413 --
ANDROID_3.4.5/drivers/usb/gadget/f_accessory.c | 1190 -----
ANDROID_3.4.5/drivers/usb/gadget/f_acm.c | 814 ----
ANDROID_3.4.5/drivers/usb/gadget/f_adb.c | 620 ---
ANDROID_3.4.5/drivers/usb/gadget/f_audio_source.c | 828 ----
ANDROID_3.4.5/drivers/usb/gadget/f_ecm.c | 924 ----
ANDROID_3.4.5/drivers/usb/gadget/f_eem.c | 598 ---
ANDROID_3.4.5/drivers/usb/gadget/f_fs.c | 2415 ----------
ANDROID_3.4.5/drivers/usb/gadget/f_hid.c | 659 ---
ANDROID_3.4.5/drivers/usb/gadget/f_loopback.c | 430 --
ANDROID_3.4.5/drivers/usb/gadget/f_mass_storage.c | 3218 --------------
ANDROID_3.4.5/drivers/usb/gadget/f_midi.c | 990 -----
ANDROID_3.4.5/drivers/usb/gadget/f_mtp.c | 1295 ------
ANDROID_3.4.5/drivers/usb/gadget/f_ncm.c | 1378 ------
ANDROID_3.4.5/drivers/usb/gadget/f_obex.c | 471 --
ANDROID_3.4.5/drivers/usb/gadget/f_phonet.c | 629 ---
ANDROID_3.4.5/drivers/usb/gadget/f_rawbulk.c | 322 --
ANDROID_3.4.5/drivers/usb/gadget/f_rndis.c | 936 ----
ANDROID_3.4.5/drivers/usb/gadget/f_serial.c | 321 --
ANDROID_3.4.5/drivers/usb/gadget/f_sourcesink.c | 584 ---
ANDROID_3.4.5/drivers/usb/gadget/f_subset.c | 460 --
ANDROID_3.4.5/drivers/usb/gadget/f_uac1.c | 776 ----
ANDROID_3.4.5/drivers/usb/gadget/f_uac2.c | 1449 ------
ANDROID_3.4.5/drivers/usb/gadget/f_uvc.c | 662 ---
ANDROID_3.4.5/drivers/usb/gadget/f_uvc.h | 25 -
ANDROID_3.4.5/drivers/usb/gadget/file_storage.c | 3676 ---------------
ANDROID_3.4.5/drivers/usb/gadget/fsl_mxc_udc.c | 123 -
ANDROID_3.4.5/drivers/usb/gadget/fsl_qe_udc.c | 2823 ------------
ANDROID_3.4.5/drivers/usb/gadget/fsl_qe_udc.h | 422 --
ANDROID_3.4.5/drivers/usb/gadget/fsl_udc_core.c | 2778 ------------
ANDROID_3.4.5/drivers/usb/gadget/fsl_usb2_udc.h | 600 ---
ANDROID_3.4.5/drivers/usb/gadget/fusb300_udc.c | 1561 -------
ANDROID_3.4.5/drivers/usb/gadget/fusb300_udc.h | 677 ---
ANDROID_3.4.5/drivers/usb/gadget/g_ffs.c | 327 --
ANDROID_3.4.5/drivers/usb/gadget/g_zero.h | 25 -
ANDROID_3.4.5/drivers/usb/gadget/gadget_chips.h | 147 -
ANDROID_3.4.5/drivers/usb/gadget/gmidi.c | 206 -
ANDROID_3.4.5/drivers/usb/gadget/goku_udc.c | 1908 --------
ANDROID_3.4.5/drivers/usb/gadget/goku_udc.h | 293 --
ANDROID_3.4.5/drivers/usb/gadget/hid.c | 288 --
ANDROID_3.4.5/drivers/usb/gadget/imx_udc.c | 1595 -------
ANDROID_3.4.5/drivers/usb/gadget/imx_udc.h | 351 --
ANDROID_3.4.5/drivers/usb/gadget/inode.c | 2135 ---------
ANDROID_3.4.5/drivers/usb/gadget/langwell_udc.c | 3434 --------------
ANDROID_3.4.5/drivers/usb/gadget/langwell_udc.h | 224 -
ANDROID_3.4.5/drivers/usb/gadget/m66592-udc.c | 1773 --------
ANDROID_3.4.5/drivers/usb/gadget/m66592-udc.h | 610 ---
ANDROID_3.4.5/drivers/usb/gadget/mass_storage.c | 182 -
ANDROID_3.4.5/drivers/usb/gadget/multi.c | 362 --
ANDROID_3.4.5/drivers/usb/gadget/mv_udc.h | 315 --
ANDROID_3.4.5/drivers/usb/gadget/mv_udc_core.c | 2494 -----------
ANDROID_3.4.5/drivers/usb/gadget/ncm.c | 240 -
ANDROID_3.4.5/drivers/usb/gadget/ndis.h | 211 -
ANDROID_3.4.5/drivers/usb/gadget/net2272.c | 2715 -----------
ANDROID_3.4.5/drivers/usb/gadget/net2272.h | 601 ---
ANDROID_3.4.5/drivers/usb/gadget/net2280.c | 2896 ------------
ANDROID_3.4.5/drivers/usb/gadget/net2280.h | 308 --
ANDROID_3.4.5/drivers/usb/gadget/nokia.c | 259 --
ANDROID_3.4.5/drivers/usb/gadget/omap_udc.c | 3148 -------------
ANDROID_3.4.5/drivers/usb/gadget/omap_udc.h | 207 -
ANDROID_3.4.5/drivers/usb/gadget/pch_udc.c | 3310 --------------
ANDROID_3.4.5/drivers/usb/gadget/printer.c | 1600 -------
ANDROID_3.4.5/drivers/usb/gadget/pxa25x_udc.c | 2373 ----------
ANDROID_3.4.5/drivers/usb/gadget/pxa25x_udc.h | 252 --
ANDROID_3.4.5/drivers/usb/gadget/pxa27x_udc.c | 2679 -----------
ANDROID_3.4.5/drivers/usb/gadget/pxa27x_udc.h | 496 ---
ANDROID_3.4.5/drivers/usb/gadget/r8a66597-udc.c | 2043 ---------
ANDROID_3.4.5/drivers/usb/gadget/r8a66597-udc.h | 294 --
ANDROID_3.4.5/drivers/usb/gadget/rawbulk.c | 1272 ------
.../drivers/usb/gadget/rawbulk_transfer.c | 1372 ------
ANDROID_3.4.5/drivers/usb/gadget/rndis.c | 1209 -----
ANDROID_3.4.5/drivers/usb/gadget/rndis.h | 268 --
ANDROID_3.4.5/drivers/usb/gadget/s3c-hsotg.c | 3478 ---------------
ANDROID_3.4.5/drivers/usb/gadget/s3c-hsudc.c | 1413 ------
ANDROID_3.4.5/drivers/usb/gadget/s3c2410_udc.c | 2106 ---------
ANDROID_3.4.5/drivers/usb/gadget/s3c2410_udc.h | 100 -
ANDROID_3.4.5/drivers/usb/gadget/serial.c | 283 --
ANDROID_3.4.5/drivers/usb/gadget/storage_common.c | 938 ----
ANDROID_3.4.5/drivers/usb/gadget/u_ether.c | 1015 -----
ANDROID_3.4.5/drivers/usb/gadget/u_ether.h | 126 -
ANDROID_3.4.5/drivers/usb/gadget/u_phonet.h | 21 -
ANDROID_3.4.5/drivers/usb/gadget/u_serial.c | 1344 ------
ANDROID_3.4.5/drivers/usb/gadget/u_serial.h | 65 -
ANDROID_3.4.5/drivers/usb/gadget/u_uac1.c | 327 --
ANDROID_3.4.5/drivers/usb/gadget/u_uac1.h | 56 -
ANDROID_3.4.5/drivers/usb/gadget/udc-core.c | 539 ---
ANDROID_3.4.5/drivers/usb/gadget/udc_wmt.c | 4699 --------------------
ANDROID_3.4.5/drivers/usb/gadget/udc_wmt.h | 801 ----
ANDROID_3.4.5/drivers/usb/gadget/usbstring.c | 71 -
ANDROID_3.4.5/drivers/usb/gadget/uvc.h | 199 -
ANDROID_3.4.5/drivers/usb/gadget/uvc_queue.c | 585 ---
ANDROID_3.4.5/drivers/usb/gadget/uvc_queue.h | 69 -
ANDROID_3.4.5/drivers/usb/gadget/uvc_v4l2.c | 356 --
ANDROID_3.4.5/drivers/usb/gadget/uvc_video.c | 385 --
ANDROID_3.4.5/drivers/usb/gadget/webcam.c | 399 --
ANDROID_3.4.5/drivers/usb/gadget/zero.c | 353 --
ANDROID_3.4.5/drivers/usb/host/Kconfig | 655 ---
ANDROID_3.4.5/drivers/usb/host/Makefile | 43 -
ANDROID_3.4.5/drivers/usb/host/alchemy-common.c | 614 ---
ANDROID_3.4.5/drivers/usb/host/ehci-atmel.c | 256 --
ANDROID_3.4.5/drivers/usb/host/ehci-au1xxx.c | 267 --
ANDROID_3.4.5/drivers/usb/host/ehci-cns3xxx.c | 171 -
ANDROID_3.4.5/drivers/usb/host/ehci-dbg.c | 1089 -----
ANDROID_3.4.5/drivers/usb/host/ehci-fsl.c | 706 ---
ANDROID_3.4.5/drivers/usb/host/ehci-fsl.h | 53 -
ANDROID_3.4.5/drivers/usb/host/ehci-grlib.c | 242 -
ANDROID_3.4.5/drivers/usb/host/ehci-hcd.c | 1554 -------
ANDROID_3.4.5/drivers/usb/host/ehci-hub.c | 1405 ------
ANDROID_3.4.5/drivers/usb/host/ehci-ixp4xx.c | 156 -
ANDROID_3.4.5/drivers/usb/host/ehci-lpm.c | 84 -
ANDROID_3.4.5/drivers/usb/host/ehci-ls1x.c | 159 -
ANDROID_3.4.5/drivers/usb/host/ehci-mem.c | 264 --
ANDROID_3.4.5/drivers/usb/host/ehci-msm.c | 247 -
ANDROID_3.4.5/drivers/usb/host/ehci-mv.c | 391 --
ANDROID_3.4.5/drivers/usb/host/ehci-mxc.c | 344 --
ANDROID_3.4.5/drivers/usb/host/ehci-octeon.c | 209 -
ANDROID_3.4.5/drivers/usb/host/ehci-omap.c | 377 --
ANDROID_3.4.5/drivers/usb/host/ehci-orion.c | 320 --
ANDROID_3.4.5/drivers/usb/host/ehci-pci.c | 575 ---
ANDROID_3.4.5/drivers/usb/host/ehci-platform.c | 196 -
ANDROID_3.4.5/drivers/usb/host/ehci-pmcmsp.c | 383 --
ANDROID_3.4.5/drivers/usb/host/ehci-ppc-of.c | 284 --
ANDROID_3.4.5/drivers/usb/host/ehci-ps3.c | 282 --
ANDROID_3.4.5/drivers/usb/host/ehci-q.c | 1321 ------
ANDROID_3.4.5/drivers/usb/host/ehci-s5p.c | 313 --
ANDROID_3.4.5/drivers/usb/host/ehci-sched.c | 2502 -----------
ANDROID_3.4.5/drivers/usb/host/ehci-sh.c | 243 -
ANDROID_3.4.5/drivers/usb/host/ehci-spear.c | 291 --
ANDROID_3.4.5/drivers/usb/host/ehci-sysfs.c | 190 -
ANDROID_3.4.5/drivers/usb/host/ehci-tegra.c | 873 ----
ANDROID_3.4.5/drivers/usb/host/ehci-vt8500.c | 175 -
ANDROID_3.4.5/drivers/usb/host/ehci-w90x900.c | 186 -
ANDROID_3.4.5/drivers/usb/host/ehci-xilinx-of.c | 299 --
ANDROID_3.4.5/drivers/usb/host/ehci-xls.c | 161 -
ANDROID_3.4.5/drivers/usb/host/ehci.h | 796 ----
ANDROID_3.4.5/drivers/usb/host/fhci-dbg.c | 139 -
ANDROID_3.4.5/drivers/usb/host/fhci-hcd.c | 833 ----
ANDROID_3.4.5/drivers/usb/host/fhci-hub.c | 345 --
ANDROID_3.4.5/drivers/usb/host/fhci-mem.c | 114 -
ANDROID_3.4.5/drivers/usb/host/fhci-q.c | 285 --
ANDROID_3.4.5/drivers/usb/host/fhci-sched.c | 895 ----
ANDROID_3.4.5/drivers/usb/host/fhci-tds.c | 626 ---
ANDROID_3.4.5/drivers/usb/host/fhci.h | 612 ---
ANDROID_3.4.5/drivers/usb/host/fsl-mph-dr-of.c | 303 --
ANDROID_3.4.5/drivers/usb/host/hwa-hc.c | 843 ----
ANDROID_3.4.5/drivers/usb/host/imx21-dbg.c | 527 ---
ANDROID_3.4.5/drivers/usb/host/imx21-hcd.c | 1932 --------
ANDROID_3.4.5/drivers/usb/host/imx21-hcd.h | 440 --
ANDROID_3.4.5/drivers/usb/host/isp116x-hcd.c | 1713 -------
ANDROID_3.4.5/drivers/usb/host/isp116x.h | 606 ---
ANDROID_3.4.5/drivers/usb/host/isp1362-hcd.c | 2869 ------------
ANDROID_3.4.5/drivers/usb/host/isp1362.h | 1057 -----
ANDROID_3.4.5/drivers/usb/host/isp1760-hcd.c | 2262 ----------
ANDROID_3.4.5/drivers/usb/host/isp1760-hcd.h | 208 -
ANDROID_3.4.5/drivers/usb/host/isp1760-if.c | 473 --
ANDROID_3.4.5/drivers/usb/host/octeon2-common.c | 200 -
ANDROID_3.4.5/drivers/usb/host/ohci-at91.c | 717 ---
ANDROID_3.4.5/drivers/usb/host/ohci-au1xxx.c | 233 -
ANDROID_3.4.5/drivers/usb/host/ohci-cns3xxx.c | 165 -
ANDROID_3.4.5/drivers/usb/host/ohci-da8xx.c | 456 --
ANDROID_3.4.5/drivers/usb/host/ohci-dbg.c | 877 ----
ANDROID_3.4.5/drivers/usb/host/ohci-ep93xx.c | 216 -
ANDROID_3.4.5/drivers/usb/host/ohci-exynos.c | 272 --
ANDROID_3.4.5/drivers/usb/host/ohci-hcd.c | 1305 ------
ANDROID_3.4.5/drivers/usb/host/ohci-hub.c | 825 ----
ANDROID_3.4.5/drivers/usb/host/ohci-jz4740.c | 276 --
ANDROID_3.4.5/drivers/usb/host/ohci-mem.c | 138 -
ANDROID_3.4.5/drivers/usb/host/ohci-nxp.c | 528 ---
ANDROID_3.4.5/drivers/usb/host/ohci-octeon.c | 214 -
ANDROID_3.4.5/drivers/usb/host/ohci-omap.c | 557 ---
ANDROID_3.4.5/drivers/usb/host/ohci-omap3.c | 243 -
ANDROID_3.4.5/drivers/usb/host/ohci-pci.c | 422 --
ANDROID_3.4.5/drivers/usb/host/ohci-platform.c | 194 -
ANDROID_3.4.5/drivers/usb/host/ohci-pnx8550.c | 242 -
ANDROID_3.4.5/drivers/usb/host/ohci-ppc-of.c | 253 --
ANDROID_3.4.5/drivers/usb/host/ohci-ppc-soc.c | 215 -
ANDROID_3.4.5/drivers/usb/host/ohci-ps3.c | 249 --
ANDROID_3.4.5/drivers/usb/host/ohci-pxa27x.c | 551 ---
ANDROID_3.4.5/drivers/usb/host/ohci-q.c | 1134 -----
ANDROID_3.4.5/drivers/usb/host/ohci-s3c2410.c | 552 ---
ANDROID_3.4.5/drivers/usb/host/ohci-sa1111.c | 257 --
ANDROID_3.4.5/drivers/usb/host/ohci-sh.c | 141 -
ANDROID_3.4.5/drivers/usb/host/ohci-sm501.c | 265 --
ANDROID_3.4.5/drivers/usb/host/ohci-spear.c | 239 -
ANDROID_3.4.5/drivers/usb/host/ohci-ssb.c | 260 --
ANDROID_3.4.5/drivers/usb/host/ohci-tmio.c | 373 --
ANDROID_3.4.5/drivers/usb/host/ohci-xls.c | 151 -
ANDROID_3.4.5/drivers/usb/host/ohci.h | 725 ---
ANDROID_3.4.5/drivers/usb/host/oxu210hp-hcd.c | 3957 ----------------
ANDROID_3.4.5/drivers/usb/host/oxu210hp.h | 447 --
ANDROID_3.4.5/drivers/usb/host/pci-quirks.c | 934 ----
ANDROID_3.4.5/drivers/usb/host/pci-quirks.h | 19 -
ANDROID_3.4.5/drivers/usb/host/r8a66597-hcd.c | 2558 -----------
ANDROID_3.4.5/drivers/usb/host/r8a66597.h | 350 --
ANDROID_3.4.5/drivers/usb/host/sl811-hcd.c | 1822 --------
ANDROID_3.4.5/drivers/usb/host/sl811.h | 266 --
ANDROID_3.4.5/drivers/usb/host/sl811_cs.c | 216 -
ANDROID_3.4.5/drivers/usb/host/u132-hcd.c | 3260 --------------
ANDROID_3.4.5/drivers/usb/host/uhci-debug.c | 593 ---
ANDROID_3.4.5/drivers/usb/host/uhci-grlib.c | 208 -
ANDROID_3.4.5/drivers/usb/host/uhci-hcd.c | 939 ----
ANDROID_3.4.5/drivers/usb/host/uhci-hcd.h | 664 ---
ANDROID_3.4.5/drivers/usb/host/uhci-hub.c | 421 --
ANDROID_3.4.5/drivers/usb/host/uhci-pci.c | 325 --
ANDROID_3.4.5/drivers/usb/host/uhci-q.c | 1791 --------
ANDROID_3.4.5/drivers/usb/host/whci/Kbuild | 12 -
ANDROID_3.4.5/drivers/usb/host/whci/asl.c | 389 --
ANDROID_3.4.5/drivers/usb/host/whci/debug.c | 203 -
ANDROID_3.4.5/drivers/usb/host/whci/hcd.c | 368 --
ANDROID_3.4.5/drivers/usb/host/whci/hw.c | 104 -
ANDROID_3.4.5/drivers/usb/host/whci/init.c | 189 -
ANDROID_3.4.5/drivers/usb/host/whci/int.c | 94 -
ANDROID_3.4.5/drivers/usb/host/whci/pzl.c | 417 --
ANDROID_3.4.5/drivers/usb/host/whci/qset.c | 832 ----
ANDROID_3.4.5/drivers/usb/host/whci/whcd.h | 215 -
ANDROID_3.4.5/drivers/usb/host/whci/whci-hc.h | 414 --
ANDROID_3.4.5/drivers/usb/host/whci/wusb.c | 222 -
ANDROID_3.4.5/drivers/usb/host/xhci-dbg.c | 576 ---
ANDROID_3.4.5/drivers/usb/host/xhci-ext-caps.h | 155 -
ANDROID_3.4.5/drivers/usb/host/xhci-hub.c | 1096 -----
ANDROID_3.4.5/drivers/usb/host/xhci-mem.c | 2460 ----------
ANDROID_3.4.5/drivers/usb/host/xhci-pci.c | 335 --
ANDROID_3.4.5/drivers/usb/host/xhci-plat.c | 205 -
ANDROID_3.4.5/drivers/usb/host/xhci-ring.c | 3691 ---------------
ANDROID_3.4.5/drivers/usb/host/xhci.c | 4114 -----------------
ANDROID_3.4.5/drivers/usb/host/xhci.h | 1810 --------
ANDROID_3.4.5/drivers/usb/image/Kconfig | 30 -
ANDROID_3.4.5/drivers/usb/image/Makefile | 6 -
ANDROID_3.4.5/drivers/usb/image/mdc800.c | 1089 -----
ANDROID_3.4.5/drivers/usb/image/microtek.c | 816 ----
ANDROID_3.4.5/drivers/usb/image/microtek.h | 54 -
ANDROID_3.4.5/drivers/usb/misc/Kconfig | 246 -
ANDROID_3.4.5/drivers/usb/misc/Makefile | 29 -
ANDROID_3.4.5/drivers/usb/misc/adutux.c | 892 ----
ANDROID_3.4.5/drivers/usb/misc/appledisplay.c | 381 --
ANDROID_3.4.5/drivers/usb/misc/cypress_cy7c63.c | 279 --
ANDROID_3.4.5/drivers/usb/misc/cytherm.c | 424 --
ANDROID_3.4.5/drivers/usb/misc/emi26.c | 286 --
ANDROID_3.4.5/drivers/usb/misc/emi62.c | 300 --
ANDROID_3.4.5/drivers/usb/misc/ftdi-elan.c | 2946 ------------
ANDROID_3.4.5/drivers/usb/misc/idmouse.c | 436 --
ANDROID_3.4.5/drivers/usb/misc/iowarrior.c | 930 ----
ANDROID_3.4.5/drivers/usb/misc/isight_firmware.c | 134 -
ANDROID_3.4.5/drivers/usb/misc/ldusb.c | 825 ----
ANDROID_3.4.5/drivers/usb/misc/legousbtower.c | 1052 -----
ANDROID_3.4.5/drivers/usb/misc/rio500.c | 539 ---
ANDROID_3.4.5/drivers/usb/misc/rio500_usb.h | 37 -
ANDROID_3.4.5/drivers/usb/misc/sisusbvga/Kconfig | 46 -
ANDROID_3.4.5/drivers/usb/misc/sisusbvga/Makefile | 7 -
ANDROID_3.4.5/drivers/usb/misc/sisusbvga/sisusb.c | 3285 --------------
ANDROID_3.4.5/drivers/usb/misc/sisusbvga/sisusb.h | 311 --
.../drivers/usb/misc/sisusbvga/sisusb_con.c | 1564 -------
.../drivers/usb/misc/sisusbvga/sisusb_init.c | 959 ----
.../drivers/usb/misc/sisusbvga/sisusb_init.h | 841 ----
.../drivers/usb/misc/sisusbvga/sisusb_struct.h | 161 -
ANDROID_3.4.5/drivers/usb/misc/trancevibrator.c | 144 -
ANDROID_3.4.5/drivers/usb/misc/usb_u132.h | 101 -
ANDROID_3.4.5/drivers/usb/misc/usblcd.c | 457 --
ANDROID_3.4.5/drivers/usb/misc/usbled.c | 240 -
ANDROID_3.4.5/drivers/usb/misc/usbsevseg.c | 444 --
ANDROID_3.4.5/drivers/usb/misc/usbtest.c | 2529 -----------
ANDROID_3.4.5/drivers/usb/misc/uss720.c | 825 ----
ANDROID_3.4.5/drivers/usb/misc/yurex.c | 540 ---
ANDROID_3.4.5/drivers/usb/mon/Kconfig | 13 -
ANDROID_3.4.5/drivers/usb/mon/Makefile | 7 -
ANDROID_3.4.5/drivers/usb/mon/mon_bin.c | 1389 ------
ANDROID_3.4.5/drivers/usb/mon/mon_main.c | 431 --
ANDROID_3.4.5/drivers/usb/mon/mon_stat.c | 69 -
ANDROID_3.4.5/drivers/usb/mon/mon_text.c | 761 ----
ANDROID_3.4.5/drivers/usb/mon/usb_mon.h | 75 -
ANDROID_3.4.5/drivers/usb/musb/Kconfig | 117 -
ANDROID_3.4.5/drivers/usb/musb/Makefile | 30 -
ANDROID_3.4.5/drivers/usb/musb/am35x.c | 656 ---
ANDROID_3.4.5/drivers/usb/musb/blackfin.c | 600 ---
ANDROID_3.4.5/drivers/usb/musb/blackfin.h | 87 -
ANDROID_3.4.5/drivers/usb/musb/cppi_dma.c | 1563 -------
ANDROID_3.4.5/drivers/usb/musb/cppi_dma.h | 134 -
ANDROID_3.4.5/drivers/usb/musb/da8xx.c | 601 ---
ANDROID_3.4.5/drivers/usb/musb/davinci.c | 635 ---
ANDROID_3.4.5/drivers/usb/musb/davinci.h | 107 -
ANDROID_3.4.5/drivers/usb/musb/musb_core.c | 2416 ----------
ANDROID_3.4.5/drivers/usb/musb/musb_core.h | 606 ---
ANDROID_3.4.5/drivers/usb/musb/musb_debug.h | 58 -
ANDROID_3.4.5/drivers/usb/musb/musb_debugfs.c | 278 --
ANDROID_3.4.5/drivers/usb/musb/musb_dma.h | 186 -
ANDROID_3.4.5/drivers/usb/musb/musb_gadget.c | 2239 ----------
ANDROID_3.4.5/drivers/usb/musb/musb_gadget.h | 121 -
ANDROID_3.4.5/drivers/usb/musb/musb_gadget_ep0.c | 1083 -----
ANDROID_3.4.5/drivers/usb/musb/musb_host.c | 2331 ----------
ANDROID_3.4.5/drivers/usb/musb/musb_host.h | 108 -
ANDROID_3.4.5/drivers/usb/musb/musb_io.h | 142 -
ANDROID_3.4.5/drivers/usb/musb/musb_regs.h | 645 ---
ANDROID_3.4.5/drivers/usb/musb/musb_virthub.c | 435 --
ANDROID_3.4.5/drivers/usb/musb/musbhsdma.c | 422 --
ANDROID_3.4.5/drivers/usb/musb/musbhsdma.h | 165 -
ANDROID_3.4.5/drivers/usb/musb/omap2430.c | 555 ---
ANDROID_3.4.5/drivers/usb/musb/omap2430.h | 52 -
ANDROID_3.4.5/drivers/usb/musb/tusb6010.c | 1265 ------
ANDROID_3.4.5/drivers/usb/musb/tusb6010.h | 232 -
ANDROID_3.4.5/drivers/usb/musb/tusb6010_omap.c | 727 ---
ANDROID_3.4.5/drivers/usb/musb/ux500.c | 219 -
ANDROID_3.4.5/drivers/usb/musb/ux500_dma.c | 393 --
ANDROID_3.4.5/drivers/usb/otg/Kconfig | 139 -
ANDROID_3.4.5/drivers/usb/otg/Makefile | 24 -
ANDROID_3.4.5/drivers/usb/otg/ab8500-usb.c | 596 ---
ANDROID_3.4.5/drivers/usb/otg/fsl_otg.c | 1169 -----
ANDROID_3.4.5/drivers/usb/otg/fsl_otg.h | 406 --
ANDROID_3.4.5/drivers/usb/otg/gpio_vbus.c | 381 --
ANDROID_3.4.5/drivers/usb/otg/isp1301_omap.c | 1656 -------
ANDROID_3.4.5/drivers/usb/otg/msm_otg.c | 1773 --------
ANDROID_3.4.5/drivers/usb/otg/mv_otg.c | 973 ----
ANDROID_3.4.5/drivers/usb/otg/mv_otg.h | 165 -
ANDROID_3.4.5/drivers/usb/otg/nop-usb-xceiv.c | 175 -
ANDROID_3.4.5/drivers/usb/otg/otg-wakelock.c | 170 -
ANDROID_3.4.5/drivers/usb/otg/otg.c | 102 -
ANDROID_3.4.5/drivers/usb/otg/otg_fsm.c | 348 --
ANDROID_3.4.5/drivers/usb/otg/otg_fsm.h | 154 -
ANDROID_3.4.5/drivers/usb/otg/twl4030-usb.c | 734 ---
ANDROID_3.4.5/drivers/usb/otg/twl6030-usb.c | 539 ---
ANDROID_3.4.5/drivers/usb/otg/ulpi.c | 283 --
ANDROID_3.4.5/drivers/usb/otg/ulpi_viewport.c | 80 -
ANDROID_3.4.5/drivers/usb/renesas_usbhs/Kconfig | 15 -
ANDROID_3.4.5/drivers/usb/renesas_usbhs/Makefile | 15 -
ANDROID_3.4.5/drivers/usb/renesas_usbhs/common.c | 648 ---
ANDROID_3.4.5/drivers/usb/renesas_usbhs/common.h | 324 --
ANDROID_3.4.5/drivers/usb/renesas_usbhs/fifo.c | 1193 -----
ANDROID_3.4.5/drivers/usb/renesas_usbhs/fifo.h | 104 -
ANDROID_3.4.5/drivers/usb/renesas_usbhs/mod.c | 369 --
ANDROID_3.4.5/drivers/usb/renesas_usbhs/mod.h | 172 -
.../drivers/usb/renesas_usbhs/mod_gadget.c | 1021 -----
ANDROID_3.4.5/drivers/usb/renesas_usbhs/mod_host.c | 1560 -------
ANDROID_3.4.5/drivers/usb/renesas_usbhs/pipe.c | 725 ---
ANDROID_3.4.5/drivers/usb/renesas_usbhs/pipe.h | 115 -
ANDROID_3.4.5/drivers/usb/serial/Kconfig | 682 ---
ANDROID_3.4.5/drivers/usb/serial/Makefile | 65 -
.../drivers/usb/serial/Makefile-keyspan_pda_fw | 16 -
ANDROID_3.4.5/drivers/usb/serial/aircable.c | 207 -
ANDROID_3.4.5/drivers/usb/serial/ark3116.c | 859 ----
ANDROID_3.4.5/drivers/usb/serial/belkin_sa.c | 535 ---
ANDROID_3.4.5/drivers/usb/serial/belkin_sa.h | 124 -
ANDROID_3.4.5/drivers/usb/serial/bus.c | 179 -
ANDROID_3.4.5/drivers/usb/serial/ch341.c | 660 ---
ANDROID_3.4.5/drivers/usb/serial/console.c | 317 --
ANDROID_3.4.5/drivers/usb/serial/cp210x.c | 913 ----
ANDROID_3.4.5/drivers/usb/serial/cyberjack.c | 486 --
ANDROID_3.4.5/drivers/usb/serial/cypress_m8.c | 1363 ------
ANDROID_3.4.5/drivers/usb/serial/cypress_m8.h | 70 -
ANDROID_3.4.5/drivers/usb/serial/digi_acceleport.c | 1590 -------
ANDROID_3.4.5/drivers/usb/serial/empeg.c | 148 -
ANDROID_3.4.5/drivers/usb/serial/ezusb.c | 61 -
ANDROID_3.4.5/drivers/usb/serial/ezusb_convert.pl | 50 -
ANDROID_3.4.5/drivers/usb/serial/f81232.c | 405 --
ANDROID_3.4.5/drivers/usb/serial/ftdi_sio.c | 2481 -----------
ANDROID_3.4.5/drivers/usb/serial/ftdi_sio.h | 564 ---
ANDROID_3.4.5/drivers/usb/serial/ftdi_sio_ids.h | 1218 -----
ANDROID_3.4.5/drivers/usb/serial/funsoft.c | 52 -
ANDROID_3.4.5/drivers/usb/serial/garmin_gps.c | 1528 -------
ANDROID_3.4.5/drivers/usb/serial/generic.c | 580 ---
ANDROID_3.4.5/drivers/usb/serial/hp4x.c | 63 -
ANDROID_3.4.5/drivers/usb/serial/io_16654.h | 195 -
ANDROID_3.4.5/drivers/usb/serial/io_edgeport.c | 3195 -------------
ANDROID_3.4.5/drivers/usb/serial/io_edgeport.h | 134 -
ANDROID_3.4.5/drivers/usb/serial/io_ionsp.h | 455 --
ANDROID_3.4.5/drivers/usb/serial/io_tables.h | 227 -
ANDROID_3.4.5/drivers/usb/serial/io_ti.c | 2804 ------------
ANDROID_3.4.5/drivers/usb/serial/io_ti.h | 186 -
ANDROID_3.4.5/drivers/usb/serial/io_usbvend.h | 683 ---
ANDROID_3.4.5/drivers/usb/serial/ipaq.c | 670 ---
ANDROID_3.4.5/drivers/usb/serial/ipw.c | 344 --
ANDROID_3.4.5/drivers/usb/serial/ir-usb.c | 476 --
ANDROID_3.4.5/drivers/usb/serial/iuu_phoenix.c | 1324 ------
ANDROID_3.4.5/drivers/usb/serial/iuu_phoenix.h | 122 -
ANDROID_3.4.5/drivers/usb/serial/keyspan.c | 2616 -----------
ANDROID_3.4.5/drivers/usb/serial/keyspan.h | 623 ---
ANDROID_3.4.5/drivers/usb/serial/keyspan_pda.c | 844 ----
.../drivers/usb/serial/keyspan_usa26msg.h | 260 --
.../drivers/usb/serial/keyspan_usa28msg.h | 201 -
.../drivers/usb/serial/keyspan_usa49msg.h | 282 --
.../drivers/usb/serial/keyspan_usa67msg.h | 254 --
.../drivers/usb/serial/keyspan_usa90msg.h | 198 -
ANDROID_3.4.5/drivers/usb/serial/kl5kusb105.c | 702 ---
ANDROID_3.4.5/drivers/usb/serial/kl5kusb105.h | 68 -
ANDROID_3.4.5/drivers/usb/serial/kobil_sct.c | 693 ---
ANDROID_3.4.5/drivers/usb/serial/kobil_sct.h | 77 -
ANDROID_3.4.5/drivers/usb/serial/mct_u232.c | 919 ----
ANDROID_3.4.5/drivers/usb/serial/mct_u232.h | 467 --
ANDROID_3.4.5/drivers/usb/serial/metro-usb.c | 394 --
ANDROID_3.4.5/drivers/usb/serial/mos7720.c | 2213 ---------
ANDROID_3.4.5/drivers/usb/serial/mos7840.c | 2716 -----------
ANDROID_3.4.5/drivers/usb/serial/moto_modem.c | 55 -
ANDROID_3.4.5/drivers/usb/serial/navman.c | 140 -
ANDROID_3.4.5/drivers/usb/serial/omninet.c | 331 --
ANDROID_3.4.5/drivers/usb/serial/opticon.c | 640 ---
ANDROID_3.4.5/drivers/usb/serial/option.c | 1556 -------
ANDROID_3.4.5/drivers/usb/serial/oti6858.c | 970 ----
ANDROID_3.4.5/drivers/usb/serial/oti6858.h | 15 -
ANDROID_3.4.5/drivers/usb/serial/pl2303.c | 865 ----
ANDROID_3.4.5/drivers/usb/serial/pl2303.h | 151 -
ANDROID_3.4.5/drivers/usb/serial/qcaux.c | 101 -
ANDROID_3.4.5/drivers/usb/serial/qcserial.c | 301 --
ANDROID_3.4.5/drivers/usb/serial/safe_serial.c | 351 --
ANDROID_3.4.5/drivers/usb/serial/siemens_mpi.c | 56 -
ANDROID_3.4.5/drivers/usb/serial/sierra.c | 1136 -----
ANDROID_3.4.5/drivers/usb/serial/spcp8x5.c | 676 ---
ANDROID_3.4.5/drivers/usb/serial/ssu100.c | 704 ---
ANDROID_3.4.5/drivers/usb/serial/symbolserial.c | 317 --
.../drivers/usb/serial/ti_usb_3410_5052.c | 1750 --------
.../drivers/usb/serial/ti_usb_3410_5052.h | 245 -
ANDROID_3.4.5/drivers/usb/serial/usb-serial.c | 1455 ------
ANDROID_3.4.5/drivers/usb/serial/usb-wwan.h | 69 -
ANDROID_3.4.5/drivers/usb/serial/usb_debug.c | 87 -
ANDROID_3.4.5/drivers/usb/serial/usb_wwan.c | 774 ----
ANDROID_3.4.5/drivers/usb/serial/via_option.c | 1218 -----
ANDROID_3.4.5/drivers/usb/serial/via_usb-wwan.h | 88 -
ANDROID_3.4.5/drivers/usb/serial/via_usb_wwan.c | 1013 -----
ANDROID_3.4.5/drivers/usb/serial/visor.c | 716 ---
ANDROID_3.4.5/drivers/usb/serial/visor.h | 161 -
ANDROID_3.4.5/drivers/usb/serial/vivopay-serial.c | 53 -
ANDROID_3.4.5/drivers/usb/serial/whiteheat.c | 1470 ------
ANDROID_3.4.5/drivers/usb/serial/whiteheat.h | 302 --
ANDROID_3.4.5/drivers/usb/serial/zio.c | 46 -
ANDROID_3.4.5/drivers/usb/storage/Kconfig | 229 -
ANDROID_3.4.5/drivers/usb/storage/Makefile | 51 -
ANDROID_3.4.5/drivers/usb/storage/alauda.c | 1282 ------
ANDROID_3.4.5/drivers/usb/storage/cypress_atacb.c | 278 --
ANDROID_3.4.5/drivers/usb/storage/datafab.c | 757 ----
ANDROID_3.4.5/drivers/usb/storage/debug.c | 177 -
ANDROID_3.4.5/drivers/usb/storage/debug.h | 62 -
ANDROID_3.4.5/drivers/usb/storage/ene_ub6250.c | 2413 ----------
ANDROID_3.4.5/drivers/usb/storage/freecom.c | 559 ---
ANDROID_3.4.5/drivers/usb/storage/initializers.c | 106 -
ANDROID_3.4.5/drivers/usb/storage/initializers.h | 50 -
ANDROID_3.4.5/drivers/usb/storage/isd200.c | 1572 -------
ANDROID_3.4.5/drivers/usb/storage/jumpshot.c | 683 ---
ANDROID_3.4.5/drivers/usb/storage/karma.c | 236 -
ANDROID_3.4.5/drivers/usb/storage/libusual.c | 243 -
ANDROID_3.4.5/drivers/usb/storage/onetouch.c | 318 --
ANDROID_3.4.5/drivers/usb/storage/option_ms.c | 170 -
ANDROID_3.4.5/drivers/usb/storage/option_ms.h | 4 -
ANDROID_3.4.5/drivers/usb/storage/protocol.c | 220 -
ANDROID_3.4.5/drivers/usb/storage/protocol.h | 57 -
ANDROID_3.4.5/drivers/usb/storage/realtek_cr.c | 1112 -----
ANDROID_3.4.5/drivers/usb/storage/scsiglue.c | 595 ---
ANDROID_3.4.5/drivers/usb/storage/scsiglue.h | 48 -
ANDROID_3.4.5/drivers/usb/storage/sddr09.c | 1793 --------
ANDROID_3.4.5/drivers/usb/storage/sddr55.c | 1012 -----
ANDROID_3.4.5/drivers/usb/storage/shuttle_usbat.c | 1869 --------
ANDROID_3.4.5/drivers/usb/storage/sierra_ms.c | 207 -
ANDROID_3.4.5/drivers/usb/storage/sierra_ms.h | 4 -
ANDROID_3.4.5/drivers/usb/storage/transport.c | 1353 ------
ANDROID_3.4.5/drivers/usb/storage/transport.h | 103 -
ANDROID_3.4.5/drivers/usb/storage/uas.c | 862 ----
ANDROID_3.4.5/drivers/usb/storage/unusual_alauda.h | 31 -
.../drivers/usb/storage/unusual_cypress.h | 39 -
.../drivers/usb/storage/unusual_datafab.h | 98 -
ANDROID_3.4.5/drivers/usb/storage/unusual_devs.h | 2050 ---------
.../drivers/usb/storage/unusual_ene_ub6250.h | 26 -
.../drivers/usb/storage/unusual_freecom.h | 26 -
ANDROID_3.4.5/drivers/usb/storage/unusual_isd200.h | 57 -
.../drivers/usb/storage/unusual_jumpshot.h | 27 -
ANDROID_3.4.5/drivers/usb/storage/unusual_karma.h | 26 -
.../drivers/usb/storage/unusual_onetouch.h | 36 -
.../drivers/usb/storage/unusual_realtek.h | 41 -
ANDROID_3.4.5/drivers/usb/storage/unusual_sddr09.h | 56 -
ANDROID_3.4.5/drivers/usb/storage/unusual_sddr55.h | 44 -
ANDROID_3.4.5/drivers/usb/storage/unusual_usbat.h | 43 -
ANDROID_3.4.5/drivers/usb/storage/usb.c | 1127 -----
ANDROID_3.4.5/drivers/usb/storage/usb.h | 204 -
ANDROID_3.4.5/drivers/usb/storage/usual-tables.c | 118 -
ANDROID_3.4.5/drivers/usb/usb-common.c | 35 -
ANDROID_3.4.5/drivers/usb/usb-skeleton.c | 679 ---
ANDROID_3.4.5/drivers/usb/wusbcore/Kconfig | 42 -
ANDROID_3.4.5/drivers/usb/wusbcore/Makefile | 25 -
ANDROID_3.4.5/drivers/usb/wusbcore/cbaf.c | 662 ---
ANDROID_3.4.5/drivers/usb/wusbcore/crypto.c | 518 ---
ANDROID_3.4.5/drivers/usb/wusbcore/dev-sysfs.c | 139 -
ANDROID_3.4.5/drivers/usb/wusbcore/devconnect.c | 1133 -----
ANDROID_3.4.5/drivers/usb/wusbcore/mmc.c | 287 --
ANDROID_3.4.5/drivers/usb/wusbcore/pal.c | 54 -
ANDROID_3.4.5/drivers/usb/wusbcore/reservation.c | 118 -
ANDROID_3.4.5/drivers/usb/wusbcore/rh.c | 452 --
ANDROID_3.4.5/drivers/usb/wusbcore/security.c | 577 ---
ANDROID_3.4.5/drivers/usb/wusbcore/wa-hc.c | 97 -
ANDROID_3.4.5/drivers/usb/wusbcore/wa-hc.h | 417 --
ANDROID_3.4.5/drivers/usb/wusbcore/wa-nep.c | 305 --
ANDROID_3.4.5/drivers/usb/wusbcore/wa-rpipe.c | 530 ---
ANDROID_3.4.5/drivers/usb/wusbcore/wa-xfer.c | 1616 -------
ANDROID_3.4.5/drivers/usb/wusbcore/wusbhc.c | 450 --
ANDROID_3.4.5/drivers/usb/wusbcore/wusbhc.h | 496 ---
573 files changed, 400437 deletions(-)
delete mode 100644 ANDROID_3.4.5/drivers/usb/Kconfig
delete mode 100644 ANDROID_3.4.5/drivers/usb/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/README
delete mode 100644 ANDROID_3.4.5/drivers/usb/atm/Kconfig
delete mode 100644 ANDROID_3.4.5/drivers/usb/atm/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/atm/cxacru.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/atm/speedtch.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/atm/ueagle-atm.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/atm/usbatm.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/atm/usbatm.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/atm/xusbatm.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/c67x00/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/c67x00/c67x00-drv.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/c67x00/c67x00-hcd.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/c67x00/c67x00-hcd.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/c67x00/c67x00-ll-hpi.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/c67x00/c67x00-sched.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/c67x00/c67x00.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/class/Kconfig
delete mode 100644 ANDROID_3.4.5/drivers/usb/class/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/class/cdc-acm.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/class/cdc-acm.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/class/cdc-wdm.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/class/usblp.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/class/usbtmc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/Kconfig
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/buffer.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/config.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/devices.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/devio.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/driver.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/endpoint.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/file.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/generic.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/hcd-pci.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/hcd.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/hub.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/inode.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/message.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/notify.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/otg_whitelist.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/quirks.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/sysfs.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/urb.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/usb.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/core/usb.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/dwc3/Kconfig
delete mode 100644 ANDROID_3.4.5/drivers/usb/dwc3/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/dwc3/core.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/dwc3/core.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/dwc3/debug.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/dwc3/debugfs.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/dwc3/dwc3-exynos.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/dwc3/dwc3-omap.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/dwc3/dwc3-pci.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/dwc3/ep0.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/dwc3/gadget.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/dwc3/gadget.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/dwc3/host.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/dwc3/io.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/early/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/early/ehci-dbgp.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/Kconfig
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/acm_ms.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/amd5536udc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/amd5536udc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/android.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/at91_udc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/at91_udc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/atmel_usba_udc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/atmel_usba_udc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/audio.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/cdc2.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/ci13xxx_msm.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/ci13xxx_pci.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/ci13xxx_udc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/ci13xxx_udc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/composite.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/config.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/dbgp.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/dummy_hcd.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/epautoconf.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/ether.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_accessory.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_acm.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_adb.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_audio_source.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_ecm.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_eem.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_fs.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_hid.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_loopback.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_mass_storage.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_midi.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_mtp.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_ncm.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_obex.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_phonet.c
delete mode 100755 ANDROID_3.4.5/drivers/usb/gadget/f_rawbulk.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_rndis.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_serial.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_sourcesink.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_subset.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_uac1.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_uac2.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_uvc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/f_uvc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/file_storage.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/fsl_mxc_udc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/fsl_qe_udc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/fsl_qe_udc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/fsl_udc_core.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/fsl_usb2_udc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/fusb300_udc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/fusb300_udc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/g_ffs.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/g_zero.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/gadget_chips.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/gmidi.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/goku_udc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/goku_udc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/hid.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/imx_udc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/imx_udc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/inode.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/langwell_udc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/langwell_udc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/m66592-udc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/m66592-udc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/mass_storage.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/multi.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/mv_udc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/mv_udc_core.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/ncm.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/ndis.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/net2272.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/net2272.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/net2280.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/net2280.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/nokia.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/omap_udc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/omap_udc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/pch_udc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/printer.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/pxa25x_udc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/pxa25x_udc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/pxa27x_udc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/pxa27x_udc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/r8a66597-udc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/r8a66597-udc.h
delete mode 100755 ANDROID_3.4.5/drivers/usb/gadget/rawbulk.c
delete mode 100755 ANDROID_3.4.5/drivers/usb/gadget/rawbulk_transfer.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/rndis.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/rndis.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/s3c-hsotg.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/s3c-hsudc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/s3c2410_udc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/s3c2410_udc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/serial.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/storage_common.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/u_ether.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/u_ether.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/u_phonet.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/u_serial.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/u_serial.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/u_uac1.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/u_uac1.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/udc-core.c
delete mode 100755 ANDROID_3.4.5/drivers/usb/gadget/udc_wmt.c
delete mode 100755 ANDROID_3.4.5/drivers/usb/gadget/udc_wmt.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/usbstring.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/uvc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/uvc_queue.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/uvc_queue.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/uvc_v4l2.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/uvc_video.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/webcam.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/gadget/zero.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/Kconfig
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/alchemy-common.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-atmel.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-au1xxx.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-cns3xxx.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-dbg.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-fsl.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-fsl.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-grlib.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-hcd.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-hub.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-ixp4xx.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-lpm.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-ls1x.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-mem.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-msm.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-mv.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-mxc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-octeon.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-omap.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-orion.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-pci.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-platform.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-pmcmsp.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-ppc-of.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-ps3.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-q.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-s5p.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-sched.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-sh.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-spear.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-sysfs.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-tegra.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-vt8500.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-w90x900.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-xilinx-of.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci-xls.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ehci.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/fhci-dbg.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/fhci-hcd.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/fhci-hub.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/fhci-mem.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/fhci-q.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/fhci-sched.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/fhci-tds.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/fhci.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/fsl-mph-dr-of.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/hwa-hc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/imx21-dbg.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/imx21-hcd.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/imx21-hcd.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/isp116x-hcd.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/isp116x.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/isp1362-hcd.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/isp1362.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/isp1760-hcd.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/isp1760-hcd.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/isp1760-if.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/octeon2-common.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-at91.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-au1xxx.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-cns3xxx.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-da8xx.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-dbg.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-ep93xx.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-exynos.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-hcd.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-hub.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-jz4740.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-mem.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-nxp.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-octeon.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-omap.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-omap3.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-pci.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-platform.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-pnx8550.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-ppc-of.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-ppc-soc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-ps3.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-pxa27x.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-q.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-s3c2410.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-sa1111.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-sh.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-sm501.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-spear.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-ssb.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-tmio.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci-xls.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/ohci.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/oxu210hp-hcd.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/oxu210hp.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/pci-quirks.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/pci-quirks.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/r8a66597-hcd.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/r8a66597.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/sl811-hcd.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/sl811.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/sl811_cs.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/u132-hcd.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/uhci-debug.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/uhci-grlib.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/uhci-hcd.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/uhci-hcd.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/uhci-hub.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/uhci-pci.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/uhci-q.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/whci/Kbuild
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/whci/asl.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/whci/debug.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/whci/hcd.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/whci/hw.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/whci/init.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/whci/int.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/whci/pzl.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/whci/qset.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/whci/whcd.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/whci/whci-hc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/whci/wusb.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/xhci-dbg.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/xhci-ext-caps.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/xhci-hub.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/xhci-mem.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/xhci-pci.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/xhci-plat.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/xhci-ring.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/xhci.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/host/xhci.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/image/Kconfig
delete mode 100644 ANDROID_3.4.5/drivers/usb/image/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/image/mdc800.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/image/microtek.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/image/microtek.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/Kconfig
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/adutux.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/appledisplay.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/cypress_cy7c63.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/cytherm.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/emi26.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/emi62.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/ftdi-elan.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/idmouse.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/iowarrior.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/isight_firmware.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/ldusb.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/legousbtower.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/rio500.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/rio500_usb.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/sisusbvga/Kconfig
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/sisusbvga/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/sisusbvga/sisusb.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/sisusbvga/sisusb.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/sisusbvga/sisusb_con.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/sisusbvga/sisusb_init.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/sisusbvga/sisusb_init.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/sisusbvga/sisusb_struct.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/trancevibrator.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/usb_u132.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/usblcd.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/usbled.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/usbsevseg.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/usbtest.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/uss720.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/misc/yurex.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/mon/Kconfig
delete mode 100644 ANDROID_3.4.5/drivers/usb/mon/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/mon/mon_bin.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/mon/mon_main.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/mon/mon_stat.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/mon/mon_text.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/mon/usb_mon.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/Kconfig
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/am35x.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/blackfin.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/blackfin.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/cppi_dma.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/cppi_dma.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/da8xx.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/davinci.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/davinci.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/musb_core.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/musb_core.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/musb_debug.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/musb_debugfs.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/musb_dma.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/musb_gadget.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/musb_gadget.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/musb_gadget_ep0.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/musb_host.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/musb_host.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/musb_io.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/musb_regs.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/musb_virthub.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/musbhsdma.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/musbhsdma.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/omap2430.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/omap2430.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/tusb6010.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/tusb6010.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/tusb6010_omap.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/ux500.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/musb/ux500_dma.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/Kconfig
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/ab8500-usb.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/fsl_otg.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/fsl_otg.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/gpio_vbus.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/isp1301_omap.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/msm_otg.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/mv_otg.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/mv_otg.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/nop-usb-xceiv.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/otg-wakelock.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/otg.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/otg_fsm.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/otg_fsm.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/twl4030-usb.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/twl6030-usb.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/ulpi.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/otg/ulpi_viewport.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/renesas_usbhs/Kconfig
delete mode 100644 ANDROID_3.4.5/drivers/usb/renesas_usbhs/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/renesas_usbhs/common.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/renesas_usbhs/common.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/renesas_usbhs/fifo.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/renesas_usbhs/fifo.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/renesas_usbhs/mod.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/renesas_usbhs/mod.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/renesas_usbhs/mod_gadget.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/renesas_usbhs/mod_host.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/renesas_usbhs/pipe.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/renesas_usbhs/pipe.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/Kconfig
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/Makefile-keyspan_pda_fw
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/aircable.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/ark3116.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/belkin_sa.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/belkin_sa.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/bus.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/ch341.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/console.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/cp210x.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/cyberjack.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/cypress_m8.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/cypress_m8.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/digi_acceleport.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/empeg.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/ezusb.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/ezusb_convert.pl
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/f81232.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/ftdi_sio.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/ftdi_sio.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/ftdi_sio_ids.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/funsoft.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/garmin_gps.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/generic.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/hp4x.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/io_16654.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/io_edgeport.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/io_edgeport.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/io_ionsp.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/io_tables.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/io_ti.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/io_ti.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/io_usbvend.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/ipaq.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/ipw.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/ir-usb.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/iuu_phoenix.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/iuu_phoenix.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/keyspan.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/keyspan.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/keyspan_pda.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/keyspan_usa26msg.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/keyspan_usa28msg.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/keyspan_usa49msg.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/keyspan_usa67msg.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/keyspan_usa90msg.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/kl5kusb105.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/kl5kusb105.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/kobil_sct.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/kobil_sct.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/mct_u232.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/mct_u232.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/metro-usb.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/mos7720.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/mos7840.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/moto_modem.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/navman.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/omninet.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/opticon.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/option.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/oti6858.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/oti6858.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/pl2303.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/pl2303.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/qcaux.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/qcserial.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/safe_serial.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/siemens_mpi.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/sierra.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/spcp8x5.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/ssu100.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/symbolserial.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/ti_usb_3410_5052.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/ti_usb_3410_5052.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/usb-serial.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/usb-wwan.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/usb_debug.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/usb_wwan.c
delete mode 100755 ANDROID_3.4.5/drivers/usb/serial/via_option.c
delete mode 100755 ANDROID_3.4.5/drivers/usb/serial/via_usb-wwan.h
delete mode 100755 ANDROID_3.4.5/drivers/usb/serial/via_usb_wwan.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/visor.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/visor.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/vivopay-serial.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/whiteheat.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/whiteheat.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/serial/zio.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/Kconfig
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/alauda.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/cypress_atacb.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/datafab.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/debug.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/debug.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/ene_ub6250.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/freecom.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/initializers.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/initializers.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/isd200.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/jumpshot.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/karma.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/libusual.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/onetouch.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/option_ms.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/option_ms.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/protocol.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/protocol.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/realtek_cr.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/scsiglue.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/scsiglue.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/sddr09.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/sddr55.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/shuttle_usbat.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/sierra_ms.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/sierra_ms.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/transport.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/transport.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/uas.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/unusual_alauda.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/unusual_cypress.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/unusual_datafab.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/unusual_devs.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/unusual_ene_ub6250.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/unusual_freecom.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/unusual_isd200.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/unusual_jumpshot.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/unusual_karma.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/unusual_onetouch.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/unusual_realtek.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/unusual_sddr09.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/unusual_sddr55.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/unusual_usbat.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/usb.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/usb.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/storage/usual-tables.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/usb-common.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/usb-skeleton.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/Kconfig
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/Makefile
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/cbaf.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/crypto.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/dev-sysfs.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/devconnect.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/mmc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/pal.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/reservation.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/rh.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/security.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/wa-hc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/wa-hc.h
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/wa-nep.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/wa-rpipe.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/wa-xfer.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/wusbhc.c
delete mode 100644 ANDROID_3.4.5/drivers/usb/wusbcore/wusbhc.h
(limited to 'ANDROID_3.4.5/drivers/usb')
diff --git a/ANDROID_3.4.5/drivers/usb/Kconfig b/ANDROID_3.4.5/drivers/usb/Kconfig
deleted file mode 100644
index 76316a33..00000000
--- a/ANDROID_3.4.5/drivers/usb/Kconfig
+++ /dev/null
@@ -1,186 +0,0 @@
-#
-# USB device configuration
-#
-
-# many non-PCI SOC chips embed OHCI
-config USB_ARCH_HAS_OHCI
- boolean
- # ARM:
- default y if SA1111
- default y if ARCH_OMAP
- default y if ARCH_S3C24XX
- default y if PXA27x
- default y if PXA3xx
- default y if ARCH_EP93XX
- default y if ARCH_AT91
- default y if ARCH_PNX4008 && I2C
- default y if MFD_TC6393XB
- default y if ARCH_W90X900
- default y if ARCH_DAVINCI_DA8XX
- default y if ARCH_CNS3XXX
- default y if PLAT_SPEAR
- default y if ARCH_EXYNOS
- # PPC:
- default y if STB03xxx
- default y if PPC_MPC52xx
- # MIPS:
- default y if MIPS_ALCHEMY
- default y if MACH_JZ4740
- # more:
- default PCI
-
-# some non-PCI hcds implement EHCI
-config USB_ARCH_HAS_EHCI
- boolean
- default y if FSL_SOC
- default y if PPC_MPC512x
- default y if ARCH_IXP4XX
- default y if ARCH_W90X900
- default y if ARCH_AT91
- default y if ARCH_MXC
- default y if ARCH_OMAP3
- default y if ARCH_CNS3XXX
- default y if ARCH_VT8500
- default y if PLAT_SPEAR
- default y if PLAT_S5P
- default y if ARCH_MSM
- default y if MICROBLAZE
- default y if SPARC_LEON
- default y if ARCH_MMP
- default y if MACH_LOONGSON1
- default PCI
-
-# some non-PCI HCDs implement xHCI
-config USB_ARCH_HAS_XHCI
- boolean
- default PCI
-
-menuconfig USB_SUPPORT
- bool "USB support"
- depends on HAS_IOMEM
- default y
- ---help---
- This option adds core support for Universal Serial Bus (USB).
- You will also need drivers from the following menu to make use of it.
-
-if USB_SUPPORT
-
-config USB_COMMON
- tristate
- default y
- depends on USB || USB_GADGET
-
-# Host-side USB depends on having a host controller
-# NOTE: dummy_hcd is always an option, but it's ignored here ...
-# NOTE: SL-811 option should be board-specific ...
-config USB_ARCH_HAS_HCD
- boolean
- default y if USB_ARCH_HAS_OHCI
- default y if USB_ARCH_HAS_EHCI
- default y if USB_ARCH_HAS_XHCI
- default y if PCMCIA && !M32R # sl811_cs
- default y if ARM # SL-811
- default y if BLACKFIN # SL-811
- default y if SUPERH # r8a66597-hcd
- default PCI
-
-# ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface.
-config USB
- tristate "Support for Host-side USB"
- depends on USB_ARCH_HAS_HCD
- select NLS # for UTF-8 strings
- ---help---
- Universal Serial Bus (USB) is a specification for a serial bus
- subsystem which offers higher speeds and more features than the
- traditional PC serial port. The bus supplies power to peripherals
- and allows for hot swapping. Up to 127 USB peripherals can be
- connected to a single USB host in a tree structure.
-
- The USB host is the root of the tree, the peripherals are the
- leaves and the inner nodes are special USB devices called hubs.
- Most PCs now have USB host ports, used to connect peripherals
- such as scanners, keyboards, mice, modems, cameras, disks,
- flash memory, network links, and printers to the PC.
-
- Say Y here if your computer has a host-side USB port and you want
- to use USB devices. You then need to say Y to at least one of the
- Host Controller Driver (HCD) options below. Choose a USB 1.1
- controller, such as "UHCI HCD support" or "OHCI HCD support",
- and "EHCI HCD (USB 2.0) support" except for older systems that
- do not have USB 2.0 support. It doesn't normally hurt to select
- them all if you are not certain.
-
- If your system has a device-side USB port, used in the peripheral
- side of the USB protocol, see the "USB Gadget" framework instead.
-
- After choosing your HCD, then select drivers for the USB peripherals
- you'll be using. You may want to check out the information provided
- in and especially the links given in
- .
-
- To compile this driver as a module, choose M here: the
- module will be called usbcore.
-
-source "drivers/usb/core/Kconfig"
-
-source "drivers/usb/dwc3/Kconfig"
-
-source "drivers/usb/mon/Kconfig"
-
-source "drivers/usb/wusbcore/Kconfig"
-
-source "drivers/usb/host/Kconfig"
-
-source "drivers/usb/musb/Kconfig"
-
-source "drivers/usb/renesas_usbhs/Kconfig"
-
-source "drivers/usb/class/Kconfig"
-
-source "drivers/usb/storage/Kconfig"
-
-source "drivers/usb/image/Kconfig"
-
-comment "USB port drivers"
- depends on USB
-
-config USB_USS720
- tristate "USS720 parport driver"
- depends on USB && PARPORT
- select PARPORT_NOT_PC
- ---help---
- This driver is for USB parallel port adapters that use the Lucent
- Technologies USS-720 chip. These cables are plugged into your USB
- port and provide USB compatibility to peripherals designed with
- parallel port interfaces.
-
- The chip has two modes: automatic mode and manual mode. In automatic
- mode, it looks to the computer like a standard USB printer. Only
- printers may be connected to the USS-720 in this mode. The generic
- USB printer driver ("USB Printer support", above) may be used in
- that mode, and you can say N here if you want to use the chip only
- in this mode.
-
- Manual mode is not limited to printers, any parallel port
- device should work. This driver utilizes manual mode.
- Note however that some operations are three orders of magnitude
- slower than on a PCI/ISA Parallel Port, so timing critical
- applications might not work.
-
- Say Y here if you own an USS-720 USB->Parport cable and intend to
- connect anything other than a printer to it.
-
- To compile this driver as a module, choose M here: the
- module will be called uss720.
-
-source "drivers/usb/serial/Kconfig"
-
-source "drivers/usb/misc/Kconfig"
-
-source "drivers/usb/atm/Kconfig"
-
-source "drivers/usb/gadget/Kconfig"
-
-source "drivers/usb/otg/Kconfig"
-
-endif # USB_SUPPORT
diff --git a/ANDROID_3.4.5/drivers/usb/Makefile b/ANDROID_3.4.5/drivers/usb/Makefile
deleted file mode 100644
index 53a7bc07..00000000
--- a/ANDROID_3.4.5/drivers/usb/Makefile
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# Makefile for the kernel USB device drivers.
-#
-
-# Object files in subdirectories
-
-obj-$(CONFIG_USB) += core/
-
-obj-$(CONFIG_USB_OTG_UTILS) += otg/
-
-obj-$(CONFIG_USB_DWC3) += dwc3/
-
-obj-$(CONFIG_USB_MON) += mon/
-
-obj-$(CONFIG_PCI) += host/
-obj-$(CONFIG_USB_EHCI_HCD) += host/
-obj-$(CONFIG_USB_ISP116X_HCD) += host/
-obj-$(CONFIG_USB_OHCI_HCD) += host/
-obj-$(CONFIG_USB_UHCI_HCD) += host/
-obj-$(CONFIG_USB_FHCI_HCD) += host/
-obj-$(CONFIG_USB_XHCI_HCD) += host/
-obj-$(CONFIG_USB_SL811_HCD) += host/
-obj-$(CONFIG_USB_ISP1362_HCD) += host/
-obj-$(CONFIG_USB_U132_HCD) += host/
-obj-$(CONFIG_USB_R8A66597_HCD) += host/
-obj-$(CONFIG_USB_HWA_HCD) += host/
-obj-$(CONFIG_USB_ISP1760_HCD) += host/
-obj-$(CONFIG_USB_IMX21_HCD) += host/
-obj-$(CONFIG_USB_FSL_MPH_DR_OF) += host/
-
-obj-$(CONFIG_USB_C67X00_HCD) += c67x00/
-
-obj-$(CONFIG_USB_WUSB) += wusbcore/
-
-obj-$(CONFIG_USB_ACM) += class/
-obj-$(CONFIG_USB_PRINTER) += class/
-obj-$(CONFIG_USB_WDM) += class/
-obj-$(CONFIG_USB_TMC) += class/
-
-obj-$(CONFIG_USB_STORAGE) += storage/
-obj-$(CONFIG_USB) += storage/
-
-obj-$(CONFIG_USB_MDC800) += image/
-obj-$(CONFIG_USB_MICROTEK) += image/
-
-obj-$(CONFIG_USB_SERIAL) += serial/
-
-obj-$(CONFIG_USB) += misc/
-obj-$(CONFIG_EARLY_PRINTK_DBGP) += early/
-
-obj-$(CONFIG_USB_ATM) += atm/
-obj-$(CONFIG_USB_SPEEDTOUCH) += atm/
-
-obj-$(CONFIG_USB_MUSB_HDRC) += musb/
-obj-$(CONFIG_USB_RENESAS_USBHS) += renesas_usbhs/
-obj-$(CONFIG_USB_GADGET) += gadget/
-
-obj-$(CONFIG_USB_COMMON) += usb-common.o
diff --git a/ANDROID_3.4.5/drivers/usb/README b/ANDROID_3.4.5/drivers/usb/README
deleted file mode 100644
index 284f46b3..00000000
--- a/ANDROID_3.4.5/drivers/usb/README
+++ /dev/null
@@ -1,54 +0,0 @@
-To understand all the Linux-USB framework, you'll use these resources:
-
- * This source code. This is necessarily an evolving work, and
- includes kerneldoc that should help you get a current overview.
- ("make pdfdocs", and then look at "usb.pdf" for host side and
- "gadget.pdf" for peripheral side.) Also, Documentation/usb has
- more information.
-
- * The USB 2.0 specification (from www.usb.org), with supplements
- such as those for USB OTG and the various device classes.
- The USB specification has a good overview chapter, and USB
- peripherals conform to the widely known "Chapter 9".
-
- * Chip specifications for USB controllers. Examples include
- host controllers (on PCs, servers, and more); peripheral
- controllers (in devices with Linux firmware, like printers or
- cell phones); and hard-wired peripherals like Ethernet adapters.
-
- * Specifications for other protocols implemented by USB peripheral
- functions. Some are vendor-specific; others are vendor-neutral
- but just standardized outside of the www.usb.org team.
-
-Here is a list of what each subdirectory here is, and what is contained in
-them.
-
-core/ - This is for the core USB host code, including the
- usbfs files and the hub class driver ("khubd").
-
-host/ - This is for USB host controller drivers. This
- includes UHCI, OHCI, EHCI, and others that might
- be used with more specialized "embedded" systems.
-
-gadget/ - This is for USB peripheral controller drivers and
- the various gadget drivers which talk to them.
-
-
-Individual USB driver directories. A new driver should be added to the
-first subdirectory in the list below that it fits into.
-
-image/ - This is for still image drivers, like scanners or
- digital cameras.
-../input/ - This is for any driver that uses the input subsystem,
- like keyboard, mice, touchscreens, tablets, etc.
-../media/ - This is for multimedia drivers, like video cameras,
- radios, and any other drivers that talk to the v4l
- subsystem.
-../net/ - This is for network drivers.
-serial/ - This is for USB to serial drivers.
-storage/ - This is for USB mass-storage drivers.
-class/ - This is for all USB device drivers that do not fit
- into any of the above categories, and work for a range
- of USB Class specified devices.
-misc/ - This is for all USB device drivers that do not fit
- into any of the above categories.
diff --git a/ANDROID_3.4.5/drivers/usb/atm/Kconfig b/ANDROID_3.4.5/drivers/usb/atm/Kconfig
deleted file mode 100644
index be0b8daa..00000000
--- a/ANDROID_3.4.5/drivers/usb/atm/Kconfig
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# USB/ATM DSL configuration
-#
-
-menuconfig USB_ATM
- tristate "USB DSL modem support"
- depends on USB && ATM
- select CRC32
- default n
- help
- Say Y here if you want to connect a USB Digital Subscriber Line (DSL)
- modem to your computer's USB port. You will then need to choose your
- modem from the list below.
-
- To compile this driver as a module, choose M here: the
- module will be called usbatm.
-
-if USB_ATM
-
-config USB_SPEEDTOUCH
- tristate "Speedtouch USB support"
- select FW_LOADER
- help
- Say Y here if you have an SpeedTouch USB or SpeedTouch 330
- modem. In order to use your modem you will need to install the
- two parts of the firmware, extracted by the user space tools; see
- for details.
-
- To compile this driver as a module, choose M here: the
- module will be called speedtch.
-
-config USB_CXACRU
- tristate "Conexant AccessRunner USB support"
- select FW_LOADER
- help
- Say Y here if you have an ADSL USB modem based on the Conexant
- AccessRunner chipset. In order to use your modem you will need to
- install the firmware, extracted by the user space tools; see
- for details.
-
- To compile this driver as a module, choose M here: the
- module will be called cxacru.
-
-config USB_UEAGLEATM
- tristate "ADI 930 and eagle USB DSL modem"
- select FW_LOADER
- help
- Say Y here if you have an ADSL USB modem based on the ADI 930
- or eagle chipset. In order to use your modem you will need to
- install firmwares and CMV (Command Management Variables); see
- for details.
-
- To compile this driver as a module, choose M here: the
- module will be called ueagle-atm.
-
-config USB_XUSBATM
- tristate "Other USB DSL modem support"
- help
- Say Y here if you have a DSL USB modem not explicitly supported by
- another USB DSL drivers. In order to use your modem you will need to
- pass the vendor ID, product ID, and endpoint numbers for transmission
- and reception as module parameters. You may need to initialize
- the modem using a user space utility (a firmware loader for example).
-
- To compile this driver as a module, choose M here: the
- module will be called xusbatm.
-
-endif # USB_ATM
diff --git a/ANDROID_3.4.5/drivers/usb/atm/Makefile b/ANDROID_3.4.5/drivers/usb/atm/Makefile
deleted file mode 100644
index a5d792ec..00000000
--- a/ANDROID_3.4.5/drivers/usb/atm/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# Makefile for USB ATM/xDSL drivers
-#
-
-ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
-
-obj-$(CONFIG_USB_CXACRU) += cxacru.o
-obj-$(CONFIG_USB_SPEEDTOUCH) += speedtch.o
-obj-$(CONFIG_USB_UEAGLEATM) += ueagle-atm.o
-obj-$(CONFIG_USB_ATM) += usbatm.o
-obj-$(CONFIG_USB_XUSBATM) += xusbatm.o
diff --git a/ANDROID_3.4.5/drivers/usb/atm/cxacru.c b/ANDROID_3.4.5/drivers/usb/atm/cxacru.c
deleted file mode 100644
index 98b89fe1..00000000
--- a/ANDROID_3.4.5/drivers/usb/atm/cxacru.c
+++ /dev/null
@@ -1,1380 +0,0 @@
-/******************************************************************************
- * cxacru.c - driver for USB ADSL modems based on
- * Conexant AccessRunner chipset
- *
- * Copyright (C) 2004 David Woodhouse, Duncan Sands, Roman Kagan
- * Copyright (C) 2005 Duncan Sands, Roman Kagan (rkagan % mail ! ru)
- * Copyright (C) 2007 Simon Arlott
- * Copyright (C) 2009 Simon Arlott
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- ******************************************************************************/
-
-/*
- * Credit is due for Josep Comas, who created the original patch to speedtch.c
- * to support the different padding used by the AccessRunner (now generalized
- * into usbatm), and the userspace firmware loading utility.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "usbatm.h"
-
-#define DRIVER_AUTHOR "Roman Kagan, David Woodhouse, Duncan Sands, Simon Arlott"
-#define DRIVER_VERSION "0.4"
-#define DRIVER_DESC "Conexant AccessRunner ADSL USB modem driver"
-
-static const char cxacru_driver_name[] = "cxacru";
-
-#define CXACRU_EP_CMD 0x01 /* Bulk/interrupt in/out */
-#define CXACRU_EP_DATA 0x02 /* Bulk in/out */
-
-#define CMD_PACKET_SIZE 64 /* Should be maxpacket(ep)? */
-#define CMD_MAX_CONFIG ((CMD_PACKET_SIZE / 4 - 1) / 2)
-
-/* Addresses */
-#define PLLFCLK_ADDR 0x00350068
-#define PLLBCLK_ADDR 0x0035006c
-#define SDRAMEN_ADDR 0x00350010
-#define FW_ADDR 0x00801000
-#define BR_ADDR 0x00180600
-#define SIG_ADDR 0x00180500
-#define BR_STACK_ADDR 0x00187f10
-
-/* Values */
-#define SDRAM_ENA 0x1
-
-#define CMD_TIMEOUT 2000 /* msecs */
-#define POLL_INTERVAL 1 /* secs */
-
-/* commands for interaction with the modem through the control channel before
- * firmware is loaded */
-enum cxacru_fw_request {
- FW_CMD_ERR,
- FW_GET_VER,
- FW_READ_MEM,
- FW_WRITE_MEM,
- FW_RMW_MEM,
- FW_CHECKSUM_MEM,
- FW_GOTO_MEM,
-};
-
-/* commands for interaction with the modem through the control channel once
- * firmware is loaded */
-enum cxacru_cm_request {
- CM_REQUEST_UNDEFINED = 0x80,
- CM_REQUEST_TEST,
- CM_REQUEST_CHIP_GET_MAC_ADDRESS,
- CM_REQUEST_CHIP_GET_DP_VERSIONS,
- CM_REQUEST_CHIP_ADSL_LINE_START,
- CM_REQUEST_CHIP_ADSL_LINE_STOP,
- CM_REQUEST_CHIP_ADSL_LINE_GET_STATUS,
- CM_REQUEST_CHIP_ADSL_LINE_GET_SPEED,
- CM_REQUEST_CARD_INFO_GET,
- CM_REQUEST_CARD_DATA_GET,
- CM_REQUEST_CARD_DATA_SET,
- CM_REQUEST_COMMAND_HW_IO,
- CM_REQUEST_INTERFACE_HW_IO,
- CM_REQUEST_CARD_SERIAL_DATA_PATH_GET,
- CM_REQUEST_CARD_SERIAL_DATA_PATH_SET,
- CM_REQUEST_CARD_CONTROLLER_VERSION_GET,
- CM_REQUEST_CARD_GET_STATUS,
- CM_REQUEST_CARD_GET_MAC_ADDRESS,
- CM_REQUEST_CARD_GET_DATA_LINK_STATUS,
- CM_REQUEST_MAX,
-};
-
-/* commands for interaction with the flash memory
- *
- * read: response is the contents of the first 60 bytes of flash memory
- * write: request contains the 60 bytes of data to write to flash memory
- * response is the contents of the first 60 bytes of flash memory
- *
- * layout: PP PP VV VV MM MM MM MM MM MM ?? ?? SS SS SS SS SS SS SS SS
- * SS SS SS SS SS SS SS SS 00 00 00 00 00 00 00 00 00 00 00 00
- * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
- *
- * P: le16 USB Product ID
- * V: le16 USB Vendor ID
- * M: be48 MAC Address
- * S: le16 ASCII Serial Number
- */
-enum cxacru_cm_flash {
- CM_FLASH_READ = 0xa1,
- CM_FLASH_WRITE = 0xa2
-};
-
-/* reply codes to the commands above */
-enum cxacru_cm_status {
- CM_STATUS_UNDEFINED,
- CM_STATUS_SUCCESS,
- CM_STATUS_ERROR,
- CM_STATUS_UNSUPPORTED,
- CM_STATUS_UNIMPLEMENTED,
- CM_STATUS_PARAMETER_ERROR,
- CM_STATUS_DBG_LOOPBACK,
- CM_STATUS_MAX,
-};
-
-/* indices into CARD_INFO_GET return array */
-enum cxacru_info_idx {
- CXINF_DOWNSTREAM_RATE,
- CXINF_UPSTREAM_RATE,
- CXINF_LINK_STATUS,
- CXINF_LINE_STATUS,
- CXINF_MAC_ADDRESS_HIGH,
- CXINF_MAC_ADDRESS_LOW,
- CXINF_UPSTREAM_SNR_MARGIN,
- CXINF_DOWNSTREAM_SNR_MARGIN,
- CXINF_UPSTREAM_ATTENUATION,
- CXINF_DOWNSTREAM_ATTENUATION,
- CXINF_TRANSMITTER_POWER,
- CXINF_UPSTREAM_BITS_PER_FRAME,
- CXINF_DOWNSTREAM_BITS_PER_FRAME,
- CXINF_STARTUP_ATTEMPTS,
- CXINF_UPSTREAM_CRC_ERRORS,
- CXINF_DOWNSTREAM_CRC_ERRORS,
- CXINF_UPSTREAM_FEC_ERRORS,
- CXINF_DOWNSTREAM_FEC_ERRORS,
- CXINF_UPSTREAM_HEC_ERRORS,
- CXINF_DOWNSTREAM_HEC_ERRORS,
- CXINF_LINE_STARTABLE,
- CXINF_MODULATION,
- CXINF_ADSL_HEADEND,
- CXINF_ADSL_HEADEND_ENVIRONMENT,
- CXINF_CONTROLLER_VERSION,
- /* dunno what the missing two mean */
- CXINF_MAX = 0x1c,
-};
-
-enum cxacru_poll_state {
- CXPOLL_STOPPING,
- CXPOLL_STOPPED,
- CXPOLL_POLLING,
- CXPOLL_SHUTDOWN
-};
-
-struct cxacru_modem_type {
- u32 pll_f_clk;
- u32 pll_b_clk;
- int boot_rom_patch;
-};
-
-struct cxacru_data {
- struct usbatm_data *usbatm;
-
- const struct cxacru_modem_type *modem_type;
-
- int line_status;
- struct mutex adsl_state_serialize;
- int adsl_status;
- struct delayed_work poll_work;
- u32 card_info[CXINF_MAX];
- struct mutex poll_state_serialize;
- enum cxacru_poll_state poll_state;
-
- /* contol handles */
- struct mutex cm_serialize;
- u8 *rcv_buf;
- u8 *snd_buf;
- struct urb *rcv_urb;
- struct urb *snd_urb;
- struct completion rcv_done;
- struct completion snd_done;
-};
-
-static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
- u8 *wdata, int wsize, u8 *rdata, int rsize);
-static void cxacru_poll_status(struct work_struct *work);
-
-/* Card info exported through sysfs */
-#define CXACRU__ATTR_INIT(_name) \
-static DEVICE_ATTR(_name, S_IRUGO, cxacru_sysfs_show_##_name, NULL)
-
-#define CXACRU_CMD_INIT(_name) \
-static DEVICE_ATTR(_name, S_IWUSR | S_IRUGO, \
- cxacru_sysfs_show_##_name, cxacru_sysfs_store_##_name)
-
-#define CXACRU_SET_INIT(_name) \
-static DEVICE_ATTR(_name, S_IWUSR, \
- NULL, cxacru_sysfs_store_##_name)
-
-#define CXACRU_ATTR_INIT(_value, _type, _name) \
-static ssize_t cxacru_sysfs_show_##_name(struct device *dev, \
- struct device_attribute *attr, char *buf) \
-{ \
- struct cxacru_data *instance = to_usbatm_driver_data(\
- to_usb_interface(dev)); \
-\
- if (instance == NULL) \
- return -ENODEV; \
-\
- return cxacru_sysfs_showattr_##_type(instance->card_info[_value], buf); \
-} \
-CXACRU__ATTR_INIT(_name)
-
-#define CXACRU_ATTR_CREATE(_v, _t, _name) CXACRU_DEVICE_CREATE_FILE(_name)
-#define CXACRU_CMD_CREATE(_name) CXACRU_DEVICE_CREATE_FILE(_name)
-#define CXACRU_SET_CREATE(_name) CXACRU_DEVICE_CREATE_FILE(_name)
-#define CXACRU__ATTR_CREATE(_name) CXACRU_DEVICE_CREATE_FILE(_name)
-
-#define CXACRU_ATTR_REMOVE(_v, _t, _name) CXACRU_DEVICE_REMOVE_FILE(_name)
-#define CXACRU_CMD_REMOVE(_name) CXACRU_DEVICE_REMOVE_FILE(_name)
-#define CXACRU_SET_REMOVE(_name) CXACRU_DEVICE_REMOVE_FILE(_name)
-#define CXACRU__ATTR_REMOVE(_name) CXACRU_DEVICE_REMOVE_FILE(_name)
-
-static ssize_t cxacru_sysfs_showattr_u32(u32 value, char *buf)
-{
- return snprintf(buf, PAGE_SIZE, "%u\n", value);
-}
-
-static ssize_t cxacru_sysfs_showattr_s8(s8 value, char *buf)
-{
- return snprintf(buf, PAGE_SIZE, "%d\n", value);
-}
-
-static ssize_t cxacru_sysfs_showattr_dB(s16 value, char *buf)
-{
- if (likely(value >= 0)) {
- return snprintf(buf, PAGE_SIZE, "%u.%02u\n",
- value / 100, value % 100);
- } else {
- value = -value;
- return snprintf(buf, PAGE_SIZE, "-%u.%02u\n",
- value / 100, value % 100);
- }
-}
-
-static ssize_t cxacru_sysfs_showattr_bool(u32 value, char *buf)
-{
- static char *str[] = { "no", "yes" };
- if (unlikely(value >= ARRAY_SIZE(str)))
- return snprintf(buf, PAGE_SIZE, "%u\n", value);
- return snprintf(buf, PAGE_SIZE, "%s\n", str[value]);
-}
-
-static ssize_t cxacru_sysfs_showattr_LINK(u32 value, char *buf)
-{
- static char *str[] = { NULL, "not connected", "connected", "lost" };
- if (unlikely(value >= ARRAY_SIZE(str) || str[value] == NULL))
- return snprintf(buf, PAGE_SIZE, "%u\n", value);
- return snprintf(buf, PAGE_SIZE, "%s\n", str[value]);
-}
-
-static ssize_t cxacru_sysfs_showattr_LINE(u32 value, char *buf)
-{
- static char *str[] = { "down", "attempting to activate",
- "training", "channel analysis", "exchange", "up",
- "waiting", "initialising"
- };
- if (unlikely(value >= ARRAY_SIZE(str)))
- return snprintf(buf, PAGE_SIZE, "%u\n", value);
- return snprintf(buf, PAGE_SIZE, "%s\n", str[value]);
-}
-
-static ssize_t cxacru_sysfs_showattr_MODU(u32 value, char *buf)
-{
- static char *str[] = {
- "",
- "ANSI T1.413",
- "ITU-T G.992.1 (G.DMT)",
- "ITU-T G.992.2 (G.LITE)"
- };
- if (unlikely(value >= ARRAY_SIZE(str)))
- return snprintf(buf, PAGE_SIZE, "%u\n", value);
- return snprintf(buf, PAGE_SIZE, "%s\n", str[value]);
-}
-
-/*
- * This could use MAC_ADDRESS_HIGH and MAC_ADDRESS_LOW, but since
- * this data is already in atm_dev there's no point.
- *
- * MAC_ADDRESS_HIGH = 0x????5544
- * MAC_ADDRESS_LOW = 0x33221100
- * Where 00-55 are bytes 0-5 of the MAC.
- */
-static ssize_t cxacru_sysfs_show_mac_address(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct cxacru_data *instance = to_usbatm_driver_data(
- to_usb_interface(dev));
-
- if (instance == NULL || instance->usbatm->atm_dev == NULL)
- return -ENODEV;
-
- return snprintf(buf, PAGE_SIZE, "%pM\n",
- instance->usbatm->atm_dev->esi);
-}
-
-static ssize_t cxacru_sysfs_show_adsl_state(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- static char *str[] = { "running", "stopped" };
- struct cxacru_data *instance = to_usbatm_driver_data(
- to_usb_interface(dev));
- u32 value;
-
- if (instance == NULL)
- return -ENODEV;
-
- value = instance->card_info[CXINF_LINE_STARTABLE];
- if (unlikely(value >= ARRAY_SIZE(str)))
- return snprintf(buf, PAGE_SIZE, "%u\n", value);
- return snprintf(buf, PAGE_SIZE, "%s\n", str[value]);
-}
-
-static ssize_t cxacru_sysfs_store_adsl_state(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t count)
-{
- struct cxacru_data *instance = to_usbatm_driver_data(
- to_usb_interface(dev));
- int ret;
- int poll = -1;
- char str_cmd[8];
- int len = strlen(buf);
-
- if (!capable(CAP_NET_ADMIN))
- return -EACCES;
-
- ret = sscanf(buf, "%7s", str_cmd);
- if (ret != 1)
- return -EINVAL;
- ret = 0;
-
- if (instance == NULL)
- return -ENODEV;
-
- if (mutex_lock_interruptible(&instance->adsl_state_serialize))
- return -ERESTARTSYS;
-
- if (!strcmp(str_cmd, "stop") || !strcmp(str_cmd, "restart")) {
- ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_STOP, NULL, 0, NULL, 0);
- if (ret < 0) {
- atm_err(instance->usbatm, "change adsl state:"
- " CHIP_ADSL_LINE_STOP returned %d\n", ret);
-
- ret = -EIO;
- } else {
- ret = len;
- poll = CXPOLL_STOPPED;
- }
- }
-
- /* Line status is only updated every second
- * and the device appears to only react to
- * START/STOP every second too. Wait 1.5s to
- * be sure that restart will have an effect. */
- if (!strcmp(str_cmd, "restart"))
- msleep(1500);
-
- if (!strcmp(str_cmd, "start") || !strcmp(str_cmd, "restart")) {
- ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0);
- if (ret < 0) {
- atm_err(instance->usbatm, "change adsl state:"
- " CHIP_ADSL_LINE_START returned %d\n", ret);
-
- ret = -EIO;
- } else {
- ret = len;
- poll = CXPOLL_POLLING;
- }
- }
-
- if (!strcmp(str_cmd, "poll")) {
- ret = len;
- poll = CXPOLL_POLLING;
- }
-
- if (ret == 0) {
- ret = -EINVAL;
- poll = -1;
- }
-
- if (poll == CXPOLL_POLLING) {
- mutex_lock(&instance->poll_state_serialize);
- switch (instance->poll_state) {
- case CXPOLL_STOPPED:
- /* start polling */
- instance->poll_state = CXPOLL_POLLING;
- break;
-
- case CXPOLL_STOPPING:
- /* abort stop request */
- instance->poll_state = CXPOLL_POLLING;
- case CXPOLL_POLLING:
- case CXPOLL_SHUTDOWN:
- /* don't start polling */
- poll = -1;
- }
- mutex_unlock(&instance->poll_state_serialize);
- } else if (poll == CXPOLL_STOPPED) {
- mutex_lock(&instance->poll_state_serialize);
- /* request stop */
- if (instance->poll_state == CXPOLL_POLLING)
- instance->poll_state = CXPOLL_STOPPING;
- mutex_unlock(&instance->poll_state_serialize);
- }
-
- mutex_unlock(&instance->adsl_state_serialize);
-
- if (poll == CXPOLL_POLLING)
- cxacru_poll_status(&instance->poll_work.work);
-
- return ret;
-}
-
-/* CM_REQUEST_CARD_DATA_GET times out, so no show attribute */
-
-static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t count)
-{
- struct cxacru_data *instance = to_usbatm_driver_data(
- to_usb_interface(dev));
- int len = strlen(buf);
- int ret, pos, num;
- __le32 data[CMD_PACKET_SIZE / 4];
-
- if (!capable(CAP_NET_ADMIN))
- return -EACCES;
-
- if (instance == NULL)
- return -ENODEV;
-
- pos = 0;
- num = 0;
- while (pos < len) {
- int tmp;
- u32 index;
- u32 value;
-
- ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
- if (ret < 2)
- return -EINVAL;
- if (index < 0 || index > 0x7f)
- return -EINVAL;
- pos += tmp;
-
- /* skip trailing newline */
- if (buf[pos] == '\n' && pos == len-1)
- pos++;
-
- data[num * 2 + 1] = cpu_to_le32(index);
- data[num * 2 + 2] = cpu_to_le32(value);
- num++;
-
- /* send config values when data buffer is full
- * or no more data
- */
- if (pos >= len || num >= CMD_MAX_CONFIG) {
- char log[CMD_MAX_CONFIG * 12 + 1]; /* %02x=%08x */
-
- data[0] = cpu_to_le32(num);
- ret = cxacru_cm(instance, CM_REQUEST_CARD_DATA_SET,
- (u8 *) data, 4 + num * 8, NULL, 0);
- if (ret < 0) {
- atm_err(instance->usbatm,
- "set card data returned %d\n", ret);
- return -EIO;
- }
-
- for (tmp = 0; tmp < num; tmp++)
- snprintf(log + tmp*12, 13, " %02x=%08x",
- le32_to_cpu(data[tmp * 2 + 1]),
- le32_to_cpu(data[tmp * 2 + 2]));
- atm_info(instance->usbatm, "config%s\n", log);
- num = 0;
- }
- }
-
- return len;
-}
-
-/*
- * All device attributes are included in CXACRU_ALL_FILES
- * so that the same list can be used multiple times:
- * INIT (define the device attributes)
- * CREATE (create all the device files)
- * REMOVE (remove all the device files)
- *
- * With the last two being defined as needed in the functions
- * they are used in before calling CXACRU_ALL_FILES()
- */
-#define CXACRU_ALL_FILES(_action) \
-CXACRU_ATTR_##_action(CXINF_DOWNSTREAM_RATE, u32, downstream_rate); \
-CXACRU_ATTR_##_action(CXINF_UPSTREAM_RATE, u32, upstream_rate); \
-CXACRU_ATTR_##_action(CXINF_LINK_STATUS, LINK, link_status); \
-CXACRU_ATTR_##_action(CXINF_LINE_STATUS, LINE, line_status); \
-CXACRU__ATTR_##_action( mac_address); \
-CXACRU_ATTR_##_action(CXINF_UPSTREAM_SNR_MARGIN, dB, upstream_snr_margin); \
-CXACRU_ATTR_##_action(CXINF_DOWNSTREAM_SNR_MARGIN, dB, downstream_snr_margin); \
-CXACRU_ATTR_##_action(CXINF_UPSTREAM_ATTENUATION, dB, upstream_attenuation); \
-CXACRU_ATTR_##_action(CXINF_DOWNSTREAM_ATTENUATION, dB, downstream_attenuation); \
-CXACRU_ATTR_##_action(CXINF_TRANSMITTER_POWER, s8, transmitter_power); \
-CXACRU_ATTR_##_action(CXINF_UPSTREAM_BITS_PER_FRAME, u32, upstream_bits_per_frame); \
-CXACRU_ATTR_##_action(CXINF_DOWNSTREAM_BITS_PER_FRAME, u32, downstream_bits_per_frame); \
-CXACRU_ATTR_##_action(CXINF_STARTUP_ATTEMPTS, u32, startup_attempts); \
-CXACRU_ATTR_##_action(CXINF_UPSTREAM_CRC_ERRORS, u32, upstream_crc_errors); \
-CXACRU_ATTR_##_action(CXINF_DOWNSTREAM_CRC_ERRORS, u32, downstream_crc_errors); \
-CXACRU_ATTR_##_action(CXINF_UPSTREAM_FEC_ERRORS, u32, upstream_fec_errors); \
-CXACRU_ATTR_##_action(CXINF_DOWNSTREAM_FEC_ERRORS, u32, downstream_fec_errors); \
-CXACRU_ATTR_##_action(CXINF_UPSTREAM_HEC_ERRORS, u32, upstream_hec_errors); \
-CXACRU_ATTR_##_action(CXINF_DOWNSTREAM_HEC_ERRORS, u32, downstream_hec_errors); \
-CXACRU_ATTR_##_action(CXINF_LINE_STARTABLE, bool, line_startable); \
-CXACRU_ATTR_##_action(CXINF_MODULATION, MODU, modulation); \
-CXACRU_ATTR_##_action(CXINF_ADSL_HEADEND, u32, adsl_headend); \
-CXACRU_ATTR_##_action(CXINF_ADSL_HEADEND_ENVIRONMENT, u32, adsl_headend_environment); \
-CXACRU_ATTR_##_action(CXINF_CONTROLLER_VERSION, u32, adsl_controller_version); \
-CXACRU_CMD_##_action( adsl_state); \
-CXACRU_SET_##_action( adsl_config);
-
-CXACRU_ALL_FILES(INIT);
-
-/* the following three functions are stolen from drivers/usb/core/message.c */
-static void cxacru_blocking_completion(struct urb *urb)
-{
- complete(urb->context);
-}
-
-static void cxacru_timeout_kill(unsigned long data)
-{
- usb_unlink_urb((struct urb *) data);
-}
-
-static int cxacru_start_wait_urb(struct urb *urb, struct completion *done,
- int *actual_length)
-{
- struct timer_list timer;
-
- init_timer(&timer);
- timer.expires = jiffies + msecs_to_jiffies(CMD_TIMEOUT);
- timer.data = (unsigned long) urb;
- timer.function = cxacru_timeout_kill;
- add_timer(&timer);
- wait_for_completion(done);
- del_timer_sync(&timer);
-
- if (actual_length)
- *actual_length = urb->actual_length;
- return urb->status; /* must read status after completion */
-}
-
-static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
- u8 *wdata, int wsize, u8 *rdata, int rsize)
-{
- int ret, actlen;
- int offb, offd;
- const int stride = CMD_PACKET_SIZE - 4;
- u8 *wbuf = instance->snd_buf;
- u8 *rbuf = instance->rcv_buf;
- int wbuflen = ((wsize - 1) / stride + 1) * CMD_PACKET_SIZE;
- int rbuflen = ((rsize - 1) / stride + 1) * CMD_PACKET_SIZE;
-
- if (wbuflen > PAGE_SIZE || rbuflen > PAGE_SIZE) {
- if (printk_ratelimit())
- usb_err(instance->usbatm, "requested transfer size too large (%d, %d)\n",
- wbuflen, rbuflen);
- ret = -ENOMEM;
- goto err;
- }
-
- mutex_lock(&instance->cm_serialize);
-
- /* submit reading urb before the writing one */
- init_completion(&instance->rcv_done);
- ret = usb_submit_urb(instance->rcv_urb, GFP_KERNEL);
- if (ret < 0) {
- if (printk_ratelimit())
- usb_err(instance->usbatm, "submit of read urb for cm %#x failed (%d)\n",
- cm, ret);
- goto fail;
- }
-
- memset(wbuf, 0, wbuflen);
- /* handle wsize == 0 */
- wbuf[0] = cm;
- for (offb = offd = 0; offd < wsize; offd += stride, offb += CMD_PACKET_SIZE) {
- wbuf[offb] = cm;
- memcpy(wbuf + offb + 4, wdata + offd, min_t(int, stride, wsize - offd));
- }
-
- instance->snd_urb->transfer_buffer_length = wbuflen;
- init_completion(&instance->snd_done);
- ret = usb_submit_urb(instance->snd_urb, GFP_KERNEL);
- if (ret < 0) {
- if (printk_ratelimit())
- usb_err(instance->usbatm, "submit of write urb for cm %#x failed (%d)\n",
- cm, ret);
- goto fail;
- }
-
- ret = cxacru_start_wait_urb(instance->snd_urb, &instance->snd_done, NULL);
- if (ret < 0) {
- if (printk_ratelimit())
- usb_err(instance->usbatm, "send of cm %#x failed (%d)\n", cm, ret);
- goto fail;
- }
-
- ret = cxacru_start_wait_urb(instance->rcv_urb, &instance->rcv_done, &actlen);
- if (ret < 0) {
- if (printk_ratelimit())
- usb_err(instance->usbatm, "receive of cm %#x failed (%d)\n", cm, ret);
- goto fail;
- }
- if (actlen % CMD_PACKET_SIZE || !actlen) {
- if (printk_ratelimit())
- usb_err(instance->usbatm, "invalid response length to cm %#x: %d\n",
- cm, actlen);
- ret = -EIO;
- goto fail;
- }
-
- /* check the return status and copy the data to the output buffer, if needed */
- for (offb = offd = 0; offd < rsize && offb < actlen; offb += CMD_PACKET_SIZE) {
- if (rbuf[offb] != cm) {
- if (printk_ratelimit())
- usb_err(instance->usbatm, "wrong cm %#x in response to cm %#x\n",
- rbuf[offb], cm);
- ret = -EIO;
- goto fail;
- }
- if (rbuf[offb + 1] != CM_STATUS_SUCCESS) {
- if (printk_ratelimit())
- usb_err(instance->usbatm, "response to cm %#x failed: %#x\n",
- cm, rbuf[offb + 1]);
- ret = -EIO;
- goto fail;
- }
- if (offd >= rsize)
- break;
- memcpy(rdata + offd, rbuf + offb + 4, min_t(int, stride, rsize - offd));
- offd += stride;
- }
-
- ret = offd;
- dbg("cm %#x", cm);
-fail:
- mutex_unlock(&instance->cm_serialize);
-err:
- return ret;
-}
-
-static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_request cm,
- u32 *data, int size)
-{
- int ret, len;
- __le32 *buf;
- int offb, offd;
- const int stride = CMD_PACKET_SIZE / (4 * 2) - 1;
- int buflen = ((size - 1) / stride + 1 + size * 2) * 4;
-
- buf = kmalloc(buflen, GFP_KERNEL);
- if (!buf)
- return -ENOMEM;
-
- ret = cxacru_cm(instance, cm, NULL, 0, (u8 *) buf, buflen);
- if (ret < 0)
- goto cleanup;
-
- /* len > 0 && len % 4 == 0 guaranteed by cxacru_cm() */
- len = ret / 4;
- for (offb = 0; offb < len; ) {
- int l = le32_to_cpu(buf[offb++]);
- if (l < 0 || l > stride || l > (len - offb) / 2) {
- if (printk_ratelimit())
- usb_err(instance->usbatm, "invalid data length from cm %#x: %d\n",
- cm, l);
- ret = -EIO;
- goto cleanup;
- }
- while (l--) {
- offd = le32_to_cpu(buf[offb++]);
- if (offd >= size) {
- if (printk_ratelimit())
- usb_err(instance->usbatm, "wrong index %#x in response to cm %#x\n",
- offd, cm);
- ret = -EIO;
- goto cleanup;
- }
- data[offd] = le32_to_cpu(buf[offb++]);
- }
- }
-
- ret = 0;
-
-cleanup:
- kfree(buf);
- return ret;
-}
-
-static int cxacru_card_status(struct cxacru_data *instance)
-{
- int ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_STATUS, NULL, 0, NULL, 0);
- if (ret < 0) { /* firmware not loaded */
- dbg("cxacru_adsl_start: CARD_GET_STATUS returned %d", ret);
- return ret;
- }
- return 0;
-}
-
-static void cxacru_remove_device_files(struct usbatm_data *usbatm_instance,
- struct atm_dev *atm_dev)
-{
- struct usb_interface *intf = usbatm_instance->usb_intf;
-
- #define CXACRU_DEVICE_REMOVE_FILE(_name) \
- device_remove_file(&intf->dev, &dev_attr_##_name);
- CXACRU_ALL_FILES(REMOVE);
- #undef CXACRU_DEVICE_REMOVE_FILE
-}
-
-static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
- struct atm_dev *atm_dev)
-{
- struct cxacru_data *instance = usbatm_instance->driver_data;
- struct usb_interface *intf = usbatm_instance->usb_intf;
- int ret;
- int start_polling = 1;
-
- dbg("cxacru_atm_start");
-
- /* Read MAC address */
- ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_MAC_ADDRESS, NULL, 0,
- atm_dev->esi, sizeof(atm_dev->esi));
- if (ret < 0) {
- atm_err(usbatm_instance, "cxacru_atm_start: CARD_GET_MAC_ADDRESS returned %d\n", ret);
- return ret;
- }
-
- #define CXACRU_DEVICE_CREATE_FILE(_name) \
- ret = device_create_file(&intf->dev, &dev_attr_##_name); \
- if (unlikely(ret)) \
- goto fail_sysfs;
- CXACRU_ALL_FILES(CREATE);
- #undef CXACRU_DEVICE_CREATE_FILE
-
- /* start ADSL */
- mutex_lock(&instance->adsl_state_serialize);
- ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0);
- if (ret < 0)
- atm_err(usbatm_instance, "cxacru_atm_start: CHIP_ADSL_LINE_START returned %d\n", ret);
-
- /* Start status polling */
- mutex_lock(&instance->poll_state_serialize);
- switch (instance->poll_state) {
- case CXPOLL_STOPPED:
- /* start polling */
- instance->poll_state = CXPOLL_POLLING;
- break;
-
- case CXPOLL_STOPPING:
- /* abort stop request */
- instance->poll_state = CXPOLL_POLLING;
- case CXPOLL_POLLING:
- case CXPOLL_SHUTDOWN:
- /* don't start polling */
- start_polling = 0;
- }
- mutex_unlock(&instance->poll_state_serialize);
- mutex_unlock(&instance->adsl_state_serialize);
-
- printk(KERN_INFO "%s%d: %s %pM\n", atm_dev->type, atm_dev->number,
- usbatm_instance->description, atm_dev->esi);
-
- if (start_polling)
- cxacru_poll_status(&instance->poll_work.work);
- return 0;
-
-fail_sysfs:
- usb_err(usbatm_instance, "cxacru_atm_start: device_create_file failed (%d)\n", ret);
- cxacru_remove_device_files(usbatm_instance, atm_dev);
- return ret;
-}
-
-static void cxacru_poll_status(struct work_struct *work)
-{
- struct cxacru_data *instance =
- container_of(work, struct cxacru_data, poll_work.work);
- u32 buf[CXINF_MAX] = {};
- struct usbatm_data *usbatm = instance->usbatm;
- struct atm_dev *atm_dev = usbatm->atm_dev;
- int keep_polling = 1;
- int ret;
-
- ret = cxacru_cm_get_array(instance, CM_REQUEST_CARD_INFO_GET, buf, CXINF_MAX);
- if (ret < 0) {
- if (ret != -ESHUTDOWN)
- atm_warn(usbatm, "poll status: error %d\n", ret);
-
- mutex_lock(&instance->poll_state_serialize);
- if (instance->poll_state != CXPOLL_SHUTDOWN) {
- instance->poll_state = CXPOLL_STOPPED;
-
- if (ret != -ESHUTDOWN)
- atm_warn(usbatm, "polling disabled, set adsl_state"
- " to 'start' or 'poll' to resume\n");
- }
- mutex_unlock(&instance->poll_state_serialize);
- goto reschedule;
- }
-
- memcpy(instance->card_info, buf, sizeof(instance->card_info));
-
- if (instance->adsl_status != buf[CXINF_LINE_STARTABLE]) {
- instance->adsl_status = buf[CXINF_LINE_STARTABLE];
-
- switch (instance->adsl_status) {
- case 0:
- atm_printk(KERN_INFO, usbatm, "ADSL state: running\n");
- break;
-
- case 1:
- atm_printk(KERN_INFO, usbatm, "ADSL state: stopped\n");
- break;
-
- default:
- atm_printk(KERN_INFO, usbatm, "Unknown adsl status %02x\n", instance->adsl_status);
- break;
- }
- }
-
- if (instance->line_status == buf[CXINF_LINE_STATUS])
- goto reschedule;
-
- instance->line_status = buf[CXINF_LINE_STATUS];
- switch (instance->line_status) {
- case 0:
- atm_dev_signal_change(atm_dev, ATM_PHY_SIG_LOST);
- atm_info(usbatm, "ADSL line: down\n");
- break;
-
- case 1:
- atm_dev_signal_change(atm_dev, ATM_PHY_SIG_LOST);
- atm_info(usbatm, "ADSL line: attempting to activate\n");
- break;
-
- case 2:
- atm_dev_signal_change(atm_dev, ATM_PHY_SIG_LOST);
- atm_info(usbatm, "ADSL line: training\n");
- break;
-
- case 3:
- atm_dev_signal_change(atm_dev, ATM_PHY_SIG_LOST);
- atm_info(usbatm, "ADSL line: channel analysis\n");
- break;
-
- case 4:
- atm_dev_signal_change(atm_dev, ATM_PHY_SIG_LOST);
- atm_info(usbatm, "ADSL line: exchange\n");
- break;
-
- case 5:
- atm_dev->link_rate = buf[CXINF_DOWNSTREAM_RATE] * 1000 / 424;
- atm_dev_signal_change(atm_dev, ATM_PHY_SIG_FOUND);
-
- atm_info(usbatm, "ADSL line: up (%d kb/s down | %d kb/s up)\n",
- buf[CXINF_DOWNSTREAM_RATE], buf[CXINF_UPSTREAM_RATE]);
- break;
-
- case 6:
- atm_dev_signal_change(atm_dev, ATM_PHY_SIG_LOST);
- atm_info(usbatm, "ADSL line: waiting\n");
- break;
-
- case 7:
- atm_dev_signal_change(atm_dev, ATM_PHY_SIG_LOST);
- atm_info(usbatm, "ADSL line: initializing\n");
- break;
-
- default:
- atm_dev_signal_change(atm_dev, ATM_PHY_SIG_UNKNOWN);
- atm_info(usbatm, "Unknown line state %02x\n", instance->line_status);
- break;
- }
-reschedule:
-
- mutex_lock(&instance->poll_state_serialize);
- if (instance->poll_state == CXPOLL_STOPPING &&
- instance->adsl_status == 1 && /* stopped */
- instance->line_status == 0) /* down */
- instance->poll_state = CXPOLL_STOPPED;
-
- if (instance->poll_state == CXPOLL_STOPPED)
- keep_polling = 0;
- mutex_unlock(&instance->poll_state_serialize);
-
- if (keep_polling)
- schedule_delayed_work(&instance->poll_work,
- round_jiffies_relative(POLL_INTERVAL*HZ));
-}
-
-static int cxacru_fw(struct usb_device *usb_dev, enum cxacru_fw_request fw,
- u8 code1, u8 code2, u32 addr, const u8 *data, int size)
-{
- int ret;
- u8 *buf;
- int offd, offb;
- const int stride = CMD_PACKET_SIZE - 8;
-
- buf = (u8 *) __get_free_page(GFP_KERNEL);
- if (!buf)
- return -ENOMEM;
-
- offb = offd = 0;
- do {
- int l = min_t(int, stride, size - offd);
- buf[offb++] = fw;
- buf[offb++] = l;
- buf[offb++] = code1;
- buf[offb++] = code2;
- put_unaligned(cpu_to_le32(addr), (__le32 *)(buf + offb));
- offb += 4;
- addr += l;
- if (l)
- memcpy(buf + offb, data + offd, l);
- if (l < stride)
- memset(buf + offb + l, 0, stride - l);
- offb += stride;
- offd += stride;
- if ((offb >= PAGE_SIZE) || (offd >= size)) {
- ret = usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, CXACRU_EP_CMD),
- buf, offb, NULL, CMD_TIMEOUT);
- if (ret < 0) {
- dbg("sending fw %#x failed", fw);
- goto cleanup;
- }
- offb = 0;
- }
- } while (offd < size);
- dbg("sent fw %#x", fw);
-
- ret = 0;
-
-cleanup:
- free_page((unsigned long) buf);
- return ret;
-}
-
-static void cxacru_upload_firmware(struct cxacru_data *instance,
- const struct firmware *fw,
- const struct firmware *bp)
-{
- int ret;
- struct usbatm_data *usbatm = instance->usbatm;
- struct usb_device *usb_dev = usbatm->usb_dev;
- __le16 signature[] = { usb_dev->descriptor.idVendor,
- usb_dev->descriptor.idProduct };
- __le32 val;
-
- dbg("cxacru_upload_firmware");
-
- /* FirmwarePllFClkValue */
- val = cpu_to_le32(instance->modem_type->pll_f_clk);
- ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLFCLK_ADDR, (u8 *) &val, 4);
- if (ret) {
- usb_err(usbatm, "FirmwarePllFClkValue failed: %d\n", ret);
- return;
- }
-
- /* FirmwarePllBClkValue */
- val = cpu_to_le32(instance->modem_type->pll_b_clk);
- ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLBCLK_ADDR, (u8 *) &val, 4);
- if (ret) {
- usb_err(usbatm, "FirmwarePllBClkValue failed: %d\n", ret);
- return;
- }
-
- /* Enable SDRAM */
- val = cpu_to_le32(SDRAM_ENA);
- ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SDRAMEN_ADDR, (u8 *) &val, 4);
- if (ret) {
- usb_err(usbatm, "Enable SDRAM failed: %d\n", ret);
- return;
- }
-
- /* Firmware */
- usb_info(usbatm, "loading firmware\n");
- ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, FW_ADDR, fw->data, fw->size);
- if (ret) {
- usb_err(usbatm, "Firmware upload failed: %d\n", ret);
- return;
- }
-
- /* Boot ROM patch */
- if (instance->modem_type->boot_rom_patch) {
- usb_info(usbatm, "loading boot ROM patch\n");
- ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_ADDR, bp->data, bp->size);
- if (ret) {
- usb_err(usbatm, "Boot ROM patching failed: %d\n", ret);
- return;
- }
- }
-
- /* Signature */
- ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SIG_ADDR, (u8 *) signature, 4);
- if (ret) {
- usb_err(usbatm, "Signature storing failed: %d\n", ret);
- return;
- }
-
- usb_info(usbatm, "starting device\n");
- if (instance->modem_type->boot_rom_patch) {
- val = cpu_to_le32(BR_ADDR);
- ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_STACK_ADDR, (u8 *) &val, 4);
- } else {
- ret = cxacru_fw(usb_dev, FW_GOTO_MEM, 0x0, 0x0, FW_ADDR, NULL, 0);
- }
- if (ret) {
- usb_err(usbatm, "Passing control to firmware failed: %d\n", ret);
- return;
- }
-
- /* Delay to allow firmware to start up. */
- msleep_interruptible(1000);
-
- usb_clear_halt(usb_dev, usb_sndbulkpipe(usb_dev, CXACRU_EP_CMD));
- usb_clear_halt(usb_dev, usb_rcvbulkpipe(usb_dev, CXACRU_EP_CMD));
- usb_clear_halt(usb_dev, usb_sndbulkpipe(usb_dev, CXACRU_EP_DATA));
- usb_clear_halt(usb_dev, usb_rcvbulkpipe(usb_dev, CXACRU_EP_DATA));
-
- ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_STATUS, NULL, 0, NULL, 0);
- if (ret < 0) {
- usb_err(usbatm, "modem failed to initialize: %d\n", ret);
- return;
- }
-}
-
-static int cxacru_find_firmware(struct cxacru_data *instance,
- char *phase, const struct firmware **fw_p)
-{
- struct usbatm_data *usbatm = instance->usbatm;
- struct device *dev = &usbatm->usb_intf->dev;
- char buf[16];
-
- sprintf(buf, "cxacru-%s.bin", phase);
- dbg("cxacru_find_firmware: looking for %s", buf);
-
- if (request_firmware(fw_p, buf, dev)) {
- usb_dbg(usbatm, "no stage %s firmware found\n", phase);
- return -ENOENT;
- }
-
- usb_info(usbatm, "found firmware %s\n", buf);
-
- return 0;
-}
-
-static int cxacru_heavy_init(struct usbatm_data *usbatm_instance,
- struct usb_interface *usb_intf)
-{
- const struct firmware *fw, *bp;
- struct cxacru_data *instance = usbatm_instance->driver_data;
-
- int ret = cxacru_find_firmware(instance, "fw", &fw);
- if (ret) {
- usb_warn(usbatm_instance, "firmware (cxacru-fw.bin) unavailable (system misconfigured?)\n");
- return ret;
- }
-
- if (instance->modem_type->boot_rom_patch) {
- ret = cxacru_find_firmware(instance, "bp", &bp);
- if (ret) {
- usb_warn(usbatm_instance, "boot ROM patch (cxacru-bp.bin) unavailable (system misconfigured?)\n");
- release_firmware(fw);
- return ret;
- }
- }
-
- cxacru_upload_firmware(instance, fw, bp);
-
- if (instance->modem_type->boot_rom_patch)
- release_firmware(bp);
- release_firmware(fw);
-
- ret = cxacru_card_status(instance);
- if (ret)
- dbg("modem initialisation failed");
- else
- dbg("done setting up the modem");
-
- return ret;
-}
-
-static int cxacru_bind(struct usbatm_data *usbatm_instance,
- struct usb_interface *intf, const struct usb_device_id *id)
-{
- struct cxacru_data *instance;
- struct usb_device *usb_dev = interface_to_usbdev(intf);
- struct usb_host_endpoint *cmd_ep = usb_dev->ep_in[CXACRU_EP_CMD];
- int ret;
-
- /* instance init */
- instance = kzalloc(sizeof(*instance), GFP_KERNEL);
- if (!instance) {
- dbg("cxacru_bind: no memory for instance data");
- return -ENOMEM;
- }
-
- instance->usbatm = usbatm_instance;
- instance->modem_type = (struct cxacru_modem_type *) id->driver_info;
-
- mutex_init(&instance->poll_state_serialize);
- instance->poll_state = CXPOLL_STOPPED;
- instance->line_status = -1;
- instance->adsl_status = -1;
-
- mutex_init(&instance->adsl_state_serialize);
-
- instance->rcv_buf = (u8 *) __get_free_page(GFP_KERNEL);
- if (!instance->rcv_buf) {
- dbg("cxacru_bind: no memory for rcv_buf");
- ret = -ENOMEM;
- goto fail;
- }
- instance->snd_buf = (u8 *) __get_free_page(GFP_KERNEL);
- if (!instance->snd_buf) {
- dbg("cxacru_bind: no memory for snd_buf");
- ret = -ENOMEM;
- goto fail;
- }
- instance->rcv_urb = usb_alloc_urb(0, GFP_KERNEL);
- if (!instance->rcv_urb) {
- dbg("cxacru_bind: no memory for rcv_urb");
- ret = -ENOMEM;
- goto fail;
- }
- instance->snd_urb = usb_alloc_urb(0, GFP_KERNEL);
- if (!instance->snd_urb) {
- dbg("cxacru_bind: no memory for snd_urb");
- ret = -ENOMEM;
- goto fail;
- }
-
- if (!cmd_ep) {
- dbg("cxacru_bind: no command endpoint");
- ret = -ENODEV;
- goto fail;
- }
-
- if ((cmd_ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
- == USB_ENDPOINT_XFER_INT) {
- usb_fill_int_urb(instance->rcv_urb,
- usb_dev, usb_rcvintpipe(usb_dev, CXACRU_EP_CMD),
- instance->rcv_buf, PAGE_SIZE,
- cxacru_blocking_completion, &instance->rcv_done, 1);
-
- usb_fill_int_urb(instance->snd_urb,
- usb_dev, usb_sndintpipe(usb_dev, CXACRU_EP_CMD),
- instance->snd_buf, PAGE_SIZE,
- cxacru_blocking_completion, &instance->snd_done, 4);
- } else {
- usb_fill_bulk_urb(instance->rcv_urb,
- usb_dev, usb_rcvbulkpipe(usb_dev, CXACRU_EP_CMD),
- instance->rcv_buf, PAGE_SIZE,
- cxacru_blocking_completion, &instance->rcv_done);
-
- usb_fill_bulk_urb(instance->snd_urb,
- usb_dev, usb_sndbulkpipe(usb_dev, CXACRU_EP_CMD),
- instance->snd_buf, PAGE_SIZE,
- cxacru_blocking_completion, &instance->snd_done);
- }
-
- mutex_init(&instance->cm_serialize);
-
- INIT_DELAYED_WORK(&instance->poll_work, cxacru_poll_status);
-
- usbatm_instance->driver_data = instance;
-
- usbatm_instance->flags = (cxacru_card_status(instance) ? 0 : UDSL_SKIP_HEAVY_INIT);
-
- return 0;
-
- fail:
- free_page((unsigned long) instance->snd_buf);
- free_page((unsigned long) instance->rcv_buf);
- usb_free_urb(instance->snd_urb);
- usb_free_urb(instance->rcv_urb);
- kfree(instance);
-
- return ret;
-}
-
-static void cxacru_unbind(struct usbatm_data *usbatm_instance,
- struct usb_interface *intf)
-{
- struct cxacru_data *instance = usbatm_instance->driver_data;
- int is_polling = 1;
-
- dbg("cxacru_unbind entered");
-
- if (!instance) {
- dbg("cxacru_unbind: NULL instance!");
- return;
- }
-
- mutex_lock(&instance->poll_state_serialize);
- BUG_ON(instance->poll_state == CXPOLL_SHUTDOWN);
-
- /* ensure that status polling continues unless
- * it has already stopped */
- if (instance->poll_state == CXPOLL_STOPPED)
- is_polling = 0;
-
- /* stop polling from being stopped or started */
- instance->poll_state = CXPOLL_SHUTDOWN;
- mutex_unlock(&instance->poll_state_serialize);
-
- if (is_polling)
- cancel_delayed_work_sync(&instance->poll_work);
-
- usb_kill_urb(instance->snd_urb);
- usb_kill_urb(instance->rcv_urb);
- usb_free_urb(instance->snd_urb);
- usb_free_urb(instance->rcv_urb);
-
- free_page((unsigned long) instance->snd_buf);
- free_page((unsigned long) instance->rcv_buf);
-
- kfree(instance);
-
- usbatm_instance->driver_data = NULL;
-}
-
-static const struct cxacru_modem_type cxacru_cafe = {
- .pll_f_clk = 0x02d874df,
- .pll_b_clk = 0x0196a51a,
- .boot_rom_patch = 1,
-};
-
-static const struct cxacru_modem_type cxacru_cb00 = {
- .pll_f_clk = 0x5,
- .pll_b_clk = 0x3,
- .boot_rom_patch = 0,
-};
-
-static const struct usb_device_id cxacru_usb_ids[] = {
- { /* V = Conexant P = ADSL modem (Euphrates project) */
- USB_DEVICE(0x0572, 0xcafe), .driver_info = (unsigned long) &cxacru_cafe
- },
- { /* V = Conexant P = ADSL modem (Hasbani project) */
- USB_DEVICE(0x0572, 0xcb00), .driver_info = (unsigned long) &cxacru_cb00
- },
- { /* V = Conexant P = ADSL modem */
- USB_DEVICE(0x0572, 0xcb01), .driver_info = (unsigned long) &cxacru_cb00
- },
- { /* V = Conexant P = ADSL modem (Well PTI-800) */
- USB_DEVICE(0x0572, 0xcb02), .driver_info = (unsigned long) &cxacru_cb00
- },
- { /* V = Conexant P = ADSL modem */
- USB_DEVICE(0x0572, 0xcb06), .driver_info = (unsigned long) &cxacru_cb00
- },
- { /* V = Conexant P = ADSL modem (ZTE ZXDSL 852) */
- USB_DEVICE(0x0572, 0xcb07), .driver_info = (unsigned long) &cxacru_cb00
- },
- { /* V = Olitec P = ADSL modem version 2 */
- USB_DEVICE(0x08e3, 0x0100), .driver_info = (unsigned long) &cxacru_cafe
- },
- { /* V = Olitec P = ADSL modem version 3 */
- USB_DEVICE(0x08e3, 0x0102), .driver_info = (unsigned long) &cxacru_cb00
- },
- { /* V = Trust/Amigo Technology Co. P = AMX-CA86U */
- USB_DEVICE(0x0eb0, 0x3457), .driver_info = (unsigned long) &cxacru_cafe
- },
- { /* V = Zoom P = 5510 */
- USB_DEVICE(0x1803, 0x5510), .driver_info = (unsigned long) &cxacru_cb00
- },
- { /* V = Draytek P = Vigor 318 */
- USB_DEVICE(0x0675, 0x0200), .driver_info = (unsigned long) &cxacru_cb00
- },
- { /* V = Zyxel P = 630-C1 aka OMNI ADSL USB (Annex A) */
- USB_DEVICE(0x0586, 0x330a), .driver_info = (unsigned long) &cxacru_cb00
- },
- { /* V = Zyxel P = 630-C3 aka OMNI ADSL USB (Annex B) */
- USB_DEVICE(0x0586, 0x330b), .driver_info = (unsigned long) &cxacru_cb00
- },
- { /* V = Aethra P = Starmodem UM1020 */
- USB_DEVICE(0x0659, 0x0020), .driver_info = (unsigned long) &cxacru_cb00
- },
- { /* V = Aztech Systems P = ? AKA Pirelli AUA-010 */
- USB_DEVICE(0x0509, 0x0812), .driver_info = (unsigned long) &cxacru_cb00
- },
- { /* V = Netopia P = Cayman 3341(Annex A)/3351(Annex B) */
- USB_DEVICE(0x100d, 0xcb01), .driver_info = (unsigned long) &cxacru_cb00
- },
- { /* V = Netopia P = Cayman 3342(Annex A)/3352(Annex B) */
- USB_DEVICE(0x100d, 0x3342), .driver_info = (unsigned long) &cxacru_cb00
- },
- {}
-};
-
-MODULE_DEVICE_TABLE(usb, cxacru_usb_ids);
-
-static struct usbatm_driver cxacru_driver = {
- .driver_name = cxacru_driver_name,
- .bind = cxacru_bind,
- .heavy_init = cxacru_heavy_init,
- .unbind = cxacru_unbind,
- .atm_start = cxacru_atm_start,
- .atm_stop = cxacru_remove_device_files,
- .bulk_in = CXACRU_EP_DATA,
- .bulk_out = CXACRU_EP_DATA,
- .rx_padding = 3,
- .tx_padding = 11,
-};
-
-static int cxacru_usb_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- struct usb_device *usb_dev = interface_to_usbdev(intf);
- char buf[15];
-
- /* Avoid ADSL routers (cx82310_eth).
- * Abort if bDeviceClass is 0xff and iProduct is "USB NET CARD".
- */
- if (usb_dev->descriptor.bDeviceClass == USB_CLASS_VENDOR_SPEC
- && usb_string(usb_dev, usb_dev->descriptor.iProduct,
- buf, sizeof(buf)) > 0) {
- if (!strcmp(buf, "USB NET CARD")) {
- dev_info(&intf->dev, "ignoring cx82310_eth device\n");
- return -ENODEV;
- }
- }
-
- return usbatm_usb_probe(intf, id, &cxacru_driver);
-}
-
-static struct usb_driver cxacru_usb_driver = {
- .name = cxacru_driver_name,
- .probe = cxacru_usb_probe,
- .disconnect = usbatm_usb_disconnect,
- .id_table = cxacru_usb_ids
-};
-
-module_usb_driver(cxacru_usb_driver);
-
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-MODULE_VERSION(DRIVER_VERSION);
diff --git a/ANDROID_3.4.5/drivers/usb/atm/speedtch.c b/ANDROID_3.4.5/drivers/usb/atm/speedtch.c
deleted file mode 100644
index 98dd9e49..00000000
--- a/ANDROID_3.4.5/drivers/usb/atm/speedtch.c
+++ /dev/null
@@ -1,961 +0,0 @@
-/******************************************************************************
- * speedtch.c - Alcatel SpeedTouch USB xDSL modem driver
- *
- * Copyright (C) 2001, Alcatel
- * Copyright (C) 2003, Duncan Sands
- * Copyright (C) 2004, David Woodhouse
- *
- * Based on "modem_run.c", copyright (C) 2001, Benoit Papillault
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- ******************************************************************************/
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "usbatm.h"
-
-#define DRIVER_AUTHOR "Johan Verrept, Duncan Sands "
-#define DRIVER_VERSION "1.10"
-#define DRIVER_DESC "Alcatel SpeedTouch USB driver version " DRIVER_VERSION
-
-static const char speedtch_driver_name[] = "speedtch";
-
-#define CTRL_TIMEOUT 2000 /* milliseconds */
-#define DATA_TIMEOUT 2000 /* milliseconds */
-
-#define OFFSET_7 0 /* size 1 */
-#define OFFSET_b 1 /* size 8 */
-#define OFFSET_d 9 /* size 4 */
-#define OFFSET_e 13 /* size 1 */
-#define OFFSET_f 14 /* size 1 */
-
-#define SIZE_7 1
-#define SIZE_b 8
-#define SIZE_d 4
-#define SIZE_e 1
-#define SIZE_f 1
-
-#define MIN_POLL_DELAY 5000 /* milliseconds */
-#define MAX_POLL_DELAY 60000 /* milliseconds */
-
-#define RESUBMIT_DELAY 1000 /* milliseconds */
-
-#define DEFAULT_BULK_ALTSETTING 1
-#define DEFAULT_ISOC_ALTSETTING 3
-#define DEFAULT_DL_512_FIRST 0
-#define DEFAULT_ENABLE_ISOC 0
-#define DEFAULT_SW_BUFFERING 0
-
-static unsigned int altsetting = 0; /* zero means: use the default */
-static bool dl_512_first = DEFAULT_DL_512_FIRST;
-static bool enable_isoc = DEFAULT_ENABLE_ISOC;
-static bool sw_buffering = DEFAULT_SW_BUFFERING;
-
-#define DEFAULT_B_MAX_DSL 8128
-#define DEFAULT_MODEM_MODE 11
-#define MODEM_OPTION_LENGTH 16
-static const unsigned char DEFAULT_MODEM_OPTION[MODEM_OPTION_LENGTH] = {
- 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-static unsigned int BMaxDSL = DEFAULT_B_MAX_DSL;
-static unsigned char ModemMode = DEFAULT_MODEM_MODE;
-static unsigned char ModemOption[MODEM_OPTION_LENGTH];
-static unsigned int num_ModemOption;
-
-module_param(altsetting, uint, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(altsetting,
- "Alternative setting for data interface (bulk_default: "
- __MODULE_STRING(DEFAULT_BULK_ALTSETTING) "; isoc_default: "
- __MODULE_STRING(DEFAULT_ISOC_ALTSETTING) ")");
-
-module_param(dl_512_first, bool, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(dl_512_first,
- "Read 512 bytes before sending firmware (default: "
- __MODULE_STRING(DEFAULT_DL_512_FIRST) ")");
-
-module_param(enable_isoc, bool, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(enable_isoc,
- "Use isochronous transfers if available (default: "
- __MODULE_STRING(DEFAULT_ENABLE_ISOC) ")");
-
-module_param(sw_buffering, bool, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(sw_buffering,
- "Enable software buffering (default: "
- __MODULE_STRING(DEFAULT_SW_BUFFERING) ")");
-
-module_param(BMaxDSL, uint, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(BMaxDSL,
- "default: " __MODULE_STRING(DEFAULT_B_MAX_DSL));
-
-module_param(ModemMode, byte, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(ModemMode,
- "default: " __MODULE_STRING(DEFAULT_MODEM_MODE));
-
-module_param_array(ModemOption, byte, &num_ModemOption, S_IRUGO);
-MODULE_PARM_DESC(ModemOption, "default: 0x10,0x00,0x00,0x00,0x20");
-
-#define INTERFACE_DATA 1
-#define ENDPOINT_INT 0x81
-#define ENDPOINT_BULK_DATA 0x07
-#define ENDPOINT_ISOC_DATA 0x07
-#define ENDPOINT_FIRMWARE 0x05
-
-struct speedtch_params {
- unsigned int altsetting;
- unsigned int BMaxDSL;
- unsigned char ModemMode;
- unsigned char ModemOption[MODEM_OPTION_LENGTH];
-};
-
-struct speedtch_instance_data {
- struct usbatm_data *usbatm;
-
- struct speedtch_params params; /* set in probe, constant afterwards */
-
- struct timer_list status_check_timer;
- struct work_struct status_check_work;
-
- unsigned char last_status;
-
- int poll_delay; /* milliseconds */
-
- struct timer_list resubmit_timer;
- struct urb *int_urb;
- unsigned char int_data[16];
-
- unsigned char scratch_buffer[16];
-};
-
-/***************
-** firmware **
-***************/
-
-static void speedtch_set_swbuff(struct speedtch_instance_data *instance, int state)
-{
- struct usbatm_data *usbatm = instance->usbatm;
- struct usb_device *usb_dev = usbatm->usb_dev;
- int ret;
-
- ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
- 0x32, 0x40, state ? 0x01 : 0x00, 0x00, NULL, 0, CTRL_TIMEOUT);
- if (ret < 0)
- usb_warn(usbatm,
- "%sabling SW buffering: usb_control_msg returned %d\n",
- state ? "En" : "Dis", ret);
- else
- dbg("speedtch_set_swbuff: %sbled SW buffering", state ? "En" : "Dis");
-}
-
-static void speedtch_test_sequence(struct speedtch_instance_data *instance)
-{
- struct usbatm_data *usbatm = instance->usbatm;
- struct usb_device *usb_dev = usbatm->usb_dev;
- unsigned char *buf = instance->scratch_buffer;
- int ret;
-
- /* URB 147 */
- buf[0] = 0x1c;
- buf[1] = 0x50;
- ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
- 0x01, 0x40, 0x0b, 0x00, buf, 2, CTRL_TIMEOUT);
- if (ret < 0)
- usb_warn(usbatm, "%s failed on URB147: %d\n", __func__, ret);
-
- /* URB 148 */
- buf[0] = 0x32;
- buf[1] = 0x00;
- ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
- 0x01, 0x40, 0x02, 0x00, buf, 2, CTRL_TIMEOUT);
- if (ret < 0)
- usb_warn(usbatm, "%s failed on URB148: %d\n", __func__, ret);
-
- /* URB 149 */
- buf[0] = 0x01;
- buf[1] = 0x00;
- buf[2] = 0x01;
- ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
- 0x01, 0x40, 0x03, 0x00, buf, 3, CTRL_TIMEOUT);
- if (ret < 0)
- usb_warn(usbatm, "%s failed on URB149: %d\n", __func__, ret);
-
- /* URB 150 */
- buf[0] = 0x01;
- buf[1] = 0x00;
- buf[2] = 0x01;
- ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
- 0x01, 0x40, 0x04, 0x00, buf, 3, CTRL_TIMEOUT);
- if (ret < 0)
- usb_warn(usbatm, "%s failed on URB150: %d\n", __func__, ret);
-
- /* Extra initialisation in recent drivers - gives higher speeds */
-
- /* URBext1 */
- buf[0] = instance->params.ModemMode;
- ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
- 0x01, 0x40, 0x11, 0x00, buf, 1, CTRL_TIMEOUT);
- if (ret < 0)
- usb_warn(usbatm, "%s failed on URBext1: %d\n", __func__, ret);
-
- /* URBext2 */
- /* This seems to be the one which actually triggers the higher sync
- rate -- it does require the new firmware too, although it works OK
- with older firmware */
- ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
- 0x01, 0x40, 0x14, 0x00,
- instance->params.ModemOption,
- MODEM_OPTION_LENGTH, CTRL_TIMEOUT);
- if (ret < 0)
- usb_warn(usbatm, "%s failed on URBext2: %d\n", __func__, ret);
-
- /* URBext3 */
- buf[0] = instance->params.BMaxDSL & 0xff;
- buf[1] = instance->params.BMaxDSL >> 8;
- ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
- 0x01, 0x40, 0x12, 0x00, buf, 2, CTRL_TIMEOUT);
- if (ret < 0)
- usb_warn(usbatm, "%s failed on URBext3: %d\n", __func__, ret);
-}
-
-static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
- const struct firmware *fw1,
- const struct firmware *fw2)
-{
- unsigned char *buffer;
- struct usbatm_data *usbatm = instance->usbatm;
- struct usb_device *usb_dev = usbatm->usb_dev;
- int actual_length;
- int ret = 0;
- int offset;
-
- usb_dbg(usbatm, "%s entered\n", __func__);
-
- if (!(buffer = (unsigned char *)__get_free_page(GFP_KERNEL))) {
- ret = -ENOMEM;
- usb_dbg(usbatm, "%s: no memory for buffer!\n", __func__);
- goto out;
- }
-
- if (!usb_ifnum_to_if(usb_dev, 2)) {
- ret = -ENODEV;
- usb_dbg(usbatm, "%s: interface not found!\n", __func__);
- goto out_free;
- }
-
- /* URB 7 */
- if (dl_512_first) { /* some modems need a read before writing the firmware */
- ret = usb_bulk_msg(usb_dev, usb_rcvbulkpipe(usb_dev, ENDPOINT_FIRMWARE),
- buffer, 0x200, &actual_length, 2000);
-
- if (ret < 0 && ret != -ETIMEDOUT)
- usb_warn(usbatm, "%s: read BLOCK0 from modem failed (%d)!\n", __func__, ret);
- else
- usb_dbg(usbatm, "%s: BLOCK0 downloaded (%d bytes)\n", __func__, ret);
- }
-
- /* URB 8 : both leds are static green */
- for (offset = 0; offset < fw1->size; offset += PAGE_SIZE) {
- int thislen = min_t(int, PAGE_SIZE, fw1->size - offset);
- memcpy(buffer, fw1->data + offset, thislen);
-
- ret = usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, ENDPOINT_FIRMWARE),
- buffer, thislen, &actual_length, DATA_TIMEOUT);
-
- if (ret < 0) {
- usb_err(usbatm, "%s: write BLOCK1 to modem failed (%d)!\n", __func__, ret);
- goto out_free;
- }
- usb_dbg(usbatm, "%s: BLOCK1 uploaded (%zu bytes)\n", __func__, fw1->size);
- }
-
- /* USB led blinking green, ADSL led off */
-
- /* URB 11 */
- ret = usb_bulk_msg(usb_dev, usb_rcvbulkpipe(usb_dev, ENDPOINT_FIRMWARE),
- buffer, 0x200, &actual_length, DATA_TIMEOUT);
-
- if (ret < 0) {
- usb_err(usbatm, "%s: read BLOCK2 from modem failed (%d)!\n", __func__, ret);
- goto out_free;
- }
- usb_dbg(usbatm, "%s: BLOCK2 downloaded (%d bytes)\n", __func__, actual_length);
-
- /* URBs 12 to 139 - USB led blinking green, ADSL led off */
- for (offset = 0; offset < fw2->size; offset += PAGE_SIZE) {
- int thislen = min_t(int, PAGE_SIZE, fw2->size - offset);
- memcpy(buffer, fw2->data + offset, thislen);
-
- ret = usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, ENDPOINT_FIRMWARE),
- buffer, thislen, &actual_length, DATA_TIMEOUT);
-
- if (ret < 0) {
- usb_err(usbatm, "%s: write BLOCK3 to modem failed (%d)!\n", __func__, ret);
- goto out_free;
- }
- }
- usb_dbg(usbatm, "%s: BLOCK3 uploaded (%zu bytes)\n", __func__, fw2->size);
-
- /* USB led static green, ADSL led static red */
-
- /* URB 142 */
- ret = usb_bulk_msg(usb_dev, usb_rcvbulkpipe(usb_dev, ENDPOINT_FIRMWARE),
- buffer, 0x200, &actual_length, DATA_TIMEOUT);
-
- if (ret < 0) {
- usb_err(usbatm, "%s: read BLOCK4 from modem failed (%d)!\n", __func__, ret);
- goto out_free;
- }
-
- /* success */
- usb_dbg(usbatm, "%s: BLOCK4 downloaded (%d bytes)\n", __func__, actual_length);
-
- /* Delay to allow firmware to start up. We can do this here
- because we're in our own kernel thread anyway. */
- msleep_interruptible(1000);
-
- if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->params.altsetting)) < 0) {
- usb_err(usbatm, "%s: setting interface to %d failed (%d)!\n", __func__, instance->params.altsetting, ret);
- goto out_free;
- }
-
- /* Enable software buffering, if requested */
- if (sw_buffering)
- speedtch_set_swbuff(instance, 1);
-
- /* Magic spell; don't ask us what this does */
- speedtch_test_sequence(instance);
-
- ret = 0;
-
-out_free:
- free_page((unsigned long)buffer);
-out:
- return ret;
-}
-
-static int speedtch_find_firmware(struct usbatm_data *usbatm, struct usb_interface *intf,
- int phase, const struct firmware **fw_p)
-{
- struct device *dev = &intf->dev;
- const u16 bcdDevice = le16_to_cpu(interface_to_usbdev(intf)->descriptor.bcdDevice);
- const u8 major_revision = bcdDevice >> 8;
- const u8 minor_revision = bcdDevice & 0xff;
- char buf[24];
-
- sprintf(buf, "speedtch-%d.bin.%x.%02x", phase, major_revision, minor_revision);
- usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
-
- if (request_firmware(fw_p, buf, dev)) {
- sprintf(buf, "speedtch-%d.bin.%x", phase, major_revision);
- usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
-
- if (request_firmware(fw_p, buf, dev)) {
- sprintf(buf, "speedtch-%d.bin", phase);
- usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
-
- if (request_firmware(fw_p, buf, dev)) {
- usb_err(usbatm, "%s: no stage %d firmware found!\n", __func__, phase);
- return -ENOENT;
- }
- }
- }
-
- usb_info(usbatm, "found stage %d firmware %s\n", phase, buf);
-
- return 0;
-}
-
-static int speedtch_heavy_init(struct usbatm_data *usbatm, struct usb_interface *intf)
-{
- const struct firmware *fw1, *fw2;
- struct speedtch_instance_data *instance = usbatm->driver_data;
- int ret;
-
- if ((ret = speedtch_find_firmware(usbatm, intf, 1, &fw1)) < 0)
- return ret;
-
- if ((ret = speedtch_find_firmware(usbatm, intf, 2, &fw2)) < 0) {
- release_firmware(fw1);
- return ret;
- }
-
- if ((ret = speedtch_upload_firmware(instance, fw1, fw2)) < 0)
- usb_err(usbatm, "%s: firmware upload failed (%d)!\n", __func__, ret);
-
- release_firmware(fw2);
- release_firmware(fw1);
-
- return ret;
-}
-
-
-/**********
-** ATM **
-**********/
-
-static int speedtch_read_status(struct speedtch_instance_data *instance)
-{
- struct usbatm_data *usbatm = instance->usbatm;
- struct usb_device *usb_dev = usbatm->usb_dev;
- unsigned char *buf = instance->scratch_buffer;
- int ret;
-
- memset(buf, 0, 16);
-
- ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
- 0x12, 0xc0, 0x07, 0x00, buf + OFFSET_7, SIZE_7,
- CTRL_TIMEOUT);
- if (ret < 0) {
- atm_dbg(usbatm, "%s: MSG 7 failed\n", __func__);
- return ret;
- }
-
- ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
- 0x12, 0xc0, 0x0b, 0x00, buf + OFFSET_b, SIZE_b,
- CTRL_TIMEOUT);
- if (ret < 0) {
- atm_dbg(usbatm, "%s: MSG B failed\n", __func__);
- return ret;
- }
-
- ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
- 0x12, 0xc0, 0x0d, 0x00, buf + OFFSET_d, SIZE_d,
- CTRL_TIMEOUT);
- if (ret < 0) {
- atm_dbg(usbatm, "%s: MSG D failed\n", __func__);
- return ret;
- }
-
- ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
- 0x01, 0xc0, 0x0e, 0x00, buf + OFFSET_e, SIZE_e,
- CTRL_TIMEOUT);
- if (ret < 0) {
- atm_dbg(usbatm, "%s: MSG E failed\n", __func__);
- return ret;
- }
-
- ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
- 0x01, 0xc0, 0x0f, 0x00, buf + OFFSET_f, SIZE_f,
- CTRL_TIMEOUT);
- if (ret < 0) {
- atm_dbg(usbatm, "%s: MSG F failed\n", __func__);
- return ret;
- }
-
- return 0;
-}
-
-static int speedtch_start_synchro(struct speedtch_instance_data *instance)
-{
- struct usbatm_data *usbatm = instance->usbatm;
- struct usb_device *usb_dev = usbatm->usb_dev;
- unsigned char *buf = instance->scratch_buffer;
- int ret;
-
- atm_dbg(usbatm, "%s entered\n", __func__);
-
- memset(buf, 0, 2);
-
- ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
- 0x12, 0xc0, 0x04, 0x00,
- buf, 2, CTRL_TIMEOUT);
-
- if (ret < 0)
- atm_warn(usbatm, "failed to start ADSL synchronisation: %d\n", ret);
- else
- atm_dbg(usbatm, "%s: modem prodded. %d bytes returned: %02x %02x\n",
- __func__, ret, buf[0], buf[1]);
-
- return ret;
-}
-
-static void speedtch_check_status(struct work_struct *work)
-{
- struct speedtch_instance_data *instance =
- container_of(work, struct speedtch_instance_data,
- status_check_work);
- struct usbatm_data *usbatm = instance->usbatm;
- struct atm_dev *atm_dev = usbatm->atm_dev;
- unsigned char *buf = instance->scratch_buffer;
- int down_speed, up_speed, ret;
- unsigned char status;
-
-#ifdef VERBOSE_DEBUG
- atm_dbg(usbatm, "%s entered\n", __func__);
-#endif
-
- ret = speedtch_read_status(instance);
- if (ret < 0) {
- atm_warn(usbatm, "error %d fetching device status\n", ret);
- instance->poll_delay = min(2 * instance->poll_delay, MAX_POLL_DELAY);
- return;
- }
-
- instance->poll_delay = max(instance->poll_delay / 2, MIN_POLL_DELAY);
-
- status = buf[OFFSET_7];
-
- if ((status != instance->last_status) || !status) {
- atm_dbg(usbatm, "%s: line state 0x%02x\n", __func__, status);
-
- switch (status) {
- case 0:
- atm_dev_signal_change(atm_dev, ATM_PHY_SIG_LOST);
- if (instance->last_status)
- atm_info(usbatm, "ADSL line is down\n");
- /* It may never resync again unless we ask it to... */
- ret = speedtch_start_synchro(instance);
- break;
-
- case 0x08:
- atm_dev_signal_change(atm_dev, ATM_PHY_SIG_UNKNOWN);
- atm_info(usbatm, "ADSL line is blocked?\n");
- break;
-
- case 0x10:
- atm_dev_signal_change(atm_dev, ATM_PHY_SIG_LOST);
- atm_info(usbatm, "ADSL line is synchronising\n");
- break;
-
- case 0x20:
- down_speed = buf[OFFSET_b] | (buf[OFFSET_b + 1] << 8)
- | (buf[OFFSET_b + 2] << 16) | (buf[OFFSET_b + 3] << 24);
- up_speed = buf[OFFSET_b + 4] | (buf[OFFSET_b + 5] << 8)
- | (buf[OFFSET_b + 6] << 16) | (buf[OFFSET_b + 7] << 24);
-
- if (!(down_speed & 0x0000ffff) && !(up_speed & 0x0000ffff)) {
- down_speed >>= 16;
- up_speed >>= 16;
- }
-
- atm_dev->link_rate = down_speed * 1000 / 424;
- atm_dev_signal_change(atm_dev, ATM_PHY_SIG_FOUND);
-
- atm_info(usbatm,
- "ADSL line is up (%d kb/s down | %d kb/s up)\n",
- down_speed, up_speed);
- break;
-
- default:
- atm_dev_signal_change(atm_dev, ATM_PHY_SIG_UNKNOWN);
- atm_info(usbatm, "unknown line state %02x\n", status);
- break;
- }
-
- instance->last_status = status;
- }
-}
-
-static void speedtch_status_poll(unsigned long data)
-{
- struct speedtch_instance_data *instance = (void *)data;
-
- schedule_work(&instance->status_check_work);
-
- /* The following check is racy, but the race is harmless */
- if (instance->poll_delay < MAX_POLL_DELAY)
- mod_timer(&instance->status_check_timer, jiffies + msecs_to_jiffies(instance->poll_delay));
- else
- atm_warn(instance->usbatm, "Too many failures - disabling line status polling\n");
-}
-
-static void speedtch_resubmit_int(unsigned long data)
-{
- struct speedtch_instance_data *instance = (void *)data;
- struct urb *int_urb = instance->int_urb;
- int ret;
-
- atm_dbg(instance->usbatm, "%s entered\n", __func__);
-
- if (int_urb) {
- ret = usb_submit_urb(int_urb, GFP_ATOMIC);
- if (!ret)
- schedule_work(&instance->status_check_work);
- else {
- atm_dbg(instance->usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret);
- mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY));
- }
- }
-}
-
-static void speedtch_handle_int(struct urb *int_urb)
-{
- struct speedtch_instance_data *instance = int_urb->context;
- struct usbatm_data *usbatm = instance->usbatm;
- unsigned int count = int_urb->actual_length;
- int status = int_urb->status;
- int ret;
-
- /* The magic interrupt for "up state" */
- static const unsigned char up_int[6] = { 0xa1, 0x00, 0x01, 0x00, 0x00, 0x00 };
- /* The magic interrupt for "down state" */
- static const unsigned char down_int[6] = { 0xa1, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
- atm_dbg(usbatm, "%s entered\n", __func__);
-
- if (status < 0) {
- atm_dbg(usbatm, "%s: nonzero urb status %d!\n", __func__, status);
- goto fail;
- }
-
- if ((count == 6) && !memcmp(up_int, instance->int_data, 6)) {
- del_timer(&instance->status_check_timer);
- atm_info(usbatm, "DSL line goes up\n");
- } else if ((count == 6) && !memcmp(down_int, instance->int_data, 6)) {
- atm_info(usbatm, "DSL line goes down\n");
- } else {
- int i;
-
- atm_dbg(usbatm, "%s: unknown interrupt packet of length %d:", __func__, count);
- for (i = 0; i < count; i++)
- printk(" %02x", instance->int_data[i]);
- printk("\n");
- goto fail;
- }
-
- if ((int_urb = instance->int_urb)) {
- ret = usb_submit_urb(int_urb, GFP_ATOMIC);
- schedule_work(&instance->status_check_work);
- if (ret < 0) {
- atm_dbg(usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret);
- goto fail;
- }
- }
-
- return;
-
-fail:
- if ((int_urb = instance->int_urb))
- mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY));
-}
-
-static int speedtch_atm_start(struct usbatm_data *usbatm, struct atm_dev *atm_dev)
-{
- struct usb_device *usb_dev = usbatm->usb_dev;
- struct speedtch_instance_data *instance = usbatm->driver_data;
- int i, ret;
- unsigned char mac_str[13];
-
- atm_dbg(usbatm, "%s entered\n", __func__);
-
- /* Set MAC address, it is stored in the serial number */
- memset(atm_dev->esi, 0, sizeof(atm_dev->esi));
- if (usb_string(usb_dev, usb_dev->descriptor.iSerialNumber, mac_str, sizeof(mac_str)) == 12) {
- for (i = 0; i < 6; i++)
- atm_dev->esi[i] = (hex_to_bin(mac_str[i * 2]) << 4) +
- hex_to_bin(mac_str[i * 2 + 1]);
- }
-
- /* Start modem synchronisation */
- ret = speedtch_start_synchro(instance);
-
- /* Set up interrupt endpoint */
- if (instance->int_urb) {
- ret = usb_submit_urb(instance->int_urb, GFP_KERNEL);
- if (ret < 0) {
- /* Doesn't matter; we'll poll anyway */
- atm_dbg(usbatm, "%s: submission of interrupt URB failed (%d)!\n", __func__, ret);
- usb_free_urb(instance->int_urb);
- instance->int_urb = NULL;
- }
- }
-
- /* Start status polling */
- mod_timer(&instance->status_check_timer, jiffies + msecs_to_jiffies(1000));
-
- return 0;
-}
-
-static void speedtch_atm_stop(struct usbatm_data *usbatm, struct atm_dev *atm_dev)
-{
- struct speedtch_instance_data *instance = usbatm->driver_data;
- struct urb *int_urb = instance->int_urb;
-
- atm_dbg(usbatm, "%s entered\n", __func__);
-
- del_timer_sync(&instance->status_check_timer);
-
- /*
- * Since resubmit_timer and int_urb can schedule themselves and
- * each other, shutting them down correctly takes some care
- */
- instance->int_urb = NULL; /* signal shutdown */
- mb();
- usb_kill_urb(int_urb);
- del_timer_sync(&instance->resubmit_timer);
- /*
- * At this point, speedtch_handle_int and speedtch_resubmit_int
- * can run or be running, but instance->int_urb == NULL means that
- * they will not reschedule
- */
- usb_kill_urb(int_urb);
- del_timer_sync(&instance->resubmit_timer);
- usb_free_urb(int_urb);
-
- flush_work_sync(&instance->status_check_work);
-}
-
-static int speedtch_pre_reset(struct usb_interface *intf)
-{
- return 0;
-}
-
-static int speedtch_post_reset(struct usb_interface *intf)
-{
- return 0;
-}
-
-
-/**********
-** USB **
-**********/
-
-static struct usb_device_id speedtch_usb_ids[] = {
- {USB_DEVICE(0x06b9, 0x4061)},
- {}
-};
-
-MODULE_DEVICE_TABLE(usb, speedtch_usb_ids);
-
-static int speedtch_usb_probe(struct usb_interface *, const struct usb_device_id *);
-
-static struct usb_driver speedtch_usb_driver = {
- .name = speedtch_driver_name,
- .probe = speedtch_usb_probe,
- .disconnect = usbatm_usb_disconnect,
- .pre_reset = speedtch_pre_reset,
- .post_reset = speedtch_post_reset,
- .id_table = speedtch_usb_ids
-};
-
-static void speedtch_release_interfaces(struct usb_device *usb_dev,
- int num_interfaces)
-{
- struct usb_interface *cur_intf;
- int i;
-
- for (i = 0; i < num_interfaces; i++)
- if ((cur_intf = usb_ifnum_to_if(usb_dev, i))) {
- usb_set_intfdata(cur_intf, NULL);
- usb_driver_release_interface(&speedtch_usb_driver, cur_intf);
- }
-}
-
-static int speedtch_bind(struct usbatm_data *usbatm,
- struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- struct usb_device *usb_dev = interface_to_usbdev(intf);
- struct usb_interface *cur_intf, *data_intf;
- struct speedtch_instance_data *instance;
- int ifnum = intf->altsetting->desc.bInterfaceNumber;
- int num_interfaces = usb_dev->actconfig->desc.bNumInterfaces;
- int i, ret;
- int use_isoc;
-
- usb_dbg(usbatm, "%s entered\n", __func__);
-
- /* sanity checks */
-
- if (usb_dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) {
- usb_err(usbatm, "%s: wrong device class %d\n", __func__, usb_dev->descriptor.bDeviceClass);
- return -ENODEV;
- }
-
- if (!(data_intf = usb_ifnum_to_if(usb_dev, INTERFACE_DATA))) {
- usb_err(usbatm, "%s: data interface not found!\n", __func__);
- return -ENODEV;
- }
-
- /* claim all interfaces */
-
- for (i = 0; i < num_interfaces; i++) {
- cur_intf = usb_ifnum_to_if(usb_dev, i);
-
- if ((i != ifnum) && cur_intf) {
- ret = usb_driver_claim_interface(&speedtch_usb_driver, cur_intf, usbatm);
-
- if (ret < 0) {
- usb_err(usbatm, "%s: failed to claim interface %2d (%d)!\n", __func__, i, ret);
- speedtch_release_interfaces(usb_dev, i);
- return ret;
- }
- }
- }
-
- instance = kzalloc(sizeof(*instance), GFP_KERNEL);
-
- if (!instance) {
- usb_err(usbatm, "%s: no memory for instance data!\n", __func__);
- ret = -ENOMEM;
- goto fail_release;
- }
-
- instance->usbatm = usbatm;
-
- /* module parameters may change at any moment, so take a snapshot */
- instance->params.altsetting = altsetting;
- instance->params.BMaxDSL = BMaxDSL;
- instance->params.ModemMode = ModemMode;
- memcpy(instance->params.ModemOption, DEFAULT_MODEM_OPTION, MODEM_OPTION_LENGTH);
- memcpy(instance->params.ModemOption, ModemOption, num_ModemOption);
- use_isoc = enable_isoc;
-
- if (instance->params.altsetting)
- if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->params.altsetting)) < 0) {
- usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, instance->params.altsetting, ret);
- instance->params.altsetting = 0; /* fall back to default */
- }
-
- if (!instance->params.altsetting && use_isoc)
- if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_ISOC_ALTSETTING)) < 0) {
- usb_dbg(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_ISOC_ALTSETTING, ret);
- use_isoc = 0; /* fall back to bulk */
- }
-
- if (use_isoc) {
- const struct usb_host_interface *desc = data_intf->cur_altsetting;
- const __u8 target_address = USB_DIR_IN | usbatm->driver->isoc_in;
-
- use_isoc = 0; /* fall back to bulk if endpoint not found */
-
- for (i = 0; i < desc->desc.bNumEndpoints; i++) {
- const struct usb_endpoint_descriptor *endpoint_desc = &desc->endpoint[i].desc;
-
- if ((endpoint_desc->bEndpointAddress == target_address)) {
- use_isoc =
- usb_endpoint_xfer_isoc(endpoint_desc);
- break;
- }
- }
-
- if (!use_isoc)
- usb_info(usbatm, "isochronous transfer not supported - using bulk\n");
- }
-
- if (!use_isoc && !instance->params.altsetting)
- if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_BULK_ALTSETTING)) < 0) {
- usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_BULK_ALTSETTING, ret);
- goto fail_free;
- }
-
- if (!instance->params.altsetting)
- instance->params.altsetting = use_isoc ? DEFAULT_ISOC_ALTSETTING : DEFAULT_BULK_ALTSETTING;
-
- usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0);
-
- INIT_WORK(&instance->status_check_work, speedtch_check_status);
- init_timer(&instance->status_check_timer);
-
- instance->status_check_timer.function = speedtch_status_poll;
- instance->status_check_timer.data = (unsigned long)instance;
- instance->last_status = 0xff;
- instance->poll_delay = MIN_POLL_DELAY;
-
- init_timer(&instance->resubmit_timer);
- instance->resubmit_timer.function = speedtch_resubmit_int;
- instance->resubmit_timer.data = (unsigned long)instance;
-
- instance->int_urb = usb_alloc_urb(0, GFP_KERNEL);
-
- if (instance->int_urb)
- usb_fill_int_urb(instance->int_urb, usb_dev,
- usb_rcvintpipe(usb_dev, ENDPOINT_INT),
- instance->int_data, sizeof(instance->int_data),
- speedtch_handle_int, instance, 50);
- else
- usb_dbg(usbatm, "%s: no memory for interrupt urb!\n", __func__);
-
- /* check whether the modem already seems to be alive */
- ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
- 0x12, 0xc0, 0x07, 0x00,
- instance->scratch_buffer + OFFSET_7, SIZE_7, 500);
-
- usbatm->flags |= (ret == SIZE_7 ? UDSL_SKIP_HEAVY_INIT : 0);
-
- usb_dbg(usbatm, "%s: firmware %s loaded\n", __func__, usbatm->flags & UDSL_SKIP_HEAVY_INIT ? "already" : "not");
-
- if (!(usbatm->flags & UDSL_SKIP_HEAVY_INIT))
- if ((ret = usb_reset_device(usb_dev)) < 0) {
- usb_err(usbatm, "%s: device reset failed (%d)!\n", __func__, ret);
- goto fail_free;
- }
-
- usbatm->driver_data = instance;
-
- return 0;
-
-fail_free:
- usb_free_urb(instance->int_urb);
- kfree(instance);
-fail_release:
- speedtch_release_interfaces(usb_dev, num_interfaces);
- return ret;
-}
-
-static void speedtch_unbind(struct usbatm_data *usbatm, struct usb_interface *intf)
-{
- struct usb_device *usb_dev = interface_to_usbdev(intf);
- struct speedtch_instance_data *instance = usbatm->driver_data;
-
- usb_dbg(usbatm, "%s entered\n", __func__);
-
- speedtch_release_interfaces(usb_dev, usb_dev->actconfig->desc.bNumInterfaces);
- usb_free_urb(instance->int_urb);
- kfree(instance);
-}
-
-
-/***********
-** init **
-***********/
-
-static struct usbatm_driver speedtch_usbatm_driver = {
- .driver_name = speedtch_driver_name,
- .bind = speedtch_bind,
- .heavy_init = speedtch_heavy_init,
- .unbind = speedtch_unbind,
- .atm_start = speedtch_atm_start,
- .atm_stop = speedtch_atm_stop,
- .bulk_in = ENDPOINT_BULK_DATA,
- .bulk_out = ENDPOINT_BULK_DATA,
- .isoc_in = ENDPOINT_ISOC_DATA
-};
-
-static int speedtch_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
-{
- return usbatm_usb_probe(intf, id, &speedtch_usbatm_driver);
-}
-
-module_usb_driver(speedtch_usb_driver);
-
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-MODULE_VERSION(DRIVER_VERSION);
diff --git a/ANDROID_3.4.5/drivers/usb/atm/ueagle-atm.c b/ANDROID_3.4.5/drivers/usb/atm/ueagle-atm.c
deleted file mode 100644
index 01ea5d74..00000000
--- a/ANDROID_3.4.5/drivers/usb/atm/ueagle-atm.c
+++ /dev/null
@@ -1,2760 +0,0 @@
-/*-
- * Copyright (c) 2003, 2004
- * Damien Bergamini . All rights reserved.
- *
- * Copyright (c) 2005-2007 Matthieu Castet
- * Copyright (c) 2005-2007 Stanislaw Gruszka
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * BSD license below:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice unmodified, this list of conditions, and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * GPL license :
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- *
- * HISTORY : some part of the code was base on ueagle 1.3 BSD driver,
- * Damien Bergamini agree to put his code under a DUAL GPL/BSD license.
- *
- * The rest of the code was was rewritten from scratch.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-#include "usbatm.h"
-
-#define EAGLEUSBVERSION "ueagle 1.4"
-
-
-/*
- * Debug macros
- */
-#define uea_dbg(usb_dev, format, args...) \
- do { \
- if (debug >= 1) \
- dev_dbg(&(usb_dev)->dev, \
- "[ueagle-atm dbg] %s: " format, \
- __func__, ##args); \
- } while (0)
-
-#define uea_vdbg(usb_dev, format, args...) \
- do { \
- if (debug >= 2) \
- dev_dbg(&(usb_dev)->dev, \
- "[ueagle-atm vdbg] " format, ##args); \
- } while (0)
-
-#define uea_enters(usb_dev) \
- uea_vdbg(usb_dev, "entering %s\n" , __func__)
-
-#define uea_leaves(usb_dev) \
- uea_vdbg(usb_dev, "leaving %s\n" , __func__)
-
-#define uea_err(usb_dev, format, args...) \
- dev_err(&(usb_dev)->dev , "[UEAGLE-ATM] " format , ##args)
-
-#define uea_warn(usb_dev, format, args...) \
- dev_warn(&(usb_dev)->dev , "[Ueagle-atm] " format, ##args)
-
-#define uea_info(usb_dev, format, args...) \
- dev_info(&(usb_dev)->dev , "[ueagle-atm] " format, ##args)
-
-struct intr_pkt;
-
-/* cmv's from firmware */
-struct uea_cmvs_v1 {
- u32 address;
- u16 offset;
- u32 data;
-} __packed;
-
-struct uea_cmvs_v2 {
- u32 group;
- u32 address;
- u32 offset;
- u32 data;
-} __packed;
-
-/* information about currently processed cmv */
-struct cmv_dsc_e1 {
- u8 function;
- u16 idx;
- u32 address;
- u16 offset;
-};
-
-struct cmv_dsc_e4 {
- u16 function;
- u16 offset;
- u16 address;
- u16 group;
-};
-
-union cmv_dsc {
- struct cmv_dsc_e1 e1;
- struct cmv_dsc_e4 e4;
-};
-
-struct uea_softc {
- struct usb_device *usb_dev;
- struct usbatm_data *usbatm;
-
- int modem_index;
- unsigned int driver_info;
- int annex;
-#define ANNEXA 0
-#define ANNEXB 1
-
- int booting;
- int reset;
-
- wait_queue_head_t sync_q;
-
- struct task_struct *kthread;
- u32 data;
- u32 data1;
-
- int cmv_ack;
- union cmv_dsc cmv_dsc;
-
- struct work_struct task;
- u16 pageno;
- u16 ovl;
-
- const struct firmware *dsp_firm;
- struct urb *urb_int;
-
- void (*dispatch_cmv) (struct uea_softc *, struct intr_pkt *);
- void (*schedule_load_page) (struct uea_softc *, struct intr_pkt *);
- int (*stat) (struct uea_softc *);
- int (*send_cmvs) (struct uea_softc *);
-
- /* keep in sync with eaglectl */
- struct uea_stats {
- struct {
- u32 state;
- u32 flags;
- u32 mflags;
- u32 vidcpe;
- u32 vidco;
- u32 dsrate;
- u32 usrate;
- u32 dsunc;
- u32 usunc;
- u32 dscorr;
- u32 uscorr;
- u32 txflow;
- u32 rxflow;
- u32 usattenuation;
- u32 dsattenuation;
- u32 dsmargin;
- u32 usmargin;
- u32 firmid;
- } phy;
- } stats;
-};
-
-/*
- * Elsa IDs
- */
-#define ELSA_VID 0x05CC
-#define ELSA_PID_PSTFIRM 0x3350
-#define ELSA_PID_PREFIRM 0x3351
-
-#define ELSA_PID_A_PREFIRM 0x3352
-#define ELSA_PID_A_PSTFIRM 0x3353
-#define ELSA_PID_B_PREFIRM 0x3362
-#define ELSA_PID_B_PSTFIRM 0x3363
-
-/*
- * Devolo IDs : pots if (pid & 0x10)
- */
-#define DEVOLO_VID 0x1039
-#define DEVOLO_EAGLE_I_A_PID_PSTFIRM 0x2110
-#define DEVOLO_EAGLE_I_A_PID_PREFIRM 0x2111
-
-#define DEVOLO_EAGLE_I_B_PID_PSTFIRM 0x2100
-#define DEVOLO_EAGLE_I_B_PID_PREFIRM 0x2101
-
-#define DEVOLO_EAGLE_II_A_PID_PSTFIRM 0x2130
-#define DEVOLO_EAGLE_II_A_PID_PREFIRM 0x2131
-
-#define DEVOLO_EAGLE_II_B_PID_PSTFIRM 0x2120
-#define DEVOLO_EAGLE_II_B_PID_PREFIRM 0x2121
-
-/*
- * Reference design USB IDs
- */
-#define ANALOG_VID 0x1110
-#define ADI930_PID_PREFIRM 0x9001
-#define ADI930_PID_PSTFIRM 0x9000
-
-#define EAGLE_I_PID_PREFIRM 0x9010 /* Eagle I */
-#define EAGLE_I_PID_PSTFIRM 0x900F /* Eagle I */
-
-#define EAGLE_IIC_PID_PREFIRM 0x9024 /* Eagle IIC */
-#define EAGLE_IIC_PID_PSTFIRM 0x9023 /* Eagle IIC */
-
-#define EAGLE_II_PID_PREFIRM 0x9022 /* Eagle II */
-#define EAGLE_II_PID_PSTFIRM 0x9021 /* Eagle II */
-
-#define EAGLE_III_PID_PREFIRM 0x9032 /* Eagle III */
-#define EAGLE_III_PID_PSTFIRM 0x9031 /* Eagle III */
-
-#define EAGLE_IV_PID_PREFIRM 0x9042 /* Eagle IV */
-#define EAGLE_IV_PID_PSTFIRM 0x9041 /* Eagle IV */
-
-/*
- * USR USB IDs
- */
-#define USR_VID 0x0BAF
-#define MILLER_A_PID_PREFIRM 0x00F2
-#define MILLER_A_PID_PSTFIRM 0x00F1
-#define MILLER_B_PID_PREFIRM 0x00FA
-#define MILLER_B_PID_PSTFIRM 0x00F9
-#define HEINEKEN_A_PID_PREFIRM 0x00F6
-#define HEINEKEN_A_PID_PSTFIRM 0x00F5
-#define HEINEKEN_B_PID_PREFIRM 0x00F8
-#define HEINEKEN_B_PID_PSTFIRM 0x00F7
-
-#define PREFIRM 0
-#define PSTFIRM (1<<7)
-#define AUTO_ANNEX_A (1<<8)
-#define AUTO_ANNEX_B (1<<9)
-
-enum {
- ADI930 = 0,
- EAGLE_I,
- EAGLE_II,
- EAGLE_III,
- EAGLE_IV
-};
-
-/* macros for both struct usb_device_id and struct uea_softc */
-#define UEA_IS_PREFIRM(x) \
- (!((x)->driver_info & PSTFIRM))
-#define UEA_CHIP_VERSION(x) \
- ((x)->driver_info & 0xf)
-
-#define IS_ISDN(x) \
- ((x)->annex & ANNEXB)
-
-#define INS_TO_USBDEV(ins) (ins->usb_dev)
-
-#define GET_STATUS(data) \
- ((data >> 8) & 0xf)
-
-#define IS_OPERATIONAL(sc) \
- ((UEA_CHIP_VERSION(sc) != EAGLE_IV) ? \
- (GET_STATUS(sc->stats.phy.state) == 2) : \
- (sc->stats.phy.state == 7))
-
-/*
- * Set of macros to handle unaligned data in the firmware blob.
- * The FW_GET_BYTE() macro is provided only for consistency.
- */
-
-#define FW_GET_BYTE(p) (*((__u8 *) (p)))
-
-#define FW_DIR "ueagle-atm/"
-#define UEA_FW_NAME_MAX 30
-#define NB_MODEM 4
-
-#define BULK_TIMEOUT 300
-#define CTRL_TIMEOUT 1000
-
-#define ACK_TIMEOUT msecs_to_jiffies(3000)
-
-#define UEA_INTR_IFACE_NO 0
-#define UEA_US_IFACE_NO 1
-#define UEA_DS_IFACE_NO 2
-
-#define FASTEST_ISO_INTF 8
-
-#define UEA_BULK_DATA_PIPE 0x02
-#define UEA_IDMA_PIPE 0x04
-#define UEA_INTR_PIPE 0x04
-#define UEA_ISO_DATA_PIPE 0x08
-
-#define UEA_E1_SET_BLOCK 0x0001
-#define UEA_E4_SET_BLOCK 0x002c
-#define UEA_SET_MODE 0x0003
-#define UEA_SET_2183_DATA 0x0004
-#define UEA_SET_TIMEOUT 0x0011
-
-#define UEA_LOOPBACK_OFF 0x0002
-#define UEA_LOOPBACK_ON 0x0003
-#define UEA_BOOT_IDMA 0x0006
-#define UEA_START_RESET 0x0007
-#define UEA_END_RESET 0x0008
-
-#define UEA_SWAP_MAILBOX (0x3fcd | 0x4000)
-#define UEA_MPTX_START (0x3fce | 0x4000)
-#define UEA_MPTX_MAILBOX (0x3fd6 | 0x4000)
-#define UEA_MPRX_MAILBOX (0x3fdf | 0x4000)
-
-/* block information in eagle4 dsp firmware */
-struct block_index {
- __le32 PageOffset;
- __le32 NotLastBlock;
- __le32 dummy;
- __le32 PageSize;
- __le32 PageAddress;
- __le16 dummy1;
- __le16 PageNumber;
-} __packed;
-
-#define E4_IS_BOOT_PAGE(PageSize) ((le32_to_cpu(PageSize)) & 0x80000000)
-#define E4_PAGE_BYTES(PageSize) ((le32_to_cpu(PageSize) & 0x7fffffff) * 4)
-
-#define E4_L1_STRING_HEADER 0x10
-#define E4_MAX_PAGE_NUMBER 0x58
-#define E4_NO_SWAPPAGE_HEADERS 0x31
-
-/* l1_code is eagle4 dsp firmware format */
-struct l1_code {
- u8 string_header[E4_L1_STRING_HEADER];
- u8 page_number_to_block_index[E4_MAX_PAGE_NUMBER];
- struct block_index page_header[E4_NO_SWAPPAGE_HEADERS];
- u8 code[0];
-} __packed;
-
-/* structures describing a block within a DSP page */
-struct block_info_e1 {
- __le16 wHdr;
- __le16 wAddress;
- __le16 wSize;
- __le16 wOvlOffset;
- __le16 wOvl; /* overlay */
- __le16 wLast;
-} __packed;
-#define E1_BLOCK_INFO_SIZE 12
-
-struct block_info_e4 {
- __be16 wHdr;
- __u8 bBootPage;
- __u8 bPageNumber;
- __be32 dwSize;
- __be32 dwAddress;
- __be16 wReserved;
-} __packed;
-#define E4_BLOCK_INFO_SIZE 14
-
-#define UEA_BIHDR 0xabcd
-#define UEA_RESERVED 0xffff
-
-/* constants describing cmv type */
-#define E1_PREAMBLE 0x535c
-#define E1_MODEMTOHOST 0x01
-#define E1_HOSTTOMODEM 0x10
-
-#define E1_MEMACCESS 0x1
-#define E1_ADSLDIRECTIVE 0x7
-#define E1_FUNCTION_TYPE(f) ((f) >> 4)
-#define E1_FUNCTION_SUBTYPE(f) ((f) & 0x0f)
-
-#define E4_MEMACCESS 0
-#define E4_ADSLDIRECTIVE 0xf
-#define E4_FUNCTION_TYPE(f) ((f) >> 8)
-#define E4_FUNCTION_SIZE(f) ((f) & 0x0f)
-#define E4_FUNCTION_SUBTYPE(f) (((f) >> 4) & 0x0f)
-
-/* for MEMACCESS */
-#define E1_REQUESTREAD 0x0
-#define E1_REQUESTWRITE 0x1
-#define E1_REPLYREAD 0x2
-#define E1_REPLYWRITE 0x3
-
-#define E4_REQUESTREAD 0x0
-#define E4_REQUESTWRITE 0x4
-#define E4_REPLYREAD (E4_REQUESTREAD | 1)
-#define E4_REPLYWRITE (E4_REQUESTWRITE | 1)
-
-/* for ADSLDIRECTIVE */
-#define E1_KERNELREADY 0x0
-#define E1_MODEMREADY 0x1
-
-#define E4_KERNELREADY 0x0
-#define E4_MODEMREADY 0x1
-
-#define E1_MAKEFUNCTION(t, s) (((t) & 0xf) << 4 | ((s) & 0xf))
-#define E4_MAKEFUNCTION(t, st, s) (((t) & 0xf) << 8 | \
- ((st) & 0xf) << 4 | ((s) & 0xf))
-
-#define E1_MAKESA(a, b, c, d) \
- (((c) & 0xff) << 24 | \
- ((d) & 0xff) << 16 | \
- ((a) & 0xff) << 8 | \
- ((b) & 0xff))
-
-#define E1_GETSA1(a) ((a >> 8) & 0xff)
-#define E1_GETSA2(a) (a & 0xff)
-#define E1_GETSA3(a) ((a >> 24) & 0xff)
-#define E1_GETSA4(a) ((a >> 16) & 0xff)
-
-#define E1_SA_CNTL E1_MAKESA('C', 'N', 'T', 'L')
-#define E1_SA_DIAG E1_MAKESA('D', 'I', 'A', 'G')
-#define E1_SA_INFO E1_MAKESA('I', 'N', 'F', 'O')
-#define E1_SA_OPTN E1_MAKESA('O', 'P', 'T', 'N')
-#define E1_SA_RATE E1_MAKESA('R', 'A', 'T', 'E')
-#define E1_SA_STAT E1_MAKESA('S', 'T', 'A', 'T')
-
-#define E4_SA_CNTL 1
-#define E4_SA_STAT 2
-#define E4_SA_INFO 3
-#define E4_SA_TEST 4
-#define E4_SA_OPTN 5
-#define E4_SA_RATE 6
-#define E4_SA_DIAG 7
-#define E4_SA_CNFG 8
-
-/* structures representing a CMV (Configuration and Management Variable) */
-struct cmv_e1 {
- __le16 wPreamble;
- __u8 bDirection;
- __u8 bFunction;
- __le16 wIndex;
- __le32 dwSymbolicAddress;
- __le16 wOffsetAddress;
- __le32 dwData;
-} __packed;
-
-struct cmv_e4 {
- __be16 wGroup;
- __be16 wFunction;
- __be16 wOffset;
- __be16 wAddress;
- __be32 dwData[6];
-} __packed;
-
-/* structures representing swap information */
-struct swap_info_e1 {
- __u8 bSwapPageNo;
- __u8 bOvl; /* overlay */
-} __packed;
-
-struct swap_info_e4 {
- __u8 bSwapPageNo;
-} __packed;
-
-/* structures representing interrupt data */
-#define e1_bSwapPageNo u.e1.s1.swapinfo.bSwapPageNo
-#define e1_bOvl u.e1.s1.swapinfo.bOvl
-#define e4_bSwapPageNo u.e4.s1.swapinfo.bSwapPageNo
-
-#define INT_LOADSWAPPAGE 0x0001
-#define INT_INCOMINGCMV 0x0002
-
-union intr_data_e1 {
- struct {
- struct swap_info_e1 swapinfo;
- __le16 wDataSize;
- } __packed s1;
- struct {
- struct cmv_e1 cmv;
- __le16 wDataSize;
- } __packed s2;
-} __packed;
-
-union intr_data_e4 {
- struct {
- struct swap_info_e4 swapinfo;
- __le16 wDataSize;
- } __packed s1;
- struct {
- struct cmv_e4 cmv;
- __le16 wDataSize;
- } __packed s2;
-} __packed;
-
-struct intr_pkt {
- __u8 bType;
- __u8 bNotification;
- __le16 wValue;
- __le16 wIndex;
- __le16 wLength;
- __le16 wInterrupt;
- union {
- union intr_data_e1 e1;
- union intr_data_e4 e4;
- } u;
-} __packed;
-
-#define E1_INTR_PKT_SIZE 28
-#define E4_INTR_PKT_SIZE 64
-
-static struct usb_driver uea_driver;
-static DEFINE_MUTEX(uea_mutex);
-static const char * const chip_name[] = {
- "ADI930", "Eagle I", "Eagle II", "Eagle III", "Eagle IV"};
-
-static int modem_index;
-static unsigned int debug;
-static unsigned int altsetting[NB_MODEM] = {
- [0 ... (NB_MODEM - 1)] = FASTEST_ISO_INTF};
-static bool sync_wait[NB_MODEM];
-static char *cmv_file[NB_MODEM];
-static int annex[NB_MODEM];
-
-module_param(debug, uint, 0644);
-MODULE_PARM_DESC(debug, "module debug level (0=off,1=on,2=verbose)");
-module_param_array(altsetting, uint, NULL, 0644);
-MODULE_PARM_DESC(altsetting, "alternate setting for incoming traffic: 0=bulk, "
- "1=isoc slowest, ... , 8=isoc fastest (default)");
-module_param_array(sync_wait, bool, NULL, 0644);
-MODULE_PARM_DESC(sync_wait, "wait the synchronisation before starting ATM");
-module_param_array(cmv_file, charp, NULL, 0644);
-MODULE_PARM_DESC(cmv_file,
- "file name with configuration and management variables");
-module_param_array(annex, uint, NULL, 0644);
-MODULE_PARM_DESC(annex,
- "manually set annex a/b (0=auto, 1=annex a, 2=annex b)");
-
-#define uea_wait(sc, cond, timeo) \
-({ \
- int _r = wait_event_interruptible_timeout(sc->sync_q, \
- (cond) || kthread_should_stop(), timeo); \
- if (kthread_should_stop()) \
- _r = -ENODEV; \
- _r; \
-})
-
-#define UPDATE_ATM_STAT(type, val) \
- do { \
- if (sc->usbatm->atm_dev) \
- sc->usbatm->atm_dev->type = val; \
- } while (0)
-
-#define UPDATE_ATM_SIGNAL(val) \
- do { \
- if (sc->usbatm->atm_dev) \
- atm_dev_signal_change(sc->usbatm->atm_dev, val); \
- } while (0)
-
-
-/* Firmware loading */
-#define LOAD_INTERNAL 0xA0
-#define F8051_USBCS 0x7f92
-
-/**
- * uea_send_modem_cmd - Send a command for pre-firmware devices.
- */
-static int uea_send_modem_cmd(struct usb_device *usb,
- u16 addr, u16 size, const u8 *buff)
-{
- int ret = -ENOMEM;
- u8 *xfer_buff;
-
- xfer_buff = kmemdup(buff, size, GFP_KERNEL);
- if (xfer_buff) {
- ret = usb_control_msg(usb,
- usb_sndctrlpipe(usb, 0),
- LOAD_INTERNAL,
- USB_DIR_OUT | USB_TYPE_VENDOR |
- USB_RECIP_DEVICE, addr, 0, xfer_buff,
- size, CTRL_TIMEOUT);
- kfree(xfer_buff);
- }
-
- if (ret < 0)
- return ret;
-
- return (ret == size) ? 0 : -EIO;
-}
-
-static void uea_upload_pre_firmware(const struct firmware *fw_entry,
- void *context)
-{
- struct usb_device *usb = context;
- const u8 *pfw;
- u8 value;
- u32 crc = 0;
- int ret, size;
-
- uea_enters(usb);
- if (!fw_entry) {
- uea_err(usb, "firmware is not available\n");
- goto err;
- }
-
- pfw = fw_entry->data;
- size = fw_entry->size;
- if (size < 4)
- goto err_fw_corrupted;
-
- crc = get_unaligned_le32(pfw);
- pfw += 4;
- size -= 4;
- if (crc32_be(0, pfw, size) != crc)
- goto err_fw_corrupted;
-
- /*
- * Start to upload firmware : send reset
- */
- value = 1;
- ret = uea_send_modem_cmd(usb, F8051_USBCS, sizeof(value), &value);
-
- if (ret < 0) {
- uea_err(usb, "modem reset failed with error %d\n", ret);
- goto err;
- }
-
- while (size > 3) {
- u8 len = FW_GET_BYTE(pfw);
- u16 add = get_unaligned_le16(pfw + 1);
-
- size -= len + 3;
- if (size < 0)
- goto err_fw_corrupted;
-
- ret = uea_send_modem_cmd(usb, add, len, pfw + 3);
- if (ret < 0) {
- uea_err(usb, "uploading firmware data failed "
- "with error %d\n", ret);
- goto err;
- }
- pfw += len + 3;
- }
-
- if (size != 0)
- goto err_fw_corrupted;
-
- /*
- * Tell the modem we finish : de-assert reset
- */
- value = 0;
- ret = uea_send_modem_cmd(usb, F8051_USBCS, 1, &value);
- if (ret < 0)
- uea_err(usb, "modem de-assert failed with error %d\n", ret);
- else
- uea_info(usb, "firmware uploaded\n");
-
- goto err;
-
-err_fw_corrupted:
- uea_err(usb, "firmware is corrupted\n");
-err:
- release_firmware(fw_entry);
- uea_leaves(usb);
-}
-
-/**
- * uea_load_firmware - Load usb firmware for pre-firmware devices.
- */
-static int uea_load_firmware(struct usb_device *usb, unsigned int ver)
-{
- int ret;
- char *fw_name = FW_DIR "eagle.fw";
-
- uea_enters(usb);
- uea_info(usb, "pre-firmware device, uploading firmware\n");
-
- switch (ver) {
- case ADI930:
- fw_name = FW_DIR "adi930.fw";
- break;
- case EAGLE_I:
- fw_name = FW_DIR "eagleI.fw";
- break;
- case EAGLE_II:
- fw_name = FW_DIR "eagleII.fw";
- break;
- case EAGLE_III:
- fw_name = FW_DIR "eagleIII.fw";
- break;
- case EAGLE_IV:
- fw_name = FW_DIR "eagleIV.fw";
- break;
- }
-
- ret = request_firmware_nowait(THIS_MODULE, 1, fw_name, &usb->dev,
- GFP_KERNEL, usb,
- uea_upload_pre_firmware);
- if (ret)
- uea_err(usb, "firmware %s is not available\n", fw_name);
- else
- uea_info(usb, "loading firmware %s\n", fw_name);
-
- uea_leaves(usb);
- return ret;
-}
-
-/* modem management : dsp firmware, send/read CMV, monitoring statistic
- */
-
-/*
- * Make sure that the DSP code provided is safe to use.
- */
-static int check_dsp_e1(const u8 *dsp, unsigned int len)
-{
- u8 pagecount, blockcount;
- u16 blocksize;
- u32 pageoffset;
- unsigned int i, j, p, pp;
-
- pagecount = FW_GET_BYTE(dsp);
- p = 1;
-
- /* enough space for page offsets? */
- if (p + 4 * pagecount > len)
- return 1;
-
- for (i = 0; i < pagecount; i++) {
-
- pageoffset = get_unaligned_le32(dsp + p);
- p += 4;
-
- if (pageoffset == 0)
- continue;
-
- /* enough space for blockcount? */
- if (pageoffset >= len)
- return 1;
-
- pp = pageoffset;
- blockcount = FW_GET_BYTE(dsp + pp);
- pp += 1;
-
- for (j = 0; j < blockcount; j++) {
-
- /* enough space for block header? */
- if (pp + 4 > len)
- return 1;
-
- pp += 2; /* skip blockaddr */
- blocksize = get_unaligned_le16(dsp + pp);
- pp += 2;
-
- /* enough space for block data? */
- if (pp + blocksize > len)
- return 1;
-
- pp += blocksize;
- }
- }
-
- return 0;
-}
-
-static int check_dsp_e4(const u8 *dsp, int len)
-{
- int i;
- struct l1_code *p = (struct l1_code *) dsp;
- unsigned int sum = p->code - dsp;
-
- if (len < sum)
- return 1;
-
- if (strcmp("STRATIPHY ANEXA", p->string_header) != 0 &&
- strcmp("STRATIPHY ANEXB", p->string_header) != 0)
- return 1;
-
- for (i = 0; i < E4_MAX_PAGE_NUMBER; i++) {
- struct block_index *blockidx;
- u8 blockno = p->page_number_to_block_index[i];
- if (blockno >= E4_NO_SWAPPAGE_HEADERS)
- continue;
-
- do {
- u64 l;
-
- if (blockno >= E4_NO_SWAPPAGE_HEADERS)
- return 1;
-
- blockidx = &p->page_header[blockno++];
- if ((u8 *)(blockidx + 1) - dsp >= len)
- return 1;
-
- if (le16_to_cpu(blockidx->PageNumber) != i)
- return 1;
-
- l = E4_PAGE_BYTES(blockidx->PageSize);
- sum += l;
- l += le32_to_cpu(blockidx->PageOffset);
- if (l > len)
- return 1;
-
- /* zero is zero regardless endianes */
- } while (blockidx->NotLastBlock);
- }
-
- return (sum == len) ? 0 : 1;
-}
-
-/*
- * send data to the idma pipe
- * */
-static int uea_idma_write(struct uea_softc *sc, const void *data, u32 size)
-{
- int ret = -ENOMEM;
- u8 *xfer_buff;
- int bytes_read;
-
- xfer_buff = kmemdup(data, size, GFP_KERNEL);
- if (!xfer_buff) {
- uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
- return ret;
- }
-
- ret = usb_bulk_msg(sc->usb_dev,
- usb_sndbulkpipe(sc->usb_dev, UEA_IDMA_PIPE),
- xfer_buff, size, &bytes_read, BULK_TIMEOUT);
-
- kfree(xfer_buff);
- if (ret < 0)
- return ret;
- if (size != bytes_read) {
- uea_err(INS_TO_USBDEV(sc), "size != bytes_read %d %d\n", size,
- bytes_read);
- return -EIO;
- }
-
- return 0;
-}
-
-static int request_dsp(struct uea_softc *sc)
-{
- int ret;
- char *dsp_name;
-
- if (UEA_CHIP_VERSION(sc) == EAGLE_IV) {
- if (IS_ISDN(sc))
- dsp_name = FW_DIR "DSP4i.bin";
- else
- dsp_name = FW_DIR "DSP4p.bin";
- } else if (UEA_CHIP_VERSION(sc) == ADI930) {
- if (IS_ISDN(sc))
- dsp_name = FW_DIR "DSP9i.bin";
- else
- dsp_name = FW_DIR "DSP9p.bin";
- } else {
- if (IS_ISDN(sc))
- dsp_name = FW_DIR "DSPei.bin";
- else
- dsp_name = FW_DIR "DSPep.bin";
- }
-
- ret = request_firmware(&sc->dsp_firm, dsp_name, &sc->usb_dev->dev);
- if (ret < 0) {
- uea_err(INS_TO_USBDEV(sc),
- "requesting firmware %s failed with error %d\n",
- dsp_name, ret);
- return ret;
- }
-
- if (UEA_CHIP_VERSION(sc) == EAGLE_IV)
- ret = check_dsp_e4(sc->dsp_firm->data, sc->dsp_firm->size);
- else
- ret = check_dsp_e1(sc->dsp_firm->data, sc->dsp_firm->size);
-
- if (ret) {
- uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n",
- dsp_name);
- release_firmware(sc->dsp_firm);
- sc->dsp_firm = NULL;
- return -EILSEQ;
- }
-
- return 0;
-}
-
-/*
- * The uea_load_page() function must be called within a process context
- */
-static void uea_load_page_e1(struct work_struct *work)
-{
- struct uea_softc *sc = container_of(work, struct uea_softc, task);
- u16 pageno = sc->pageno;
- u16 ovl = sc->ovl;
- struct block_info_e1 bi;
-
- const u8 *p;
- u8 pagecount, blockcount;
- u16 blockaddr, blocksize;
- u32 pageoffset;
- int i;
-
- /* reload firmware when reboot start and it's loaded already */
- if (ovl == 0 && pageno == 0 && sc->dsp_firm) {
- release_firmware(sc->dsp_firm);
- sc->dsp_firm = NULL;
- }
-
- if (sc->dsp_firm == NULL && request_dsp(sc) < 0)
- return;
-
- p = sc->dsp_firm->data;
- pagecount = FW_GET_BYTE(p);
- p += 1;
-
- if (pageno >= pagecount)
- goto bad1;
-
- p += 4 * pageno;
- pageoffset = get_unaligned_le32(p);
-
- if (pageoffset == 0)
- goto bad1;
-
- p = sc->dsp_firm->data + pageoffset;
- blockcount = FW_GET_BYTE(p);
- p += 1;
-
- uea_dbg(INS_TO_USBDEV(sc),
- "sending %u blocks for DSP page %u\n", blockcount, pageno);
-
- bi.wHdr = cpu_to_le16(UEA_BIHDR);
- bi.wOvl = cpu_to_le16(ovl);
- bi.wOvlOffset = cpu_to_le16(ovl | 0x8000);
-
- for (i = 0; i < blockcount; i++) {
- blockaddr = get_unaligned_le16(p);
- p += 2;
-
- blocksize = get_unaligned_le16(p);
- p += 2;
-
- bi.wSize = cpu_to_le16(blocksize);
- bi.wAddress = cpu_to_le16(blockaddr);
- bi.wLast = cpu_to_le16((i == blockcount - 1) ? 1 : 0);
-
- /* send block info through the IDMA pipe */
- if (uea_idma_write(sc, &bi, E1_BLOCK_INFO_SIZE))
- goto bad2;
-
- /* send block data through the IDMA pipe */
- if (uea_idma_write(sc, p, blocksize))
- goto bad2;
-
- p += blocksize;
- }
-
- return;
-
-bad2:
- uea_err(INS_TO_USBDEV(sc), "sending DSP block %u failed\n", i);
- return;
-bad1:
- uea_err(INS_TO_USBDEV(sc), "invalid DSP page %u requested\n", pageno);
-}
-
-static void __uea_load_page_e4(struct uea_softc *sc, u8 pageno, int boot)
-{
- struct block_info_e4 bi;
- struct block_index *blockidx;
- struct l1_code *p = (struct l1_code *) sc->dsp_firm->data;
- u8 blockno = p->page_number_to_block_index[pageno];
-
- bi.wHdr = cpu_to_be16(UEA_BIHDR);
- bi.bBootPage = boot;
- bi.bPageNumber = pageno;
- bi.wReserved = cpu_to_be16(UEA_RESERVED);
-
- do {
- const u8 *blockoffset;
- unsigned int blocksize;
-
- blockidx = &p->page_header[blockno];
- blocksize = E4_PAGE_BYTES(blockidx->PageSize);
- blockoffset = sc->dsp_firm->data + le32_to_cpu(
- blockidx->PageOffset);
-
- bi.dwSize = cpu_to_be32(blocksize);
- bi.dwAddress = cpu_to_be32(le32_to_cpu(blockidx->PageAddress));
-
- uea_dbg(INS_TO_USBDEV(sc),
- "sending block %u for DSP page "
- "%u size %u address %x\n",
- blockno, pageno, blocksize,
- le32_to_cpu(blockidx->PageAddress));
-
- /* send block info through the IDMA pipe */
- if (uea_idma_write(sc, &bi, E4_BLOCK_INFO_SIZE))
- goto bad;
-
- /* send block data through the IDMA pipe */
- if (uea_idma_write(sc, blockoffset, blocksize))
- goto bad;
-
- blockno++;
- } while (blockidx->NotLastBlock);
-
- return;
-
-bad:
- uea_err(INS_TO_USBDEV(sc), "sending DSP block %u failed\n", blockno);
- return;
-}
-
-static void uea_load_page_e4(struct work_struct *work)
-{
- struct uea_softc *sc = container_of(work, struct uea_softc, task);
- u8 pageno = sc->pageno;
- int i;
- struct block_info_e4 bi;
- struct l1_code *p;
-
- uea_dbg(INS_TO_USBDEV(sc), "sending DSP page %u\n", pageno);
-
- /* reload firmware when reboot start and it's loaded already */
- if (pageno == 0 && sc->dsp_firm) {
- release_firmware(sc->dsp_firm);
- sc->dsp_firm = NULL;
- }
-
- if (sc->dsp_firm == NULL && request_dsp(sc) < 0)
- return;
-
- p = (struct l1_code *) sc->dsp_firm->data;
- if (pageno >= le16_to_cpu(p->page_header[0].PageNumber)) {
- uea_err(INS_TO_USBDEV(sc), "invalid DSP "
- "page %u requested\n", pageno);
- return;
- }
-
- if (pageno != 0) {
- __uea_load_page_e4(sc, pageno, 0);
- return;
- }
-
- uea_dbg(INS_TO_USBDEV(sc),
- "sending Main DSP page %u\n", p->page_header[0].PageNumber);
-
- for (i = 0; i < le16_to_cpu(p->page_header[0].PageNumber); i++) {
- if (E4_IS_BOOT_PAGE(p->page_header[i].PageSize))
- __uea_load_page_e4(sc, i, 1);
- }
-
- uea_dbg(INS_TO_USBDEV(sc) , "sending start bi\n");
-
- bi.wHdr = cpu_to_be16(UEA_BIHDR);
- bi.bBootPage = 0;
- bi.bPageNumber = 0xff;
- bi.wReserved = cpu_to_be16(UEA_RESERVED);
- bi.dwSize = cpu_to_be32(E4_PAGE_BYTES(p->page_header[0].PageSize));
- bi.dwAddress = cpu_to_be32(le32_to_cpu(p->page_header[0].PageAddress));
-
- /* send block info through the IDMA pipe */
- if (uea_idma_write(sc, &bi, E4_BLOCK_INFO_SIZE))
- uea_err(INS_TO_USBDEV(sc), "sending DSP start bi failed\n");
-}
-
-static inline void wake_up_cmv_ack(struct uea_softc *sc)
-{
- BUG_ON(sc->cmv_ack);
- sc->cmv_ack = 1;
- wake_up(&sc->sync_q);
-}
-
-static inline int wait_cmv_ack(struct uea_softc *sc)
-{
- int ret = uea_wait(sc, sc->cmv_ack , ACK_TIMEOUT);
-
- sc->cmv_ack = 0;
-
- uea_dbg(INS_TO_USBDEV(sc), "wait_event_timeout : %d ms\n",
- jiffies_to_msecs(ret));
-
- if (ret < 0)
- return ret;
-
- return (ret == 0) ? -ETIMEDOUT : 0;
-}
-
-#define UCDC_SEND_ENCAPSULATED_COMMAND 0x00
-
-static int uea_request(struct uea_softc *sc,
- u16 value, u16 index, u16 size, const void *data)
-{
- u8 *xfer_buff;
- int ret = -ENOMEM;
-
- xfer_buff = kmemdup(data, size, GFP_KERNEL);
- if (!xfer_buff) {
- uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
- return ret;
- }
-
- ret = usb_control_msg(sc->usb_dev, usb_sndctrlpipe(sc->usb_dev, 0),
- UCDC_SEND_ENCAPSULATED_COMMAND,
- USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
- value, index, xfer_buff, size, CTRL_TIMEOUT);
-
- kfree(xfer_buff);
- if (ret < 0) {
- uea_err(INS_TO_USBDEV(sc), "usb_control_msg error %d\n", ret);
- return ret;
- }
-
- if (ret != size) {
- uea_err(INS_TO_USBDEV(sc),
- "usb_control_msg send only %d bytes (instead of %d)\n",
- ret, size);
- return -EIO;
- }
-
- return 0;
-}
-
-static int uea_cmv_e1(struct uea_softc *sc,
- u8 function, u32 address, u16 offset, u32 data)
-{
- struct cmv_e1 cmv;
- int ret;
-
- uea_enters(INS_TO_USBDEV(sc));
- uea_vdbg(INS_TO_USBDEV(sc), "Function : %d-%d, Address : %c%c%c%c, "
- "offset : 0x%04x, data : 0x%08x\n",
- E1_FUNCTION_TYPE(function),
- E1_FUNCTION_SUBTYPE(function),
- E1_GETSA1(address), E1_GETSA2(address),
- E1_GETSA3(address),
- E1_GETSA4(address), offset, data);
-
- /* we send a request, but we expect a reply */
- sc->cmv_dsc.e1.function = function | 0x2;
- sc->cmv_dsc.e1.idx++;
- sc->cmv_dsc.e1.address = address;
- sc->cmv_dsc.e1.offset = offset;
-
- cmv.wPreamble = cpu_to_le16(E1_PREAMBLE);
- cmv.bDirection = E1_HOSTTOMODEM;
- cmv.bFunction = function;
- cmv.wIndex = cpu_to_le16(sc->cmv_dsc.e1.idx);
- put_unaligned_le32(address, &cmv.dwSymbolicAddress);
- cmv.wOffsetAddress = cpu_to_le16(offset);
- put_unaligned_le32(data >> 16 | data << 16, &cmv.dwData);
-
- ret = uea_request(sc, UEA_E1_SET_BLOCK, UEA_MPTX_START,
- sizeof(cmv), &cmv);
- if (ret < 0)
- return ret;
- ret = wait_cmv_ack(sc);
- uea_leaves(INS_TO_USBDEV(sc));
- return ret;
-}
-
-static int uea_cmv_e4(struct uea_softc *sc,
- u16 function, u16 group, u16 address, u16 offset, u32 data)
-{
- struct cmv_e4 cmv;
- int ret;
-
- uea_enters(INS_TO_USBDEV(sc));
- memset(&cmv, 0, sizeof(cmv));
-
- uea_vdbg(INS_TO_USBDEV(sc), "Function : %d-%d, Group : 0x%04x, "
- "Address : 0x%04x, offset : 0x%04x, data : 0x%08x\n",
- E4_FUNCTION_TYPE(function), E4_FUNCTION_SUBTYPE(function),
- group, address, offset, data);
-
- /* we send a request, but we expect a reply */
- sc->cmv_dsc.e4.function = function | (0x1 << 4);
- sc->cmv_dsc.e4.offset = offset;
- sc->cmv_dsc.e4.address = address;
- sc->cmv_dsc.e4.group = group;
-
- cmv.wFunction = cpu_to_be16(function);
- cmv.wGroup = cpu_to_be16(group);
- cmv.wAddress = cpu_to_be16(address);
- cmv.wOffset = cpu_to_be16(offset);
- cmv.dwData[0] = cpu_to_be32(data);
-
- ret = uea_request(sc, UEA_E4_SET_BLOCK, UEA_MPTX_START,
- sizeof(cmv), &cmv);
- if (ret < 0)
- return ret;
- ret = wait_cmv_ack(sc);
- uea_leaves(INS_TO_USBDEV(sc));
- return ret;
-}
-
-static inline int uea_read_cmv_e1(struct uea_softc *sc,
- u32 address, u16 offset, u32 *data)
-{
- int ret = uea_cmv_e1(sc, E1_MAKEFUNCTION(E1_MEMACCESS, E1_REQUESTREAD),
- address, offset, 0);
- if (ret < 0)
- uea_err(INS_TO_USBDEV(sc),
- "reading cmv failed with error %d\n", ret);
- else
- *data = sc->data;
-
- return ret;
-}
-
-static inline int uea_read_cmv_e4(struct uea_softc *sc,
- u8 size, u16 group, u16 address, u16 offset, u32 *data)
-{
- int ret = uea_cmv_e4(sc, E4_MAKEFUNCTION(E4_MEMACCESS,
- E4_REQUESTREAD, size),
- group, address, offset, 0);
- if (ret < 0)
- uea_err(INS_TO_USBDEV(sc),
- "reading cmv failed with error %d\n", ret);
- else {
- *data = sc->data;
- /* size is in 16-bit word quantities */
- if (size > 2)
- *(data + 1) = sc->data1;
- }
- return ret;
-}
-
-static inline int uea_write_cmv_e1(struct uea_softc *sc,
- u32 address, u16 offset, u32 data)
-{
- int ret = uea_cmv_e1(sc, E1_MAKEFUNCTION(E1_MEMACCESS, E1_REQUESTWRITE),
- address, offset, data);
- if (ret < 0)
- uea_err(INS_TO_USBDEV(sc),
- "writing cmv failed with error %d\n", ret);
-
- return ret;
-}
-
-static inline int uea_write_cmv_e4(struct uea_softc *sc,
- u8 size, u16 group, u16 address, u16 offset, u32 data)
-{
- int ret = uea_cmv_e4(sc, E4_MAKEFUNCTION(E4_MEMACCESS,
- E4_REQUESTWRITE, size),
- group, address, offset, data);
- if (ret < 0)
- uea_err(INS_TO_USBDEV(sc),
- "writing cmv failed with error %d\n", ret);
-
- return ret;
-}
-
-static void uea_set_bulk_timeout(struct uea_softc *sc, u32 dsrate)
-{
- int ret;
- u16 timeout;
-
- /* in bulk mode the modem have problem with high rate
- * changing internal timing could improve things, but the
- * value is mysterious.
- * ADI930 don't support it (-EPIPE error).
- */
-
- if (UEA_CHIP_VERSION(sc) == ADI930 ||
- altsetting[sc->modem_index] > 0 ||
- sc->stats.phy.dsrate == dsrate)
- return;
-
- /* Original timming (1Mbit/s) from ADI (used in windows driver) */
- timeout = (dsrate <= 1024*1024) ? 0 : 1;
- ret = uea_request(sc, UEA_SET_TIMEOUT, timeout, 0, NULL);
- uea_info(INS_TO_USBDEV(sc), "setting new timeout %d%s\n",
- timeout, ret < 0 ? " failed" : "");
-
-}
-
-/*
- * Monitor the modem and update the stat
- * return 0 if everything is ok
- * return < 0 if an error occurs (-EAGAIN reboot needed)
- */
-static int uea_stat_e1(struct uea_softc *sc)
-{
- u32 data;
- int ret;
-
- uea_enters(INS_TO_USBDEV(sc));
- data = sc->stats.phy.state;
-
- ret = uea_read_cmv_e1(sc, E1_SA_STAT, 0, &sc->stats.phy.state);
- if (ret < 0)
- return ret;
-
- switch (GET_STATUS(sc->stats.phy.state)) {
- case 0: /* not yet synchronized */
- uea_dbg(INS_TO_USBDEV(sc),
- "modem not yet synchronized\n");
- return 0;
-
- case 1: /* initialization */
- uea_dbg(INS_TO_USBDEV(sc), "modem initializing\n");
- return 0;
-
- case 2: /* operational */
- uea_vdbg(INS_TO_USBDEV(sc), "modem operational\n");
- break;
-
- case 3: /* fail ... */
- uea_info(INS_TO_USBDEV(sc), "modem synchronization failed"
- " (may be try other cmv/dsp)\n");
- return -EAGAIN;
-
- case 4 ... 6: /* test state */
- uea_warn(INS_TO_USBDEV(sc),
- "modem in test mode - not supported\n");
- return -EAGAIN;
-
- case 7: /* fast-retain ... */
- uea_info(INS_TO_USBDEV(sc), "modem in fast-retain mode\n");
- return 0;
- default:
- uea_err(INS_TO_USBDEV(sc), "modem invalid SW mode %d\n",
- GET_STATUS(sc->stats.phy.state));
- return -EAGAIN;
- }
-
- if (GET_STATUS(data) != 2) {
- uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_OFF, 0, NULL);
- uea_info(INS_TO_USBDEV(sc), "modem operational\n");
-
- /* release the dsp firmware as it is not needed until
- * the next failure
- */
- if (sc->dsp_firm) {
- release_firmware(sc->dsp_firm);
- sc->dsp_firm = NULL;
- }
- }
-
- /* always update it as atm layer could not be init when we switch to
- * operational state
- */
- UPDATE_ATM_SIGNAL(ATM_PHY_SIG_FOUND);
-
- /* wake up processes waiting for synchronization */
- wake_up(&sc->sync_q);
-
- ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 2, &sc->stats.phy.flags);
- if (ret < 0)
- return ret;
- sc->stats.phy.mflags |= sc->stats.phy.flags;
-
- /* in case of a flags ( for example delineation LOSS (& 0x10)),
- * we check the status again in order to detect the failure earlier
- */
- if (sc->stats.phy.flags) {
- uea_dbg(INS_TO_USBDEV(sc), "Stat flag = 0x%x\n",
- sc->stats.phy.flags);
- return 0;
- }
-
- ret = uea_read_cmv_e1(sc, E1_SA_RATE, 0, &data);
- if (ret < 0)
- return ret;
-
- uea_set_bulk_timeout(sc, (data >> 16) * 32);
- sc->stats.phy.dsrate = (data >> 16) * 32;
- sc->stats.phy.usrate = (data & 0xffff) * 32;
- UPDATE_ATM_STAT(link_rate, sc->stats.phy.dsrate * 1000 / 424);
-
- ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 23, &data);
- if (ret < 0)
- return ret;
- sc->stats.phy.dsattenuation = (data & 0xff) / 2;
-
- ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 47, &data);
- if (ret < 0)
- return ret;
- sc->stats.phy.usattenuation = (data & 0xff) / 2;
-
- ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 25, &sc->stats.phy.dsmargin);
- if (ret < 0)
- return ret;
-
- ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 49, &sc->stats.phy.usmargin);
- if (ret < 0)
- return ret;
-
- ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 51, &sc->stats.phy.rxflow);
- if (ret < 0)
- return ret;
-
- ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 52, &sc->stats.phy.txflow);
- if (ret < 0)
- return ret;
-
- ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 54, &sc->stats.phy.dsunc);
- if (ret < 0)
- return ret;
-
- /* only for atu-c */
- ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 58, &sc->stats.phy.usunc);
- if (ret < 0)
- return ret;
-
- ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 53, &sc->stats.phy.dscorr);
- if (ret < 0)
- return ret;
-
- /* only for atu-c */
- ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 57, &sc->stats.phy.uscorr);
- if (ret < 0)
- return ret;
-
- ret = uea_read_cmv_e1(sc, E1_SA_INFO, 8, &sc->stats.phy.vidco);
- if (ret < 0)
- return ret;
-
- ret = uea_read_cmv_e1(sc, E1_SA_INFO, 13, &sc->stats.phy.vidcpe);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-static int uea_stat_e4(struct uea_softc *sc)
-{
- u32 data;
- u32 tmp_arr[2];
- int ret;
-
- uea_enters(INS_TO_USBDEV(sc));
- data = sc->stats.phy.state;
-
- /* XXX only need to be done before operationnal... */
- ret = uea_read_cmv_e4(sc, 1, E4_SA_STAT, 0, 0, &sc->stats.phy.state);
- if (ret < 0)
- return ret;
-
- switch (sc->stats.phy.state) {
- case 0x0: /* not yet synchronized */
- case 0x1:
- case 0x3:
- case 0x4:
- uea_dbg(INS_TO_USBDEV(sc), "modem not yet "
- "synchronized\n");
- return 0;
- case 0x5: /* initialization */
- case 0x6:
- case 0x9:
- case 0xa:
- uea_dbg(INS_TO_USBDEV(sc), "modem initializing\n");
- return 0;
- case 0x2: /* fail ... */
- uea_info(INS_TO_USBDEV(sc), "modem synchronization "
- "failed (may be try other cmv/dsp)\n");
- return -EAGAIN;
- case 0x7: /* operational */
- break;
- default:
- uea_warn(INS_TO_USBDEV(sc), "unknown state: %x\n",
- sc->stats.phy.state);
- return 0;
- }
-
- if (data != 7) {
- uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_OFF, 0, NULL);
- uea_info(INS_TO_USBDEV(sc), "modem operational\n");
-
- /* release the dsp firmware as it is not needed until
- * the next failure
- */
- if (sc->dsp_firm) {
- release_firmware(sc->dsp_firm);
- sc->dsp_firm = NULL;
- }
- }
-
- /* always update it as atm layer could not be init when we switch to
- * operational state
- */
- UPDATE_ATM_SIGNAL(ATM_PHY_SIG_FOUND);
-
- /* wake up processes waiting for synchronization */
- wake_up(&sc->sync_q);
-
- /* TODO improve this state machine :
- * we need some CMV info : what they do and their unit
- * we should find the equivalent of eagle3- CMV
- */
- /* check flags */
- ret = uea_read_cmv_e4(sc, 1, E4_SA_DIAG, 0, 0, &sc->stats.phy.flags);
- if (ret < 0)
- return ret;
- sc->stats.phy.mflags |= sc->stats.phy.flags;
-
- /* in case of a flags ( for example delineation LOSS (& 0x10)),
- * we check the status again in order to detect the failure earlier
- */
- if (sc->stats.phy.flags) {
- uea_dbg(INS_TO_USBDEV(sc), "Stat flag = 0x%x\n",
- sc->stats.phy.flags);
- if (sc->stats.phy.flags & 1) /* delineation LOSS */
- return -EAGAIN;
- if (sc->stats.phy.flags & 0x4000) /* Reset Flag */
- return -EAGAIN;
- return 0;
- }
-
- /* rate data may be in upper or lower half of 64 bit word, strange */
- ret = uea_read_cmv_e4(sc, 4, E4_SA_RATE, 0, 0, tmp_arr);
- if (ret < 0)
- return ret;
- data = (tmp_arr[0]) ? tmp_arr[0] : tmp_arr[1];
- sc->stats.phy.usrate = data / 1000;
-
- ret = uea_read_cmv_e4(sc, 4, E4_SA_RATE, 1, 0, tmp_arr);
- if (ret < 0)
- return ret;
- data = (tmp_arr[0]) ? tmp_arr[0] : tmp_arr[1];
- uea_set_bulk_timeout(sc, data / 1000);
- sc->stats.phy.dsrate = data / 1000;
- UPDATE_ATM_STAT(link_rate, sc->stats.phy.dsrate * 1000 / 424);
-
- ret = uea_read_cmv_e4(sc, 1, E4_SA_INFO, 68, 1, &data);
- if (ret < 0)
- return ret;
- sc->stats.phy.dsattenuation = data / 10;
-
- ret = uea_read_cmv_e4(sc, 1, E4_SA_INFO, 69, 1, &data);
- if (ret < 0)
- return ret;
- sc->stats.phy.usattenuation = data / 10;
-
- ret = uea_read_cmv_e4(sc, 1, E4_SA_INFO, 68, 3, &data);
- if (ret < 0)
- return ret;
- sc->stats.phy.dsmargin = data / 2;
-
- ret = uea_read_cmv_e4(sc, 1, E4_SA_INFO, 69, 3, &data);
- if (ret < 0)
- return ret;
- sc->stats.phy.usmargin = data / 10;
-
- return 0;
-}
-
-static void cmvs_file_name(struct uea_softc *sc, char *const cmv_name, int ver)
-{
- char file_arr[] = "CMVxy.bin";
- char *file;
-
- kparam_block_sysfs_write(cmv_file);
- /* set proper name corresponding modem version and line type */
- if (cmv_file[sc->modem_index] == NULL) {
- if (UEA_CHIP_VERSION(sc) == ADI930)
- file_arr[3] = '9';
- else if (UEA_CHIP_VERSION(sc) == EAGLE_IV)
- file_arr[3] = '4';
- else
- file_arr[3] = 'e';
-
- file_arr[4] = IS_ISDN(sc) ? 'i' : 'p';
- file = file_arr;
- } else
- file = cmv_file[sc->modem_index];
-
- strcpy(cmv_name, FW_DIR);
- strlcat(cmv_name, file, UEA_FW_NAME_MAX);
- if (ver == 2)
- strlcat(cmv_name, ".v2", UEA_FW_NAME_MAX);
- kparam_unblock_sysfs_write(cmv_file);
-}
-
-static int request_cmvs_old(struct uea_softc *sc,
- void **cmvs, const struct firmware **fw)
-{
- int ret, size;
- u8 *data;
- char cmv_name[UEA_FW_NAME_MAX]; /* 30 bytes stack variable */
-
- cmvs_file_name(sc, cmv_name, 1);
- ret = request_firmware(fw, cmv_name, &sc->usb_dev->dev);
- if (ret < 0) {
- uea_err(INS_TO_USBDEV(sc),
- "requesting firmware %s failed with error %d\n",
- cmv_name, ret);
- return ret;
- }
-
- data = (u8 *) (*fw)->data;
- size = (*fw)->size;
- if (size < 1)
- goto err_fw_corrupted;
-
- if (size != *data * sizeof(struct uea_cmvs_v1) + 1)
- goto err_fw_corrupted;
-
- *cmvs = (void *)(data + 1);
- return *data;
-
-err_fw_corrupted:
- uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n", cmv_name);
- release_firmware(*fw);
- return -EILSEQ;
-}
-
-static int request_cmvs(struct uea_softc *sc,
- void **cmvs, const struct firmware **fw, int *ver)
-{
- int ret, size;
- u32 crc;
- u8 *data;
- char cmv_name[UEA_FW_NAME_MAX]; /* 30 bytes stack variable */
-
- cmvs_file_name(sc, cmv_name, 2);
- ret = request_firmware(fw, cmv_name, &sc->usb_dev->dev);
- if (ret < 0) {
- /* if caller can handle old version, try to provide it */
- if (*ver == 1) {
- uea_warn(INS_TO_USBDEV(sc), "requesting "
- "firmware %s failed, "
- "try to get older cmvs\n", cmv_name);
- return request_cmvs_old(sc, cmvs, fw);
- }
- uea_err(INS_TO_USBDEV(sc),
- "requesting firmware %s failed with error %d\n",
- cmv_name, ret);
- return ret;
- }
-
- size = (*fw)->size;
- data = (u8 *) (*fw)->data;
- if (size < 4 || strncmp(data, "cmv2", 4) != 0) {
- if (*ver == 1) {
- uea_warn(INS_TO_USBDEV(sc), "firmware %s is corrupted,"
- " try to get older cmvs\n", cmv_name);
- release_firmware(*fw);
- return request_cmvs_old(sc, cmvs, fw);
- }
- goto err_fw_corrupted;
- }
-
- *ver = 2;
-
- data += 4;
- size -= 4;
- if (size < 5)
- goto err_fw_corrupted;
-
- crc = get_unaligned_le32(data);
- data += 4;
- size -= 4;
- if (crc32_be(0, data, size) != crc)
- goto err_fw_corrupted;
-
- if (size != *data * sizeof(struct uea_cmvs_v2) + 1)
- goto err_fw_corrupted;
-
- *cmvs = (void *) (data + 1);
- return *data;
-
-err_fw_corrupted:
- uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n", cmv_name);
- release_firmware(*fw);
- return -EILSEQ;
-}
-
-static int uea_send_cmvs_e1(struct uea_softc *sc)
-{
- int i, ret, len;
- void *cmvs_ptr;
- const struct firmware *cmvs_fw;
- int ver = 1; /* we can handle v1 cmv firmware version; */
-
- /* Enter in R-IDLE (cmv) until instructed otherwise */
- ret = uea_write_cmv_e1(sc, E1_SA_CNTL, 0, 1);
- if (ret < 0)
- return ret;
-
- /* Dump firmware version */
- ret = uea_read_cmv_e1(sc, E1_SA_INFO, 10, &sc->stats.phy.firmid);
- if (ret < 0)
- return ret;
- uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n",
- sc->stats.phy.firmid);
-
- /* get options */
- ret = len = request_cmvs(sc, &cmvs_ptr, &cmvs_fw, &ver);
- if (ret < 0)
- return ret;
-
- /* send options */
- if (ver == 1) {
- struct uea_cmvs_v1 *cmvs_v1 = cmvs_ptr;
-
- uea_warn(INS_TO_USBDEV(sc), "use deprecated cmvs version, "
- "please update your firmware\n");
-
- for (i = 0; i < len; i++) {
- ret = uea_write_cmv_e1(sc,
- get_unaligned_le32(&cmvs_v1[i].address),
- get_unaligned_le16(&cmvs_v1[i].offset),
- get_unaligned_le32(&cmvs_v1[i].data));
- if (ret < 0)
- goto out;
- }
- } else if (ver == 2) {
- struct uea_cmvs_v2 *cmvs_v2 = cmvs_ptr;
-
- for (i = 0; i < len; i++) {
- ret = uea_write_cmv_e1(sc,
- get_unaligned_le32(&cmvs_v2[i].address),
- (u16) get_unaligned_le32(&cmvs_v2[i].offset),
- get_unaligned_le32(&cmvs_v2[i].data));
- if (ret < 0)
- goto out;
- }
- } else {
- /* This really should not happen */
- uea_err(INS_TO_USBDEV(sc), "bad cmvs version %d\n", ver);
- goto out;
- }
-
- /* Enter in R-ACT-REQ */
- ret = uea_write_cmv_e1(sc, E1_SA_CNTL, 0, 2);
- uea_vdbg(INS_TO_USBDEV(sc), "Entering in R-ACT-REQ state\n");
- uea_info(INS_TO_USBDEV(sc), "modem started, waiting "
- "synchronization...\n");
-out:
- release_firmware(cmvs_fw);
- return ret;
-}
-
-static int uea_send_cmvs_e4(struct uea_softc *sc)
-{
- int i, ret, len;
- void *cmvs_ptr;
- const struct firmware *cmvs_fw;
- int ver = 2; /* we can only handle v2 cmv firmware version; */
-
- /* Enter in R-IDLE (cmv) until instructed otherwise */
- ret = uea_write_cmv_e4(sc, 1, E4_SA_CNTL, 0, 0, 1);
- if (ret < 0)
- return ret;
-
- /* Dump firmware version */
- /* XXX don't read the 3th byte as it is always 6 */
- ret = uea_read_cmv_e4(sc, 2, E4_SA_INFO, 55, 0, &sc->stats.phy.firmid);
- if (ret < 0)
- return ret;
- uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n",
- sc->stats.phy.firmid);
-
-
- /* get options */
- ret = len = request_cmvs(sc, &cmvs_ptr, &cmvs_fw, &ver);
- if (ret < 0)
- return ret;
-
- /* send options */
- if (ver == 2) {
- struct uea_cmvs_v2 *cmvs_v2 = cmvs_ptr;
-
- for (i = 0; i < len; i++) {
- ret = uea_write_cmv_e4(sc, 1,
- get_unaligned_le32(&cmvs_v2[i].group),
- get_unaligned_le32(&cmvs_v2[i].address),
- get_unaligned_le32(&cmvs_v2[i].offset),
- get_unaligned_le32(&cmvs_v2[i].data));
- if (ret < 0)
- goto out;
- }
- } else {
- /* This really should not happen */
- uea_err(INS_TO_USBDEV(sc), "bad cmvs version %d\n", ver);
- goto out;
- }
-
- /* Enter in R-ACT-REQ */
- ret = uea_write_cmv_e4(sc, 1, E4_SA_CNTL, 0, 0, 2);
- uea_vdbg(INS_TO_USBDEV(sc), "Entering in R-ACT-REQ state\n");
- uea_info(INS_TO_USBDEV(sc), "modem started, waiting "
- "synchronization...\n");
-out:
- release_firmware(cmvs_fw);
- return ret;
-}
-
-/* Start boot post firmware modem:
- * - send reset commands through usb control pipe
- * - start workqueue for DSP loading
- * - send CMV options to modem
- */
-
-static int uea_start_reset(struct uea_softc *sc)
-{
- u16 zero = 0; /* ;-) */
- int ret;
-
- uea_enters(INS_TO_USBDEV(sc));
- uea_info(INS_TO_USBDEV(sc), "(re)booting started\n");
-
- /* mask interrupt */
- sc->booting = 1;
- /* We need to set this here because, a ack timeout could have occurred,
- * but before we start the reboot, the ack occurs and set this to 1.
- * So we will failed to wait Ready CMV.
- */
- sc->cmv_ack = 0;
- UPDATE_ATM_SIGNAL(ATM_PHY_SIG_LOST);
-
- /* reset statistics */
- memset(&sc->stats, 0, sizeof(struct uea_stats));
-
- /* tell the modem that we want to boot in IDMA mode */
- uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_ON, 0, NULL);
- uea_request(sc, UEA_SET_MODE, UEA_BOOT_IDMA, 0, NULL);
-
- /* enter reset mode */
- uea_request(sc, UEA_SET_MODE, UEA_START_RESET, 0, NULL);
-
- /* original driver use 200ms, but windows driver use 100ms */
- ret = uea_wait(sc, 0, msecs_to_jiffies(100));
- if (ret < 0)
- return ret;
-
- /* leave reset mode */
- uea_request(sc, UEA_SET_MODE, UEA_END_RESET, 0, NULL);
-
- if (UEA_CHIP_VERSION(sc) != EAGLE_IV) {
- /* clear tx and rx mailboxes */
- uea_request(sc, UEA_SET_2183_DATA, UEA_MPTX_MAILBOX, 2, &zero);
- uea_request(sc, UEA_SET_2183_DATA, UEA_MPRX_MAILBOX, 2, &zero);
- uea_request(sc, UEA_SET_2183_DATA, UEA_SWAP_MAILBOX, 2, &zero);
- }
-
- ret = uea_wait(sc, 0, msecs_to_jiffies(1000));
- if (ret < 0)
- return ret;
-
- if (UEA_CHIP_VERSION(sc) == EAGLE_IV)
- sc->cmv_dsc.e4.function = E4_MAKEFUNCTION(E4_ADSLDIRECTIVE,
- E4_MODEMREADY, 1);
- else
- sc->cmv_dsc.e1.function = E1_MAKEFUNCTION(E1_ADSLDIRECTIVE,
- E1_MODEMREADY);
-
- /* demask interrupt */
- sc->booting = 0;
-
- /* start loading DSP */
- sc->pageno = 0;
- sc->ovl = 0;
- schedule_work(&sc->task);
-
- /* wait for modem ready CMV */
- ret = wait_cmv_ack(sc);
- if (ret < 0)
- return ret;
-
- uea_vdbg(INS_TO_USBDEV(sc), "Ready CMV received\n");
-
- ret = sc->send_cmvs(sc);
- if (ret < 0)
- return ret;
-
- sc->reset = 0;
- uea_leaves(INS_TO_USBDEV(sc));
- return ret;
-}
-
-/*
- * In case of an error wait 1s before rebooting the modem
- * if the modem don't request reboot (-EAGAIN).
- * Monitor the modem every 1s.
- */
-
-static int uea_kthread(void *data)
-{
- struct uea_softc *sc = data;
- int ret = -EAGAIN;
-
- set_freezable();
- uea_enters(INS_TO_USBDEV(sc));
- while (!kthread_should_stop()) {
- if (ret < 0 || sc->reset)
- ret = uea_start_reset(sc);
- if (!ret)
- ret = sc->stat(sc);
- if (ret != -EAGAIN)
- uea_wait(sc, 0, msecs_to_jiffies(1000));
- try_to_freeze();
- }
- uea_leaves(INS_TO_USBDEV(sc));
- return ret;
-}
-
-/* Load second usb firmware for ADI930 chip */
-static int load_XILINX_firmware(struct uea_softc *sc)
-{
- const struct firmware *fw_entry;
- int ret, size, u, ln;
- const u8 *pfw;
- u8 value;
- char *fw_name = FW_DIR "930-fpga.bin";
-
- uea_enters(INS_TO_USBDEV(sc));
-
- ret = request_firmware(&fw_entry, fw_name, &sc->usb_dev->dev);
- if (ret) {
- uea_err(INS_TO_USBDEV(sc), "firmware %s is not available\n",
- fw_name);
- goto err0;
- }
-
- pfw = fw_entry->data;
- size = fw_entry->size;
- if (size != 0x577B) {
- uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n",
- fw_name);
- ret = -EILSEQ;
- goto err1;
- }
- for (u = 0; u < size; u += ln) {
- ln = min(size - u, 64);
- ret = uea_request(sc, 0xe, 0, ln, pfw + u);
- if (ret < 0) {
- uea_err(INS_TO_USBDEV(sc),
- "elsa download data failed (%d)\n", ret);
- goto err1;
- }
- }
-
- /* finish to send the fpga */
- ret = uea_request(sc, 0xe, 1, 0, NULL);
- if (ret < 0) {
- uea_err(INS_TO_USBDEV(sc),
- "elsa download data failed (%d)\n", ret);
- goto err1;
- }
-
- /* Tell the modem we finish : de-assert reset */
- value = 0;
- ret = uea_send_modem_cmd(sc->usb_dev, 0xe, 1, &value);
- if (ret < 0)
- uea_err(sc->usb_dev, "elsa de-assert failed with error"
- " %d\n", ret);
-
-err1:
- release_firmware(fw_entry);
-err0:
- uea_leaves(INS_TO_USBDEV(sc));
- return ret;
-}
-
-/* The modem send us an ack. First with check if it right */
-static void uea_dispatch_cmv_e1(struct uea_softc *sc, struct intr_pkt *intr)
-{
- struct cmv_dsc_e1 *dsc = &sc->cmv_dsc.e1;
- struct cmv_e1 *cmv = &intr->u.e1.s2.cmv;
-
- uea_enters(INS_TO_USBDEV(sc));
- if (le16_to_cpu(cmv->wPreamble) != E1_PREAMBLE)
- goto bad1;
-
- if (cmv->bDirection != E1_MODEMTOHOST)
- goto bad1;
-
- /* FIXME : ADI930 reply wrong preambule (func = 2, sub = 2) to
- * the first MEMACCESS cmv. Ignore it...
- */
- if (cmv->bFunction != dsc->function) {
- if (UEA_CHIP_VERSION(sc) == ADI930
- && cmv->bFunction == E1_MAKEFUNCTION(2, 2)) {
- cmv->wIndex = cpu_to_le16(dsc->idx);
- put_unaligned_le32(dsc->address,
- &cmv->dwSymbolicAddress);
- cmv->wOffsetAddress = cpu_to_le16(dsc->offset);
- } else
- goto bad2;
- }
-
- if (cmv->bFunction == E1_MAKEFUNCTION(E1_ADSLDIRECTIVE,
- E1_MODEMREADY)) {
- wake_up_cmv_ack(sc);
- uea_leaves(INS_TO_USBDEV(sc));
- return;
- }
-
- /* in case of MEMACCESS */
- if (le16_to_cpu(cmv->wIndex) != dsc->idx ||
- get_unaligned_le32(&cmv->dwSymbolicAddress) != dsc->address ||
- le16_to_cpu(cmv->wOffsetAddress) != dsc->offset)
- goto bad2;
-
- sc->data = get_unaligned_le32(&cmv->dwData);
- sc->data = sc->data << 16 | sc->data >> 16;
-
- wake_up_cmv_ack(sc);
- uea_leaves(INS_TO_USBDEV(sc));
- return;
-
-bad2:
- uea_err(INS_TO_USBDEV(sc), "unexpected cmv received, "
- "Function : %d, Subfunction : %d\n",
- E1_FUNCTION_TYPE(cmv->bFunction),
- E1_FUNCTION_SUBTYPE(cmv->bFunction));
- uea_leaves(INS_TO_USBDEV(sc));
- return;
-
-bad1:
- uea_err(INS_TO_USBDEV(sc), "invalid cmv received, "
- "wPreamble %d, bDirection %d\n",
- le16_to_cpu(cmv->wPreamble), cmv->bDirection);
- uea_leaves(INS_TO_USBDEV(sc));
-}
-
-/* The modem send us an ack. First with check if it right */
-static void uea_dispatch_cmv_e4(struct uea_softc *sc, struct intr_pkt *intr)
-{
- struct cmv_dsc_e4 *dsc = &sc->cmv_dsc.e4;
- struct cmv_e4 *cmv = &intr->u.e4.s2.cmv;
-
- uea_enters(INS_TO_USBDEV(sc));
- uea_dbg(INS_TO_USBDEV(sc), "cmv %x %x %x %x %x %x\n",
- be16_to_cpu(cmv->wGroup), be16_to_cpu(cmv->wFunction),
- be16_to_cpu(cmv->wOffset), be16_to_cpu(cmv->wAddress),
- be32_to_cpu(cmv->dwData[0]), be32_to_cpu(cmv->dwData[1]));
-
- if (be16_to_cpu(cmv->wFunction) != dsc->function)
- goto bad2;
-
- if (be16_to_cpu(cmv->wFunction) == E4_MAKEFUNCTION(E4_ADSLDIRECTIVE,
- E4_MODEMREADY, 1)) {
- wake_up_cmv_ack(sc);
- uea_leaves(INS_TO_USBDEV(sc));
- return;
- }
-
- /* in case of MEMACCESS */
- if (be16_to_cpu(cmv->wOffset) != dsc->offset ||
- be16_to_cpu(cmv->wGroup) != dsc->group ||
- be16_to_cpu(cmv->wAddress) != dsc->address)
- goto bad2;
-
- sc->data = be32_to_cpu(cmv->dwData[0]);
- sc->data1 = be32_to_cpu(cmv->dwData[1]);
- wake_up_cmv_ack(sc);
- uea_leaves(INS_TO_USBDEV(sc));
- return;
-
-bad2:
- uea_err(INS_TO_USBDEV(sc), "unexpected cmv received, "
- "Function : %d, Subfunction : %d\n",
- E4_FUNCTION_TYPE(cmv->wFunction),
- E4_FUNCTION_SUBTYPE(cmv->wFunction));
- uea_leaves(INS_TO_USBDEV(sc));
- return;
-}
-
-static void uea_schedule_load_page_e1(struct uea_softc *sc,
- struct intr_pkt *intr)
-{
- sc->pageno = intr->e1_bSwapPageNo;
- sc->ovl = intr->e1_bOvl >> 4 | intr->e1_bOvl << 4;
- schedule_work(&sc->task);
-}
-
-static void uea_schedule_load_page_e4(struct uea_softc *sc,
- struct intr_pkt *intr)
-{
- sc->pageno = intr->e4_bSwapPageNo;
- schedule_work(&sc->task);
-}
-
-/*
- * interrupt handler
- */
-static void uea_intr(struct urb *urb)
-{
- struct uea_softc *sc = urb->context;
- struct intr_pkt *intr = urb->transfer_buffer;
- int status = urb->status;
-
- uea_enters(INS_TO_USBDEV(sc));
-
- if (unlikely(status < 0)) {
- uea_err(INS_TO_USBDEV(sc), "uea_intr() failed with %d\n",
- status);
- return;
- }
-
- /* device-to-host interrupt */
- if (intr->bType != 0x08 || sc->booting) {
- uea_err(INS_TO_USBDEV(sc), "wrong interrupt\n");
- goto resubmit;
- }
-
- switch (le16_to_cpu(intr->wInterrupt)) {
- case INT_LOADSWAPPAGE:
- sc->schedule_load_page(sc, intr);
- break;
-
- case INT_INCOMINGCMV:
- sc->dispatch_cmv(sc, intr);
- break;
-
- default:
- uea_err(INS_TO_USBDEV(sc), "unknown interrupt %u\n",
- le16_to_cpu(intr->wInterrupt));
- }
-
-resubmit:
- usb_submit_urb(sc->urb_int, GFP_ATOMIC);
-}
-
-/*
- * Start the modem : init the data and start kernel thread
- */
-static int uea_boot(struct uea_softc *sc)
-{
- int ret, size;
- struct intr_pkt *intr;
-
- uea_enters(INS_TO_USBDEV(sc));
-
- if (UEA_CHIP_VERSION(sc) == EAGLE_IV) {
- size = E4_INTR_PKT_SIZE;
- sc->dispatch_cmv = uea_dispatch_cmv_e4;
- sc->schedule_load_page = uea_schedule_load_page_e4;
- sc->stat = uea_stat_e4;
- sc->send_cmvs = uea_send_cmvs_e4;
- INIT_WORK(&sc->task, uea_load_page_e4);
- } else {
- size = E1_INTR_PKT_SIZE;
- sc->dispatch_cmv = uea_dispatch_cmv_e1;
- sc->schedule_load_page = uea_schedule_load_page_e1;
- sc->stat = uea_stat_e1;
- sc->send_cmvs = uea_send_cmvs_e1;
- INIT_WORK(&sc->task, uea_load_page_e1);
- }
-
- init_waitqueue_head(&sc->sync_q);
-
- if (UEA_CHIP_VERSION(sc) == ADI930)
- load_XILINX_firmware(sc);
-
- intr = kmalloc(size, GFP_KERNEL);
- if (!intr) {
- uea_err(INS_TO_USBDEV(sc),
- "cannot allocate interrupt package\n");
- goto err0;
- }
-
- sc->urb_int = usb_alloc_urb(0, GFP_KERNEL);
- if (!sc->urb_int) {
- uea_err(INS_TO_USBDEV(sc), "cannot allocate interrupt URB\n");
- goto err1;
- }
-
- usb_fill_int_urb(sc->urb_int, sc->usb_dev,
- usb_rcvintpipe(sc->usb_dev, UEA_INTR_PIPE),
- intr, size, uea_intr, sc,
- sc->usb_dev->actconfig->interface[0]->altsetting[0].
- endpoint[0].desc.bInterval);
-
- ret = usb_submit_urb(sc->urb_int, GFP_KERNEL);
- if (ret < 0) {
- uea_err(INS_TO_USBDEV(sc),
- "urb submition failed with error %d\n", ret);
- goto err1;
- }
-
- /* Create worker thread, but don't start it here. Start it after
- * all usbatm generic initialization is done.
- */
- sc->kthread = kthread_create(uea_kthread, sc, "ueagle-atm");
- if (IS_ERR(sc->kthread)) {
- uea_err(INS_TO_USBDEV(sc), "failed to create thread\n");
- goto err2;
- }
-
- uea_leaves(INS_TO_USBDEV(sc));
- return 0;
-
-err2:
- usb_kill_urb(sc->urb_int);
-err1:
- usb_free_urb(sc->urb_int);
- sc->urb_int = NULL;
- kfree(intr);
-err0:
- uea_leaves(INS_TO_USBDEV(sc));
- return -ENOMEM;
-}
-
-/*
- * Stop the modem : kill kernel thread and free data
- */
-static void uea_stop(struct uea_softc *sc)
-{
- int ret;
- uea_enters(INS_TO_USBDEV(sc));
- ret = kthread_stop(sc->kthread);
- uea_dbg(INS_TO_USBDEV(sc), "kthread finish with status %d\n", ret);
-
- uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_ON, 0, NULL);
-
- usb_kill_urb(sc->urb_int);
- kfree(sc->urb_int->transfer_buffer);
- usb_free_urb(sc->urb_int);
-
- /* flush the work item, when no one can schedule it */
- flush_work_sync(&sc->task);
-
- if (sc->dsp_firm)
- release_firmware(sc->dsp_firm);
- uea_leaves(INS_TO_USBDEV(sc));
-}
-
-/* syfs interface */
-static struct uea_softc *dev_to_uea(struct device *dev)
-{
- struct usb_interface *intf;
- struct usbatm_data *usbatm;
-
- intf = to_usb_interface(dev);
- if (!intf)
- return NULL;
-
- usbatm = usb_get_intfdata(intf);
- if (!usbatm)
- return NULL;
-
- return usbatm->driver_data;
-}
-
-static ssize_t read_status(struct device *dev, struct device_attribute *attr,
- char *buf)
-{
- int ret = -ENODEV;
- struct uea_softc *sc;
-
- mutex_lock(&uea_mutex);
- sc = dev_to_uea(dev);
- if (!sc)
- goto out;
- ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.state);
-out:
- mutex_unlock(&uea_mutex);
- return ret;
-}
-
-static ssize_t reboot(struct device *dev, struct device_attribute *attr,
- const char *buf, size_t count)
-{
- int ret = -ENODEV;
- struct uea_softc *sc;
-
- mutex_lock(&uea_mutex);
- sc = dev_to_uea(dev);
- if (!sc)
- goto out;
- sc->reset = 1;
- ret = count;
-out:
- mutex_unlock(&uea_mutex);
- return ret;
-}
-
-static DEVICE_ATTR(stat_status, S_IWUSR | S_IRUGO, read_status, reboot);
-
-static ssize_t read_human_status(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- int ret = -ENODEV;
- int modem_state;
- struct uea_softc *sc;
-
- mutex_lock(&uea_mutex);
- sc = dev_to_uea(dev);
- if (!sc)
- goto out;
-
- if (UEA_CHIP_VERSION(sc) == EAGLE_IV) {
- switch (sc->stats.phy.state) {
- case 0x0: /* not yet synchronized */
- case 0x1:
- case 0x3:
- case 0x4:
- modem_state = 0;
- break;
- case 0x5: /* initialization */
- case 0x6:
- case 0x9:
- case 0xa:
- modem_state = 1;
- break;
- case 0x7: /* operational */
- modem_state = 2;
- break;
- case 0x2: /* fail ... */
- modem_state = 3;
- break;
- default: /* unknown */
- modem_state = 4;
- break;
- }
- } else
- modem_state = GET_STATUS(sc->stats.phy.state);
-
- switch (modem_state) {
- case 0:
- ret = sprintf(buf, "Modem is booting\n");
- break;
- case 1:
- ret = sprintf(buf, "Modem is initializing\n");
- break;
- case 2:
- ret = sprintf(buf, "Modem is operational\n");
- break;
- case 3:
- ret = sprintf(buf, "Modem synchronization failed\n");
- break;
- default:
- ret = sprintf(buf, "Modem state is unknown\n");
- break;
- }
-out:
- mutex_unlock(&uea_mutex);
- return ret;
-}
-
-static DEVICE_ATTR(stat_human_status, S_IRUGO, read_human_status, NULL);
-
-static ssize_t read_delin(struct device *dev, struct device_attribute *attr,
- char *buf)
-{
- int ret = -ENODEV;
- struct uea_softc *sc;
- char *delin = "GOOD";
-
- mutex_lock(&uea_mutex);
- sc = dev_to_uea(dev);
- if (!sc)
- goto out;
-
- if (UEA_CHIP_VERSION(sc) == EAGLE_IV) {
- if (sc->stats.phy.flags & 0x4000)
- delin = "RESET";
- else if (sc->stats.phy.flags & 0x0001)
- delin = "LOSS";
- } else {
- if (sc->stats.phy.flags & 0x0C00)
- delin = "ERROR";
- else if (sc->stats.phy.flags & 0x0030)
- delin = "LOSS";
- }
-
- ret = sprintf(buf, "%s\n", delin);
-out:
- mutex_unlock(&uea_mutex);
- return ret;
-}
-
-static DEVICE_ATTR(stat_delin, S_IRUGO, read_delin, NULL);
-
-#define UEA_ATTR(name, reset) \
- \
-static ssize_t read_##name(struct device *dev, \
- struct device_attribute *attr, char *buf) \
-{ \
- int ret = -ENODEV; \
- struct uea_softc *sc; \
- \
- mutex_lock(&uea_mutex); \
- sc = dev_to_uea(dev); \
- if (!sc) \
- goto out; \
- ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.name); \
- if (reset) \
- sc->stats.phy.name = 0; \
-out: \
- mutex_unlock(&uea_mutex); \
- return ret; \
-} \
- \
-static DEVICE_ATTR(stat_##name, S_IRUGO, read_##name, NULL)
-
-UEA_ATTR(mflags, 1);
-UEA_ATTR(vidcpe, 0);
-UEA_ATTR(usrate, 0);
-UEA_ATTR(dsrate, 0);
-UEA_ATTR(usattenuation, 0);
-UEA_ATTR(dsattenuation, 0);
-UEA_ATTR(usmargin, 0);
-UEA_ATTR(dsmargin, 0);
-UEA_ATTR(txflow, 0);
-UEA_ATTR(rxflow, 0);
-UEA_ATTR(uscorr, 0);
-UEA_ATTR(dscorr, 0);
-UEA_ATTR(usunc, 0);
-UEA_ATTR(dsunc, 0);
-UEA_ATTR(firmid, 0);
-
-/* Retrieve the device End System Identifier (MAC) */
-
-static int uea_getesi(struct uea_softc *sc, u_char * esi)
-{
- unsigned char mac_str[2 * ETH_ALEN + 1];
- int i;
- if (usb_string
- (sc->usb_dev, sc->usb_dev->descriptor.iSerialNumber, mac_str,
- sizeof(mac_str)) != 2 * ETH_ALEN)
- return 1;
-
- for (i = 0; i < ETH_ALEN; i++)
- esi[i] = hex_to_bin(mac_str[2 * i]) * 16 +
- hex_to_bin(mac_str[2 * i + 1]);
-
- return 0;
-}
-
-/* ATM stuff */
-static int uea_atm_open(struct usbatm_data *usbatm, struct atm_dev *atm_dev)
-{
- struct uea_softc *sc = usbatm->driver_data;
-
- return uea_getesi(sc, atm_dev->esi);
-}
-
-static int uea_heavy(struct usbatm_data *usbatm, struct usb_interface *intf)
-{
- struct uea_softc *sc = usbatm->driver_data;
-
- wait_event_interruptible(sc->sync_q, IS_OPERATIONAL(sc));
-
- return 0;
-
-}
-
-static int claim_interface(struct usb_device *usb_dev,
- struct usbatm_data *usbatm, int ifnum)
-{
- int ret;
- struct usb_interface *intf = usb_ifnum_to_if(usb_dev, ifnum);
-
- if (!intf) {
- uea_err(usb_dev, "interface %d not found\n", ifnum);
- return -ENODEV;
- }
-
- ret = usb_driver_claim_interface(&uea_driver, intf, usbatm);
- if (ret != 0)
- uea_err(usb_dev, "can't claim interface %d, error %d\n", ifnum,
- ret);
- return ret;
-}
-
-static struct attribute *attrs[] = {
- &dev_attr_stat_status.attr,
- &dev_attr_stat_mflags.attr,
- &dev_attr_stat_human_status.attr,
- &dev_attr_stat_delin.attr,
- &dev_attr_stat_vidcpe.attr,
- &dev_attr_stat_usrate.attr,
- &dev_attr_stat_dsrate.attr,
- &dev_attr_stat_usattenuation.attr,
- &dev_attr_stat_dsattenuation.attr,
- &dev_attr_stat_usmargin.attr,
- &dev_attr_stat_dsmargin.attr,
- &dev_attr_stat_txflow.attr,
- &dev_attr_stat_rxflow.attr,
- &dev_attr_stat_uscorr.attr,
- &dev_attr_stat_dscorr.attr,
- &dev_attr_stat_usunc.attr,
- &dev_attr_stat_dsunc.attr,
- &dev_attr_stat_firmid.attr,
- NULL,
-};
-static struct attribute_group attr_grp = {
- .attrs = attrs,
-};
-
-static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- struct usb_device *usb = interface_to_usbdev(intf);
- struct uea_softc *sc;
- int ret, ifnum = intf->altsetting->desc.bInterfaceNumber;
- unsigned int alt;
-
- uea_enters(usb);
-
- /* interface 0 is for firmware/monitoring */
- if (ifnum != UEA_INTR_IFACE_NO)
- return -ENODEV;
-
- usbatm->flags = (sync_wait[modem_index] ? 0 : UDSL_SKIP_HEAVY_INIT);
-
- /* interface 1 is for outbound traffic */
- ret = claim_interface(usb, usbatm, UEA_US_IFACE_NO);
- if (ret < 0)
- return ret;
-
- /* ADI930 has only 2 interfaces and inbound traffic is on interface 1 */
- if (UEA_CHIP_VERSION(id) != ADI930) {
- /* interface 2 is for inbound traffic */
- ret = claim_interface(usb, usbatm, UEA_DS_IFACE_NO);
- if (ret < 0)
- return ret;
- }
-
- sc = kzalloc(sizeof(struct uea_softc), GFP_KERNEL);
- if (!sc) {
- uea_err(usb, "uea_init: not enough memory !\n");
- return -ENOMEM;
- }
-
- sc->usb_dev = usb;
- usbatm->driver_data = sc;
- sc->usbatm = usbatm;
- sc->modem_index = (modem_index < NB_MODEM) ? modem_index++ : 0;
- sc->driver_info = id->driver_info;
-
- /* first try to use module parameter */
- if (annex[sc->modem_index] == 1)
- sc->annex = ANNEXA;
- else if (annex[sc->modem_index] == 2)
- sc->annex = ANNEXB;
- /* try to autodetect annex */
- else if (sc->driver_info & AUTO_ANNEX_A)
- sc->annex = ANNEXA;
- else if (sc->driver_info & AUTO_ANNEX_B)
- sc->annex = ANNEXB;
- else
- sc->annex = (le16_to_cpu
- (sc->usb_dev->descriptor.bcdDevice) & 0x80) ? ANNEXB : ANNEXA;
-
- alt = altsetting[sc->modem_index];
- /* ADI930 don't support iso */
- if (UEA_CHIP_VERSION(id) != ADI930 && alt > 0) {
- if (alt <= 8 &&
- usb_set_interface(usb, UEA_DS_IFACE_NO, alt) == 0) {
- uea_dbg(usb, "set alternate %u for 2 interface\n", alt);
- uea_info(usb, "using iso mode\n");
- usbatm->flags |= UDSL_USE_ISOC | UDSL_IGNORE_EILSEQ;
- } else {
- uea_err(usb, "setting alternate %u failed for "
- "2 interface, using bulk mode\n", alt);
- }
- }
-
- ret = sysfs_create_group(&intf->dev.kobj, &attr_grp);
- if (ret < 0)
- goto error;
-
- ret = uea_boot(sc);
- if (ret < 0)
- goto error_rm_grp;
-
- return 0;
-
-error_rm_grp:
- sysfs_remove_group(&intf->dev.kobj, &attr_grp);
-error:
- kfree(sc);
- return ret;
-}
-
-static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf)
-{
- struct uea_softc *sc = usbatm->driver_data;
-
- sysfs_remove_group(&intf->dev.kobj, &attr_grp);
- uea_stop(sc);
- kfree(sc);
-}
-
-static struct usbatm_driver uea_usbatm_driver = {
- .driver_name = "ueagle-atm",
- .bind = uea_bind,
- .atm_start = uea_atm_open,
- .unbind = uea_unbind,
- .heavy_init = uea_heavy,
- .bulk_in = UEA_BULK_DATA_PIPE,
- .bulk_out = UEA_BULK_DATA_PIPE,
- .isoc_in = UEA_ISO_DATA_PIPE,
-};
-
-static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)
-{
- struct usb_device *usb = interface_to_usbdev(intf);
- int ret;
-
- uea_enters(usb);
- uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) Rev (%#X): %s\n",
- le16_to_cpu(usb->descriptor.idVendor),
- le16_to_cpu(usb->descriptor.idProduct),
- le16_to_cpu(usb->descriptor.bcdDevice),
- chip_name[UEA_CHIP_VERSION(id)]);
-
- usb_reset_device(usb);
-
- if (UEA_IS_PREFIRM(id))
- return uea_load_firmware(usb, UEA_CHIP_VERSION(id));
-
- ret = usbatm_usb_probe(intf, id, &uea_usbatm_driver);
- if (ret == 0) {
- struct usbatm_data *usbatm = usb_get_intfdata(intf);
- struct uea_softc *sc = usbatm->driver_data;
-
- /* Ensure carrier is initialized to off as early as possible */
- UPDATE_ATM_SIGNAL(ATM_PHY_SIG_LOST);
-
- /* Only start the worker thread when all init is done */
- wake_up_process(sc->kthread);
- }
-
- return ret;
-}
-
-static void uea_disconnect(struct usb_interface *intf)
-{
- struct usb_device *usb = interface_to_usbdev(intf);
- int ifnum = intf->altsetting->desc.bInterfaceNumber;
- uea_enters(usb);
-
- /* ADI930 has 2 interfaces and eagle 3 interfaces.
- * Pre-firmware device has one interface
- */
- if (usb->config->desc.bNumInterfaces != 1 && ifnum == 0) {
- mutex_lock(&uea_mutex);
- usbatm_usb_disconnect(intf);
- mutex_unlock(&uea_mutex);
- uea_info(usb, "ADSL device removed\n");
- }
-
- uea_leaves(usb);
-}
-
-/*
- * List of supported VID/PID
- */
-static const struct usb_device_id uea_ids[] = {
- {USB_DEVICE(ANALOG_VID, ADI930_PID_PREFIRM),
- .driver_info = ADI930 | PREFIRM},
- {USB_DEVICE(ANALOG_VID, ADI930_PID_PSTFIRM),
- .driver_info = ADI930 | PSTFIRM},
- {USB_DEVICE(ANALOG_VID, EAGLE_I_PID_PREFIRM),
- .driver_info = EAGLE_I | PREFIRM},
- {USB_DEVICE(ANALOG_VID, EAGLE_I_PID_PSTFIRM),
- .driver_info = EAGLE_I | PSTFIRM},
- {USB_DEVICE(ANALOG_VID, EAGLE_II_PID_PREFIRM),
- .driver_info = EAGLE_II | PREFIRM},
- {USB_DEVICE(ANALOG_VID, EAGLE_II_PID_PSTFIRM),
- .driver_info = EAGLE_II | PSTFIRM},
- {USB_DEVICE(ANALOG_VID, EAGLE_IIC_PID_PREFIRM),
- .driver_info = EAGLE_II | PREFIRM},
- {USB_DEVICE(ANALOG_VID, EAGLE_IIC_PID_PSTFIRM),
- .driver_info = EAGLE_II | PSTFIRM},
- {USB_DEVICE(ANALOG_VID, EAGLE_III_PID_PREFIRM),
- .driver_info = EAGLE_III | PREFIRM},
- {USB_DEVICE(ANALOG_VID, EAGLE_III_PID_PSTFIRM),
- .driver_info = EAGLE_III | PSTFIRM},
- {USB_DEVICE(ANALOG_VID, EAGLE_IV_PID_PREFIRM),
- .driver_info = EAGLE_IV | PREFIRM},
- {USB_DEVICE(ANALOG_VID, EAGLE_IV_PID_PSTFIRM),
- .driver_info = EAGLE_IV | PSTFIRM},
- {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_I_A_PID_PREFIRM),
- .driver_info = EAGLE_I | PREFIRM},
- {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_I_A_PID_PSTFIRM),
- .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_A},
- {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_I_B_PID_PREFIRM),
- .driver_info = EAGLE_I | PREFIRM},
- {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_I_B_PID_PSTFIRM),
- .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_B},
- {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_II_A_PID_PREFIRM),
- .driver_info = EAGLE_II | PREFIRM},
- {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_II_A_PID_PSTFIRM),
- .driver_info = EAGLE_II | PSTFIRM | AUTO_ANNEX_A},
- {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_II_B_PID_PREFIRM),
- .driver_info = EAGLE_II | PREFIRM},
- {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_II_B_PID_PSTFIRM),
- .driver_info = EAGLE_II | PSTFIRM | AUTO_ANNEX_B},
- {USB_DEVICE(ELSA_VID, ELSA_PID_PREFIRM),
- .driver_info = ADI930 | PREFIRM},
- {USB_DEVICE(ELSA_VID, ELSA_PID_PSTFIRM),
- .driver_info = ADI930 | PSTFIRM},
- {USB_DEVICE(ELSA_VID, ELSA_PID_A_PREFIRM),
- .driver_info = ADI930 | PREFIRM},
- {USB_DEVICE(ELSA_VID, ELSA_PID_A_PSTFIRM),
- .driver_info = ADI930 | PSTFIRM | AUTO_ANNEX_A},
- {USB_DEVICE(ELSA_VID, ELSA_PID_B_PREFIRM),
- .driver_info = ADI930 | PREFIRM},
- {USB_DEVICE(ELSA_VID, ELSA_PID_B_PSTFIRM),
- .driver_info = ADI930 | PSTFIRM | AUTO_ANNEX_B},
- {USB_DEVICE(USR_VID, MILLER_A_PID_PREFIRM),
- .driver_info = EAGLE_I | PREFIRM},
- {USB_DEVICE(USR_VID, MILLER_A_PID_PSTFIRM),
- .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_A},
- {USB_DEVICE(USR_VID, MILLER_B_PID_PREFIRM),
- .driver_info = EAGLE_I | PREFIRM},
- {USB_DEVICE(USR_VID, MILLER_B_PID_PSTFIRM),
- .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_B},
- {USB_DEVICE(USR_VID, HEINEKEN_A_PID_PREFIRM),
- .driver_info = EAGLE_I | PREFIRM},
- {USB_DEVICE(USR_VID, HEINEKEN_A_PID_PSTFIRM),
- .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_A},
- {USB_DEVICE(USR_VID, HEINEKEN_B_PID_PREFIRM),
- .driver_info = EAGLE_I | PREFIRM},
- {USB_DEVICE(USR_VID, HEINEKEN_B_PID_PSTFIRM),
- .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_B},
- {}
-};
-
-/*
- * USB driver descriptor
- */
-static struct usb_driver uea_driver = {
- .name = "ueagle-atm",
- .id_table = uea_ids,
- .probe = uea_probe,
- .disconnect = uea_disconnect,
-};
-
-MODULE_DEVICE_TABLE(usb, uea_ids);
-
-module_usb_driver(uea_driver);
-
-MODULE_AUTHOR("Damien Bergamini/Matthieu Castet/Stanislaw W. Gruszka");
-MODULE_DESCRIPTION("ADI 930/Eagle USB ADSL Modem driver");
-MODULE_LICENSE("Dual BSD/GPL");
diff --git a/ANDROID_3.4.5/drivers/usb/atm/usbatm.c b/ANDROID_3.4.5/drivers/usb/atm/usbatm.c
deleted file mode 100644
index d3448ca1..00000000
--- a/ANDROID_3.4.5/drivers/usb/atm/usbatm.c
+++ /dev/null
@@ -1,1388 +0,0 @@
-/******************************************************************************
- * usbatm.c - Generic USB xDSL driver core
- *
- * Copyright (C) 2001, Alcatel
- * Copyright (C) 2003, Duncan Sands, SolNegro, Josep Comas
- * Copyright (C) 2004, David Woodhouse, Roman Kagan
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- ******************************************************************************/
-
-/*
- * Written by Johan Verrept, Duncan Sands (duncan.sands@free.fr) and David Woodhouse
- *
- * 1.7+: - See the check-in logs
- *
- * 1.6: - No longer opens a connection if the firmware is not loaded
- * - Added support for the speedtouch 330
- * - Removed the limit on the number of devices
- * - Module now autoloads on device plugin
- * - Merged relevant parts of sarlib
- * - Replaced the kernel thread with a tasklet
- * - New packet transmission code
- * - Changed proc file contents
- * - Fixed all known SMP races
- * - Many fixes and cleanups
- * - Various fixes by Oliver Neukum (oliver@neukum.name)
- *
- * 1.5A: - Version for inclusion in 2.5 series kernel
- * - Modifications by Richard Purdie (rpurdie@rpsys.net)
- * - made compatible with kernel 2.5.6 onwards by changing
- * usbatm_usb_send_data_context->urb to a pointer and adding code
- * to alloc and free it
- * - remove_wait_queue() added to usbatm_atm_processqueue_thread()
- *
- * 1.5: - fixed memory leak when atmsar_decode_aal5 returned NULL.
- * (reported by stephen.robinson@zen.co.uk)
- *
- * 1.4: - changed the spin_lock() under interrupt to spin_lock_irqsave()
- * - unlink all active send urbs of a vcc that is being closed.
- *
- * 1.3.1: - added the version number
- *
- * 1.3: - Added multiple send urb support
- * - fixed memory leak and vcc->tx_inuse starvation bug
- * when not enough memory left in vcc.
- *
- * 1.2: - Fixed race condition in usbatm_usb_send_data()
- * 1.1: - Turned off packet debugging
- *
- */
-
-#include "usbatm.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#ifdef VERBOSE_DEBUG
-static int usbatm_print_packet(const unsigned char *data, int len);
-#define PACKETDEBUG(arg...) usbatm_print_packet(arg)
-#define vdbg(arg...) dbg(arg)
-#else
-#define PACKETDEBUG(arg...)
-#define vdbg(arg...)
-#endif
-
-#define DRIVER_AUTHOR "Johan Verrept, Duncan Sands "
-#define DRIVER_VERSION "1.10"
-#define DRIVER_DESC "Generic USB ATM/DSL I/O, version " DRIVER_VERSION
-
-static const char usbatm_driver_name[] = "usbatm";
-
-#define UDSL_MAX_RCV_URBS 16
-#define UDSL_MAX_SND_URBS 16
-#define UDSL_MAX_BUF_SIZE 65536
-#define UDSL_DEFAULT_RCV_URBS 4
-#define UDSL_DEFAULT_SND_URBS 4
-#define UDSL_DEFAULT_RCV_BUF_SIZE 3392 /* 64 * ATM_CELL_SIZE */
-#define UDSL_DEFAULT_SND_BUF_SIZE 3392 /* 64 * ATM_CELL_SIZE */
-
-#define ATM_CELL_HEADER (ATM_CELL_SIZE - ATM_CELL_PAYLOAD)
-
-#define THROTTLE_MSECS 100 /* delay to recover processing after urb submission fails */
-
-static unsigned int num_rcv_urbs = UDSL_DEFAULT_RCV_URBS;
-static unsigned int num_snd_urbs = UDSL_DEFAULT_SND_URBS;
-static unsigned int rcv_buf_bytes = UDSL_DEFAULT_RCV_BUF_SIZE;
-static unsigned int snd_buf_bytes = UDSL_DEFAULT_SND_BUF_SIZE;
-
-module_param(num_rcv_urbs, uint, S_IRUGO);
-MODULE_PARM_DESC(num_rcv_urbs,
- "Number of urbs used for reception (range: 0-"
- __MODULE_STRING(UDSL_MAX_RCV_URBS) ", default: "
- __MODULE_STRING(UDSL_DEFAULT_RCV_URBS) ")");
-
-module_param(num_snd_urbs, uint, S_IRUGO);
-MODULE_PARM_DESC(num_snd_urbs,
- "Number of urbs used for transmission (range: 0-"
- __MODULE_STRING(UDSL_MAX_SND_URBS) ", default: "
- __MODULE_STRING(UDSL_DEFAULT_SND_URBS) ")");
-
-module_param(rcv_buf_bytes, uint, S_IRUGO);
-MODULE_PARM_DESC(rcv_buf_bytes,
- "Size of the buffers used for reception, in bytes (range: 1-"
- __MODULE_STRING(UDSL_MAX_BUF_SIZE) ", default: "
- __MODULE_STRING(UDSL_DEFAULT_RCV_BUF_SIZE) ")");
-
-module_param(snd_buf_bytes, uint, S_IRUGO);
-MODULE_PARM_DESC(snd_buf_bytes,
- "Size of the buffers used for transmission, in bytes (range: 1-"
- __MODULE_STRING(UDSL_MAX_BUF_SIZE) ", default: "
- __MODULE_STRING(UDSL_DEFAULT_SND_BUF_SIZE) ")");
-
-
-/* receive */
-
-struct usbatm_vcc_data {
- /* vpi/vci lookup */
- struct list_head list;
- short vpi;
- int vci;
- struct atm_vcc *vcc;
-
- /* raw cell reassembly */
- struct sk_buff *sarb;
-};
-
-
-/* send */
-
-struct usbatm_control {
- struct atm_skb_data atm;
- u32 len;
- u32 crc;
-};
-
-#define UDSL_SKB(x) ((struct usbatm_control *)(x)->cb)
-
-
-/* ATM */
-
-static void usbatm_atm_dev_close(struct atm_dev *atm_dev);
-static int usbatm_atm_open(struct atm_vcc *vcc);
-static void usbatm_atm_close(struct atm_vcc *vcc);
-static int usbatm_atm_ioctl(struct atm_dev *atm_dev, unsigned int cmd, void __user * arg);
-static int usbatm_atm_send(struct atm_vcc *vcc, struct sk_buff *skb);
-static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *page);
-
-static struct atmdev_ops usbatm_atm_devops = {
- .dev_close = usbatm_atm_dev_close,
- .open = usbatm_atm_open,
- .close = usbatm_atm_close,
- .ioctl = usbatm_atm_ioctl,
- .send = usbatm_atm_send,
- .proc_read = usbatm_atm_proc_read,
- .owner = THIS_MODULE,
-};
-
-
-/***********
-** misc **
-***********/
-
-static inline unsigned int usbatm_pdu_length(unsigned int length)
-{
- length += ATM_CELL_PAYLOAD - 1 + ATM_AAL5_TRAILER;
- return length - length % ATM_CELL_PAYLOAD;
-}
-
-static inline void usbatm_pop(struct atm_vcc *vcc, struct sk_buff *skb)
-{
- if (vcc->pop)
- vcc->pop(vcc, skb);
- else
- dev_kfree_skb_any(skb);
-}
-
-
-/***********
-** urbs **
-************/
-
-static struct urb *usbatm_pop_urb(struct usbatm_channel *channel)
-{
- struct urb *urb;
-
- spin_lock_irq(&channel->lock);
- if (list_empty(&channel->list)) {
- spin_unlock_irq(&channel->lock);
- return NULL;
- }
-
- urb = list_entry(channel->list.next, struct urb, urb_list);
- list_del(&urb->urb_list);
- spin_unlock_irq(&channel->lock);
-
- return urb;
-}
-
-static int usbatm_submit_urb(struct urb *urb)
-{
- struct usbatm_channel *channel = urb->context;
- int ret;
-
- vdbg("%s: submitting urb 0x%p, size %u",
- __func__, urb, urb->transfer_buffer_length);
-
- ret = usb_submit_urb(urb, GFP_ATOMIC);
- if (ret) {
- if (printk_ratelimit())
- atm_warn(channel->usbatm, "%s: urb 0x%p submission failed (%d)!\n",
- __func__, urb, ret);
-
- /* consider all errors transient and return the buffer back to the queue */
- urb->status = -EAGAIN;
- spin_lock_irq(&channel->lock);
-
- /* must add to the front when sending; doesn't matter when receiving */
- list_add(&urb->urb_list, &channel->list);
-
- spin_unlock_irq(&channel->lock);
-
- /* make sure the channel doesn't stall */
- mod_timer(&channel->delay, jiffies + msecs_to_jiffies(THROTTLE_MSECS));
- }
-
- return ret;
-}
-
-static void usbatm_complete(struct urb *urb)
-{
- struct usbatm_channel *channel = urb->context;
- unsigned long flags;
- int status = urb->status;
-
- vdbg("%s: urb 0x%p, status %d, actual_length %d",
- __func__, urb, status, urb->actual_length);
-
- /* usually in_interrupt(), but not always */
- spin_lock_irqsave(&channel->lock, flags);
-
- /* must add to the back when receiving; doesn't matter when sending */
- list_add_tail(&urb->urb_list, &channel->list);
-
- spin_unlock_irqrestore(&channel->lock, flags);
-
- if (unlikely(status) &&
- (!(channel->usbatm->flags & UDSL_IGNORE_EILSEQ) ||
- status != -EILSEQ)) {
- if (status == -ESHUTDOWN)
- return;
-
- if (printk_ratelimit())
- atm_warn(channel->usbatm, "%s: urb 0x%p failed (%d)!\n",
- __func__, urb, status);
- /* throttle processing in case of an error */
- mod_timer(&channel->delay, jiffies + msecs_to_jiffies(THROTTLE_MSECS));
- } else
- tasklet_schedule(&channel->tasklet);
-}
-
-
-/*************
-** decode **
-*************/
-
-static inline struct usbatm_vcc_data *usbatm_find_vcc(struct usbatm_data *instance,
- short vpi, int vci)
-{
- struct usbatm_vcc_data *vcc_data;
-
- list_for_each_entry(vcc_data, &instance->vcc_list, list)
- if ((vcc_data->vci == vci) && (vcc_data->vpi == vpi))
- return vcc_data;
- return NULL;
-}
-
-static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char *source)
-{
- struct atm_vcc *vcc;
- struct sk_buff *sarb;
- short vpi = ((source[0] & 0x0f) << 4) | (source[1] >> 4);
- int vci = ((source[1] & 0x0f) << 12) | (source[2] << 4) | (source[3] >> 4);
- u8 pti = ((source[3] & 0xe) >> 1);
-
- vdbg("%s: vpi %hd, vci %d, pti %d", __func__, vpi, vci, pti);
-
- if ((vci != instance->cached_vci) || (vpi != instance->cached_vpi)) {
- instance->cached_vpi = vpi;
- instance->cached_vci = vci;
-
- instance->cached_vcc = usbatm_find_vcc(instance, vpi, vci);
-
- if (!instance->cached_vcc)
- atm_rldbg(instance, "%s: unknown vpi/vci (%hd/%d)!\n", __func__, vpi, vci);
- }
-
- if (!instance->cached_vcc)
- return;
-
- vcc = instance->cached_vcc->vcc;
-
- /* OAM F5 end-to-end */
- if (pti == ATM_PTI_E2EF5) {
- if (printk_ratelimit())
- atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
- __func__, vpi, vci);
- atomic_inc(&vcc->stats->rx_err);
- return;
- }
-
- sarb = instance->cached_vcc->sarb;
-
- if (sarb->tail + ATM_CELL_PAYLOAD > sarb->end) {
- atm_rldbg(instance, "%s: buffer overrun (sarb->len %u, vcc: 0x%p)!\n",
- __func__, sarb->len, vcc);
- /* discard cells already received */
- skb_trim(sarb, 0);
- UDSL_ASSERT(instance, sarb->tail + ATM_CELL_PAYLOAD <= sarb->end);
- }
-
- memcpy(skb_tail_pointer(sarb), source + ATM_CELL_HEADER, ATM_CELL_PAYLOAD);
- __skb_put(sarb, ATM_CELL_PAYLOAD);
-
- if (pti & 1) {
- struct sk_buff *skb;
- unsigned int length;
- unsigned int pdu_length;
-
- length = (source[ATM_CELL_SIZE - 6] << 8) + source[ATM_CELL_SIZE - 5];
-
- /* guard against overflow */
- if (length > ATM_MAX_AAL5_PDU) {
- atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
- __func__, length, vcc);
- atomic_inc(&vcc->stats->rx_err);
- goto out;
- }
-
- pdu_length = usbatm_pdu_length(length);
-
- if (sarb->len < pdu_length) {
- atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
- __func__, pdu_length, sarb->len, vcc);
- atomic_inc(&vcc->stats->rx_err);
- goto out;
- }
-
- if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
- atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
- __func__, vcc);
- atomic_inc(&vcc->stats->rx_err);
- goto out;
- }
-
- vdbg("%s: got packet (length: %u, pdu_length: %u, vcc: 0x%p)", __func__, length, pdu_length, vcc);
-
- if (!(skb = dev_alloc_skb(length))) {
- if (printk_ratelimit())
- atm_err(instance, "%s: no memory for skb (length: %u)!\n",
- __func__, length);
- atomic_inc(&vcc->stats->rx_drop);
- goto out;
- }
-
- vdbg("%s: allocated new sk_buff (skb: 0x%p, skb->truesize: %u)", __func__, skb, skb->truesize);
-
- if (!atm_charge(vcc, skb->truesize)) {
- atm_rldbg(instance, "%s: failed atm_charge (skb->truesize: %u)!\n",
- __func__, skb->truesize);
- dev_kfree_skb_any(skb);
- goto out; /* atm_charge increments rx_drop */
- }
-
- skb_copy_to_linear_data(skb,
- skb_tail_pointer(sarb) - pdu_length,
- length);
- __skb_put(skb, length);
-
- vdbg("%s: sending skb 0x%p, skb->len %u, skb->truesize %u",
- __func__, skb, skb->len, skb->truesize);
-
- PACKETDEBUG(skb->data, skb->len);
-
- vcc->push(vcc, skb);
-
- atomic_inc(&vcc->stats->rx);
- out:
- skb_trim(sarb, 0);
- }
-}
-
-static void usbatm_extract_cells(struct usbatm_data *instance,
- unsigned char *source, unsigned int avail_data)
-{
- unsigned int stride = instance->rx_channel.stride;
- unsigned int buf_usage = instance->buf_usage;
-
- /* extract cells from incoming data, taking into account that
- * the length of avail data may not be a multiple of stride */
-
- if (buf_usage > 0) {
- /* we have a partially received atm cell */
- unsigned char *cell_buf = instance->cell_buf;
- unsigned int space_left = stride - buf_usage;
-
- UDSL_ASSERT(instance, buf_usage <= stride);
-
- if (avail_data >= space_left) {
- /* add new data and process cell */
- memcpy(cell_buf + buf_usage, source, space_left);
- source += space_left;
- avail_data -= space_left;
- usbatm_extract_one_cell(instance, cell_buf);
- instance->buf_usage = 0;
- } else {
- /* not enough data to fill the cell */
- memcpy(cell_buf + buf_usage, source, avail_data);
- instance->buf_usage = buf_usage + avail_data;
- return;
- }
- }
-
- for (; avail_data >= stride; avail_data -= stride, source += stride)
- usbatm_extract_one_cell(instance, source);
-
- if (avail_data > 0) {
- /* length was not a multiple of stride -
- * save remaining data for next call */
- memcpy(instance->cell_buf, source, avail_data);
- instance->buf_usage = avail_data;
- }
-}
-
-
-/*************
-** encode **
-*************/
-
-static unsigned int usbatm_write_cells(struct usbatm_data *instance,
- struct sk_buff *skb,
- u8 *target, unsigned int avail_space)
-{
- struct usbatm_control *ctrl = UDSL_SKB(skb);
- struct atm_vcc *vcc = ctrl->atm.vcc;
- unsigned int bytes_written;
- unsigned int stride = instance->tx_channel.stride;
-
- vdbg("%s: skb->len=%d, avail_space=%u", __func__, skb->len, avail_space);
- UDSL_ASSERT(instance, !(avail_space % stride));
-
- for (bytes_written = 0; bytes_written < avail_space && ctrl->len;
- bytes_written += stride, target += stride) {
- unsigned int data_len = min_t(unsigned int, skb->len, ATM_CELL_PAYLOAD);
- unsigned int left = ATM_CELL_PAYLOAD - data_len;
- u8 *ptr = target;
-
- ptr[0] = vcc->vpi >> 4;
- ptr[1] = (vcc->vpi << 4) | (vcc->vci >> 12);
- ptr[2] = vcc->vci >> 4;
- ptr[3] = vcc->vci << 4;
- ptr[4] = 0xec;
- ptr += ATM_CELL_HEADER;
-
- skb_copy_from_linear_data(skb, ptr, data_len);
- ptr += data_len;
- __skb_pull(skb, data_len);
-
- if (!left)
- continue;
-
- memset(ptr, 0, left);
-
- if (left >= ATM_AAL5_TRAILER) { /* trailer will go in this cell */
- u8 *trailer = target + ATM_CELL_SIZE - ATM_AAL5_TRAILER;
- /* trailer[0] = 0; UU = 0 */
- /* trailer[1] = 0; CPI = 0 */
- trailer[2] = ctrl->len >> 8;
- trailer[3] = ctrl->len;
-
- ctrl->crc = ~crc32_be(ctrl->crc, ptr, left - 4);
-
- trailer[4] = ctrl->crc >> 24;
- trailer[5] = ctrl->crc >> 16;
- trailer[6] = ctrl->crc >> 8;
- trailer[7] = ctrl->crc;
-
- target[3] |= 0x2; /* adjust PTI */
-
- ctrl->len = 0; /* tag this skb finished */
- } else
- ctrl->crc = crc32_be(ctrl->crc, ptr, left);
- }
-
- return bytes_written;
-}
-
-
-/**************
-** receive **
-**************/
-
-static void usbatm_rx_process(unsigned long data)
-{
- struct usbatm_data *instance = (struct usbatm_data *)data;
- struct urb *urb;
-
- while ((urb = usbatm_pop_urb(&instance->rx_channel))) {
- vdbg("%s: processing urb 0x%p", __func__, urb);
-
- if (usb_pipeisoc(urb->pipe)) {
- unsigned char *merge_start = NULL;
- unsigned int merge_length = 0;
- const unsigned int packet_size = instance->rx_channel.packet_size;
- int i;
-
- for (i = 0; i < urb->number_of_packets; i++) {
- if (!urb->iso_frame_desc[i].status) {
- unsigned int actual_length = urb->iso_frame_desc[i].actual_length;
-
- UDSL_ASSERT(instance, actual_length <= packet_size);
-
- if (!merge_length)
- merge_start = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset;
- merge_length += actual_length;
- if (merge_length && (actual_length < packet_size)) {
- usbatm_extract_cells(instance, merge_start, merge_length);
- merge_length = 0;
- }
- } else {
- atm_rldbg(instance, "%s: status %d in frame %d!\n", __func__, urb->status, i);
- if (merge_length)
- usbatm_extract_cells(instance, merge_start, merge_length);
- merge_length = 0;
- instance->buf_usage = 0;
- }
- }
-
- if (merge_length)
- usbatm_extract_cells(instance, merge_start, merge_length);
- } else
- if (!urb->status)
- usbatm_extract_cells(instance, urb->transfer_buffer, urb->actual_length);
- else
- instance->buf_usage = 0;
-
- if (usbatm_submit_urb(urb))
- return;
- }
-}
-
-
-/***********
-** send **
-***********/
-
-static void usbatm_tx_process(unsigned long data)
-{
- struct usbatm_data *instance = (struct usbatm_data *)data;
- struct sk_buff *skb = instance->current_skb;
- struct urb *urb = NULL;
- const unsigned int buf_size = instance->tx_channel.buf_size;
- unsigned int bytes_written = 0;
- u8 *buffer = NULL;
-
- if (!skb)
- skb = skb_dequeue(&instance->sndqueue);
-
- while (skb) {
- if (!urb) {
- urb = usbatm_pop_urb(&instance->tx_channel);
- if (!urb)
- break; /* no more senders */
- buffer = urb->transfer_buffer;
- bytes_written = (urb->status == -EAGAIN) ?
- urb->transfer_buffer_length : 0;
- }
-
- bytes_written += usbatm_write_cells(instance, skb,
- buffer + bytes_written,
- buf_size - bytes_written);
-
- vdbg("%s: wrote %u bytes from skb 0x%p to urb 0x%p",
- __func__, bytes_written, skb, urb);
-
- if (!UDSL_SKB(skb)->len) {
- struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
-
- usbatm_pop(vcc, skb);
- atomic_inc(&vcc->stats->tx);
-
- skb = skb_dequeue(&instance->sndqueue);
- }
-
- if (bytes_written == buf_size || (!skb && bytes_written)) {
- urb->transfer_buffer_length = bytes_written;
-
- if (usbatm_submit_urb(urb))
- break;
- urb = NULL;
- }
- }
-
- instance->current_skb = skb;
-}
-
-static void usbatm_cancel_send(struct usbatm_data *instance,
- struct atm_vcc *vcc)
-{
- struct sk_buff *skb, *n;
-
- atm_dbg(instance, "%s entered\n", __func__);
- spin_lock_irq(&instance->sndqueue.lock);
- skb_queue_walk_safe(&instance->sndqueue, skb, n) {
- if (UDSL_SKB(skb)->atm.vcc == vcc) {
- atm_dbg(instance, "%s: popping skb 0x%p\n", __func__, skb);
- __skb_unlink(skb, &instance->sndqueue);
- usbatm_pop(vcc, skb);
- }
- }
- spin_unlock_irq(&instance->sndqueue.lock);
-
- tasklet_disable(&instance->tx_channel.tasklet);
- if ((skb = instance->current_skb) && (UDSL_SKB(skb)->atm.vcc == vcc)) {
- atm_dbg(instance, "%s: popping current skb (0x%p)\n", __func__, skb);
- instance->current_skb = NULL;
- usbatm_pop(vcc, skb);
- }
- tasklet_enable(&instance->tx_channel.tasklet);
- atm_dbg(instance, "%s done\n", __func__);
-}
-
-static int usbatm_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
-{
- struct usbatm_data *instance = vcc->dev->dev_data;
- struct usbatm_control *ctrl = UDSL_SKB(skb);
- int err;
-
- vdbg("%s called (skb 0x%p, len %u)", __func__, skb, skb->len);
-
- /* racy disconnection check - fine */
- if (!instance || instance->disconnected) {
-#ifdef DEBUG
- printk_ratelimited(KERN_DEBUG "%s: %s!\n", __func__, instance ? "disconnected" : "NULL instance");
-#endif
- err = -ENODEV;
- goto fail;
- }
-
- if (vcc->qos.aal != ATM_AAL5) {
- atm_rldbg(instance, "%s: unsupported ATM type %d!\n", __func__, vcc->qos.aal);
- err = -EINVAL;
- goto fail;
- }
-
- if (skb->len > ATM_MAX_AAL5_PDU) {
- atm_rldbg(instance, "%s: packet too long (%d vs %d)!\n",
- __func__, skb->len, ATM_MAX_AAL5_PDU);
- err = -EINVAL;
- goto fail;
- }
-
- PACKETDEBUG(skb->data, skb->len);
-
- /* initialize the control block */
- ctrl->atm.vcc = vcc;
- ctrl->len = skb->len;
- ctrl->crc = crc32_be(~0, skb->data, skb->len);
-
- skb_queue_tail(&instance->sndqueue, skb);
- tasklet_schedule(&instance->tx_channel.tasklet);
-
- return 0;
-
- fail:
- usbatm_pop(vcc, skb);
- return err;
-}
-
-
-/********************
-** bean counting **
-********************/
-
-static void usbatm_destroy_instance(struct kref *kref)
-{
- struct usbatm_data *instance = container_of(kref, struct usbatm_data, refcount);
-
- dbg("%s", __func__);
-
- tasklet_kill(&instance->rx_channel.tasklet);
- tasklet_kill(&instance->tx_channel.tasklet);
- usb_put_dev(instance->usb_dev);
- kfree(instance);
-}
-
-static void usbatm_get_instance(struct usbatm_data *instance)
-{
- dbg("%s", __func__);
-
- kref_get(&instance->refcount);
-}
-
-static void usbatm_put_instance(struct usbatm_data *instance)
-{
- dbg("%s", __func__);
-
- kref_put(&instance->refcount, usbatm_destroy_instance);
-}
-
-
-/**********
-** ATM **
-**********/
-
-static void usbatm_atm_dev_close(struct atm_dev *atm_dev)
-{
- struct usbatm_data *instance = atm_dev->dev_data;
-
- dbg("%s", __func__);
-
- if (!instance)
- return;
-
- atm_dev->dev_data = NULL; /* catch bugs */
- usbatm_put_instance(instance); /* taken in usbatm_atm_init */
-}
-
-static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *page)
-{
- struct usbatm_data *instance = atm_dev->dev_data;
- int left = *pos;
-
- if (!instance) {
- dbg("%s: NULL instance!", __func__);
- return -ENODEV;
- }
-
- if (!left--)
- return sprintf(page, "%s\n", instance->description);
-
- if (!left--)
- return sprintf(page, "MAC: %pM\n", atm_dev->esi);
-
- if (!left--)
- return sprintf(page,
- "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
- atomic_read(&atm_dev->stats.aal5.tx),
- atomic_read(&atm_dev->stats.aal5.tx_err),
- atomic_read(&atm_dev->stats.aal5.rx),
- atomic_read(&atm_dev->stats.aal5.rx_err),
- atomic_read(&atm_dev->stats.aal5.rx_drop));
-
- if (!left--) {
- if (instance->disconnected)
- return sprintf(page, "Disconnected\n");
- else
- switch (atm_dev->signal) {
- case ATM_PHY_SIG_FOUND:
- return sprintf(page, "Line up\n");
- case ATM_PHY_SIG_LOST:
- return sprintf(page, "Line down\n");
- default:
- return sprintf(page, "Line state unknown\n");
- }
- }
-
- return 0;
-}
-
-static int usbatm_atm_open(struct atm_vcc *vcc)
-{
- struct usbatm_data *instance = vcc->dev->dev_data;
- struct usbatm_vcc_data *new = NULL;
- int ret;
- int vci = vcc->vci;
- short vpi = vcc->vpi;
-
- if (!instance) {
- dbg("%s: NULL data!", __func__);
- return -ENODEV;
- }
-
- atm_dbg(instance, "%s: vpi %hd, vci %d\n", __func__, vpi, vci);
-
- /* only support AAL5 */
- if ((vcc->qos.aal != ATM_AAL5)) {
- atm_warn(instance, "%s: unsupported ATM type %d!\n", __func__, vcc->qos.aal);
- return -EINVAL;
- }
-
- /* sanity checks */
- if ((vcc->qos.rxtp.max_sdu < 0) || (vcc->qos.rxtp.max_sdu > ATM_MAX_AAL5_PDU)) {
- atm_dbg(instance, "%s: max_sdu %d out of range!\n", __func__, vcc->qos.rxtp.max_sdu);
- return -EINVAL;
- }
-
- mutex_lock(&instance->serialize); /* vs self, usbatm_atm_close, usbatm_usb_disconnect */
-
- if (instance->disconnected) {
- atm_dbg(instance, "%s: disconnected!\n", __func__);
- ret = -ENODEV;
- goto fail;
- }
-
- if (usbatm_find_vcc(instance, vpi, vci)) {
- atm_dbg(instance, "%s: %hd/%d already in use!\n", __func__, vpi, vci);
- ret = -EADDRINUSE;
- goto fail;
- }
-
- if (!(new = kzalloc(sizeof(struct usbatm_vcc_data), GFP_KERNEL))) {
- atm_err(instance, "%s: no memory for vcc_data!\n", __func__);
- ret = -ENOMEM;
- goto fail;
- }
-
- new->vcc = vcc;
- new->vpi = vpi;
- new->vci = vci;
-
- new->sarb = alloc_skb(usbatm_pdu_length(vcc->qos.rxtp.max_sdu), GFP_KERNEL);
- if (!new->sarb) {
- atm_err(instance, "%s: no memory for SAR buffer!\n", __func__);
- ret = -ENOMEM;
- goto fail;
- }
-
- vcc->dev_data = new;
-
- tasklet_disable(&instance->rx_channel.tasklet);
- instance->cached_vcc = new;
- instance->cached_vpi = vpi;
- instance->cached_vci = vci;
- list_add(&new->list, &instance->vcc_list);
- tasklet_enable(&instance->rx_channel.tasklet);
-
- set_bit(ATM_VF_ADDR, &vcc->flags);
- set_bit(ATM_VF_PARTIAL, &vcc->flags);
- set_bit(ATM_VF_READY, &vcc->flags);
-
- mutex_unlock(&instance->serialize);
-
- atm_dbg(instance, "%s: allocated vcc data 0x%p\n", __func__, new);
-
- return 0;
-
-fail:
- kfree(new);
- mutex_unlock(&instance->serialize);
- return ret;
-}
-
-static void usbatm_atm_close(struct atm_vcc *vcc)
-{
- struct usbatm_data *instance = vcc->dev->dev_data;
- struct usbatm_vcc_data *vcc_data = vcc->dev_data;
-
- if (!instance || !vcc_data) {
- dbg("%s: NULL data!", __func__);
- return;
- }
-
- atm_dbg(instance, "%s entered\n", __func__);
-
- atm_dbg(instance, "%s: deallocating vcc 0x%p with vpi %d vci %d\n",
- __func__, vcc_data, vcc_data->vpi, vcc_data->vci);
-
- usbatm_cancel_send(instance, vcc);
-
- mutex_lock(&instance->serialize); /* vs self, usbatm_atm_open, usbatm_usb_disconnect */
-
- tasklet_disable(&instance->rx_channel.tasklet);
- if (instance->cached_vcc == vcc_data) {
- instance->cached_vcc = NULL;
- instance->cached_vpi = ATM_VPI_UNSPEC;
- instance->cached_vci = ATM_VCI_UNSPEC;
- }
- list_del(&vcc_data->list);
- tasklet_enable(&instance->rx_channel.tasklet);
-
- kfree_skb(vcc_data->sarb);
- vcc_data->sarb = NULL;
-
- kfree(vcc_data);
- vcc->dev_data = NULL;
-
- vcc->vpi = ATM_VPI_UNSPEC;
- vcc->vci = ATM_VCI_UNSPEC;
- clear_bit(ATM_VF_READY, &vcc->flags);
- clear_bit(ATM_VF_PARTIAL, &vcc->flags);
- clear_bit(ATM_VF_ADDR, &vcc->flags);
-
- mutex_unlock(&instance->serialize);
-
- atm_dbg(instance, "%s successful\n", __func__);
-}
-
-static int usbatm_atm_ioctl(struct atm_dev *atm_dev, unsigned int cmd,
- void __user * arg)
-{
- struct usbatm_data *instance = atm_dev->dev_data;
-
- if (!instance || instance->disconnected) {
- dbg("%s: %s!", __func__, instance ? "disconnected" : "NULL instance");
- return -ENODEV;
- }
-
- switch (cmd) {
- case ATM_QUERYLOOP:
- return put_user(ATM_LM_NONE, (int __user *)arg) ? -EFAULT : 0;
- default:
- return -ENOIOCTLCMD;
- }
-}
-
-static int usbatm_atm_init(struct usbatm_data *instance)
-{
- struct atm_dev *atm_dev;
- int ret, i;
-
- /* ATM init. The ATM initialization scheme suffers from an intrinsic race
- * condition: callbacks we register can be executed at once, before we have
- * initialized the struct atm_dev. To protect against this, all callbacks
- * abort if atm_dev->dev_data is NULL. */
- atm_dev = atm_dev_register(instance->driver_name,
- &instance->usb_intf->dev, &usbatm_atm_devops,
- -1, NULL);
- if (!atm_dev) {
- usb_err(instance, "%s: failed to register ATM device!\n", __func__);
- return -1;
- }
-
- instance->atm_dev = atm_dev;
-
- atm_dev->ci_range.vpi_bits = ATM_CI_MAX;
- atm_dev->ci_range.vci_bits = ATM_CI_MAX;
- atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
-
- /* temp init ATM device, set to 128kbit */
- atm_dev->link_rate = 128 * 1000 / 424;
-
- if (instance->driver->atm_start && ((ret = instance->driver->atm_start(instance, atm_dev)) < 0)) {
- atm_err(instance, "%s: atm_start failed: %d!\n", __func__, ret);
- goto fail;
- }
-
- usbatm_get_instance(instance); /* dropped in usbatm_atm_dev_close */
-
- /* ready for ATM callbacks */
- mb();
- atm_dev->dev_data = instance;
-
- /* submit all rx URBs */
- for (i = 0; i < num_rcv_urbs; i++)
- usbatm_submit_urb(instance->urbs[i]);
-
- return 0;
-
- fail:
- instance->atm_dev = NULL;
- atm_dev_deregister(atm_dev); /* usbatm_atm_dev_close will eventually be called */
- return ret;
-}
-
-
-/**********
-** USB **
-**********/
-
-static int usbatm_do_heavy_init(void *arg)
-{
- struct usbatm_data *instance = arg;
- int ret;
-
- allow_signal(SIGTERM);
- complete(&instance->thread_started);
-
- ret = instance->driver->heavy_init(instance, instance->usb_intf);
-
- if (!ret)
- ret = usbatm_atm_init(instance);
-
- mutex_lock(&instance->serialize);
- instance->thread = NULL;
- mutex_unlock(&instance->serialize);
-
- complete_and_exit(&instance->thread_exited, ret);
-}
-
-static int usbatm_heavy_init(struct usbatm_data *instance)
-{
- struct task_struct *t;
-
- t = kthread_create(usbatm_do_heavy_init, instance,
- instance->driver->driver_name);
- if (IS_ERR(t)) {
- usb_err(instance, "%s: failed to create kernel_thread (%ld)!\n",
- __func__, PTR_ERR(t));
- return PTR_ERR(t);
- }
-
- instance->thread = t;
- wake_up_process(t);
- wait_for_completion(&instance->thread_started);
-
- return 0;
-}
-
-static void usbatm_tasklet_schedule(unsigned long data)
-{
- tasklet_schedule((struct tasklet_struct *) data);
-}
-
-static void usbatm_init_channel(struct usbatm_channel *channel)
-{
- spin_lock_init(&channel->lock);
- INIT_LIST_HEAD(&channel->list);
- channel->delay.function = usbatm_tasklet_schedule;
- channel->delay.data = (unsigned long) &channel->tasklet;
- init_timer(&channel->delay);
-}
-
-int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
- struct usbatm_driver *driver)
-{
- struct device *dev = &intf->dev;
- struct usb_device *usb_dev = interface_to_usbdev(intf);
- struct usbatm_data *instance;
- char *buf;
- int error = -ENOMEM;
- int i, length;
- unsigned int maxpacket, num_packets;
-
- dev_dbg(dev, "%s: trying driver %s with vendor=%04x, product=%04x, ifnum %2d\n",
- __func__, driver->driver_name,
- le16_to_cpu(usb_dev->descriptor.idVendor),
- le16_to_cpu(usb_dev->descriptor.idProduct),
- intf->altsetting->desc.bInterfaceNumber);
-
- /* instance init */
- instance = kzalloc(sizeof(*instance) + sizeof(struct urb *) * (num_rcv_urbs + num_snd_urbs), GFP_KERNEL);
- if (!instance) {
- dev_err(dev, "%s: no memory for instance data!\n", __func__);
- return -ENOMEM;
- }
-
- /* public fields */
-
- instance->driver = driver;
- snprintf(instance->driver_name, sizeof(instance->driver_name), driver->driver_name);
-
- instance->usb_dev = usb_dev;
- instance->usb_intf = intf;
-
- buf = instance->description;
- length = sizeof(instance->description);
-
- if ((i = usb_string(usb_dev, usb_dev->descriptor.iProduct, buf, length)) < 0)
- goto bind;
-
- buf += i;
- length -= i;
-
- i = scnprintf(buf, length, " (");
- buf += i;
- length -= i;
-
- if (length <= 0 || (i = usb_make_path(usb_dev, buf, length)) < 0)
- goto bind;
-
- buf += i;
- length -= i;
-
- snprintf(buf, length, ")");
-
- bind:
- if (driver->bind && (error = driver->bind(instance, intf, id)) < 0) {
- dev_err(dev, "%s: bind failed: %d!\n", __func__, error);
- goto fail_free;
- }
-
- /* private fields */
-
- kref_init(&instance->refcount); /* dropped in usbatm_usb_disconnect */
- mutex_init(&instance->serialize);
-
- instance->thread = NULL;
- init_completion(&instance->thread_started);
- init_completion(&instance->thread_exited);
-
- INIT_LIST_HEAD(&instance->vcc_list);
- skb_queue_head_init(&instance->sndqueue);
-
- usbatm_init_channel(&instance->rx_channel);
- usbatm_init_channel(&instance->tx_channel);
- tasklet_init(&instance->rx_channel.tasklet, usbatm_rx_process, (unsigned long)instance);
- tasklet_init(&instance->tx_channel.tasklet, usbatm_tx_process, (unsigned long)instance);
- instance->rx_channel.stride = ATM_CELL_SIZE + driver->rx_padding;
- instance->tx_channel.stride = ATM_CELL_SIZE + driver->tx_padding;
- instance->rx_channel.usbatm = instance->tx_channel.usbatm = instance;
-
- if ((instance->flags & UDSL_USE_ISOC) && driver->isoc_in)
- instance->rx_channel.endpoint = usb_rcvisocpipe(usb_dev, driver->isoc_in);
- else
- instance->rx_channel.endpoint = usb_rcvbulkpipe(usb_dev, driver->bulk_in);
-
- instance->tx_channel.endpoint = usb_sndbulkpipe(usb_dev, driver->bulk_out);
-
- /* tx buffer size must be a positive multiple of the stride */
- instance->tx_channel.buf_size = max(instance->tx_channel.stride,
- snd_buf_bytes - (snd_buf_bytes % instance->tx_channel.stride));
-
- /* rx buffer size must be a positive multiple of the endpoint maxpacket */
- maxpacket = usb_maxpacket(usb_dev, instance->rx_channel.endpoint, 0);
-
- if ((maxpacket < 1) || (maxpacket > UDSL_MAX_BUF_SIZE)) {
- dev_err(dev, "%s: invalid endpoint %02x!\n", __func__,
- usb_pipeendpoint(instance->rx_channel.endpoint));
- error = -EINVAL;
- goto fail_unbind;
- }
-
- num_packets = max(1U, (rcv_buf_bytes + maxpacket / 2) / maxpacket); /* round */
-
- if (num_packets * maxpacket > UDSL_MAX_BUF_SIZE)
- num_packets--;
-
- instance->rx_channel.buf_size = num_packets * maxpacket;
- instance->rx_channel.packet_size = maxpacket;
-
-#ifdef DEBUG
- for (i = 0; i < 2; i++) {
- struct usbatm_channel *channel = i ?
- &instance->tx_channel : &instance->rx_channel;
-
- dev_dbg(dev, "%s: using %d byte buffer for %s channel 0x%p\n", __func__, channel->buf_size, i ? "tx" : "rx", channel);
- }
-#endif
-
- /* initialize urbs */
-
- for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++) {
- u8 *buffer;
- struct usbatm_channel *channel = i < num_rcv_urbs ?
- &instance->rx_channel : &instance->tx_channel;
- struct urb *urb;
- unsigned int iso_packets = usb_pipeisoc(channel->endpoint) ? channel->buf_size / channel->packet_size : 0;
-
- UDSL_ASSERT(instance, !usb_pipeisoc(channel->endpoint) || usb_pipein(channel->endpoint));
-
- urb = usb_alloc_urb(iso_packets, GFP_KERNEL);
- if (!urb) {
- dev_err(dev, "%s: no memory for urb %d!\n", __func__, i);
- error = -ENOMEM;
- goto fail_unbind;
- }
-
- instance->urbs[i] = urb;
-
- /* zero the tx padding to avoid leaking information */
- buffer = kzalloc(channel->buf_size, GFP_KERNEL);
- if (!buffer) {
- dev_err(dev, "%s: no memory for buffer %d!\n", __func__, i);
- error = -ENOMEM;
- goto fail_unbind;
- }
-
- usb_fill_bulk_urb(urb, instance->usb_dev, channel->endpoint,
- buffer, channel->buf_size, usbatm_complete, channel);
- if (iso_packets) {
- int j;
- urb->interval = 1;
- urb->transfer_flags = URB_ISO_ASAP;
- urb->number_of_packets = iso_packets;
- for (j = 0; j < iso_packets; j++) {
- urb->iso_frame_desc[j].offset = channel->packet_size * j;
- urb->iso_frame_desc[j].length = channel->packet_size;
- }
- }
-
- /* put all tx URBs on the list of spares */
- if (i >= num_rcv_urbs)
- list_add_tail(&urb->urb_list, &channel->list);
-
- vdbg("%s: alloced buffer 0x%p buf size %u urb 0x%p",
- __func__, urb->transfer_buffer, urb->transfer_buffer_length, urb);
- }
-
- instance->cached_vpi = ATM_VPI_UNSPEC;
- instance->cached_vci = ATM_VCI_UNSPEC;
- instance->cell_buf = kmalloc(instance->rx_channel.stride, GFP_KERNEL);
-
- if (!instance->cell_buf) {
- dev_err(dev, "%s: no memory for cell buffer!\n", __func__);
- error = -ENOMEM;
- goto fail_unbind;
- }
-
- if (!(instance->flags & UDSL_SKIP_HEAVY_INIT) && driver->heavy_init) {
- error = usbatm_heavy_init(instance);
- } else {
- complete(&instance->thread_exited); /* pretend that heavy_init was run */
- error = usbatm_atm_init(instance);
- }
-
- if (error < 0)
- goto fail_unbind;
-
- usb_get_dev(usb_dev);
- usb_set_intfdata(intf, instance);
-
- return 0;
-
- fail_unbind:
- if (instance->driver->unbind)
- instance->driver->unbind(instance, intf);
- fail_free:
- kfree(instance->cell_buf);
-
- for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++) {
- if (instance->urbs[i])
- kfree(instance->urbs[i]->transfer_buffer);
- usb_free_urb(instance->urbs[i]);
- }
-
- kfree(instance);
-
- return error;
-}
-EXPORT_SYMBOL_GPL(usbatm_usb_probe);
-
-void usbatm_usb_disconnect(struct usb_interface *intf)
-{
- struct device *dev = &intf->dev;
- struct usbatm_data *instance = usb_get_intfdata(intf);
- struct usbatm_vcc_data *vcc_data;
- int i;
-
- dev_dbg(dev, "%s entered\n", __func__);
-
- if (!instance) {
- dev_dbg(dev, "%s: NULL instance!\n", __func__);
- return;
- }
-
- usb_set_intfdata(intf, NULL);
-
- mutex_lock(&instance->serialize);
- instance->disconnected = 1;
- if (instance->thread != NULL)
- send_sig(SIGTERM, instance->thread, 1);
- mutex_unlock(&instance->serialize);
-
- wait_for_completion(&instance->thread_exited);
-
- mutex_lock(&instance->serialize);
- list_for_each_entry(vcc_data, &instance->vcc_list, list)
- vcc_release_async(vcc_data->vcc, -EPIPE);
- mutex_unlock(&instance->serialize);
-
- tasklet_disable(&instance->rx_channel.tasklet);
- tasklet_disable(&instance->tx_channel.tasklet);
-
- for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++)
- usb_kill_urb(instance->urbs[i]);
-
- del_timer_sync(&instance->rx_channel.delay);
- del_timer_sync(&instance->tx_channel.delay);
-
- /* turn usbatm_[rt]x_process into something close to a no-op */
- /* no need to take the spinlock */
- INIT_LIST_HEAD(&instance->rx_channel.list);
- INIT_LIST_HEAD(&instance->tx_channel.list);
-
- tasklet_enable(&instance->rx_channel.tasklet);
- tasklet_enable(&instance->tx_channel.tasklet);
-
- if (instance->atm_dev && instance->driver->atm_stop)
- instance->driver->atm_stop(instance, instance->atm_dev);
-
- if (instance->driver->unbind)
- instance->driver->unbind(instance, intf);
-
- instance->driver_data = NULL;
-
- for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++) {
- kfree(instance->urbs[i]->transfer_buffer);
- usb_free_urb(instance->urbs[i]);
- }
-
- kfree(instance->cell_buf);
-
- /* ATM finalize */
- if (instance->atm_dev) {
- atm_dev_deregister(instance->atm_dev);
- instance->atm_dev = NULL;
- }
-
- usbatm_put_instance(instance); /* taken in usbatm_usb_probe */
-}
-EXPORT_SYMBOL_GPL(usbatm_usb_disconnect);
-
-
-/***********
-** init **
-***********/
-
-static int __init usbatm_usb_init(void)
-{
- dbg("%s: driver version %s", __func__, DRIVER_VERSION);
-
- if (sizeof(struct usbatm_control) > FIELD_SIZEOF(struct sk_buff, cb)) {
- printk(KERN_ERR "%s unusable with this kernel!\n", usbatm_driver_name);
- return -EIO;
- }
-
- if ((num_rcv_urbs > UDSL_MAX_RCV_URBS)
- || (num_snd_urbs > UDSL_MAX_SND_URBS)
- || (rcv_buf_bytes < 1)
- || (rcv_buf_bytes > UDSL_MAX_BUF_SIZE)
- || (snd_buf_bytes < 1)
- || (snd_buf_bytes > UDSL_MAX_BUF_SIZE))
- return -EINVAL;
-
- return 0;
-}
-module_init(usbatm_usb_init);
-
-static void __exit usbatm_usb_exit(void)
-{
- dbg("%s", __func__);
-}
-module_exit(usbatm_usb_exit);
-
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-MODULE_VERSION(DRIVER_VERSION);
-
-/************
-** debug **
-************/
-
-#ifdef VERBOSE_DEBUG
-static int usbatm_print_packet(const unsigned char *data, int len)
-{
- unsigned char buffer[256];
- int i = 0, j = 0;
-
- for (i = 0; i < len;) {
- buffer[0] = '\0';
- sprintf(buffer, "%.3d :", i);
- for (j = 0; (j < 16) && (i < len); j++, i++)
- sprintf(buffer, "%s %2.2x", buffer, data[i]);
- dbg("%s", buffer);
- }
- return i;
-}
-#endif
diff --git a/ANDROID_3.4.5/drivers/usb/atm/usbatm.h b/ANDROID_3.4.5/drivers/usb/atm/usbatm.h
deleted file mode 100644
index 5fc48940..00000000
--- a/ANDROID_3.4.5/drivers/usb/atm/usbatm.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/******************************************************************************
- * usbatm.h - Generic USB xDSL driver core
- *
- * Copyright (C) 2001, Alcatel
- * Copyright (C) 2003, Duncan Sands, SolNegro, Josep Comas
- * Copyright (C) 2004, David Woodhouse
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- ******************************************************************************/
-
-#ifndef _USBATM_H_
-#define _USBATM_H_
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-/*
-#define VERBOSE_DEBUG
-*/
-
-#ifdef DEBUG
-#define UDSL_ASSERT(instance, x) BUG_ON(!(x))
-#else
-#define UDSL_ASSERT(instance, x) \
- do { \
- if (!(x)) \
- dev_warn(&(instance)->usb_intf->dev, \
- "failed assertion '%s' at line %d", \
- __stringify(x), __LINE__); \
- } while (0)
-#endif
-
-#define usb_err(instance, format, arg...) \
- dev_err(&(instance)->usb_intf->dev , format , ## arg)
-#define usb_info(instance, format, arg...) \
- dev_info(&(instance)->usb_intf->dev , format , ## arg)
-#define usb_warn(instance, format, arg...) \
- dev_warn(&(instance)->usb_intf->dev , format , ## arg)
-#ifdef DEBUG
-#define usb_dbg(instance, format, arg...) \
- dev_printk(KERN_DEBUG , &(instance)->usb_intf->dev , format , ## arg)
-#else
-#define usb_dbg(instance, format, arg...) \
- do {} while (0)
-#endif
-
-/* FIXME: move to dev_* once ATM is driver model aware */
-#define atm_printk(level, instance, format, arg...) \
- printk(level "ATM dev %d: " format , \
- (instance)->atm_dev->number , ## arg)
-
-#define atm_err(instance, format, arg...) \
- atm_printk(KERN_ERR, instance , format , ## arg)
-#define atm_info(instance, format, arg...) \
- atm_printk(KERN_INFO, instance , format , ## arg)
-#define atm_warn(instance, format, arg...) \
- atm_printk(KERN_WARNING, instance , format , ## arg)
-#ifdef DEBUG
-#define atm_dbg(instance, format, arg...) \
- atm_printk(KERN_DEBUG, instance , format , ## arg)
-#define atm_rldbg(instance, format, arg...) \
- if (printk_ratelimit()) \
- atm_printk(KERN_DEBUG, instance , format , ## arg)
-#else
-#define atm_dbg(instance, format, arg...) \
- do {} while (0)
-#define atm_rldbg(instance, format, arg...) \
- do {} while (0)
-#endif
-
-
-/* flags, set by mini-driver in bind() */
-
-#define UDSL_SKIP_HEAVY_INIT (1<<0)
-#define UDSL_USE_ISOC (1<<1)
-#define UDSL_IGNORE_EILSEQ (1<<2)
-
-
-/* mini driver */
-
-struct usbatm_data;
-
-/*
-* Assuming all methods exist and succeed, they are called in this order:
-*
-* bind, heavy_init, atm_start, ..., atm_stop, unbind
-*/
-
-struct usbatm_driver {
- const char *driver_name;
-
- /* init device ... can sleep, or cause probe() failure */
- int (*bind) (struct usbatm_data *, struct usb_interface *,
- const struct usb_device_id *id);
-
- /* additional device initialization that is too slow to be done in probe() */
- int (*heavy_init) (struct usbatm_data *, struct usb_interface *);
-
- /* cleanup device ... can sleep, but can't fail */
- void (*unbind) (struct usbatm_data *, struct usb_interface *);
-
- /* init ATM device ... can sleep, or cause ATM initialization failure */
- int (*atm_start) (struct usbatm_data *, struct atm_dev *);
-
- /* cleanup ATM device ... can sleep, but can't fail */
- void (*atm_stop) (struct usbatm_data *, struct atm_dev *);
-
- int bulk_in; /* bulk rx endpoint */
- int isoc_in; /* isochronous rx endpoint */
- int bulk_out; /* bulk tx endpoint */
-
- unsigned rx_padding;
- unsigned tx_padding;
-};
-
-extern int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
- struct usbatm_driver *driver);
-extern void usbatm_usb_disconnect(struct usb_interface *intf);
-
-
-struct usbatm_channel {
- int endpoint; /* usb pipe */
- unsigned int stride; /* ATM cell size + padding */
- unsigned int buf_size; /* urb buffer size */
- unsigned int packet_size; /* endpoint maxpacket */
- spinlock_t lock;
- struct list_head list;
- struct tasklet_struct tasklet;
- struct timer_list delay;
- struct usbatm_data *usbatm;
-};
-
-/* main driver data */
-
-struct usbatm_data {
- /******************
- * public fields *
- ******************/
-
- /* mini driver */
- struct usbatm_driver *driver;
- void *driver_data;
- char driver_name[16];
- unsigned int flags; /* set by mini-driver in bind() */
-
- /* USB device */
- struct usb_device *usb_dev;
- struct usb_interface *usb_intf;
- char description[64];
-
- /* ATM device */
- struct atm_dev *atm_dev;
-
- /********************************
- * private fields - do not use *
- ********************************/
-
- struct kref refcount;
- struct mutex serialize;
- int disconnected;
-
- /* heavy init */
- struct task_struct *thread;
- struct completion thread_started;
- struct completion thread_exited;
-
- /* ATM device */
- struct list_head vcc_list;
-
- struct usbatm_channel rx_channel;
- struct usbatm_channel tx_channel;
-
- struct sk_buff_head sndqueue;
- struct sk_buff *current_skb; /* being emptied */
-
- struct usbatm_vcc_data *cached_vcc;
- int cached_vci;
- short cached_vpi;
-
- unsigned char *cell_buf; /* holds partial rx cell */
- unsigned int buf_usage;
-
- struct urb *urbs[0];
-};
-
-static inline void *to_usbatm_driver_data(struct usb_interface *intf)
-{
- struct usbatm_data *usbatm_instance;
-
- if (intf == NULL)
- return NULL;
-
- usbatm_instance = usb_get_intfdata(intf);
-
- if (usbatm_instance == NULL) /* set NULL before unbind() */
- return NULL;
-
- return usbatm_instance->driver_data; /* set NULL after unbind() */
-}
-
-#endif /* _USBATM_H_ */
diff --git a/ANDROID_3.4.5/drivers/usb/atm/xusbatm.c b/ANDROID_3.4.5/drivers/usb/atm/xusbatm.c
deleted file mode 100644
index 48ee0c5f..00000000
--- a/ANDROID_3.4.5/drivers/usb/atm/xusbatm.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/******************************************************************************
- * xusbatm.c - dumb usbatm-based driver for modems initialized in userspace
- *
- * Copyright (C) 2005 Duncan Sands, Roman Kagan (rkagan % mail ! ru)
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- ******************************************************************************/
-
-#include
-#include /* for random_ether_addr() */
-
-#include "usbatm.h"
-
-
-#define XUSBATM_DRIVERS_MAX 8
-
-#define XUSBATM_PARM(name, type, parmtype, desc) \
- static type name[XUSBATM_DRIVERS_MAX]; \
- static unsigned int num_##name; \
- module_param_array(name, parmtype, &num_##name, 0444); \
- MODULE_PARM_DESC(name, desc)
-
-XUSBATM_PARM(vendor, unsigned short, ushort, "USB device vendor");
-XUSBATM_PARM(product, unsigned short, ushort, "USB device product");
-
-XUSBATM_PARM(rx_endpoint, unsigned char, byte, "rx endpoint number");
-XUSBATM_PARM(tx_endpoint, unsigned char, byte, "tx endpoint number");
-XUSBATM_PARM(rx_padding, unsigned char, byte, "rx padding (default 0)");
-XUSBATM_PARM(tx_padding, unsigned char, byte, "tx padding (default 0)");
-XUSBATM_PARM(rx_altsetting, unsigned char, byte, "rx altsetting (default 0)");
-XUSBATM_PARM(tx_altsetting, unsigned char, byte, "rx altsetting (default 0)");
-
-static const char xusbatm_driver_name[] = "xusbatm";
-
-static struct usbatm_driver xusbatm_drivers[XUSBATM_DRIVERS_MAX];
-static struct usb_device_id xusbatm_usb_ids[XUSBATM_DRIVERS_MAX + 1];
-static struct usb_driver xusbatm_usb_driver;
-
-static struct usb_interface *xusbatm_find_intf(struct usb_device *usb_dev, int altsetting, u8 ep)
-{
- struct usb_host_interface *alt;
- struct usb_interface *intf;
- int i, j;
-
- for (i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++)
- if ((intf = usb_dev->actconfig->interface[i]) && (alt = usb_altnum_to_altsetting(intf, altsetting)))
- for (j = 0; j < alt->desc.bNumEndpoints; j++)
- if (alt->endpoint[j].desc.bEndpointAddress == ep)
- return intf;
- return NULL;
-}
-
-static int xusbatm_capture_intf(struct usbatm_data *usbatm, struct usb_device *usb_dev,
- struct usb_interface *intf, int altsetting, int claim)
-{
- int ifnum = intf->altsetting->desc.bInterfaceNumber;
- int ret;
-
- if (claim && (ret = usb_driver_claim_interface(&xusbatm_usb_driver, intf, usbatm))) {
- usb_err(usbatm, "%s: failed to claim interface %2d (%d)!\n", __func__, ifnum, ret);
- return ret;
- }
- if ((ret = usb_set_interface(usb_dev, ifnum, altsetting))) {
- usb_err(usbatm, "%s: altsetting %2d for interface %2d failed (%d)!\n", __func__, altsetting, ifnum, ret);
- return ret;
- }
- return 0;
-}
-
-static void xusbatm_release_intf(struct usb_device *usb_dev, struct usb_interface *intf, int claimed)
-{
- if (claimed) {
- usb_set_intfdata(intf, NULL);
- usb_driver_release_interface(&xusbatm_usb_driver, intf);
- }
-}
-
-static int xusbatm_bind(struct usbatm_data *usbatm,
- struct usb_interface *intf, const struct usb_device_id *id)
-{
- struct usb_device *usb_dev = interface_to_usbdev(intf);
- int drv_ix = id - xusbatm_usb_ids;
- int rx_alt = rx_altsetting[drv_ix];
- int tx_alt = tx_altsetting[drv_ix];
- struct usb_interface *rx_intf = xusbatm_find_intf(usb_dev, rx_alt, rx_endpoint[drv_ix]);
- struct usb_interface *tx_intf = xusbatm_find_intf(usb_dev, tx_alt, tx_endpoint[drv_ix]);
- int ret;
-
- usb_dbg(usbatm, "%s: binding driver %d: vendor %04x product %04x"
- " rx: ep %02x padd %d alt %2d tx: ep %02x padd %d alt %2d\n",
- __func__, drv_ix, vendor[drv_ix], product[drv_ix],
- rx_endpoint[drv_ix], rx_padding[drv_ix], rx_alt,
- tx_endpoint[drv_ix], tx_padding[drv_ix], tx_alt);
-
- if (!rx_intf || !tx_intf) {
- if (!rx_intf)
- usb_dbg(usbatm, "%s: no interface contains endpoint %02x in altsetting %2d\n",
- __func__, rx_endpoint[drv_ix], rx_alt);
- if (!tx_intf)
- usb_dbg(usbatm, "%s: no interface contains endpoint %02x in altsetting %2d\n",
- __func__, tx_endpoint[drv_ix], tx_alt);
- return -ENODEV;
- }
-
- if ((rx_intf != intf) && (tx_intf != intf))
- return -ENODEV;
-
- if ((rx_intf == tx_intf) && (rx_alt != tx_alt)) {
- usb_err(usbatm, "%s: altsettings clash on interface %2d (%2d vs %2d)!\n", __func__,
- rx_intf->altsetting->desc.bInterfaceNumber, rx_alt, tx_alt);
- return -EINVAL;
- }
-
- usb_dbg(usbatm, "%s: rx If#=%2d; tx If#=%2d\n", __func__,
- rx_intf->altsetting->desc.bInterfaceNumber,
- tx_intf->altsetting->desc.bInterfaceNumber);
-
- if ((ret = xusbatm_capture_intf(usbatm, usb_dev, rx_intf, rx_alt, rx_intf != intf)))
- return ret;
-
- if ((tx_intf != rx_intf) && (ret = xusbatm_capture_intf(usbatm, usb_dev, tx_intf, tx_alt, tx_intf != intf))) {
- xusbatm_release_intf(usb_dev, rx_intf, rx_intf != intf);
- return ret;
- }
-
- return 0;
-}
-
-static void xusbatm_unbind(struct usbatm_data *usbatm,
- struct usb_interface *intf)
-{
- struct usb_device *usb_dev = interface_to_usbdev(intf);
- int i;
-
- usb_dbg(usbatm, "%s entered\n", __func__);
-
- for (i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++) {
- struct usb_interface *cur_intf = usb_dev->actconfig->interface[i];
-
- if (cur_intf && (usb_get_intfdata(cur_intf) == usbatm)) {
- usb_set_intfdata(cur_intf, NULL);
- usb_driver_release_interface(&xusbatm_usb_driver, cur_intf);
- }
- }
-}
-
-static int xusbatm_atm_start(struct usbatm_data *usbatm,
- struct atm_dev *atm_dev)
-{
- atm_dbg(usbatm, "%s entered\n", __func__);
-
- /* use random MAC as we've no way to get it from the device */
- random_ether_addr(atm_dev->esi);
-
- return 0;
-}
-
-
-static int xusbatm_usb_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- return usbatm_usb_probe(intf, id,
- xusbatm_drivers + (id - xusbatm_usb_ids));
-}
-
-static struct usb_driver xusbatm_usb_driver = {
- .name = xusbatm_driver_name,
- .probe = xusbatm_usb_probe,
- .disconnect = usbatm_usb_disconnect,
- .id_table = xusbatm_usb_ids
-};
-
-static int __init xusbatm_init(void)
-{
- int i;
-
- dbg("xusbatm_init");
-
- if (!num_vendor ||
- num_vendor != num_product ||
- num_vendor != num_rx_endpoint ||
- num_vendor != num_tx_endpoint) {
- printk(KERN_WARNING "xusbatm: malformed module parameters\n");
- return -EINVAL;
- }
-
- for (i = 0; i < num_vendor; i++) {
- rx_endpoint[i] |= USB_DIR_IN;
- tx_endpoint[i] &= USB_ENDPOINT_NUMBER_MASK;
-
- xusbatm_usb_ids[i].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
- xusbatm_usb_ids[i].idVendor = vendor[i];
- xusbatm_usb_ids[i].idProduct = product[i];
-
- xusbatm_drivers[i].driver_name = xusbatm_driver_name;
- xusbatm_drivers[i].bind = xusbatm_bind;
- xusbatm_drivers[i].unbind = xusbatm_unbind;
- xusbatm_drivers[i].atm_start = xusbatm_atm_start;
- xusbatm_drivers[i].bulk_in = rx_endpoint[i];
- xusbatm_drivers[i].bulk_out = tx_endpoint[i];
- xusbatm_drivers[i].rx_padding = rx_padding[i];
- xusbatm_drivers[i].tx_padding = tx_padding[i];
- }
-
- return usb_register(&xusbatm_usb_driver);
-}
-module_init(xusbatm_init);
-
-static void __exit xusbatm_exit(void)
-{
- dbg("xusbatm_exit entered");
-
- usb_deregister(&xusbatm_usb_driver);
-}
-module_exit(xusbatm_exit);
-
-MODULE_AUTHOR("Roman Kagan, Duncan Sands");
-MODULE_DESCRIPTION("Driver for USB ADSL modems initialized in userspace");
-MODULE_LICENSE("GPL");
-MODULE_VERSION("0.1");
diff --git a/ANDROID_3.4.5/drivers/usb/c67x00/Makefile b/ANDROID_3.4.5/drivers/usb/c67x00/Makefile
deleted file mode 100644
index b1218683..00000000
--- a/ANDROID_3.4.5/drivers/usb/c67x00/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Makefile for Cypress C67X00 USB Controller
-#
-
-ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
-
-obj-$(CONFIG_USB_C67X00_HCD) += c67x00.o
-
-c67x00-y := c67x00-drv.o c67x00-ll-hpi.o c67x00-hcd.o c67x00-sched.o
diff --git a/ANDROID_3.4.5/drivers/usb/c67x00/c67x00-drv.c b/ANDROID_3.4.5/drivers/usb/c67x00/c67x00-drv.c
deleted file mode 100644
index 6f3b6e26..00000000
--- a/ANDROID_3.4.5/drivers/usb/c67x00/c67x00-drv.c
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * c67x00-drv.c: Cypress C67X00 USB Common infrastructure
- *
- * Copyright (C) 2006-2008 Barco N.V.
- * Derived from the Cypress cy7c67200/300 ezusb linux driver and
- * based on multiple host controller drivers inside the linux kernel.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA.
- */
-
-/*
- * This file implements the common infrastructure for using the c67x00.
- * It is both the link between the platform configuration and subdrivers and
- * the link between the common hardware parts and the subdrivers (e.g.
- * interrupt handling).
- *
- * The c67x00 has 2 SIE's (serial interface engine) which can be configured
- * to be host, device or OTG (with some limitations, E.G. only SIE1 can be OTG).
- *
- * Depending on the platform configuration, the SIE's are created and
- * the corresponding subdriver is initialized (c67x00_probe_sie).
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "c67x00.h"
-#include "c67x00-hcd.h"
-
-static void c67x00_probe_sie(struct c67x00_sie *sie,
- struct c67x00_device *dev, int sie_num)
-{
- spin_lock_init(&sie->lock);
- sie->dev = dev;
- sie->sie_num = sie_num;
- sie->mode = c67x00_sie_config(dev->pdata->sie_config, sie_num);
-
- switch (sie->mode) {
- case C67X00_SIE_HOST:
- c67x00_hcd_probe(sie);
- break;
-
- case C67X00_SIE_UNUSED:
- dev_info(sie_dev(sie),
- "Not using SIE %d as requested\n", sie->sie_num);
- break;
-
- default:
- dev_err(sie_dev(sie),
- "Unsupported configuration: 0x%x for SIE %d\n",
- sie->mode, sie->sie_num);
- break;
- }
-}
-
-static void c67x00_remove_sie(struct c67x00_sie *sie)
-{
- switch (sie->mode) {
- case C67X00_SIE_HOST:
- c67x00_hcd_remove(sie);
- break;
-
- default:
- break;
- }
-}
-
-static irqreturn_t c67x00_irq(int irq, void *__dev)
-{
- struct c67x00_device *c67x00 = __dev;
- struct c67x00_sie *sie;
- u16 msg, int_status;
- int i, count = 8;
-
- int_status = c67x00_ll_hpi_status(c67x00);
- if (!int_status)
- return IRQ_NONE;
-
- while (int_status != 0 && (count-- >= 0)) {
- c67x00_ll_irq(c67x00, int_status);
- for (i = 0; i < C67X00_SIES; i++) {
- sie = &c67x00->sie[i];
- msg = 0;
- if (int_status & SIEMSG_FLG(i))
- msg = c67x00_ll_fetch_siemsg(c67x00, i);
- if (sie->irq)
- sie->irq(sie, int_status, msg);
- }
- int_status = c67x00_ll_hpi_status(c67x00);
- }
-
- if (int_status)
- dev_warn(&c67x00->pdev->dev, "Not all interrupts handled! "
- "status = 0x%04x\n", int_status);
-
- return IRQ_HANDLED;
-}
-
-/* ------------------------------------------------------------------------- */
-
-static int __devinit c67x00_drv_probe(struct platform_device *pdev)
-{
- struct c67x00_device *c67x00;
- struct c67x00_platform_data *pdata;
- struct resource *res, *res2;
- int ret, i;
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res)
- return -ENODEV;
-
- res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
- if (!res2)
- return -ENODEV;
-
- pdata = pdev->dev.platform_data;
- if (!pdata)
- return -ENODEV;
-
- c67x00 = kzalloc(sizeof(*c67x00), GFP_KERNEL);
- if (!c67x00)
- return -ENOMEM;
-
- if (!request_mem_region(res->start, resource_size(res),
- pdev->name)) {
- dev_err(&pdev->dev, "Memory region busy\n");
- ret = -EBUSY;
- goto request_mem_failed;
- }
- c67x00->hpi.base = ioremap(res->start, resource_size(res));
- if (!c67x00->hpi.base) {
- dev_err(&pdev->dev, "Unable to map HPI registers\n");
- ret = -EIO;
- goto map_failed;
- }
-
- spin_lock_init(&c67x00->hpi.lock);
- c67x00->hpi.regstep = pdata->hpi_regstep;
- c67x00->pdata = pdev->dev.platform_data;
- c67x00->pdev = pdev;
-
- c67x00_ll_init(c67x00);
- c67x00_ll_hpi_reg_init(c67x00);
-
- ret = request_irq(res2->start, c67x00_irq, 0, pdev->name, c67x00);
- if (ret) {
- dev_err(&pdev->dev, "Cannot claim IRQ\n");
- goto request_irq_failed;
- }
-
- ret = c67x00_ll_reset(c67x00);
- if (ret) {
- dev_err(&pdev->dev, "Device reset failed\n");
- goto reset_failed;
- }
-
- for (i = 0; i < C67X00_SIES; i++)
- c67x00_probe_sie(&c67x00->sie[i], c67x00, i);
-
- platform_set_drvdata(pdev, c67x00);
-
- return 0;
-
- reset_failed:
- free_irq(res2->start, c67x00);
- request_irq_failed:
- iounmap(c67x00->hpi.base);
- map_failed:
- release_mem_region(res->start, resource_size(res));
- request_mem_failed:
- kfree(c67x00);
-
- return ret;
-}
-
-static int __devexit c67x00_drv_remove(struct platform_device *pdev)
-{
- struct c67x00_device *c67x00 = platform_get_drvdata(pdev);
- struct resource *res;
- int i;
-
- for (i = 0; i < C67X00_SIES; i++)
- c67x00_remove_sie(&c67x00->sie[i]);
-
- c67x00_ll_release(c67x00);
-
- res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
- if (res)
- free_irq(res->start, c67x00);
-
- iounmap(c67x00->hpi.base);
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (res)
- release_mem_region(res->start, resource_size(res));
-
- kfree(c67x00);
-
- return 0;
-}
-
-static struct platform_driver c67x00_driver = {
- .probe = c67x00_drv_probe,
- .remove = __devexit_p(c67x00_drv_remove),
- .driver = {
- .owner = THIS_MODULE,
- .name = "c67x00",
- },
-};
-
-module_platform_driver(c67x00_driver);
-
-MODULE_AUTHOR("Peter Korsgaard, Jan Veldeman, Grant Likely");
-MODULE_DESCRIPTION("Cypress C67X00 USB Controller Driver");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:c67x00");
diff --git a/ANDROID_3.4.5/drivers/usb/c67x00/c67x00-hcd.c b/ANDROID_3.4.5/drivers/usb/c67x00/c67x00-hcd.c
deleted file mode 100644
index 75e47b86..00000000
--- a/ANDROID_3.4.5/drivers/usb/c67x00/c67x00-hcd.c
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * c67x00-hcd.c: Cypress C67X00 USB Host Controller Driver
- *
- * Copyright (C) 2006-2008 Barco N.V.
- * Derived from the Cypress cy7c67200/300 ezusb linux driver and
- * based on multiple host controller drivers inside the linux kernel.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA.
- */
-
-#include
-#include
-#include
-
-#include "c67x00.h"
-#include "c67x00-hcd.h"
-
-/* --------------------------------------------------------------------------
- * Root Hub Support
- */
-
-static __u8 c67x00_hub_des[] = {
- 0x09, /* __u8 bLength; */
- 0x29, /* __u8 bDescriptorType; Hub-descriptor */
- 0x02, /* __u8 bNbrPorts; */
- 0x00, /* __u16 wHubCharacteristics; */
- 0x00, /* (per-port OC, no power switching) */
- 0x32, /* __u8 bPwrOn2pwrGood; 2ms */
- 0x00, /* __u8 bHubContrCurrent; 0 mA */
- 0x00, /* __u8 DeviceRemovable; ** 7 Ports max ** */
- 0xff, /* __u8 PortPwrCtrlMask; ** 7 ports max ** */
-};
-
-static void c67x00_hub_reset_host_port(struct c67x00_sie *sie, int port)
-{
- struct c67x00_hcd *c67x00 = sie->private_data;
- unsigned long flags;
-
- c67x00_ll_husb_reset(sie, port);
-
- spin_lock_irqsave(&c67x00->lock, flags);
- c67x00_ll_husb_reset_port(sie, port);
- spin_unlock_irqrestore(&c67x00->lock, flags);
-
- c67x00_ll_set_husb_eot(sie->dev, DEFAULT_EOT);
-}
-
-static int c67x00_hub_status_data(struct usb_hcd *hcd, char *buf)
-{
- struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
- struct c67x00_sie *sie = c67x00->sie;
- u16 status;
- int i;
-
- *buf = 0;
- status = c67x00_ll_usb_get_status(sie);
- for (i = 0; i < C67X00_PORTS; i++)
- if (status & PORT_CONNECT_CHANGE(i))
- *buf |= (1 << i);
-
- /* bit 0 denotes hub change, b1..n port change */
- *buf <<= 1;
-
- return !!*buf;
-}
-
-static int c67x00_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
- u16 wIndex, char *buf, u16 wLength)
-{
- struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
- struct c67x00_sie *sie = c67x00->sie;
- u16 status, usb_status;
- int len = 0;
- unsigned int port = wIndex-1;
- u16 wPortChange, wPortStatus;
-
- switch (typeReq) {
-
- case GetHubStatus:
- *(__le32 *) buf = cpu_to_le32(0);
- len = 4; /* hub power */
- break;
-
- case GetPortStatus:
- if (wIndex > C67X00_PORTS)
- return -EPIPE;
-
- status = c67x00_ll_usb_get_status(sie);
- usb_status = c67x00_ll_get_usb_ctl(sie);
-
- wPortChange = 0;
- if (status & PORT_CONNECT_CHANGE(port))
- wPortChange |= USB_PORT_STAT_C_CONNECTION;
-
- wPortStatus = USB_PORT_STAT_POWER;
- if (!(status & PORT_SE0_STATUS(port)))
- wPortStatus |= USB_PORT_STAT_CONNECTION;
- if (usb_status & LOW_SPEED_PORT(port)) {
- wPortStatus |= USB_PORT_STAT_LOW_SPEED;
- c67x00->low_speed_ports |= (1 << port);
- } else
- c67x00->low_speed_ports &= ~(1 << port);
-
- if (usb_status & SOF_EOP_EN(port))
- wPortStatus |= USB_PORT_STAT_ENABLE;
-
- *(__le16 *) buf = cpu_to_le16(wPortStatus);
- *(__le16 *) (buf + 2) = cpu_to_le16(wPortChange);
- len = 4;
- break;
-
- case SetHubFeature: /* We don't implement these */
- case ClearHubFeature:
- switch (wValue) {
- case C_HUB_OVER_CURRENT:
- case C_HUB_LOCAL_POWER:
- len = 0;
- break;
-
- default:
- return -EPIPE;
- }
- break;
-
- case SetPortFeature:
- if (wIndex > C67X00_PORTS)
- return -EPIPE;
-
- switch (wValue) {
- case USB_PORT_FEAT_SUSPEND:
- dev_dbg(c67x00_hcd_dev(c67x00),
- "SetPortFeature %d (SUSPEND)\n", port);
- len = 0;
- break;
-
- case USB_PORT_FEAT_RESET:
- c67x00_hub_reset_host_port(sie, port);
- len = 0;
- break;
-
- case USB_PORT_FEAT_POWER:
- /* Power always enabled */
- len = 0;
- break;
-
- default:
- dev_dbg(c67x00_hcd_dev(c67x00),
- "%s: SetPortFeature %d (0x%04x) Error!\n",
- __func__, port, wValue);
- return -EPIPE;
- }
- break;
-
- case ClearPortFeature:
- if (wIndex > C67X00_PORTS)
- return -EPIPE;
-
- switch (wValue) {
- case USB_PORT_FEAT_ENABLE:
- /* Reset the port so that the c67x00 also notices the
- * disconnect */
- c67x00_hub_reset_host_port(sie, port);
- len = 0;
- break;
-
- case USB_PORT_FEAT_C_ENABLE:
- dev_dbg(c67x00_hcd_dev(c67x00),
- "ClearPortFeature (%d): C_ENABLE\n", port);
- len = 0;
- break;
-
- case USB_PORT_FEAT_SUSPEND:
- dev_dbg(c67x00_hcd_dev(c67x00),
- "ClearPortFeature (%d): SUSPEND\n", port);
- len = 0;
- break;
-
- case USB_PORT_FEAT_C_SUSPEND:
- dev_dbg(c67x00_hcd_dev(c67x00),
- "ClearPortFeature (%d): C_SUSPEND\n", port);
- len = 0;
- break;
-
- case USB_PORT_FEAT_POWER:
- dev_dbg(c67x00_hcd_dev(c67x00),
- "ClearPortFeature (%d): POWER\n", port);
- return -EPIPE;
-
- case USB_PORT_FEAT_C_CONNECTION:
- c67x00_ll_usb_clear_status(sie,
- PORT_CONNECT_CHANGE(port));
- len = 0;
- break;
-
- case USB_PORT_FEAT_C_OVER_CURRENT:
- dev_dbg(c67x00_hcd_dev(c67x00),
- "ClearPortFeature (%d): OVER_CURRENT\n", port);
- len = 0;
- break;
-
- case USB_PORT_FEAT_C_RESET:
- dev_dbg(c67x00_hcd_dev(c67x00),
- "ClearPortFeature (%d): C_RESET\n", port);
- len = 0;
- break;
-
- default:
- dev_dbg(c67x00_hcd_dev(c67x00),
- "%s: ClearPortFeature %d (0x%04x) Error!\n",
- __func__, port, wValue);
- return -EPIPE;
- }
- break;
-
- case GetHubDescriptor:
- len = min_t(unsigned int, sizeof(c67x00_hub_des), wLength);
- memcpy(buf, c67x00_hub_des, len);
- break;
-
- default:
- dev_dbg(c67x00_hcd_dev(c67x00), "%s: unknown\n", __func__);
- return -EPIPE;
- }
-
- return 0;
-}
-
-/* ---------------------------------------------------------------------
- * Main part of host controller driver
- */
-
-/**
- * c67x00_hcd_irq
- *
- * This function is called from the interrupt handler in c67x00-drv.c
- */
-static void c67x00_hcd_irq(struct c67x00_sie *sie, u16 int_status, u16 msg)
-{
- struct c67x00_hcd *c67x00 = sie->private_data;
- struct usb_hcd *hcd = c67x00_hcd_to_hcd(c67x00);
-
- /* Handle sie message flags */
- if (msg) {
- if (msg & HUSB_TDListDone)
- c67x00_sched_kick(c67x00);
- else
- dev_warn(c67x00_hcd_dev(c67x00),
- "Unknown SIE msg flag(s): 0x%04x\n", msg);
- }
-
- if (unlikely(hcd->state == HC_STATE_HALT))
- return;
-
- if (!HCD_HW_ACCESSIBLE(hcd))
- return;
-
- /* Handle Start of frame events */
- if (int_status & SOFEOP_FLG(sie->sie_num)) {
- c67x00_ll_usb_clear_status(sie, SOF_EOP_IRQ_FLG);
- c67x00_sched_kick(c67x00);
- }
-}
-
-/**
- * c67x00_hcd_start: Host controller start hook
- */
-static int c67x00_hcd_start(struct usb_hcd *hcd)
-{
- hcd->uses_new_polling = 1;
- hcd->state = HC_STATE_RUNNING;
- set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
-
- return 0;
-}
-
-/**
- * c67x00_hcd_stop: Host controller stop hook
- */
-static void c67x00_hcd_stop(struct usb_hcd *hcd)
-{
- /* Nothing to do */
-}
-
-static int c67x00_hcd_get_frame(struct usb_hcd *hcd)
-{
- struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
- u16 temp_val;
-
- dev_dbg(c67x00_hcd_dev(c67x00), "%s\n", __func__);
- temp_val = c67x00_ll_husb_get_frame(c67x00->sie);
- temp_val &= HOST_FRAME_MASK;
- return temp_val ? (temp_val - 1) : HOST_FRAME_MASK;
-}
-
-static struct hc_driver c67x00_hc_driver = {
- .description = "c67x00-hcd",
- .product_desc = "Cypress C67X00 Host Controller",
- .hcd_priv_size = sizeof(struct c67x00_hcd),
- .flags = HCD_USB11 | HCD_MEMORY,
-
- /*
- * basic lifecycle operations
- */
- .start = c67x00_hcd_start,
- .stop = c67x00_hcd_stop,
-
- /*
- * managing i/o requests and associated device resources
- */
- .urb_enqueue = c67x00_urb_enqueue,
- .urb_dequeue = c67x00_urb_dequeue,
- .endpoint_disable = c67x00_endpoint_disable,
-
- /*
- * scheduling support
- */
- .get_frame_number = c67x00_hcd_get_frame,
-
- /*
- * root hub support
- */
- .hub_status_data = c67x00_hub_status_data,
- .hub_control = c67x00_hub_control,
-};
-
-/* ---------------------------------------------------------------------
- * Setup/Teardown routines
- */
-
-int c67x00_hcd_probe(struct c67x00_sie *sie)
-{
- struct c67x00_hcd *c67x00;
- struct usb_hcd *hcd;
- unsigned long flags;
- int retval;
-
- if (usb_disabled())
- return -ENODEV;
-
- hcd = usb_create_hcd(&c67x00_hc_driver, sie_dev(sie), "c67x00_sie");
- if (!hcd) {
- retval = -ENOMEM;
- goto err0;
- }
- c67x00 = hcd_to_c67x00_hcd(hcd);
-
- spin_lock_init(&c67x00->lock);
- c67x00->sie = sie;
-
- INIT_LIST_HEAD(&c67x00->list[PIPE_ISOCHRONOUS]);
- INIT_LIST_HEAD(&c67x00->list[PIPE_INTERRUPT]);
- INIT_LIST_HEAD(&c67x00->list[PIPE_CONTROL]);
- INIT_LIST_HEAD(&c67x00->list[PIPE_BULK]);
- c67x00->urb_count = 0;
- INIT_LIST_HEAD(&c67x00->td_list);
- c67x00->td_base_addr = CY_HCD_BUF_ADDR + SIE_TD_OFFSET(sie->sie_num);
- c67x00->buf_base_addr = CY_HCD_BUF_ADDR + SIE_BUF_OFFSET(sie->sie_num);
- c67x00->max_frame_bw = MAX_FRAME_BW_STD;
-
- c67x00_ll_husb_init_host_port(sie);
-
- init_completion(&c67x00->endpoint_disable);
- retval = c67x00_sched_start_scheduler(c67x00);
- if (retval)
- goto err1;
-
- retval = usb_add_hcd(hcd, 0, 0);
- if (retval) {
- dev_dbg(sie_dev(sie), "%s: usb_add_hcd returned %d\n",
- __func__, retval);
- goto err2;
- }
-
- spin_lock_irqsave(&sie->lock, flags);
- sie->private_data = c67x00;
- sie->irq = c67x00_hcd_irq;
- spin_unlock_irqrestore(&sie->lock, flags);
-
- return retval;
-
- err2:
- c67x00_sched_stop_scheduler(c67x00);
- err1:
- usb_put_hcd(hcd);
- err0:
- return retval;
-}
-
-/* may be called with controller, bus, and devices active */
-void c67x00_hcd_remove(struct c67x00_sie *sie)
-{
- struct c67x00_hcd *c67x00 = sie->private_data;
- struct usb_hcd *hcd = c67x00_hcd_to_hcd(c67x00);
-
- c67x00_sched_stop_scheduler(c67x00);
- usb_remove_hcd(hcd);
- usb_put_hcd(hcd);
-}
diff --git a/ANDROID_3.4.5/drivers/usb/c67x00/c67x00-hcd.h b/ANDROID_3.4.5/drivers/usb/c67x00/c67x00-hcd.h
deleted file mode 100644
index e3d493d4..00000000
--- a/ANDROID_3.4.5/drivers/usb/c67x00/c67x00-hcd.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * c67x00-hcd.h: Cypress C67X00 USB HCD
- *
- * Copyright (C) 2006-2008 Barco N.V.
- * Derived from the Cypress cy7c67200/300 ezusb linux driver and
- * based on multiple host controller drivers inside the linux kernel.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA.
- */
-
-#ifndef _USB_C67X00_HCD_H
-#define _USB_C67X00_HCD_H
-
-#include
-#include
-#include
-#include
-#include
-#include "c67x00.h"
-
-/*
- * The following parameters depend on the CPU speed, bus speed, ...
- * These can be tuned for specific use cases, e.g. if isochronous transfers
- * are very important, bandwidth can be sacrificed to guarantee that the
- * 1ms deadline will be met.
- * If bulk transfers are important, the MAX_FRAME_BW can be increased,
- * but some (or many) isochronous deadlines might not be met.
- *
- * The values are specified in bittime.
- */
-
-/*
- * The current implementation switches between _STD (default) and _ISO (when
- * isochronous transfers are scheduled), in order to optimize the throughput
- * in normal cicrumstances, but also provide good isochronous behaviour.
- *
- * Bandwidth is described in bit time so with a 12MHz USB clock and 1ms
- * frames; there are 12000 bit times per frame.
- */
-
-#define TOTAL_FRAME_BW 12000
-#define DEFAULT_EOT 2250
-
-#define MAX_FRAME_BW_STD (TOTAL_FRAME_BW - DEFAULT_EOT)
-#define MAX_FRAME_BW_ISO 2400
-
-/*
- * Periodic transfers may only use 90% of the full frame, but as
- * we currently don't even use 90% of the full frame, we may
- * use the full usable time for periodic transfers.
- */
-#define MAX_PERIODIC_BW(full_bw) full_bw
-
-/* -------------------------------------------------------------------------- */
-
-struct c67x00_hcd {
- spinlock_t lock;
- struct c67x00_sie *sie;
- unsigned int low_speed_ports; /* bitmask of low speed ports */
- unsigned int urb_count;
- unsigned int urb_iso_count;
-
- struct list_head list[4]; /* iso, int, ctrl, bulk */
-#if PIPE_BULK != 3
-#error "Sanity check failed, this code presumes PIPE_... to range from 0 to 3"
-#endif
-
- /* USB bandwidth allocated to td_list */
- int bandwidth_allocated;
- /* USB bandwidth allocated for isoc/int transfer */
- int periodic_bw_allocated;
- struct list_head td_list;
- int max_frame_bw;
-
- u16 td_base_addr;
- u16 buf_base_addr;
- u16 next_td_addr;
- u16 next_buf_addr;
-
- struct tasklet_struct tasklet;
-
- struct completion endpoint_disable;
-
- u16 current_frame;
- u16 last_frame;
-};
-
-static inline struct c67x00_hcd *hcd_to_c67x00_hcd(struct usb_hcd *hcd)
-{
- return (struct c67x00_hcd *)(hcd->hcd_priv);
-}
-
-static inline struct usb_hcd *c67x00_hcd_to_hcd(struct c67x00_hcd *c67x00)
-{
- return container_of((void *)c67x00, struct usb_hcd, hcd_priv);
-}
-
-/* ---------------------------------------------------------------------
- * Functions used by c67x00-drv
- */
-
-int c67x00_hcd_probe(struct c67x00_sie *sie);
-void c67x00_hcd_remove(struct c67x00_sie *sie);
-
-/* ---------------------------------------------------------------------
- * Transfer Descriptor scheduling functions
- */
-int c67x00_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags);
-int c67x00_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status);
-void c67x00_endpoint_disable(struct usb_hcd *hcd,
- struct usb_host_endpoint *ep);
-
-void c67x00_hcd_msg_received(struct c67x00_sie *sie, u16 msg);
-void c67x00_sched_kick(struct c67x00_hcd *c67x00);
-int c67x00_sched_start_scheduler(struct c67x00_hcd *c67x00);
-void c67x00_sched_stop_scheduler(struct c67x00_hcd *c67x00);
-
-#define c67x00_hcd_dev(x) (c67x00_hcd_to_hcd(x)->self.controller)
-
-#endif /* _USB_C67X00_HCD_H */
diff --git a/ANDROID_3.4.5/drivers/usb/c67x00/c67x00-ll-hpi.c b/ANDROID_3.4.5/drivers/usb/c67x00/c67x00-ll-hpi.c
deleted file mode 100644
index a9636f43..00000000
--- a/ANDROID_3.4.5/drivers/usb/c67x00/c67x00-ll-hpi.c
+++ /dev/null
@@ -1,481 +0,0 @@
-/*
- * c67x00-ll-hpi.c: Cypress C67X00 USB Low level interface using HPI
- *
- * Copyright (C) 2006-2008 Barco N.V.
- * Derived from the Cypress cy7c67200/300 ezusb linux driver and
- * based on multiple host controller drivers inside the linux kernel.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA.
- */
-
-#include
-#include
-#include
-#include
-#include "c67x00.h"
-
-#define COMM_REGS 14
-
-struct c67x00_lcp_int_data {
- u16 regs[COMM_REGS];
-};
-
-/* -------------------------------------------------------------------------- */
-/* Interface definitions */
-
-#define COMM_ACK 0x0FED
-#define COMM_NAK 0xDEAD
-
-#define COMM_RESET 0xFA50
-#define COMM_EXEC_INT 0xCE01
-#define COMM_INT_NUM 0x01C2
-
-/* Registers 0 to COMM_REGS-1 */
-#define COMM_R(x) (0x01C4 + 2 * (x))
-
-#define HUSB_SIE_pCurrentTDPtr(x) ((x) ? 0x01B2 : 0x01B0)
-#define HUSB_SIE_pTDListDone_Sem(x) ((x) ? 0x01B8 : 0x01B6)
-#define HUSB_pEOT 0x01B4
-
-/* Software interrupts */
-/* 114, 115: */
-#define HUSB_SIE_INIT_INT(x) ((x) ? 0x0073 : 0x0072)
-#define HUSB_RESET_INT 0x0074
-
-#define SUSB_INIT_INT 0x0071
-#define SUSB_INIT_INT_LOC (SUSB_INIT_INT * 2)
-
-/* -----------------------------------------------------------------------
- * HPI implementation
- *
- * The c67x00 chip also support control via SPI or HSS serial
- * interfaces. However, this driver assumes that register access can
- * be performed from IRQ context. While this is a safe assuption with
- * the HPI interface, it is not true for the serial interfaces.
- */
-
-/* HPI registers */
-#define HPI_DATA 0
-#define HPI_MAILBOX 1
-#define HPI_ADDR 2
-#define HPI_STATUS 3
-
-static inline u16 hpi_read_reg(struct c67x00_device *dev, int reg)
-{
- return __raw_readw(dev->hpi.base + reg * dev->hpi.regstep);
-}
-
-static inline void hpi_write_reg(struct c67x00_device *dev, int reg, u16 value)
-{
- __raw_writew(value, dev->hpi.base + reg * dev->hpi.regstep);
-}
-
-static inline u16 hpi_read_word_nolock(struct c67x00_device *dev, u16 reg)
-{
- hpi_write_reg(dev, HPI_ADDR, reg);
- return hpi_read_reg(dev, HPI_DATA);
-}
-
-static u16 hpi_read_word(struct c67x00_device *dev, u16 reg)
-{
- u16 value;
- unsigned long flags;
-
- spin_lock_irqsave(&dev->hpi.lock, flags);
- value = hpi_read_word_nolock(dev, reg);
- spin_unlock_irqrestore(&dev->hpi.lock, flags);
-
- return value;
-}
-
-static void hpi_write_word_nolock(struct c67x00_device *dev, u16 reg, u16 value)
-{
- hpi_write_reg(dev, HPI_ADDR, reg);
- hpi_write_reg(dev, HPI_DATA, value);
-}
-
-static void hpi_write_word(struct c67x00_device *dev, u16 reg, u16 value)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&dev->hpi.lock, flags);
- hpi_write_word_nolock(dev, reg, value);
- spin_unlock_irqrestore(&dev->hpi.lock, flags);
-}
-
-/*
- * Only data is little endian, addr has cpu endianess
- */
-static void hpi_write_words_le16(struct c67x00_device *dev, u16 addr,
- __le16 *data, u16 count)
-{
- unsigned long flags;
- int i;
-
- spin_lock_irqsave(&dev->hpi.lock, flags);
-
- hpi_write_reg(dev, HPI_ADDR, addr);
- for (i = 0; i < count; i++)
- hpi_write_reg(dev, HPI_DATA, le16_to_cpu(*data++));
-
- spin_unlock_irqrestore(&dev->hpi.lock, flags);
-}
-
-/*
- * Only data is little endian, addr has cpu endianess
- */
-static void hpi_read_words_le16(struct c67x00_device *dev, u16 addr,
- __le16 *data, u16 count)
-{
- unsigned long flags;
- int i;
-
- spin_lock_irqsave(&dev->hpi.lock, flags);
- hpi_write_reg(dev, HPI_ADDR, addr);
- for (i = 0; i < count; i++)
- *data++ = cpu_to_le16(hpi_read_reg(dev, HPI_DATA));
-
- spin_unlock_irqrestore(&dev->hpi.lock, flags);
-}
-
-static void hpi_set_bits(struct c67x00_device *dev, u16 reg, u16 mask)
-{
- u16 value;
- unsigned long flags;
-
- spin_lock_irqsave(&dev->hpi.lock, flags);
- value = hpi_read_word_nolock(dev, reg);
- hpi_write_word_nolock(dev, reg, value | mask);
- spin_unlock_irqrestore(&dev->hpi.lock, flags);
-}
-
-static void hpi_clear_bits(struct c67x00_device *dev, u16 reg, u16 mask)
-{
- u16 value;
- unsigned long flags;
-
- spin_lock_irqsave(&dev->hpi.lock, flags);
- value = hpi_read_word_nolock(dev, reg);
- hpi_write_word_nolock(dev, reg, value & ~mask);
- spin_unlock_irqrestore(&dev->hpi.lock, flags);
-}
-
-static u16 hpi_recv_mbox(struct c67x00_device *dev)
-{
- u16 value;
- unsigned long flags;
-
- spin_lock_irqsave(&dev->hpi.lock, flags);
- value = hpi_read_reg(dev, HPI_MAILBOX);
- spin_unlock_irqrestore(&dev->hpi.lock, flags);
-
- return value;
-}
-
-static u16 hpi_send_mbox(struct c67x00_device *dev, u16 value)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&dev->hpi.lock, flags);
- hpi_write_reg(dev, HPI_MAILBOX, value);
- spin_unlock_irqrestore(&dev->hpi.lock, flags);
-
- return value;
-}
-
-u16 c67x00_ll_hpi_status(struct c67x00_device *dev)
-{
- u16 value;
- unsigned long flags;
-
- spin_lock_irqsave(&dev->hpi.lock, flags);
- value = hpi_read_reg(dev, HPI_STATUS);
- spin_unlock_irqrestore(&dev->hpi.lock, flags);
-
- return value;
-}
-
-void c67x00_ll_hpi_reg_init(struct c67x00_device *dev)
-{
- int i;
-
- hpi_recv_mbox(dev);
- c67x00_ll_hpi_status(dev);
- hpi_write_word(dev, HPI_IRQ_ROUTING_REG, 0);
-
- for (i = 0; i < C67X00_SIES; i++) {
- hpi_write_word(dev, SIEMSG_REG(i), 0);
- hpi_read_word(dev, SIEMSG_REG(i));
- }
-}
-
-void c67x00_ll_hpi_enable_sofeop(struct c67x00_sie *sie)
-{
- hpi_set_bits(sie->dev, HPI_IRQ_ROUTING_REG,
- SOFEOP_TO_HPI_EN(sie->sie_num));
-}
-
-void c67x00_ll_hpi_disable_sofeop(struct c67x00_sie *sie)
-{
- hpi_clear_bits(sie->dev, HPI_IRQ_ROUTING_REG,
- SOFEOP_TO_HPI_EN(sie->sie_num));
-}
-
-/* -------------------------------------------------------------------------- */
-/* Transactions */
-
-static inline u16 ll_recv_msg(struct c67x00_device *dev)
-{
- u16 res;
-
- res = wait_for_completion_timeout(&dev->hpi.lcp.msg_received, 5 * HZ);
- WARN_ON(!res);
-
- return (res == 0) ? -EIO : 0;
-}
-
-/* -------------------------------------------------------------------------- */
-/* General functions */
-
-u16 c67x00_ll_fetch_siemsg(struct c67x00_device *dev, int sie_num)
-{
- u16 val;
-
- val = hpi_read_word(dev, SIEMSG_REG(sie_num));
- /* clear register to allow next message */
- hpi_write_word(dev, SIEMSG_REG(sie_num), 0);
-
- return val;
-}
-
-u16 c67x00_ll_get_usb_ctl(struct c67x00_sie *sie)
-{
- return hpi_read_word(sie->dev, USB_CTL_REG(sie->sie_num));
-}
-
-/**
- * c67x00_ll_usb_clear_status - clear the USB status bits
- */
-void c67x00_ll_usb_clear_status(struct c67x00_sie *sie, u16 bits)
-{
- hpi_write_word(sie->dev, USB_STAT_REG(sie->sie_num), bits);
-}
-
-u16 c67x00_ll_usb_get_status(struct c67x00_sie *sie)
-{
- return hpi_read_word(sie->dev, USB_STAT_REG(sie->sie_num));
-}
-
-/* -------------------------------------------------------------------------- */
-
-static int c67x00_comm_exec_int(struct c67x00_device *dev, u16 nr,
- struct c67x00_lcp_int_data *data)
-{
- int i, rc;
-
- mutex_lock(&dev->hpi.lcp.mutex);
- hpi_write_word(dev, COMM_INT_NUM, nr);
- for (i = 0; i < COMM_REGS; i++)
- hpi_write_word(dev, COMM_R(i), data->regs[i]);
- hpi_send_mbox(dev, COMM_EXEC_INT);
- rc = ll_recv_msg(dev);
- mutex_unlock(&dev->hpi.lcp.mutex);
-
- return rc;
-}
-
-/* -------------------------------------------------------------------------- */
-/* Host specific functions */
-
-void c67x00_ll_set_husb_eot(struct c67x00_device *dev, u16 value)
-{
- mutex_lock(&dev->hpi.lcp.mutex);
- hpi_write_word(dev, HUSB_pEOT, value);
- mutex_unlock(&dev->hpi.lcp.mutex);
-}
-
-static inline void c67x00_ll_husb_sie_init(struct c67x00_sie *sie)
-{
- struct c67x00_device *dev = sie->dev;
- struct c67x00_lcp_int_data data;
- int rc;
-
- rc = c67x00_comm_exec_int(dev, HUSB_SIE_INIT_INT(sie->sie_num), &data);
- BUG_ON(rc); /* No return path for error code; crash spectacularly */
-}
-
-void c67x00_ll_husb_reset(struct c67x00_sie *sie, int port)
-{
- struct c67x00_device *dev = sie->dev;
- struct c67x00_lcp_int_data data;
- int rc;
-
- data.regs[0] = 50; /* Reset USB port for 50ms */
- data.regs[1] = port | (sie->sie_num << 1);
- rc = c67x00_comm_exec_int(dev, HUSB_RESET_INT, &data);
- BUG_ON(rc); /* No return path for error code; crash spectacularly */
-}
-
-void c67x00_ll_husb_set_current_td(struct c67x00_sie *sie, u16 addr)
-{
- hpi_write_word(sie->dev, HUSB_SIE_pCurrentTDPtr(sie->sie_num), addr);
-}
-
-u16 c67x00_ll_husb_get_current_td(struct c67x00_sie *sie)
-{
- return hpi_read_word(sie->dev, HUSB_SIE_pCurrentTDPtr(sie->sie_num));
-}
-
-u16 c67x00_ll_husb_get_frame(struct c67x00_sie *sie)
-{
- return hpi_read_word(sie->dev, HOST_FRAME_REG(sie->sie_num));
-}
-
-void c67x00_ll_husb_init_host_port(struct c67x00_sie *sie)
-{
- /* Set port into host mode */
- hpi_set_bits(sie->dev, USB_CTL_REG(sie->sie_num), HOST_MODE);
- c67x00_ll_husb_sie_init(sie);
- /* Clear interrupts */
- c67x00_ll_usb_clear_status(sie, HOST_STAT_MASK);
- /* Check */
- if (!(hpi_read_word(sie->dev, USB_CTL_REG(sie->sie_num)) & HOST_MODE))
- dev_warn(sie_dev(sie),
- "SIE %d not set to host mode\n", sie->sie_num);
-}
-
-void c67x00_ll_husb_reset_port(struct c67x00_sie *sie, int port)
-{
- /* Clear connect change */
- c67x00_ll_usb_clear_status(sie, PORT_CONNECT_CHANGE(port));
-
- /* Enable interrupts */
- hpi_set_bits(sie->dev, HPI_IRQ_ROUTING_REG,
- SOFEOP_TO_CPU_EN(sie->sie_num));
- hpi_set_bits(sie->dev, HOST_IRQ_EN_REG(sie->sie_num),
- SOF_EOP_IRQ_EN | DONE_IRQ_EN);
-
- /* Enable pull down transistors */
- hpi_set_bits(sie->dev, USB_CTL_REG(sie->sie_num), PORT_RES_EN(port));
-}
-
-/* -------------------------------------------------------------------------- */
-
-void c67x00_ll_irq(struct c67x00_device *dev, u16 int_status)
-{
- if ((int_status & MBX_OUT_FLG) == 0)
- return;
-
- dev->hpi.lcp.last_msg = hpi_recv_mbox(dev);
- complete(&dev->hpi.lcp.msg_received);
-}
-
-/* -------------------------------------------------------------------------- */
-
-int c67x00_ll_reset(struct c67x00_device *dev)
-{
- int rc;
-
- mutex_lock(&dev->hpi.lcp.mutex);
- hpi_send_mbox(dev, COMM_RESET);
- rc = ll_recv_msg(dev);
- mutex_unlock(&dev->hpi.lcp.mutex);
-
- return rc;
-}
-
-/* -------------------------------------------------------------------------- */
-
-/**
- * c67x00_ll_write_mem_le16 - write into c67x00 memory
- * Only data is little endian, addr has cpu endianess.
- */
-void c67x00_ll_write_mem_le16(struct c67x00_device *dev, u16 addr,
- void *data, int len)
-{
- u8 *buf = data;
-
- /* Sanity check */
- if (addr + len > 0xffff) {
- dev_err(&dev->pdev->dev,
- "Trying to write beyond writable region!\n");
- return;
- }
-
- if (addr & 0x01) {
- /* unaligned access */
- u16 tmp;
- tmp = hpi_read_word(dev, addr - 1);
- tmp = (tmp & 0x00ff) | (*buf++ << 8);
- hpi_write_word(dev, addr - 1, tmp);
- addr++;
- len--;
- }
-
- hpi_write_words_le16(dev, addr, (__le16 *)buf, len / 2);
- buf += len & ~0x01;
- addr += len & ~0x01;
- len &= 0x01;
-
- if (len) {
- u16 tmp;
- tmp = hpi_read_word(dev, addr);
- tmp = (tmp & 0xff00) | *buf;
- hpi_write_word(dev, addr, tmp);
- }
-}
-
-/**
- * c67x00_ll_read_mem_le16 - read from c67x00 memory
- * Only data is little endian, addr has cpu endianess.
- */
-void c67x00_ll_read_mem_le16(struct c67x00_device *dev, u16 addr,
- void *data, int len)
-{
- u8 *buf = data;
-
- if (addr & 0x01) {
- /* unaligned access */
- u16 tmp;
- tmp = hpi_read_word(dev, addr - 1);
- *buf++ = (tmp >> 8) & 0x00ff;
- addr++;
- len--;
- }
-
- hpi_read_words_le16(dev, addr, (__le16 *)buf, len / 2);
- buf += len & ~0x01;
- addr += len & ~0x01;
- len &= 0x01;
-
- if (len) {
- u16 tmp;
- tmp = hpi_read_word(dev, addr);
- *buf = tmp & 0x00ff;
- }
-}
-
-/* -------------------------------------------------------------------------- */
-
-void c67x00_ll_init(struct c67x00_device *dev)
-{
- mutex_init(&dev->hpi.lcp.mutex);
- init_completion(&dev->hpi.lcp.msg_received);
-}
-
-void c67x00_ll_release(struct c67x00_device *dev)
-{
-}
diff --git a/ANDROID_3.4.5/drivers/usb/c67x00/c67x00-sched.c b/ANDROID_3.4.5/drivers/usb/c67x00/c67x00-sched.c
deleted file mode 100644
index a03fbc15..00000000
--- a/ANDROID_3.4.5/drivers/usb/c67x00/c67x00-sched.c
+++ /dev/null
@@ -1,1171 +0,0 @@
-/*
- * c67x00-sched.c: Cypress C67X00 USB Host Controller Driver - TD scheduling
- *
- * Copyright (C) 2006-2008 Barco N.V.
- * Derived from the Cypress cy7c67200/300 ezusb linux driver and
- * based on multiple host controller drivers inside the linux kernel.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA.
- */
-
-#include
-#include
-
-#include "c67x00.h"
-#include "c67x00-hcd.h"
-
-/*
- * These are the stages for a control urb, they are kept
- * in both urb->interval and td->privdata.
- */
-#define SETUP_STAGE 0
-#define DATA_STAGE 1
-#define STATUS_STAGE 2
-
-/* -------------------------------------------------------------------------- */
-
-/**
- * struct c67x00_ep_data: Host endpoint data structure
- */
-struct c67x00_ep_data {
- struct list_head queue;
- struct list_head node;
- struct usb_host_endpoint *hep;
- struct usb_device *dev;
- u16 next_frame; /* For int/isoc transactions */
-};
-
-/**
- * struct c67x00_td
- *
- * Hardware parts are little endiannes, SW in CPU endianess.
- */
-struct c67x00_td {
- /* HW specific part */
- __le16 ly_base_addr; /* Bytes 0-1 */
- __le16 port_length; /* Bytes 2-3 */
- u8 pid_ep; /* Byte 4 */
- u8 dev_addr; /* Byte 5 */
- u8 ctrl_reg; /* Byte 6 */
- u8 status; /* Byte 7 */
- u8 retry_cnt; /* Byte 8 */
-#define TT_OFFSET 2
-#define TT_CONTROL 0
-#define TT_ISOCHRONOUS 1
-#define TT_BULK 2
-#define TT_INTERRUPT 3
- u8 residue; /* Byte 9 */
- __le16 next_td_addr; /* Bytes 10-11 */
- /* SW part */
- struct list_head td_list;
- u16 td_addr;
- void *data;
- struct urb *urb;
- unsigned long privdata;
-
- /* These are needed for handling the toggle bits:
- * an urb can be dequeued while a td is in progress
- * after checking the td, the toggle bit might need to
- * be fixed */
- struct c67x00_ep_data *ep_data;
- unsigned int pipe;
-};
-
-struct c67x00_urb_priv {
- struct list_head hep_node;
- struct urb *urb;
- int port;
- int cnt; /* packet number for isoc */
- int status;
- struct c67x00_ep_data *ep_data;
-};
-
-#define td_udev(td) ((td)->ep_data->dev)
-
-#define CY_TD_SIZE 12
-
-#define TD_PIDEP_OFFSET 0x04
-#define TD_PIDEPMASK_PID 0xF0
-#define TD_PIDEPMASK_EP 0x0F
-#define TD_PORTLENMASK_DL 0x02FF
-#define TD_PORTLENMASK_PN 0xC000
-
-#define TD_STATUS_OFFSET 0x07
-#define TD_STATUSMASK_ACK 0x01
-#define TD_STATUSMASK_ERR 0x02
-#define TD_STATUSMASK_TMOUT 0x04
-#define TD_STATUSMASK_SEQ 0x08
-#define TD_STATUSMASK_SETUP 0x10
-#define TD_STATUSMASK_OVF 0x20
-#define TD_STATUSMASK_NAK 0x40
-#define TD_STATUSMASK_STALL 0x80
-
-#define TD_ERROR_MASK (TD_STATUSMASK_ERR | TD_STATUSMASK_TMOUT | \
- TD_STATUSMASK_STALL)
-
-#define TD_RETRYCNT_OFFSET 0x08
-#define TD_RETRYCNTMASK_ACT_FLG 0x10
-#define TD_RETRYCNTMASK_TX_TYPE 0x0C
-#define TD_RETRYCNTMASK_RTY_CNT 0x03
-
-#define TD_RESIDUE_OVERFLOW 0x80
-
-#define TD_PID_IN 0x90
-
-/* Residue: signed 8bits, neg -> OVERFLOW, pos -> UNDERFLOW */
-#define td_residue(td) ((__s8)(td->residue))
-#define td_ly_base_addr(td) (__le16_to_cpu((td)->ly_base_addr))
-#define td_port_length(td) (__le16_to_cpu((td)->port_length))
-#define td_next_td_addr(td) (__le16_to_cpu((td)->next_td_addr))
-
-#define td_active(td) ((td)->retry_cnt & TD_RETRYCNTMASK_ACT_FLG)
-#define td_length(td) (td_port_length(td) & TD_PORTLENMASK_DL)
-
-#define td_sequence_ok(td) (!td->status || \
- (!(td->status & TD_STATUSMASK_SEQ) == \
- !(td->ctrl_reg & SEQ_SEL)))
-
-#define td_acked(td) (!td->status || \
- (td->status & TD_STATUSMASK_ACK))
-#define td_actual_bytes(td) (td_length(td) - td_residue(td))
-
-/* -------------------------------------------------------------------------- */
-
-#ifdef DEBUG
-
-/**
- * dbg_td - Dump the contents of the TD
- */
-static void dbg_td(struct c67x00_hcd *c67x00, struct c67x00_td *td, char *msg)
-{
- struct device *dev = c67x00_hcd_dev(c67x00);
-
- dev_dbg(dev, "### %s at 0x%04x\n", msg, td->td_addr);
- dev_dbg(dev, "urb: 0x%p\n", td->urb);
- dev_dbg(dev, "endpoint: %4d\n", usb_pipeendpoint(td->pipe));
- dev_dbg(dev, "pipeout: %4d\n", usb_pipeout(td->pipe));
- dev_dbg(dev, "ly_base_addr: 0x%04x\n", td_ly_base_addr(td));
- dev_dbg(dev, "port_length: 0x%04x\n", td_port_length(td));
- dev_dbg(dev, "pid_ep: 0x%02x\n", td->pid_ep);
- dev_dbg(dev, "dev_addr: 0x%02x\n", td->dev_addr);
- dev_dbg(dev, "ctrl_reg: 0x%02x\n", td->ctrl_reg);
- dev_dbg(dev, "status: 0x%02x\n", td->status);
- dev_dbg(dev, "retry_cnt: 0x%02x\n", td->retry_cnt);
- dev_dbg(dev, "residue: 0x%02x\n", td->residue);
- dev_dbg(dev, "next_td_addr: 0x%04x\n", td_next_td_addr(td));
- dev_dbg(dev, "data:");
- print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 1,
- td->data, td_length(td), 1);
-}
-#else /* DEBUG */
-
-static inline void
-dbg_td(struct c67x00_hcd *c67x00, struct c67x00_td *td, char *msg) { }
-
-#endif /* DEBUG */
-
-/* -------------------------------------------------------------------------- */
-/* Helper functions */
-
-static inline u16 c67x00_get_current_frame_number(struct c67x00_hcd *c67x00)
-{
- return c67x00_ll_husb_get_frame(c67x00->sie) & HOST_FRAME_MASK;
-}
-
-/**
- * frame_add
- * Software wraparound for framenumbers.
- */
-static inline u16 frame_add(u16 a, u16 b)
-{
- return (a + b) & HOST_FRAME_MASK;
-}
-
-/**
- * frame_after - is frame a after frame b
- */
-static inline int frame_after(u16 a, u16 b)
-{
- return ((HOST_FRAME_MASK + a - b) & HOST_FRAME_MASK) <
- (HOST_FRAME_MASK / 2);
-}
-
-/**
- * frame_after_eq - is frame a after or equal to frame b
- */
-static inline int frame_after_eq(u16 a, u16 b)
-{
- return ((HOST_FRAME_MASK + 1 + a - b) & HOST_FRAME_MASK) <
- (HOST_FRAME_MASK / 2);
-}
-
-/* -------------------------------------------------------------------------- */
-
-/**
- * c67x00_release_urb - remove link from all tds to this urb
- * Disconnects the urb from it's tds, so that it can be given back.
- * pre: urb->hcpriv != NULL
- */
-static void c67x00_release_urb(struct c67x00_hcd *c67x00, struct urb *urb)
-{
- struct c67x00_td *td;
- struct c67x00_urb_priv *urbp;
-
- BUG_ON(!urb);
-
- c67x00->urb_count--;
-
- if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
- c67x00->urb_iso_count--;
- if (c67x00->urb_iso_count == 0)
- c67x00->max_frame_bw = MAX_FRAME_BW_STD;
- }
-
- /* TODO this might be not so efficient when we've got many urbs!
- * Alternatives:
- * * only clear when needed
- * * keep a list of tds with each urbp
- */
- list_for_each_entry(td, &c67x00->td_list, td_list)
- if (urb == td->urb)
- td->urb = NULL;
-
- urbp = urb->hcpriv;
- urb->hcpriv = NULL;
- list_del(&urbp->hep_node);
- kfree(urbp);
-}
-
-/* -------------------------------------------------------------------------- */
-
-static struct c67x00_ep_data *
-c67x00_ep_data_alloc(struct c67x00_hcd *c67x00, struct urb *urb)
-{
- struct usb_host_endpoint *hep = urb->ep;
- struct c67x00_ep_data *ep_data;
- int type;
-
- c67x00->current_frame = c67x00_get_current_frame_number(c67x00);
-
- /* Check if endpoint already has a c67x00_ep_data struct allocated */
- if (hep->hcpriv) {
- ep_data = hep->hcpriv;
- if (frame_after(c67x00->current_frame, ep_data->next_frame))
- ep_data->next_frame =
- frame_add(c67x00->current_frame, 1);
- return hep->hcpriv;
- }
-
- /* Allocate and initialize a new c67x00 endpoint data structure */
- ep_data = kzalloc(sizeof(*ep_data), GFP_ATOMIC);
- if (!ep_data)
- return NULL;
-
- INIT_LIST_HEAD(&ep_data->queue);
- INIT_LIST_HEAD(&ep_data->node);
- ep_data->hep = hep;
-
- /* hold a reference to udev as long as this endpoint lives,
- * this is needed to possibly fix the data toggle */
- ep_data->dev = usb_get_dev(urb->dev);
- hep->hcpriv = ep_data;
-
- /* For ISOC and INT endpoints, start ASAP: */
- ep_data->next_frame = frame_add(c67x00->current_frame, 1);
-
- /* Add the endpoint data to one of the pipe lists; must be added
- in order of endpoint address */
- type = usb_pipetype(urb->pipe);
- if (list_empty(&ep_data->node)) {
- list_add(&ep_data->node, &c67x00->list[type]);
- } else {
- struct c67x00_ep_data *prev;
-
- list_for_each_entry(prev, &c67x00->list[type], node) {
- if (prev->hep->desc.bEndpointAddress >
- hep->desc.bEndpointAddress) {
- list_add(&ep_data->node, prev->node.prev);
- break;
- }
- }
- }
-
- return ep_data;
-}
-
-static int c67x00_ep_data_free(struct usb_host_endpoint *hep)
-{
- struct c67x00_ep_data *ep_data = hep->hcpriv;
-
- if (!ep_data)
- return 0;
-
- if (!list_empty(&ep_data->queue))
- return -EBUSY;
-
- usb_put_dev(ep_data->dev);
- list_del(&ep_data->queue);
- list_del(&ep_data->node);
-
- kfree(ep_data);
- hep->hcpriv = NULL;
-
- return 0;
-}
-
-void c67x00_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep)
-{
- struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
- unsigned long flags;
-
- if (!list_empty(&ep->urb_list))
- dev_warn(c67x00_hcd_dev(c67x00), "error: urb list not empty\n");
-
- spin_lock_irqsave(&c67x00->lock, flags);
-
- /* loop waiting for all transfers in the endpoint queue to complete */
- while (c67x00_ep_data_free(ep)) {
- /* Drop the lock so we can sleep waiting for the hardware */
- spin_unlock_irqrestore(&c67x00->lock, flags);
-
- /* it could happen that we reinitialize this completion, while
- * somebody was waiting for that completion. The timeout and
- * while loop handle such cases, but this might be improved */
- INIT_COMPLETION(c67x00->endpoint_disable);
- c67x00_sched_kick(c67x00);
- wait_for_completion_timeout(&c67x00->endpoint_disable, 1 * HZ);
-
- spin_lock_irqsave(&c67x00->lock, flags);
- }
-
- spin_unlock_irqrestore(&c67x00->lock, flags);
-}
-
-/* -------------------------------------------------------------------------- */
-
-static inline int get_root_port(struct usb_device *dev)
-{
- while (dev->parent->parent)
- dev = dev->parent;
- return dev->portnum;
-}
-
-int c67x00_urb_enqueue(struct usb_hcd *hcd,
- struct urb *urb, gfp_t mem_flags)
-{
- int ret;
- unsigned long flags;
- struct c67x00_urb_priv *urbp;
- struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
- int port = get_root_port(urb->dev)-1;
-
- spin_lock_irqsave(&c67x00->lock, flags);
-
- /* Make sure host controller is running */
- if (!HC_IS_RUNNING(hcd->state)) {
- ret = -ENODEV;
- goto err_not_linked;
- }
-
- ret = usb_hcd_link_urb_to_ep(hcd, urb);
- if (ret)
- goto err_not_linked;
-
- /* Allocate and initialize urb private data */
- urbp = kzalloc(sizeof(*urbp), mem_flags);
- if (!urbp) {
- ret = -ENOMEM;
- goto err_urbp;
- }
-
- INIT_LIST_HEAD(&urbp->hep_node);
- urbp->urb = urb;
- urbp->port = port;
-
- urbp->ep_data = c67x00_ep_data_alloc(c67x00, urb);
-
- if (!urbp->ep_data) {
- ret = -ENOMEM;
- goto err_epdata;
- }
-
- /* TODO claim bandwidth with usb_claim_bandwidth?
- * also release it somewhere! */
-
- urb->hcpriv = urbp;
-
- urb->actual_length = 0; /* Nothing received/transmitted yet */
-
- switch (usb_pipetype(urb->pipe)) {
- case PIPE_CONTROL:
- urb->interval = SETUP_STAGE;
- break;
- case PIPE_INTERRUPT:
- break;
- case PIPE_BULK:
- break;
- case PIPE_ISOCHRONOUS:
- if (c67x00->urb_iso_count == 0)
- c67x00->max_frame_bw = MAX_FRAME_BW_ISO;
- c67x00->urb_iso_count++;
- /* Assume always URB_ISO_ASAP, FIXME */
- if (list_empty(&urbp->ep_data->queue))
- urb->start_frame = urbp->ep_data->next_frame;
- else {
- /* Go right after the last one */
- struct urb *last_urb;
-
- last_urb = list_entry(urbp->ep_data->queue.prev,
- struct c67x00_urb_priv,
- hep_node)->urb;
- urb->start_frame =
- frame_add(last_urb->start_frame,
- last_urb->number_of_packets *
- last_urb->interval);
- }
- urbp->cnt = 0;
- break;
- }
-
- /* Add the URB to the endpoint queue */
- list_add_tail(&urbp->hep_node, &urbp->ep_data->queue);
-
- /* If this is the only URB, kick start the controller */
- if (!c67x00->urb_count++)
- c67x00_ll_hpi_enable_sofeop(c67x00->sie);
-
- c67x00_sched_kick(c67x00);
- spin_unlock_irqrestore(&c67x00->lock, flags);
-
- return 0;
-
-err_epdata:
- kfree(urbp);
-err_urbp:
- usb_hcd_unlink_urb_from_ep(hcd, urb);
-err_not_linked:
- spin_unlock_irqrestore(&c67x00->lock, flags);
-
- return ret;
-}
-
-int c67x00_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
-{
- struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
- unsigned long flags;
- int rc;
-
- spin_lock_irqsave(&c67x00->lock, flags);
- rc = usb_hcd_check_unlink_urb(hcd, urb, status);
- if (rc)
- goto done;
-
- c67x00_release_urb(c67x00, urb);
- usb_hcd_unlink_urb_from_ep(hcd, urb);
-
- spin_unlock(&c67x00->lock);
- usb_hcd_giveback_urb(hcd, urb, status);
- spin_lock(&c67x00->lock);
-
- spin_unlock_irqrestore(&c67x00->lock, flags);
-
- return 0;
-
- done:
- spin_unlock_irqrestore(&c67x00->lock, flags);
- return rc;
-}
-
-/* -------------------------------------------------------------------------- */
-
-/*
- * pre: c67x00 locked, urb unlocked
- */
-static void
-c67x00_giveback_urb(struct c67x00_hcd *c67x00, struct urb *urb, int status)
-{
- struct c67x00_urb_priv *urbp;
-
- if (!urb)
- return;
-
- urbp = urb->hcpriv;
- urbp->status = status;
-
- list_del_init(&urbp->hep_node);
-
- c67x00_release_urb(c67x00, urb);
- usb_hcd_unlink_urb_from_ep(c67x00_hcd_to_hcd(c67x00), urb);
- spin_unlock(&c67x00->lock);
- usb_hcd_giveback_urb(c67x00_hcd_to_hcd(c67x00), urb, urbp->status);
- spin_lock(&c67x00->lock);
-}
-
-/* -------------------------------------------------------------------------- */
-
-static int c67x00_claim_frame_bw(struct c67x00_hcd *c67x00, struct urb *urb,
- int len, int periodic)
-{
- struct c67x00_urb_priv *urbp = urb->hcpriv;
- int bit_time;
-
- /* According to the C67x00 BIOS user manual, page 3-18,19, the
- * following calculations provide the full speed bit times for
- * a transaction.
- *
- * FS(in) = 112.5 + 9.36*BC + HOST_DELAY
- * FS(in,iso) = 90.5 + 9.36*BC + HOST_DELAY
- * FS(out) = 112.5 + 9.36*BC + HOST_DELAY
- * FS(out,iso) = 78.4 + 9.36*BC + HOST_DELAY
- * LS(in) = 802.4 + 75.78*BC + HOST_DELAY
- * LS(out) = 802.6 + 74.67*BC + HOST_DELAY
- *
- * HOST_DELAY == 106 for the c67200 and c67300.
- */
-
- /* make calculations in 1/100 bit times to maintain resolution */
- if (urbp->ep_data->dev->speed == USB_SPEED_LOW) {
- /* Low speed pipe */
- if (usb_pipein(urb->pipe))
- bit_time = 80240 + 7578*len;
- else
- bit_time = 80260 + 7467*len;
- } else {
- /* FS pipes */
- if (usb_pipeisoc(urb->pipe))
- bit_time = usb_pipein(urb->pipe) ? 9050 : 7840;
- else
- bit_time = 11250;
- bit_time += 936*len;
- }
-
- /* Scale back down to integer bit times. Use a host delay of 106.
- * (this is the only place it is used) */
- bit_time = ((bit_time+50) / 100) + 106;
-
- if (unlikely(bit_time + c67x00->bandwidth_allocated >=
- c67x00->max_frame_bw))
- return -EMSGSIZE;
-
- if (unlikely(c67x00->next_td_addr + CY_TD_SIZE >=
- c67x00->td_base_addr + SIE_TD_SIZE))
- return -EMSGSIZE;
-
- if (unlikely(c67x00->next_buf_addr + len >=
- c67x00->buf_base_addr + SIE_TD_BUF_SIZE))
- return -EMSGSIZE;
-
- if (periodic) {
- if (unlikely(bit_time + c67x00->periodic_bw_allocated >=
- MAX_PERIODIC_BW(c67x00->max_frame_bw)))
- return -EMSGSIZE;
- c67x00->periodic_bw_allocated += bit_time;
- }
-
- c67x00->bandwidth_allocated += bit_time;
- return 0;
-}
-
-/* -------------------------------------------------------------------------- */
-
-/**
- * td_addr and buf_addr must be word aligned
- */
-static int c67x00_create_td(struct c67x00_hcd *c67x00, struct urb *urb,
- void *data, int len, int pid, int toggle,
- unsigned long privdata)
-{
- struct c67x00_td *td;
- struct c67x00_urb_priv *urbp = urb->hcpriv;
- const __u8 active_flag = 1, retry_cnt = 1;
- __u8 cmd = 0;
- int tt = 0;
-
- if (c67x00_claim_frame_bw(c67x00, urb, len, usb_pipeisoc(urb->pipe)
- || usb_pipeint(urb->pipe)))
- return -EMSGSIZE; /* Not really an error, but expected */
-
- td = kzalloc(sizeof(*td), GFP_ATOMIC);
- if (!td)
- return -ENOMEM;
-
- td->pipe = urb->pipe;
- td->ep_data = urbp->ep_data;
-
- if ((td_udev(td)->speed == USB_SPEED_LOW) &&
- !(c67x00->low_speed_ports & (1 << urbp->port)))
- cmd |= PREAMBLE_EN;
-
- switch (usb_pipetype(td->pipe)) {
- case PIPE_ISOCHRONOUS:
- tt = TT_ISOCHRONOUS;
- cmd |= ISO_EN;
- break;
- case PIPE_CONTROL:
- tt = TT_CONTROL;
- break;
- case PIPE_BULK:
- tt = TT_BULK;
- break;
- case PIPE_INTERRUPT:
- tt = TT_INTERRUPT;
- break;
- }
-
- if (toggle)
- cmd |= SEQ_SEL;
-
- cmd |= ARM_EN;
-
- /* SW part */
- td->td_addr = c67x00->next_td_addr;
- c67x00->next_td_addr = c67x00->next_td_addr + CY_TD_SIZE;
-
- /* HW part */
- td->ly_base_addr = __cpu_to_le16(c67x00->next_buf_addr);
- td->port_length = __cpu_to_le16((c67x00->sie->sie_num << 15) |
- (urbp->port << 14) | (len & 0x3FF));
- td->pid_ep = ((pid & 0xF) << TD_PIDEP_OFFSET) |
- (usb_pipeendpoint(td->pipe) & 0xF);
- td->dev_addr = usb_pipedevice(td->pipe) & 0x7F;
- td->ctrl_reg = cmd;
- td->status = 0;
- td->retry_cnt = (tt << TT_OFFSET) | (active_flag << 4) | retry_cnt;
- td->residue = 0;
- td->next_td_addr = __cpu_to_le16(c67x00->next_td_addr);
-
- /* SW part */
- td->data = data;
- td->urb = urb;
- td->privdata = privdata;
-
- c67x00->next_buf_addr += (len + 1) & ~0x01; /* properly align */
-
- list_add_tail(&td->td_list, &c67x00->td_list);
- return 0;
-}
-
-static inline void c67x00_release_td(struct c67x00_td *td)
-{
- list_del_init(&td->td_list);
- kfree(td);
-}
-
-/* -------------------------------------------------------------------------- */
-
-static int c67x00_add_data_urb(struct c67x00_hcd *c67x00, struct urb *urb)
-{
- int remaining;
- int toggle;
- int pid;
- int ret = 0;
- int maxps;
- int need_empty;
-
- toggle = usb_gettoggle(urb->dev, usb_pipeendpoint(urb->pipe),
- usb_pipeout(urb->pipe));
- remaining = urb->transfer_buffer_length - urb->actual_length;
-
- maxps = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe));
-
- need_empty = (urb->transfer_flags & URB_ZERO_PACKET) &&
- usb_pipeout(urb->pipe) && !(remaining % maxps);
-
- while (remaining || need_empty) {
- int len;
- char *td_buf;
-
- len = (remaining > maxps) ? maxps : remaining;
- if (!len)
- need_empty = 0;
-
- pid = usb_pipeout(urb->pipe) ? USB_PID_OUT : USB_PID_IN;
- td_buf = urb->transfer_buffer + urb->transfer_buffer_length -
- remaining;
- ret = c67x00_create_td(c67x00, urb, td_buf, len, pid, toggle,
- DATA_STAGE);
- if (ret)
- return ret; /* td wasn't created */
-
- toggle ^= 1;
- remaining -= len;
- if (usb_pipecontrol(urb->pipe))
- break;
- }
-
- return 0;
-}
-
-/**
- * return 0 in case more bandwidth is available, else errorcode
- */
-static int c67x00_add_ctrl_urb(struct c67x00_hcd *c67x00, struct urb *urb)
-{
- int ret;
- int pid;
-
- switch (urb->interval) {
- default:
- case SETUP_STAGE:
- ret = c67x00_create_td(c67x00, urb, urb->setup_packet,
- 8, USB_PID_SETUP, 0, SETUP_STAGE);
- if (ret)
- return ret;
- urb->interval = SETUP_STAGE;
- usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
- usb_pipeout(urb->pipe), 1);
- break;
- case DATA_STAGE:
- if (urb->transfer_buffer_length) {
- ret = c67x00_add_data_urb(c67x00, urb);
- if (ret)
- return ret;
- break;
- } /* else fallthrough */
- case STATUS_STAGE:
- pid = !usb_pipeout(urb->pipe) ? USB_PID_OUT : USB_PID_IN;
- ret = c67x00_create_td(c67x00, urb, NULL, 0, pid, 1,
- STATUS_STAGE);
- if (ret)
- return ret;
- break;
- }
-
- return 0;
-}
-
-/*
- * return 0 in case more bandwidth is available, else errorcode
- */
-static int c67x00_add_int_urb(struct c67x00_hcd *c67x00, struct urb *urb)
-{
- struct c67x00_urb_priv *urbp = urb->hcpriv;
-
- if (frame_after_eq(c67x00->current_frame, urbp->ep_data->next_frame)) {
- urbp->ep_data->next_frame =
- frame_add(urbp->ep_data->next_frame, urb->interval);
- return c67x00_add_data_urb(c67x00, urb);
- }
- return 0;
-}
-
-static int c67x00_add_iso_urb(struct c67x00_hcd *c67x00, struct urb *urb)
-{
- struct c67x00_urb_priv *urbp = urb->hcpriv;
-
- if (frame_after_eq(c67x00->current_frame, urbp->ep_data->next_frame)) {
- char *td_buf;
- int len, pid, ret;
-
- BUG_ON(urbp->cnt >= urb->number_of_packets);
-
- td_buf = urb->transfer_buffer +
- urb->iso_frame_desc[urbp->cnt].offset;
- len = urb->iso_frame_desc[urbp->cnt].length;
- pid = usb_pipeout(urb->pipe) ? USB_PID_OUT : USB_PID_IN;
-
- ret = c67x00_create_td(c67x00, urb, td_buf, len, pid, 0,
- urbp->cnt);
- if (ret) {
- printk(KERN_DEBUG "create failed: %d\n", ret);
- urb->iso_frame_desc[urbp->cnt].actual_length = 0;
- urb->iso_frame_desc[urbp->cnt].status = ret;
- if (urbp->cnt + 1 == urb->number_of_packets)
- c67x00_giveback_urb(c67x00, urb, 0);
- }
-
- urbp->ep_data->next_frame =
- frame_add(urbp->ep_data->next_frame, urb->interval);
- urbp->cnt++;
- }
- return 0;
-}
-
-/* -------------------------------------------------------------------------- */
-
-static void c67x00_fill_from_list(struct c67x00_hcd *c67x00, int type,
- int (*add)(struct c67x00_hcd *, struct urb *))
-{
- struct c67x00_ep_data *ep_data;
- struct urb *urb;
-
- /* traverse every endpoint on the list */
- list_for_each_entry(ep_data, &c67x00->list[type], node) {
- if (!list_empty(&ep_data->queue)) {
- /* and add the first urb */
- /* isochronous transfer rely on this */
- urb = list_entry(ep_data->queue.next,
- struct c67x00_urb_priv,
- hep_node)->urb;
- add(c67x00, urb);
- }
- }
-}
-
-static void c67x00_fill_frame(struct c67x00_hcd *c67x00)
-{
- struct c67x00_td *td, *ttd;
-
- /* Check if we can proceed */
- if (!list_empty(&c67x00->td_list)) {
- dev_warn(c67x00_hcd_dev(c67x00),
- "TD list not empty! This should not happen!\n");
- list_for_each_entry_safe(td, ttd, &c67x00->td_list, td_list) {
- dbg_td(c67x00, td, "Unprocessed td");
- c67x00_release_td(td);
- }
- }
-
- /* Reinitialize variables */
- c67x00->bandwidth_allocated = 0;
- c67x00->periodic_bw_allocated = 0;
-
- c67x00->next_td_addr = c67x00->td_base_addr;
- c67x00->next_buf_addr = c67x00->buf_base_addr;
-
- /* Fill the list */
- c67x00_fill_from_list(c67x00, PIPE_ISOCHRONOUS, c67x00_add_iso_urb);
- c67x00_fill_from_list(c67x00, PIPE_INTERRUPT, c67x00_add_int_urb);
- c67x00_fill_from_list(c67x00, PIPE_CONTROL, c67x00_add_ctrl_urb);
- c67x00_fill_from_list(c67x00, PIPE_BULK, c67x00_add_data_urb);
-}
-
-/* -------------------------------------------------------------------------- */
-
-/**
- * Get TD from C67X00
- */
-static inline void
-c67x00_parse_td(struct c67x00_hcd *c67x00, struct c67x00_td *td)
-{
- c67x00_ll_read_mem_le16(c67x00->sie->dev,
- td->td_addr, td, CY_TD_SIZE);
-
- if (usb_pipein(td->pipe) && td_actual_bytes(td))
- c67x00_ll_read_mem_le16(c67x00->sie->dev, td_ly_base_addr(td),
- td->data, td_actual_bytes(td));
-}
-
-static int c67x00_td_to_error(struct c67x00_hcd *c67x00, struct c67x00_td *td)
-{
- if (td->status & TD_STATUSMASK_ERR) {
- dbg_td(c67x00, td, "ERROR_FLAG");
- return -EILSEQ;
- }
- if (td->status & TD_STATUSMASK_STALL) {
- /* dbg_td(c67x00, td, "STALL"); */
- return -EPIPE;
- }
- if (td->status & TD_STATUSMASK_TMOUT) {
- dbg_td(c67x00, td, "TIMEOUT");
- return -ETIMEDOUT;
- }
-
- return 0;
-}
-
-static inline int c67x00_end_of_data(struct c67x00_td *td)
-{
- int maxps, need_empty, remaining;
- struct urb *urb = td->urb;
- int act_bytes;
-
- act_bytes = td_actual_bytes(td);
-
- if (unlikely(!act_bytes))
- return 1; /* This was an empty packet */
-
- maxps = usb_maxpacket(td_udev(td), td->pipe, usb_pipeout(td->pipe));
-
- if (unlikely(act_bytes < maxps))
- return 1; /* Smaller then full packet */
-
- remaining = urb->transfer_buffer_length - urb->actual_length;
- need_empty = (urb->transfer_flags & URB_ZERO_PACKET) &&
- usb_pipeout(urb->pipe) && !(remaining % maxps);
-
- if (unlikely(!remaining && !need_empty))
- return 1;
-
- return 0;
-}
-
-/* -------------------------------------------------------------------------- */
-
-/* Remove all td's from the list which come
- * after last_td and are meant for the same pipe.
- * This is used when a short packet has occurred */
-static inline void c67x00_clear_pipe(struct c67x00_hcd *c67x00,
- struct c67x00_td *last_td)
-{
- struct c67x00_td *td, *tmp;
- td = last_td;
- tmp = last_td;
- while (td->td_list.next != &c67x00->td_list) {
- td = list_entry(td->td_list.next, struct c67x00_td, td_list);
- if (td->pipe == last_td->pipe) {
- c67x00_release_td(td);
- td = tmp;
- }
- tmp = td;
- }
-}
-
-/* -------------------------------------------------------------------------- */
-
-static void c67x00_handle_successful_td(struct c67x00_hcd *c67x00,
- struct c67x00_td *td)
-{
- struct urb *urb = td->urb;
-
- if (!urb)
- return;
-
- urb->actual_length += td_actual_bytes(td);
-
- switch (usb_pipetype(td->pipe)) {
- /* isochronous tds are handled separately */
- case PIPE_CONTROL:
- switch (td->privdata) {
- case SETUP_STAGE:
- urb->interval =
- urb->transfer_buffer_length ?
- DATA_STAGE : STATUS_STAGE;
- /* Don't count setup_packet with normal data: */
- urb->actual_length = 0;
- break;
-
- case DATA_STAGE:
- if (c67x00_end_of_data(td)) {
- urb->interval = STATUS_STAGE;
- c67x00_clear_pipe(c67x00, td);
- }
- break;
-
- case STATUS_STAGE:
- urb->interval = 0;
- c67x00_giveback_urb(c67x00, urb, 0);
- break;
- }
- break;
-
- case PIPE_INTERRUPT:
- case PIPE_BULK:
- if (unlikely(c67x00_end_of_data(td))) {
- c67x00_clear_pipe(c67x00, td);
- c67x00_giveback_urb(c67x00, urb, 0);
- }
- break;
- }
-}
-
-static void c67x00_handle_isoc(struct c67x00_hcd *c67x00, struct c67x00_td *td)
-{
- struct urb *urb = td->urb;
- struct c67x00_urb_priv *urbp;
- int cnt;
-
- if (!urb)
- return;
-
- urbp = urb->hcpriv;
- cnt = td->privdata;
-
- if (td->status & TD_ERROR_MASK)
- urb->error_count++;
-
- urb->iso_frame_desc[cnt].actual_length = td_actual_bytes(td);
- urb->iso_frame_desc[cnt].status = c67x00_td_to_error(c67x00, td);
- if (cnt + 1 == urb->number_of_packets) /* Last packet */
- c67x00_giveback_urb(c67x00, urb, 0);
-}
-
-/* -------------------------------------------------------------------------- */
-
-/**
- * c67x00_check_td_list - handle tds which have been processed by the c67x00
- * pre: current_td == 0
- */
-static inline void c67x00_check_td_list(struct c67x00_hcd *c67x00)
-{
- struct c67x00_td *td, *tmp;
- struct urb *urb;
- int ack_ok;
- int clear_endpoint;
-
- list_for_each_entry_safe(td, tmp, &c67x00->td_list, td_list) {
- /* get the TD */
- c67x00_parse_td(c67x00, td);
- urb = td->urb; /* urb can be NULL! */
- ack_ok = 0;
- clear_endpoint = 1;
-
- /* Handle isochronous transfers separately */
- if (usb_pipeisoc(td->pipe)) {
- clear_endpoint = 0;
- c67x00_handle_isoc(c67x00, td);
- goto cont;
- }
-
- /* When an error occurs, all td's for that pipe go into an
- * inactive state. This state matches successful transfers so
- * we must make sure not to service them. */
- if (td->status & TD_ERROR_MASK) {
- c67x00_giveback_urb(c67x00, urb,
- c67x00_td_to_error(c67x00, td));
- goto cont;
- }
-
- if ((td->status & TD_STATUSMASK_NAK) || !td_sequence_ok(td) ||
- !td_acked(td))
- goto cont;
-
- /* Sequence ok and acked, don't need to fix toggle */
- ack_ok = 1;
-
- if (unlikely(td->status & TD_STATUSMASK_OVF)) {
- if (td_residue(td) & TD_RESIDUE_OVERFLOW) {
- /* Overflow */
- c67x00_giveback_urb(c67x00, urb, -EOVERFLOW);
- goto cont;
- }
- }
-
- clear_endpoint = 0;
- c67x00_handle_successful_td(c67x00, td);
-
-cont:
- if (clear_endpoint)
- c67x00_clear_pipe(c67x00, td);
- if (ack_ok)
- usb_settoggle(td_udev(td), usb_pipeendpoint(td->pipe),
- usb_pipeout(td->pipe),
- !(td->ctrl_reg & SEQ_SEL));
- /* next in list could have been removed, due to clear_pipe! */
- tmp = list_entry(td->td_list.next, typeof(*td), td_list);
- c67x00_release_td(td);
- }
-}
-
-/* -------------------------------------------------------------------------- */
-
-static inline int c67x00_all_tds_processed(struct c67x00_hcd *c67x00)
-{
- /* If all tds are processed, we can check the previous frame (if
- * there was any) and start our next frame.
- */
- return !c67x00_ll_husb_get_current_td(c67x00->sie);
-}
-
-/**
- * Send td to C67X00
- */
-static void c67x00_send_td(struct c67x00_hcd *c67x00, struct c67x00_td *td)
-{
- int len = td_length(td);
-
- if (len && ((td->pid_ep & TD_PIDEPMASK_PID) != TD_PID_IN))
- c67x00_ll_write_mem_le16(c67x00->sie->dev, td_ly_base_addr(td),
- td->data, len);
-
- c67x00_ll_write_mem_le16(c67x00->sie->dev,
- td->td_addr, td, CY_TD_SIZE);
-}
-
-static void c67x00_send_frame(struct c67x00_hcd *c67x00)
-{
- struct c67x00_td *td;
-
- if (list_empty(&c67x00->td_list))
- dev_warn(c67x00_hcd_dev(c67x00),
- "%s: td list should not be empty here!\n",
- __func__);
-
- list_for_each_entry(td, &c67x00->td_list, td_list) {
- if (td->td_list.next == &c67x00->td_list)
- td->next_td_addr = 0; /* Last td in list */
-
- c67x00_send_td(c67x00, td);
- }
-
- c67x00_ll_husb_set_current_td(c67x00->sie, c67x00->td_base_addr);
-}
-
-/* -------------------------------------------------------------------------- */
-
-/**
- * c67x00_do_work - Schedulers state machine
- */
-static void c67x00_do_work(struct c67x00_hcd *c67x00)
-{
- spin_lock(&c67x00->lock);
- /* Make sure all tds are processed */
- if (!c67x00_all_tds_processed(c67x00))
- goto out;
-
- c67x00_check_td_list(c67x00);
-
- /* no td's are being processed (current == 0)
- * and all have been "checked" */
- complete(&c67x00->endpoint_disable);
-
- if (!list_empty(&c67x00->td_list))
- goto out;
-
- c67x00->current_frame = c67x00_get_current_frame_number(c67x00);
- if (c67x00->current_frame == c67x00->last_frame)
- goto out; /* Don't send tds in same frame */
- c67x00->last_frame = c67x00->current_frame;
-
- /* If no urbs are scheduled, our work is done */
- if (!c67x00->urb_count) {
- c67x00_ll_hpi_disable_sofeop(c67x00->sie);
- goto out;
- }
-
- c67x00_fill_frame(c67x00);
- if (!list_empty(&c67x00->td_list))
- /* TD's have been added to the frame */
- c67x00_send_frame(c67x00);
-
- out:
- spin_unlock(&c67x00->lock);
-}
-
-/* -------------------------------------------------------------------------- */
-
-static void c67x00_sched_tasklet(unsigned long __c67x00)
-{
- struct c67x00_hcd *c67x00 = (struct c67x00_hcd *)__c67x00;
- c67x00_do_work(c67x00);
-}
-
-void c67x00_sched_kick(struct c67x00_hcd *c67x00)
-{
- tasklet_hi_schedule(&c67x00->tasklet);
-}
-
-int c67x00_sched_start_scheduler(struct c67x00_hcd *c67x00)
-{
- tasklet_init(&c67x00->tasklet, c67x00_sched_tasklet,
- (unsigned long)c67x00);
- return 0;
-}
-
-void c67x00_sched_stop_scheduler(struct c67x00_hcd *c67x00)
-{
- tasklet_kill(&c67x00->tasklet);
-}
diff --git a/ANDROID_3.4.5/drivers/usb/c67x00/c67x00.h b/ANDROID_3.4.5/drivers/usb/c67x00/c67x00.h
deleted file mode 100644
index a26e9ded..00000000
--- a/ANDROID_3.4.5/drivers/usb/c67x00/c67x00.h
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * c67x00.h: Cypress C67X00 USB register and field definitions
- *
- * Copyright (C) 2006-2008 Barco N.V.
- * Derived from the Cypress cy7c67200/300 ezusb linux driver and
- * based on multiple host controller drivers inside the linux kernel.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA.
- */
-
-#ifndef _USB_C67X00_H
-#define _USB_C67X00_H
-
-#include
-#include
-#include
-#include
-
-/* ---------------------------------------------------------------------
- * Cypress C67x00 register definitions
- */
-
-/* Hardware Revision Register */
-#define HW_REV_REG 0xC004
-
-/* General USB registers */
-/* ===================== */
-
-/* USB Control Register */
-#define USB_CTL_REG(x) ((x) ? 0xC0AA : 0xC08A)
-
-#define LOW_SPEED_PORT(x) ((x) ? 0x0800 : 0x0400)
-#define HOST_MODE 0x0200
-#define PORT_RES_EN(x) ((x) ? 0x0100 : 0x0080)
-#define SOF_EOP_EN(x) ((x) ? 0x0002 : 0x0001)
-
-/* USB status register - Notice it has different content in hcd/udc mode */
-#define USB_STAT_REG(x) ((x) ? 0xC0B0 : 0xC090)
-
-#define EP0_IRQ_FLG 0x0001
-#define EP1_IRQ_FLG 0x0002
-#define EP2_IRQ_FLG 0x0004
-#define EP3_IRQ_FLG 0x0008
-#define EP4_IRQ_FLG 0x0010
-#define EP5_IRQ_FLG 0x0020
-#define EP6_IRQ_FLG 0x0040
-#define EP7_IRQ_FLG 0x0080
-#define RESET_IRQ_FLG 0x0100
-#define SOF_EOP_IRQ_FLG 0x0200
-#define ID_IRQ_FLG 0x4000
-#define VBUS_IRQ_FLG 0x8000
-
-/* USB Host only registers */
-/* ======================= */
-
-/* Host n Control Register */
-#define HOST_CTL_REG(x) ((x) ? 0xC0A0 : 0xC080)
-
-#define PREAMBLE_EN 0x0080 /* Preamble enable */
-#define SEQ_SEL 0x0040 /* Data Toggle Sequence Bit Select */
-#define ISO_EN 0x0010 /* Isochronous enable */
-#define ARM_EN 0x0001 /* Arm operation */
-
-/* Host n Interrupt Enable Register */
-#define HOST_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C)
-
-#define SOF_EOP_IRQ_EN 0x0200 /* SOF/EOP Interrupt Enable */
-#define SOF_EOP_TMOUT_IRQ_EN 0x0800 /* SOF/EOP Timeout Interrupt Enable */
-#define ID_IRQ_EN 0x4000 /* ID interrupt enable */
-#define VBUS_IRQ_EN 0x8000 /* VBUS interrupt enable */
-#define DONE_IRQ_EN 0x0001 /* Done Interrupt Enable */
-
-/* USB status register */
-#define HOST_STAT_MASK 0x02FD
-#define PORT_CONNECT_CHANGE(x) ((x) ? 0x0020 : 0x0010)
-#define PORT_SE0_STATUS(x) ((x) ? 0x0008 : 0x0004)
-
-/* Host Frame Register */
-#define HOST_FRAME_REG(x) ((x) ? 0xC0B6 : 0xC096)
-
-#define HOST_FRAME_MASK 0x07FF
-
-/* USB Peripheral only registers */
-/* ============================= */
-
-/* Device n Port Sel reg */
-#define DEVICE_N_PORT_SEL(x) ((x) ? 0xC0A4 : 0xC084)
-
-/* Device n Interrupt Enable Register */
-#define DEVICE_N_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C)
-
-#define DEVICE_N_ENDPOINT_N_CTL_REG(dev, ep) ((dev) \
- ? (0x0280 + (ep << 4)) \
- : (0x0200 + (ep << 4)))
-#define DEVICE_N_ENDPOINT_N_STAT_REG(dev, ep) ((dev) \
- ? (0x0286 + (ep << 4)) \
- : (0x0206 + (ep << 4)))
-
-#define DEVICE_N_ADDRESS(dev) ((dev) ? (0xC0AE) : (0xC08E))
-
-/* HPI registers */
-/* ============= */
-
-/* HPI Status register */
-#define SOFEOP_FLG(x) (1 << ((x) ? 12 : 10))
-#define SIEMSG_FLG(x) (1 << (4 + (x)))
-#define RESET_FLG(x) ((x) ? 0x0200 : 0x0002)
-#define DONE_FLG(x) (1 << (2 + (x)))
-#define RESUME_FLG(x) (1 << (6 + (x)))
-#define MBX_OUT_FLG 0x0001 /* Message out available */
-#define MBX_IN_FLG 0x0100
-#define ID_FLG 0x4000
-#define VBUS_FLG 0x8000
-
-/* Interrupt routing register */
-#define HPI_IRQ_ROUTING_REG 0x0142
-
-#define HPI_SWAP_ENABLE(x) ((x) ? 0x0100 : 0x0001)
-#define RESET_TO_HPI_ENABLE(x) ((x) ? 0x0200 : 0x0002)
-#define DONE_TO_HPI_ENABLE(x) ((x) ? 0x0008 : 0x0004)
-#define RESUME_TO_HPI_ENABLE(x) ((x) ? 0x0080 : 0x0040)
-#define SOFEOP_TO_HPI_EN(x) ((x) ? 0x2000 : 0x0800)
-#define SOFEOP_TO_CPU_EN(x) ((x) ? 0x1000 : 0x0400)
-#define ID_TO_HPI_ENABLE 0x4000
-#define VBUS_TO_HPI_ENABLE 0x8000
-
-/* SIE msg registers */
-#define SIEMSG_REG(x) ((x) ? 0x0148 : 0x0144)
-
-#define HUSB_TDListDone 0x1000
-
-#define SUSB_EP0_MSG 0x0001
-#define SUSB_EP1_MSG 0x0002
-#define SUSB_EP2_MSG 0x0004
-#define SUSB_EP3_MSG 0x0008
-#define SUSB_EP4_MSG 0x0010
-#define SUSB_EP5_MSG 0x0020
-#define SUSB_EP6_MSG 0x0040
-#define SUSB_EP7_MSG 0x0080
-#define SUSB_RST_MSG 0x0100
-#define SUSB_SOF_MSG 0x0200
-#define SUSB_CFG_MSG 0x0400
-#define SUSB_SUS_MSG 0x0800
-#define SUSB_ID_MSG 0x4000
-#define SUSB_VBUS_MSG 0x8000
-
-/* BIOS interrupt routines */
-
-#define SUSBx_RECEIVE_INT(x) ((x) ? 97 : 81)
-#define SUSBx_SEND_INT(x) ((x) ? 96 : 80)
-
-#define SUSBx_DEV_DESC_VEC(x) ((x) ? 0x00D4 : 0x00B4)
-#define SUSBx_CONF_DESC_VEC(x) ((x) ? 0x00D6 : 0x00B6)
-#define SUSBx_STRING_DESC_VEC(x) ((x) ? 0x00D8 : 0x00B8)
-
-#define CY_HCD_BUF_ADDR 0x500 /* Base address for host */
-#define SIE_TD_SIZE 0x200 /* size of the td list */
-#define SIE_TD_BUF_SIZE 0x400 /* size of the data buffer */
-
-#define SIE_TD_OFFSET(host) ((host) ? (SIE_TD_SIZE+SIE_TD_BUF_SIZE) : 0)
-#define SIE_BUF_OFFSET(host) (SIE_TD_OFFSET(host) + SIE_TD_SIZE)
-
-/* Base address of HCD + 2 x TD_SIZE + 2 x TD_BUF_SIZE */
-#define CY_UDC_REQ_HEADER_BASE 0x1100
-/* 8- byte request headers for IN/OUT transfers */
-#define CY_UDC_REQ_HEADER_SIZE 8
-
-#define CY_UDC_REQ_HEADER_ADDR(ep_num) (CY_UDC_REQ_HEADER_BASE + \
- ((ep_num) * CY_UDC_REQ_HEADER_SIZE))
-#define CY_UDC_DESC_BASE_ADDRESS (CY_UDC_REQ_HEADER_ADDR(8))
-
-#define CY_UDC_BIOS_REPLACE_BASE 0x1800
-#define CY_UDC_REQ_BUFFER_BASE 0x2000
-#define CY_UDC_REQ_BUFFER_SIZE 0x0400
-#define CY_UDC_REQ_BUFFER_ADDR(ep_num) (CY_UDC_REQ_BUFFER_BASE + \
- ((ep_num) * CY_UDC_REQ_BUFFER_SIZE))
-
-/* ---------------------------------------------------------------------
- * Driver data structures
- */
-
-struct c67x00_device;
-
-/**
- * struct c67x00_sie - Common data associated with a SIE
- * @lock: lock to protect this struct and the associated chip registers
- * @private_data: subdriver dependent data
- * @irq: subdriver dependent irq handler, set NULL when not used
- * @dev: link to common driver structure
- * @sie_num: SIE number on chip, starting from 0
- * @mode: SIE mode (host/peripheral/otg/not used)
- */
-struct c67x00_sie {
- /* Entries to be used by the subdrivers */
- spinlock_t lock; /* protect this structure */
- void *private_data;
- void (*irq) (struct c67x00_sie *sie, u16 int_status, u16 msg);
-
- /* Read only: */
- struct c67x00_device *dev;
- int sie_num;
- int mode;
-};
-
-#define sie_dev(s) (&(s)->dev->pdev->dev)
-
-/**
- * struct c67x00_lcp
- */
-struct c67x00_lcp {
- /* Internal use only */
- struct mutex mutex;
- struct completion msg_received;
- u16 last_msg;
-};
-
-/*
- * struct c67x00_hpi
- */
-struct c67x00_hpi {
- void __iomem *base;
- int regstep;
- spinlock_t lock;
- struct c67x00_lcp lcp;
-};
-
-#define C67X00_SIES 2
-#define C67X00_PORTS 2
-
-/**
- * struct c67x00_device - Common data associated with a c67x00 instance
- * @hpi: hpi addresses
- * @sie: array of sie's on this chip
- * @pdev: platform device of instance
- * @pdata: configuration provided by the platform
- */
-struct c67x00_device {
- struct c67x00_hpi hpi;
- struct c67x00_sie sie[C67X00_SIES];
- struct platform_device *pdev;
- struct c67x00_platform_data *pdata;
-};
-
-/* ---------------------------------------------------------------------
- * Low level interface functions
- */
-
-/* Host Port Interface (HPI) functions */
-u16 c67x00_ll_hpi_status(struct c67x00_device *dev);
-void c67x00_ll_hpi_reg_init(struct c67x00_device *dev);
-void c67x00_ll_hpi_enable_sofeop(struct c67x00_sie *sie);
-void c67x00_ll_hpi_disable_sofeop(struct c67x00_sie *sie);
-
-/* General functions */
-u16 c67x00_ll_fetch_siemsg(struct c67x00_device *dev, int sie_num);
-u16 c67x00_ll_get_usb_ctl(struct c67x00_sie *sie);
-void c67x00_ll_usb_clear_status(struct c67x00_sie *sie, u16 bits);
-u16 c67x00_ll_usb_get_status(struct c67x00_sie *sie);
-void c67x00_ll_write_mem_le16(struct c67x00_device *dev, u16 addr,
- void *data, int len);
-void c67x00_ll_read_mem_le16(struct c67x00_device *dev, u16 addr,
- void *data, int len);
-
-/* Host specific functions */
-void c67x00_ll_set_husb_eot(struct c67x00_device *dev, u16 value);
-void c67x00_ll_husb_reset(struct c67x00_sie *sie, int port);
-void c67x00_ll_husb_set_current_td(struct c67x00_sie *sie, u16 addr);
-u16 c67x00_ll_husb_get_current_td(struct c67x00_sie *sie);
-u16 c67x00_ll_husb_get_frame(struct c67x00_sie *sie);
-void c67x00_ll_husb_init_host_port(struct c67x00_sie *sie);
-void c67x00_ll_husb_reset_port(struct c67x00_sie *sie, int port);
-
-/* Called by c67x00_irq to handle lcp interrupts */
-void c67x00_ll_irq(struct c67x00_device *dev, u16 int_status);
-
-/* Setup and teardown */
-void c67x00_ll_init(struct c67x00_device *dev);
-void c67x00_ll_release(struct c67x00_device *dev);
-int c67x00_ll_reset(struct c67x00_device *dev);
-
-#endif /* _USB_C67X00_H */
diff --git a/ANDROID_3.4.5/drivers/usb/class/Kconfig b/ANDROID_3.4.5/drivers/usb/class/Kconfig
deleted file mode 100644
index 2519e320..00000000
--- a/ANDROID_3.4.5/drivers/usb/class/Kconfig
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# USB Class driver configuration
-#
-comment "USB Device Class drivers"
- depends on USB
-
-config USB_ACM
- tristate "USB Modem (CDC ACM) support"
- depends on USB
- ---help---
- This driver supports USB modems and ISDN adapters which support the
- Communication Device Class Abstract Control Model interface.
- Please read for details.
-
- If your modem only reports "Cls=ff(vend.)" in the descriptors in
- /proc/bus/usb/devices, then your modem will not work with this
- driver.
-
- To compile this driver as a module, choose M here: the
- module will be called cdc-acm.
-
-config USB_PRINTER
- tristate "USB Printer support"
- depends on USB
- help
- Say Y here if you want to connect a USB printer to your computer's
- USB port.
-
- To compile this driver as a module, choose M here: the
- module will be called usblp.
-
-config USB_WDM
- tristate "USB Wireless Device Management support"
- depends on USB
- ---help---
- This driver supports the WMC Device Management functionality
- of cell phones compliant to the CDC WMC specification. You can use
- AT commands over this device.
-
- To compile this driver as a module, choose M here: the
- module will be called cdc-wdm.
-
-config USB_TMC
- tristate "USB Test and Measurement Class support"
- depends on USB
- help
- Say Y here if you want to connect a USB device that follows
- the USB.org specification for USB Test and Measurement devices
- to your computer's USB port.
-
- To compile this driver as a module, choose M here: the
- module will be called usbtmc.
diff --git a/ANDROID_3.4.5/drivers/usb/class/Makefile b/ANDROID_3.4.5/drivers/usb/class/Makefile
deleted file mode 100644
index 32e85277..00000000
--- a/ANDROID_3.4.5/drivers/usb/class/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Makefile for USB Class drivers
-# (one step up from the misc category)
-#
-
-obj-$(CONFIG_USB_ACM) += cdc-acm.o
-obj-$(CONFIG_USB_PRINTER) += usblp.o
-obj-$(CONFIG_USB_WDM) += cdc-wdm.o
-obj-$(CONFIG_USB_TMC) += usbtmc.o
diff --git a/ANDROID_3.4.5/drivers/usb/class/cdc-acm.c b/ANDROID_3.4.5/drivers/usb/class/cdc-acm.c
deleted file mode 100644
index 640cf798..00000000
--- a/ANDROID_3.4.5/drivers/usb/class/cdc-acm.c
+++ /dev/null
@@ -1,1752 +0,0 @@
-/*
- * cdc-acm.c
- *
- * Copyright (c) 1999 Armin Fuerst
- * Copyright (c) 1999 Pavel Machek
- * Copyright (c) 1999 Johannes Erdfelt
- * Copyright (c) 2000 Vojtech Pavlik
- * Copyright (c) 2004 Oliver Neukum
- * Copyright (c) 2005 David Kubicek
- * Copyright (c) 2011 Johan Hovold
- *
- * USB Abstract Control Model driver for USB modems and ISDN adapters
- *
- * Sponsored by SuSE
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#undef DEBUG
-#undef VERBOSE_DEBUG
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "cdc-acm.h"
-
-
-#define DRIVER_AUTHOR "Armin Fuerst, Pavel Machek, Johannes Erdfelt, Vojtech Pavlik, David Kubicek, Johan Hovold"
-#define DRIVER_DESC "USB Abstract Control Model driver for USB modems and ISDN adapters"
-
-static struct usb_driver acm_driver;
-static struct tty_driver *acm_tty_driver;
-static struct acm *acm_table[ACM_TTY_MINORS];
-
-static DEFINE_MUTEX(acm_table_lock);
-
-/*
- * acm_table accessors
- */
-
-/*
- * Look up an ACM structure by index. If found and not disconnected, increment
- * its refcount and return it with its mutex held.
- */
-static struct acm *acm_get_by_index(unsigned index)
-{
- struct acm *acm;
-
- mutex_lock(&acm_table_lock);
- acm = acm_table[index];
- if (acm) {
- mutex_lock(&acm->mutex);
- if (acm->disconnected) {
- mutex_unlock(&acm->mutex);
- acm = NULL;
- } else {
- tty_port_get(&acm->port);
- mutex_unlock(&acm->mutex);
- }
- }
- mutex_unlock(&acm_table_lock);
- return acm;
-}
-
-/*
- * Try to find an available minor number and if found, associate it with 'acm'.
- */
-static int acm_alloc_minor(struct acm *acm)
-{
- int minor;
-
- mutex_lock(&acm_table_lock);
- for (minor = 0; minor < ACM_TTY_MINORS; minor++) {
- if (!acm_table[minor]) {
- acm_table[minor] = acm;
- break;
- }
- }
- mutex_unlock(&acm_table_lock);
-
- return minor;
-}
-
-/* Release the minor number associated with 'acm'. */
-static void acm_release_minor(struct acm *acm)
-{
- mutex_lock(&acm_table_lock);
- acm_table[acm->minor] = NULL;
- mutex_unlock(&acm_table_lock);
-}
-
-/*
- * Functions for ACM control messages.
- */
-
-static int acm_ctrl_msg(struct acm *acm, int request, int value,
- void *buf, int len)
-{
- int retval = usb_control_msg(acm->dev, usb_sndctrlpipe(acm->dev, 0),
- request, USB_RT_ACM, value,
- acm->control->altsetting[0].desc.bInterfaceNumber,
- buf, len, 5000);
- dev_dbg(&acm->control->dev,
- "%s - rq 0x%02x, val %#x, len %#x, result %d\n",
- __func__, request, value, len, retval);
- return retval < 0 ? retval : 0;
-}
-
-/* devices aren't required to support these requests.
- * the cdc acm descriptor tells whether they do...
- */
-#define acm_set_control(acm, control) \
- acm_ctrl_msg(acm, USB_CDC_REQ_SET_CONTROL_LINE_STATE, control, NULL, 0)
-#define acm_set_line(acm, line) \
- acm_ctrl_msg(acm, USB_CDC_REQ_SET_LINE_CODING, 0, line, sizeof *(line))
-#define acm_send_break(acm, ms) \
- acm_ctrl_msg(acm, USB_CDC_REQ_SEND_BREAK, ms, NULL, 0)
-
-/*
- * Write buffer management.
- * All of these assume proper locks taken by the caller.
- */
-
-static int acm_wb_alloc(struct acm *acm)
-{
- int i, wbn;
- struct acm_wb *wb;
-
- wbn = 0;
- i = 0;
- for (;;) {
- wb = &acm->wb[wbn];
- if (!wb->use) {
- wb->use = 1;
- return wbn;
- }
- wbn = (wbn + 1) % ACM_NW;
- if (++i >= ACM_NW)
- return -1;
- }
-}
-
-static int acm_wb_is_avail(struct acm *acm)
-{
- int i, n;
- unsigned long flags;
-
- n = ACM_NW;
- spin_lock_irqsave(&acm->write_lock, flags);
- for (i = 0; i < ACM_NW; i++)
- n -= acm->wb[i].use;
- spin_unlock_irqrestore(&acm->write_lock, flags);
- return n;
-}
-
-/*
- * Finish write. Caller must hold acm->write_lock
- */
-static void acm_write_done(struct acm *acm, struct acm_wb *wb)
-{
- wb->use = 0;
- acm->transmitting--;
- usb_autopm_put_interface_async(acm->control);
-}
-
-/*
- * Poke write.
- *
- * the caller is responsible for locking
- */
-
-static int acm_start_wb(struct acm *acm, struct acm_wb *wb)
-{
- int rc;
-
- acm->transmitting++;
-
- wb->urb->transfer_buffer = wb->buf;
- wb->urb->transfer_dma = wb->dmah;
- wb->urb->transfer_buffer_length = wb->len;
- wb->urb->dev = acm->dev;
-
- rc = usb_submit_urb(wb->urb, GFP_ATOMIC);
- if (rc < 0) {
- dev_err(&acm->data->dev,
- "%s - usb_submit_urb(write bulk) failed: %d\n",
- __func__, rc);
- acm_write_done(acm, wb);
- }
- return rc;
-}
-
-static int acm_write_start(struct acm *acm, int wbn)
-{
- unsigned long flags;
- struct acm_wb *wb = &acm->wb[wbn];
- int rc;
-
- spin_lock_irqsave(&acm->write_lock, flags);
- if (!acm->dev) {
- wb->use = 0;
- spin_unlock_irqrestore(&acm->write_lock, flags);
- return -ENODEV;
- }
-
- dev_vdbg(&acm->data->dev, "%s - susp_count %d\n", __func__,
- acm->susp_count);
- usb_autopm_get_interface_async(acm->control);
- if (acm->susp_count) {
- if (!acm->delayed_wb)
- acm->delayed_wb = wb;
- else
- usb_autopm_put_interface_async(acm->control);
- spin_unlock_irqrestore(&acm->write_lock, flags);
- return 0; /* A white lie */
- }
- usb_mark_last_busy(acm->dev);
-
- rc = acm_start_wb(acm, wb);
- spin_unlock_irqrestore(&acm->write_lock, flags);
-
- return rc;
-
-}
-/*
- * attributes exported through sysfs
- */
-static ssize_t show_caps
-(struct device *dev, struct device_attribute *attr, char *buf)
-{
- struct usb_interface *intf = to_usb_interface(dev);
- struct acm *acm = usb_get_intfdata(intf);
-
- return sprintf(buf, "%d", acm->ctrl_caps);
-}
-static DEVICE_ATTR(bmCapabilities, S_IRUGO, show_caps, NULL);
-
-static ssize_t show_country_codes
-(struct device *dev, struct device_attribute *attr, char *buf)
-{
- struct usb_interface *intf = to_usb_interface(dev);
- struct acm *acm = usb_get_intfdata(intf);
-
- memcpy(buf, acm->country_codes, acm->country_code_size);
- return acm->country_code_size;
-}
-
-static DEVICE_ATTR(wCountryCodes, S_IRUGO, show_country_codes, NULL);
-
-static ssize_t show_country_rel_date
-(struct device *dev, struct device_attribute *attr, char *buf)
-{
- struct usb_interface *intf = to_usb_interface(dev);
- struct acm *acm = usb_get_intfdata(intf);
-
- return sprintf(buf, "%d", acm->country_rel_date);
-}
-
-static DEVICE_ATTR(iCountryCodeRelDate, S_IRUGO, show_country_rel_date, NULL);
-/*
- * Interrupt handlers for various ACM device responses
- */
-
-/* control interface reports status changes with "interrupt" transfers */
-static void acm_ctrl_irq(struct urb *urb)
-{
- struct acm *acm = urb->context;
- struct usb_cdc_notification *dr = urb->transfer_buffer;
- struct tty_struct *tty;
- unsigned char *data;
- int newctrl;
- int retval;
- int status = urb->status;
-
- switch (status) {
- case 0:
- /* success */
- break;
- case -ECONNRESET:
- case -ENOENT:
- case -ESHUTDOWN:
- /* this urb is terminated, clean up */
- dev_dbg(&acm->control->dev,
- "%s - urb shutting down with status: %d\n",
- __func__, status);
- return;
- default:
- dev_dbg(&acm->control->dev,
- "%s - nonzero urb status received: %d\n",
- __func__, status);
- goto exit;
- }
-
- usb_mark_last_busy(acm->dev);
-
- data = (unsigned char *)(dr + 1);
- switch (dr->bNotificationType) {
- case USB_CDC_NOTIFY_NETWORK_CONNECTION:
- dev_dbg(&acm->control->dev, "%s - network connection: %d\n",
- __func__, dr->wValue);
- break;
-
- case USB_CDC_NOTIFY_SERIAL_STATE:
- tty = tty_port_tty_get(&acm->port);
- newctrl = get_unaligned_le16(data);
-
- if (tty) {
- if (!acm->clocal &&
- (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) {
- dev_dbg(&acm->control->dev,
- "%s - calling hangup\n", __func__);
- tty_hangup(tty);
- }
- tty_kref_put(tty);
- }
-
- acm->ctrlin = newctrl;
-
- dev_dbg(&acm->control->dev,
- "%s - input control lines: dcd%c dsr%c break%c "
- "ring%c framing%c parity%c overrun%c\n",
- __func__,
- acm->ctrlin & ACM_CTRL_DCD ? '+' : '-',
- acm->ctrlin & ACM_CTRL_DSR ? '+' : '-',
- acm->ctrlin & ACM_CTRL_BRK ? '+' : '-',
- acm->ctrlin & ACM_CTRL_RI ? '+' : '-',
- acm->ctrlin & ACM_CTRL_FRAMING ? '+' : '-',
- acm->ctrlin & ACM_CTRL_PARITY ? '+' : '-',
- acm->ctrlin & ACM_CTRL_OVERRUN ? '+' : '-');
- break;
-
- default:
- dev_dbg(&acm->control->dev,
- "%s - unknown notification %d received: index %d "
- "len %d data0 %d data1 %d\n",
- __func__,
- dr->bNotificationType, dr->wIndex,
- dr->wLength, data[0], data[1]);
- break;
- }
-exit:
- retval = usb_submit_urb(urb, GFP_ATOMIC);
- if (retval)
- dev_err(&acm->control->dev, "%s - usb_submit_urb failed: %d\n",
- __func__, retval);
-}
-
-static int acm_submit_read_urb(struct acm *acm, int index, gfp_t mem_flags)
-{
- int res;
-
- if (!test_and_clear_bit(index, &acm->read_urbs_free))
- return 0;
-
- dev_vdbg(&acm->data->dev, "%s - urb %d\n", __func__, index);
-
- res = usb_submit_urb(acm->read_urbs[index], mem_flags);
- if (res) {
- if (res != -EPERM) {
- dev_err(&acm->data->dev,
- "%s - usb_submit_urb failed: %d\n",
- __func__, res);
- }
- set_bit(index, &acm->read_urbs_free);
- return res;
- }
-
- return 0;
-}
-
-static int acm_submit_read_urbs(struct acm *acm, gfp_t mem_flags)
-{
- int res;
- int i;
-
- for (i = 0; i < acm->rx_buflimit; ++i) {
- res = acm_submit_read_urb(acm, i, mem_flags);
- if (res)
- return res;
- }
-
- return 0;
-}
-
-static void acm_process_read_urb(struct acm *acm, struct urb *urb)
-{
- struct tty_struct *tty;
-
- if (!urb->actual_length)
- return;
-
- tty = tty_port_tty_get(&acm->port);
- if (!tty)
- return;
-
- tty_insert_flip_string(tty, urb->transfer_buffer, urb->actual_length);
- tty_flip_buffer_push(tty);
-
- tty_kref_put(tty);
-}
-
-static void acm_read_bulk_callback(struct urb *urb)
-{
- struct acm_rb *rb = urb->context;
- struct acm *acm = rb->instance;
- unsigned long flags;
-
- dev_vdbg(&acm->data->dev, "%s - urb %d, len %d\n", __func__,
- rb->index, urb->actual_length);
- set_bit(rb->index, &acm->read_urbs_free);
-
- if (!acm->dev) {
- dev_dbg(&acm->data->dev, "%s - disconnected\n", __func__);
- return;
- }
- usb_mark_last_busy(acm->dev);
-
- if (urb->status) {
- dev_dbg(&acm->data->dev, "%s - non-zero urb status: %d\n",
- __func__, urb->status);
- return;
- }
- acm_process_read_urb(acm, urb);
-
- /* throttle device if requested by tty */
- spin_lock_irqsave(&acm->read_lock, flags);
- acm->throttled = acm->throttle_req;
- if (!acm->throttled && !acm->susp_count) {
- spin_unlock_irqrestore(&acm->read_lock, flags);
- acm_submit_read_urb(acm, rb->index, GFP_ATOMIC);
- } else {
- spin_unlock_irqrestore(&acm->read_lock, flags);
- }
-}
-
-/* data interface wrote those outgoing bytes */
-static void acm_write_bulk(struct urb *urb)
-{
- struct acm_wb *wb = urb->context;
- struct acm *acm = wb->instance;
- unsigned long flags;
-
- if (urb->status || (urb->actual_length != urb->transfer_buffer_length))
- dev_vdbg(&acm->data->dev, "%s - len %d/%d, status %d\n",
- __func__,
- urb->actual_length,
- urb->transfer_buffer_length,
- urb->status);
-
- spin_lock_irqsave(&acm->write_lock, flags);
- acm_write_done(acm, wb);
- spin_unlock_irqrestore(&acm->write_lock, flags);
- schedule_work(&acm->work);
-}
-
-static void acm_softint(struct work_struct *work)
-{
- struct acm *acm = container_of(work, struct acm, work);
- struct tty_struct *tty;
-
- dev_vdbg(&acm->data->dev, "%s\n", __func__);
-
- tty = tty_port_tty_get(&acm->port);
- if (!tty)
- return;
- tty_wakeup(tty);
- tty_kref_put(tty);
-}
-
-/*
- * TTY handlers
- */
-
-static int acm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
-{
- struct acm *acm;
- int retval;
-
- dev_dbg(tty->dev, "%s\n", __func__);
-
- acm = acm_get_by_index(tty->index);
- if (!acm)
- return -ENODEV;
-
- retval = tty_standard_install(driver, tty);
- if (retval)
- goto error_init_termios;
-
- tty->driver_data = acm;
-
- return 0;
-
-error_init_termios:
- tty_port_put(&acm->port);
- return retval;
-}
-
-static int acm_tty_open(struct tty_struct *tty, struct file *filp)
-{
- struct acm *acm = tty->driver_data;
-
- dev_dbg(tty->dev, "%s\n", __func__);
-
- return tty_port_open(&acm->port, tty, filp);
-}
-
-static int acm_port_activate(struct tty_port *port, struct tty_struct *tty)
-{
- struct acm *acm = container_of(port, struct acm, port);
- int retval = -ENODEV;
-
- dev_dbg(&acm->control->dev, "%s\n", __func__);
-
- mutex_lock(&acm->mutex);
- if (acm->disconnected)
- goto disconnected;
-
- retval = usb_autopm_get_interface(acm->control);
- if (retval)
- goto error_get_interface;
-
- /*
- * FIXME: Why do we need this? Allocating 64K of physically contiguous
- * memory is really nasty...
- */
- set_bit(TTY_NO_WRITE_SPLIT, &tty->flags);
- acm->control->needs_remote_wakeup = 1;
-
- acm->ctrlurb->dev = acm->dev;
- if (usb_submit_urb(acm->ctrlurb, GFP_KERNEL)) {
- dev_err(&acm->control->dev,
- "%s - usb_submit_urb(ctrl irq) failed\n", __func__);
- goto error_submit_urb;
- }
-
- acm->ctrlout = ACM_CTRL_DTR | ACM_CTRL_RTS;
- if (acm_set_control(acm, acm->ctrlout) < 0 &&
- (acm->ctrl_caps & USB_CDC_CAP_LINE))
- goto error_set_control;
-
- usb_autopm_put_interface(acm->control);
-
- /*
- * Unthrottle device in case the TTY was closed while throttled.
- */
- spin_lock_irq(&acm->read_lock);
- acm->throttled = 0;
- acm->throttle_req = 0;
- spin_unlock_irq(&acm->read_lock);
-
- if (acm_submit_read_urbs(acm, GFP_KERNEL))
- goto error_submit_read_urbs;
-
- mutex_unlock(&acm->mutex);
-
- return 0;
-
-error_submit_read_urbs:
- acm->ctrlout = 0;
- acm_set_control(acm, acm->ctrlout);
-error_set_control:
- usb_kill_urb(acm->ctrlurb);
-error_submit_urb:
- usb_autopm_put_interface(acm->control);
-error_get_interface:
-disconnected:
- mutex_unlock(&acm->mutex);
- return retval;
-}
-
-static void acm_port_destruct(struct tty_port *port)
-{
- struct acm *acm = container_of(port, struct acm, port);
-
- dev_dbg(&acm->control->dev, "%s\n", __func__);
-
- tty_unregister_device(acm_tty_driver, acm->minor);
- acm_release_minor(acm);
- usb_put_intf(acm->control);
- kfree(acm->country_codes);
- kfree(acm);
-}
-
-static void acm_port_shutdown(struct tty_port *port)
-{
- struct acm *acm = container_of(port, struct acm, port);
- int i;
-
- dev_dbg(&acm->control->dev, "%s\n", __func__);
-
- mutex_lock(&acm->mutex);
- if (!acm->disconnected) {
- usb_autopm_get_interface(acm->control);
- acm_set_control(acm, acm->ctrlout = 0);
- usb_kill_urb(acm->ctrlurb);
- for (i = 0; i < ACM_NW; i++)
- usb_kill_urb(acm->wb[i].urb);
- for (i = 0; i < acm->rx_buflimit; i++)
- usb_kill_urb(acm->read_urbs[i]);
- acm->control->needs_remote_wakeup = 0;
- usb_autopm_put_interface(acm->control);
- }
- mutex_unlock(&acm->mutex);
-}
-
-static void acm_tty_cleanup(struct tty_struct *tty)
-{
- struct acm *acm = tty->driver_data;
- dev_dbg(&acm->control->dev, "%s\n", __func__);
- tty_port_put(&acm->port);
-}
-
-static void acm_tty_hangup(struct tty_struct *tty)
-{
- struct acm *acm = tty->driver_data;
- dev_dbg(&acm->control->dev, "%s\n", __func__);
- tty_port_hangup(&acm->port);
-}
-
-static void acm_tty_close(struct tty_struct *tty, struct file *filp)
-{
- struct acm *acm = tty->driver_data;
- dev_dbg(&acm->control->dev, "%s\n", __func__);
- tty_port_close(&acm->port, tty, filp);
-}
-
-static int acm_tty_write(struct tty_struct *tty,
- const unsigned char *buf, int count)
-{
- struct acm *acm = tty->driver_data;
- int stat;
- unsigned long flags;
- int wbn;
- struct acm_wb *wb;
-
- if (!count)
- return 0;
-
- dev_vdbg(&acm->data->dev, "%s - count %d\n", __func__, count);
-
- spin_lock_irqsave(&acm->write_lock, flags);
- wbn = acm_wb_alloc(acm);
- if (wbn < 0) {
- spin_unlock_irqrestore(&acm->write_lock, flags);
- return 0;
- }
- wb = &acm->wb[wbn];
-
- count = (count > acm->writesize) ? acm->writesize : count;
- dev_vdbg(&acm->data->dev, "%s - write %d\n", __func__, count);
- memcpy(wb->buf, buf, count);
- wb->len = count;
- spin_unlock_irqrestore(&acm->write_lock, flags);
-
- stat = acm_write_start(acm, wbn);
- if (stat < 0)
- return stat;
- return count;
-}
-
-static int acm_tty_write_room(struct tty_struct *tty)
-{
- struct acm *acm = tty->driver_data;
- /*
- * Do not let the line discipline to know that we have a reserve,
- * or it might get too enthusiastic.
- */
- return acm_wb_is_avail(acm) ? acm->writesize : 0;
-}
-
-static int acm_tty_chars_in_buffer(struct tty_struct *tty)
-{
- struct acm *acm = tty->driver_data;
- /*
- * if the device was unplugged then any remaining characters fell out
- * of the connector ;)
- */
- if (acm->disconnected)
- return 0;
- /*
- * This is inaccurate (overcounts), but it works.
- */
- return (ACM_NW - acm_wb_is_avail(acm)) * acm->writesize;
-}
-
-static void acm_tty_throttle(struct tty_struct *tty)
-{
- struct acm *acm = tty->driver_data;
-
- spin_lock_irq(&acm->read_lock);
- acm->throttle_req = 1;
- spin_unlock_irq(&acm->read_lock);
-}
-
-static void acm_tty_unthrottle(struct tty_struct *tty)
-{
- struct acm *acm = tty->driver_data;
- unsigned int was_throttled;
-
- spin_lock_irq(&acm->read_lock);
- was_throttled = acm->throttled;
- acm->throttled = 0;
- acm->throttle_req = 0;
- spin_unlock_irq(&acm->read_lock);
-
- if (was_throttled)
- acm_submit_read_urbs(acm, GFP_KERNEL);
-}
-
-static int acm_tty_break_ctl(struct tty_struct *tty, int state)
-{
- struct acm *acm = tty->driver_data;
- int retval;
-
- retval = acm_send_break(acm, state ? 0xffff : 0);
- if (retval < 0)
- dev_dbg(&acm->control->dev, "%s - send break failed\n",
- __func__);
- return retval;
-}
-
-static int acm_tty_tiocmget(struct tty_struct *tty)
-{
- struct acm *acm = tty->driver_data;
-
- return (acm->ctrlout & ACM_CTRL_DTR ? TIOCM_DTR : 0) |
- (acm->ctrlout & ACM_CTRL_RTS ? TIOCM_RTS : 0) |
- (acm->ctrlin & ACM_CTRL_DSR ? TIOCM_DSR : 0) |
- (acm->ctrlin & ACM_CTRL_RI ? TIOCM_RI : 0) |
- (acm->ctrlin & ACM_CTRL_DCD ? TIOCM_CD : 0) |
- TIOCM_CTS;
-}
-
-static int acm_tty_tiocmset(struct tty_struct *tty,
- unsigned int set, unsigned int clear)
-{
- struct acm *acm = tty->driver_data;
- unsigned int newctrl;
-
- newctrl = acm->ctrlout;
- set = (set & TIOCM_DTR ? ACM_CTRL_DTR : 0) |
- (set & TIOCM_RTS ? ACM_CTRL_RTS : 0);
- clear = (clear & TIOCM_DTR ? ACM_CTRL_DTR : 0) |
- (clear & TIOCM_RTS ? ACM_CTRL_RTS : 0);
-
- newctrl = (newctrl & ~clear) | set;
-
- if (acm->ctrlout == newctrl)
- return 0;
- return acm_set_control(acm, acm->ctrlout = newctrl);
-}
-
-static int get_serial_info(struct acm *acm, struct serial_struct __user *info)
-{
- struct serial_struct tmp;
-
- if (!info)
- return -EINVAL;
-
- memset(&tmp, 0, sizeof(tmp));
- tmp.flags = ASYNC_LOW_LATENCY;
- tmp.xmit_fifo_size = acm->writesize;
- tmp.baud_base = le32_to_cpu(acm->line.dwDTERate);
-
- if (copy_to_user(info, &tmp, sizeof(tmp)))
- return -EFAULT;
- else
- return 0;
-}
-
-static int acm_tty_ioctl(struct tty_struct *tty,
- unsigned int cmd, unsigned long arg)
-{
- struct acm *acm = tty->driver_data;
- int rv = -ENOIOCTLCMD;
-
- switch (cmd) {
- case TIOCGSERIAL: /* gets serial port data */
- rv = get_serial_info(acm, (struct serial_struct __user *) arg);
- break;
- }
-
- return rv;
-}
-
-static const __u32 acm_tty_speed[] = {
- 0, 50, 75, 110, 134, 150, 200, 300, 600,
- 1200, 1800, 2400, 4800, 9600, 19200, 38400,
- 57600, 115200, 230400, 460800, 500000, 576000,
- 921600, 1000000, 1152000, 1500000, 2000000,
- 2500000, 3000000, 3500000, 4000000
-};
-
-static const __u8 acm_tty_size[] = {
- 5, 6, 7, 8
-};
-
-static void acm_tty_set_termios(struct tty_struct *tty,
- struct ktermios *termios_old)
-{
- struct acm *acm = tty->driver_data;
- struct ktermios *termios = tty->termios;
- struct usb_cdc_line_coding newline;
- int newctrl = acm->ctrlout;
-
- newline.dwDTERate = cpu_to_le32(tty_get_baud_rate(tty));
- newline.bCharFormat = termios->c_cflag & CSTOPB ? 2 : 0;
- newline.bParityType = termios->c_cflag & PARENB ?
- (termios->c_cflag & PARODD ? 1 : 2) +
- (termios->c_cflag & CMSPAR ? 2 : 0) : 0;
- newline.bDataBits = acm_tty_size[(termios->c_cflag & CSIZE) >> 4];
- /* FIXME: Needs to clear unsupported bits in the termios */
- acm->clocal = ((termios->c_cflag & CLOCAL) != 0);
-
- if (!newline.dwDTERate) {
- newline.dwDTERate = acm->line.dwDTERate;
- newctrl &= ~ACM_CTRL_DTR;
- } else
- newctrl |= ACM_CTRL_DTR;
-
- if (newctrl != acm->ctrlout)
- acm_set_control(acm, acm->ctrlout = newctrl);
-
- if (memcmp(&acm->line, &newline, sizeof newline)) {
- memcpy(&acm->line, &newline, sizeof newline);
- dev_dbg(&acm->control->dev, "%s - set line: %d %d %d %d\n",
- __func__,
- le32_to_cpu(newline.dwDTERate),
- newline.bCharFormat, newline.bParityType,
- newline.bDataBits);
- acm_set_line(acm, &acm->line);
- }
-}
-
-static const struct tty_port_operations acm_port_ops = {
- .shutdown = acm_port_shutdown,
- .activate = acm_port_activate,
- .destruct = acm_port_destruct,
-};
-
-/*
- * USB probe and disconnect routines.
- */
-
-/* Little helpers: write/read buffers free */
-static void acm_write_buffers_free(struct acm *acm)
-{
- int i;
- struct acm_wb *wb;
- struct usb_device *usb_dev = interface_to_usbdev(acm->control);
-
- for (wb = &acm->wb[0], i = 0; i < ACM_NW; i++, wb++)
- usb_free_coherent(usb_dev, acm->writesize, wb->buf, wb->dmah);
-}
-
-static void acm_read_buffers_free(struct acm *acm)
-{
- struct usb_device *usb_dev = interface_to_usbdev(acm->control);
- int i;
-
- for (i = 0; i < acm->rx_buflimit; i++)
- usb_free_coherent(usb_dev, acm->readsize,
- acm->read_buffers[i].base, acm->read_buffers[i].dma);
-}
-
-/* Little helper: write buffers allocate */
-static int acm_write_buffers_alloc(struct acm *acm)
-{
- int i;
- struct acm_wb *wb;
-
- for (wb = &acm->wb[0], i = 0; i < ACM_NW; i++, wb++) {
- wb->buf = usb_alloc_coherent(acm->dev, acm->writesize, GFP_KERNEL,
- &wb->dmah);
- if (!wb->buf) {
- while (i != 0) {
- --i;
- --wb;
- usb_free_coherent(acm->dev, acm->writesize,
- wb->buf, wb->dmah);
- }
- return -ENOMEM;
- }
- }
- return 0;
-}
-
-static int acm_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- struct usb_cdc_union_desc *union_header = NULL;
- struct usb_cdc_country_functional_desc *cfd = NULL;
- unsigned char *buffer = intf->altsetting->extra;
- int buflen = intf->altsetting->extralen;
- struct usb_interface *control_interface;
- struct usb_interface *data_interface;
- struct usb_endpoint_descriptor *epctrl = NULL;
- struct usb_endpoint_descriptor *epread = NULL;
- struct usb_endpoint_descriptor *epwrite = NULL;
- struct usb_device *usb_dev = interface_to_usbdev(intf);
- struct acm *acm;
- int minor;
- int ctrlsize, readsize;
- u8 *buf;
- u8 ac_management_function = 0;
- u8 call_management_function = 0;
- int call_interface_num = -1;
- int data_interface_num = -1;
- unsigned long quirks;
- int num_rx_buf;
- int i;
- int combined_interfaces = 0;
-
- /* normal quirks */
- quirks = (unsigned long)id->driver_info;
- num_rx_buf = (quirks == SINGLE_RX_URB) ? 1 : ACM_NR;
-
- /* handle quirks deadly to normal probing*/
- if (quirks == NO_UNION_NORMAL) {
- data_interface = usb_ifnum_to_if(usb_dev, 1);
- control_interface = usb_ifnum_to_if(usb_dev, 0);
- goto skip_normal_probe;
- }
-
- /* normal probing*/
- if (!buffer) {
- dev_err(&intf->dev, "Weird descriptor references\n");
- return -EINVAL;
- }
-
- if (!buflen) {
- if (intf->cur_altsetting->endpoint &&
- intf->cur_altsetting->endpoint->extralen &&
- intf->cur_altsetting->endpoint->extra) {
- dev_dbg(&intf->dev,
- "Seeking extra descriptors on endpoint\n");
- buflen = intf->cur_altsetting->endpoint->extralen;
- buffer = intf->cur_altsetting->endpoint->extra;
- } else {
- dev_err(&intf->dev,
- "Zero length descriptor references\n");
- return -EINVAL;
- }
- }
-
- while (buflen > 0) {
- if (buffer[1] != USB_DT_CS_INTERFACE) {
- dev_err(&intf->dev, "skipping garbage\n");
- goto next_desc;
- }
-
- switch (buffer[2]) {
- case USB_CDC_UNION_TYPE: /* we've found it */
- if (union_header) {
- dev_err(&intf->dev, "More than one "
- "union descriptor, skipping ...\n");
- goto next_desc;
- }
- union_header = (struct usb_cdc_union_desc *)buffer;
- break;
- case USB_CDC_COUNTRY_TYPE: /* export through sysfs*/
- cfd = (struct usb_cdc_country_functional_desc *)buffer;
- break;
- case USB_CDC_HEADER_TYPE: /* maybe check version */
- break; /* for now we ignore it */
- case USB_CDC_ACM_TYPE:
- ac_management_function = buffer[3];
- break;
- case USB_CDC_CALL_MANAGEMENT_TYPE:
- call_management_function = buffer[3];
- call_interface_num = buffer[4];
- if ( (quirks & NOT_A_MODEM) == 0 && (call_management_function & 3) != 3)
- dev_err(&intf->dev, "This device cannot do calls on its own. It is not a modem.\n");
- break;
- default:
- /* there are LOTS more CDC descriptors that
- * could legitimately be found here.
- */
- dev_dbg(&intf->dev, "Ignoring descriptor: "
- "type %02x, length %d\n",
- buffer[2], buffer[0]);
- break;
- }
-next_desc:
- buflen -= buffer[0];
- buffer += buffer[0];
- }
-
- if (!union_header) {
- if (call_interface_num > 0) {
- dev_dbg(&intf->dev, "No union descriptor, using call management descriptor\n");
- /* quirks for Droids MuIn LCD */
- if (quirks & NO_DATA_INTERFACE)
- data_interface = usb_ifnum_to_if(usb_dev, 0);
- else
- data_interface = usb_ifnum_to_if(usb_dev, (data_interface_num = call_interface_num));
- control_interface = intf;
- } else {
- if (intf->cur_altsetting->desc.bNumEndpoints != 3) {
- dev_dbg(&intf->dev,"No union descriptor, giving up\n");
- return -ENODEV;
- } else {
- dev_warn(&intf->dev,"No union descriptor, testing for castrated device\n");
- combined_interfaces = 1;
- control_interface = data_interface = intf;
- goto look_for_collapsed_interface;
- }
- }
- } else {
- control_interface = usb_ifnum_to_if(usb_dev, union_header->bMasterInterface0);
- data_interface = usb_ifnum_to_if(usb_dev, (data_interface_num = union_header->bSlaveInterface0));
- if (!control_interface || !data_interface) {
- dev_dbg(&intf->dev, "no interfaces\n");
- return -ENODEV;
- }
- }
-
- if (data_interface_num != call_interface_num)
- dev_dbg(&intf->dev, "Separate call control interface. That is not fully supported.\n");
-
- if (control_interface == data_interface) {
- /* some broken devices designed for windows work this way */
- dev_warn(&intf->dev,"Control and data interfaces are not separated!\n");
- combined_interfaces = 1;
- /* a popular other OS doesn't use it */
- quirks |= NO_CAP_LINE;
- if (data_interface->cur_altsetting->desc.bNumEndpoints != 3) {
- dev_err(&intf->dev, "This needs exactly 3 endpoints\n");
- return -EINVAL;
- }
-look_for_collapsed_interface:
- for (i = 0; i < 3; i++) {
- struct usb_endpoint_descriptor *ep;
- ep = &data_interface->cur_altsetting->endpoint[i].desc;
-
- if (usb_endpoint_is_int_in(ep))
- epctrl = ep;
- else if (usb_endpoint_is_bulk_out(ep))
- epwrite = ep;
- else if (usb_endpoint_is_bulk_in(ep))
- epread = ep;
- else
- return -EINVAL;
- }
- if (!epctrl || !epread || !epwrite)
- return -ENODEV;
- else
- goto made_compressed_probe;
- }
-
-skip_normal_probe:
-
- /*workaround for switched interfaces */
- if (data_interface->cur_altsetting->desc.bInterfaceClass
- != CDC_DATA_INTERFACE_TYPE) {
- if (control_interface->cur_altsetting->desc.bInterfaceClass
- == CDC_DATA_INTERFACE_TYPE) {
- struct usb_interface *t;
- dev_dbg(&intf->dev,
- "Your device has switched interfaces.\n");
- t = control_interface;
- control_interface = data_interface;
- data_interface = t;
- } else {
- return -EINVAL;
- }
- }
-
- /* Accept probe requests only for the control interface */
- if (!combined_interfaces && intf != control_interface)
- return -ENODEV;
-
- if (!combined_interfaces && usb_interface_claimed(data_interface)) {
- /* valid in this context */
- dev_dbg(&intf->dev, "The data interface isn't available\n");
- return -EBUSY;
- }
-
-
- if (data_interface->cur_altsetting->desc.bNumEndpoints < 2)
- return -EINVAL;
-
- epctrl = &control_interface->cur_altsetting->endpoint[0].desc;
- epread = &data_interface->cur_altsetting->endpoint[0].desc;
- epwrite = &data_interface->cur_altsetting->endpoint[1].desc;
-
-
- /* workaround for switched endpoints */
- if (!usb_endpoint_dir_in(epread)) {
- /* descriptors are swapped */
- struct usb_endpoint_descriptor *t;
- dev_dbg(&intf->dev,
- "The data interface has switched endpoints\n");
- t = epread;
- epread = epwrite;
- epwrite = t;
- }
-made_compressed_probe:
- dev_dbg(&intf->dev, "interfaces are valid\n");
-
- acm = kzalloc(sizeof(struct acm), GFP_KERNEL);
- if (acm == NULL) {
- dev_err(&intf->dev, "out of memory (acm kzalloc)\n");
- goto alloc_fail;
- }
-
- minor = acm_alloc_minor(acm);
- if (minor == ACM_TTY_MINORS) {
- dev_err(&intf->dev, "no more free acm devices\n");
- kfree(acm);
- return -ENODEV;
- }
-
- ctrlsize = usb_endpoint_maxp(epctrl);
- readsize = usb_endpoint_maxp(epread) *
- (quirks == SINGLE_RX_URB ? 1 : 2);
- acm->combined_interfaces = combined_interfaces;
- acm->writesize = usb_endpoint_maxp(epwrite) * 20;
- acm->control = control_interface;
- acm->data = data_interface;
- acm->minor = minor;
- acm->dev = usb_dev;
- acm->ctrl_caps = ac_management_function;
- if (quirks & NO_CAP_LINE)
- acm->ctrl_caps &= ~USB_CDC_CAP_LINE;
- acm->ctrlsize = ctrlsize;
- acm->readsize = readsize;
- acm->rx_buflimit = num_rx_buf;
- INIT_WORK(&acm->work, acm_softint);
- spin_lock_init(&acm->write_lock);
- spin_lock_init(&acm->read_lock);
- mutex_init(&acm->mutex);
- acm->rx_endpoint = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress);
- acm->is_int_ep = usb_endpoint_xfer_int(epread);
- if (acm->is_int_ep)
- acm->bInterval = epread->bInterval;
- tty_port_init(&acm->port);
- acm->port.ops = &acm_port_ops;
-
- buf = usb_alloc_coherent(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma);
- if (!buf) {
- dev_err(&intf->dev, "out of memory (ctrl buffer alloc)\n");
- goto alloc_fail2;
- }
- acm->ctrl_buffer = buf;
-
- if (acm_write_buffers_alloc(acm) < 0) {
- dev_err(&intf->dev, "out of memory (write buffer alloc)\n");
- goto alloc_fail4;
- }
-
- acm->ctrlurb = usb_alloc_urb(0, GFP_KERNEL);
- if (!acm->ctrlurb) {
- dev_err(&intf->dev, "out of memory (ctrlurb kmalloc)\n");
- goto alloc_fail5;
- }
- for (i = 0; i < num_rx_buf; i++) {
- struct acm_rb *rb = &(acm->read_buffers[i]);
- struct urb *urb;
-
- rb->base = usb_alloc_coherent(acm->dev, readsize, GFP_KERNEL,
- &rb->dma);
- if (!rb->base) {
- dev_err(&intf->dev, "out of memory "
- "(read bufs usb_alloc_coherent)\n");
- goto alloc_fail6;
- }
- rb->index = i;
- rb->instance = acm;
-
- urb = usb_alloc_urb(0, GFP_KERNEL);
- if (!urb) {
- dev_err(&intf->dev,
- "out of memory (read urbs usb_alloc_urb)\n");
- goto alloc_fail6;
- }
- urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
- urb->transfer_dma = rb->dma;
- if (acm->is_int_ep) {
- usb_fill_int_urb(urb, acm->dev,
- acm->rx_endpoint,
- rb->base,
- acm->readsize,
- acm_read_bulk_callback, rb,
- acm->bInterval);
- } else {
- usb_fill_bulk_urb(urb, acm->dev,
- acm->rx_endpoint,
- rb->base,
- acm->readsize,
- acm_read_bulk_callback, rb);
- }
-
- acm->read_urbs[i] = urb;
- __set_bit(i, &acm->read_urbs_free);
- }
- for (i = 0; i < ACM_NW; i++) {
- struct acm_wb *snd = &(acm->wb[i]);
-
- snd->urb = usb_alloc_urb(0, GFP_KERNEL);
- if (snd->urb == NULL) {
- dev_err(&intf->dev,
- "out of memory (write urbs usb_alloc_urb)\n");
- goto alloc_fail7;
- }
-
- if (usb_endpoint_xfer_int(epwrite))
- usb_fill_int_urb(snd->urb, usb_dev,
- usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
- NULL, acm->writesize, acm_write_bulk, snd, epwrite->bInterval);
- else
- usb_fill_bulk_urb(snd->urb, usb_dev,
- usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
- NULL, acm->writesize, acm_write_bulk, snd);
- snd->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
- snd->instance = acm;
- }
-
- usb_set_intfdata(intf, acm);
-
- i = device_create_file(&intf->dev, &dev_attr_bmCapabilities);
- if (i < 0)
- goto alloc_fail7;
-
- if (cfd) { /* export the country data */
- acm->country_codes = kmalloc(cfd->bLength - 4, GFP_KERNEL);
- if (!acm->country_codes)
- goto skip_countries;
- acm->country_code_size = cfd->bLength - 4;
- memcpy(acm->country_codes, (u8 *)&cfd->wCountyCode0,
- cfd->bLength - 4);
- acm->country_rel_date = cfd->iCountryCodeRelDate;
-
- i = device_create_file(&intf->dev, &dev_attr_wCountryCodes);
- if (i < 0) {
- kfree(acm->country_codes);
- acm->country_codes = NULL;
- acm->country_code_size = 0;
- goto skip_countries;
- }
-
- i = device_create_file(&intf->dev,
- &dev_attr_iCountryCodeRelDate);
- if (i < 0) {
- device_remove_file(&intf->dev, &dev_attr_wCountryCodes);
- kfree(acm->country_codes);
- acm->country_codes = NULL;
- acm->country_code_size = 0;
- goto skip_countries;
- }
- }
-
-skip_countries:
- usb_fill_int_urb(acm->ctrlurb, usb_dev,
- usb_rcvintpipe(usb_dev, epctrl->bEndpointAddress),
- acm->ctrl_buffer, ctrlsize, acm_ctrl_irq, acm,
- /* works around buggy devices */
- epctrl->bInterval ? epctrl->bInterval : 0xff);
- acm->ctrlurb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
- acm->ctrlurb->transfer_dma = acm->ctrl_dma;
-
- dev_info(&intf->dev, "ttyACM%d: USB ACM device\n", minor);
-
- acm_set_control(acm, acm->ctrlout);
-
- acm->line.dwDTERate = cpu_to_le32(9600);
- acm->line.bDataBits = 8;
- acm_set_line(acm, &acm->line);
-
- usb_driver_claim_interface(&acm_driver, data_interface, acm);
- usb_set_intfdata(data_interface, acm);
-
- usb_get_intf(control_interface);
- tty_register_device(acm_tty_driver, minor, &control_interface->dev);
-
- return 0;
-alloc_fail7:
- for (i = 0; i < ACM_NW; i++)
- usb_free_urb(acm->wb[i].urb);
-alloc_fail6:
- for (i = 0; i < num_rx_buf; i++)
- usb_free_urb(acm->read_urbs[i]);
- acm_read_buffers_free(acm);
- usb_free_urb(acm->ctrlurb);
-alloc_fail5:
- acm_write_buffers_free(acm);
-alloc_fail4:
- usb_free_coherent(usb_dev, ctrlsize, acm->ctrl_buffer, acm->ctrl_dma);
-alloc_fail2:
- acm_release_minor(acm);
- kfree(acm);
-alloc_fail:
- return -ENOMEM;
-}
-
-static void stop_data_traffic(struct acm *acm)
-{
- int i;
-
- dev_dbg(&acm->control->dev, "%s\n", __func__);
-
- usb_kill_urb(acm->ctrlurb);
- for (i = 0; i < ACM_NW; i++)
- usb_kill_urb(acm->wb[i].urb);
- for (i = 0; i < acm->rx_buflimit; i++)
- usb_kill_urb(acm->read_urbs[i]);
-
- cancel_work_sync(&acm->work);
-}
-
-static void acm_disconnect(struct usb_interface *intf)
-{
- struct acm *acm = usb_get_intfdata(intf);
- struct usb_device *usb_dev = interface_to_usbdev(intf);
- struct tty_struct *tty;
- int i;
-
- dev_dbg(&intf->dev, "%s\n", __func__);
-
- /* sibling interface is already cleaning up */
- if (!acm)
- return;
-
- mutex_lock(&acm->mutex);
- acm->disconnected = true;
- if (acm->country_codes) {
- device_remove_file(&acm->control->dev,
- &dev_attr_wCountryCodes);
- device_remove_file(&acm->control->dev,
- &dev_attr_iCountryCodeRelDate);
- }
- device_remove_file(&acm->control->dev, &dev_attr_bmCapabilities);
- usb_set_intfdata(acm->control, NULL);
- usb_set_intfdata(acm->data, NULL);
- mutex_unlock(&acm->mutex);
-
- tty = tty_port_tty_get(&acm->port);
- if (tty) {
- tty_vhangup(tty);
- tty_kref_put(tty);
- }
-
- stop_data_traffic(acm);
-
- usb_free_urb(acm->ctrlurb);
- for (i = 0; i < ACM_NW; i++)
- usb_free_urb(acm->wb[i].urb);
- for (i = 0; i < acm->rx_buflimit; i++)
- usb_free_urb(acm->read_urbs[i]);
- acm_write_buffers_free(acm);
- usb_free_coherent(usb_dev, acm->ctrlsize, acm->ctrl_buffer, acm->ctrl_dma);
- acm_read_buffers_free(acm);
-
- if (!acm->combined_interfaces)
- usb_driver_release_interface(&acm_driver, intf == acm->control ?
- acm->data : acm->control);
-
- tty_port_put(&acm->port);
-}
-
-#ifdef CONFIG_PM
-static int acm_suspend(struct usb_interface *intf, pm_message_t message)
-{
- struct acm *acm = usb_get_intfdata(intf);
- int cnt;
-
- if (PMSG_IS_AUTO(message)) {
- int b;
-
- spin_lock_irq(&acm->write_lock);
- b = acm->transmitting;
- spin_unlock_irq(&acm->write_lock);
- if (b)
- return -EBUSY;
- }
-
- spin_lock_irq(&acm->read_lock);
- spin_lock(&acm->write_lock);
- cnt = acm->susp_count++;
- spin_unlock(&acm->write_lock);
- spin_unlock_irq(&acm->read_lock);
-
- if (cnt)
- return 0;
-
- if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags))
- stop_data_traffic(acm);
-
- return 0;
-}
-
-static int acm_resume(struct usb_interface *intf)
-{
- struct acm *acm = usb_get_intfdata(intf);
- struct acm_wb *wb;
- int rv = 0;
- int cnt;
-
- spin_lock_irq(&acm->read_lock);
- acm->susp_count -= 1;
- cnt = acm->susp_count;
- spin_unlock_irq(&acm->read_lock);
-
- if (cnt)
- return 0;
-
- if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags)) {
- rv = usb_submit_urb(acm->ctrlurb, GFP_NOIO);
-
- spin_lock_irq(&acm->write_lock);
- if (acm->delayed_wb) {
- wb = acm->delayed_wb;
- acm->delayed_wb = NULL;
- spin_unlock_irq(&acm->write_lock);
- acm_start_wb(acm, wb);
- } else {
- spin_unlock_irq(&acm->write_lock);
- }
-
- /*
- * delayed error checking because we must
- * do the write path at all cost
- */
- if (rv < 0)
- goto err_out;
-
- rv = acm_submit_read_urbs(acm, GFP_NOIO);
- }
-
-err_out:
- return rv;
-}
-
-static int acm_reset_resume(struct usb_interface *intf)
-{
- struct acm *acm = usb_get_intfdata(intf);
- struct tty_struct *tty;
-
- if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags)) {
- tty = tty_port_tty_get(&acm->port);
- if (tty) {
- tty_hangup(tty);
- tty_kref_put(tty);
- }
- }
-
- return acm_resume(intf);
-}
-
-#endif /* CONFIG_PM */
-
-#define NOKIA_PCSUITE_ACM_INFO(x) \
- USB_DEVICE_AND_INTERFACE_INFO(0x0421, x, \
- USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, \
- USB_CDC_ACM_PROTO_VENDOR)
-
-#define SAMSUNG_PCSUITE_ACM_INFO(x) \
- USB_DEVICE_AND_INTERFACE_INFO(0x04e7, x, \
- USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, \
- USB_CDC_ACM_PROTO_VENDOR)
-
-/*
- * USB driver structure.
- */
-
-static const struct usb_device_id acm_ids[] = {
- /* quirky and broken devices */
- { USB_DEVICE(0x0870, 0x0001), /* Metricom GS Modem */
- .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
- },
- { USB_DEVICE(0x0e8d, 0x0003), /* FIREFLY, MediaTek Inc; andrey.arapov@gmail.com */
- .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
- },
- { USB_DEVICE(0x0e8d, 0x3329), /* MediaTek Inc GPS */
- .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
- },
- { USB_DEVICE(0x0482, 0x0203), /* KYOCERA AH-K3001V */
- .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
- },
- { USB_DEVICE(0x079b, 0x000f), /* BT On-Air USB MODEM */
- .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
- },
- { USB_DEVICE(0x0ace, 0x1602), /* ZyDAS 56K USB MODEM */
- .driver_info = SINGLE_RX_URB,
- },
- { USB_DEVICE(0x0ace, 0x1608), /* ZyDAS 56K USB MODEM */
- .driver_info = SINGLE_RX_URB, /* firmware bug */
- },
- { USB_DEVICE(0x0ace, 0x1611), /* ZyDAS 56K USB MODEM - new version */
- .driver_info = SINGLE_RX_URB, /* firmware bug */
- },
- { USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */
- .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
- },
- { USB_DEVICE(0x0803, 0x3095), /* Zoom Telephonics Model 3095F USB MODEM */
- .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
- },
- { USB_DEVICE(0x0572, 0x1321), /* Conexant USB MODEM CX93010 */
- .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
- },
- { USB_DEVICE(0x0572, 0x1324), /* Conexant USB MODEM RD02-D400 */
- .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
- },
- { USB_DEVICE(0x0572, 0x1328), /* Shiro / Aztech USB MODEM UM-3100 */
- .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
- },
- { USB_DEVICE(0x22b8, 0x6425), /* Motorola MOTOMAGX phones */
- },
- /* Motorola H24 HSPA module: */
- { USB_DEVICE(0x22b8, 0x2d91) }, /* modem */
- { USB_DEVICE(0x22b8, 0x2d92) }, /* modem + diagnostics */
- { USB_DEVICE(0x22b8, 0x2d93) }, /* modem + AT port */
- { USB_DEVICE(0x22b8, 0x2d95) }, /* modem + AT port + diagnostics */
- { USB_DEVICE(0x22b8, 0x2d96) }, /* modem + NMEA */
- { USB_DEVICE(0x22b8, 0x2d97) }, /* modem + diagnostics + NMEA */
- { USB_DEVICE(0x22b8, 0x2d99) }, /* modem + AT port + NMEA */
- { USB_DEVICE(0x22b8, 0x2d9a) }, /* modem + AT port + diagnostics + NMEA */
-
- { USB_DEVICE(0x0572, 0x1329), /* Hummingbird huc56s (Conexant) */
- .driver_info = NO_UNION_NORMAL, /* union descriptor misplaced on
- data interface instead of
- communications interface.
- Maybe we should define a new
- quirk for this. */
- },
- { USB_DEVICE(0x1bbb, 0x0003), /* Alcatel OT-I650 */
- .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
- },
- { USB_DEVICE(0x1576, 0x03b1), /* Maretron USB100 */
- .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
- },
-
- /* Nokia S60 phones expose two ACM channels. The first is
- * a modem and is picked up by the standard AT-command
- * information below. The second is 'vendor-specific' but
- * is treated as a serial device at the S60 end, so we want
- * to expose it on Linux too. */
- { NOKIA_PCSUITE_ACM_INFO(0x042D), }, /* Nokia 3250 */
- { NOKIA_PCSUITE_ACM_INFO(0x04D8), }, /* Nokia 5500 Sport */
- { NOKIA_PCSUITE_ACM_INFO(0x04C9), }, /* Nokia E50 */
- { NOKIA_PCSUITE_ACM_INFO(0x0419), }, /* Nokia E60 */
- { NOKIA_PCSUITE_ACM_INFO(0x044D), }, /* Nokia E61 */
- { NOKIA_PCSUITE_ACM_INFO(0x0001), }, /* Nokia E61i */
- { NOKIA_PCSUITE_ACM_INFO(0x0475), }, /* Nokia E62 */
- { NOKIA_PCSUITE_ACM_INFO(0x0508), }, /* Nokia E65 */
- { NOKIA_PCSUITE_ACM_INFO(0x0418), }, /* Nokia E70 */
- { NOKIA_PCSUITE_ACM_INFO(0x0425), }, /* Nokia N71 */
- { NOKIA_PCSUITE_ACM_INFO(0x0486), }, /* Nokia N73 */
- { NOKIA_PCSUITE_ACM_INFO(0x04DF), }, /* Nokia N75 */
- { NOKIA_PCSUITE_ACM_INFO(0x000e), }, /* Nokia N77 */
- { NOKIA_PCSUITE_ACM_INFO(0x0445), }, /* Nokia N80 */
- { NOKIA_PCSUITE_ACM_INFO(0x042F), }, /* Nokia N91 & N91 8GB */
- { NOKIA_PCSUITE_ACM_INFO(0x048E), }, /* Nokia N92 */
- { NOKIA_PCSUITE_ACM_INFO(0x0420), }, /* Nokia N93 */
- { NOKIA_PCSUITE_ACM_INFO(0x04E6), }, /* Nokia N93i */
- { NOKIA_PCSUITE_ACM_INFO(0x04B2), }, /* Nokia 5700 XpressMusic */
- { NOKIA_PCSUITE_ACM_INFO(0x0134), }, /* Nokia 6110 Navigator (China) */
- { NOKIA_PCSUITE_ACM_INFO(0x046E), }, /* Nokia 6110 Navigator */
- { NOKIA_PCSUITE_ACM_INFO(0x002f), }, /* Nokia 6120 classic & */
- { NOKIA_PCSUITE_ACM_INFO(0x0088), }, /* Nokia 6121 classic */
- { NOKIA_PCSUITE_ACM_INFO(0x00fc), }, /* Nokia 6124 classic */
- { NOKIA_PCSUITE_ACM_INFO(0x0042), }, /* Nokia E51 */
- { NOKIA_PCSUITE_ACM_INFO(0x00b0), }, /* Nokia E66 */
- { NOKIA_PCSUITE_ACM_INFO(0x00ab), }, /* Nokia E71 */
- { NOKIA_PCSUITE_ACM_INFO(0x0481), }, /* Nokia N76 */
- { NOKIA_PCSUITE_ACM_INFO(0x0007), }, /* Nokia N81 & N81 8GB */
- { NOKIA_PCSUITE_ACM_INFO(0x0071), }, /* Nokia N82 */
- { NOKIA_PCSUITE_ACM_INFO(0x04F0), }, /* Nokia N95 & N95-3 NAM */
- { NOKIA_PCSUITE_ACM_INFO(0x0070), }, /* Nokia N95 8GB */
- { NOKIA_PCSUITE_ACM_INFO(0x00e9), }, /* Nokia 5320 XpressMusic */
- { NOKIA_PCSUITE_ACM_INFO(0x0099), }, /* Nokia 6210 Navigator, RM-367 */
- { NOKIA_PCSUITE_ACM_INFO(0x0128), }, /* Nokia 6210 Navigator, RM-419 */
- { NOKIA_PCSUITE_ACM_INFO(0x008f), }, /* Nokia 6220 Classic */
- { NOKIA_PCSUITE_ACM_INFO(0x00a0), }, /* Nokia 6650 */
- { NOKIA_PCSUITE_ACM_INFO(0x007b), }, /* Nokia N78 */
- { NOKIA_PCSUITE_ACM_INFO(0x0094), }, /* Nokia N85 */
- { NOKIA_PCSUITE_ACM_INFO(0x003a), }, /* Nokia N96 & N96-3 */
- { NOKIA_PCSUITE_ACM_INFO(0x00e9), }, /* Nokia 5320 XpressMusic */
- { NOKIA_PCSUITE_ACM_INFO(0x0108), }, /* Nokia 5320 XpressMusic 2G */
- { NOKIA_PCSUITE_ACM_INFO(0x01f5), }, /* Nokia N97, RM-505 */
- { NOKIA_PCSUITE_ACM_INFO(0x02e3), }, /* Nokia 5230, RM-588 */
- { NOKIA_PCSUITE_ACM_INFO(0x0178), }, /* Nokia E63 */
- { NOKIA_PCSUITE_ACM_INFO(0x010e), }, /* Nokia E75 */
- { NOKIA_PCSUITE_ACM_INFO(0x02d9), }, /* Nokia 6760 Slide */
- { NOKIA_PCSUITE_ACM_INFO(0x01d0), }, /* Nokia E52 */
- { NOKIA_PCSUITE_ACM_INFO(0x0223), }, /* Nokia E72 */
- { NOKIA_PCSUITE_ACM_INFO(0x0275), }, /* Nokia X6 */
- { NOKIA_PCSUITE_ACM_INFO(0x026c), }, /* Nokia N97 Mini */
- { NOKIA_PCSUITE_ACM_INFO(0x0154), }, /* Nokia 5800 XpressMusic */
- { NOKIA_PCSUITE_ACM_INFO(0x04ce), }, /* Nokia E90 */
- { NOKIA_PCSUITE_ACM_INFO(0x01d4), }, /* Nokia E55 */
- { NOKIA_PCSUITE_ACM_INFO(0x0302), }, /* Nokia N8 */
- { NOKIA_PCSUITE_ACM_INFO(0x0335), }, /* Nokia E7 */
- { NOKIA_PCSUITE_ACM_INFO(0x03cd), }, /* Nokia C7 */
- { SAMSUNG_PCSUITE_ACM_INFO(0x6651), }, /* Samsung GTi8510 (INNOV8) */
-
- /* Support for Owen devices */
- { USB_DEVICE(0x03eb, 0x0030), }, /* Owen SI30 */
-
- /* NOTE: non-Nokia COMM/ACM/0xff is likely MSFT RNDIS... NOT a modem! */
-
- /* Support Lego NXT using pbLua firmware */
- { USB_DEVICE(0x0694, 0xff00),
- .driver_info = NOT_A_MODEM,
- },
-
- /* Support for Droids MuIn LCD */
- { USB_DEVICE(0x04d8, 0x000b),
- .driver_info = NO_DATA_INTERFACE,
- },
-
- /* control interfaces without any protocol set */
- { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
- USB_CDC_PROTO_NONE) },
-
- /* control interfaces with various AT-command sets */
- { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
- USB_CDC_ACM_PROTO_AT_V25TER) },
- { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
- USB_CDC_ACM_PROTO_AT_PCCA101) },
- { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
- USB_CDC_ACM_PROTO_AT_PCCA101_WAKE) },
- { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
- USB_CDC_ACM_PROTO_AT_GSM) },
- { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
- USB_CDC_ACM_PROTO_AT_3G) },
- { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
- USB_CDC_ACM_PROTO_AT_CDMA) },
-
- { }
-};
-
-MODULE_DEVICE_TABLE(usb, acm_ids);
-
-static struct usb_driver acm_driver = {
- .name = "cdc_acm",
- .probe = acm_probe,
- .disconnect = acm_disconnect,
-#ifdef CONFIG_PM
- .suspend = acm_suspend,
- .resume = acm_resume,
- .reset_resume = acm_reset_resume,
-#endif
- .id_table = acm_ids,
-#ifdef CONFIG_PM
- .supports_autosuspend = 1,
-#endif
-};
-
-/*
- * TTY driver structures.
- */
-
-static const struct tty_operations acm_ops = {
- .install = acm_tty_install,
- .open = acm_tty_open,
- .close = acm_tty_close,
- .cleanup = acm_tty_cleanup,
- .hangup = acm_tty_hangup,
- .write = acm_tty_write,
- .write_room = acm_tty_write_room,
- .ioctl = acm_tty_ioctl,
- .throttle = acm_tty_throttle,
- .unthrottle = acm_tty_unthrottle,
- .chars_in_buffer = acm_tty_chars_in_buffer,
- .break_ctl = acm_tty_break_ctl,
- .set_termios = acm_tty_set_termios,
- .tiocmget = acm_tty_tiocmget,
- .tiocmset = acm_tty_tiocmset,
-};
-
-/*
- * Init / exit.
- */
-
-static int __init acm_init(void)
-{
- int retval;
- acm_tty_driver = alloc_tty_driver(ACM_TTY_MINORS);
- if (!acm_tty_driver)
- return -ENOMEM;
- acm_tty_driver->driver_name = "acm",
- acm_tty_driver->name = "ttyACM",
- acm_tty_driver->major = ACM_TTY_MAJOR,
- acm_tty_driver->minor_start = 0,
- acm_tty_driver->type = TTY_DRIVER_TYPE_SERIAL,
- acm_tty_driver->subtype = SERIAL_TYPE_NORMAL,
- acm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
- acm_tty_driver->init_termios = tty_std_termios;
- acm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD |
- HUPCL | CLOCAL;
- tty_set_operations(acm_tty_driver, &acm_ops);
-
- retval = tty_register_driver(acm_tty_driver);
- if (retval) {
- put_tty_driver(acm_tty_driver);
- return retval;
- }
-
- retval = usb_register(&acm_driver);
- if (retval) {
- tty_unregister_driver(acm_tty_driver);
- put_tty_driver(acm_tty_driver);
- return retval;
- }
-
- printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n");
-
- return 0;
-}
-
-static void __exit acm_exit(void)
-{
- usb_deregister(&acm_driver);
- tty_unregister_driver(acm_tty_driver);
- put_tty_driver(acm_tty_driver);
-}
-
-module_init(acm_init);
-module_exit(acm_exit);
-
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-MODULE_ALIAS_CHARDEV_MAJOR(ACM_TTY_MAJOR);
diff --git a/ANDROID_3.4.5/drivers/usb/class/cdc-acm.h b/ANDROID_3.4.5/drivers/usb/class/cdc-acm.h
deleted file mode 100644
index 35ef887b..00000000
--- a/ANDROID_3.4.5/drivers/usb/class/cdc-acm.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- *
- * Includes for cdc-acm.c
- *
- * Mainly take from usbnet's cdc-ether part
- *
- */
-
-/*
- * CMSPAR, some architectures can't have space and mark parity.
- */
-
-#ifndef CMSPAR
-#define CMSPAR 0
-#endif
-
-/*
- * Major and minor numbers.
- */
-
-#define ACM_TTY_MAJOR 166
-#define ACM_TTY_MINORS 32
-
-/*
- * Requests.
- */
-
-#define USB_RT_ACM (USB_TYPE_CLASS | USB_RECIP_INTERFACE)
-
-/*
- * Output control lines.
- */
-
-#define ACM_CTRL_DTR 0x01
-#define ACM_CTRL_RTS 0x02
-
-/*
- * Input control lines and line errors.
- */
-
-#define ACM_CTRL_DCD 0x01
-#define ACM_CTRL_DSR 0x02
-#define ACM_CTRL_BRK 0x04
-#define ACM_CTRL_RI 0x08
-
-#define ACM_CTRL_FRAMING 0x10
-#define ACM_CTRL_PARITY 0x20
-#define ACM_CTRL_OVERRUN 0x40
-
-/*
- * Internal driver structures.
- */
-
-/*
- * The only reason to have several buffers is to accommodate assumptions
- * in line disciplines. They ask for empty space amount, receive our URB size,
- * and proceed to issue several 1-character writes, assuming they will fit.
- * The very first write takes a complete URB. Fortunately, this only happens
- * when processing onlcr, so we only need 2 buffers. These values must be
- * powers of 2.
- */
-#define ACM_NW 16
-#define ACM_NR 16
-
-struct acm_wb {
- unsigned char *buf;
- dma_addr_t dmah;
- int len;
- int use;
- struct urb *urb;
- struct acm *instance;
-};
-
-struct acm_rb {
- int size;
- unsigned char *base;
- dma_addr_t dma;
- int index;
- struct acm *instance;
-};
-
-struct acm {
- struct usb_device *dev; /* the corresponding usb device */
- struct usb_interface *control; /* control interface */
- struct usb_interface *data; /* data interface */
- struct tty_port port; /* our tty port data */
- struct urb *ctrlurb; /* urbs */
- u8 *ctrl_buffer; /* buffers of urbs */
- dma_addr_t ctrl_dma; /* dma handles of buffers */
- u8 *country_codes; /* country codes from device */
- unsigned int country_code_size; /* size of this buffer */
- unsigned int country_rel_date; /* release date of version */
- struct acm_wb wb[ACM_NW];
- unsigned long read_urbs_free;
- struct urb *read_urbs[ACM_NR];
- struct acm_rb read_buffers[ACM_NR];
- int rx_buflimit;
- int rx_endpoint;
- spinlock_t read_lock;
- int write_used; /* number of non-empty write buffers */
- int transmitting;
- spinlock_t write_lock;
- struct mutex mutex;
- bool disconnected;
- struct usb_cdc_line_coding line; /* bits, stop, parity */
- struct work_struct work; /* work queue entry for line discipline waking up */
- unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */
- unsigned int ctrlout; /* output control lines (DTR, RTS) */
- unsigned int writesize; /* max packet size for the output bulk endpoint */
- unsigned int readsize,ctrlsize; /* buffer sizes for freeing */
- unsigned int minor; /* acm minor number */
- unsigned char clocal; /* termios CLOCAL */
- unsigned int ctrl_caps; /* control capabilities from the class specific header */
- unsigned int susp_count; /* number of suspended interfaces */
- unsigned int combined_interfaces:1; /* control and data collapsed */
- unsigned int is_int_ep:1; /* interrupt endpoints contrary to spec used */
- unsigned int throttled:1; /* actually throttled */
- unsigned int throttle_req:1; /* throttle requested */
- u8 bInterval;
- struct acm_wb *delayed_wb; /* write queued for a device about to be woken */
-};
-
-#define CDC_DATA_INTERFACE_TYPE 0x0a
-
-/* constants describing various quirks and errors */
-#define NO_UNION_NORMAL 1
-#define SINGLE_RX_URB 2
-#define NO_CAP_LINE 4
-#define NOT_A_MODEM 8
-#define NO_DATA_INTERFACE 16
diff --git a/ANDROID_3.4.5/drivers/usb/class/cdc-wdm.c b/ANDROID_3.4.5/drivers/usb/class/cdc-wdm.c
deleted file mode 100644
index 01d247e8..00000000
--- a/ANDROID_3.4.5/drivers/usb/class/cdc-wdm.c
+++ /dev/null
@@ -1,1048 +0,0 @@
-/*
- * cdc-wdm.c
- *
- * This driver supports USB CDC WCM Device Management.
- *
- * Copyright (c) 2007-2009 Oliver Neukum
- *
- * Some code taken from cdc-acm.c
- *
- * Released under the GPLv2.
- *
- * Many thanks to Carl Nordbeck
- */
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-/*
- * Version Information
- */
-#define DRIVER_VERSION "v0.03"
-#define DRIVER_AUTHOR "Oliver Neukum"
-#define DRIVER_DESC "USB Abstract Control Model driver for USB WCM Device Management"
-
-#define HUAWEI_VENDOR_ID 0x12D1
-
-static const struct usb_device_id wdm_ids[] = {
- {
- .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS |
- USB_DEVICE_ID_MATCH_INT_SUBCLASS,
- .bInterfaceClass = USB_CLASS_COMM,
- .bInterfaceSubClass = USB_CDC_SUBCLASS_DMM
- },
- {
- /*
- * Huawei E392, E398 and possibly other Qualcomm based modems
- * embed the Qualcomm QMI protocol inside CDC on CDC ECM like
- * control interfaces. Userspace access to this is required
- * to configure the accompanying data interface
- */
- .match_flags = USB_DEVICE_ID_MATCH_VENDOR |
- USB_DEVICE_ID_MATCH_INT_INFO,
- .idVendor = HUAWEI_VENDOR_ID,
- .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
- .bInterfaceSubClass = 1,
- .bInterfaceProtocol = 9, /* NOTE: CDC ECM control interface! */
- },
- {
- /* Vodafone/Huawei K5005 (12d1:14c8) and similar modems */
- .match_flags = USB_DEVICE_ID_MATCH_VENDOR |
- USB_DEVICE_ID_MATCH_INT_INFO,
- .idVendor = HUAWEI_VENDOR_ID,
- .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
- .bInterfaceSubClass = 1,
- .bInterfaceProtocol = 57, /* NOTE: CDC ECM control interface! */
- },
- { }
-};
-
-MODULE_DEVICE_TABLE (usb, wdm_ids);
-
-#define WDM_MINOR_BASE 176
-
-
-#define WDM_IN_USE 1
-#define WDM_DISCONNECTING 2
-#define WDM_RESULT 3
-#define WDM_READ 4
-#define WDM_INT_STALL 5
-#define WDM_POLL_RUNNING 6
-#define WDM_RESPONDING 7
-#define WDM_SUSPENDING 8
-#define WDM_RESETTING 9
-
-#define WDM_MAX 16
-
-/* CDC-WMC r1.1 requires wMaxCommand to be "at least 256 decimal (0x100)" */
-#define WDM_DEFAULT_BUFSIZE 256
-
-static DEFINE_MUTEX(wdm_mutex);
-static DEFINE_SPINLOCK(wdm_device_list_lock);
-static LIST_HEAD(wdm_device_list);
-
-/* --- method tables --- */
-
-struct wdm_device {
- u8 *inbuf; /* buffer for response */
- u8 *outbuf; /* buffer for command */
- u8 *sbuf; /* buffer for status */
- u8 *ubuf; /* buffer for copy to user space */
-
- struct urb *command;
- struct urb *response;
- struct urb *validity;
- struct usb_interface *intf;
- struct usb_ctrlrequest *orq;
- struct usb_ctrlrequest *irq;
- spinlock_t iuspin;
-
- unsigned long flags;
- u16 bufsize;
- u16 wMaxCommand;
- u16 wMaxPacketSize;
- __le16 inum;
- int reslength;
- int length;
- int read;
- int count;
- dma_addr_t shandle;
- dma_addr_t ihandle;
- struct mutex wlock;
- struct mutex rlock;
- wait_queue_head_t wait;
- struct work_struct rxwork;
- int werr;
- int rerr;
-
- struct list_head device_list;
- int (*manage_power)(struct usb_interface *, int);
-};
-
-static struct usb_driver wdm_driver;
-
-/* return intfdata if we own the interface, else look up intf in the list */
-static struct wdm_device *wdm_find_device(struct usb_interface *intf)
-{
- struct wdm_device *desc = NULL;
-
- spin_lock(&wdm_device_list_lock);
- list_for_each_entry(desc, &wdm_device_list, device_list)
- if (desc->intf == intf)
- break;
- spin_unlock(&wdm_device_list_lock);
-
- return desc;
-}
-
-static struct wdm_device *wdm_find_device_by_minor(int minor)
-{
- struct wdm_device *desc = NULL;
-
- spin_lock(&wdm_device_list_lock);
- list_for_each_entry(desc, &wdm_device_list, device_list)
- if (desc->intf->minor == minor)
- break;
- spin_unlock(&wdm_device_list_lock);
-
- return desc;
-}
-
-/* --- callbacks --- */
-static void wdm_out_callback(struct urb *urb)
-{
- struct wdm_device *desc;
- desc = urb->context;
- spin_lock(&desc->iuspin);
- desc->werr = urb->status;
- spin_unlock(&desc->iuspin);
- kfree(desc->outbuf);
- desc->outbuf = NULL;
- clear_bit(WDM_IN_USE, &desc->flags);
- wake_up(&desc->wait);
-}
-
-static void wdm_in_callback(struct urb *urb)
-{
- struct wdm_device *desc = urb->context;
- int status = urb->status;
-
- spin_lock(&desc->iuspin);
- clear_bit(WDM_RESPONDING, &desc->flags);
-
- if (status) {
- switch (status) {
- case -ENOENT:
- dev_dbg(&desc->intf->dev,
- "nonzero urb status received: -ENOENT");
- goto skip_error;
- case -ECONNRESET:
- dev_dbg(&desc->intf->dev,
- "nonzero urb status received: -ECONNRESET");
- goto skip_error;
- case -ESHUTDOWN:
- dev_dbg(&desc->intf->dev,
- "nonzero urb status received: -ESHUTDOWN");
- goto skip_error;
- case -EPIPE:
- dev_err(&desc->intf->dev,
- "nonzero urb status received: -EPIPE\n");
- break;
- default:
- dev_err(&desc->intf->dev,
- "Unexpected error %d\n", status);
- break;
- }
- }
-
- desc->rerr = status;
- desc->reslength = urb->actual_length;
- memmove(desc->ubuf + desc->length, desc->inbuf, desc->reslength);
- desc->length += desc->reslength;
-skip_error:
- wake_up(&desc->wait);
-
- set_bit(WDM_READ, &desc->flags);
- spin_unlock(&desc->iuspin);
-}
-
-static void wdm_int_callback(struct urb *urb)
-{
- int rv = 0;
- int status = urb->status;
- struct wdm_device *desc;
- struct usb_cdc_notification *dr;
-
- desc = urb->context;
- dr = (struct usb_cdc_notification *)desc->sbuf;
-
- if (status) {
- switch (status) {
- case -ESHUTDOWN:
- case -ENOENT:
- case -ECONNRESET:
- return; /* unplug */
- case -EPIPE:
- set_bit(WDM_INT_STALL, &desc->flags);
- dev_err(&desc->intf->dev, "Stall on int endpoint\n");
- goto sw; /* halt is cleared in work */
- default:
- dev_err(&desc->intf->dev,
- "nonzero urb status received: %d\n", status);
- break;
- }
- }
-
- if (urb->actual_length < sizeof(struct usb_cdc_notification)) {
- dev_err(&desc->intf->dev, "wdm_int_callback - %d bytes\n",
- urb->actual_length);
- goto exit;
- }
-
- switch (dr->bNotificationType) {
- case USB_CDC_NOTIFY_RESPONSE_AVAILABLE:
- dev_dbg(&desc->intf->dev,
- "NOTIFY_RESPONSE_AVAILABLE received: index %d len %d",
- dr->wIndex, dr->wLength);
- break;
-
- case USB_CDC_NOTIFY_NETWORK_CONNECTION:
-
- dev_dbg(&desc->intf->dev,
- "NOTIFY_NETWORK_CONNECTION %s network",
- dr->wValue ? "connected to" : "disconnected from");
- goto exit;
- default:
- clear_bit(WDM_POLL_RUNNING, &desc->flags);
- dev_err(&desc->intf->dev,
- "unknown notification %d received: index %d len %d\n",
- dr->bNotificationType, dr->wIndex, dr->wLength);
- goto exit;
- }
-
- spin_lock(&desc->iuspin);
- clear_bit(WDM_READ, &desc->flags);
- set_bit(WDM_RESPONDING, &desc->flags);
- if (!test_bit(WDM_DISCONNECTING, &desc->flags)
- && !test_bit(WDM_SUSPENDING, &desc->flags)) {
- rv = usb_submit_urb(desc->response, GFP_ATOMIC);
- dev_dbg(&desc->intf->dev, "%s: usb_submit_urb %d",
- __func__, rv);
- }
- spin_unlock(&desc->iuspin);
- if (rv < 0) {
- clear_bit(WDM_RESPONDING, &desc->flags);
- if (rv == -EPERM)
- return;
- if (rv == -ENOMEM) {
-sw:
- rv = schedule_work(&desc->rxwork);
- if (rv)
- dev_err(&desc->intf->dev,
- "Cannot schedule work\n");
- }
- }
-exit:
- rv = usb_submit_urb(urb, GFP_ATOMIC);
- if (rv)
- dev_err(&desc->intf->dev,
- "%s - usb_submit_urb failed with result %d\n",
- __func__, rv);
-
-}
-
-static void kill_urbs(struct wdm_device *desc)
-{
- /* the order here is essential */
- usb_kill_urb(desc->command);
- usb_kill_urb(desc->validity);
- usb_kill_urb(desc->response);
-}
-
-static void free_urbs(struct wdm_device *desc)
-{
- usb_free_urb(desc->validity);
- usb_free_urb(desc->response);
- usb_free_urb(desc->command);
-}
-
-static void cleanup(struct wdm_device *desc)
-{
- kfree(desc->sbuf);
- kfree(desc->inbuf);
- kfree(desc->orq);
- kfree(desc->irq);
- kfree(desc->ubuf);
- free_urbs(desc);
- kfree(desc);
-}
-
-static ssize_t wdm_write
-(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
-{
- u8 *buf;
- int rv = -EMSGSIZE, r, we;
- struct wdm_device *desc = file->private_data;
- struct usb_ctrlrequest *req;
-
- if (count > desc->wMaxCommand)
- count = desc->wMaxCommand;
-
- spin_lock_irq(&desc->iuspin);
- we = desc->werr;
- desc->werr = 0;
- spin_unlock_irq(&desc->iuspin);
- if (we < 0)
- return -EIO;
-
- buf = kmalloc(count, GFP_KERNEL);
- if (!buf) {
- rv = -ENOMEM;
- goto outnl;
- }
-
- r = copy_from_user(buf, buffer, count);
- if (r > 0) {
- kfree(buf);
- rv = -EFAULT;
- goto outnl;
- }
-
- /* concurrent writes and disconnect */
- r = mutex_lock_interruptible(&desc->wlock);
- rv = -ERESTARTSYS;
- if (r) {
- kfree(buf);
- goto outnl;
- }
-
- if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
- kfree(buf);
- rv = -ENODEV;
- goto outnp;
- }
-
- r = usb_autopm_get_interface(desc->intf);
- if (r < 0) {
- kfree(buf);
- goto outnp;
- }
-
- if (!(file->f_flags & O_NONBLOCK))
- r = wait_event_interruptible(desc->wait, !test_bit(WDM_IN_USE,
- &desc->flags));
- else
- if (test_bit(WDM_IN_USE, &desc->flags))
- r = -EAGAIN;
-
- if (test_bit(WDM_RESETTING, &desc->flags))
- r = -EIO;
-
- if (r < 0) {
- kfree(buf);
- goto out;
- }
-
- req = desc->orq;
- usb_fill_control_urb(
- desc->command,
- interface_to_usbdev(desc->intf),
- /* using common endpoint 0 */
- usb_sndctrlpipe(interface_to_usbdev(desc->intf), 0),
- (unsigned char *)req,
- buf,
- count,
- wdm_out_callback,
- desc
- );
-
- req->bRequestType = (USB_DIR_OUT | USB_TYPE_CLASS |
- USB_RECIP_INTERFACE);
- req->bRequest = USB_CDC_SEND_ENCAPSULATED_COMMAND;
- req->wValue = 0;
- req->wIndex = desc->inum;
- req->wLength = cpu_to_le16(count);
- set_bit(WDM_IN_USE, &desc->flags);
- desc->outbuf = buf;
-
- rv = usb_submit_urb(desc->command, GFP_KERNEL);
- if (rv < 0) {
- kfree(buf);
- desc->outbuf = NULL;
- clear_bit(WDM_IN_USE, &desc->flags);
- dev_err(&desc->intf->dev, "Tx URB error: %d\n", rv);
- } else {
- dev_dbg(&desc->intf->dev, "Tx URB has been submitted index=%d",
- req->wIndex);
- }
-out:
- usb_autopm_put_interface(desc->intf);
-outnp:
- mutex_unlock(&desc->wlock);
-outnl:
- return rv < 0 ? rv : count;
-}
-
-static ssize_t wdm_read
-(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
-{
- int rv, cntr;
- int i = 0;
- struct wdm_device *desc = file->private_data;
-
-
- rv = mutex_lock_interruptible(&desc->rlock); /*concurrent reads */
- if (rv < 0)
- return -ERESTARTSYS;
-
- cntr = ACCESS_ONCE(desc->length);
- if (cntr == 0) {
- desc->read = 0;
-retry:
- if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
- rv = -ENODEV;
- goto err;
- }
- i++;
- if (file->f_flags & O_NONBLOCK) {
- if (!test_bit(WDM_READ, &desc->flags)) {
- rv = cntr ? cntr : -EAGAIN;
- goto err;
- }
- rv = 0;
- } else {
- rv = wait_event_interruptible(desc->wait,
- test_bit(WDM_READ, &desc->flags));
- }
-
- /* may have happened while we slept */
- if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
- rv = -ENODEV;
- goto err;
- }
- if (test_bit(WDM_RESETTING, &desc->flags)) {
- rv = -EIO;
- goto err;
- }
- usb_mark_last_busy(interface_to_usbdev(desc->intf));
- if (rv < 0) {
- rv = -ERESTARTSYS;
- goto err;
- }
-
- spin_lock_irq(&desc->iuspin);
-
- if (desc->rerr) { /* read completed, error happened */
- desc->rerr = 0;
- spin_unlock_irq(&desc->iuspin);
- rv = -EIO;
- goto err;
- }
- /*
- * recheck whether we've lost the race
- * against the completion handler
- */
- if (!test_bit(WDM_READ, &desc->flags)) { /* lost race */
- spin_unlock_irq(&desc->iuspin);
- goto retry;
- }
- if (!desc->reslength) { /* zero length read */
- dev_dbg(&desc->intf->dev, "%s: zero length - clearing WDM_READ\n", __func__);
- clear_bit(WDM_READ, &desc->flags);
- spin_unlock_irq(&desc->iuspin);
- goto retry;
- }
- cntr = desc->length;
- spin_unlock_irq(&desc->iuspin);
- }
-
- if (cntr > count)
- cntr = count;
- rv = copy_to_user(buffer, desc->ubuf, cntr);
- if (rv > 0) {
- rv = -EFAULT;
- goto err;
- }
-
- spin_lock_irq(&desc->iuspin);
-
- for (i = 0; i < desc->length - cntr; i++)
- desc->ubuf[i] = desc->ubuf[i + cntr];
-
- desc->length -= cntr;
- /* in case we had outstanding data */
- if (!desc->length)
- clear_bit(WDM_READ, &desc->flags);
-
- spin_unlock_irq(&desc->iuspin);
-
- rv = cntr;
-
-err:
- mutex_unlock(&desc->rlock);
- return rv;
-}
-
-static int wdm_flush(struct file *file, fl_owner_t id)
-{
- struct wdm_device *desc = file->private_data;
-
- wait_event(desc->wait, !test_bit(WDM_IN_USE, &desc->flags));
-
- /* cannot dereference desc->intf if WDM_DISCONNECTING */
- if (desc->werr < 0 && !test_bit(WDM_DISCONNECTING, &desc->flags))
- dev_err(&desc->intf->dev, "Error in flush path: %d\n",
- desc->werr);
-
- return usb_translate_errors(desc->werr);
-}
-
-static unsigned int wdm_poll(struct file *file, struct poll_table_struct *wait)
-{
- struct wdm_device *desc = file->private_data;
- unsigned long flags;
- unsigned int mask = 0;
-
- spin_lock_irqsave(&desc->iuspin, flags);
- if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
- mask = POLLHUP | POLLERR;
- spin_unlock_irqrestore(&desc->iuspin, flags);
- goto desc_out;
- }
- if (test_bit(WDM_READ, &desc->flags))
- mask = POLLIN | POLLRDNORM;
- if (desc->rerr || desc->werr)
- mask |= POLLERR;
- if (!test_bit(WDM_IN_USE, &desc->flags))
- mask |= POLLOUT | POLLWRNORM;
- spin_unlock_irqrestore(&desc->iuspin, flags);
-
- poll_wait(file, &desc->wait, wait);
-
-desc_out:
- return mask;
-}
-
-static int wdm_open(struct inode *inode, struct file *file)
-{
- int minor = iminor(inode);
- int rv = -ENODEV;
- struct usb_interface *intf;
- struct wdm_device *desc;
-
- mutex_lock(&wdm_mutex);
- desc = wdm_find_device_by_minor(minor);
- if (!desc)
- goto out;
-
- intf = desc->intf;
- if (test_bit(WDM_DISCONNECTING, &desc->flags))
- goto out;
- file->private_data = desc;
-
- rv = usb_autopm_get_interface(desc->intf);
- if (rv < 0) {
- dev_err(&desc->intf->dev, "Error autopm - %d\n", rv);
- goto out;
- }
-
- /* using write lock to protect desc->count */
- mutex_lock(&desc->wlock);
- if (!desc->count++) {
- desc->werr = 0;
- desc->rerr = 0;
- rv = usb_submit_urb(desc->validity, GFP_KERNEL);
- if (rv < 0) {
- desc->count--;
- dev_err(&desc->intf->dev,
- "Error submitting int urb - %d\n", rv);
- }
- } else {
- rv = 0;
- }
- mutex_unlock(&desc->wlock);
- if (desc->count == 1)
- desc->manage_power(intf, 1);
- usb_autopm_put_interface(desc->intf);
-out:
- mutex_unlock(&wdm_mutex);
- return rv;
-}
-
-static int wdm_release(struct inode *inode, struct file *file)
-{
- struct wdm_device *desc = file->private_data;
-
- mutex_lock(&wdm_mutex);
-
- /* using write lock to protect desc->count */
- mutex_lock(&desc->wlock);
- desc->count--;
- mutex_unlock(&desc->wlock);
-
- if (!desc->count) {
- if (!test_bit(WDM_DISCONNECTING, &desc->flags)) {
- dev_dbg(&desc->intf->dev, "wdm_release: cleanup");
- kill_urbs(desc);
- desc->manage_power(desc->intf, 0);
- } else {
- /* must avoid dev_printk here as desc->intf is invalid */
- pr_debug(KBUILD_MODNAME " %s: device gone - cleaning up\n", __func__);
- cleanup(desc);
- }
- }
- mutex_unlock(&wdm_mutex);
- return 0;
-}
-
-static const struct file_operations wdm_fops = {
- .owner = THIS_MODULE,
- .read = wdm_read,
- .write = wdm_write,
- .open = wdm_open,
- .flush = wdm_flush,
- .release = wdm_release,
- .poll = wdm_poll,
- .llseek = noop_llseek,
-};
-
-static struct usb_class_driver wdm_class = {
- .name = "cdc-wdm%d",
- .fops = &wdm_fops,
- .minor_base = WDM_MINOR_BASE,
-};
-
-/* --- error handling --- */
-static void wdm_rxwork(struct work_struct *work)
-{
- struct wdm_device *desc = container_of(work, struct wdm_device, rxwork);
- unsigned long flags;
- int rv;
-
- spin_lock_irqsave(&desc->iuspin, flags);
- if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
- spin_unlock_irqrestore(&desc->iuspin, flags);
- } else {
- spin_unlock_irqrestore(&desc->iuspin, flags);
- rv = usb_submit_urb(desc->response, GFP_KERNEL);
- if (rv < 0 && rv != -EPERM) {
- spin_lock_irqsave(&desc->iuspin, flags);
- if (!test_bit(WDM_DISCONNECTING, &desc->flags))
- schedule_work(&desc->rxwork);
- spin_unlock_irqrestore(&desc->iuspin, flags);
- }
- }
-}
-
-/* --- hotplug --- */
-
-static int wdm_create(struct usb_interface *intf, struct usb_endpoint_descriptor *ep,
- u16 bufsize, int (*manage_power)(struct usb_interface *, int))
-{
- int rv = -ENOMEM;
- struct wdm_device *desc;
-
- desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL);
- if (!desc)
- goto out;
- INIT_LIST_HEAD(&desc->device_list);
- mutex_init(&desc->rlock);
- mutex_init(&desc->wlock);
- spin_lock_init(&desc->iuspin);
- init_waitqueue_head(&desc->wait);
- desc->wMaxCommand = bufsize;
- /* this will be expanded and needed in hardware endianness */
- desc->inum = cpu_to_le16((u16)intf->cur_altsetting->desc.bInterfaceNumber);
- desc->intf = intf;
- INIT_WORK(&desc->rxwork, wdm_rxwork);
-
- rv = -EINVAL;
- if (!usb_endpoint_is_int_in(ep))
- goto err;
-
- desc->wMaxPacketSize = usb_endpoint_maxp(ep);
-
- desc->orq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
- if (!desc->orq)
- goto err;
- desc->irq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
- if (!desc->irq)
- goto err;
-
- desc->validity = usb_alloc_urb(0, GFP_KERNEL);
- if (!desc->validity)
- goto err;
-
- desc->response = usb_alloc_urb(0, GFP_KERNEL);
- if (!desc->response)
- goto err;
-
- desc->command = usb_alloc_urb(0, GFP_KERNEL);
- if (!desc->command)
- goto err;
-
- desc->ubuf = kmalloc(desc->wMaxCommand, GFP_KERNEL);
- if (!desc->ubuf)
- goto err;
-
- desc->sbuf = kmalloc(desc->wMaxPacketSize, GFP_KERNEL);
- if (!desc->sbuf)
- goto err;
-
- desc->inbuf = kmalloc(desc->wMaxCommand, GFP_KERNEL);
- if (!desc->inbuf)
- goto err;
-
- usb_fill_int_urb(
- desc->validity,
- interface_to_usbdev(intf),
- usb_rcvintpipe(interface_to_usbdev(intf), ep->bEndpointAddress),
- desc->sbuf,
- desc->wMaxPacketSize,
- wdm_int_callback,
- desc,
- ep->bInterval
- );
-
- desc->irq->bRequestType = (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE);
- desc->irq->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE;
- desc->irq->wValue = 0;
- desc->irq->wIndex = desc->inum;
- desc->irq->wLength = cpu_to_le16(desc->wMaxCommand);
-
- usb_fill_control_urb(
- desc->response,
- interface_to_usbdev(intf),
- /* using common endpoint 0 */
- usb_rcvctrlpipe(interface_to_usbdev(desc->intf), 0),
- (unsigned char *)desc->irq,
- desc->inbuf,
- desc->wMaxCommand,
- wdm_in_callback,
- desc
- );
-
- desc->manage_power = manage_power;
-
- spin_lock(&wdm_device_list_lock);
- list_add(&desc->device_list, &wdm_device_list);
- spin_unlock(&wdm_device_list_lock);
-
- rv = usb_register_dev(intf, &wdm_class);
- if (rv < 0)
- goto err;
- else
- dev_info(&intf->dev, "%s: USB WDM device\n", dev_name(intf->usb_dev));
-out:
- return rv;
-err:
- spin_lock(&wdm_device_list_lock);
- list_del(&desc->device_list);
- spin_unlock(&wdm_device_list_lock);
- cleanup(desc);
- return rv;
-}
-
-static int wdm_manage_power(struct usb_interface *intf, int on)
-{
- /* need autopm_get/put here to ensure the usbcore sees the new value */
- int rv = usb_autopm_get_interface(intf);
- if (rv < 0)
- goto err;
-
- intf->needs_remote_wakeup = on;
- usb_autopm_put_interface(intf);
-err:
- return rv;
-}
-
-static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id)
-{
- int rv = -EINVAL;
- struct usb_host_interface *iface;
- struct usb_endpoint_descriptor *ep;
- struct usb_cdc_dmm_desc *dmhd;
- u8 *buffer = intf->altsetting->extra;
- int buflen = intf->altsetting->extralen;
- u16 maxcom = WDM_DEFAULT_BUFSIZE;
-
- if (!buffer)
- goto err;
- while (buflen > 2) {
- if (buffer[1] != USB_DT_CS_INTERFACE) {
- dev_err(&intf->dev, "skipping garbage\n");
- goto next_desc;
- }
-
- switch (buffer[2]) {
- case USB_CDC_HEADER_TYPE:
- break;
- case USB_CDC_DMM_TYPE:
- dmhd = (struct usb_cdc_dmm_desc *)buffer;
- maxcom = le16_to_cpu(dmhd->wMaxCommand);
- dev_dbg(&intf->dev,
- "Finding maximum buffer length: %d", maxcom);
- break;
- default:
- dev_err(&intf->dev,
- "Ignoring extra header, type %d, length %d\n",
- buffer[2], buffer[0]);
- break;
- }
-next_desc:
- buflen -= buffer[0];
- buffer += buffer[0];
- }
-
- iface = intf->cur_altsetting;
- if (iface->desc.bNumEndpoints != 1)
- goto err;
- ep = &iface->endpoint[0].desc;
-
- rv = wdm_create(intf, ep, maxcom, &wdm_manage_power);
-
-err:
- return rv;
-}
-
-/**
- * usb_cdc_wdm_register - register a WDM subdriver
- * @intf: usb interface the subdriver will associate with
- * @ep: interrupt endpoint to monitor for notifications
- * @bufsize: maximum message size to support for read/write
- *
- * Create WDM usb class character device and associate it with intf
- * without binding, allowing another driver to manage the interface.
- *
- * The subdriver will manage the given interrupt endpoint exclusively
- * and will issue control requests referring to the given intf. It
- * will otherwise avoid interferring, and in particular not do
- * usb_set_intfdata/usb_get_intfdata on intf.
- *
- * The return value is a pointer to the subdriver's struct usb_driver.
- * The registering driver is responsible for calling this subdriver's
- * disconnect, suspend, resume, pre_reset and post_reset methods from
- * its own.
- */
-struct usb_driver *usb_cdc_wdm_register(struct usb_interface *intf,
- struct usb_endpoint_descriptor *ep,
- int bufsize,
- int (*manage_power)(struct usb_interface *, int))
-{
- int rv = -EINVAL;
-
- rv = wdm_create(intf, ep, bufsize, manage_power);
- if (rv < 0)
- goto err;
-
- return &wdm_driver;
-err:
- return ERR_PTR(rv);
-}
-EXPORT_SYMBOL(usb_cdc_wdm_register);
-
-static void wdm_disconnect(struct usb_interface *intf)
-{
- struct wdm_device *desc;
- unsigned long flags;
-
- usb_deregister_dev(intf, &wdm_class);
- desc = wdm_find_device(intf);
- mutex_lock(&wdm_mutex);
-
- /* the spinlock makes sure no new urbs are generated in the callbacks */
- spin_lock_irqsave(&desc->iuspin, flags);
- set_bit(WDM_DISCONNECTING, &desc->flags);
- set_bit(WDM_READ, &desc->flags);
- /* to terminate pending flushes */
- clear_bit(WDM_IN_USE, &desc->flags);
- spin_unlock_irqrestore(&desc->iuspin, flags);
- wake_up_all(&desc->wait);
- mutex_lock(&desc->rlock);
- mutex_lock(&desc->wlock);
- kill_urbs(desc);
- cancel_work_sync(&desc->rxwork);
- mutex_unlock(&desc->wlock);
- mutex_unlock(&desc->rlock);
-
- /* the desc->intf pointer used as list key is now invalid */
- spin_lock(&wdm_device_list_lock);
- list_del(&desc->device_list);
- spin_unlock(&wdm_device_list_lock);
-
- if (!desc->count)
- cleanup(desc);
- mutex_unlock(&wdm_mutex);
-}
-
-#ifdef CONFIG_PM
-static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
-{
- struct wdm_device *desc = wdm_find_device(intf);
- int rv = 0;
-
- dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor);
-
- /* if this is an autosuspend the caller does the locking */
- if (!PMSG_IS_AUTO(message)) {
- mutex_lock(&desc->rlock);
- mutex_lock(&desc->wlock);
- }
- spin_lock_irq(&desc->iuspin);
-
- if (PMSG_IS_AUTO(message) &&
- (test_bit(WDM_IN_USE, &desc->flags)
- || test_bit(WDM_RESPONDING, &desc->flags))) {
- spin_unlock_irq(&desc->iuspin);
- rv = -EBUSY;
- } else {
-
- set_bit(WDM_SUSPENDING, &desc->flags);
- spin_unlock_irq(&desc->iuspin);
- /* callback submits work - order is essential */
- kill_urbs(desc);
- cancel_work_sync(&desc->rxwork);
- }
- if (!PMSG_IS_AUTO(message)) {
- mutex_unlock(&desc->wlock);
- mutex_unlock(&desc->rlock);
- }
-
- return rv;
-}
-#endif
-
-static int recover_from_urb_loss(struct wdm_device *desc)
-{
- int rv = 0;
-
- if (desc->count) {
- rv = usb_submit_urb(desc->validity, GFP_NOIO);
- if (rv < 0)
- dev_err(&desc->intf->dev,
- "Error resume submitting int urb - %d\n", rv);
- }
- return rv;
-}
-
-#ifdef CONFIG_PM
-static int wdm_resume(struct usb_interface *intf)
-{
- struct wdm_device *desc = wdm_find_device(intf);
- int rv;
-
- dev_dbg(&desc->intf->dev, "wdm%d_resume\n", intf->minor);
-
- clear_bit(WDM_SUSPENDING, &desc->flags);
- rv = recover_from_urb_loss(desc);
-
- return rv;
-}
-#endif
-
-static int wdm_pre_reset(struct usb_interface *intf)
-{
- struct wdm_device *desc = wdm_find_device(intf);
-
- /*
- * we notify everybody using poll of
- * an exceptional situation
- * must be done before recovery lest a spontaneous
- * message from the device is lost
- */
- spin_lock_irq(&desc->iuspin);
- set_bit(WDM_RESETTING, &desc->flags); /* inform read/write */
- set_bit(WDM_READ, &desc->flags); /* unblock read */
- clear_bit(WDM_IN_USE, &desc->flags); /* unblock write */
- desc->rerr = -EINTR;
- spin_unlock_irq(&desc->iuspin);
- wake_up_all(&desc->wait);
- mutex_lock(&desc->rlock);
- mutex_lock(&desc->wlock);
- kill_urbs(desc);
- cancel_work_sync(&desc->rxwork);
- return 0;
-}
-
-static int wdm_post_reset(struct usb_interface *intf)
-{
- struct wdm_device *desc = wdm_find_device(intf);
- int rv;
-
- clear_bit(WDM_RESETTING, &desc->flags);
- rv = recover_from_urb_loss(desc);
- mutex_unlock(&desc->wlock);
- mutex_unlock(&desc->rlock);
- return 0;
-}
-
-static struct usb_driver wdm_driver = {
- .name = "cdc_wdm",
- .probe = wdm_probe,
- .disconnect = wdm_disconnect,
-#ifdef CONFIG_PM
- .suspend = wdm_suspend,
- .resume = wdm_resume,
- .reset_resume = wdm_resume,
-#endif
- .pre_reset = wdm_pre_reset,
- .post_reset = wdm_post_reset,
- .id_table = wdm_ids,
- .supports_autosuspend = 1,
-};
-
-module_usb_driver(wdm_driver);
-
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
diff --git a/ANDROID_3.4.5/drivers/usb/class/usblp.c b/ANDROID_3.4.5/drivers/usb/class/usblp.c
deleted file mode 100644
index a68c1a63..00000000
--- a/ANDROID_3.4.5/drivers/usb/class/usblp.c
+++ /dev/null
@@ -1,1421 +0,0 @@
-/*
- * usblp.c
- *
- * Copyright (c) 1999 Michael Gee
- * Copyright (c) 1999 Pavel Machek
- * Copyright (c) 2000 Randy Dunlap
- * Copyright (c) 2000 Vojtech Pavlik
- # Copyright (c) 2001 Pete Zaitcev
- # Copyright (c) 2001 David Paschal
- * Copyright (c) 2006 Oliver Neukum
- *
- * USB Printer Device Class driver for USB printers and printer cables
- *
- * Sponsored by SuSE
- *
- * ChangeLog:
- * v0.1 - thorough cleaning, URBification, almost a rewrite
- * v0.2 - some more cleanups
- * v0.3 - cleaner again, waitqueue fixes
- * v0.4 - fixes in unidirectional mode
- * v0.5 - add DEVICE_ID string support
- * v0.6 - never time out
- * v0.7 - fixed bulk-IN read and poll (David Paschal)
- * v0.8 - add devfs support
- * v0.9 - fix unplug-while-open paths
- * v0.10- remove sleep_on, fix error on oom (oliver@neukum.org)
- * v0.11 - add proto_bias option (Pete Zaitcev)
- * v0.12 - add hpoj.sourceforge.net ioctls (David Paschal)
- * v0.13 - alloc space for statusbuf ( not on stack);
- * use usb_alloc_coherent() for read buf & write buf;
- * none - Maintained in Linux kernel after v0.13
- */
-
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#undef DEBUG
-#include
-#include
-
-/*
- * Version Information
- */
-#define DRIVER_AUTHOR "Michael Gee, Pavel Machek, Vojtech Pavlik, Randy Dunlap, Pete Zaitcev, David Paschal"
-#define DRIVER_DESC "USB Printer Device Class driver"
-
-#define USBLP_BUF_SIZE 8192
-#define USBLP_BUF_SIZE_IN 1024
-#define USBLP_DEVICE_ID_SIZE 1024
-
-/* ioctls: */
-#define IOCNR_GET_DEVICE_ID 1
-#define IOCNR_GET_PROTOCOLS 2
-#define IOCNR_SET_PROTOCOL 3
-#define IOCNR_HP_SET_CHANNEL 4
-#define IOCNR_GET_BUS_ADDRESS 5
-#define IOCNR_GET_VID_PID 6
-#define IOCNR_SOFT_RESET 7
-/* Get device_id string: */
-#define LPIOC_GET_DEVICE_ID(len) _IOC(_IOC_READ, 'P', IOCNR_GET_DEVICE_ID, len)
-/* The following ioctls were added for http://hpoj.sourceforge.net: */
-/* Get two-int array:
- * [0]=current protocol (1=7/1/1, 2=7/1/2, 3=7/1/3),
- * [1]=supported protocol mask (mask&(1<wmut locks wstatus.
- * ->mut locks the whole usblp, except [rw]complete, and thus, by indirection,
- * [rw]status. We only touch status when we know the side idle.
- * ->lock locks what interrupt accesses.
- */
-struct usblp {
- struct usb_device *dev; /* USB device */
- struct mutex wmut;
- struct mutex mut;
- spinlock_t lock; /* locks rcomplete, wcomplete */
- char *readbuf; /* read transfer_buffer */
- char *statusbuf; /* status transfer_buffer */
- struct usb_anchor urbs;
- wait_queue_head_t rwait, wwait;
- int readcount; /* Counter for reads */
- int ifnum; /* Interface number */
- struct usb_interface *intf; /* The interface */
- /* Alternate-setting numbers and endpoints for each protocol
- * (7/1/{index=1,2,3}) that the device supports: */
- struct {
- int alt_setting;
- struct usb_endpoint_descriptor *epwrite;
- struct usb_endpoint_descriptor *epread;
- } protocol[USBLP_MAX_PROTOCOLS];
- int current_protocol;
- int minor; /* minor number of device */
- int wcomplete, rcomplete;
- int wstatus; /* bytes written or error */
- int rstatus; /* bytes ready or error */
- unsigned int quirks; /* quirks flags */
- unsigned int flags; /* mode flags */
- unsigned char used; /* True if open */
- unsigned char present; /* True if not disconnected */
- unsigned char bidir; /* interface is bidirectional */
- unsigned char no_paper; /* Paper Out happened */
- unsigned char *device_id_string; /* IEEE 1284 DEVICE ID string (ptr) */
- /* first 2 bytes are (big-endian) length */
-};
-
-#ifdef DEBUG
-static void usblp_dump(struct usblp *usblp)
-{
- int p;
-
- dbg("usblp=0x%p", usblp);
- dbg("dev=0x%p", usblp->dev);
- dbg("present=%d", usblp->present);
- dbg("readbuf=0x%p", usblp->readbuf);
- dbg("readcount=%d", usblp->readcount);
- dbg("ifnum=%d", usblp->ifnum);
- for (p = USBLP_FIRST_PROTOCOL; p <= USBLP_LAST_PROTOCOL; p++) {
- dbg("protocol[%d].alt_setting=%d", p, usblp->protocol[p].alt_setting);
- dbg("protocol[%d].epwrite=%p", p, usblp->protocol[p].epwrite);
- dbg("protocol[%d].epread=%p", p, usblp->protocol[p].epread);
- }
- dbg("current_protocol=%d", usblp->current_protocol);
- dbg("minor=%d", usblp->minor);
- dbg("wstatus=%d", usblp->wstatus);
- dbg("rstatus=%d", usblp->rstatus);
- dbg("quirks=%d", usblp->quirks);
- dbg("used=%d", usblp->used);
- dbg("bidir=%d", usblp->bidir);
- dbg("device_id_string=\"%s\"",
- usblp->device_id_string ?
- usblp->device_id_string + 2 :
- (unsigned char *)"(null)");
-}
-#endif
-
-/* Quirks: various printer quirks are handled by this table & its flags. */
-
-struct quirk_printer_struct {
- __u16 vendorId;
- __u16 productId;
- unsigned int quirks;
-};
-
-#define USBLP_QUIRK_BIDIR 0x1 /* reports bidir but requires unidirectional mode (no INs/reads) */
-#define USBLP_QUIRK_USB_INIT 0x2 /* needs vendor USB init string */
-#define USBLP_QUIRK_BAD_CLASS 0x4 /* descriptor uses vendor-specific Class or SubClass */
-
-static const struct quirk_printer_struct quirk_printers[] = {
- { 0x03f0, 0x0004, USBLP_QUIRK_BIDIR }, /* HP DeskJet 895C */
- { 0x03f0, 0x0104, USBLP_QUIRK_BIDIR }, /* HP DeskJet 880C */
- { 0x03f0, 0x0204, USBLP_QUIRK_BIDIR }, /* HP DeskJet 815C */
- { 0x03f0, 0x0304, USBLP_QUIRK_BIDIR }, /* HP DeskJet 810C/812C */
- { 0x03f0, 0x0404, USBLP_QUIRK_BIDIR }, /* HP DeskJet 830C */
- { 0x03f0, 0x0504, USBLP_QUIRK_BIDIR }, /* HP DeskJet 885C */
- { 0x03f0, 0x0604, USBLP_QUIRK_BIDIR }, /* HP DeskJet 840C */
- { 0x03f0, 0x0804, USBLP_QUIRK_BIDIR }, /* HP DeskJet 816C */
- { 0x03f0, 0x1104, USBLP_QUIRK_BIDIR }, /* HP Deskjet 959C */
- { 0x0409, 0xefbe, USBLP_QUIRK_BIDIR }, /* NEC Picty900 (HP OEM) */
- { 0x0409, 0xbef4, USBLP_QUIRK_BIDIR }, /* NEC Picty760 (HP OEM) */
- { 0x0409, 0xf0be, USBLP_QUIRK_BIDIR }, /* NEC Picty920 (HP OEM) */
- { 0x0409, 0xf1be, USBLP_QUIRK_BIDIR }, /* NEC Picty800 (HP OEM) */
- { 0x0482, 0x0010, USBLP_QUIRK_BIDIR }, /* Kyocera Mita FS 820, by zut */
- { 0x04f9, 0x000d, USBLP_QUIRK_BIDIR }, /* Brother Industries, Ltd HL-1440 Laser Printer */
- { 0x04b8, 0x0202, USBLP_QUIRK_BAD_CLASS }, /* Seiko Epson Receipt Printer M129C */
- { 0, 0 }
-};
-
-static int usblp_wwait(struct usblp *usblp, int nonblock);
-static int usblp_wtest(struct usblp *usblp, int nonblock);
-static int usblp_rwait_and_lock(struct usblp *usblp, int nonblock);
-static int usblp_rtest(struct usblp *usblp, int nonblock);
-static int usblp_submit_read(struct usblp *usblp);
-static int usblp_select_alts(struct usblp *usblp);
-static int usblp_set_protocol(struct usblp *usblp, int protocol);
-static int usblp_cache_device_id_string(struct usblp *usblp);
-
-/* forward reference to make our lives easier */
-static struct usb_driver usblp_driver;
-static DEFINE_MUTEX(usblp_mutex); /* locks the existence of usblp's */
-
-/*
- * Functions for usblp control messages.
- */
-
-static int usblp_ctrl_msg(struct usblp *usblp, int request, int type, int dir, int recip, int value, void *buf, int len)
-{
- int retval;
- int index = usblp->ifnum;
-
- /* High byte has the interface index.
- Low byte has the alternate setting.
- */
- if ((request == USBLP_REQ_GET_ID) && (type == USB_TYPE_CLASS))
- index = (usblp->ifnum<<8)|usblp->protocol[usblp->current_protocol].alt_setting;
-
- retval = usb_control_msg(usblp->dev,
- dir ? usb_rcvctrlpipe(usblp->dev, 0) : usb_sndctrlpipe(usblp->dev, 0),
- request, type | dir | recip, value, index, buf, len, USBLP_CTL_TIMEOUT);
- dbg("usblp_control_msg: rq: 0x%02x dir: %d recip: %d value: %d idx: %d len: %#x result: %d",
- request, !!dir, recip, value, index, len, retval);
- return retval < 0 ? retval : 0;
-}
-
-#define usblp_read_status(usblp, status)\
- usblp_ctrl_msg(usblp, USBLP_REQ_GET_STATUS, USB_TYPE_CLASS, USB_DIR_IN, USB_RECIP_INTERFACE, 0, status, 1)
-#define usblp_get_id(usblp, config, id, maxlen)\
- usblp_ctrl_msg(usblp, USBLP_REQ_GET_ID, USB_TYPE_CLASS, USB_DIR_IN, USB_RECIP_INTERFACE, config, id, maxlen)
-#define usblp_reset(usblp)\
- usblp_ctrl_msg(usblp, USBLP_REQ_RESET, USB_TYPE_CLASS, USB_DIR_OUT, USB_RECIP_OTHER, 0, NULL, 0)
-
-#define usblp_hp_channel_change_request(usblp, channel, buffer) \
- usblp_ctrl_msg(usblp, USBLP_REQ_HP_CHANNEL_CHANGE_REQUEST, USB_TYPE_VENDOR, USB_DIR_IN, USB_RECIP_INTERFACE, channel, buffer, 1)
-
-/*
- * See the description for usblp_select_alts() below for the usage
- * explanation. Look into your /proc/bus/usb/devices and dmesg in
- * case of any trouble.
- */
-static int proto_bias = -1;
-
-/*
- * URB callback.
- */
-
-static void usblp_bulk_read(struct urb *urb)
-{
- struct usblp *usblp = urb->context;
- int status = urb->status;
-
- if (usblp->present && usblp->used) {
- if (status)
- printk(KERN_WARNING "usblp%d: "
- "nonzero read bulk status received: %d\n",
- usblp->minor, status);
- }
- spin_lock(&usblp->lock);
- if (status < 0)
- usblp->rstatus = status;
- else
- usblp->rstatus = urb->actual_length;
- usblp->rcomplete = 1;
- wake_up(&usblp->rwait);
- spin_unlock(&usblp->lock);
-
- usb_free_urb(urb);
-}
-
-static void usblp_bulk_write(struct urb *urb)
-{
- struct usblp *usblp = urb->context;
- int status = urb->status;
-
- if (usblp->present && usblp->used) {
- if (status)
- printk(KERN_WARNING "usblp%d: "
- "nonzero write bulk status received: %d\n",
- usblp->minor, status);
- }
- spin_lock(&usblp->lock);
- if (status < 0)
- usblp->wstatus = status;
- else
- usblp->wstatus = urb->actual_length;
- usblp->no_paper = 0;
- usblp->wcomplete = 1;
- wake_up(&usblp->wwait);
- spin_unlock(&usblp->lock);
-
- usb_free_urb(urb);
-}
-
-/*
- * Get and print printer errors.
- */
-
-static const char *usblp_messages[] = { "ok", "out of paper", "off-line", "on fire" };
-
-static int usblp_check_status(struct usblp *usblp, int err)
-{
- unsigned char status, newerr = 0;
- int error;
-
- mutex_lock(&usblp->mut);
- if ((error = usblp_read_status(usblp, usblp->statusbuf)) < 0) {
- mutex_unlock(&usblp->mut);
- printk_ratelimited(KERN_ERR
- "usblp%d: error %d reading printer status\n",
- usblp->minor, error);
- return 0;
- }
- status = *usblp->statusbuf;
- mutex_unlock(&usblp->mut);
-
- if (~status & LP_PERRORP)
- newerr = 3;
- if (status & LP_POUTPA)
- newerr = 1;
- if (~status & LP_PSELECD)
- newerr = 2;
-
- if (newerr != err) {
- printk(KERN_INFO "usblp%d: %s\n",
- usblp->minor, usblp_messages[newerr]);
- }
-
- return newerr;
-}
-
-static int handle_bidir(struct usblp *usblp)
-{
- if (usblp->bidir && usblp->used) {
- if (usblp_submit_read(usblp) < 0)
- return -EIO;
- }
- return 0;
-}
-
-/*
- * File op functions.
- */
-
-static int usblp_open(struct inode *inode, struct file *file)
-{
- int minor = iminor(inode);
- struct usblp *usblp;
- struct usb_interface *intf;
- int retval;
-
- if (minor < 0)
- return -ENODEV;
-
- mutex_lock(&usblp_mutex);
-
- retval = -ENODEV;
- intf = usb_find_interface(&usblp_driver, minor);
- if (!intf)
- goto out;
- usblp = usb_get_intfdata(intf);
- if (!usblp || !usblp->dev || !usblp->present)
- goto out;
-
- retval = -EBUSY;
- if (usblp->used)
- goto out;
-
- /*
- * We do not implement LP_ABORTOPEN/LPABORTOPEN for two reasons:
- * - We do not want persistent state which close(2) does not clear
- * - It is not used anyway, according to CUPS people
- */
-
- retval = usb_autopm_get_interface(intf);
- if (retval < 0)
- goto out;
- usblp->used = 1;
- file->private_data = usblp;
-
- usblp->wcomplete = 1; /* we begin writeable */
- usblp->wstatus = 0;
- usblp->rcomplete = 0;
-
- if (handle_bidir(usblp) < 0) {
- usb_autopm_put_interface(intf);
- usblp->used = 0;
- file->private_data = NULL;
- retval = -EIO;
- }
-out:
- mutex_unlock(&usblp_mutex);
- return retval;
-}
-
-static void usblp_cleanup(struct usblp *usblp)
-{
- printk(KERN_INFO "usblp%d: removed\n", usblp->minor);
-
- kfree(usblp->readbuf);
- kfree(usblp->device_id_string);
- kfree(usblp->statusbuf);
- kfree(usblp);
-}
-
-static void usblp_unlink_urbs(struct usblp *usblp)
-{
- usb_kill_anchored_urbs(&usblp->urbs);
-}
-
-static int usblp_release(struct inode *inode, struct file *file)
-{
- struct usblp *usblp = file->private_data;
-
- usblp->flags &= ~LP_ABORT;
-
- mutex_lock(&usblp_mutex);
- usblp->used = 0;
- if (usblp->present) {
- usblp_unlink_urbs(usblp);
- usb_autopm_put_interface(usblp->intf);
- } else /* finish cleanup from disconnect */
- usblp_cleanup(usblp);
- mutex_unlock(&usblp_mutex);
- return 0;
-}
-
-/* No kernel lock - fine */
-static unsigned int usblp_poll(struct file *file, struct poll_table_struct *wait)
-{
- int ret;
- unsigned long flags;
-
- struct usblp *usblp = file->private_data;
- /* Should we check file->f_mode & FMODE_WRITE before poll_wait()? */
- poll_wait(file, &usblp->rwait, wait);
- poll_wait(file, &usblp->wwait, wait);
- spin_lock_irqsave(&usblp->lock, flags);
- ret = ((usblp->bidir && usblp->rcomplete) ? POLLIN | POLLRDNORM : 0) |
- ((usblp->no_paper || usblp->wcomplete) ? POLLOUT | POLLWRNORM : 0);
- spin_unlock_irqrestore(&usblp->lock, flags);
- return ret;
-}
-
-static long usblp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
- struct usblp *usblp = file->private_data;
- int length, err, i;
- unsigned char newChannel;
- int status;
- int twoints[2];
- int retval = 0;
-
- mutex_lock(&usblp->mut);
- if (!usblp->present) {
- retval = -ENODEV;
- goto done;
- }
-
- dbg("usblp_ioctl: cmd=0x%x (%c nr=%d len=%d dir=%d)", cmd, _IOC_TYPE(cmd),
- _IOC_NR(cmd), _IOC_SIZE(cmd), _IOC_DIR(cmd));
-
- if (_IOC_TYPE(cmd) == 'P') /* new-style ioctl number */
-
- switch (_IOC_NR(cmd)) {
-
- case IOCNR_GET_DEVICE_ID: /* get the DEVICE_ID string */
- if (_IOC_DIR(cmd) != _IOC_READ) {
- retval = -EINVAL;
- goto done;
- }
-
- length = usblp_cache_device_id_string(usblp);
- if (length < 0) {
- retval = length;
- goto done;
- }
- if (length > _IOC_SIZE(cmd))
- length = _IOC_SIZE(cmd); /* truncate */
-
- if (copy_to_user((void __user *) arg,
- usblp->device_id_string,
- (unsigned long) length)) {
- retval = -EFAULT;
- goto done;
- }
-
- break;
-
- case IOCNR_GET_PROTOCOLS:
- if (_IOC_DIR(cmd) != _IOC_READ ||
- _IOC_SIZE(cmd) < sizeof(twoints)) {
- retval = -EINVAL;
- goto done;
- }
-
- twoints[0] = usblp->current_protocol;
- twoints[1] = 0;
- for (i = USBLP_FIRST_PROTOCOL;
- i <= USBLP_LAST_PROTOCOL; i++) {
- if (usblp->protocol[i].alt_setting >= 0)
- twoints[1] |= (1<current_protocol);
- }
- break;
-
- case IOCNR_HP_SET_CHANNEL:
- if (_IOC_DIR(cmd) != _IOC_WRITE ||
- le16_to_cpu(usblp->dev->descriptor.idVendor) != 0x03F0 ||
- usblp->quirks & USBLP_QUIRK_BIDIR) {
- retval = -EINVAL;
- goto done;
- }
-
- err = usblp_hp_channel_change_request(usblp,
- arg, &newChannel);
- if (err < 0) {
- dev_err(&usblp->dev->dev,
- "usblp%d: error = %d setting "
- "HP channel\n",
- usblp->minor, err);
- retval = -EIO;
- goto done;
- }
-
- dbg("usblp%d requested/got HP channel %ld/%d",
- usblp->minor, arg, newChannel);
- break;
-
- case IOCNR_GET_BUS_ADDRESS:
- if (_IOC_DIR(cmd) != _IOC_READ ||
- _IOC_SIZE(cmd) < sizeof(twoints)) {
- retval = -EINVAL;
- goto done;
- }
-
- twoints[0] = usblp->dev->bus->busnum;
- twoints[1] = usblp->dev->devnum;
- if (copy_to_user((void __user *)arg,
- (unsigned char *)twoints,
- sizeof(twoints))) {
- retval = -EFAULT;
- goto done;
- }
-
- dbg("usblp%d is bus=%d, device=%d",
- usblp->minor, twoints[0], twoints[1]);
- break;
-
- case IOCNR_GET_VID_PID:
- if (_IOC_DIR(cmd) != _IOC_READ ||
- _IOC_SIZE(cmd) < sizeof(twoints)) {
- retval = -EINVAL;
- goto done;
- }
-
- twoints[0] = le16_to_cpu(usblp->dev->descriptor.idVendor);
- twoints[1] = le16_to_cpu(usblp->dev->descriptor.idProduct);
- if (copy_to_user((void __user *)arg,
- (unsigned char *)twoints,
- sizeof(twoints))) {
- retval = -EFAULT;
- goto done;
- }
-
- dbg("usblp%d is VID=0x%4.4X, PID=0x%4.4X",
- usblp->minor, twoints[0], twoints[1]);
- break;
-
- case IOCNR_SOFT_RESET:
- if (_IOC_DIR(cmd) != _IOC_NONE) {
- retval = -EINVAL;
- goto done;
- }
- retval = usblp_reset(usblp);
- break;
- default:
- retval = -ENOTTY;
- }
- else /* old-style ioctl value */
- switch (cmd) {
-
- case LPGETSTATUS:
- if ((retval = usblp_read_status(usblp, usblp->statusbuf))) {
- printk_ratelimited(KERN_ERR "usblp%d:"
- "failed reading printer status (%d)\n",
- usblp->minor, retval);
- retval = -EIO;
- goto done;
- }
- status = *usblp->statusbuf;
- if (copy_to_user((void __user *)arg, &status, sizeof(int)))
- retval = -EFAULT;
- break;
-
- case LPABORT:
- if (arg)
- usblp->flags |= LP_ABORT;
- else
- usblp->flags &= ~LP_ABORT;
- break;
-
- default:
- retval = -ENOTTY;
- }
-
-done:
- mutex_unlock(&usblp->mut);
- return retval;
-}
-
-static struct urb *usblp_new_writeurb(struct usblp *usblp, int transfer_length)
-{
- struct urb *urb;
- char *writebuf;
-
- if ((writebuf = kmalloc(transfer_length, GFP_KERNEL)) == NULL)
- return NULL;
- if ((urb = usb_alloc_urb(0, GFP_KERNEL)) == NULL) {
- kfree(writebuf);
- return NULL;
- }
-
- usb_fill_bulk_urb(urb, usblp->dev,
- usb_sndbulkpipe(usblp->dev,
- usblp->protocol[usblp->current_protocol].epwrite->bEndpointAddress),
- writebuf, transfer_length, usblp_bulk_write, usblp);
- urb->transfer_flags |= URB_FREE_BUFFER;
-
- return urb;
-}
-
-static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
-{
- struct usblp *usblp = file->private_data;
- struct urb *writeurb;
- int rv;
- int transfer_length;
- ssize_t writecount = 0;
-
- if (mutex_lock_interruptible(&usblp->wmut)) {
- rv = -EINTR;
- goto raise_biglock;
- }
- if ((rv = usblp_wwait(usblp, !!(file->f_flags & O_NONBLOCK))) < 0)
- goto raise_wait;
-
- while (writecount < count) {
- /*
- * Step 1: Submit next block.
- */
- if ((transfer_length = count - writecount) > USBLP_BUF_SIZE)
- transfer_length = USBLP_BUF_SIZE;
-
- rv = -ENOMEM;
- if ((writeurb = usblp_new_writeurb(usblp, transfer_length)) == NULL)
- goto raise_urb;
- usb_anchor_urb(writeurb, &usblp->urbs);
-
- if (copy_from_user(writeurb->transfer_buffer,
- buffer + writecount, transfer_length)) {
- rv = -EFAULT;
- goto raise_badaddr;
- }
-
- spin_lock_irq(&usblp->lock);
- usblp->wcomplete = 0;
- spin_unlock_irq(&usblp->lock);
- if ((rv = usb_submit_urb(writeurb, GFP_KERNEL)) < 0) {
- usblp->wstatus = 0;
- spin_lock_irq(&usblp->lock);
- usblp->no_paper = 0;
- usblp->wcomplete = 1;
- wake_up(&usblp->wwait);
- spin_unlock_irq(&usblp->lock);
- if (rv != -ENOMEM)
- rv = -EIO;
- goto raise_submit;
- }
-
- /*
- * Step 2: Wait for transfer to end, collect results.
- */
- rv = usblp_wwait(usblp, !!(file->f_flags&O_NONBLOCK));
- if (rv < 0) {
- if (rv == -EAGAIN) {
- /* Presume that it's going to complete well. */
- writecount += transfer_length;
- }
- if (rv == -ENOSPC) {
- spin_lock_irq(&usblp->lock);
- usblp->no_paper = 1; /* Mark for poll(2) */
- spin_unlock_irq(&usblp->lock);
- writecount += transfer_length;
- }
- /* Leave URB dangling, to be cleaned on close. */
- goto collect_error;
- }
-
- if (usblp->wstatus < 0) {
- rv = -EIO;
- goto collect_error;
- }
- /*
- * This is critical: it must be our URB, not other writer's.
- * The wmut exists mainly to cover us here.
- */
- writecount += usblp->wstatus;
- }
-
- mutex_unlock(&usblp->wmut);
- return writecount;
-
-raise_submit:
-raise_badaddr:
- usb_unanchor_urb(writeurb);
- usb_free_urb(writeurb);
-raise_urb:
-raise_wait:
-collect_error: /* Out of raise sequence */
- mutex_unlock(&usblp->wmut);
-raise_biglock:
- return writecount ? writecount : rv;
-}
-
-/*
- * Notice that we fail to restart in a few cases: on EFAULT, on restart
- * error, etc. This is the historical behaviour. In all such cases we return
- * EIO, and applications loop in order to get the new read going.
- */
-static ssize_t usblp_read(struct file *file, char __user *buffer, size_t len, loff_t *ppos)
-{
- struct usblp *usblp = file->private_data;
- ssize_t count;
- ssize_t avail;
- int rv;
-
- if (!usblp->bidir)
- return -EINVAL;
-
- rv = usblp_rwait_and_lock(usblp, !!(file->f_flags & O_NONBLOCK));
- if (rv < 0)
- return rv;
-
- if ((avail = usblp->rstatus) < 0) {
- printk(KERN_ERR "usblp%d: error %d reading from printer\n",
- usblp->minor, (int)avail);
- usblp_submit_read(usblp);
- count = -EIO;
- goto done;
- }
-
- count = len < avail - usblp->readcount ? len : avail - usblp->readcount;
- if (count != 0 &&
- copy_to_user(buffer, usblp->readbuf + usblp->readcount, count)) {
- count = -EFAULT;
- goto done;
- }
-
- if ((usblp->readcount += count) == avail) {
- if (usblp_submit_read(usblp) < 0) {
- /* We don't want to leak USB return codes into errno. */
- if (count == 0)
- count = -EIO;
- goto done;
- }
- }
-
-done:
- mutex_unlock(&usblp->mut);
- return count;
-}
-
-/*
- * Wait for the write path to come idle.
- * This is called under the ->wmut, so the idle path stays idle.
- *
- * Our write path has a peculiar property: it does not buffer like a tty,
- * but waits for the write to succeed. This allows our ->release to bug out
- * without waiting for writes to drain. But it obviously does not work
- * when O_NONBLOCK is set. So, applications setting O_NONBLOCK must use
- * select(2) or poll(2) to wait for the buffer to drain before closing.
- * Alternatively, set blocking mode with fcntl and issue a zero-size write.
- */
-static int usblp_wwait(struct usblp *usblp, int nonblock)
-{
- DECLARE_WAITQUEUE(waita, current);
- int rc;
- int err = 0;
-
- add_wait_queue(&usblp->wwait, &waita);
- for (;;) {
- set_current_state(TASK_INTERRUPTIBLE);
- if (mutex_lock_interruptible(&usblp->mut)) {
- rc = -EINTR;
- break;
- }
- rc = usblp_wtest(usblp, nonblock);
- mutex_unlock(&usblp->mut);
- if (rc <= 0)
- break;
-
- if (schedule_timeout(msecs_to_jiffies(1500)) == 0) {
- if (usblp->flags & LP_ABORT) {
- err = usblp_check_status(usblp, err);
- if (err == 1) { /* Paper out */
- rc = -ENOSPC;
- break;
- }
- } else {
- /* Prod the printer, Gentoo#251237. */
- mutex_lock(&usblp->mut);
- usblp_read_status(usblp, usblp->statusbuf);
- mutex_unlock(&usblp->mut);
- }
- }
- }
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&usblp->wwait, &waita);
- return rc;
-}
-
-static int usblp_wtest(struct usblp *usblp, int nonblock)
-{
- unsigned long flags;
-
- if (!usblp->present)
- return -ENODEV;
- if (signal_pending(current))
- return -EINTR;
- spin_lock_irqsave(&usblp->lock, flags);
- if (usblp->wcomplete) {
- spin_unlock_irqrestore(&usblp->lock, flags);
- return 0;
- }
- spin_unlock_irqrestore(&usblp->lock, flags);
- if (nonblock)
- return -EAGAIN;
- return 1;
-}
-
-/*
- * Wait for read bytes to become available. This probably should have been
- * called usblp_r_lock_and_wait(), because we lock first. But it's a traditional
- * name for functions which lock and return.
- *
- * We do not use wait_event_interruptible because it makes locking iffy.
- */
-static int usblp_rwait_and_lock(struct usblp *usblp, int nonblock)
-{
- DECLARE_WAITQUEUE(waita, current);
- int rc;
-
- add_wait_queue(&usblp->rwait, &waita);
- for (;;) {
- if (mutex_lock_interruptible(&usblp->mut)) {
- rc = -EINTR;
- break;
- }
- set_current_state(TASK_INTERRUPTIBLE);
- if ((rc = usblp_rtest(usblp, nonblock)) < 0) {
- mutex_unlock(&usblp->mut);
- break;
- }
- if (rc == 0) /* Keep it locked */
- break;
- mutex_unlock(&usblp->mut);
- schedule();
- }
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&usblp->rwait, &waita);
- return rc;
-}
-
-static int usblp_rtest(struct usblp *usblp, int nonblock)
-{
- unsigned long flags;
-
- if (!usblp->present)
- return -ENODEV;
- if (signal_pending(current))
- return -EINTR;
- spin_lock_irqsave(&usblp->lock, flags);
- if (usblp->rcomplete) {
- spin_unlock_irqrestore(&usblp->lock, flags);
- return 0;
- }
- spin_unlock_irqrestore(&usblp->lock, flags);
- if (nonblock)
- return -EAGAIN;
- return 1;
-}
-
-/*
- * Please check ->bidir and other such things outside for now.
- */
-static int usblp_submit_read(struct usblp *usblp)
-{
- struct urb *urb;
- unsigned long flags;
- int rc;
-
- rc = -ENOMEM;
- if ((urb = usb_alloc_urb(0, GFP_KERNEL)) == NULL)
- goto raise_urb;
-
- usb_fill_bulk_urb(urb, usblp->dev,
- usb_rcvbulkpipe(usblp->dev,
- usblp->protocol[usblp->current_protocol].epread->bEndpointAddress),
- usblp->readbuf, USBLP_BUF_SIZE_IN,
- usblp_bulk_read, usblp);
- usb_anchor_urb(urb, &usblp->urbs);
-
- spin_lock_irqsave(&usblp->lock, flags);
- usblp->readcount = 0; /* XXX Why here? */
- usblp->rcomplete = 0;
- spin_unlock_irqrestore(&usblp->lock, flags);
- if ((rc = usb_submit_urb(urb, GFP_KERNEL)) < 0) {
- dbg("error submitting urb (%d)", rc);
- spin_lock_irqsave(&usblp->lock, flags);
- usblp->rstatus = rc;
- usblp->rcomplete = 1;
- spin_unlock_irqrestore(&usblp->lock, flags);
- goto raise_submit;
- }
-
- return 0;
-
-raise_submit:
- usb_unanchor_urb(urb);
- usb_free_urb(urb);
-raise_urb:
- return rc;
-}
-
-/*
- * Checks for printers that have quirks, such as requiring unidirectional
- * communication but reporting bidirectional; currently some HP printers
- * have this flaw (HP 810, 880, 895, etc.), or needing an init string
- * sent at each open (like some Epsons).
- * Returns 1 if found, 0 if not found.
- *
- * HP recommended that we use the bidirectional interface but
- * don't attempt any bulk IN transfers from the IN endpoint.
- * Here's some more detail on the problem:
- * The problem is not that it isn't bidirectional though. The problem
- * is that if you request a device ID, or status information, while
- * the buffers are full, the return data will end up in the print data
- * buffer. For example if you make sure you never request the device ID
- * while you are sending print data, and you don't try to query the
- * printer status every couple of milliseconds, you will probably be OK.
- */
-static unsigned int usblp_quirks(__u16 vendor, __u16 product)
-{
- int i;
-
- for (i = 0; quirk_printers[i].vendorId; i++) {
- if (vendor == quirk_printers[i].vendorId &&
- product == quirk_printers[i].productId)
- return quirk_printers[i].quirks;
- }
- return 0;
-}
-
-static const struct file_operations usblp_fops = {
- .owner = THIS_MODULE,
- .read = usblp_read,
- .write = usblp_write,
- .poll = usblp_poll,
- .unlocked_ioctl = usblp_ioctl,
- .compat_ioctl = usblp_ioctl,
- .open = usblp_open,
- .release = usblp_release,
- .llseek = noop_llseek,
-};
-
-static char *usblp_devnode(struct device *dev, umode_t *mode)
-{
- return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev));
-}
-
-static struct usb_class_driver usblp_class = {
- .name = "lp%d",
- .devnode = usblp_devnode,
- .fops = &usblp_fops,
- .minor_base = USBLP_MINOR_BASE,
-};
-
-static ssize_t usblp_show_ieee1284_id(struct device *dev, struct device_attribute *attr, char *buf)
-{
- struct usb_interface *intf = to_usb_interface(dev);
- struct usblp *usblp = usb_get_intfdata(intf);
-
- if (usblp->device_id_string[0] == 0 &&
- usblp->device_id_string[1] == 0)
- return 0;
-
- return sprintf(buf, "%s", usblp->device_id_string+2);
-}
-
-static DEVICE_ATTR(ieee1284_id, S_IRUGO, usblp_show_ieee1284_id, NULL);
-
-static int usblp_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- struct usb_device *dev = interface_to_usbdev(intf);
- struct usblp *usblp;
- int protocol;
- int retval;
-
- /* Malloc and start initializing usblp structure so we can use it
- * directly. */
- usblp = kzalloc(sizeof(struct usblp), GFP_KERNEL);
- if (!usblp) {
- retval = -ENOMEM;
- goto abort_ret;
- }
- usblp->dev = dev;
- mutex_init(&usblp->wmut);
- mutex_init(&usblp->mut);
- spin_lock_init(&usblp->lock);
- init_waitqueue_head(&usblp->rwait);
- init_waitqueue_head(&usblp->wwait);
- init_usb_anchor(&usblp->urbs);
- usblp->ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
- usblp->intf = intf;
-
- /* Malloc device ID string buffer to the largest expected length,
- * since we can re-query it on an ioctl and a dynamic string
- * could change in length. */
- if (!(usblp->device_id_string = kmalloc(USBLP_DEVICE_ID_SIZE, GFP_KERNEL))) {
- retval = -ENOMEM;
- goto abort;
- }
-
- /*
- * Allocate read buffer. We somewhat wastefully
- * malloc both regardless of bidirectionality, because the
- * alternate setting can be changed later via an ioctl.
- */
- if (!(usblp->readbuf = kmalloc(USBLP_BUF_SIZE_IN, GFP_KERNEL))) {
- retval = -ENOMEM;
- goto abort;
- }
-
- /* Allocate buffer for printer status */
- usblp->statusbuf = kmalloc(STATUS_BUF_SIZE, GFP_KERNEL);
- if (!usblp->statusbuf) {
- retval = -ENOMEM;
- goto abort;
- }
-
- /* Lookup quirks for this printer. */
- usblp->quirks = usblp_quirks(
- le16_to_cpu(dev->descriptor.idVendor),
- le16_to_cpu(dev->descriptor.idProduct));
-
- /* Analyze and pick initial alternate settings and endpoints. */
- protocol = usblp_select_alts(usblp);
- if (protocol < 0) {
- dbg("incompatible printer-class device 0x%4.4X/0x%4.4X",
- le16_to_cpu(dev->descriptor.idVendor),
- le16_to_cpu(dev->descriptor.idProduct));
- retval = -ENODEV;
- goto abort;
- }
-
- /* Setup the selected alternate setting and endpoints. */
- if (usblp_set_protocol(usblp, protocol) < 0) {
- retval = -ENODEV; /* ->probe isn't ->ioctl */
- goto abort;
- }
-
- /* Retrieve and store the device ID string. */
- usblp_cache_device_id_string(usblp);
- retval = device_create_file(&intf->dev, &dev_attr_ieee1284_id);
- if (retval)
- goto abort_intfdata;
-
-#ifdef DEBUG
- usblp_check_status(usblp, 0);
-#endif
-
- usb_set_intfdata(intf, usblp);
-
- usblp->present = 1;
-
- retval = usb_register_dev(intf, &usblp_class);
- if (retval) {
- printk(KERN_ERR "usblp: Not able to get a minor"
- " (base %u, slice default): %d\n",
- USBLP_MINOR_BASE, retval);
- goto abort_intfdata;
- }
- usblp->minor = intf->minor;
- printk(KERN_INFO "usblp%d: USB %sdirectional printer dev %d "
- "if %d alt %d proto %d vid 0x%4.4X pid 0x%4.4X\n",
- usblp->minor, usblp->bidir ? "Bi" : "Uni", dev->devnum,
- usblp->ifnum,
- usblp->protocol[usblp->current_protocol].alt_setting,
- usblp->current_protocol,
- le16_to_cpu(usblp->dev->descriptor.idVendor),
- le16_to_cpu(usblp->dev->descriptor.idProduct));
-
- return 0;
-
-abort_intfdata:
- usb_set_intfdata(intf, NULL);
- device_remove_file(&intf->dev, &dev_attr_ieee1284_id);
-abort:
- kfree(usblp->readbuf);
- kfree(usblp->statusbuf);
- kfree(usblp->device_id_string);
- kfree(usblp);
-abort_ret:
- return retval;
-}
-
-/*
- * We are a "new" style driver with usb_device_id table,
- * but our requirements are too intricate for simple match to handle.
- *
- * The "proto_bias" option may be used to specify the preferred protocol
- * for all USB printers (1=7/1/1, 2=7/1/2, 3=7/1/3). If the device
- * supports the preferred protocol, then we bind to it.
- *
- * The best interface for us is 7/1/2, because it is compatible
- * with a stream of characters. If we find it, we bind to it.
- *
- * Note that the people from hpoj.sourceforge.net need to be able to
- * bind to 7/1/3 (MLC/1284.4), so we provide them ioctls for this purpose.
- *
- * Failing 7/1/2, we look for 7/1/3, even though it's probably not
- * stream-compatible, because this matches the behaviour of the old code.
- *
- * If nothing else, we bind to 7/1/1 - the unidirectional interface.
- */
-static int usblp_select_alts(struct usblp *usblp)
-{
- struct usb_interface *if_alt;
- struct usb_host_interface *ifd;
- struct usb_endpoint_descriptor *epd, *epwrite, *epread;
- int p, i, e;
-
- if_alt = usblp->intf;
-
- for (p = 0; p < USBLP_MAX_PROTOCOLS; p++)
- usblp->protocol[p].alt_setting = -1;
-
- /* Find out what we have. */
- for (i = 0; i < if_alt->num_altsetting; i++) {
- ifd = &if_alt->altsetting[i];
-
- if (ifd->desc.bInterfaceClass != 7 || ifd->desc.bInterfaceSubClass != 1)
- if (!(usblp->quirks & USBLP_QUIRK_BAD_CLASS))
- continue;
-
- if (ifd->desc.bInterfaceProtocol < USBLP_FIRST_PROTOCOL ||
- ifd->desc.bInterfaceProtocol > USBLP_LAST_PROTOCOL)
- continue;
-
- /* Look for bulk OUT and IN endpoints. */
- epwrite = epread = NULL;
- for (e = 0; e < ifd->desc.bNumEndpoints; e++) {
- epd = &ifd->endpoint[e].desc;
-
- if (usb_endpoint_is_bulk_out(epd))
- if (!epwrite)
- epwrite = epd;
-
- if (usb_endpoint_is_bulk_in(epd))
- if (!epread)
- epread = epd;
- }
-
- /* Ignore buggy hardware without the right endpoints. */
- if (!epwrite || (ifd->desc.bInterfaceProtocol > 1 && !epread))
- continue;
-
- /* Turn off reads for 7/1/1 (unidirectional) interfaces
- * and buggy bidirectional printers. */
- if (ifd->desc.bInterfaceProtocol == 1) {
- epread = NULL;
- } else if (usblp->quirks & USBLP_QUIRK_BIDIR) {
- printk(KERN_INFO "usblp%d: Disabling reads from "
- "problematic bidirectional printer\n",
- usblp->minor);
- epread = NULL;
- }
-
- usblp->protocol[ifd->desc.bInterfaceProtocol].alt_setting =
- ifd->desc.bAlternateSetting;
- usblp->protocol[ifd->desc.bInterfaceProtocol].epwrite = epwrite;
- usblp->protocol[ifd->desc.bInterfaceProtocol].epread = epread;
- }
-
- /* If our requested protocol is supported, then use it. */
- if (proto_bias >= USBLP_FIRST_PROTOCOL &&
- proto_bias <= USBLP_LAST_PROTOCOL &&
- usblp->protocol[proto_bias].alt_setting != -1)
- return proto_bias;
-
- /* Ordering is important here. */
- if (usblp->protocol[2].alt_setting != -1)
- return 2;
- if (usblp->protocol[1].alt_setting != -1)
- return 1;
- if (usblp->protocol[3].alt_setting != -1)
- return 3;
-
- /* If nothing is available, then don't bind to this device. */
- return -1;
-}
-
-static int usblp_set_protocol(struct usblp *usblp, int protocol)
-{
- int r, alts;
-
- if (protocol < USBLP_FIRST_PROTOCOL || protocol > USBLP_LAST_PROTOCOL)
- return -EINVAL;
-
- alts = usblp->protocol[protocol].alt_setting;
- if (alts < 0)
- return -EINVAL;
- r = usb_set_interface(usblp->dev, usblp->ifnum, alts);
- if (r < 0) {
- printk(KERN_ERR "usblp: can't set desired altsetting %d on interface %d\n",
- alts, usblp->ifnum);
- return r;
- }
-
- usblp->bidir = (usblp->protocol[protocol].epread != NULL);
- usblp->current_protocol = protocol;
- dbg("usblp%d set protocol %d", usblp->minor, protocol);
- return 0;
-}
-
-/* Retrieves and caches device ID string.
- * Returns length, including length bytes but not null terminator.
- * On error, returns a negative errno value. */
-static int usblp_cache_device_id_string(struct usblp *usblp)
-{
- int err, length;
-
- err = usblp_get_id(usblp, 0, usblp->device_id_string, USBLP_DEVICE_ID_SIZE - 1);
- if (err < 0) {
- dbg("usblp%d: error = %d reading IEEE-1284 Device ID string",
- usblp->minor, err);
- usblp->device_id_string[0] = usblp->device_id_string[1] = '\0';
- return -EIO;
- }
-
- /* First two bytes are length in big-endian.
- * They count themselves, and we copy them into
- * the user's buffer. */
- length = be16_to_cpu(*((__be16 *)usblp->device_id_string));
- if (length < 2)
- length = 2;
- else if (length >= USBLP_DEVICE_ID_SIZE)
- length = USBLP_DEVICE_ID_SIZE - 1;
- usblp->device_id_string[length] = '\0';
-
- dbg("usblp%d Device ID string [len=%d]=\"%s\"",
- usblp->minor, length, &usblp->device_id_string[2]);
-
- return length;
-}
-
-static void usblp_disconnect(struct usb_interface *intf)
-{
- struct usblp *usblp = usb_get_intfdata(intf);
-
- usb_deregister_dev(intf, &usblp_class);
-
- if (!usblp || !usblp->dev) {
- dev_err(&intf->dev, "bogus disconnect\n");
- BUG();
- }
-
- device_remove_file(&intf->dev, &dev_attr_ieee1284_id);
-
- mutex_lock(&usblp_mutex);
- mutex_lock(&usblp->mut);
- usblp->present = 0;
- wake_up(&usblp->wwait);
- wake_up(&usblp->rwait);
- usb_set_intfdata(intf, NULL);
-
- usblp_unlink_urbs(usblp);
- mutex_unlock(&usblp->mut);
-
- if (!usblp->used)
- usblp_cleanup(usblp);
- mutex_unlock(&usblp_mutex);
-}
-
-static int usblp_suspend(struct usb_interface *intf, pm_message_t message)
-{
- struct usblp *usblp = usb_get_intfdata(intf);
-
- usblp_unlink_urbs(usblp);
-#if 0 /* XXX Do we want this? What if someone is reading, should we fail? */
- /* not strictly necessary, but just in case */
- wake_up(&usblp->wwait);
- wake_up(&usblp->rwait);
-#endif
-
- return 0;
-}
-
-static int usblp_resume(struct usb_interface *intf)
-{
- struct usblp *usblp = usb_get_intfdata(intf);
- int r;
-
- r = handle_bidir(usblp);
-
- return r;
-}
-
-static const struct usb_device_id usblp_ids[] = {
- { USB_DEVICE_INFO(7, 1, 1) },
- { USB_DEVICE_INFO(7, 1, 2) },
- { USB_DEVICE_INFO(7, 1, 3) },
- { USB_INTERFACE_INFO(7, 1, 1) },
- { USB_INTERFACE_INFO(7, 1, 2) },
- { USB_INTERFACE_INFO(7, 1, 3) },
- { USB_DEVICE(0x04b8, 0x0202) }, /* Seiko Epson Receipt Printer M129C */
- { } /* Terminating entry */
-};
-
-MODULE_DEVICE_TABLE(usb, usblp_ids);
-
-static struct usb_driver usblp_driver = {
- .name = "usblp",
- .probe = usblp_probe,
- .disconnect = usblp_disconnect,
- .suspend = usblp_suspend,
- .resume = usblp_resume,
- .id_table = usblp_ids,
- .supports_autosuspend = 1,
-};
-
-module_usb_driver(usblp_driver);
-
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
-module_param(proto_bias, int, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(proto_bias, "Favourite protocol number");
-MODULE_LICENSE("GPL");
diff --git a/ANDROID_3.4.5/drivers/usb/class/usbtmc.c b/ANDROID_3.4.5/drivers/usb/class/usbtmc.c
deleted file mode 100644
index 70d69d06..00000000
--- a/ANDROID_3.4.5/drivers/usb/class/usbtmc.c
+++ /dev/null
@@ -1,1121 +0,0 @@
-/**
- * drivers/usb/class/usbtmc.c - USB Test & Measurement class driver
- *
- * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany
- * Copyright (C) 2008 Novell, Inc.
- * Copyright (C) 2008 Greg Kroah-Hartman
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * The GNU General Public License is available at
- * http://www.gnu.org/copyleft/gpl.html.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-
-#define USBTMC_MINOR_BASE 176
-
-/*
- * Size of driver internal IO buffer. Must be multiple of 4 and at least as
- * large as wMaxPacketSize (which is usually 512 bytes).
- */
-#define USBTMC_SIZE_IOBUFFER 2048
-
-/* Default USB timeout (in milliseconds) */
-#define USBTMC_TIMEOUT 5000
-
-/*
- * Maximum number of read cycles to empty bulk in endpoint during CLEAR and
- * ABORT_BULK_IN requests. Ends the loop if (for whatever reason) a short
- * packet is never read.
- */
-#define USBTMC_MAX_READS_TO_CLEAR_BULK_IN 100
-
-static const struct usb_device_id usbtmc_devices[] = {
- { USB_INTERFACE_INFO(USB_CLASS_APP_SPEC, 3, 0), },
- { USB_INTERFACE_INFO(USB_CLASS_APP_SPEC, 3, 1), },
- { 0, } /* terminating entry */
-};
-MODULE_DEVICE_TABLE(usb, usbtmc_devices);
-
-/*
- * This structure is the capabilities for the device
- * See section 4.2.1.8 of the USBTMC specification,
- * and section 4.2.2 of the USBTMC usb488 subclass
- * specification for details.
- */
-struct usbtmc_dev_capabilities {
- __u8 interface_capabilities;
- __u8 device_capabilities;
- __u8 usb488_interface_capabilities;
- __u8 usb488_device_capabilities;
-};
-
-/* This structure holds private data for each USBTMC device. One copy is
- * allocated for each USBTMC device in the driver's probe function.
- */
-struct usbtmc_device_data {
- const struct usb_device_id *id;
- struct usb_device *usb_dev;
- struct usb_interface *intf;
-
- unsigned int bulk_in;
- unsigned int bulk_out;
-
- u8 bTag;
- u8 bTag_last_write; /* needed for abort */
- u8 bTag_last_read; /* needed for abort */
-
- /* attributes from the USB TMC spec for this device */
- u8 TermChar;
- bool TermCharEnabled;
- bool auto_abort;
-
- bool zombie; /* fd of disconnected device */
-
- struct usbtmc_dev_capabilities capabilities;
- struct kref kref;
- struct mutex io_mutex; /* only one i/o function running at a time */
-};
-#define to_usbtmc_data(d) container_of(d, struct usbtmc_device_data, kref)
-
-/* Forward declarations */
-static struct usb_driver usbtmc_driver;
-
-static void usbtmc_delete(struct kref *kref)
-{
- struct usbtmc_device_data *data = to_usbtmc_data(kref);
-
- usb_put_dev(data->usb_dev);
- kfree(data);
-}
-
-static int usbtmc_open(struct inode *inode, struct file *filp)
-{
- struct usb_interface *intf;
- struct usbtmc_device_data *data;
- int retval = 0;
-
- intf = usb_find_interface(&usbtmc_driver, iminor(inode));
- if (!intf) {
- printk(KERN_ERR KBUILD_MODNAME
- ": can not find device for minor %d", iminor(inode));
- retval = -ENODEV;
- goto exit;
- }
-
- data = usb_get_intfdata(intf);
- kref_get(&data->kref);
-
- /* Store pointer in file structure's private data field */
- filp->private_data = data;
-
-exit:
- return retval;
-}
-
-static int usbtmc_release(struct inode *inode, struct file *file)
-{
- struct usbtmc_device_data *data = file->private_data;
-
- kref_put(&data->kref, usbtmc_delete);
- return 0;
-}
-
-static int usbtmc_ioctl_abort_bulk_in(struct usbtmc_device_data *data)
-{
- u8 *buffer;
- struct device *dev;
- int rv;
- int n;
- int actual;
- struct usb_host_interface *current_setting;
- int max_size;
-
- dev = &data->intf->dev;
- buffer = kmalloc(USBTMC_SIZE_IOBUFFER, GFP_KERNEL);
- if (!buffer)
- return -ENOMEM;
-
- rv = usb_control_msg(data->usb_dev,
- usb_rcvctrlpipe(data->usb_dev, 0),
- USBTMC_REQUEST_INITIATE_ABORT_BULK_IN,
- USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT,
- data->bTag_last_read, data->bulk_in,
- buffer, 2, USBTMC_TIMEOUT);
-
- if (rv < 0) {
- dev_err(dev, "usb_control_msg returned %d\n", rv);
- goto exit;
- }
-
- dev_dbg(dev, "INITIATE_ABORT_BULK_IN returned %x\n", buffer[0]);
-
- if (buffer[0] == USBTMC_STATUS_FAILED) {
- rv = 0;
- goto exit;
- }
-
- if (buffer[0] != USBTMC_STATUS_SUCCESS) {
- dev_err(dev, "INITIATE_ABORT_BULK_IN returned %x\n",
- buffer[0]);
- rv = -EPERM;
- goto exit;
- }
-
- max_size = 0;
- current_setting = data->intf->cur_altsetting;
- for (n = 0; n < current_setting->desc.bNumEndpoints; n++)
- if (current_setting->endpoint[n].desc.bEndpointAddress ==
- data->bulk_in)
- max_size = usb_endpoint_maxp(¤t_setting->endpoint[n].desc);
-
- if (max_size == 0) {
- dev_err(dev, "Couldn't get wMaxPacketSize\n");
- rv = -EPERM;
- goto exit;
- }
-
- dev_dbg(&data->intf->dev, "wMaxPacketSize is %d\n", max_size);
-
- n = 0;
-
- do {
- dev_dbg(dev, "Reading from bulk in EP\n");
-
- rv = usb_bulk_msg(data->usb_dev,
- usb_rcvbulkpipe(data->usb_dev,
- data->bulk_in),
- buffer, USBTMC_SIZE_IOBUFFER,
- &actual, USBTMC_TIMEOUT);
-
- n++;
-
- if (rv < 0) {
- dev_err(dev, "usb_bulk_msg returned %d\n", rv);
- goto exit;
- }
- } while ((actual == max_size) &&
- (n < USBTMC_MAX_READS_TO_CLEAR_BULK_IN));
-
- if (actual == max_size) {
- dev_err(dev, "Couldn't clear device buffer within %d cycles\n",
- USBTMC_MAX_READS_TO_CLEAR_BULK_IN);
- rv = -EPERM;
- goto exit;
- }
-
- n = 0;
-
-usbtmc_abort_bulk_in_status:
- rv = usb_control_msg(data->usb_dev,
- usb_rcvctrlpipe(data->usb_dev, 0),
- USBTMC_REQUEST_CHECK_ABORT_BULK_IN_STATUS,
- USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT,
- 0, data->bulk_in, buffer, 0x08,
- USBTMC_TIMEOUT);
-
- if (rv < 0) {
- dev_err(dev, "usb_control_msg returned %d\n", rv);
- goto exit;
- }
-
- dev_dbg(dev, "INITIATE_ABORT_BULK_IN returned %x\n", buffer[0]);
-
- if (buffer[0] == USBTMC_STATUS_SUCCESS) {
- rv = 0;
- goto exit;
- }
-
- if (buffer[0] != USBTMC_STATUS_PENDING) {
- dev_err(dev, "INITIATE_ABORT_BULK_IN returned %x\n", buffer[0]);
- rv = -EPERM;
- goto exit;
- }
-
- if (buffer[1] == 1)
- do {
- dev_dbg(dev, "Reading from bulk in EP\n");
-
- rv = usb_bulk_msg(data->usb_dev,
- usb_rcvbulkpipe(data->usb_dev,
- data->bulk_in),
- buffer, USBTMC_SIZE_IOBUFFER,
- &actual, USBTMC_TIMEOUT);
-
- n++;
-
- if (rv < 0) {
- dev_err(dev, "usb_bulk_msg returned %d\n", rv);
- goto exit;
- }
- } while ((actual == max_size) &&
- (n < USBTMC_MAX_READS_TO_CLEAR_BULK_IN));
-
- if (actual == max_size) {
- dev_err(dev, "Couldn't clear device buffer within %d cycles\n",
- USBTMC_MAX_READS_TO_CLEAR_BULK_IN);
- rv = -EPERM;
- goto exit;
- }
-
- goto usbtmc_abort_bulk_in_status;
-
-exit:
- kfree(buffer);
- return rv;
-
-}
-
-static int usbtmc_ioctl_abort_bulk_out(struct usbtmc_device_data *data)
-{
- struct device *dev;
- u8 *buffer;
- int rv;
- int n;
-
- dev = &data->intf->dev;
-
- buffer = kmalloc(8, GFP_KERNEL);
- if (!buffer)
- return -ENOMEM;
-
- rv = usb_control_msg(data->usb_dev,
- usb_rcvctrlpipe(data->usb_dev, 0),
- USBTMC_REQUEST_INITIATE_ABORT_BULK_OUT,
- USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT,
- data->bTag_last_write, data->bulk_out,
- buffer, 2, USBTMC_TIMEOUT);
-
- if (rv < 0) {
- dev_err(dev, "usb_control_msg returned %d\n", rv);
- goto exit;
- }
-
- dev_dbg(dev, "INITIATE_ABORT_BULK_OUT returned %x\n", buffer[0]);
-
- if (buffer[0] != USBTMC_STATUS_SUCCESS) {
- dev_err(dev, "INITIATE_ABORT_BULK_OUT returned %x\n",
- buffer[0]);
- rv = -EPERM;
- goto exit;
- }
-
- n = 0;
-
-usbtmc_abort_bulk_out_check_status:
- rv = usb_control_msg(data->usb_dev,
- usb_rcvctrlpipe(data->usb_dev, 0),
- USBTMC_REQUEST_CHECK_ABORT_BULK_OUT_STATUS,
- USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT,
- 0, data->bulk_out, buffer, 0x08,
- USBTMC_TIMEOUT);
- n++;
- if (rv < 0) {
- dev_err(dev, "usb_control_msg returned %d\n", rv);
- goto exit;
- }
-
- dev_dbg(dev, "CHECK_ABORT_BULK_OUT returned %x\n", buffer[0]);
-
- if (buffer[0] == USBTMC_STATUS_SUCCESS)
- goto usbtmc_abort_bulk_out_clear_halt;
-
- if ((buffer[0] == USBTMC_STATUS_PENDING) &&
- (n < USBTMC_MAX_READS_TO_CLEAR_BULK_IN))
- goto usbtmc_abort_bulk_out_check_status;
-
- rv = -EPERM;
- goto exit;
-
-usbtmc_abort_bulk_out_clear_halt:
- rv = usb_clear_halt(data->usb_dev,
- usb_sndbulkpipe(data->usb_dev, data->bulk_out));
-
- if (rv < 0) {
- dev_err(dev, "usb_control_msg returned %d\n", rv);
- goto exit;
- }
- rv = 0;
-
-exit:
- kfree(buffer);
- return rv;
-}
-
-static ssize_t usbtmc_read(struct file *filp, char __user *buf,
- size_t count, loff_t *f_pos)
-{
- struct usbtmc_device_data *data;
- struct device *dev;
- u32 n_characters;
- u8 *buffer;
- int actual;
- size_t done;
- size_t remaining;
- int retval;
- size_t this_part;
-
- /* Get pointer to private data structure */
- data = filp->private_data;
- dev = &data->intf->dev;
-
- buffer = kmalloc(USBTMC_SIZE_IOBUFFER, GFP_KERNEL);
- if (!buffer)
- return -ENOMEM;
-
- mutex_lock(&data->io_mutex);
- if (data->zombie) {
- retval = -ENODEV;
- goto exit;
- }
-
- remaining = count;
- done = 0;
-
- while (remaining > 0) {
- if (remaining > USBTMC_SIZE_IOBUFFER - 12 - 3)
- this_part = USBTMC_SIZE_IOBUFFER - 12 - 3;
- else
- this_part = remaining;
-
- /* Setup IO buffer for DEV_DEP_MSG_IN message
- * Refer to class specs for details
- */
- buffer[0] = 2;
- buffer[1] = data->bTag;
- buffer[2] = ~(data->bTag);
- buffer[3] = 0; /* Reserved */
- buffer[4] = (this_part) & 255;
- buffer[5] = ((this_part) >> 8) & 255;
- buffer[6] = ((this_part) >> 16) & 255;
- buffer[7] = ((this_part) >> 24) & 255;
- buffer[8] = data->TermCharEnabled * 2;
- /* Use term character? */
- buffer[9] = data->TermChar;
- buffer[10] = 0; /* Reserved */
- buffer[11] = 0; /* Reserved */
-
- /* Send bulk URB */
- retval = usb_bulk_msg(data->usb_dev,
- usb_sndbulkpipe(data->usb_dev,
- data->bulk_out),
- buffer, 12, &actual, USBTMC_TIMEOUT);
-
- /* Store bTag (in case we need to abort) */
- data->bTag_last_write = data->bTag;
-
- /* Increment bTag -- and increment again if zero */
- data->bTag++;
- if (!data->bTag)
- (data->bTag)++;
-
- if (retval < 0) {
- dev_err(dev, "usb_bulk_msg returned %d\n", retval);
- if (data->auto_abort)
- usbtmc_ioctl_abort_bulk_out(data);
- goto exit;
- }
-
- /* Send bulk URB */
- retval = usb_bulk_msg(data->usb_dev,
- usb_rcvbulkpipe(data->usb_dev,
- data->bulk_in),
- buffer, USBTMC_SIZE_IOBUFFER, &actual,
- USBTMC_TIMEOUT);
-
- /* Store bTag (in case we need to abort) */
- data->bTag_last_read = data->bTag;
-
- if (retval < 0) {
- dev_err(dev, "Unable to read data, error %d\n", retval);
- if (data->auto_abort)
- usbtmc_ioctl_abort_bulk_in(data);
- goto exit;
- }
-
- /* How many characters did the instrument send? */
- n_characters = buffer[4] +
- (buffer[5] << 8) +
- (buffer[6] << 16) +
- (buffer[7] << 24);
-
- /* Ensure the instrument doesn't lie about it */
- if(n_characters > actual - 12) {
- dev_err(dev, "Device lies about message size: %u > %d\n", n_characters, actual - 12);
- n_characters = actual - 12;
- }
-
- /* Ensure the instrument doesn't send more back than requested */
- if(n_characters > this_part) {
- dev_err(dev, "Device returns more than requested: %zu > %zu\n", done + n_characters, done + this_part);
- n_characters = this_part;
- }
-
- /* Bound amount of data received by amount of data requested */
- if (n_characters > this_part)
- n_characters = this_part;
-
- /* Copy buffer to user space */
- if (copy_to_user(buf + done, &buffer[12], n_characters)) {
- /* There must have been an addressing problem */
- retval = -EFAULT;
- goto exit;
- }
-
- done += n_characters;
- /* Terminate if end-of-message bit received from device */
- if ((buffer[8] & 0x01) && (actual >= n_characters + 12))
- remaining = 0;
- else
- remaining -= n_characters;
- }
-
- /* Update file position value */
- *f_pos = *f_pos + done;
- retval = done;
-
-exit:
- mutex_unlock(&data->io_mutex);
- kfree(buffer);
- return retval;
-}
-
-static ssize_t usbtmc_write(struct file *filp, const char __user *buf,
- size_t count, loff_t *f_pos)
-{
- struct usbtmc_device_data *data;
- u8 *buffer;
- int retval;
- int actual;
- unsigned long int n_bytes;
- int remaining;
- int done;
- int this_part;
-
- data = filp->private_data;
-
- buffer = kmalloc(USBTMC_SIZE_IOBUFFER, GFP_KERNEL);
- if (!buffer)
- return -ENOMEM;
-
- mutex_lock(&data->io_mutex);
- if (data->zombie) {
- retval = -ENODEV;
- goto exit;
- }
-
- remaining = count;
- done = 0;
-
- while (remaining > 0) {
- if (remaining > USBTMC_SIZE_IOBUFFER - 12) {
- this_part = USBTMC_SIZE_IOBUFFER - 12;
- buffer[8] = 0;
- } else {
- this_part = remaining;
- buffer[8] = 1;
- }
-
- /* Setup IO buffer for DEV_DEP_MSG_OUT message */
- buffer[0] = 1;
- buffer[1] = data->bTag;
- buffer[2] = ~(data->bTag);
- buffer[3] = 0; /* Reserved */
- buffer[4] = this_part & 255;
- buffer[5] = (this_part >> 8) & 255;
- buffer[6] = (this_part >> 16) & 255;
- buffer[7] = (this_part >> 24) & 255;
- /* buffer[8] is set above... */
- buffer[9] = 0; /* Reserved */
- buffer[10] = 0; /* Reserved */
- buffer[11] = 0; /* Reserved */
-
- if (copy_from_user(&buffer[12], buf + done, this_part)) {
- retval = -EFAULT;
- goto exit;
- }
-
- n_bytes = roundup(12 + this_part, 4);
- memset(buffer + 12 + this_part, 0, n_bytes - (12 + this_part));
-
- do {
- retval = usb_bulk_msg(data->usb_dev,
- usb_sndbulkpipe(data->usb_dev,
- data->bulk_out),
- buffer, n_bytes,
- &actual, USBTMC_TIMEOUT);
- if (retval != 0)
- break;
- n_bytes -= actual;
- } while (n_bytes);
-
- data->bTag_last_write = data->bTag;
- data->bTag++;
-
- if (!data->bTag)
- data->bTag++;
-
- if (retval < 0) {
- dev_err(&data->intf->dev,
- "Unable to send data, error %d\n", retval);
- if (data->auto_abort)
- usbtmc_ioctl_abort_bulk_out(data);
- goto exit;
- }
-
- remaining -= this_part;
- done += this_part;
- }
-
- retval = count;
-exit:
- mutex_unlock(&data->io_mutex);
- kfree(buffer);
- return retval;
-}
-
-static int usbtmc_ioctl_clear(struct usbtmc_device_data *data)
-{
- struct usb_host_interface *current_setting;
- struct usb_endpoint_descriptor *desc;
- struct device *dev;
- u8 *buffer;
- int rv;
- int n;
- int actual;
- int max_size;
-
- dev = &data->intf->dev;
-
- dev_dbg(dev, "Sending INITIATE_CLEAR request\n");
-
- buffer = kmalloc(USBTMC_SIZE_IOBUFFER, GFP_KERNEL);
- if (!buffer)
- return -ENOMEM;
-
- rv = usb_control_msg(data->usb_dev,
- usb_rcvctrlpipe(data->usb_dev, 0),
- USBTMC_REQUEST_INITIATE_CLEAR,
- USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
- 0, 0, buffer, 1, USBTMC_TIMEOUT);
- if (rv < 0) {
- dev_err(dev, "usb_control_msg returned %d\n", rv);
- goto exit;
- }
-
- dev_dbg(dev, "INITIATE_CLEAR returned %x\n", buffer[0]);
-
- if (buffer[0] != USBTMC_STATUS_SUCCESS) {
- dev_err(dev, "INITIATE_CLEAR returned %x\n", buffer[0]);
- rv = -EPERM;
- goto exit;
- }
-
- max_size = 0;
- current_setting = data->intf->cur_altsetting;
- for (n = 0; n < current_setting->desc.bNumEndpoints; n++) {
- desc = ¤t_setting->endpoint[n].desc;
- if (desc->bEndpointAddress == data->bulk_in)
- max_size = usb_endpoint_maxp(desc);
- }
-
- if (max_size == 0) {
- dev_err(dev, "Couldn't get wMaxPacketSize\n");
- rv = -EPERM;
- goto exit;
- }
-
- dev_dbg(dev, "wMaxPacketSize is %d\n", max_size);
-
- n = 0;
-
-usbtmc_clear_check_status:
-
- dev_dbg(dev, "Sending CHECK_CLEAR_STATUS request\n");
-
- rv = usb_control_msg(data->usb_dev,
- usb_rcvctrlpipe(data->usb_dev, 0),
- USBTMC_REQUEST_CHECK_CLEAR_STATUS,
- USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
- 0, 0, buffer, 2, USBTMC_TIMEOUT);
- if (rv < 0) {
- dev_err(dev, "usb_control_msg returned %d\n", rv);
- goto exit;
- }
-
- dev_dbg(dev, "CHECK_CLEAR_STATUS returned %x\n", buffer[0]);
-
- if (buffer[0] == USBTMC_STATUS_SUCCESS)
- goto usbtmc_clear_bulk_out_halt;
-
- if (buffer[0] != USBTMC_STATUS_PENDING) {
- dev_err(dev, "CHECK_CLEAR_STATUS returned %x\n", buffer[0]);
- rv = -EPERM;
- goto exit;
- }
-
- if (buffer[1] == 1)
- do {
- dev_dbg(dev, "Reading from bulk in EP\n");
-
- rv = usb_bulk_msg(data->usb_dev,
- usb_rcvbulkpipe(data->usb_dev,
- data->bulk_in),
- buffer, USBTMC_SIZE_IOBUFFER,
- &actual, USBTMC_TIMEOUT);
- n++;
-
- if (rv < 0) {
- dev_err(dev, "usb_control_msg returned %d\n",
- rv);
- goto exit;
- }
- } while ((actual == max_size) &&
- (n < USBTMC_MAX_READS_TO_CLEAR_BULK_IN));
-
- if (actual == max_size) {
- dev_err(dev, "Couldn't clear device buffer within %d cycles\n",
- USBTMC_MAX_READS_TO_CLEAR_BULK_IN);
- rv = -EPERM;
- goto exit;
- }
-
- goto usbtmc_clear_check_status;
-
-usbtmc_clear_bulk_out_halt:
-
- rv = usb_clear_halt(data->usb_dev,
- usb_sndbulkpipe(data->usb_dev, data->bulk_out));
- if (rv < 0) {
- dev_err(dev, "usb_control_msg returned %d\n", rv);
- goto exit;
- }
- rv = 0;
-
-exit:
- kfree(buffer);
- return rv;
-}
-
-static int usbtmc_ioctl_clear_out_halt(struct usbtmc_device_data *data)
-{
- u8 *buffer;
- int rv;
-
- buffer = kmalloc(2, GFP_KERNEL);
- if (!buffer)
- return -ENOMEM;
-
- rv = usb_clear_halt(data->usb_dev,
- usb_sndbulkpipe(data->usb_dev, data->bulk_out));
-
- if (rv < 0) {
- dev_err(&data->usb_dev->dev, "usb_control_msg returned %d\n",
- rv);
- goto exit;
- }
- rv = 0;
-
-exit:
- kfree(buffer);
- return rv;
-}
-
-static int usbtmc_ioctl_clear_in_halt(struct usbtmc_device_data *data)
-{
- u8 *buffer;
- int rv;
-
- buffer = kmalloc(2, GFP_KERNEL);
- if (!buffer)
- return -ENOMEM;
-
- rv = usb_clear_halt(data->usb_dev,
- usb_rcvbulkpipe(data->usb_dev, data->bulk_in));
-
- if (rv < 0) {
- dev_err(&data->usb_dev->dev, "usb_control_msg returned %d\n",
- rv);
- goto exit;
- }
- rv = 0;
-
-exit:
- kfree(buffer);
- return rv;
-}
-
-static int get_capabilities(struct usbtmc_device_data *data)
-{
- struct device *dev = &data->usb_dev->dev;
- char *buffer;
- int rv = 0;
-
- buffer = kmalloc(0x18, GFP_KERNEL);
- if (!buffer)
- return -ENOMEM;
-
- rv = usb_control_msg(data->usb_dev, usb_rcvctrlpipe(data->usb_dev, 0),
- USBTMC_REQUEST_GET_CAPABILITIES,
- USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
- 0, 0, buffer, 0x18, USBTMC_TIMEOUT);
- if (rv < 0) {
- dev_err(dev, "usb_control_msg returned %d\n", rv);
- goto err_out;
- }
-
- dev_dbg(dev, "GET_CAPABILITIES returned %x\n", buffer[0]);
- if (buffer[0] != USBTMC_STATUS_SUCCESS) {
- dev_err(dev, "GET_CAPABILITIES returned %x\n", buffer[0]);
- rv = -EPERM;
- goto err_out;
- }
- dev_dbg(dev, "Interface capabilities are %x\n", buffer[4]);
- dev_dbg(dev, "Device capabilities are %x\n", buffer[5]);
- dev_dbg(dev, "USB488 interface capabilities are %x\n", buffer[14]);
- dev_dbg(dev, "USB488 device capabilities are %x\n", buffer[15]);
-
- data->capabilities.interface_capabilities = buffer[4];
- data->capabilities.device_capabilities = buffer[5];
- data->capabilities.usb488_interface_capabilities = buffer[14];
- data->capabilities.usb488_device_capabilities = buffer[15];
- rv = 0;
-
-err_out:
- kfree(buffer);
- return rv;
-}
-
-#define capability_attribute(name) \
-static ssize_t show_##name(struct device *dev, \
- struct device_attribute *attr, char *buf) \
-{ \
- struct usb_interface *intf = to_usb_interface(dev); \
- struct usbtmc_device_data *data = usb_get_intfdata(intf); \
- \
- return sprintf(buf, "%d\n", data->capabilities.name); \
-} \
-static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
-
-capability_attribute(interface_capabilities);
-capability_attribute(device_capabilities);
-capability_attribute(usb488_interface_capabilities);
-capability_attribute(usb488_device_capabilities);
-
-static struct attribute *capability_attrs[] = {
- &dev_attr_interface_capabilities.attr,
- &dev_attr_device_capabilities.attr,
- &dev_attr_usb488_interface_capabilities.attr,
- &dev_attr_usb488_device_capabilities.attr,
- NULL,
-};
-
-static struct attribute_group capability_attr_grp = {
- .attrs = capability_attrs,
-};
-
-static ssize_t show_TermChar(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct usb_interface *intf = to_usb_interface(dev);
- struct usbtmc_device_data *data = usb_get_intfdata(intf);
-
- return sprintf(buf, "%c\n", data->TermChar);
-}
-
-static ssize_t store_TermChar(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct usb_interface *intf = to_usb_interface(dev);
- struct usbtmc_device_data *data = usb_get_intfdata(intf);
-
- if (count < 1)
- return -EINVAL;
- data->TermChar = buf[0];
- return count;
-}
-static DEVICE_ATTR(TermChar, S_IRUGO, show_TermChar, store_TermChar);
-
-#define data_attribute(name) \
-static ssize_t show_##name(struct device *dev, \
- struct device_attribute *attr, char *buf) \
-{ \
- struct usb_interface *intf = to_usb_interface(dev); \
- struct usbtmc_device_data *data = usb_get_intfdata(intf); \
- \
- return sprintf(buf, "%d\n", data->name); \
-} \
-static ssize_t store_##name(struct device *dev, \
- struct device_attribute *attr, \
- const char *buf, size_t count) \
-{ \
- struct usb_interface *intf = to_usb_interface(dev); \
- struct usbtmc_device_data *data = usb_get_intfdata(intf); \
- ssize_t result; \
- unsigned val; \
- \
- result = sscanf(buf, "%u\n", &val); \
- if (result != 1) \
- result = -EINVAL; \
- data->name = val; \
- if (result < 0) \
- return result; \
- else \
- return count; \
-} \
-static DEVICE_ATTR(name, S_IRUGO, show_##name, store_##name)
-
-data_attribute(TermCharEnabled);
-data_attribute(auto_abort);
-
-static struct attribute *data_attrs[] = {
- &dev_attr_TermChar.attr,
- &dev_attr_TermCharEnabled.attr,
- &dev_attr_auto_abort.attr,
- NULL,
-};
-
-static struct attribute_group data_attr_grp = {
- .attrs = data_attrs,
-};
-
-static int usbtmc_ioctl_indicator_pulse(struct usbtmc_device_data *data)
-{
- struct device *dev;
- u8 *buffer;
- int rv;
-
- dev = &data->intf->dev;
-
- buffer = kmalloc(2, GFP_KERNEL);
- if (!buffer)
- return -ENOMEM;
-
- rv = usb_control_msg(data->usb_dev,
- usb_rcvctrlpipe(data->usb_dev, 0),
- USBTMC_REQUEST_INDICATOR_PULSE,
- USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
- 0, 0, buffer, 0x01, USBTMC_TIMEOUT);
-
- if (rv < 0) {
- dev_err(dev, "usb_control_msg returned %d\n", rv);
- goto exit;
- }
-
- dev_dbg(dev, "INDICATOR_PULSE returned %x\n", buffer[0]);
-
- if (buffer[0] != USBTMC_STATUS_SUCCESS) {
- dev_err(dev, "INDICATOR_PULSE returned %x\n", buffer[0]);
- rv = -EPERM;
- goto exit;
- }
- rv = 0;
-
-exit:
- kfree(buffer);
- return rv;
-}
-
-static long usbtmc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
- struct usbtmc_device_data *data;
- int retval = -EBADRQC;
-
- data = file->private_data;
- mutex_lock(&data->io_mutex);
- if (data->zombie) {
- retval = -ENODEV;
- goto skip_io_on_zombie;
- }
-
- switch (cmd) {
- case USBTMC_IOCTL_CLEAR_OUT_HALT:
- retval = usbtmc_ioctl_clear_out_halt(data);
- break;
-
- case USBTMC_IOCTL_CLEAR_IN_HALT:
- retval = usbtmc_ioctl_clear_in_halt(data);
- break;
-
- case USBTMC_IOCTL_INDICATOR_PULSE:
- retval = usbtmc_ioctl_indicator_pulse(data);
- break;
-
- case USBTMC_IOCTL_CLEAR:
- retval = usbtmc_ioctl_clear(data);
- break;
-
- case USBTMC_IOCTL_ABORT_BULK_OUT:
- retval = usbtmc_ioctl_abort_bulk_out(data);
- break;
-
- case USBTMC_IOCTL_ABORT_BULK_IN:
- retval = usbtmc_ioctl_abort_bulk_in(data);
- break;
- }
-
-skip_io_on_zombie:
- mutex_unlock(&data->io_mutex);
- return retval;
-}
-
-static const struct file_operations fops = {
- .owner = THIS_MODULE,
- .read = usbtmc_read,
- .write = usbtmc_write,
- .open = usbtmc_open,
- .release = usbtmc_release,
- .unlocked_ioctl = usbtmc_ioctl,
- .llseek = default_llseek,
-};
-
-static struct usb_class_driver usbtmc_class = {
- .name = "usbtmc%d",
- .fops = &fops,
- .minor_base = USBTMC_MINOR_BASE,
-};
-
-
-static int usbtmc_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- struct usbtmc_device_data *data;
- struct usb_host_interface *iface_desc;
- struct usb_endpoint_descriptor *endpoint;
- int n;
- int retcode;
-
- dev_dbg(&intf->dev, "%s called\n", __func__);
-
- data = kmalloc(sizeof(struct usbtmc_device_data), GFP_KERNEL);
- if (!data) {
- dev_err(&intf->dev, "Unable to allocate kernel memory\n");
- return -ENOMEM;
- }
-
- data->intf = intf;
- data->id = id;
- data->usb_dev = usb_get_dev(interface_to_usbdev(intf));
- usb_set_intfdata(intf, data);
- kref_init(&data->kref);
- mutex_init(&data->io_mutex);
- data->zombie = 0;
-
- /* Initialize USBTMC bTag and other fields */
- data->bTag = 1;
- data->TermCharEnabled = 0;
- data->TermChar = '\n';
-
- /* USBTMC devices have only one setting, so use that */
- iface_desc = data->intf->cur_altsetting;
-
- /* Find bulk in endpoint */
- for (n = 0; n < iface_desc->desc.bNumEndpoints; n++) {
- endpoint = &iface_desc->endpoint[n].desc;
-
- if (usb_endpoint_is_bulk_in(endpoint)) {
- data->bulk_in = endpoint->bEndpointAddress;
- dev_dbg(&intf->dev, "Found bulk in endpoint at %u\n",
- data->bulk_in);
- break;
- }
- }
-
- /* Find bulk out endpoint */
- for (n = 0; n < iface_desc->desc.bNumEndpoints; n++) {
- endpoint = &iface_desc->endpoint[n].desc;
-
- if (usb_endpoint_is_bulk_out(endpoint)) {
- data->bulk_out = endpoint->bEndpointAddress;
- dev_dbg(&intf->dev, "Found Bulk out endpoint at %u\n",
- data->bulk_out);
- break;
- }
- }
-
- retcode = get_capabilities(data);
- if (retcode)
- dev_err(&intf->dev, "can't read capabilities\n");
- else
- retcode = sysfs_create_group(&intf->dev.kobj,
- &capability_attr_grp);
-
- retcode = sysfs_create_group(&intf->dev.kobj, &data_attr_grp);
-
- retcode = usb_register_dev(intf, &usbtmc_class);
- if (retcode) {
- dev_err(&intf->dev, "Not able to get a minor"
- " (base %u, slice default): %d\n", USBTMC_MINOR_BASE,
- retcode);
- goto error_register;
- }
- dev_dbg(&intf->dev, "Using minor number %d\n", intf->minor);
-
- return 0;
-
-error_register:
- sysfs_remove_group(&intf->dev.kobj, &capability_attr_grp);
- sysfs_remove_group(&intf->dev.kobj, &data_attr_grp);
- kref_put(&data->kref, usbtmc_delete);
- return retcode;
-}
-
-static void usbtmc_disconnect(struct usb_interface *intf)
-{
- struct usbtmc_device_data *data;
-
- dev_dbg(&intf->dev, "usbtmc_disconnect called\n");
-
- data = usb_get_intfdata(intf);
- usb_deregister_dev(intf, &usbtmc_class);
- sysfs_remove_group(&intf->dev.kobj, &capability_attr_grp);
- sysfs_remove_group(&intf->dev.kobj, &data_attr_grp);
- mutex_lock(&data->io_mutex);
- data->zombie = 1;
- mutex_unlock(&data->io_mutex);
- kref_put(&data->kref, usbtmc_delete);
-}
-
-static int usbtmc_suspend(struct usb_interface *intf, pm_message_t message)
-{
- /* this driver does not have pending URBs */
- return 0;
-}
-
-static int usbtmc_resume(struct usb_interface *intf)
-{
- return 0;
-}
-
-static struct usb_driver usbtmc_driver = {
- .name = "usbtmc",
- .id_table = usbtmc_devices,
- .probe = usbtmc_probe,
- .disconnect = usbtmc_disconnect,
- .suspend = usbtmc_suspend,
- .resume = usbtmc_resume,
-};
-
-module_usb_driver(usbtmc_driver);
-
-MODULE_LICENSE("GPL");
diff --git a/ANDROID_3.4.5/drivers/usb/core/Kconfig b/ANDROID_3.4.5/drivers/usb/core/Kconfig
deleted file mode 100644
index 18d02e32..00000000
--- a/ANDROID_3.4.5/drivers/usb/core/Kconfig
+++ /dev/null
@@ -1,150 +0,0 @@
-#
-# USB Core configuration
-#
-config USB_DEBUG
- bool "USB verbose debug messages"
- depends on USB
- help
- Say Y here if you want the USB core & hub drivers to produce a bunch
- of debug messages to the system log. Select this if you are having a
- problem with USB support and want to see more of what is going on.
-
-config USB_ANNOUNCE_NEW_DEVICES
- bool "USB announce new devices"
- depends on USB
- default N
- help
- Say Y here if you want the USB core to always announce the
- idVendor, idProduct, Manufacturer, Product, and SerialNumber
- strings for every new USB device to the syslog. This option is
- usually used by distro vendors to help with debugging and to
- let users know what specific device was added to the machine
- in what location.
-
- If you do not want this kind of information sent to the system
- log, or have any doubts about this, say N here.
-
-comment "Miscellaneous USB options"
- depends on USB
-
-config USB_DEVICEFS
- bool "USB device filesystem (DEPRECATED)"
- depends on USB
- ---help---
- If you say Y here (and to "/proc file system support" in the "File
- systems" section, above), you will get a file /proc/bus/usb/devices
- which lists the devices currently connected to your USB bus or
- busses, and for every connected device a file named
- "/proc/bus/usb/xxx/yyy", where xxx is the bus number and yyy the
- device number; the latter files can be used by user space programs
- to talk directly to the device. These files are "virtual", meaning
- they are generated on the fly and not stored on the hard drive.
-
- You may need to mount the usbfs file system to see the files, use
- mount -t usbfs none /proc/bus/usb
-
- For the format of the various /proc/bus/usb/ files, please read
- .
-
- Modern Linux systems do not use this.
-
- Usbfs entries are files and not character devices; usbfs can't
- handle Access Control Lists (ACL) which are the default way to
- grant access to USB devices for untrusted users of a desktop
- system.
-
- The usbfs functionality is replaced by real device-nodes managed by
- udev. These nodes lived in /dev/bus/usb and are used by libusb.
-
-config USB_DEVICE_CLASS
- bool "USB device class-devices (DEPRECATED)"
- depends on USB
- default y
- ---help---
- Userspace access to USB devices is granted by device-nodes exported
- directly from the usbdev in sysfs. Old versions of the driver
- core and udev needed additional class devices to export device nodes.
-
- These additional devices are difficult to handle in userspace, if
- information about USB interfaces must be available. One device
- contains the device node, the other device contains the interface
- data. Both devices are at the same level in sysfs (siblings) and one
- can't access the other. The device node created directly by the
- usb device is the parent device of the interface and therefore
- easily accessible from the interface event.
-
- This option provides backward compatibility for libusb device
- nodes (lsusb) when usbfs is not used, and the following udev rule
- doesn't exist:
- SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", \
- NAME="bus/usb/$env{BUSNUM}/$env{DEVNUM}", MODE="0644"
-
-config USB_DYNAMIC_MINORS
- bool "Dynamic USB minor allocation"
- depends on USB
- help
- If you say Y here, the USB subsystem will use dynamic minor
- allocation for any device that uses the USB major number.
- This means that you can have more than 16 of a single type
- of device (like USB printers).
-
- If you are unsure about this, say N here.
-
-config USB_SUSPEND
- bool "USB runtime power management (autosuspend) and wakeup"
- depends on USB && PM_RUNTIME
- help
- If you say Y here, you can use driver calls or the sysfs
- "power/control" file to enable or disable autosuspend for
- individual USB peripherals (see
- Documentation/usb/power-management.txt for more details).
-
- Also, USB "remote wakeup" signaling is supported, whereby some
- USB devices (like keyboards and network adapters) can wake up
- their parent hub. That wakeup cascades up the USB tree, and
- could wake the system from states like suspend-to-RAM.
-
- If you are unsure about this, say N here.
-
-config USB_OTG
- bool "OTG support"
- depends on USB && EXPERIMENTAL
- depends on USB_SUSPEND
- default n
- help
- The most notable feature of USB OTG is support for a
- "Dual-Role" device, which can act as either a device
- or a host. The initial role is decided by the type of
- plug inserted and can be changed later when two dual
- role devices talk to each other.
-
- Select this only if your board has Mini-AB/Micro-AB
- connector.
-
-config USB_OTG_WHITELIST
- bool "Rely on OTG Targeted Peripherals List"
- depends on USB_OTG || EXPERT
- default y if USB_OTG
- default n if EXPERT
- help
- If you say Y here, the "otg_whitelist.h" file will be used as a
- product whitelist, so USB peripherals not listed there will be
- rejected during enumeration. This behavior is required by the
- USB OTG specification for all devices not on your product's
- "Targeted Peripherals List". "Embedded Hosts" are likewise
- allowed to support only a limited number of peripherals.
-
- Otherwise, peripherals not listed there will only generate a
- warning and enumeration will continue. That's more like what
- normal Linux-USB hosts do (other than the warning), and is
- convenient for many stages of product development.
-
-config USB_OTG_BLACKLIST_HUB
- bool "Disable external hubs"
- depends on USB_OTG || EXPERT
- help
- If you say Y here, then Linux will refuse to enumerate
- external hubs. OTG hosts are allowed to reduce hardware
- and software costs by not supporting external hubs. So
- are "Embedded Hosts" that don't offer OTG support.
-
diff --git a/ANDROID_3.4.5/drivers/usb/core/Makefile b/ANDROID_3.4.5/drivers/usb/core/Makefile
deleted file mode 100644
index 507a4e1b..00000000
--- a/ANDROID_3.4.5/drivers/usb/core/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# Makefile for USB Core files and filesystem
-#
-
-ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
-
-usbcore-y := usb.o hub.o hcd.o urb.o message.o driver.o
-usbcore-y += config.o file.o buffer.o sysfs.o endpoint.o
-usbcore-y += devio.o notify.o generic.o quirks.o devices.o
-
-usbcore-$(CONFIG_PCI) += hcd-pci.o
-usbcore-$(CONFIG_USB_DEVICEFS) += inode.o
-
-obj-$(CONFIG_USB) += usbcore.o
diff --git a/ANDROID_3.4.5/drivers/usb/core/buffer.c b/ANDROID_3.4.5/drivers/usb/core/buffer.c
deleted file mode 100644
index b0585e62..00000000
--- a/ANDROID_3.4.5/drivers/usb/core/buffer.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * DMA memory management for framework level HCD code (hc_driver)
- *
- * This implementation plugs in through generic "usb_bus" level methods,
- * and should work with all USB controllers, regardles of bus type.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-
-/*
- * DMA-Coherent Buffers
- */
-
-/* FIXME tune these based on pool statistics ... */
-static const size_t pool_max[HCD_BUFFER_POOLS] = {
- /* platforms without dma-friendly caches might need to
- * prevent cacheline sharing...
- */
- 32,
- 128,
- 512,
- PAGE_SIZE / 2
- /* bigger --> allocate pages */
-};
-
-
-/* SETUP primitives */
-
-/**
- * hcd_buffer_create - initialize buffer pools
- * @hcd: the bus whose buffer pools are to be initialized
- * Context: !in_interrupt()
- *
- * Call this as part of initializing a host controller that uses the dma
- * memory allocators. It initializes some pools of dma-coherent memory that
- * will be shared by all drivers using that controller, or returns a negative
- * errno value on error.
- *
- * Call hcd_buffer_destroy() to clean up after using those pools.
- */
-int hcd_buffer_create(struct usb_hcd *hcd)
-{
- char name[16];
- int i, size;
-
- if (!hcd->self.controller->dma_mask &&
- !(hcd->driver->flags & HCD_LOCAL_MEM))
- return 0;
-
- for (i = 0; i < HCD_BUFFER_POOLS; i++) {
- size = pool_max[i];
- if (!size)
- continue;
- snprintf(name, sizeof name, "buffer-%d", size);
- hcd->pool[i] = dma_pool_create(name, hcd->self.controller,
- size, size, 0);
- if (!hcd->pool[i]) {
- hcd_buffer_destroy(hcd);
- return -ENOMEM;
- }
- }
- return 0;
-}
-
-
-/**
- * hcd_buffer_destroy - deallocate buffer pools
- * @hcd: the bus whose buffer pools are to be destroyed
- * Context: !in_interrupt()
- *
- * This frees the buffer pools created by hcd_buffer_create().
- */
-void hcd_buffer_destroy(struct usb_hcd *hcd)
-{
- int i;
-
- for (i = 0; i < HCD_BUFFER_POOLS; i++) {
- struct dma_pool *pool = hcd->pool[i];
- if (pool) {
- dma_pool_destroy(pool);
- hcd->pool[i] = NULL;
- }
- }
-}
-
-
-/* sometimes alloc/free could use kmalloc with GFP_DMA, for
- * better sharing and to leverage mm/slab.c intelligence.
- */
-
-void *hcd_buffer_alloc(
- struct usb_bus *bus,
- size_t size,
- gfp_t mem_flags,
- dma_addr_t *dma
-)
-{
- struct usb_hcd *hcd = bus_to_hcd(bus);
- int i;
-
- /* some USB hosts just use PIO */
- if (!bus->controller->dma_mask &&
- !(hcd->driver->flags & HCD_LOCAL_MEM)) {
- *dma = ~(dma_addr_t) 0;
- return kmalloc(size, mem_flags);
- }
-
- for (i = 0; i < HCD_BUFFER_POOLS; i++) {
- if (size <= pool_max[i])
- return dma_pool_alloc(hcd->pool[i], mem_flags, dma);
- }
- return dma_alloc_coherent(hcd->self.controller, size, dma, mem_flags);
-}
-
-void hcd_buffer_free(
- struct usb_bus *bus,
- size_t size,
- void *addr,
- dma_addr_t dma
-)
-{
- struct usb_hcd *hcd = bus_to_hcd(bus);
- int i;
-
- if (!addr)
- return;
-
- if (!bus->controller->dma_mask &&
- !(hcd->driver->flags & HCD_LOCAL_MEM)) {
- kfree(addr);
- return;
- }
-
- for (i = 0; i < HCD_BUFFER_POOLS; i++) {
- if (size <= pool_max[i]) {
- dma_pool_free(hcd->pool[i], addr, dma);
- return;
- }
- }
- dma_free_coherent(hcd->self.controller, size, addr, dma);
-}
diff --git a/ANDROID_3.4.5/drivers/usb/core/config.c b/ANDROID_3.4.5/drivers/usb/core/config.c
deleted file mode 100644
index f4bdd0ce..00000000
--- a/ANDROID_3.4.5/drivers/usb/core/config.c
+++ /dev/null
@@ -1,860 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "usb.h"
-
-
-#define USB_MAXALTSETTING 128 /* Hard limit */
-#define USB_MAXENDPOINTS 30 /* Hard limit */
-
-#define USB_MAXCONFIG 8 /* Arbitrary limit */
-
-
-static inline const char *plural(int n)
-{
- return (n == 1 ? "" : "s");
-}
-
-static int find_next_descriptor(unsigned char *buffer, int size,
- int dt1, int dt2, int *num_skipped)
-{
- struct usb_descriptor_header *h;
- int n = 0;
- unsigned char *buffer0 = buffer;
-
- /* Find the next descriptor of type dt1 or dt2 */
- while (size > 0) {
- h = (struct usb_descriptor_header *) buffer;
- if (h->bDescriptorType == dt1 || h->bDescriptorType == dt2)
- break;
- buffer += h->bLength;
- size -= h->bLength;
- ++n;
- }
-
- /* Store the number of descriptors skipped and return the
- * number of bytes skipped */
- if (num_skipped)
- *num_skipped = n;
- return buffer - buffer0;
-}
-
-static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
- int inum, int asnum, struct usb_host_endpoint *ep,
- unsigned char *buffer, int size)
-{
- struct usb_ss_ep_comp_descriptor *desc;
- int max_tx;
-
- /* The SuperSpeed endpoint companion descriptor is supposed to
- * be the first thing immediately following the endpoint descriptor.
- */
- desc = (struct usb_ss_ep_comp_descriptor *) buffer;
- if (desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP ||
- size < USB_DT_SS_EP_COMP_SIZE) {
- dev_warn(ddev, "No SuperSpeed endpoint companion for config %d "
- " interface %d altsetting %d ep %d: "
- "using minimum values\n",
- cfgno, inum, asnum, ep->desc.bEndpointAddress);
-
- /* Fill in some default values.
- * Leave bmAttributes as zero, which will mean no streams for
- * bulk, and isoc won't support multiple bursts of packets.
- * With bursts of only one packet, and a Mult of 1, the max
- * amount of data moved per endpoint service interval is one
- * packet.
- */
- ep->ss_ep_comp.bLength = USB_DT_SS_EP_COMP_SIZE;
- ep->ss_ep_comp.bDescriptorType = USB_DT_SS_ENDPOINT_COMP;
- if (usb_endpoint_xfer_isoc(&ep->desc) ||
- usb_endpoint_xfer_int(&ep->desc))
- ep->ss_ep_comp.wBytesPerInterval =
- ep->desc.wMaxPacketSize;
- return;
- }
-
- memcpy(&ep->ss_ep_comp, desc, USB_DT_SS_EP_COMP_SIZE);
-
- /* Check the various values */
- if (usb_endpoint_xfer_control(&ep->desc) && desc->bMaxBurst != 0) {
- dev_warn(ddev, "Control endpoint with bMaxBurst = %d in "
- "config %d interface %d altsetting %d ep %d: "
- "setting to zero\n", desc->bMaxBurst,
- cfgno, inum, asnum, ep->desc.bEndpointAddress);
- ep->ss_ep_comp.bMaxBurst = 0;
- } else if (desc->bMaxBurst > 15) {
- dev_warn(ddev, "Endpoint with bMaxBurst = %d in "
- "config %d interface %d altsetting %d ep %d: "
- "setting to 15\n", desc->bMaxBurst,
- cfgno, inum, asnum, ep->desc.bEndpointAddress);
- ep->ss_ep_comp.bMaxBurst = 15;
- }
-
- if ((usb_endpoint_xfer_control(&ep->desc) ||
- usb_endpoint_xfer_int(&ep->desc)) &&
- desc->bmAttributes != 0) {
- dev_warn(ddev, "%s endpoint with bmAttributes = %d in "
- "config %d interface %d altsetting %d ep %d: "
- "setting to zero\n",
- usb_endpoint_xfer_control(&ep->desc) ? "Control" : "Bulk",
- desc->bmAttributes,
- cfgno, inum, asnum, ep->desc.bEndpointAddress);
- ep->ss_ep_comp.bmAttributes = 0;
- } else if (usb_endpoint_xfer_bulk(&ep->desc) &&
- desc->bmAttributes > 16) {
- dev_warn(ddev, "Bulk endpoint with more than 65536 streams in "
- "config %d interface %d altsetting %d ep %d: "
- "setting to max\n",
- cfgno, inum, asnum, ep->desc.bEndpointAddress);
- ep->ss_ep_comp.bmAttributes = 16;
- } else if (usb_endpoint_xfer_isoc(&ep->desc) &&
- desc->bmAttributes > 2) {
- dev_warn(ddev, "Isoc endpoint has Mult of %d in "
- "config %d interface %d altsetting %d ep %d: "
- "setting to 3\n", desc->bmAttributes + 1,
- cfgno, inum, asnum, ep->desc.bEndpointAddress);
- ep->ss_ep_comp.bmAttributes = 2;
- }
-
- if (usb_endpoint_xfer_isoc(&ep->desc))
- max_tx = (desc->bMaxBurst + 1) * (desc->bmAttributes + 1) *
- usb_endpoint_maxp(&ep->desc);
- else if (usb_endpoint_xfer_int(&ep->desc))
- max_tx = usb_endpoint_maxp(&ep->desc) *
- (desc->bMaxBurst + 1);
- else
- max_tx = 999999;
- if (le16_to_cpu(desc->wBytesPerInterval) > max_tx) {
- dev_warn(ddev, "%s endpoint with wBytesPerInterval of %d in "
- "config %d interface %d altsetting %d ep %d: "
- "setting to %d\n",
- usb_endpoint_xfer_isoc(&ep->desc) ? "Isoc" : "Int",
- le16_to_cpu(desc->wBytesPerInterval),
- cfgno, inum, asnum, ep->desc.bEndpointAddress,
- max_tx);
- ep->ss_ep_comp.wBytesPerInterval = cpu_to_le16(max_tx);
- }
-}
-
-static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
- int asnum, struct usb_host_interface *ifp, int num_ep,
- unsigned char *buffer, int size)
-{
- unsigned char *buffer0 = buffer;
- struct usb_endpoint_descriptor *d;
- struct usb_host_endpoint *endpoint;
- int n, i, j, retval;
-
- d = (struct usb_endpoint_descriptor *) buffer;
- buffer += d->bLength;
- size -= d->bLength;
-
- if (d->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE)
- n = USB_DT_ENDPOINT_AUDIO_SIZE;
- else if (d->bLength >= USB_DT_ENDPOINT_SIZE)
- n = USB_DT_ENDPOINT_SIZE;
- else {
- dev_warn(ddev, "config %d interface %d altsetting %d has an "
- "invalid endpoint descriptor of length %d, skipping\n",
- cfgno, inum, asnum, d->bLength);
- goto skip_to_next_endpoint_or_interface_descriptor;
- }
-
- i = d->bEndpointAddress & ~USB_ENDPOINT_DIR_MASK;
- if (i >= 16 || i == 0) {
- dev_warn(ddev, "config %d interface %d altsetting %d has an "
- "invalid endpoint with address 0x%X, skipping\n",
- cfgno, inum, asnum, d->bEndpointAddress);
- goto skip_to_next_endpoint_or_interface_descriptor;
- }
-
- /* Only store as many endpoints as we have room for */
- if (ifp->desc.bNumEndpoints >= num_ep)
- goto skip_to_next_endpoint_or_interface_descriptor;
-
- endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints];
- ++ifp->desc.bNumEndpoints;
-
- memcpy(&endpoint->desc, d, n);
- INIT_LIST_HEAD(&endpoint->urb_list);
-
- /* Fix up bInterval values outside the legal range. Use 32 ms if no
- * proper value can be guessed. */
- i = 0; /* i = min, j = max, n = default */
- j = 255;
- if (usb_endpoint_xfer_int(d)) {
- i = 1;
- switch (to_usb_device(ddev)->speed) {
- case USB_SPEED_SUPER:
- case USB_SPEED_HIGH:
- /* Many device manufacturers are using full-speed
- * bInterval values in high-speed interrupt endpoint
- * descriptors. Try to fix those and fall back to a
- * 32 ms default value otherwise. */
- n = fls(d->bInterval*8);
- if (n == 0)
- n = 9; /* 32 ms = 2^(9-1) uframes */
- j = 16;
- break;
- default: /* USB_SPEED_FULL or _LOW */
- /* For low-speed, 10 ms is the official minimum.
- * But some "overclocked" devices might want faster
- * polling so we'll allow it. */
- n = 32;
- break;
- }
- } else if (usb_endpoint_xfer_isoc(d)) {
- i = 1;
- j = 16;
- switch (to_usb_device(ddev)->speed) {
- case USB_SPEED_HIGH:
- n = 9; /* 32 ms = 2^(9-1) uframes */
- break;
- default: /* USB_SPEED_FULL */
- n = 6; /* 32 ms = 2^(6-1) frames */
- break;
- }
- }
- if (d->bInterval < i || d->bInterval > j) {
- dev_warn(ddev, "config %d interface %d altsetting %d "
- "endpoint 0x%X has an invalid bInterval %d, "
- "changing to %d\n",
- cfgno, inum, asnum,
- d->bEndpointAddress, d->bInterval, n);
- endpoint->desc.bInterval = n;
- }
-
- /* Some buggy low-speed devices have Bulk endpoints, which is
- * explicitly forbidden by the USB spec. In an attempt to make
- * them usable, we will try treating them as Interrupt endpoints.
- */
- if (to_usb_device(ddev)->speed == USB_SPEED_LOW &&
- usb_endpoint_xfer_bulk(d)) {
- dev_warn(ddev, "config %d interface %d altsetting %d "
- "endpoint 0x%X is Bulk; changing to Interrupt\n",
- cfgno, inum, asnum, d->bEndpointAddress);
- endpoint->desc.bmAttributes = USB_ENDPOINT_XFER_INT;
- endpoint->desc.bInterval = 1;
- if (usb_endpoint_maxp(&endpoint->desc) > 8)
- endpoint->desc.wMaxPacketSize = cpu_to_le16(8);
- }
-
- /*
- * Some buggy high speed devices have bulk endpoints using
- * maxpacket sizes other than 512. High speed HCDs may not
- * be able to handle that particular bug, so let's warn...
- */
- if (to_usb_device(ddev)->speed == USB_SPEED_HIGH
- && usb_endpoint_xfer_bulk(d)) {
- unsigned maxp;
-
- maxp = usb_endpoint_maxp(&endpoint->desc) & 0x07ff;
- if (maxp != 512)
- dev_warn(ddev, "config %d interface %d altsetting %d "
- "bulk endpoint 0x%X has invalid maxpacket %d\n",
- cfgno, inum, asnum, d->bEndpointAddress,
- maxp);
- }
-
- /* Parse a possible SuperSpeed endpoint companion descriptor */
- if (to_usb_device(ddev)->speed == USB_SPEED_SUPER)
- usb_parse_ss_endpoint_companion(ddev, cfgno,
- inum, asnum, endpoint, buffer, size);
-
- /* Skip over any Class Specific or Vendor Specific descriptors;
- * find the next endpoint or interface descriptor */
- endpoint->extra = buffer;
- i = find_next_descriptor(buffer, size, USB_DT_ENDPOINT,
- USB_DT_INTERFACE, &n);
- endpoint->extralen = i;
- retval = buffer - buffer0 + i;
- if (n > 0)
- dev_dbg(ddev, "skipped %d descriptor%s after %s\n",
- n, plural(n), "endpoint");
- return retval;
-
-skip_to_next_endpoint_or_interface_descriptor:
- i = find_next_descriptor(buffer, size, USB_DT_ENDPOINT,
- USB_DT_INTERFACE, NULL);
- return buffer - buffer0 + i;
-}
-
-void usb_release_interface_cache(struct kref *ref)
-{
- struct usb_interface_cache *intfc = ref_to_usb_interface_cache(ref);
- int j;
-
- for (j = 0; j < intfc->num_altsetting; j++) {
- struct usb_host_interface *alt = &intfc->altsetting[j];
-
- kfree(alt->endpoint);
- kfree(alt->string);
- }
- kfree(intfc);
-}
-
-static int usb_parse_interface(struct device *ddev, int cfgno,
- struct usb_host_config *config, unsigned char *buffer, int size,
- u8 inums[], u8 nalts[])
-{
- unsigned char *buffer0 = buffer;
- struct usb_interface_descriptor *d;
- int inum, asnum;
- struct usb_interface_cache *intfc;
- struct usb_host_interface *alt;
- int i, n;
- int len, retval;
- int num_ep, num_ep_orig;
-
- d = (struct usb_interface_descriptor *) buffer;
- buffer += d->bLength;
- size -= d->bLength;
-
- if (d->bLength < USB_DT_INTERFACE_SIZE)
- goto skip_to_next_interface_descriptor;
-
- /* Which interface entry is this? */
- intfc = NULL;
- inum = d->bInterfaceNumber;
- for (i = 0; i < config->desc.bNumInterfaces; ++i) {
- if (inums[i] == inum) {
- intfc = config->intf_cache[i];
- break;
- }
- }
- if (!intfc || intfc->num_altsetting >= nalts[i])
- goto skip_to_next_interface_descriptor;
-
- /* Check for duplicate altsetting entries */
- asnum = d->bAlternateSetting;
- for ((i = 0, alt = &intfc->altsetting[0]);
- i < intfc->num_altsetting;
- (++i, ++alt)) {
- if (alt->desc.bAlternateSetting == asnum) {
- dev_warn(ddev, "Duplicate descriptor for config %d "
- "interface %d altsetting %d, skipping\n",
- cfgno, inum, asnum);
- goto skip_to_next_interface_descriptor;
- }
- }
-
- ++intfc->num_altsetting;
- memcpy(&alt->desc, d, USB_DT_INTERFACE_SIZE);
-
- /* Skip over any Class Specific or Vendor Specific descriptors;
- * find the first endpoint or interface descriptor */
- alt->extra = buffer;
- i = find_next_descriptor(buffer, size, USB_DT_ENDPOINT,
- USB_DT_INTERFACE, &n);
- alt->extralen = i;
- if (n > 0)
- dev_dbg(ddev, "skipped %d descriptor%s after %s\n",
- n, plural(n), "interface");
- buffer += i;
- size -= i;
-
- /* Allocate space for the right(?) number of endpoints */
- num_ep = num_ep_orig = alt->desc.bNumEndpoints;
- alt->desc.bNumEndpoints = 0; /* Use as a counter */
- if (num_ep > USB_MAXENDPOINTS) {
- dev_warn(ddev, "too many endpoints for config %d interface %d "
- "altsetting %d: %d, using maximum allowed: %d\n",
- cfgno, inum, asnum, num_ep, USB_MAXENDPOINTS);
- num_ep = USB_MAXENDPOINTS;
- }
-
- if (num_ep > 0) {
- /* Can't allocate 0 bytes */
- len = sizeof(struct usb_host_endpoint) * num_ep;
- alt->endpoint = kzalloc(len, GFP_KERNEL);
- if (!alt->endpoint)
- return -ENOMEM;
- }
-
- /* Parse all the endpoint descriptors */
- n = 0;
- while (size > 0) {
- if (((struct usb_descriptor_header *) buffer)->bDescriptorType
- == USB_DT_INTERFACE)
- break;
- retval = usb_parse_endpoint(ddev, cfgno, inum, asnum, alt,
- num_ep, buffer, size);
- if (retval < 0)
- return retval;
- ++n;
-
- buffer += retval;
- size -= retval;
- }
-
- if (n != num_ep_orig)
- dev_warn(ddev, "config %d interface %d altsetting %d has %d "
- "endpoint descriptor%s, different from the interface "
- "descriptor's value: %d\n",
- cfgno, inum, asnum, n, plural(n), num_ep_orig);
- return buffer - buffer0;
-
-skip_to_next_interface_descriptor:
- i = find_next_descriptor(buffer, size, USB_DT_INTERFACE,
- USB_DT_INTERFACE, NULL);
- return buffer - buffer0 + i;
-}
-
-static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
- struct usb_host_config *config, unsigned char *buffer, int size)
-{
- struct device *ddev = &dev->dev;
- unsigned char *buffer0 = buffer;
- int cfgno;
- int nintf, nintf_orig;
- int i, j, n;
- struct usb_interface_cache *intfc;
- unsigned char *buffer2;
- int size2;
- struct usb_descriptor_header *header;
- int len, retval;
- u8 inums[USB_MAXINTERFACES], nalts[USB_MAXINTERFACES];
- unsigned iad_num = 0;
-
- memcpy(&config->desc, buffer, USB_DT_CONFIG_SIZE);
- if (config->desc.bDescriptorType != USB_DT_CONFIG ||
- config->desc.bLength < USB_DT_CONFIG_SIZE) {
- dev_err(ddev, "invalid descriptor for config index %d: "
- "type = 0x%X, length = %d\n", cfgidx,
- config->desc.bDescriptorType, config->desc.bLength);
- return -EINVAL;
- }
- cfgno = config->desc.bConfigurationValue;
-
- buffer += config->desc.bLength;
- size -= config->desc.bLength;
-
- nintf = nintf_orig = config->desc.bNumInterfaces;
- if (nintf > USB_MAXINTERFACES) {
- dev_warn(ddev, "config %d has too many interfaces: %d, "
- "using maximum allowed: %d\n",
- cfgno, nintf, USB_MAXINTERFACES);
- nintf = USB_MAXINTERFACES;
- }
-
- /* Go through the descriptors, checking their length and counting the
- * number of altsettings for each interface */
- n = 0;
- for ((buffer2 = buffer, size2 = size);
- size2 > 0;
- (buffer2 += header->bLength, size2 -= header->bLength)) {
-
- if (size2 < sizeof(struct usb_descriptor_header)) {
- dev_warn(ddev, "config %d descriptor has %d excess "
- "byte%s, ignoring\n",
- cfgno, size2, plural(size2));
- break;
- }
-
- header = (struct usb_descriptor_header *) buffer2;
- if ((header->bLength > size2) || (header->bLength < 2)) {
- dev_warn(ddev, "config %d has an invalid descriptor "
- "of length %d, skipping remainder of the config\n",
- cfgno, header->bLength);
- break;
- }
-
- if (header->bDescriptorType == USB_DT_INTERFACE) {
- struct usb_interface_descriptor *d;
- int inum;
-
- d = (struct usb_interface_descriptor *) header;
- if (d->bLength < USB_DT_INTERFACE_SIZE) {
- dev_warn(ddev, "config %d has an invalid "
- "interface descriptor of length %d, "
- "skipping\n", cfgno, d->bLength);
- continue;
- }
-
- inum = d->bInterfaceNumber;
-
- if ((dev->quirks & USB_QUIRK_HONOR_BNUMINTERFACES) &&
- n >= nintf_orig) {
- dev_warn(ddev, "config %d has more interface "
- "descriptors, than it declares in "
- "bNumInterfaces, ignoring interface "
- "number: %d\n", cfgno, inum);
- continue;
- }
-
- if (inum >= nintf_orig)
- dev_warn(ddev, "config %d has an invalid "
- "interface number: %d but max is %d\n",
- cfgno, inum, nintf_orig - 1);
-
- /* Have we already encountered this interface?
- * Count its altsettings */
- for (i = 0; i < n; ++i) {
- if (inums[i] == inum)
- break;
- }
- if (i < n) {
- if (nalts[i] < 255)
- ++nalts[i];
- } else if (n < USB_MAXINTERFACES) {
- inums[n] = inum;
- nalts[n] = 1;
- ++n;
- }
-
- } else if (header->bDescriptorType ==
- USB_DT_INTERFACE_ASSOCIATION) {
- if (iad_num == USB_MAXIADS) {
- dev_warn(ddev, "found more Interface "
- "Association Descriptors "
- "than allocated for in "
- "configuration %d\n", cfgno);
- } else {
- config->intf_assoc[iad_num] =
- (struct usb_interface_assoc_descriptor
- *)header;
- iad_num++;
- }
-
- } else if (header->bDescriptorType == USB_DT_DEVICE ||
- header->bDescriptorType == USB_DT_CONFIG)
- dev_warn(ddev, "config %d contains an unexpected "
- "descriptor of type 0x%X, skipping\n",
- cfgno, header->bDescriptorType);
-
- } /* for ((buffer2 = buffer, size2 = size); ...) */
- size = buffer2 - buffer;
- config->desc.wTotalLength = cpu_to_le16(buffer2 - buffer0);
-
- if (n != nintf)
- dev_warn(ddev, "config %d has %d interface%s, different from "
- "the descriptor's value: %d\n",
- cfgno, n, plural(n), nintf_orig);
- else if (n == 0)
- dev_warn(ddev, "config %d has no interfaces?\n", cfgno);
- config->desc.bNumInterfaces = nintf = n;
-
- /* Check for missing interface numbers */
- for (i = 0; i < nintf; ++i) {
- for (j = 0; j < nintf; ++j) {
- if (inums[j] == i)
- break;
- }
- if (j >= nintf)
- dev_warn(ddev, "config %d has no interface number "
- "%d\n", cfgno, i);
- }
-
- /* Allocate the usb_interface_caches and altsetting arrays */
- for (i = 0; i < nintf; ++i) {
- j = nalts[i];
- if (j > USB_MAXALTSETTING) {
- dev_warn(ddev, "too many alternate settings for "
- "config %d interface %d: %d, "
- "using maximum allowed: %d\n",
- cfgno, inums[i], j, USB_MAXALTSETTING);
- nalts[i] = j = USB_MAXALTSETTING;
- }
-
- len = sizeof(*intfc) + sizeof(struct usb_host_interface) * j;
- config->intf_cache[i] = intfc = kzalloc(len, GFP_KERNEL);
- if (!intfc)
- return -ENOMEM;
- kref_init(&intfc->ref);
- }
-
- /* FIXME: parse the BOS descriptor */
-
- /* Skip over any Class Specific or Vendor Specific descriptors;
- * find the first interface descriptor */
- config->extra = buffer;
- i = find_next_descriptor(buffer, size, USB_DT_INTERFACE,
- USB_DT_INTERFACE, &n);
- config->extralen = i;
- if (n > 0)
- dev_dbg(ddev, "skipped %d descriptor%s after %s\n",
- n, plural(n), "configuration");
- buffer += i;
- size -= i;
-
- /* Parse all the interface/altsetting descriptors */
- while (size > 0) {
- retval = usb_parse_interface(ddev, cfgno, config,
- buffer, size, inums, nalts);
- if (retval < 0)
- return retval;
-
- buffer += retval;
- size -= retval;
- }
-
- /* Check for missing altsettings */
- for (i = 0; i < nintf; ++i) {
- intfc = config->intf_cache[i];
- for (j = 0; j < intfc->num_altsetting; ++j) {
- for (n = 0; n < intfc->num_altsetting; ++n) {
- if (intfc->altsetting[n].desc.
- bAlternateSetting == j)
- break;
- }
- if (n >= intfc->num_altsetting)
- dev_warn(ddev, "config %d interface %d has no "
- "altsetting %d\n", cfgno, inums[i], j);
- }
- }
-
- return 0;
-}
-
-/* hub-only!! ... and only exported for reset/reinit path.
- * otherwise used internally on disconnect/destroy path
- */
-void usb_destroy_configuration(struct usb_device *dev)
-{
- int c, i;
-
- if (!dev->config)
- return;
-
- if (dev->rawdescriptors) {
- for (i = 0; i < dev->descriptor.bNumConfigurations; i++)
- kfree(dev->rawdescriptors[i]);
-
- kfree(dev->rawdescriptors);
- dev->rawdescriptors = NULL;
- }
-
- for (c = 0; c < dev->descriptor.bNumConfigurations; c++) {
- struct usb_host_config *cf = &dev->config[c];
-
- kfree(cf->string);
- for (i = 0; i < cf->desc.bNumInterfaces; i++) {
- if (cf->intf_cache[i])
- kref_put(&cf->intf_cache[i]->ref,
- usb_release_interface_cache);
- }
- }
- kfree(dev->config);
- dev->config = NULL;
-}
-
-
-/*
- * Get the USB config descriptors, cache and parse'em
- *
- * hub-only!! ... and only in reset path, or usb_new_device()
- * (used by real hubs and virtual root hubs)
- *
- * NOTE: if this is a WUSB device and is not authorized, we skip the
- * whole thing. A non-authorized USB device has no
- * configurations.
- */
-int usb_get_configuration(struct usb_device *dev)
-{
- struct device *ddev = &dev->dev;
- int ncfg = dev->descriptor.bNumConfigurations;
- int result = 0;
- unsigned int cfgno, length;
- unsigned char *bigbuffer;
- struct usb_config_descriptor *desc;
-
- cfgno = 0;
- if (dev->authorized == 0) /* Not really an error */
- goto out_not_authorized;
- result = -ENOMEM;
- if (ncfg > USB_MAXCONFIG) {
- dev_warn(ddev, "too many configurations: %d, "
- "using maximum allowed: %d\n", ncfg, USB_MAXCONFIG);
- dev->descriptor.bNumConfigurations = ncfg = USB_MAXCONFIG;
- }
-
- if (ncfg < 1) {
- dev_err(ddev, "no configurations\n");
- return -EINVAL;
- }
-
- length = ncfg * sizeof(struct usb_host_config);
- dev->config = kzalloc(length, GFP_KERNEL);
- if (!dev->config)
- goto err2;
-
- length = ncfg * sizeof(char *);
- dev->rawdescriptors = kzalloc(length, GFP_KERNEL);
- if (!dev->rawdescriptors)
- goto err2;
-
- desc = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL);
- if (!desc)
- goto err2;
-
- result = 0;
- for (; cfgno < ncfg; cfgno++) {
- /* We grab just the first descriptor so we know how long
- * the whole configuration is */
- result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,
- desc, USB_DT_CONFIG_SIZE);
- if (result < 0) {
- dev_err(ddev, "unable to read config index %d "
- "descriptor/%s: %d\n", cfgno, "start", result);
- dev_err(ddev, "chopping to %d config(s)\n", cfgno);
- dev->descriptor.bNumConfigurations = cfgno;
- break;
- } else if (result < 4) {
- dev_err(ddev, "config index %d descriptor too short "
- "(expected %i, got %i)\n", cfgno,
- USB_DT_CONFIG_SIZE, result);
- result = -EINVAL;
- goto err;
- }
- length = max((int) le16_to_cpu(desc->wTotalLength),
- USB_DT_CONFIG_SIZE);
-
- /* Now that we know the length, get the whole thing */
- bigbuffer = kmalloc(length, GFP_KERNEL);
- if (!bigbuffer) {
- result = -ENOMEM;
- goto err;
- }
- result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,
- bigbuffer, length);
- if (result < 0) {
- dev_err(ddev, "unable to read config index %d "
- "descriptor/%s\n", cfgno, "all");
- kfree(bigbuffer);
- goto err;
- }
- if (result < length) {
- dev_warn(ddev, "config index %d descriptor too short "
- "(expected %i, got %i)\n", cfgno, length, result);
- length = result;
- }
-
- dev->rawdescriptors[cfgno] = bigbuffer;
-
- result = usb_parse_configuration(dev, cfgno,
- &dev->config[cfgno], bigbuffer, length);
- if (result < 0) {
- ++cfgno;
- goto err;
- }
- }
- result = 0;
-
-err:
- kfree(desc);
-out_not_authorized:
- dev->descriptor.bNumConfigurations = cfgno;
-err2:
- if (result == -ENOMEM)
- dev_err(ddev, "out of memory\n");
- return result;
-}
-
-void usb_release_bos_descriptor(struct usb_device *dev)
-{
- if (dev->bos) {
- kfree(dev->bos->desc);
- kfree(dev->bos);
- dev->bos = NULL;
- }
-}
-
-/* Get BOS descriptor set */
-int usb_get_bos_descriptor(struct usb_device *dev)
-{
- struct device *ddev = &dev->dev;
- struct usb_bos_descriptor *bos;
- struct usb_dev_cap_header *cap;
- unsigned char *buffer;
- int length, total_len, num, i;
- int ret;
-
- bos = kzalloc(sizeof(struct usb_bos_descriptor), GFP_KERNEL);
- if (!bos)
- return -ENOMEM;
-
- /* Get BOS descriptor */
- ret = usb_get_descriptor(dev, USB_DT_BOS, 0, bos, USB_DT_BOS_SIZE);
- if (ret < USB_DT_BOS_SIZE) {
- dev_err(ddev, "unable to get BOS descriptor\n");
- if (ret >= 0)
- ret = -ENOMSG;
- kfree(bos);
- return ret;
- }
-
- length = bos->bLength;
- total_len = le16_to_cpu(bos->wTotalLength);
- num = bos->bNumDeviceCaps;
- kfree(bos);
- if (total_len < length)
- return -EINVAL;
-
- dev->bos = kzalloc(sizeof(struct usb_host_bos), GFP_KERNEL);
- if (!dev->bos)
- return -ENOMEM;
-
- /* Now let's get the whole BOS descriptor set */
- buffer = kzalloc(total_len, GFP_KERNEL);
- if (!buffer) {
- ret = -ENOMEM;
- goto err;
- }
- dev->bos->desc = (struct usb_bos_descriptor *)buffer;
-
- ret = usb_get_descriptor(dev, USB_DT_BOS, 0, buffer, total_len);
- if (ret < total_len) {
- dev_err(ddev, "unable to get BOS descriptor set\n");
- if (ret >= 0)
- ret = -ENOMSG;
- goto err;
- }
- total_len -= length;
-
- for (i = 0; i < num; i++) {
- buffer += length;
- cap = (struct usb_dev_cap_header *)buffer;
- length = cap->bLength;
-
- if (total_len < length)
- break;
- total_len -= length;
-
- if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) {
- dev_warn(ddev, "descriptor type invalid, skip\n");
- continue;
- }
-
- switch (cap->bDevCapabilityType) {
- case USB_CAP_TYPE_WIRELESS_USB:
- /* Wireless USB cap descriptor is handled by wusb */
- break;
- case USB_CAP_TYPE_EXT:
- dev->bos->ext_cap =
- (struct usb_ext_cap_descriptor *)buffer;
- break;
- case USB_SS_CAP_TYPE:
- dev->bos->ss_cap =
- (struct usb_ss_cap_descriptor *)buffer;
- break;
- case CONTAINER_ID_TYPE:
- dev->bos->ss_id =
- (struct usb_ss_container_id_descriptor *)buffer;
- break;
- default:
- break;
- }
- }
-
- return 0;
-
-err:
- usb_release_bos_descriptor(dev);
- return ret;
-}
diff --git a/ANDROID_3.4.5/drivers/usb/core/devices.c b/ANDROID_3.4.5/drivers/usb/core/devices.c
deleted file mode 100644
index d9569658..00000000
--- a/ANDROID_3.4.5/drivers/usb/core/devices.c
+++ /dev/null
@@ -1,688 +0,0 @@
-/*
- * devices.c
- * (C) Copyright 1999 Randy Dunlap.
- * (C) Copyright 1999,2000 Thomas Sailer .
- * (proc file per device)
- * (C) Copyright 1999 Deti Fliegl (new USB architecture)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *************************************************************
- *
- * /devices contains USB topology, device, config, class,
- * interface, & endpoint data.
- *
- * I considered using /proc/bus/usb/devices/device# for each device
- * as it is attached or detached, but I didn't like this for some
- * reason -- maybe it's just too deep of a directory structure.
- * I also don't like looking in multiple places to gather and view
- * the data. Having only one file for ./devices also prevents race
- * conditions that could arise if a program was reading device info
- * for devices that are being removed (unplugged). (That is, the
- * program may find a directory for devnum_12 then try to open it,
- * but it was just unplugged, so the directory is now deleted.
- * But programs would just have to be prepared for situations like
- * this in any plug-and-play environment.)
- *
- * 1999-12-16: Thomas Sailer
- * Converted the whole proc stuff to real
- * read methods. Now not the whole device list needs to fit
- * into one page, only the device list for one bus.
- * Added a poll method to /proc/bus/usb/devices, to wake
- * up an eventual usbd
- * 2000-01-04: Thomas Sailer
- * Turned into its own filesystem
- * 2000-07-05: Ashley Montanaro
- * Converted file reading routine to dump to buffer once
- * per device, not per bus
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "usb.h"
-
-/* Define ALLOW_SERIAL_NUMBER if you want to see the serial number of devices */
-#define ALLOW_SERIAL_NUMBER
-
-static const char format_topo[] =
-/* T: Bus=dd Lev=dd Prnt=dd Port=dd Cnt=dd Dev#=ddd Spd=dddd MxCh=dd */
-"\nT: Bus=%2.2d Lev=%2.2d Prnt=%2.2d Port=%2.2d Cnt=%2.2d Dev#=%3d Spd=%-4s MxCh=%2d\n";
-
-static const char format_string_manufacturer[] =
-/* S: Manufacturer=xxxx */
- "S: Manufacturer=%.100s\n";
-
-static const char format_string_product[] =
-/* S: Product=xxxx */
- "S: Product=%.100s\n";
-
-#ifdef ALLOW_SERIAL_NUMBER
-static const char format_string_serialnumber[] =
-/* S: SerialNumber=xxxx */
- "S: SerialNumber=%.100s\n";
-#endif
-
-static const char format_bandwidth[] =
-/* B: Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd */
- "B: Alloc=%3d/%3d us (%2d%%), #Int=%3d, #Iso=%3d\n";
-
-static const char format_device1[] =
-/* D: Ver=xx.xx Cls=xx(sssss) Sub=xx Prot=xx MxPS=dd #Cfgs=dd */
- "D: Ver=%2x.%02x Cls=%02x(%-5s) Sub=%02x Prot=%02x MxPS=%2d #Cfgs=%3d\n";
-
-static const char format_device2[] =
-/* P: Vendor=xxxx ProdID=xxxx Rev=xx.xx */
- "P: Vendor=%04x ProdID=%04x Rev=%2x.%02x\n";
-
-static const char format_config[] =
-/* C: #Ifs=dd Cfg#=dd Atr=xx MPwr=dddmA */
- "C:%c #Ifs=%2d Cfg#=%2d Atr=%02x MxPwr=%3dmA\n";
-
-static const char format_iad[] =
-/* A: FirstIf#=dd IfCount=dd Cls=xx(sssss) Sub=xx Prot=xx */
- "A: FirstIf#=%2d IfCount=%2d Cls=%02x(%-5s) Sub=%02x Prot=%02x\n";
-
-static const char format_iface[] =
-/* I: If#=dd Alt=dd #EPs=dd Cls=xx(sssss) Sub=xx Prot=xx Driver=xxxx*/
- "I:%c If#=%2d Alt=%2d #EPs=%2d Cls=%02x(%-5s) Sub=%02x Prot=%02x Driver=%s\n";
-
-static const char format_endpt[] =
-/* E: Ad=xx(s) Atr=xx(ssss) MxPS=dddd Ivl=D?s */
- "E: Ad=%02x(%c) Atr=%02x(%-4s) MxPS=%4d Ivl=%d%cs\n";
-
-
-/*
- * Need access to the driver and USB bus lists.
- * extern struct list_head usb_bus_list;
- * However, these will come from functions that return ptrs to each of them.
- */
-
-/*
- * Wait for an connect/disconnect event to happen. We initialize
- * the event counter with an odd number, and each event will increment
- * the event counter by two, so it will always _stay_ odd. That means
- * that it will never be zero, so "event 0" will never match a current
- * event, and thus 'poll' will always trigger as readable for the first
- * time it gets called.
- */
-static struct device_connect_event {
- atomic_t count;
- wait_queue_head_t wait;
-} device_event = {
- .count = ATOMIC_INIT(1),
- .wait = __WAIT_QUEUE_HEAD_INITIALIZER(device_event.wait)
-};
-
-struct class_info {
- int class;
- char *class_name;
-};
-
-static const struct class_info clas_info[] = {
- /* max. 5 chars. per name string */
- {USB_CLASS_PER_INTERFACE, ">ifc"},
- {USB_CLASS_AUDIO, "audio"},
- {USB_CLASS_COMM, "comm."},
- {USB_CLASS_HID, "HID"},
- {USB_CLASS_PHYSICAL, "PID"},
- {USB_CLASS_STILL_IMAGE, "still"},
- {USB_CLASS_PRINTER, "print"},
- {USB_CLASS_MASS_STORAGE, "stor."},
- {USB_CLASS_HUB, "hub"},
- {USB_CLASS_CDC_DATA, "data"},
- {USB_CLASS_CSCID, "scard"},
- {USB_CLASS_CONTENT_SEC, "c-sec"},
- {USB_CLASS_VIDEO, "video"},
- {USB_CLASS_WIRELESS_CONTROLLER, "wlcon"},
- {USB_CLASS_MISC, "misc"},
- {USB_CLASS_APP_SPEC, "app."},
- {USB_CLASS_VENDOR_SPEC, "vend."},
- {-1, "unk."} /* leave as last */
-};
-
-/*****************************************************************/
-
-void usbfs_conn_disc_event(void)
-{
- atomic_add(2, &device_event.count);
- wake_up(&device_event.wait);
-}
-
-static const char *class_decode(const int class)
-{
- int ix;
-
- for (ix = 0; clas_info[ix].class != -1; ix++)
- if (clas_info[ix].class == class)
- break;
- return clas_info[ix].class_name;
-}
-
-static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end,
- const struct usb_endpoint_descriptor *desc)
-{
- char dir, unit, *type;
- unsigned interval, bandwidth = 1;
-
- if (start > end)
- return start;
-
- dir = usb_endpoint_dir_in(desc) ? 'I' : 'O';
-
- if (speed == USB_SPEED_HIGH) {
- switch (usb_endpoint_maxp(desc) & (0x03 << 11)) {
- case 1 << 11:
- bandwidth = 2; break;
- case 2 << 11:
- bandwidth = 3; break;
- }
- }
-
- /* this isn't checking for illegal values */
- switch (usb_endpoint_type(desc)) {
- case USB_ENDPOINT_XFER_CONTROL:
- type = "Ctrl";
- if (speed == USB_SPEED_HIGH) /* uframes per NAK */
- interval = desc->bInterval;
- else
- interval = 0;
- dir = 'B'; /* ctrl is bidirectional */
- break;
- case USB_ENDPOINT_XFER_ISOC:
- type = "Isoc";
- interval = 1 << (desc->bInterval - 1);
- break;
- case USB_ENDPOINT_XFER_BULK:
- type = "Bulk";
- if (speed == USB_SPEED_HIGH && dir == 'O') /* uframes per NAK */
- interval = desc->bInterval;
- else
- interval = 0;
- break;
- case USB_ENDPOINT_XFER_INT:
- type = "Int.";
- if (speed == USB_SPEED_HIGH || speed == USB_SPEED_SUPER)
- interval = 1 << (desc->bInterval - 1);
- else
- interval = desc->bInterval;
- break;
- default: /* "can't happen" */
- return start;
- }
- interval *= (speed == USB_SPEED_HIGH ||
- speed == USB_SPEED_SUPER) ? 125 : 1000;
- if (interval % 1000)
- unit = 'u';
- else {
- unit = 'm';
- interval /= 1000;
- }
-
- start += sprintf(start, format_endpt, desc->bEndpointAddress, dir,
- desc->bmAttributes, type,
- (usb_endpoint_maxp(desc) & 0x07ff) *
- bandwidth,
- interval, unit);
- return start;
-}
-
-static char *usb_dump_interface_descriptor(char *start, char *end,
- const struct usb_interface_cache *intfc,
- const struct usb_interface *iface,
- int setno)
-{
- const struct usb_interface_descriptor *desc;
- const char *driver_name = "";
- int active = 0;
-
- if (start > end)
- return start;
- desc = &intfc->altsetting[setno].desc;
- if (iface) {
- driver_name = (iface->dev.driver
- ? iface->dev.driver->name
- : "(none)");
- active = (desc == &iface->cur_altsetting->desc);
- }
- start += sprintf(start, format_iface,
- active ? '*' : ' ', /* mark active altsetting */
- desc->bInterfaceNumber,
- desc->bAlternateSetting,
- desc->bNumEndpoints,
- desc->bInterfaceClass,
- class_decode(desc->bInterfaceClass),
- desc->bInterfaceSubClass,
- desc->bInterfaceProtocol,
- driver_name);
- return start;
-}
-
-static char *usb_dump_interface(int speed, char *start, char *end,
- const struct usb_interface_cache *intfc,
- const struct usb_interface *iface, int setno)
-{
- const struct usb_host_interface *desc = &intfc->altsetting[setno];
- int i;
-
- start = usb_dump_interface_descriptor(start, end, intfc, iface, setno);
- for (i = 0; i < desc->desc.bNumEndpoints; i++) {
- if (start > end)
- return start;
- start = usb_dump_endpoint_descriptor(speed,
- start, end, &desc->endpoint[i].desc);
- }
- return start;
-}
-
-static char *usb_dump_iad_descriptor(char *start, char *end,
- const struct usb_interface_assoc_descriptor *iad)
-{
- if (start > end)
- return start;
- start += sprintf(start, format_iad,
- iad->bFirstInterface,
- iad->bInterfaceCount,
- iad->bFunctionClass,
- class_decode(iad->bFunctionClass),
- iad->bFunctionSubClass,
- iad->bFunctionProtocol);
- return start;
-}
-
-/* TBD:
- * 0. TBDs
- * 1. marking active interface altsettings (code lists all, but should mark
- * which ones are active, if any)
- */
-static char *usb_dump_config_descriptor(char *start, char *end,
- const struct usb_config_descriptor *desc,
- int active)
-{
- if (start > end)
- return start;
- start += sprintf(start, format_config,
- /* mark active/actual/current cfg. */
- active ? '*' : ' ',
- desc->bNumInterfaces,
- desc->bConfigurationValue,
- desc->bmAttributes,
- desc->bMaxPower * 2);
- return start;
-}
-
-static char *usb_dump_config(int speed, char *start, char *end,
- const struct usb_host_config *config, int active)
-{
- int i, j;
- struct usb_interface_cache *intfc;
- struct usb_interface *interface;
-
- if (start > end)
- return start;
- if (!config)
- /* getting these some in 2.3.7; none in 2.3.6 */
- return start + sprintf(start, "(null Cfg. desc.)\n");
- start = usb_dump_config_descriptor(start, end, &config->desc, active);
- for (i = 0; i < USB_MAXIADS; i++) {
- if (config->intf_assoc[i] == NULL)
- break;
- start = usb_dump_iad_descriptor(start, end,
- config->intf_assoc[i]);
- }
- for (i = 0; i < config->desc.bNumInterfaces; i++) {
- intfc = config->intf_cache[i];
- interface = config->interface[i];
- for (j = 0; j < intfc->num_altsetting; j++) {
- if (start > end)
- return start;
- start = usb_dump_interface(speed,
- start, end, intfc, interface, j);
- }
- }
- return start;
-}
-
-/*
- * Dump the different USB descriptors.
- */
-static char *usb_dump_device_descriptor(char *start, char *end,
- const struct usb_device_descriptor *desc)
-{
- u16 bcdUSB = le16_to_cpu(desc->bcdUSB);
- u16 bcdDevice = le16_to_cpu(desc->bcdDevice);
-
- if (start > end)
- return start;
- start += sprintf(start, format_device1,
- bcdUSB >> 8, bcdUSB & 0xff,
- desc->bDeviceClass,
- class_decode(desc->bDeviceClass),
- desc->bDeviceSubClass,
- desc->bDeviceProtocol,
- desc->bMaxPacketSize0,
- desc->bNumConfigurations);
- if (start > end)
- return start;
- start += sprintf(start, format_device2,
- le16_to_cpu(desc->idVendor),
- le16_to_cpu(desc->idProduct),
- bcdDevice >> 8, bcdDevice & 0xff);
- return start;
-}
-
-/*
- * Dump the different strings that this device holds.
- */
-static char *usb_dump_device_strings(char *start, char *end,
- struct usb_device *dev)
-{
- if (start > end)
- return start;
- if (dev->manufacturer)
- start += sprintf(start, format_string_manufacturer,
- dev->manufacturer);
- if (start > end)
- goto out;
- if (dev->product)
- start += sprintf(start, format_string_product, dev->product);
- if (start > end)
- goto out;
-#ifdef ALLOW_SERIAL_NUMBER
- if (dev->serial)
- start += sprintf(start, format_string_serialnumber,
- dev->serial);
-#endif
- out:
- return start;
-}
-
-static char *usb_dump_desc(char *start, char *end, struct usb_device *dev)
-{
- int i;
-
- if (start > end)
- return start;
-
- start = usb_dump_device_descriptor(start, end, &dev->descriptor);
-
- if (start > end)
- return start;
-
- start = usb_dump_device_strings(start, end, dev);
-
- for (i = 0; i < dev->descriptor.bNumConfigurations; i++) {
- if (start > end)
- return start;
- start = usb_dump_config(dev->speed,
- start, end, dev->config + i,
- /* active ? */
- (dev->config + i) == dev->actconfig);
- }
- return start;
-}
-
-
-#ifdef PROC_EXTRA /* TBD: may want to add this code later */
-
-static char *usb_dump_hub_descriptor(char *start, char *end,
- const struct usb_hub_descriptor *desc)
-{
- int leng = USB_DT_HUB_NONVAR_SIZE;
- unsigned char *ptr = (unsigned char *)desc;
-
- if (start > end)
- return start;
- start += sprintf(start, "Interface:");
- while (leng && start <= end) {
- start += sprintf(start, " %02x", *ptr);
- ptr++; leng--;
- }
- *start++ = '\n';
- return start;
-}
-
-static char *usb_dump_string(char *start, char *end,
- const struct usb_device *dev, char *id, int index)
-{
- if (start > end)
- return start;
- start += sprintf(start, "Interface:");
- if (index <= dev->maxstring && dev->stringindex &&
- dev->stringindex[index])
- start += sprintf(start, "%s: %.100s ", id,
- dev->stringindex[index]);
- return start;
-}
-
-#endif /* PROC_EXTRA */
-
-/*****************************************************************/
-
-/* This is a recursive function. Parameters:
- * buffer - the user-space buffer to write data into
- * nbytes - the maximum number of bytes to write
- * skip_bytes - the number of bytes to skip before writing anything
- * file_offset - the offset into the devices file on completion
- * The caller must own the device lock.
- */
-static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes,
- loff_t *skip_bytes, loff_t *file_offset,
- struct usb_device *usbdev, struct usb_bus *bus,
- int level, int index, int count)
-{
- int chix;
- int ret, cnt = 0;
- int parent_devnum = 0;
- char *pages_start, *data_end, *speed;
- unsigned int length;
- ssize_t total_written = 0;
-
- /* don't bother with anything else if we're not writing any data */
- if (*nbytes <= 0)
- return 0;
-
- if (level > MAX_TOPO_LEVEL)
- return 0;
- /* allocate 2^1 pages = 8K (on i386);
- * should be more than enough for one device */
- pages_start = (char *)__get_free_pages(GFP_NOIO, 1);
- if (!pages_start)
- return -ENOMEM;
-
- if (usbdev->parent && usbdev->parent->devnum != -1)
- parent_devnum = usbdev->parent->devnum;
- /*
- * So the root hub's parent is 0 and any device that is
- * plugged into the root hub has a parent of 0.
- */
- switch (usbdev->speed) {
- case USB_SPEED_LOW:
- speed = "1.5"; break;
- case USB_SPEED_UNKNOWN: /* usb 1.1 root hub code */
- case USB_SPEED_FULL:
- speed = "12"; break;
- case USB_SPEED_WIRELESS: /* Wireless has no real fixed speed */
- case USB_SPEED_HIGH:
- speed = "480"; break;
- case USB_SPEED_SUPER:
- speed = "5000"; break;
- default:
- speed = "??";
- }
- data_end = pages_start + sprintf(pages_start, format_topo,
- bus->busnum, level, parent_devnum,
- index, count, usbdev->devnum,
- speed, usbdev->maxchild);
- /*
- * level = topology-tier level;
- * parent_devnum = parent device number;
- * index = parent's connector number;
- * count = device count at this level
- */
- /* If this is the root hub, display the bandwidth information */
- if (level == 0) {
- int max;
-
- /* super/high speed reserves 80%, full/low reserves 90% */
- if (usbdev->speed == USB_SPEED_HIGH ||
- usbdev->speed == USB_SPEED_SUPER)
- max = 800;
- else
- max = FRAME_TIME_MAX_USECS_ALLOC;
-
- /* report "average" periodic allocation over a microsecond.
- * the schedules are actually bursty, HCDs need to deal with
- * that and just compute/report this average.
- */
- data_end += sprintf(data_end, format_bandwidth,
- bus->bandwidth_allocated, max,
- (100 * bus->bandwidth_allocated + max / 2)
- / max,
- bus->bandwidth_int_reqs,
- bus->bandwidth_isoc_reqs);
-
- }
- data_end = usb_dump_desc(data_end, pages_start + (2 * PAGE_SIZE) - 256,
- usbdev);
-
- if (data_end > (pages_start + (2 * PAGE_SIZE) - 256))
- data_end += sprintf(data_end, "(truncated)\n");
-
- length = data_end - pages_start;
- /* if we can start copying some data to the user */
- if (length > *skip_bytes) {
- length -= *skip_bytes;
- if (length > *nbytes)
- length = *nbytes;
- if (copy_to_user(*buffer, pages_start + *skip_bytes, length)) {
- free_pages((unsigned long)pages_start, 1);
- return -EFAULT;
- }
- *nbytes -= length;
- *file_offset += length;
- total_written += length;
- *buffer += length;
- *skip_bytes = 0;
- } else
- *skip_bytes -= length;
-
- free_pages((unsigned long)pages_start, 1);
-
- /* Now look at all of this device's children. */
- for (chix = 0; chix < usbdev->maxchild; chix++) {
- struct usb_device *childdev = usbdev->children[chix];
-
- if (childdev) {
- usb_lock_device(childdev);
- ret = usb_device_dump(buffer, nbytes, skip_bytes,
- file_offset, childdev, bus,
- level + 1, chix, ++cnt);
- usb_unlock_device(childdev);
- if (ret == -EFAULT)
- return total_written;
- total_written += ret;
- }
- }
- return total_written;
-}
-
-static ssize_t usb_device_read(struct file *file, char __user *buf,
- size_t nbytes, loff_t *ppos)
-{
- struct usb_bus *bus;
- ssize_t ret, total_written = 0;
- loff_t skip_bytes = *ppos;
-
- if (*ppos < 0)
- return -EINVAL;
- if (nbytes <= 0)
- return 0;
- if (!access_ok(VERIFY_WRITE, buf, nbytes))
- return -EFAULT;
-
- mutex_lock(&usb_bus_list_lock);
- /* print devices for all busses */
- list_for_each_entry(bus, &usb_bus_list, bus_list) {
- /* recurse through all children of the root hub */
- if (!bus->root_hub)
- continue;
- usb_lock_device(bus->root_hub);
- ret = usb_device_dump(&buf, &nbytes, &skip_bytes, ppos,
- bus->root_hub, bus, 0, 0, 0);
- usb_unlock_device(bus->root_hub);
- if (ret < 0) {
- mutex_unlock(&usb_bus_list_lock);
- return ret;
- }
- total_written += ret;
- }
- mutex_unlock(&usb_bus_list_lock);
- return total_written;
-}
-
-/* Kernel lock for "lastev" protection */
-static unsigned int usb_device_poll(struct file *file,
- struct poll_table_struct *wait)
-{
- unsigned int event_count;
-
- poll_wait(file, &device_event.wait, wait);
-
- event_count = atomic_read(&device_event.count);
- if (file->f_version != event_count) {
- file->f_version = event_count;
- return POLLIN | POLLRDNORM;
- }
-
- return 0;
-}
-
-static loff_t usb_device_lseek(struct file *file, loff_t offset, int orig)
-{
- loff_t ret;
-
- mutex_lock(&file->f_dentry->d_inode->i_mutex);
-
- switch (orig) {
- case 0:
- file->f_pos = offset;
- ret = file->f_pos;
- break;
- case 1:
- file->f_pos += offset;
- ret = file->f_pos;
- break;
- case 2:
- default:
- ret = -EINVAL;
- }
-
- mutex_unlock(&file->f_dentry->d_inode->i_mutex);
- return ret;
-}
-
-const struct file_operations usbfs_devices_fops = {
- .llseek = usb_device_lseek,
- .read = usb_device_read,
- .poll = usb_device_poll,
-};
diff --git a/ANDROID_3.4.5/drivers/usb/core/devio.c b/ANDROID_3.4.5/drivers/usb/core/devio.c
deleted file mode 100644
index 4e577728..00000000
--- a/ANDROID_3.4.5/drivers/usb/core/devio.c
+++ /dev/null
@@ -1,2181 +0,0 @@
-/*****************************************************************************/
-
-/*
- * devio.c -- User space communication with USB devices.
- *
- * Copyright (C) 1999-2000 Thomas Sailer (sailer@ife.ee.ethz.ch)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * This file implements the usbfs/x/y files, where
- * x is the bus number and y the device number.
- *
- * It allows user space programs/"drivers" to communicate directly
- * with USB devices without intervening kernel driver.
- *
- * Revision history
- * 22.12.1999 0.1 Initial release (split from proc_usb.c)
- * 04.01.2000 0.2 Turned into its own filesystem
- * 30.09.2005 0.3 Fix user-triggerable oops in async URB delivery
- * (CAN-2005-3055)
- */
-
-/*****************************************************************************/
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include /* for usbcore internals */
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "usb.h"
-
-#define USB_MAXBUS 64
-#define USB_DEVICE_MAX USB_MAXBUS * 128
-
-/* Mutual exclusion for removal, open, and release */
-DEFINE_MUTEX(usbfs_mutex);
-
-struct dev_state {
- struct list_head list; /* state list */
- struct usb_device *dev;
- struct file *file;
- spinlock_t lock; /* protects the async urb lists */
- struct list_head async_pending;
- struct list_head async_completed;
- wait_queue_head_t wait; /* wake up if a request completed */
- unsigned int discsignr;
- struct pid *disc_pid;
- const struct cred *cred;
- void __user *disccontext;
- unsigned long ifclaimed;
- u32 secid;
- u32 disabled_bulk_eps;
-};
-
-struct async {
- struct list_head asynclist;
- struct dev_state *ps;
- struct pid *pid;
- const struct cred *cred;
- unsigned int signr;
- unsigned int ifnum;
- void __user *userbuffer;
- void __user *userurb;
- struct urb *urb;
- unsigned int mem_usage;
- int status;
- u32 secid;
- u8 bulk_addr;
- u8 bulk_status;
-};
-
-static bool usbfs_snoop;
-module_param(usbfs_snoop, bool, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(usbfs_snoop, "true to log all usbfs traffic");
-
-#define snoop(dev, format, arg...) \
- do { \
- if (usbfs_snoop) \
- dev_info(dev , format , ## arg); \
- } while (0)
-
-enum snoop_when {
- SUBMIT, COMPLETE
-};
-
-#define USB_DEVICE_DEV MKDEV(USB_DEVICE_MAJOR, 0)
-
-/* Limit on the total amount of memory we can allocate for transfers */
-static unsigned usbfs_memory_mb = 16;
-module_param(usbfs_memory_mb, uint, 0644);
-MODULE_PARM_DESC(usbfs_memory_mb,
- "maximum MB allowed for usbfs buffers (0 = no limit)");
-
-/* Hard limit, necessary to avoid aithmetic overflow */
-#define USBFS_XFER_MAX (UINT_MAX / 2 - 1000000)
-
-static atomic_t usbfs_memory_usage; /* Total memory currently allocated */
-
-/* Check whether it's okay to allocate more memory for a transfer */
-static int usbfs_increase_memory_usage(unsigned amount)
-{
- unsigned lim;
-
- /*
- * Convert usbfs_memory_mb to bytes, avoiding overflows.
- * 0 means use the hard limit (effectively unlimited).
- */
- lim = ACCESS_ONCE(usbfs_memory_mb);
- if (lim == 0 || lim > (USBFS_XFER_MAX >> 20))
- lim = USBFS_XFER_MAX;
- else
- lim <<= 20;
-
- atomic_add(amount, &usbfs_memory_usage);
- if (atomic_read(&usbfs_memory_usage) <= lim)
- return 0;
- atomic_sub(amount, &usbfs_memory_usage);
- return -ENOMEM;
-}
-
-/* Memory for a transfer is being deallocated */
-static void usbfs_decrease_memory_usage(unsigned amount)
-{
- atomic_sub(amount, &usbfs_memory_usage);
-}
-
-static int connected(struct dev_state *ps)
-{
- return (!list_empty(&ps->list) &&
- ps->dev->state != USB_STATE_NOTATTACHED);
-}
-
-static loff_t usbdev_lseek(struct file *file, loff_t offset, int orig)
-{
- loff_t ret;
-
- mutex_lock(&file->f_dentry->d_inode->i_mutex);
-
- switch (orig) {
- case 0:
- file->f_pos = offset;
- ret = file->f_pos;
- break;
- case 1:
- file->f_pos += offset;
- ret = file->f_pos;
- break;
- case 2:
- default:
- ret = -EINVAL;
- }
-
- mutex_unlock(&file->f_dentry->d_inode->i_mutex);
- return ret;
-}
-
-static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
- loff_t *ppos)
-{
- struct dev_state *ps = file->private_data;
- struct usb_device *dev = ps->dev;
- ssize_t ret = 0;
- unsigned len;
- loff_t pos;
- int i;
-
- pos = *ppos;
- usb_lock_device(dev);
- if (!connected(ps)) {
- ret = -ENODEV;
- goto err;
- } else if (pos < 0) {
- ret = -EINVAL;
- goto err;
- }
-
- if (pos < sizeof(struct usb_device_descriptor)) {
- /* 18 bytes - fits on the stack */
- struct usb_device_descriptor temp_desc;
-
- memcpy(&temp_desc, &dev->descriptor, sizeof(dev->descriptor));
- le16_to_cpus(&temp_desc.bcdUSB);
- le16_to_cpus(&temp_desc.idVendor);
- le16_to_cpus(&temp_desc.idProduct);
- le16_to_cpus(&temp_desc.bcdDevice);
-
- len = sizeof(struct usb_device_descriptor) - pos;
- if (len > nbytes)
- len = nbytes;
- if (copy_to_user(buf, ((char *)&temp_desc) + pos, len)) {
- ret = -EFAULT;
- goto err;
- }
-
- *ppos += len;
- buf += len;
- nbytes -= len;
- ret += len;
- }
-
- pos = sizeof(struct usb_device_descriptor);
- for (i = 0; nbytes && i < dev->descriptor.bNumConfigurations; i++) {
- struct usb_config_descriptor *config =
- (struct usb_config_descriptor *)dev->rawdescriptors[i];
- unsigned int length = le16_to_cpu(config->wTotalLength);
-
- if (*ppos < pos + length) {
-
- /* The descriptor may claim to be longer than it
- * really is. Here is the actual allocated length. */
- unsigned alloclen =
- le16_to_cpu(dev->config[i].desc.wTotalLength);
-
- len = length - (*ppos - pos);
- if (len > nbytes)
- len = nbytes;
-
- /* Simply don't write (skip over) unallocated parts */
- if (alloclen > (*ppos - pos)) {
- alloclen -= (*ppos - pos);
- if (copy_to_user(buf,
- dev->rawdescriptors[i] + (*ppos - pos),
- min(len, alloclen))) {
- ret = -EFAULT;
- goto err;
- }
- }
-
- *ppos += len;
- buf += len;
- nbytes -= len;
- ret += len;
- }
-
- pos += length;
- }
-
-err:
- usb_unlock_device(dev);
- return ret;
-}
-
-/*
- * async list handling
- */
-
-static struct async *alloc_async(unsigned int numisoframes)
-{
- struct async *as;
-
- as = kzalloc(sizeof(struct async), GFP_KERNEL);
- if (!as)
- return NULL;
- as->urb = usb_alloc_urb(numisoframes, GFP_KERNEL);
- if (!as->urb) {
- kfree(as);
- return NULL;
- }
- return as;
-}
-
-static void free_async(struct async *as)
-{
- put_pid(as->pid);
- if (as->cred)
- put_cred(as->cred);
- kfree(as->urb->transfer_buffer);
- kfree(as->urb->setup_packet);
- usb_free_urb(as->urb);
- usbfs_decrease_memory_usage(as->mem_usage);
- kfree(as);
-}
-
-static void async_newpending(struct async *as)
-{
- struct dev_state *ps = as->ps;
- unsigned long flags;
-
- spin_lock_irqsave(&ps->lock, flags);
- list_add_tail(&as->asynclist, &ps->async_pending);
- spin_unlock_irqrestore(&ps->lock, flags);
-}
-
-static void async_removepending(struct async *as)
-{
- struct dev_state *ps = as->ps;
- unsigned long flags;
-
- spin_lock_irqsave(&ps->lock, flags);
- list_del_init(&as->asynclist);
- spin_unlock_irqrestore(&ps->lock, flags);
-}
-
-static struct async *async_getcompleted(struct dev_state *ps)
-{
- unsigned long flags;
- struct async *as = NULL;
-
- spin_lock_irqsave(&ps->lock, flags);
- if (!list_empty(&ps->async_completed)) {
- as = list_entry(ps->async_completed.next, struct async,
- asynclist);
- list_del_init(&as->asynclist);
- }
- spin_unlock_irqrestore(&ps->lock, flags);
- return as;
-}
-
-static struct async *async_getpending(struct dev_state *ps,
- void __user *userurb)
-{
- struct async *as;
-
- list_for_each_entry(as, &ps->async_pending, asynclist)
- if (as->userurb == userurb) {
- list_del_init(&as->asynclist);
- return as;
- }
-
- return NULL;
-}
-
-static void snoop_urb(struct usb_device *udev,
- void __user *userurb, int pipe, unsigned length,
- int timeout_or_status, enum snoop_when when,
- unsigned char *data, unsigned data_len)
-{
- static const char *types[] = {"isoc", "int", "ctrl", "bulk"};
- static const char *dirs[] = {"out", "in"};
- int ep;
- const char *t, *d;
-
- if (!usbfs_snoop)
- return;
-
- ep = usb_pipeendpoint(pipe);
- t = types[usb_pipetype(pipe)];
- d = dirs[!!usb_pipein(pipe)];
-
- if (userurb) { /* Async */
- if (when == SUBMIT)
- dev_info(&udev->dev, "userurb %p, ep%d %s-%s, "
- "length %u\n",
- userurb, ep, t, d, length);
- else
- dev_info(&udev->dev, "userurb %p, ep%d %s-%s, "
- "actual_length %u status %d\n",
- userurb, ep, t, d, length,
- timeout_or_status);
- } else {
- if (when == SUBMIT)
- dev_info(&udev->dev, "ep%d %s-%s, length %u, "
- "timeout %d\n",
- ep, t, d, length, timeout_or_status);
- else
- dev_info(&udev->dev, "ep%d %s-%s, actual_length %u, "
- "status %d\n",
- ep, t, d, length, timeout_or_status);
- }
-
- if (data && data_len > 0) {
- print_hex_dump(KERN_DEBUG, "data: ", DUMP_PREFIX_NONE, 32, 1,
- data, data_len, 1);
- }
-}
-
-#define AS_CONTINUATION 1
-#define AS_UNLINK 2
-
-static void cancel_bulk_urbs(struct dev_state *ps, unsigned bulk_addr)
-__releases(ps->lock)
-__acquires(ps->lock)
-{
- struct urb *urb;
- struct async *as;
-
- /* Mark all the pending URBs that match bulk_addr, up to but not
- * including the first one without AS_CONTINUATION. If such an
- * URB is encountered then a new transfer has already started so
- * the endpoint doesn't need to be disabled; otherwise it does.
- */
- list_for_each_entry(as, &ps->async_pending, asynclist) {
- if (as->bulk_addr == bulk_addr) {
- if (as->bulk_status != AS_CONTINUATION)
- goto rescan;
- as->bulk_status = AS_UNLINK;
- as->bulk_addr = 0;
- }
- }
- ps->disabled_bulk_eps |= (1 << bulk_addr);
-
- /* Now carefully unlink all the marked pending URBs */
- rescan:
- list_for_each_entry(as, &ps->async_pending, asynclist) {
- if (as->bulk_status == AS_UNLINK) {
- as->bulk_status = 0; /* Only once */
- urb = as->urb;
- usb_get_urb(urb);
- spin_unlock(&ps->lock); /* Allow completions */
- usb_unlink_urb(urb);
- usb_put_urb(urb);
- spin_lock(&ps->lock);
- goto rescan;
- }
- }
-}
-
-static void async_completed(struct urb *urb)
-{
- struct async *as = urb->context;
- struct dev_state *ps = as->ps;
- struct siginfo sinfo;
- struct pid *pid = NULL;
- u32 secid = 0;
- const struct cred *cred = NULL;
- int signr;
-
- spin_lock(&ps->lock);
- list_move_tail(&as->asynclist, &ps->async_completed);
- as->status = urb->status;
- signr = as->signr;
- if (signr) {
- sinfo.si_signo = as->signr;
- sinfo.si_errno = as->status;
- sinfo.si_code = SI_ASYNCIO;
- sinfo.si_addr = as->userurb;
- pid = get_pid(as->pid);
- cred = get_cred(as->cred);
- secid = as->secid;
- }
- snoop(&urb->dev->dev, "urb complete\n");
- snoop_urb(urb->dev, as->userurb, urb->pipe, urb->actual_length,
- as->status, COMPLETE,
- ((urb->transfer_flags & URB_DIR_MASK) == USB_DIR_OUT) ?
- NULL : urb->transfer_buffer, urb->actual_length);
- if (as->status < 0 && as->bulk_addr && as->status != -ECONNRESET &&
- as->status != -ENOENT)
- cancel_bulk_urbs(ps, as->bulk_addr);
- spin_unlock(&ps->lock);
-
- if (signr) {
- kill_pid_info_as_cred(sinfo.si_signo, &sinfo, pid, cred, secid);
- put_pid(pid);
- put_cred(cred);
- }
-
- wake_up(&ps->wait);
-}
-
-static void destroy_async(struct dev_state *ps, struct list_head *list)
-{
- struct urb *urb;
- struct async *as;
- unsigned long flags;
-
- spin_lock_irqsave(&ps->lock, flags);
- while (!list_empty(list)) {
- as = list_entry(list->next, struct async, asynclist);
- list_del_init(&as->asynclist);
- urb = as->urb;
- usb_get_urb(urb);
-
- /* drop the spinlock so the completion handler can run */
- spin_unlock_irqrestore(&ps->lock, flags);
- usb_kill_urb(urb);
- usb_put_urb(urb);
- spin_lock_irqsave(&ps->lock, flags);
- }
- spin_unlock_irqrestore(&ps->lock, flags);
-}
-
-static void destroy_async_on_interface(struct dev_state *ps,
- unsigned int ifnum)
-{
- struct list_head *p, *q, hitlist;
- unsigned long flags;
-
- INIT_LIST_HEAD(&hitlist);
- spin_lock_irqsave(&ps->lock, flags);
- list_for_each_safe(p, q, &ps->async_pending)
- if (ifnum == list_entry(p, struct async, asynclist)->ifnum)
- list_move_tail(p, &hitlist);
- spin_unlock_irqrestore(&ps->lock, flags);
- destroy_async(ps, &hitlist);
-}
-
-static void destroy_all_async(struct dev_state *ps)
-{
- destroy_async(ps, &ps->async_pending);
-}
-
-/*
- * interface claims are made only at the request of user level code,
- * which can also release them (explicitly or by closing files).
- * they're also undone when devices disconnect.
- */
-
-static int driver_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- return -ENODEV;
-}
-
-static void driver_disconnect(struct usb_interface *intf)
-{
- struct dev_state *ps = usb_get_intfdata(intf);
- unsigned int ifnum = intf->altsetting->desc.bInterfaceNumber;
-
- if (!ps)
- return;
-
- /* NOTE: this relies on usbcore having canceled and completed
- * all pending I/O requests; 2.6 does that.
- */
-
- if (likely(ifnum < 8*sizeof(ps->ifclaimed)))
- clear_bit(ifnum, &ps->ifclaimed);
- else
- dev_warn(&intf->dev, "interface number %u out of range\n",
- ifnum);
-
- usb_set_intfdata(intf, NULL);
-
- /* force async requests to complete */
- destroy_async_on_interface(ps, ifnum);
-}
-
-/* The following routines are merely placeholders. There is no way
- * to inform a user task about suspend or resumes.
- */
-static int driver_suspend(struct usb_interface *intf, pm_message_t msg)
-{
- return 0;
-}
-
-static int driver_resume(struct usb_interface *intf)
-{
- return 0;
-}
-
-struct usb_driver usbfs_driver = {
- .name = "usbfs",
- .probe = driver_probe,
- .disconnect = driver_disconnect,
- .suspend = driver_suspend,
- .resume = driver_resume,
-};
-
-static int claimintf(struct dev_state *ps, unsigned int ifnum)
-{
- struct usb_device *dev = ps->dev;
- struct usb_interface *intf;
- int err;
-
- if (ifnum >= 8*sizeof(ps->ifclaimed))
- return -EINVAL;
- /* already claimed */
- if (test_bit(ifnum, &ps->ifclaimed))
- return 0;
-
- intf = usb_ifnum_to_if(dev, ifnum);
- if (!intf)
- err = -ENOENT;
- else
- err = usb_driver_claim_interface(&usbfs_driver, intf, ps);
- if (err == 0)
- set_bit(ifnum, &ps->ifclaimed);
- return err;
-}
-
-static int releaseintf(struct dev_state *ps, unsigned int ifnum)
-{
- struct usb_device *dev;
- struct usb_interface *intf;
- int err;
-
- err = -EINVAL;
- if (ifnum >= 8*sizeof(ps->ifclaimed))
- return err;
- dev = ps->dev;
- intf = usb_ifnum_to_if(dev, ifnum);
- if (!intf)
- err = -ENOENT;
- else if (test_and_clear_bit(ifnum, &ps->ifclaimed)) {
- usb_driver_release_interface(&usbfs_driver, intf);
- err = 0;
- }
- return err;
-}
-
-static int checkintf(struct dev_state *ps, unsigned int ifnum)
-{
- if (ps->dev->state != USB_STATE_CONFIGURED)
- return -EHOSTUNREACH;
- if (ifnum >= 8*sizeof(ps->ifclaimed))
- return -EINVAL;
- if (test_bit(ifnum, &ps->ifclaimed))
- return 0;
- /* if not yet claimed, claim it for the driver */
- dev_warn(&ps->dev->dev, "usbfs: process %d (%s) did not claim "
- "interface %u before use\n", task_pid_nr(current),
- current->comm, ifnum);
- return claimintf(ps, ifnum);
-}
-
-static int findintfep(struct usb_device *dev, unsigned int ep)
-{
- unsigned int i, j, e;
- struct usb_interface *intf;
- struct usb_host_interface *alts;
- struct usb_endpoint_descriptor *endpt;
-
- if (ep & ~(USB_DIR_IN|0xf))
- return -EINVAL;
- if (!dev->actconfig)
- return -ESRCH;
- for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) {
- intf = dev->actconfig->interface[i];
- for (j = 0; j < intf->num_altsetting; j++) {
- alts = &intf->altsetting[j];
- for (e = 0; e < alts->desc.bNumEndpoints; e++) {
- endpt = &alts->endpoint[e].desc;
- if (endpt->bEndpointAddress == ep)
- return alts->desc.bInterfaceNumber;
- }
- }
- }
- return -ENOENT;
-}
-
-static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype,
- unsigned int request, unsigned int index)
-{
- int ret = 0;
- struct usb_host_interface *alt_setting;
-
- if (ps->dev->state != USB_STATE_UNAUTHENTICATED
- && ps->dev->state != USB_STATE_ADDRESS
- && ps->dev->state != USB_STATE_CONFIGURED)
- return -EHOSTUNREACH;
- if (USB_TYPE_VENDOR == (USB_TYPE_MASK & requesttype))
- return 0;
-
- /*
- * check for the special corner case 'get_device_id' in the printer
- * class specification, where wIndex is (interface << 8 | altsetting)
- * instead of just interface
- */
- if (requesttype == 0xa1 && request == 0) {
- alt_setting = usb_find_alt_setting(ps->dev->actconfig,
- index >> 8, index & 0xff);
- if (alt_setting
- && alt_setting->desc.bInterfaceClass == USB_CLASS_PRINTER)
- index >>= 8;
- }
-
- index &= 0xff;
- switch (requesttype & USB_RECIP_MASK) {
- case USB_RECIP_ENDPOINT:
- ret = findintfep(ps->dev, index);
- if (ret >= 0)
- ret = checkintf(ps, ret);
- break;
-
- case USB_RECIP_INTERFACE:
- ret = checkintf(ps, index);
- break;
- }
- return ret;
-}
-
-static int match_devt(struct device *dev, void *data)
-{
- return dev->devt == (dev_t) (unsigned long) data;
-}
-
-static struct usb_device *usbdev_lookup_by_devt(dev_t devt)
-{
- struct device *dev;
-
- dev = bus_find_device(&usb_bus_type, NULL,
- (void *) (unsigned long) devt, match_devt);
- if (!dev)
- return NULL;
- return container_of(dev, struct usb_device, dev);
-}
-
-/*
- * file operations
- */
-static int usbdev_open(struct inode *inode, struct file *file)
-{
- struct usb_device *dev = NULL;
- struct dev_state *ps;
- int ret;
-
- ret = -ENOMEM;
- ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL);
- if (!ps)
- goto out_free_ps;
-
- ret = -ENODEV;
-
- /* Protect against simultaneous removal or release */
- mutex_lock(&usbfs_mutex);
-
- /* usbdev device-node */
- if (imajor(inode) == USB_DEVICE_MAJOR)
- dev = usbdev_lookup_by_devt(inode->i_rdev);
-
-#ifdef CONFIG_USB_DEVICEFS
- /* procfs file */
- if (!dev) {
- dev = inode->i_private;
- if (dev && dev->usbfs_dentry &&
- dev->usbfs_dentry->d_inode == inode)
- usb_get_dev(dev);
- else
- dev = NULL;
- }
-#endif
- mutex_unlock(&usbfs_mutex);
-
- if (!dev)
- goto out_free_ps;
-
- usb_lock_device(dev);
- if (dev->state == USB_STATE_NOTATTACHED)
- goto out_unlock_device;
-
- ret = usb_autoresume_device(dev);
- if (ret)
- goto out_unlock_device;
-
- ps->dev = dev;
- ps->file = file;
- spin_lock_init(&ps->lock);
- INIT_LIST_HEAD(&ps->list);
- INIT_LIST_HEAD(&ps->async_pending);
- INIT_LIST_HEAD(&ps->async_completed);
- init_waitqueue_head(&ps->wait);
- ps->discsignr = 0;
- ps->disc_pid = get_pid(task_pid(current));
- ps->cred = get_current_cred();
- ps->disccontext = NULL;
- ps->ifclaimed = 0;
- security_task_getsecid(current, &ps->secid);
- smp_wmb();
- list_add_tail(&ps->list, &dev->filelist);
- file->private_data = ps;
- usb_unlock_device(dev);
- snoop(&dev->dev, "opened by process %d: %s\n", task_pid_nr(current),
- current->comm);
- return ret;
-
- out_unlock_device:
- usb_unlock_device(dev);
- usb_put_dev(dev);
- out_free_ps:
- kfree(ps);
- return ret;
-}
-
-static int usbdev_release(struct inode *inode, struct file *file)
-{
- struct dev_state *ps = file->private_data;
- struct usb_device *dev = ps->dev;
- unsigned int ifnum;
- struct async *as;
-
- usb_lock_device(dev);
- usb_hub_release_all_ports(dev, ps);
-
- list_del_init(&ps->list);
-
- for (ifnum = 0; ps->ifclaimed && ifnum < 8*sizeof(ps->ifclaimed);
- ifnum++) {
- if (test_bit(ifnum, &ps->ifclaimed))
- releaseintf(ps, ifnum);
- }
- destroy_all_async(ps);
- usb_autosuspend_device(dev);
- usb_unlock_device(dev);
- usb_put_dev(dev);
- put_pid(ps->disc_pid);
- put_cred(ps->cred);
-
- as = async_getcompleted(ps);
- while (as) {
- free_async(as);
- as = async_getcompleted(ps);
- }
- kfree(ps);
- return 0;
-}
-
-static int proc_control(struct dev_state *ps, void __user *arg)
-{
- struct usb_device *dev = ps->dev;
- struct usbdevfs_ctrltransfer ctrl;
- unsigned int tmo;
- unsigned char *tbuf;
- unsigned wLength;
- int i, pipe, ret;
-
- if (copy_from_user(&ctrl, arg, sizeof(ctrl)))
- return -EFAULT;
- ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.bRequest,
- ctrl.wIndex);
- if (ret)
- return ret;
- wLength = ctrl.wLength; /* To suppress 64k PAGE_SIZE warning */
- if (wLength > PAGE_SIZE)
- return -EINVAL;
- ret = usbfs_increase_memory_usage(PAGE_SIZE + sizeof(struct urb) +
- sizeof(struct usb_ctrlrequest));
- if (ret)
- return ret;
- tbuf = (unsigned char *)__get_free_page(GFP_KERNEL);
- if (!tbuf) {
- ret = -ENOMEM;
- goto done;
- }
- tmo = ctrl.timeout;
- snoop(&dev->dev, "control urb: bRequestType=%02x "
- "bRequest=%02x wValue=%04x "
- "wIndex=%04x wLength=%04x\n",
- ctrl.bRequestType, ctrl.bRequest,
- __le16_to_cpup(&ctrl.wValue),
- __le16_to_cpup(&ctrl.wIndex),
- __le16_to_cpup(&ctrl.wLength));
- if (ctrl.bRequestType & 0x80) {
- if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data,
- ctrl.wLength)) {
- ret = -EINVAL;
- goto done;
- }
- pipe = usb_rcvctrlpipe(dev, 0);
- snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT, NULL, 0);
-
- usb_unlock_device(dev);
- i = usb_control_msg(dev, pipe, ctrl.bRequest,
- ctrl.bRequestType, ctrl.wValue, ctrl.wIndex,
- tbuf, ctrl.wLength, tmo);
- usb_lock_device(dev);
- snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE,
- tbuf, max(i, 0));
- if ((i > 0) && ctrl.wLength) {
- if (copy_to_user(ctrl.data, tbuf, i)) {
- ret = -EFAULT;
- goto done;
- }
- }
- } else {
- if (ctrl.wLength) {
- if (copy_from_user(tbuf, ctrl.data, ctrl.wLength)) {
- ret = -EFAULT;
- goto done;
- }
- }
- pipe = usb_sndctrlpipe(dev, 0);
- snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT,
- tbuf, ctrl.wLength);
-
- usb_unlock_device(dev);
- i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest,
- ctrl.bRequestType, ctrl.wValue, ctrl.wIndex,
- tbuf, ctrl.wLength, tmo);
- usb_lock_device(dev);
- snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE, NULL, 0);
- }
- if (i < 0 && i != -EPIPE) {
- dev_printk(KERN_DEBUG, &dev->dev, "usbfs: USBDEVFS_CONTROL "
- "failed cmd %s rqt %u rq %u len %u ret %d\n",
- current->comm, ctrl.bRequestType, ctrl.bRequest,
- ctrl.wLength, i);
- }
- ret = i;
- done:
- free_page((unsigned long) tbuf);
- usbfs_decrease_memory_usage(PAGE_SIZE + sizeof(struct urb) +
- sizeof(struct usb_ctrlrequest));
- return ret;
-}
-
-static int proc_bulk(struct dev_state *ps, void __user *arg)
-{
- struct usb_device *dev = ps->dev;
- struct usbdevfs_bulktransfer bulk;
- unsigned int tmo, len1, pipe;
- int len2;
- unsigned char *tbuf;
- int i, ret;
-
- if (copy_from_user(&bulk, arg, sizeof(bulk)))
- return -EFAULT;
- ret = findintfep(ps->dev, bulk.ep);
- if (ret < 0)
- return ret;
- ret = checkintf(ps, ret);
- if (ret)
- return ret;
- if (bulk.ep & USB_DIR_IN)
- pipe = usb_rcvbulkpipe(dev, bulk.ep & 0x7f);
- else
- pipe = usb_sndbulkpipe(dev, bulk.ep & 0x7f);
- if (!usb_maxpacket(dev, pipe, !(bulk.ep & USB_DIR_IN)))
- return -EINVAL;
- len1 = bulk.len;
- if (len1 >= USBFS_XFER_MAX)
- return -EINVAL;
- ret = usbfs_increase_memory_usage(len1 + sizeof(struct urb));
- if (ret)
- return ret;
- if (!(tbuf = kmalloc(len1, GFP_KERNEL))) {
- ret = -ENOMEM;
- goto done;
- }
- tmo = bulk.timeout;
- if (bulk.ep & 0x80) {
- if (len1 && !access_ok(VERIFY_WRITE, bulk.data, len1)) {
- ret = -EINVAL;
- goto done;
- }
- snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, NULL, 0);
-
- usb_unlock_device(dev);
- i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo);
- usb_lock_device(dev);
- snoop_urb(dev, NULL, pipe, len2, i, COMPLETE, tbuf, len2);
-
- if (!i && len2) {
- if (copy_to_user(bulk.data, tbuf, len2)) {
- ret = -EFAULT;
- goto done;
- }
- }
- } else {
- if (len1) {
- if (copy_from_user(tbuf, bulk.data, len1)) {
- ret = -EFAULT;
- goto done;
- }
- }
- snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, tbuf, len1);
-
- usb_unlock_device(dev);
- i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo);
- usb_lock_device(dev);
- snoop_urb(dev, NULL, pipe, len2, i, COMPLETE, NULL, 0);
- }
- ret = (i < 0 ? i : len2);
- done:
- kfree(tbuf);
- usbfs_decrease_memory_usage(len1 + sizeof(struct urb));
- return ret;
-}
-
-static int proc_resetep(struct dev_state *ps, void __user *arg)
-{
- unsigned int ep;
- int ret;
-
- if (get_user(ep, (unsigned int __user *)arg))
- return -EFAULT;
- ret = findintfep(ps->dev, ep);
- if (ret < 0)
- return ret;
- ret = checkintf(ps, ret);
- if (ret)
- return ret;
- usb_reset_endpoint(ps->dev, ep);
- return 0;
-}
-
-static int proc_clearhalt(struct dev_state *ps, void __user *arg)
-{
- unsigned int ep;
- int pipe;
- int ret;
-
- if (get_user(ep, (unsigned int __user *)arg))
- return -EFAULT;
- ret = findintfep(ps->dev, ep);
- if (ret < 0)
- return ret;
- ret = checkintf(ps, ret);
- if (ret)
- return ret;
- if (ep & USB_DIR_IN)
- pipe = usb_rcvbulkpipe(ps->dev, ep & 0x7f);
- else
- pipe = usb_sndbulkpipe(ps->dev, ep & 0x7f);
-
- return usb_clear_halt(ps->dev, pipe);
-}
-
-static int proc_getdriver(struct dev_state *ps, void __user *arg)
-{
- struct usbdevfs_getdriver gd;
- struct usb_interface *intf;
- int ret;
-
- if (copy_from_user(&gd, arg, sizeof(gd)))
- return -EFAULT;
- intf = usb_ifnum_to_if(ps->dev, gd.interface);
- if (!intf || !intf->dev.driver)
- ret = -ENODATA;
- else {
- strncpy(gd.driver, intf->dev.driver->name,
- sizeof(gd.driver));
- ret = (copy_to_user(arg, &gd, sizeof(gd)) ? -EFAULT : 0);
- }
- return ret;
-}
-
-static int proc_connectinfo(struct dev_state *ps, void __user *arg)
-{
- struct usbdevfs_connectinfo ci = {
- .devnum = ps->dev->devnum,
- .slow = ps->dev->speed == USB_SPEED_LOW
- };
-
- if (copy_to_user(arg, &ci, sizeof(ci)))
- return -EFAULT;
- return 0;
-}
-
-static int proc_resetdevice(struct dev_state *ps)
-{
- return usb_reset_device(ps->dev);
-}
-
-static int proc_setintf(struct dev_state *ps, void __user *arg)
-{
- struct usbdevfs_setinterface setintf;
- int ret;
-
- if (copy_from_user(&setintf, arg, sizeof(setintf)))
- return -EFAULT;
- if ((ret = checkintf(ps, setintf.interface)))
- return ret;
- return usb_set_interface(ps->dev, setintf.interface,
- setintf.altsetting);
-}
-
-static int proc_setconfig(struct dev_state *ps, void __user *arg)
-{
- int u;
- int status = 0;
- struct usb_host_config *actconfig;
-
- if (get_user(u, (int __user *)arg))
- return -EFAULT;
-
- actconfig = ps->dev->actconfig;
-
- /* Don't touch the device if any interfaces are claimed.
- * It could interfere with other drivers' operations, and if
- * an interface is claimed by usbfs it could easily deadlock.
- */
- if (actconfig) {
- int i;
-
- for (i = 0; i < actconfig->desc.bNumInterfaces; ++i) {
- if (usb_interface_claimed(actconfig->interface[i])) {
- dev_warn(&ps->dev->dev,
- "usbfs: interface %d claimed by %s "
- "while '%s' sets config #%d\n",
- actconfig->interface[i]
- ->cur_altsetting
- ->desc.bInterfaceNumber,
- actconfig->interface[i]
- ->dev.driver->name,
- current->comm, u);
- status = -EBUSY;
- break;
- }
- }
- }
-
- /* SET_CONFIGURATION is often abused as a "cheap" driver reset,
- * so avoid usb_set_configuration()'s kick to sysfs
- */
- if (status == 0) {
- if (actconfig && actconfig->desc.bConfigurationValue == u)
- status = usb_reset_configuration(ps->dev);
- else
- status = usb_set_configuration(ps->dev, u);
- }
-
- return status;
-}
-
-static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
- struct usbdevfs_iso_packet_desc __user *iso_frame_desc,
- void __user *arg)
-{
- struct usbdevfs_iso_packet_desc *isopkt = NULL;
- struct usb_host_endpoint *ep;
- struct async *as = NULL;
- struct usb_ctrlrequest *dr = NULL;
- unsigned int u, totlen, isofrmlen;
- int ret, ifnum = -1;
- int is_in;
-
- if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP |
- USBDEVFS_URB_SHORT_NOT_OK |
- USBDEVFS_URB_BULK_CONTINUATION |
- USBDEVFS_URB_NO_FSBR |
- USBDEVFS_URB_ZERO_PACKET |
- USBDEVFS_URB_NO_INTERRUPT))
- return -EINVAL;
- if (uurb->buffer_length > 0 && !uurb->buffer)
- return -EINVAL;
- if (!(uurb->type == USBDEVFS_URB_TYPE_CONTROL &&
- (uurb->endpoint & ~USB_ENDPOINT_DIR_MASK) == 0)) {
- ifnum = findintfep(ps->dev, uurb->endpoint);
- if (ifnum < 0)
- return ifnum;
- ret = checkintf(ps, ifnum);
- if (ret)
- return ret;
- }
- if ((uurb->endpoint & USB_ENDPOINT_DIR_MASK) != 0) {
- is_in = 1;
- ep = ps->dev->ep_in[uurb->endpoint & USB_ENDPOINT_NUMBER_MASK];
- } else {
- is_in = 0;
- ep = ps->dev->ep_out[uurb->endpoint & USB_ENDPOINT_NUMBER_MASK];
- }
- if (!ep)
- return -ENOENT;
-
- u = 0;
- switch(uurb->type) {
- case USBDEVFS_URB_TYPE_CONTROL:
- if (!usb_endpoint_xfer_control(&ep->desc))
- return -EINVAL;
- /* min 8 byte setup packet */
- if (uurb->buffer_length < 8)
- return -EINVAL;
- dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
- if (!dr)
- return -ENOMEM;
- if (copy_from_user(dr, uurb->buffer, 8)) {
- ret = -EFAULT;
- goto error;
- }
- if (uurb->buffer_length < (le16_to_cpup(&dr->wLength) + 8)) {
- ret = -EINVAL;
- goto error;
- }
- ret = check_ctrlrecip(ps, dr->bRequestType, dr->bRequest,
- le16_to_cpup(&dr->wIndex));
- if (ret)
- goto error;
- uurb->number_of_packets = 0;
- uurb->buffer_length = le16_to_cpup(&dr->wLength);
- uurb->buffer += 8;
- if ((dr->bRequestType & USB_DIR_IN) && uurb->buffer_length) {
- is_in = 1;
- uurb->endpoint |= USB_DIR_IN;
- } else {
- is_in = 0;
- uurb->endpoint &= ~USB_DIR_IN;
- }
- snoop(&ps->dev->dev, "control urb: bRequestType=%02x "
- "bRequest=%02x wValue=%04x "
- "wIndex=%04x wLength=%04x\n",
- dr->bRequestType, dr->bRequest,
- __le16_to_cpup(&dr->wValue),
- __le16_to_cpup(&dr->wIndex),
- __le16_to_cpup(&dr->wLength));
- u = sizeof(struct usb_ctrlrequest);
- break;
-
- case USBDEVFS_URB_TYPE_BULK:
- switch (usb_endpoint_type(&ep->desc)) {
- case USB_ENDPOINT_XFER_CONTROL:
- case USB_ENDPOINT_XFER_ISOC:
- return -EINVAL;
- case USB_ENDPOINT_XFER_INT:
- /* allow single-shot interrupt transfers */
- uurb->type = USBDEVFS_URB_TYPE_INTERRUPT;
- goto interrupt_urb;
- }
- uurb->number_of_packets = 0;
- break;
-
- case USBDEVFS_URB_TYPE_INTERRUPT:
- if (!usb_endpoint_xfer_int(&ep->desc))
- return -EINVAL;
- interrupt_urb:
- uurb->number_of_packets = 0;
- break;
-
- case USBDEVFS_URB_TYPE_ISO:
- /* arbitrary limit */
- if (uurb->number_of_packets < 1 ||
- uurb->number_of_packets > 128)
- return -EINVAL;
- if (!usb_endpoint_xfer_isoc(&ep->desc))
- return -EINVAL;
- isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) *
- uurb->number_of_packets;
- if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL)))
- return -ENOMEM;
- if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) {
- ret = -EFAULT;
- goto error;
- }
- for (totlen = u = 0; u < uurb->number_of_packets; u++) {
- /* arbitrary limit,
- * sufficient for USB 2.0 high-bandwidth iso */
- if (isopkt[u].length > 8192) {
- ret = -EINVAL;
- goto error;
- }
- totlen += isopkt[u].length;
- }
- u *= sizeof(struct usb_iso_packet_descriptor);
- uurb->buffer_length = totlen;
- break;
-
- default:
- return -EINVAL;
- }
-
- if (uurb->buffer_length >= USBFS_XFER_MAX) {
- ret = -EINVAL;
- goto error;
- }
- if (uurb->buffer_length > 0 &&
- !access_ok(is_in ? VERIFY_WRITE : VERIFY_READ,
- uurb->buffer, uurb->buffer_length)) {
- ret = -EFAULT;
- goto error;
- }
- as = alloc_async(uurb->number_of_packets);
- if (!as) {
- ret = -ENOMEM;
- goto error;
- }
- u += sizeof(struct async) + sizeof(struct urb) + uurb->buffer_length;
- ret = usbfs_increase_memory_usage(u);
- if (ret)
- goto error;
- as->mem_usage = u;
-
- if (uurb->buffer_length > 0) {
- as->urb->transfer_buffer = kmalloc(uurb->buffer_length,
- GFP_KERNEL);
- if (!as->urb->transfer_buffer) {
- ret = -ENOMEM;
- goto error;
- }
- /* Isochronous input data may end up being discontiguous
- * if some of the packets are short. Clear the buffer so
- * that the gaps don't leak kernel data to userspace.
- */
- if (is_in && uurb->type == USBDEVFS_URB_TYPE_ISO)
- memset(as->urb->transfer_buffer, 0,
- uurb->buffer_length);
- }
- as->urb->dev = ps->dev;
- as->urb->pipe = (uurb->type << 30) |
- __create_pipe(ps->dev, uurb->endpoint & 0xf) |
- (uurb->endpoint & USB_DIR_IN);
-
- /* This tedious sequence is necessary because the URB_* flags
- * are internal to the kernel and subject to change, whereas
- * the USBDEVFS_URB_* flags are a user API and must not be changed.
- */
- u = (is_in ? URB_DIR_IN : URB_DIR_OUT);
- if (uurb->flags & USBDEVFS_URB_ISO_ASAP)
- u |= URB_ISO_ASAP;
- if (uurb->flags & USBDEVFS_URB_SHORT_NOT_OK)
- u |= URB_SHORT_NOT_OK;
- if (uurb->flags & USBDEVFS_URB_NO_FSBR)
- u |= URB_NO_FSBR;
- if (uurb->flags & USBDEVFS_URB_ZERO_PACKET)
- u |= URB_ZERO_PACKET;
- if (uurb->flags & USBDEVFS_URB_NO_INTERRUPT)
- u |= URB_NO_INTERRUPT;
- as->urb->transfer_flags = u;
-
- as->urb->transfer_buffer_length = uurb->buffer_length;
- as->urb->setup_packet = (unsigned char *)dr;
- dr = NULL;
- as->urb->start_frame = uurb->start_frame;
- as->urb->number_of_packets = uurb->number_of_packets;
- if (uurb->type == USBDEVFS_URB_TYPE_ISO ||
- ps->dev->speed == USB_SPEED_HIGH)
- as->urb->interval = 1 << min(15, ep->desc.bInterval - 1);
- else
- as->urb->interval = ep->desc.bInterval;
- as->urb->context = as;
- as->urb->complete = async_completed;
- for (totlen = u = 0; u < uurb->number_of_packets; u++) {
- as->urb->iso_frame_desc[u].offset = totlen;
- as->urb->iso_frame_desc[u].length = isopkt[u].length;
- totlen += isopkt[u].length;
- }
- kfree(isopkt);
- isopkt = NULL;
- as->ps = ps;
- as->userurb = arg;
- if (is_in && uurb->buffer_length > 0)
- as->userbuffer = uurb->buffer;
- else
- as->userbuffer = NULL;
- as->signr = uurb->signr;
- as->ifnum = ifnum;
- as->pid = get_pid(task_pid(current));
- as->cred = get_current_cred();
- security_task_getsecid(current, &as->secid);
- if (!is_in && uurb->buffer_length > 0) {
- if (copy_from_user(as->urb->transfer_buffer, uurb->buffer,
- uurb->buffer_length)) {
- ret = -EFAULT;
- goto error;
- }
- }
- snoop_urb(ps->dev, as->userurb, as->urb->pipe,
- as->urb->transfer_buffer_length, 0, SUBMIT,
- is_in ? NULL : as->urb->transfer_buffer,
- uurb->buffer_length);
- async_newpending(as);
-
- if (usb_endpoint_xfer_bulk(&ep->desc)) {
- spin_lock_irq(&ps->lock);
-
- /* Not exactly the endpoint address; the direction bit is
- * shifted to the 0x10 position so that the value will be
- * between 0 and 31.
- */
- as->bulk_addr = usb_endpoint_num(&ep->desc) |
- ((ep->desc.bEndpointAddress & USB_ENDPOINT_DIR_MASK)
- >> 3);
-
- /* If this bulk URB is the start of a new transfer, re-enable
- * the endpoint. Otherwise mark it as a continuation URB.
- */
- if (uurb->flags & USBDEVFS_URB_BULK_CONTINUATION)
- as->bulk_status = AS_CONTINUATION;
- else
- ps->disabled_bulk_eps &= ~(1 << as->bulk_addr);
-
- /* Don't accept continuation URBs if the endpoint is
- * disabled because of an earlier error.
- */
- if (ps->disabled_bulk_eps & (1 << as->bulk_addr))
- ret = -EREMOTEIO;
- else
- ret = usb_submit_urb(as->urb, GFP_ATOMIC);
- spin_unlock_irq(&ps->lock);
- } else {
- ret = usb_submit_urb(as->urb, GFP_KERNEL);
- }
-
- if (ret) {
- dev_printk(KERN_DEBUG, &ps->dev->dev,
- "usbfs: usb_submit_urb returned %d\n", ret);
- snoop_urb(ps->dev, as->userurb, as->urb->pipe,
- 0, ret, COMPLETE, NULL, 0);
- async_removepending(as);
- goto error;
- }
- return 0;
-
- error:
- kfree(isopkt);
- kfree(dr);
- if (as)
- free_async(as);
- return ret;
-}
-
-static int proc_submiturb(struct dev_state *ps, void __user *arg)
-{
- struct usbdevfs_urb uurb;
-
- if (copy_from_user(&uurb, arg, sizeof(uurb)))
- return -EFAULT;
-
- return proc_do_submiturb(ps, &uurb,
- (((struct usbdevfs_urb __user *)arg)->iso_frame_desc),
- arg);
-}
-
-static int proc_unlinkurb(struct dev_state *ps, void __user *arg)
-{
- struct urb *urb;
- struct async *as;
- unsigned long flags;
-
- spin_lock_irqsave(&ps->lock, flags);
- as = async_getpending(ps, arg);
- if (!as) {
- spin_unlock_irqrestore(&ps->lock, flags);
- return -EINVAL;
- }
-
- urb = as->urb;
- usb_get_urb(urb);
- spin_unlock_irqrestore(&ps->lock, flags);
-
- usb_kill_urb(urb);
- usb_put_urb(urb);
-
- return 0;
-}
-
-static int processcompl(struct async *as, void __user * __user *arg)
-{
- struct urb *urb = as->urb;
- struct usbdevfs_urb __user *userurb = as->userurb;
- void __user *addr = as->userurb;
- unsigned int i;
-
- if (as->userbuffer && urb->actual_length) {
- if (urb->number_of_packets > 0) /* Isochronous */
- i = urb->transfer_buffer_length;
- else /* Non-Isoc */
- i = urb->actual_length;
- if (copy_to_user(as->userbuffer, urb->transfer_buffer, i))
- goto err_out;
- }
- if (put_user(as->status, &userurb->status))
- goto err_out;
- if (put_user(urb->actual_length, &userurb->actual_length))
- goto err_out;
- if (put_user(urb->error_count, &userurb->error_count))
- goto err_out;
-
- if (usb_endpoint_xfer_isoc(&urb->ep->desc)) {
- for (i = 0; i < urb->number_of_packets; i++) {
- if (put_user(urb->iso_frame_desc[i].actual_length,
- &userurb->iso_frame_desc[i].actual_length))
- goto err_out;
- if (put_user(urb->iso_frame_desc[i].status,
- &userurb->iso_frame_desc[i].status))
- goto err_out;
- }
- }
-
- if (put_user(addr, (void __user * __user *)arg))
- return -EFAULT;
- return 0;
-
-err_out:
- return -EFAULT;
-}
-
-static struct async *reap_as(struct dev_state *ps)
-{
- DECLARE_WAITQUEUE(wait, current);
- struct async *as = NULL;
- struct usb_device *dev = ps->dev;
-
- add_wait_queue(&ps->wait, &wait);
- for (;;) {
- __set_current_state(TASK_INTERRUPTIBLE);
- as = async_getcompleted(ps);
- if (as)
- break;
- if (signal_pending(current))
- break;
- usb_unlock_device(dev);
- schedule();
- usb_lock_device(dev);
- }
- remove_wait_queue(&ps->wait, &wait);
- set_current_state(TASK_RUNNING);
- return as;
-}
-
-static int proc_reapurb(struct dev_state *ps, void __user *arg)
-{
- struct async *as = reap_as(ps);
- if (as) {
- int retval = processcompl(as, (void __user * __user *)arg);
- free_async(as);
- return retval;
- }
- if (signal_pending(current))
- return -EINTR;
- return -EIO;
-}
-
-static int proc_reapurbnonblock(struct dev_state *ps, void __user *arg)
-{
- int retval;
- struct async *as;
-
- as = async_getcompleted(ps);
- retval = -EAGAIN;
- if (as) {
- retval = processcompl(as, (void __user * __user *)arg);
- free_async(as);
- }
- return retval;
-}
-
-#ifdef CONFIG_COMPAT
-static int proc_control_compat(struct dev_state *ps,
- struct usbdevfs_ctrltransfer32 __user *p32)
-{
- struct usbdevfs_ctrltransfer __user *p;
- __u32 udata;
- p = compat_alloc_user_space(sizeof(*p));
- if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) ||
- get_user(udata, &p32->data) ||
- put_user(compat_ptr(udata), &p->data))
- return -EFAULT;
- return proc_control(ps, p);
-}
-
-static int proc_bulk_compat(struct dev_state *ps,
- struct usbdevfs_bulktransfer32 __user *p32)
-{
- struct usbdevfs_bulktransfer __user *p;
- compat_uint_t n;
- compat_caddr_t addr;
-
- p = compat_alloc_user_space(sizeof(*p));
-
- if (get_user(n, &p32->ep) || put_user(n, &p->ep) ||
- get_user(n, &p32->len) || put_user(n, &p->len) ||
- get_user(n, &p32->timeout) || put_user(n, &p->timeout) ||
- get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data))
- return -EFAULT;
-
- return proc_bulk(ps, p);
-}
-static int proc_disconnectsignal_compat(struct dev_state *ps, void __user *arg)
-{
- struct usbdevfs_disconnectsignal32 ds;
-
- if (copy_from_user(&ds, arg, sizeof(ds)))
- return -EFAULT;
- ps->discsignr = ds.signr;
- ps->disccontext = compat_ptr(ds.context);
- return 0;
-}
-
-static int get_urb32(struct usbdevfs_urb *kurb,
- struct usbdevfs_urb32 __user *uurb)
-{
- __u32 uptr;
- if (!access_ok(VERIFY_READ, uurb, sizeof(*uurb)) ||
- __get_user(kurb->type, &uurb->type) ||
- __get_user(kurb->endpoint, &uurb->endpoint) ||
- __get_user(kurb->status, &uurb->status) ||
- __get_user(kurb->flags, &uurb->flags) ||
- __get_user(kurb->buffer_length, &uurb->buffer_length) ||
- __get_user(kurb->actual_length, &uurb->actual_length) ||
- __get_user(kurb->start_frame, &uurb->start_frame) ||
- __get_user(kurb->number_of_packets, &uurb->number_of_packets) ||
- __get_user(kurb->error_count, &uurb->error_count) ||
- __get_user(kurb->signr, &uurb->signr))
- return -EFAULT;
-
- if (__get_user(uptr, &uurb->buffer))
- return -EFAULT;
- kurb->buffer = compat_ptr(uptr);
- if (__get_user(uptr, &uurb->usercontext))
- return -EFAULT;
- kurb->usercontext = compat_ptr(uptr);
-
- return 0;
-}
-
-static int proc_submiturb_compat(struct dev_state *ps, void __user *arg)
-{
- struct usbdevfs_urb uurb;
-
- if (get_urb32(&uurb, (struct usbdevfs_urb32 __user *)arg))
- return -EFAULT;
-
- return proc_do_submiturb(ps, &uurb,
- ((struct usbdevfs_urb32 __user *)arg)->iso_frame_desc,
- arg);
-}
-
-static int processcompl_compat(struct async *as, void __user * __user *arg)
-{
- struct urb *urb = as->urb;
- struct usbdevfs_urb32 __user *userurb = as->userurb;
- void __user *addr = as->userurb;
- unsigned int i;
-
- if (as->userbuffer && urb->actual_length)
- if (copy_to_user(as->userbuffer, urb->transfer_buffer,
- urb->actual_length))
- return -EFAULT;
- if (put_user(as->status, &userurb->status))
- return -EFAULT;
- if (put_user(urb->actual_length, &userurb->actual_length))
- return -EFAULT;
- if (put_user(urb->error_count, &userurb->error_count))
- return -EFAULT;
-
- if (usb_endpoint_xfer_isoc(&urb->ep->desc)) {
- for (i = 0; i < urb->number_of_packets; i++) {
- if (put_user(urb->iso_frame_desc[i].actual_length,
- &userurb->iso_frame_desc[i].actual_length))
- return -EFAULT;
- if (put_user(urb->iso_frame_desc[i].status,
- &userurb->iso_frame_desc[i].status))
- return -EFAULT;
- }
- }
-
- if (put_user(ptr_to_compat(addr), (u32 __user *)arg))
- return -EFAULT;
- return 0;
-}
-
-static int proc_reapurb_compat(struct dev_state *ps, void __user *arg)
-{
- struct async *as = reap_as(ps);
- if (as) {
- int retval = processcompl_compat(as, (void __user * __user *)arg);
- free_async(as);
- return retval;
- }
- if (signal_pending(current))
- return -EINTR;
- return -EIO;
-}
-
-static int proc_reapurbnonblock_compat(struct dev_state *ps, void __user *arg)
-{
- int retval;
- struct async *as;
-
- retval = -EAGAIN;
- as = async_getcompleted(ps);
- if (as) {
- retval = processcompl_compat(as, (void __user * __user *)arg);
- free_async(as);
- }
- return retval;
-}
-
-
-#endif
-
-static int proc_disconnectsignal(struct dev_state *ps, void __user *arg)
-{
- struct usbdevfs_disconnectsignal ds;
-
- if (copy_from_user(&ds, arg, sizeof(ds)))
- return -EFAULT;
- ps->discsignr = ds.signr;
- ps->disccontext = ds.context;
- return 0;
-}
-
-static int proc_claiminterface(struct dev_state *ps, void __user *arg)
-{
- unsigned int ifnum;
-
- if (get_user(ifnum, (unsigned int __user *)arg))
- return -EFAULT;
- return claimintf(ps, ifnum);
-}
-
-static int proc_releaseinterface(struct dev_state *ps, void __user *arg)
-{
- unsigned int ifnum;
- int ret;
-
- if (get_user(ifnum, (unsigned int __user *)arg))
- return -EFAULT;
- if ((ret = releaseintf(ps, ifnum)) < 0)
- return ret;
- destroy_async_on_interface (ps, ifnum);
- return 0;
-}
-
-static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)
-{
- int size;
- void *buf = NULL;
- int retval = 0;
- struct usb_interface *intf = NULL;
- struct usb_driver *driver = NULL;
-
- /* alloc buffer */
- if ((size = _IOC_SIZE(ctl->ioctl_code)) > 0) {
- if ((buf = kmalloc(size, GFP_KERNEL)) == NULL)
- return -ENOMEM;
- if ((_IOC_DIR(ctl->ioctl_code) & _IOC_WRITE)) {
- if (copy_from_user(buf, ctl->data, size)) {
- kfree(buf);
- return -EFAULT;
- }
- } else {
- memset(buf, 0, size);
- }
- }
-
- if (!connected(ps)) {
- kfree(buf);
- return -ENODEV;
- }
-
- if (ps->dev->state != USB_STATE_CONFIGURED)
- retval = -EHOSTUNREACH;
- else if (!(intf = usb_ifnum_to_if(ps->dev, ctl->ifno)))
- retval = -EINVAL;
- else switch (ctl->ioctl_code) {
-
- /* disconnect kernel driver from interface */
- case USBDEVFS_DISCONNECT:
- if (intf->dev.driver) {
- driver = to_usb_driver(intf->dev.driver);
- dev_dbg(&intf->dev, "disconnect by usbfs\n");
- usb_driver_release_interface(driver, intf);
- } else
- retval = -ENODATA;
- break;
-
- /* let kernel drivers try to (re)bind to the interface */
- case USBDEVFS_CONNECT:
- if (!intf->dev.driver)
- retval = device_attach(&intf->dev);
- else
- retval = -EBUSY;
- break;
-
- /* talk directly to the interface's driver */
- default:
- if (intf->dev.driver)
- driver = to_usb_driver(intf->dev.driver);
- if (driver == NULL || driver->unlocked_ioctl == NULL) {
- retval = -ENOTTY;
- } else {
- retval = driver->unlocked_ioctl(intf, ctl->ioctl_code, buf);
- if (retval == -ENOIOCTLCMD)
- retval = -ENOTTY;
- }
- }
-
- /* cleanup and return */
- if (retval >= 0
- && (_IOC_DIR(ctl->ioctl_code) & _IOC_READ) != 0
- && size > 0
- && copy_to_user(ctl->data, buf, size) != 0)
- retval = -EFAULT;
-
- kfree(buf);
- return retval;
-}
-
-static int proc_ioctl_default(struct dev_state *ps, void __user *arg)
-{
- struct usbdevfs_ioctl ctrl;
-
- if (copy_from_user(&ctrl, arg, sizeof(ctrl)))
- return -EFAULT;
- return proc_ioctl(ps, &ctrl);
-}
-
-#ifdef CONFIG_COMPAT
-static int proc_ioctl_compat(struct dev_state *ps, compat_uptr_t arg)
-{
- struct usbdevfs_ioctl32 __user *uioc;
- struct usbdevfs_ioctl ctrl;
- u32 udata;
-
- uioc = compat_ptr((long)arg);
- if (!access_ok(VERIFY_READ, uioc, sizeof(*uioc)) ||
- __get_user(ctrl.ifno, &uioc->ifno) ||
- __get_user(ctrl.ioctl_code, &uioc->ioctl_code) ||
- __get_user(udata, &uioc->data))
- return -EFAULT;
- ctrl.data = compat_ptr(udata);
-
- return proc_ioctl(ps, &ctrl);
-}
-#endif
-
-static int proc_claim_port(struct dev_state *ps, void __user *arg)
-{
- unsigned portnum;
- int rc;
-
- if (get_user(portnum, (unsigned __user *) arg))
- return -EFAULT;
- rc = usb_hub_claim_port(ps->dev, portnum, ps);
- if (rc == 0)
- snoop(&ps->dev->dev, "port %d claimed by process %d: %s\n",
- portnum, task_pid_nr(current), current->comm);
- return rc;
-}
-
-static int proc_release_port(struct dev_state *ps, void __user *arg)
-{
- unsigned portnum;
-
- if (get_user(portnum, (unsigned __user *) arg))
- return -EFAULT;
- return usb_hub_release_port(ps->dev, portnum, ps);
-}
-
-/*
- * NOTE: All requests here that have interface numbers as parameters
- * are assuming that somehow the configuration has been prevented from
- * changing. But there's no mechanism to ensure that...
- */
-static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
- void __user *p)
-{
- struct dev_state *ps = file->private_data;
- struct inode *inode = file->f_path.dentry->d_inode;
- struct usb_device *dev = ps->dev;
- int ret = -ENOTTY;
-
- if (!(file->f_mode & FMODE_WRITE))
- return -EPERM;
-
- usb_lock_device(dev);
- if (!connected(ps)) {
- usb_unlock_device(dev);
- return -ENODEV;
- }
-
- switch (cmd) {
- case USBDEVFS_CONTROL:
- snoop(&dev->dev, "%s: CONTROL\n", __func__);
- ret = proc_control(ps, p);
- if (ret >= 0)
- inode->i_mtime = CURRENT_TIME;
- break;
-
- case USBDEVFS_BULK:
- snoop(&dev->dev, "%s: BULK\n", __func__);
- ret = proc_bulk(ps, p);
- if (ret >= 0)
- inode->i_mtime = CURRENT_TIME;
- break;
-
- case USBDEVFS_RESETEP:
- snoop(&dev->dev, "%s: RESETEP\n", __func__);
- ret = proc_resetep(ps, p);
- if (ret >= 0)
- inode->i_mtime = CURRENT_TIME;
- break;
-
- case USBDEVFS_RESET:
- snoop(&dev->dev, "%s: RESET\n", __func__);
- ret = proc_resetdevice(ps);
- break;
-
- case USBDEVFS_CLEAR_HALT:
- snoop(&dev->dev, "%s: CLEAR_HALT\n", __func__);
- ret = proc_clearhalt(ps, p);
- if (ret >= 0)
- inode->i_mtime = CURRENT_TIME;
- break;
-
- case USBDEVFS_GETDRIVER:
- snoop(&dev->dev, "%s: GETDRIVER\n", __func__);
- ret = proc_getdriver(ps, p);
- break;
-
- case USBDEVFS_CONNECTINFO:
- snoop(&dev->dev, "%s: CONNECTINFO\n", __func__);
- ret = proc_connectinfo(ps, p);
- break;
-
- case USBDEVFS_SETINTERFACE:
- snoop(&dev->dev, "%s: SETINTERFACE\n", __func__);
- ret = proc_setintf(ps, p);
- break;
-
- case USBDEVFS_SETCONFIGURATION:
- snoop(&dev->dev, "%s: SETCONFIGURATION\n", __func__);
- ret = proc_setconfig(ps, p);
- break;
-
- case USBDEVFS_SUBMITURB:
- snoop(&dev->dev, "%s: SUBMITURB\n", __func__);
- ret = proc_submiturb(ps, p);
- if (ret >= 0)
- inode->i_mtime = CURRENT_TIME;
- break;
-
-#ifdef CONFIG_COMPAT
- case USBDEVFS_CONTROL32:
- snoop(&dev->dev, "%s: CONTROL32\n", __func__);
- ret = proc_control_compat(ps, p);
- if (ret >= 0)
- inode->i_mtime = CURRENT_TIME;
- break;
-
- case USBDEVFS_BULK32:
- snoop(&dev->dev, "%s: BULK32\n", __func__);
- ret = proc_bulk_compat(ps, p);
- if (ret >= 0)
- inode->i_mtime = CURRENT_TIME;
- break;
-
- case USBDEVFS_DISCSIGNAL32:
- snoop(&dev->dev, "%s: DISCSIGNAL32\n", __func__);
- ret = proc_disconnectsignal_compat(ps, p);
- break;
-
- case USBDEVFS_SUBMITURB32:
- snoop(&dev->dev, "%s: SUBMITURB32\n", __func__);
- ret = proc_submiturb_compat(ps, p);
- if (ret >= 0)
- inode->i_mtime = CURRENT_TIME;
- break;
-
- case USBDEVFS_REAPURB32:
- snoop(&dev->dev, "%s: REAPURB32\n", __func__);
- ret = proc_reapurb_compat(ps, p);
- break;
-
- case USBDEVFS_REAPURBNDELAY32:
- snoop(&dev->dev, "%s: REAPURBNDELAY32\n", __func__);
- ret = proc_reapurbnonblock_compat(ps, p);
- break;
-
- case USBDEVFS_IOCTL32:
- snoop(&dev->dev, "%s: IOCTL32\n", __func__);
- ret = proc_ioctl_compat(ps, ptr_to_compat(p));
- break;
-#endif
-
- case USBDEVFS_DISCARDURB:
- snoop(&dev->dev, "%s: DISCARDURB\n", __func__);
- ret = proc_unlinkurb(ps, p);
- break;
-
- case USBDEVFS_REAPURB:
- snoop(&dev->dev, "%s: REAPURB\n", __func__);
- ret = proc_reapurb(ps, p);
- break;
-
- case USBDEVFS_REAPURBNDELAY:
- snoop(&dev->dev, "%s: REAPURBNDELAY\n", __func__);
- ret = proc_reapurbnonblock(ps, p);
- break;
-
- case USBDEVFS_DISCSIGNAL:
- snoop(&dev->dev, "%s: DISCSIGNAL\n", __func__);
- ret = proc_disconnectsignal(ps, p);
- break;
-
- case USBDEVFS_CLAIMINTERFACE:
- snoop(&dev->dev, "%s: CLAIMINTERFACE\n", __func__);
- ret = proc_claiminterface(ps, p);
- break;
-
- case USBDEVFS_RELEASEINTERFACE:
- snoop(&dev->dev, "%s: RELEASEINTERFACE\n", __func__);
- ret = proc_releaseinterface(ps, p);
- break;
-
- case USBDEVFS_IOCTL:
- snoop(&dev->dev, "%s: IOCTL\n", __func__);
- ret = proc_ioctl_default(ps, p);
- break;
-
- case USBDEVFS_CLAIM_PORT:
- snoop(&dev->dev, "%s: CLAIM_PORT\n", __func__);
- ret = proc_claim_port(ps, p);
- break;
-
- case USBDEVFS_RELEASE_PORT:
- snoop(&dev->dev, "%s: RELEASE_PORT\n", __func__);
- ret = proc_release_port(ps, p);
- break;
- }
- usb_unlock_device(dev);
- if (ret >= 0)
- inode->i_atime = CURRENT_TIME;
- return ret;
-}
-
-static long usbdev_ioctl(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- int ret;
-
- ret = usbdev_do_ioctl(file, cmd, (void __user *)arg);
-
- return ret;
-}
-
-#ifdef CONFIG_COMPAT
-static long usbdev_compat_ioctl(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- int ret;
-
- ret = usbdev_do_ioctl(file, cmd, compat_ptr(arg));
-
- return ret;
-}
-#endif
-
-/* No kernel lock - fine */
-static unsigned int usbdev_poll(struct file *file,
- struct poll_table_struct *wait)
-{
- struct dev_state *ps = file->private_data;
- unsigned int mask = 0;
-
- poll_wait(file, &ps->wait, wait);
- if (file->f_mode & FMODE_WRITE && !list_empty(&ps->async_completed))
- mask |= POLLOUT | POLLWRNORM;
- if (!connected(ps))
- mask |= POLLERR | POLLHUP;
- return mask;
-}
-
-const struct file_operations usbdev_file_operations = {
- .owner = THIS_MODULE,
- .llseek = usbdev_lseek,
- .read = usbdev_read,
- .poll = usbdev_poll,
- .unlocked_ioctl = usbdev_ioctl,
-#ifdef CONFIG_COMPAT
- .compat_ioctl = usbdev_compat_ioctl,
-#endif
- .open = usbdev_open,
- .release = usbdev_release,
-};
-
-static void usbdev_remove(struct usb_device *udev)
-{
- struct dev_state *ps;
- struct siginfo sinfo;
-
- while (!list_empty(&udev->filelist)) {
- ps = list_entry(udev->filelist.next, struct dev_state, list);
- destroy_all_async(ps);
- wake_up_all(&ps->wait);
- list_del_init(&ps->list);
- if (ps->discsignr) {
- sinfo.si_signo = ps->discsignr;
- sinfo.si_errno = EPIPE;
- sinfo.si_code = SI_ASYNCIO;
- sinfo.si_addr = ps->disccontext;
- kill_pid_info_as_cred(ps->discsignr, &sinfo,
- ps->disc_pid, ps->cred, ps->secid);
- }
- }
-}
-
-#ifdef CONFIG_USB_DEVICE_CLASS
-static struct class *usb_classdev_class;
-
-static int usb_classdev_add(struct usb_device *dev)
-{
- struct device *cldev;
-
- cldev = device_create(usb_classdev_class, &dev->dev, dev->dev.devt,
- NULL, "usbdev%d.%d", dev->bus->busnum,
- dev->devnum);
- if (IS_ERR(cldev))
- return PTR_ERR(cldev);
- dev->usb_classdev = cldev;
- return 0;
-}
-
-static void usb_classdev_remove(struct usb_device *dev)
-{
- if (dev->usb_classdev)
- device_unregister(dev->usb_classdev);
-}
-
-#else
-#define usb_classdev_add(dev) 0
-#define usb_classdev_remove(dev) do {} while (0)
-
-#endif
-
-static int usbdev_notify(struct notifier_block *self,
- unsigned long action, void *dev)
-{
- switch (action) {
- case USB_DEVICE_ADD:
- if (usb_classdev_add(dev))
- return NOTIFY_BAD;
- break;
- case USB_DEVICE_REMOVE:
- usb_classdev_remove(dev);
- usbdev_remove(dev);
- break;
- }
- return NOTIFY_OK;
-}
-
-static struct notifier_block usbdev_nb = {
- .notifier_call = usbdev_notify,
-};
-
-static struct cdev usb_device_cdev;
-
-int __init usb_devio_init(void)
-{
- int retval;
-
- retval = register_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX,
- "usb_device");
- if (retval) {
- printk(KERN_ERR "Unable to register minors for usb_device\n");
- goto out;
- }
- cdev_init(&usb_device_cdev, &usbdev_file_operations);
- retval = cdev_add(&usb_device_cdev, USB_DEVICE_DEV, USB_DEVICE_MAX);
- if (retval) {
- printk(KERN_ERR "Unable to get usb_device major %d\n",
- USB_DEVICE_MAJOR);
- goto error_cdev;
- }
-#ifdef CONFIG_USB_DEVICE_CLASS
- usb_classdev_class = class_create(THIS_MODULE, "usb_device");
- if (IS_ERR(usb_classdev_class)) {
- printk(KERN_ERR "Unable to register usb_device class\n");
- retval = PTR_ERR(usb_classdev_class);
- cdev_del(&usb_device_cdev);
- usb_classdev_class = NULL;
- goto out;
- }
- /* devices of this class shadow the major:minor of their parent
- * device, so clear ->dev_kobj to prevent adding duplicate entries
- * to /sys/dev
- */
- usb_classdev_class->dev_kobj = NULL;
-#endif
- usb_register_notify(&usbdev_nb);
-out:
- return retval;
-
-error_cdev:
- unregister_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX);
- goto out;
-}
-
-void usb_devio_cleanup(void)
-{
- usb_unregister_notify(&usbdev_nb);
-#ifdef CONFIG_USB_DEVICE_CLASS
- class_destroy(usb_classdev_class);
-#endif
- cdev_del(&usb_device_cdev);
- unregister_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX);
-}
diff --git a/ANDROID_3.4.5/drivers/usb/core/driver.c b/ANDROID_3.4.5/drivers/usb/core/driver.c
deleted file mode 100644
index b3df4e9a..00000000
--- a/ANDROID_3.4.5/drivers/usb/core/driver.c
+++ /dev/null
@@ -1,1741 +0,0 @@
-/*
- * drivers/usb/driver.c - most of the driver model stuff for usb
- *
- * (C) Copyright 2005 Greg Kroah-Hartman
- *
- * based on drivers/usb/usb.c which had the following copyrights:
- * (C) Copyright Linus Torvalds 1999
- * (C) Copyright Johannes Erdfelt 1999-2001
- * (C) Copyright Andreas Gal 1999
- * (C) Copyright Gregory P. Smith 1999
- * (C) Copyright Deti Fliegl 1999 (new USB architecture)
- * (C) Copyright Randy Dunlap 2000
- * (C) Copyright David Brownell 2000-2004
- * (C) Copyright Yggdrasil Computing, Inc. 2000
- * (usb_device_id matching changes by Adam J. Richter)
- * (C) Copyright Greg Kroah-Hartman 2002-2003
- *
- * NOTE! This is not actually a driver at all, rather this is
- * just a collection of helper routines that implement the
- * matching, probing, releasing, suspending and resuming for
- * real drivers.
- *
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "usb.h"
-
-
-#ifdef CONFIG_HOTPLUG
-
-/*
- * Adds a new dynamic USBdevice ID to this driver,
- * and cause the driver to probe for all devices again.
- */
-ssize_t usb_store_new_id(struct usb_dynids *dynids,
- struct device_driver *driver,
- const char *buf, size_t count)
-{
- struct usb_dynid *dynid;
- u32 idVendor = 0;
- u32 idProduct = 0;
- unsigned int bInterfaceClass = 0;
- int fields = 0;
- int retval = 0;
-
- fields = sscanf(buf, "%x %x %x", &idVendor, &idProduct,
- &bInterfaceClass);
- if (fields < 2)
- return -EINVAL;
-
- dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
- if (!dynid)
- return -ENOMEM;
-
- INIT_LIST_HEAD(&dynid->node);
- dynid->id.idVendor = idVendor;
- dynid->id.idProduct = idProduct;
- dynid->id.match_flags = USB_DEVICE_ID_MATCH_DEVICE;
- if (fields == 3) {
- dynid->id.bInterfaceClass = (u8)bInterfaceClass;
- dynid->id.match_flags |= USB_DEVICE_ID_MATCH_INT_CLASS;
- }
-
- spin_lock(&dynids->lock);
- list_add_tail(&dynid->node, &dynids->list);
- spin_unlock(&dynids->lock);
-
- retval = driver_attach(driver);
-
- if (retval)
- return retval;
- return count;
-}
-EXPORT_SYMBOL_GPL(usb_store_new_id);
-
-static ssize_t store_new_id(struct device_driver *driver,
- const char *buf, size_t count)
-{
- struct usb_driver *usb_drv = to_usb_driver(driver);
-
- return usb_store_new_id(&usb_drv->dynids, driver, buf, count);
-}
-static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id);
-
-/**
- * store_remove_id - remove a USB device ID from this driver
- * @driver: target device driver
- * @buf: buffer for scanning device ID data
- * @count: input size
- *
- * Removes a dynamic usb device ID from this driver.
- */
-static ssize_t
-store_remove_id(struct device_driver *driver, const char *buf, size_t count)
-{
- struct usb_dynid *dynid, *n;
- struct usb_driver *usb_driver = to_usb_driver(driver);
- u32 idVendor = 0;
- u32 idProduct = 0;
- int fields = 0;
- int retval = 0;
-
- fields = sscanf(buf, "%x %x", &idVendor, &idProduct);
- if (fields < 2)
- return -EINVAL;
-
- spin_lock(&usb_driver->dynids.lock);
- list_for_each_entry_safe(dynid, n, &usb_driver->dynids.list, node) {
- struct usb_device_id *id = &dynid->id;
- if ((id->idVendor == idVendor) &&
- (id->idProduct == idProduct)) {
- list_del(&dynid->node);
- kfree(dynid);
- retval = 0;
- break;
- }
- }
- spin_unlock(&usb_driver->dynids.lock);
-
- if (retval)
- return retval;
- return count;
-}
-static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id);
-
-static int usb_create_newid_files(struct usb_driver *usb_drv)
-{
- int error = 0;
-
- if (usb_drv->no_dynamic_id)
- goto exit;
-
- if (usb_drv->probe != NULL) {
- error = driver_create_file(&usb_drv->drvwrap.driver,
- &driver_attr_new_id);
- if (error == 0) {
- error = driver_create_file(&usb_drv->drvwrap.driver,
- &driver_attr_remove_id);
- if (error)
- driver_remove_file(&usb_drv->drvwrap.driver,
- &driver_attr_new_id);
- }
- }
-exit:
- return error;
-}
-
-static void usb_remove_newid_files(struct usb_driver *usb_drv)
-{
- if (usb_drv->no_dynamic_id)
- return;
-
- if (usb_drv->probe != NULL) {
- driver_remove_file(&usb_drv->drvwrap.driver,
- &driver_attr_remove_id);
- driver_remove_file(&usb_drv->drvwrap.driver,
- &driver_attr_new_id);
- }
-}
-
-static void usb_free_dynids(struct usb_driver *usb_drv)
-{
- struct usb_dynid *dynid, *n;
-
- spin_lock(&usb_drv->dynids.lock);
- list_for_each_entry_safe(dynid, n, &usb_drv->dynids.list, node) {
- list_del(&dynid->node);
- kfree(dynid);
- }
- spin_unlock(&usb_drv->dynids.lock);
-}
-#else
-static inline int usb_create_newid_files(struct usb_driver *usb_drv)
-{
- return 0;
-}
-
-static void usb_remove_newid_files(struct usb_driver *usb_drv)
-{
-}
-
-static inline void usb_free_dynids(struct usb_driver *usb_drv)
-{
-}
-#endif
-
-static const struct usb_device_id *usb_match_dynamic_id(struct usb_interface *intf,
- struct usb_driver *drv)
-{
- struct usb_dynid *dynid;
-
- spin_lock(&drv->dynids.lock);
- list_for_each_entry(dynid, &drv->dynids.list, node) {
- if (usb_match_one_id(intf, &dynid->id)) {
- spin_unlock(&drv->dynids.lock);
- return &dynid->id;
- }
- }
- spin_unlock(&drv->dynids.lock);
- return NULL;
-}
-
-
-/* called from driver core with dev locked */
-static int usb_probe_device(struct device *dev)
-{
- struct usb_device_driver *udriver = to_usb_device_driver(dev->driver);
- struct usb_device *udev = to_usb_device(dev);
- int error = 0;
-
- dev_dbg(dev, "%s\n", __func__);
-
- /* TODO: Add real matching code */
-
- /* The device should always appear to be in use
- * unless the driver suports autosuspend.
- */
- if (!udriver->supports_autosuspend)
- error = usb_autoresume_device(udev);
-
- if (!error)
- error = udriver->probe(udev);
- return error;
-}
-
-/* called from driver core with dev locked */
-static int usb_unbind_device(struct device *dev)
-{
- struct usb_device *udev = to_usb_device(dev);
- struct usb_device_driver *udriver = to_usb_device_driver(dev->driver);
-
- udriver->disconnect(udev);
- if (!udriver->supports_autosuspend)
- usb_autosuspend_device(udev);
- return 0;
-}
-
-/*
- * Cancel any pending scheduled resets
- *
- * [see usb_queue_reset_device()]
- *
- * Called after unconfiguring / when releasing interfaces. See
- * comments in __usb_queue_reset_device() regarding
- * udev->reset_running.
- */
-static void usb_cancel_queued_reset(struct usb_interface *iface)
-{
- if (iface->reset_running == 0)
- cancel_work_sync(&iface->reset_ws);
-}
-
-/* called from driver core with dev locked */
-static int usb_probe_interface(struct device *dev)
-{
- struct usb_driver *driver = to_usb_driver(dev->driver);
- struct usb_interface *intf = to_usb_interface(dev);
- struct usb_device *udev = interface_to_usbdev(intf);
- const struct usb_device_id *id;
- int error = -ENODEV;
-
- dev_dbg(dev, "%s\n", __func__);
-
- intf->needs_binding = 0;
-
- if (usb_device_is_owned(udev))
- return error;
-
- if (udev->authorized == 0) {
- dev_err(&intf->dev, "Device is not authorized for usage\n");
- return error;
- }
-
- id = usb_match_id(intf, driver->id_table);
- if (!id)
- id = usb_match_dynamic_id(intf, driver);
- if (!id)
- return error;
-
- dev_dbg(dev, "%s - got id\n", __func__);
-
- error = usb_autoresume_device(udev);
- if (error)
- return error;
-
- intf->condition = USB_INTERFACE_BINDING;
-
- /* Probed interfaces are initially active. They are
- * runtime-PM-enabled only if the driver has autosuspend support.
- * They are sensitive to their children's power states.
- */
- pm_runtime_set_active(dev);
- pm_suspend_ignore_children(dev, false);
- if (driver->supports_autosuspend)
- pm_runtime_enable(dev);
-
- /* Carry out a deferred switch to altsetting 0 */
- if (intf->needs_altsetting0) {
- error = usb_set_interface(udev, intf->altsetting[0].
- desc.bInterfaceNumber, 0);
- if (error < 0)
- goto err;
- intf->needs_altsetting0 = 0;
- }
-
- error = driver->probe(intf, id);
- if (error)
- goto err;
-
- intf->condition = USB_INTERFACE_BOUND;
- usb_autosuspend_device(udev);
- return error;
-
- err:
- intf->needs_remote_wakeup = 0;
- intf->condition = USB_INTERFACE_UNBOUND;
- usb_cancel_queued_reset(intf);
-
- /* Unbound interfaces are always runtime-PM-disabled and -suspended */
- if (driver->supports_autosuspend)
- pm_runtime_disable(dev);
- pm_runtime_set_suspended(dev);
-
- usb_autosuspend_device(udev);
- return error;
-}
-
-/* called from driver core with dev locked */
-static int usb_unbind_interface(struct device *dev)
-{
- struct usb_driver *driver = to_usb_driver(dev->driver);
- struct usb_interface *intf = to_usb_interface(dev);
- struct usb_device *udev;
- int error, r;
-
- intf->condition = USB_INTERFACE_UNBINDING;
-
- /* Autoresume for set_interface call below */
- udev = interface_to_usbdev(intf);
- error = usb_autoresume_device(udev);
-
- /* Terminate all URBs for this interface unless the driver
- * supports "soft" unbinding.
- */
- if (!driver->soft_unbind)
- usb_disable_interface(udev, intf, false);
-
- driver->disconnect(intf);
- usb_cancel_queued_reset(intf);
-
- /* Reset other interface state.
- * We cannot do a Set-Interface if the device is suspended or
- * if it is prepared for a system sleep (since installing a new
- * altsetting means creating new endpoint device entries).
- * When either of these happens, defer the Set-Interface.
- */
- if (intf->cur_altsetting->desc.bAlternateSetting == 0) {
- /* Already in altsetting 0 so skip Set-Interface.
- * Just re-enable it without affecting the endpoint toggles.
- */
- usb_enable_interface(udev, intf, false);
- } else if (!error && !intf->dev.power.is_prepared) {
- r = usb_set_interface(udev, intf->altsetting[0].
- desc.bInterfaceNumber, 0);
- if (r < 0)
- intf->needs_altsetting0 = 1;
- } else {
- intf->needs_altsetting0 = 1;
- }
- usb_set_intfdata(intf, NULL);
-
- intf->condition = USB_INTERFACE_UNBOUND;
- intf->needs_remote_wakeup = 0;
-
- /* Unbound interfaces are always runtime-PM-disabled and -suspended */
- if (driver->supports_autosuspend)
- pm_runtime_disable(dev);
- pm_runtime_set_suspended(dev);
-
- /* Undo any residual pm_autopm_get_interface_* calls */
- for (r = atomic_read(&intf->pm_usage_cnt); r > 0; --r)
- usb_autopm_put_interface_no_suspend(intf);
- atomic_set(&intf->pm_usage_cnt, 0);
-
- if (!error)
- usb_autosuspend_device(udev);
-
- return 0;
-}
-
-/**
- * usb_driver_claim_interface - bind a driver to an interface
- * @driver: the driver to be bound
- * @iface: the interface to which it will be bound; must be in the
- * usb device's active configuration
- * @priv: driver data associated with that interface
- *
- * This is used by usb device drivers that need to claim more than one
- * interface on a device when probing (audio and acm are current examples).
- * No device driver should directly modify internal usb_interface or
- * usb_device structure members.
- *
- * Few drivers should need to use this routine, since the most natural
- * way to bind to an interface is to return the private data from
- * the driver's probe() method.
- *
- * Callers must own the device lock, so driver probe() entries don't need
- * extra locking, but other call contexts may need to explicitly claim that
- * lock.
- */
-int usb_driver_claim_interface(struct usb_driver *driver,
- struct usb_interface *iface, void *priv)
-{
- struct device *dev = &iface->dev;
- int retval = 0;
-
- if (dev->driver)
- return -EBUSY;
-
- dev->driver = &driver->drvwrap.driver;
- usb_set_intfdata(iface, priv);
- iface->needs_binding = 0;
-
- iface->condition = USB_INTERFACE_BOUND;
-
- /* Claimed interfaces are initially inactive (suspended) and
- * runtime-PM-enabled, but only if the driver has autosuspend
- * support. Otherwise they are marked active, to prevent the
- * device from being autosuspended, but left disabled. In either
- * case they are sensitive to their children's power states.
- */
- pm_suspend_ignore_children(dev, false);
- if (driver->supports_autosuspend)
- pm_runtime_enable(dev);
- else
- pm_runtime_set_active(dev);
-
- /* if interface was already added, bind now; else let
- * the future device_add() bind it, bypassing probe()
- */
- if (device_is_registered(dev))
- retval = device_bind_driver(dev);
-
- return retval;
-}
-EXPORT_SYMBOL_GPL(usb_driver_claim_interface);
-
-/**
- * usb_driver_release_interface - unbind a driver from an interface
- * @driver: the driver to be unbound
- * @iface: the interface from which it will be unbound
- *
- * This can be used by drivers to release an interface without waiting
- * for their disconnect() methods to be called. In typical cases this
- * also causes the driver disconnect() method to be called.
- *
- * This call is synchronous, and may not be used in an interrupt context.
- * Callers must own the device lock, so driver disconnect() entries don't
- * need extra locking, but other call contexts may need to explicitly claim
- * that lock.
- */
-void usb_driver_release_interface(struct usb_driver *driver,
- struct usb_interface *iface)
-{
- struct device *dev = &iface->dev;
-
- /* this should never happen, don't release something that's not ours */
- if (!dev->driver || dev->driver != &driver->drvwrap.driver)
- return;
-
- /* don't release from within disconnect() */
- if (iface->condition != USB_INTERFACE_BOUND)
- return;
- iface->condition = USB_INTERFACE_UNBINDING;
-
- /* Release via the driver core only if the interface
- * has already been registered
- */
- if (device_is_registered(dev)) {
- device_release_driver(dev);
- } else {
- device_lock(dev);
- usb_unbind_interface(dev);
- dev->driver = NULL;
- device_unlock(dev);
- }
-}
-EXPORT_SYMBOL_GPL(usb_driver_release_interface);
-
-/* returns 0 if no match, 1 if match */
-int usb_match_device(struct usb_device *dev, const struct usb_device_id *id)
-{
- if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
- id->idVendor != le16_to_cpu(dev->descriptor.idVendor))
- return 0;
-
- if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
- id->idProduct != le16_to_cpu(dev->descriptor.idProduct))
- return 0;
-
- /* No need to test id->bcdDevice_lo != 0, since 0 is never
- greater than any unsigned number. */
- if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
- (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice)))
- return 0;
-
- if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
- (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice)))
- return 0;
-
- if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
- (id->bDeviceClass != dev->descriptor.bDeviceClass))
- return 0;
-
- if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
- (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass))
- return 0;
-
- if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
- (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
- return 0;
-
- return 1;
-}
-
-/* returns 0 if no match, 1 if match */
-int usb_match_one_id(struct usb_interface *interface,
- const struct usb_device_id *id)
-{
- struct usb_host_interface *intf;
- struct usb_device *dev;
-
- /* proc_connectinfo in devio.c may call us with id == NULL. */
- if (id == NULL)
- return 0;
-
- intf = interface->cur_altsetting;
- dev = interface_to_usbdev(interface);
-
- if (!usb_match_device(dev, id))
- return 0;
-
- /* The interface class, subclass, and protocol should never be
- * checked for a match if the device class is Vendor Specific,
- * unless the match record specifies the Vendor ID. */
- if (dev->descriptor.bDeviceClass == USB_CLASS_VENDOR_SPEC &&
- !(id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
- (id->match_flags & (USB_DEVICE_ID_MATCH_INT_CLASS |
- USB_DEVICE_ID_MATCH_INT_SUBCLASS |
- USB_DEVICE_ID_MATCH_INT_PROTOCOL)))
- return 0;
-
- if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) &&
- (id->bInterfaceClass != intf->desc.bInterfaceClass))
- return 0;
-
- if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_SUBCLASS) &&
- (id->bInterfaceSubClass != intf->desc.bInterfaceSubClass))
- return 0;
-
- if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL) &&
- (id->bInterfaceProtocol != intf->desc.bInterfaceProtocol))
- return 0;
-
- return 1;
-}
-EXPORT_SYMBOL_GPL(usb_match_one_id);
-
-/**
- * usb_match_id - find first usb_device_id matching device or interface
- * @interface: the interface of interest
- * @id: array of usb_device_id structures, terminated by zero entry
- *
- * usb_match_id searches an array of usb_device_id's and returns
- * the first one matching the device or interface, or null.
- * This is used when binding (or rebinding) a driver to an interface.
- * Most USB device drivers will use this indirectly, through the usb core,
- * but some layered driver frameworks use it directly.
- * These device tables are exported with MODULE_DEVICE_TABLE, through
- * modutils, to support the driver loading functionality of USB hotplugging.
- *
- * What Matches:
- *
- * The "match_flags" element in a usb_device_id controls which
- * members are used. If the corresponding bit is set, the
- * value in the device_id must match its corresponding member
- * in the device or interface descriptor, or else the device_id
- * does not match.
- *
- * "driver_info" is normally used only by device drivers,
- * but you can create a wildcard "matches anything" usb_device_id
- * as a driver's "modules.usbmap" entry if you provide an id with
- * only a nonzero "driver_info" field. If you do this, the USB device
- * driver's probe() routine should use additional intelligence to
- * decide whether to bind to the specified interface.
- *
- * What Makes Good usb_device_id Tables:
- *
- * The match algorithm is very simple, so that intelligence in
- * driver selection must come from smart driver id records.
- * Unless you have good reasons to use another selection policy,
- * provide match elements only in related groups, and order match
- * specifiers from specific to general. Use the macros provided
- * for that purpose if you can.
- *
- * The most specific match specifiers use device descriptor
- * data. These are commonly used with product-specific matches;
- * the USB_DEVICE macro lets you provide vendor and product IDs,
- * and you can also match against ranges of product revisions.
- * These are widely used for devices with application or vendor
- * specific bDeviceClass values.
- *
- * Matches based on device class/subclass/protocol specifications
- * are slightly more general; use the USB_DEVICE_INFO macro, or
- * its siblings. These are used with single-function devices
- * where bDeviceClass doesn't specify that each interface has
- * its own class.
- *
- * Matches based on interface class/subclass/protocol are the
- * most general; they let drivers bind to any interface on a
- * multiple-function device. Use the USB_INTERFACE_INFO
- * macro, or its siblings, to match class-per-interface style
- * devices (as recorded in bInterfaceClass).
- *
- * Note that an entry created by USB_INTERFACE_INFO won't match
- * any interface if the device class is set to Vendor-Specific.
- * This is deliberate; according to the USB spec the meanings of
- * the interface class/subclass/protocol for these devices are also
- * vendor-specific, and hence matching against a standard product
- * class wouldn't work anyway. If you really want to use an
- * interface-based match for such a device, create a match record
- * that also specifies the vendor ID. (Unforunately there isn't a
- * standard macro for creating records like this.)
- *
- * Within those groups, remember that not all combinations are
- * meaningful. For example, don't give a product version range
- * without vendor and product IDs; or specify a protocol without
- * its associated class and subclass.
- */
-const struct usb_device_id *usb_match_id(struct usb_interface *interface,
- const struct usb_device_id *id)
-{
- /* proc_connectinfo in devio.c may call us with id == NULL. */
- if (id == NULL)
- return NULL;
-
- /* It is important to check that id->driver_info is nonzero,
- since an entry that is all zeroes except for a nonzero
- id->driver_info is the way to create an entry that
- indicates that the driver want to examine every
- device and interface. */
- for (; id->idVendor || id->idProduct || id->bDeviceClass ||
- id->bInterfaceClass || id->driver_info; id++) {
- if (usb_match_one_id(interface, id))
- return id;
- }
-
- return NULL;
-}
-EXPORT_SYMBOL_GPL(usb_match_id);
-
-static int usb_device_match(struct device *dev, struct device_driver *drv)
-{
- /* devices and interfaces are handled separately */
- if (is_usb_device(dev)) {
-
- /* interface drivers never match devices */
- if (!is_usb_device_driver(drv))
- return 0;
-
- /* TODO: Add real matching code */
- return 1;
-
- } else if (is_usb_interface(dev)) {
- struct usb_interface *intf;
- struct usb_driver *usb_drv;
- const struct usb_device_id *id;
-
- /* device drivers never match interfaces */
- if (is_usb_device_driver(drv))
- return 0;
-
- intf = to_usb_interface(dev);
- usb_drv = to_usb_driver(drv);
-
- id = usb_match_id(intf, usb_drv->id_table);
- if (id)
- return 1;
-
- id = usb_match_dynamic_id(intf, usb_drv);
- if (id)
- return 1;
- }
-
- return 0;
-}
-
-#ifdef CONFIG_HOTPLUG
-static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
-{
- struct usb_device *usb_dev;
-
- if (is_usb_device(dev)) {
- usb_dev = to_usb_device(dev);
- } else if (is_usb_interface(dev)) {
- struct usb_interface *intf = to_usb_interface(dev);
-
- usb_dev = interface_to_usbdev(intf);
- } else {
- return 0;
- }
-
- if (usb_dev->devnum < 0) {
- /* driver is often null here; dev_dbg() would oops */
- pr_debug("usb %s: already deleted?\n", dev_name(dev));
- return -ENODEV;
- }
- if (!usb_dev->bus) {
- pr_debug("usb %s: bus removed?\n", dev_name(dev));
- return -ENODEV;
- }
-
-#ifdef CONFIG_USB_DEVICEFS
- /* If this is available, userspace programs can directly read
- * all the device descriptors we don't tell them about. Or
- * act as usermode drivers.
- */
- if (add_uevent_var(env, "DEVICE=/proc/bus/usb/%03d/%03d",
- usb_dev->bus->busnum, usb_dev->devnum))
- return -ENOMEM;
-#endif
-
- /* per-device configurations are common */
- if (add_uevent_var(env, "PRODUCT=%x/%x/%x",
- le16_to_cpu(usb_dev->descriptor.idVendor),
- le16_to_cpu(usb_dev->descriptor.idProduct),
- le16_to_cpu(usb_dev->descriptor.bcdDevice)))
- return -ENOMEM;
-
- /* class-based driver binding models */
- if (add_uevent_var(env, "TYPE=%d/%d/%d",
- usb_dev->descriptor.bDeviceClass,
- usb_dev->descriptor.bDeviceSubClass,
- usb_dev->descriptor.bDeviceProtocol))
- return -ENOMEM;
-
- return 0;
-}
-
-#else
-
-static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
-{
- return -ENODEV;
-}
-#endif /* CONFIG_HOTPLUG */
-
-/**
- * usb_register_device_driver - register a USB device (not interface) driver
- * @new_udriver: USB operations for the device driver
- * @owner: module owner of this driver.
- *
- * Registers a USB device driver with the USB core. The list of
- * unattached devices will be rescanned whenever a new driver is
- * added, allowing the new driver to attach to any recognized devices.
- * Returns a negative error code on failure and 0 on success.
- */
-int usb_register_device_driver(struct usb_device_driver *new_udriver,
- struct module *owner)
-{
- int retval = 0;
-
- if (usb_disabled())
- return -ENODEV;
-
- new_udriver->drvwrap.for_devices = 1;
- new_udriver->drvwrap.driver.name = (char *) new_udriver->name;
- new_udriver->drvwrap.driver.bus = &usb_bus_type;
- new_udriver->drvwrap.driver.probe = usb_probe_device;
- new_udriver->drvwrap.driver.remove = usb_unbind_device;
- new_udriver->drvwrap.driver.owner = owner;
-
- retval = driver_register(&new_udriver->drvwrap.driver);
-
- if (!retval) {
- pr_info("%s: registered new device driver %s\n",
- usbcore_name, new_udriver->name);
- usbfs_update_special();
- } else {
- printk(KERN_ERR "%s: error %d registering device "
- " driver %s\n",
- usbcore_name, retval, new_udriver->name);
- }
-
- return retval;
-}
-EXPORT_SYMBOL_GPL(usb_register_device_driver);
-
-/**
- * usb_deregister_device_driver - unregister a USB device (not interface) driver
- * @udriver: USB operations of the device driver to unregister
- * Context: must be able to sleep
- *
- * Unlinks the specified driver from the internal USB driver list.
- */
-void usb_deregister_device_driver(struct usb_device_driver *udriver)
-{
- pr_info("%s: deregistering device driver %s\n",
- usbcore_name, udriver->name);
-
- driver_unregister(&udriver->drvwrap.driver);
- usbfs_update_special();
-}
-EXPORT_SYMBOL_GPL(usb_deregister_device_driver);
-
-/**
- * usb_register_driver - register a USB interface driver
- * @new_driver: USB operations for the interface driver
- * @owner: module owner of this driver.
- * @mod_name: module name string
- *
- * Registers a USB interface driver with the USB core. The list of
- * unattached interfaces will be rescanned whenever a new driver is
- * added, allowing the new driver to attach to any recognized interfaces.
- * Returns a negative error code on failure and 0 on success.
- *
- * NOTE: if you want your driver to use the USB major number, you must call
- * usb_register_dev() to enable that functionality. This function no longer
- * takes care of that.
- */
-int usb_register_driver(struct usb_driver *new_driver, struct module *owner,
- const char *mod_name)
-{
- int retval = 0;
-
- if (usb_disabled())
- return -ENODEV;
-
- new_driver->drvwrap.for_devices = 0;
- new_driver->drvwrap.driver.name = (char *) new_driver->name;
- new_driver->drvwrap.driver.bus = &usb_bus_type;
- new_driver->drvwrap.driver.probe = usb_probe_interface;
- new_driver->drvwrap.driver.remove = usb_unbind_interface;
- new_driver->drvwrap.driver.owner = owner;
- new_driver->drvwrap.driver.mod_name = mod_name;
- spin_lock_init(&new_driver->dynids.lock);
- INIT_LIST_HEAD(&new_driver->dynids.list);
-
- retval = driver_register(&new_driver->drvwrap.driver);
- if (retval)
- goto out;
-
- usbfs_update_special();
-
- retval = usb_create_newid_files(new_driver);
- if (retval)
- goto out_newid;
-
- pr_info("%s: registered new interface driver %s\n",
- usbcore_name, new_driver->name);
-
-out:
- return retval;
-
-out_newid:
- driver_unregister(&new_driver->drvwrap.driver);
-
- printk(KERN_ERR "%s: error %d registering interface "
- " driver %s\n",
- usbcore_name, retval, new_driver->name);
- goto out;
-}
-EXPORT_SYMBOL_GPL(usb_register_driver);
-
-/**
- * usb_deregister - unregister a USB interface driver
- * @driver: USB operations of the interface driver to unregister
- * Context: must be able to sleep
- *
- * Unlinks the specified driver from the internal USB driver list.
- *
- * NOTE: If you called usb_register_dev(), you still need to call
- * usb_deregister_dev() to clean up your driver's allocated minor numbers,
- * this * call will no longer do it for you.
- */
-void usb_deregister(struct usb_driver *driver)
-{
- pr_info("%s: deregistering interface driver %s\n",
- usbcore_name, driver->name);
-
- usb_remove_newid_files(driver);
- driver_unregister(&driver->drvwrap.driver);
- usb_free_dynids(driver);
-
- usbfs_update_special();
-}
-EXPORT_SYMBOL_GPL(usb_deregister);
-
-/* Forced unbinding of a USB interface driver, either because
- * it doesn't support pre_reset/post_reset/reset_resume or
- * because it doesn't support suspend/resume.
- *
- * The caller must hold @intf's device's lock, but not its pm_mutex
- * and not @intf->dev.sem.
- */
-void usb_forced_unbind_intf(struct usb_interface *intf)
-{
- struct usb_driver *driver = to_usb_driver(intf->dev.driver);
-
- dev_dbg(&intf->dev, "forced unbind\n");
- usb_driver_release_interface(driver, intf);
-
- /* Mark the interface for later rebinding */
- intf->needs_binding = 1;
-}
-
-/* Delayed forced unbinding of a USB interface driver and scan
- * for rebinding.
- *
- * The caller must hold @intf's device's lock, but not its pm_mutex
- * and not @intf->dev.sem.
- *
- * Note: Rebinds will be skipped if a system sleep transition is in
- * progress and the PM "complete" callback hasn't occurred yet.
- */
-void usb_rebind_intf(struct usb_interface *intf)
-{
- int rc;
-
- /* Delayed unbind of an existing driver */
- if (intf->dev.driver)
- usb_forced_unbind_intf(intf);
-
- /* Try to rebind the interface */
- if (!intf->dev.power.is_prepared) {
- intf->needs_binding = 0;
- rc = device_attach(&intf->dev);
- if (rc < 0)
- dev_warn(&intf->dev, "rebind failed: %d\n", rc);
- }
-}
-
-#ifdef CONFIG_PM
-
-/* Unbind drivers for @udev's interfaces that don't support suspend/resume
- * There is no check for reset_resume here because it can be determined
- * only during resume whether reset_resume is needed.
- *
- * The caller must hold @udev's device lock.
- */
-static void unbind_no_pm_drivers_interfaces(struct usb_device *udev)
-{
- struct usb_host_config *config;
- int i;
- struct usb_interface *intf;
- struct usb_driver *drv;
-
- config = udev->actconfig;
- if (config) {
- for (i = 0; i < config->desc.bNumInterfaces; ++i) {
- intf = config->interface[i];
-
- if (intf->dev.driver) {
- drv = to_usb_driver(intf->dev.driver);
- if (!drv->suspend || !drv->resume)
- usb_forced_unbind_intf(intf);
- }
- }
- }
-}
-
-/* Unbind drivers for @udev's interfaces that failed to support reset-resume.
- * These interfaces have the needs_binding flag set by usb_resume_interface().
- *
- * The caller must hold @udev's device lock.
- */
-static void unbind_no_reset_resume_drivers_interfaces(struct usb_device *udev)
-{
- struct usb_host_config *config;
- int i;
- struct usb_interface *intf;
-
- config = udev->actconfig;
- if (config) {
- for (i = 0; i < config->desc.bNumInterfaces; ++i) {
- intf = config->interface[i];
- if (intf->dev.driver && intf->needs_binding)
- usb_forced_unbind_intf(intf);
- }
- }
-}
-
-static void do_rebind_interfaces(struct usb_device *udev)
-{
- struct usb_host_config *config;
- int i;
- struct usb_interface *intf;
-
- config = udev->actconfig;
- if (config) {
- for (i = 0; i < config->desc.bNumInterfaces; ++i) {
- intf = config->interface[i];
- if (intf->needs_binding)
- usb_rebind_intf(intf);
- }
- }
-}
-
-static int usb_suspend_device(struct usb_device *udev, pm_message_t msg)
-{
- struct usb_device_driver *udriver;
- int status = 0;
-
- if (udev->state == USB_STATE_NOTATTACHED ||
- udev->state == USB_STATE_SUSPENDED)
- goto done;
-
- /* For devices that don't have a driver, we do a generic suspend. */
- if (udev->dev.driver)
- udriver = to_usb_device_driver(udev->dev.driver);
- else {
- udev->do_remote_wakeup = 0;
- udriver = &usb_generic_driver;
- }
- status = udriver->suspend(udev, msg);
-
- done:
- dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status);
- return status;
-}
-
-static int usb_resume_device(struct usb_device *udev, pm_message_t msg)
-{
- struct usb_device_driver *udriver;
- int status = 0;
-
- if (udev->state == USB_STATE_NOTATTACHED)
- goto done;
-
- /* Can't resume it if it doesn't have a driver. */
- if (udev->dev.driver == NULL) {
- status = -ENOTCONN;
- goto done;
- }
-
- /* Non-root devices on a full/low-speed bus must wait for their
- * companion high-speed root hub, in case a handoff is needed.
- */
- if (!PMSG_IS_AUTO(msg) && udev->parent && udev->bus->hs_companion)
- device_pm_wait_for_dev(&udev->dev,
- &udev->bus->hs_companion->root_hub->dev);
-
- if (udev->quirks & USB_QUIRK_RESET_RESUME)
- udev->reset_resume = 1;
-
- udriver = to_usb_device_driver(udev->dev.driver);
- status = udriver->resume(udev, msg);
-
- done:
- dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status);
- return status;
-}
-
-static int usb_suspend_interface(struct usb_device *udev,
- struct usb_interface *intf, pm_message_t msg)
-{
- struct usb_driver *driver;
- int status = 0;
-
- if (udev->state == USB_STATE_NOTATTACHED ||
- intf->condition == USB_INTERFACE_UNBOUND)
- goto done;
- driver = to_usb_driver(intf->dev.driver);
-
- /* at this time we know the driver supports suspend */
- status = driver->suspend(intf, msg);
- if (status && !PMSG_IS_AUTO(msg))
- dev_err(&intf->dev, "suspend error %d\n", status);
-
- done:
- dev_vdbg(&intf->dev, "%s: status %d\n", __func__, status);
- return status;
-}
-
-static int usb_resume_interface(struct usb_device *udev,
- struct usb_interface *intf, pm_message_t msg, int reset_resume)
-{
- struct usb_driver *driver;
- int status = 0;
-
- if (udev->state == USB_STATE_NOTATTACHED)
- goto done;
-
- /* Don't let autoresume interfere with unbinding */
- if (intf->condition == USB_INTERFACE_UNBINDING)
- goto done;
-
- /* Can't resume it if it doesn't have a driver. */
- if (intf->condition == USB_INTERFACE_UNBOUND) {
-
- /* Carry out a deferred switch to altsetting 0 */
- if (intf->needs_altsetting0 && !intf->dev.power.is_prepared) {
- usb_set_interface(udev, intf->altsetting[0].
- desc.bInterfaceNumber, 0);
- intf->needs_altsetting0 = 0;
- }
- goto done;
- }
-
- /* Don't resume if the interface is marked for rebinding */
- if (intf->needs_binding)
- goto done;
- driver = to_usb_driver(intf->dev.driver);
-
- if (reset_resume) {
- if (driver->reset_resume) {
- status = driver->reset_resume(intf);
- if (status)
- dev_err(&intf->dev, "%s error %d\n",
- "reset_resume", status);
- } else {
- intf->needs_binding = 1;
- dev_warn(&intf->dev, "no %s for driver %s?\n",
- "reset_resume", driver->name);
- }
- } else {
- status = driver->resume(intf);
- if (status)
- dev_err(&intf->dev, "resume error %d\n", status);
- }
-
-done:
- dev_vdbg(&intf->dev, "%s: status %d\n", __func__, status);
-
- /* Later we will unbind the driver and/or reprobe, if necessary */
- return status;
-}
-
-/**
- * usb_suspend_both - suspend a USB device and its interfaces
- * @udev: the usb_device to suspend
- * @msg: Power Management message describing this state transition
- *
- * This is the central routine for suspending USB devices. It calls the
- * suspend methods for all the interface drivers in @udev and then calls
- * the suspend method for @udev itself. If an error occurs at any stage,
- * all the interfaces which were suspended are resumed so that they remain
- * in the same state as the device.
- *
- * Autosuspend requests originating from a child device or an interface
- * driver may be made without the protection of @udev's device lock, but
- * all other suspend calls will hold the lock. Usbcore will insure that
- * method calls do not arrive during bind, unbind, or reset operations.
- * However drivers must be prepared to handle suspend calls arriving at
- * unpredictable times.
- *
- * This routine can run only in process context.
- */
-static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
-{
- int status = 0;
- int i = 0, n = 0;
- struct usb_interface *intf;
-
- if (udev->state == USB_STATE_NOTATTACHED ||
- udev->state == USB_STATE_SUSPENDED)
- goto done;
-
- /* Suspend all the interfaces and then udev itself */
- if (udev->actconfig) {
- n = udev->actconfig->desc.bNumInterfaces;
- for (i = n - 1; i >= 0; --i) {
- intf = udev->actconfig->interface[i];
- status = usb_suspend_interface(udev, intf, msg);
-
- /* Ignore errors during system sleep transitions */
- if (!PMSG_IS_AUTO(msg))
- status = 0;
- if (status != 0)
- break;
- }
- }
- if (status == 0) {
- status = usb_suspend_device(udev, msg);
-
- /*
- * Ignore errors from non-root-hub devices during
- * system sleep transitions. For the most part,
- * these devices should go to low power anyway when
- * the entire bus is suspended.
- */
- if (udev->parent && !PMSG_IS_AUTO(msg))
- status = 0;
- }
-
- /* If the suspend failed, resume interfaces that did get suspended */
- if (status != 0) {
- msg.event ^= (PM_EVENT_SUSPEND | PM_EVENT_RESUME);
- while (++i < n) {
- intf = udev->actconfig->interface[i];
- usb_resume_interface(udev, intf, msg, 0);
- }
-
- /* If the suspend succeeded then prevent any more URB submissions
- * and flush any outstanding URBs.
- */
- } else {
- udev->can_submit = 0;
- for (i = 0; i < 16; ++i) {
- usb_hcd_flush_endpoint(udev, udev->ep_out[i]);
- usb_hcd_flush_endpoint(udev, udev->ep_in[i]);
- }
- }
-
- done:
- dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status);
- return status;
-}
-
-/**
- * usb_resume_both - resume a USB device and its interfaces
- * @udev: the usb_device to resume
- * @msg: Power Management message describing this state transition
- *
- * This is the central routine for resuming USB devices. It calls the
- * the resume method for @udev and then calls the resume methods for all
- * the interface drivers in @udev.
- *
- * Autoresume requests originating from a child device or an interface
- * driver may be made without the protection of @udev's device lock, but
- * all other resume calls will hold the lock. Usbcore will insure that
- * method calls do not arrive during bind, unbind, or reset operations.
- * However drivers must be prepared to handle resume calls arriving at
- * unpredictable times.
- *
- * This routine can run only in process context.
- */
-static int usb_resume_both(struct usb_device *udev, pm_message_t msg)
-{
- int status = 0;
- int i;
- struct usb_interface *intf;
-
- if (udev->state == USB_STATE_NOTATTACHED) {
- status = -ENODEV;
- goto done;
- }
- udev->can_submit = 1;
-
- /* Resume the device */
- if (udev->state == USB_STATE_SUSPENDED || udev->reset_resume)
- status = usb_resume_device(udev, msg);
-
- /* Resume the interfaces */
- if (status == 0 && udev->actconfig) {
- for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
- intf = udev->actconfig->interface[i];
- usb_resume_interface(udev, intf, msg,
- udev->reset_resume);
- }
- }
- usb_mark_last_busy(udev);
-
- done:
- dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status);
- if (!(&udev->dev))
- printk("(NULL device *): %s: status %d\n", __func__, status);
- else
- printk("%s%s : %s: status %d\n",dev_driver_string(&udev->dev), dev_name(&udev->dev), __func__, status);
- if (!status)
- udev->reset_resume = 0;
- return status;
-}
-
-static void choose_wakeup(struct usb_device *udev, pm_message_t msg)
-{
- int w;
-
- /* Remote wakeup is needed only when we actually go to sleep.
- * For things like FREEZE and QUIESCE, if the device is already
- * autosuspended then its current wakeup setting is okay.
- */
- if (msg.event == PM_EVENT_FREEZE || msg.event == PM_EVENT_QUIESCE) {
- if (udev->state != USB_STATE_SUSPENDED)
- udev->do_remote_wakeup = 0;
- return;
- }
-
- /* Enable remote wakeup if it is allowed, even if no interface drivers
- * actually want it.
- */
- w = device_may_wakeup(&udev->dev);
-
- /* If the device is autosuspended with the wrong wakeup setting,
- * autoresume now so the setting can be changed.
- */
- if (udev->state == USB_STATE_SUSPENDED && w != udev->do_remote_wakeup)
- pm_runtime_resume(&udev->dev);
- udev->do_remote_wakeup = w;
-}
-
-/* The device lock is held by the PM core */
-int usb_suspend(struct device *dev, pm_message_t msg)
-{
- struct usb_device *udev = to_usb_device(dev);
-
- unbind_no_pm_drivers_interfaces(udev);
-
- /* From now on we are sure all drivers support suspend/resume
- * but not necessarily reset_resume()
- * so we may still need to unbind and rebind upon resume
- */
- choose_wakeup(udev, msg);
- return usb_suspend_both(udev, msg);
-}
-
-/* The device lock is held by the PM core */
-int usb_resume_complete(struct device *dev)
-{
- struct usb_device *udev = to_usb_device(dev);
-
- /* For PM complete calls, all we do is rebind interfaces
- * whose needs_binding flag is set
- */
- if (udev->state != USB_STATE_NOTATTACHED)
- do_rebind_interfaces(udev);
- return 0;
-}
-
-/* The device lock is held by the PM core */
-int usb_resume(struct device *dev, pm_message_t msg)
-{
- struct usb_device *udev = to_usb_device(dev);
- int status;
-
- /* For all calls, take the device back to full power and
- * tell the PM core in case it was autosuspended previously.
- * Unbind the interfaces that will need rebinding later,
- * because they fail to support reset_resume.
- * (This can't be done in usb_resume_interface()
- * above because it doesn't own the right set of locks.)
- */
- status = usb_resume_both(udev, msg);
- if (status == 0) {
- pm_runtime_disable(dev);
- pm_runtime_set_active(dev);
- pm_runtime_enable(dev);
- unbind_no_reset_resume_drivers_interfaces(udev);
- }
-
- /* Avoid PM error messages for devices disconnected while suspended
- * as we'll display regular disconnect messages just a bit later.
- */
- if (status == -ENODEV || status == -ESHUTDOWN)
- status = 0;
- return status;
-}
-
-#endif /* CONFIG_PM */
-
-#ifdef CONFIG_USB_SUSPEND
-
-/**
- * usb_enable_autosuspend - allow a USB device to be autosuspended
- * @udev: the USB device which may be autosuspended
- *
- * This routine allows @udev to be autosuspended. An autosuspend won't
- * take place until the autosuspend_delay has elapsed and all the other
- * necessary conditions are satisfied.
- *
- * The caller must hold @udev's device lock.
- */
-void usb_enable_autosuspend(struct usb_device *udev)
-{
- pm_runtime_allow(&udev->dev);
-}
-EXPORT_SYMBOL_GPL(usb_enable_autosuspend);
-
-/**
- * usb_disable_autosuspend - prevent a USB device from being autosuspended
- * @udev: the USB device which may not be autosuspended
- *
- * This routine prevents @udev from being autosuspended and wakes it up
- * if it is already autosuspended.
- *
- * The caller must hold @udev's device lock.
- */
-void usb_disable_autosuspend(struct usb_device *udev)
-{
- pm_runtime_forbid(&udev->dev);
-}
-EXPORT_SYMBOL_GPL(usb_disable_autosuspend);
-
-/**
- * usb_autosuspend_device - delayed autosuspend of a USB device and its interfaces
- * @udev: the usb_device to autosuspend
- *
- * This routine should be called when a core subsystem is finished using
- * @udev and wants to allow it to autosuspend. Examples would be when
- * @udev's device file in usbfs is closed or after a configuration change.
- *
- * @udev's usage counter is decremented; if it drops to 0 and all the
- * interfaces are inactive then a delayed autosuspend will be attempted.
- * The attempt may fail (see autosuspend_check()).
- *
- * The caller must hold @udev's device lock.
- *
- * This routine can run only in process context.
- */
-void usb_autosuspend_device(struct usb_device *udev)
-{
- int status;
-
- usb_mark_last_busy(udev);
- status = pm_runtime_put_sync_autosuspend(&udev->dev);
- dev_vdbg(&udev->dev, "%s: cnt %d -> %d\n",
- __func__, atomic_read(&udev->dev.power.usage_count),
- status);
-}
-
-/**
- * usb_autoresume_device - immediately autoresume a USB device and its interfaces
- * @udev: the usb_device to autoresume
- *
- * This routine should be called when a core subsystem wants to use @udev
- * and needs to guarantee that it is not suspended. No autosuspend will
- * occur until usb_autosuspend_device() is called. (Note that this will
- * not prevent suspend events originating in the PM core.) Examples would
- * be when @udev's device file in usbfs is opened or when a remote-wakeup
- * request is received.
- *
- * @udev's usage counter is incremented to prevent subsequent autosuspends.
- * However if the autoresume fails then the usage counter is re-decremented.
- *
- * The caller must hold @udev's device lock.
- *
- * This routine can run only in process context.
- */
-int usb_autoresume_device(struct usb_device *udev)
-{
- int status;
-
- status = pm_runtime_get_sync(&udev->dev);
- if (status < 0)
- pm_runtime_put_sync(&udev->dev);
- dev_vdbg(&udev->dev, "%s: cnt %d -> %d\n",
- __func__, atomic_read(&udev->dev.power.usage_count),
- status);
- if (status > 0)
- status = 0;
- return status;
-}
-
-/**
- * usb_autopm_put_interface - decrement a USB interface's PM-usage counter
- * @intf: the usb_interface whose counter should be decremented
- *
- * This routine should be called by an interface driver when it is
- * finished using @intf and wants to allow it to autosuspend. A typical
- * example would be a character-device driver when its device file is
- * closed.
- *
- * The routine decrements @intf's usage counter. When the counter reaches
- * 0, a delayed autosuspend request for @intf's device is attempted. The
- * attempt may fail (see autosuspend_check()).
- *
- * This routine can run only in process context.
- */
-void usb_autopm_put_interface(struct usb_interface *intf)
-{
- struct usb_device *udev = interface_to_usbdev(intf);
- int status;
-
- usb_mark_last_busy(udev);
- atomic_dec(&intf->pm_usage_cnt);
- status = pm_runtime_put_sync(&intf->dev);
- dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n",
- __func__, atomic_read(&intf->dev.power.usage_count),
- status);
-}
-EXPORT_SYMBOL_GPL(usb_autopm_put_interface);
-
-/**
- * usb_autopm_put_interface_async - decrement a USB interface's PM-usage counter
- * @intf: the usb_interface whose counter should be decremented
- *
- * This routine does much the same thing as usb_autopm_put_interface():
- * It decrements @intf's usage counter and schedules a delayed
- * autosuspend request if the counter is <= 0. The difference is that it
- * does not perform any synchronization; callers should hold a private
- * lock and handle all synchronization issues themselves.
- *
- * Typically a driver would call this routine during an URB's completion
- * handler, if no more URBs were pending.
- *
- * This routine can run in atomic context.
- */
-void usb_autopm_put_interface_async(struct usb_interface *intf)
-{
- struct usb_device *udev = interface_to_usbdev(intf);
- int status;
-
- usb_mark_last_busy(udev);
- atomic_dec(&intf->pm_usage_cnt);
- status = pm_runtime_put(&intf->dev);
- dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n",
- __func__, atomic_read(&intf->dev.power.usage_count),
- status);
-}
-EXPORT_SYMBOL_GPL(usb_autopm_put_interface_async);
-
-/**
- * usb_autopm_put_interface_no_suspend - decrement a USB interface's PM-usage counter
- * @intf: the usb_interface whose counter should be decremented
- *
- * This routine decrements @intf's usage counter but does not carry out an
- * autosuspend.
- *
- * This routine can run in atomic context.
- */
-void usb_autopm_put_interface_no_suspend(struct usb_interface *intf)
-{
- struct usb_device *udev = interface_to_usbdev(intf);
-
- usb_mark_last_busy(udev);
- atomic_dec(&intf->pm_usage_cnt);
- pm_runtime_put_noidle(&intf->dev);
-}
-EXPORT_SYMBOL_GPL(usb_autopm_put_interface_no_suspend);
-
-/**
- * usb_autopm_get_interface - increment a USB interface's PM-usage counter
- * @intf: the usb_interface whose counter should be incremented
- *
- * This routine should be called by an interface driver when it wants to
- * use @intf and needs to guarantee that it is not suspended. In addition,
- * the routine prevents @intf from being autosuspended subsequently. (Note
- * that this will not prevent suspend events originating in the PM core.)
- * This prevention will persist until usb_autopm_put_interface() is called
- * or @intf is unbound. A typical example would be a character-device
- * driver when its device file is opened.
- *
- * @intf's usage counter is incremented to prevent subsequent autosuspends.
- * However if the autoresume fails then the counter is re-decremented.
- *
- * This routine can run only in process context.
- */
-int usb_autopm_get_interface(struct usb_interface *intf)
-{
- int status;
-
- status = pm_runtime_get_sync(&intf->dev);
- if (status < 0)
- pm_runtime_put_sync(&intf->dev);
- else
- atomic_inc(&intf->pm_usage_cnt);
- dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n",
- __func__, atomic_read(&intf->dev.power.usage_count),
- status);
- if (status > 0)
- status = 0;
- return status;
-}
-EXPORT_SYMBOL_GPL(usb_autopm_get_interface);
-
-/**
- * usb_autopm_get_interface_async - increment a USB interface's PM-usage counter
- * @intf: the usb_interface whose counter should be incremented
- *
- * This routine does much the same thing as
- * usb_autopm_get_interface(): It increments @intf's usage counter and
- * queues an autoresume request if the device is suspended. The
- * differences are that it does not perform any synchronization (callers
- * should hold a private lock and handle all synchronization issues
- * themselves), and it does not autoresume the device directly (it only
- * queues a request). After a successful call, the device may not yet be
- * resumed.
- *
- * This routine can run in atomic context.
- */
-int usb_autopm_get_interface_async(struct usb_interface *intf)
-{
- int status;
-
- status = pm_runtime_get(&intf->dev);
- if (status < 0 && status != -EINPROGRESS)
- pm_runtime_put_noidle(&intf->dev);
- else
- atomic_inc(&intf->pm_usage_cnt);
- dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n",
- __func__, atomic_read(&intf->dev.power.usage_count),
- status);
- if (status > 0 || status == -EINPROGRESS)
- status = 0;
- return status;
-}
-EXPORT_SYMBOL_GPL(usb_autopm_get_interface_async);
-
-/**
- * usb_autopm_get_interface_no_resume - increment a USB interface's PM-usage counter
- * @intf: the usb_interface whose counter should be incremented
- *
- * This routine increments @intf's usage counter but does not carry out an
- * autoresume.
- *
- * This routine can run in atomic context.
- */
-void usb_autopm_get_interface_no_resume(struct usb_interface *intf)
-{
- struct usb_device *udev = interface_to_usbdev(intf);
-
- usb_mark_last_busy(udev);
- atomic_inc(&intf->pm_usage_cnt);
- pm_runtime_get_noresume(&intf->dev);
-}
-EXPORT_SYMBOL_GPL(usb_autopm_get_interface_no_resume);
-
-/* Internal routine to check whether we may autosuspend a device. */
-static int autosuspend_check(struct usb_device *udev)
-{
- int w, i;
- struct usb_interface *intf;
-
- /* Fail if autosuspend is disabled, or any interfaces are in use, or
- * any interface drivers require remote wakeup but it isn't available.
- */
- w = 0;
- if (udev->actconfig) {
- for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
- intf = udev->actconfig->interface[i];
-
- /* We don't need to check interfaces that are
- * disabled for runtime PM. Either they are unbound
- * or else their drivers don't support autosuspend
- * and so they are permanently active.
- */
- if (intf->dev.power.disable_depth)
- continue;
- if (atomic_read(&intf->dev.power.usage_count) > 0)
- return -EBUSY;
- w |= intf->needs_remote_wakeup;
-
- /* Don't allow autosuspend if the device will need
- * a reset-resume and any of its interface drivers
- * doesn't include support or needs remote wakeup.
- */
- if (udev->quirks & USB_QUIRK_RESET_RESUME) {
- struct usb_driver *driver;
-
- driver = to_usb_driver(intf->dev.driver);
- if (!driver->reset_resume ||
- intf->needs_remote_wakeup)
- return -EOPNOTSUPP;
- }
- }
- }
- if (w && !device_can_wakeup(&udev->dev)) {
- dev_dbg(&udev->dev, "remote wakeup needed for autosuspend\n");
- return -EOPNOTSUPP;
- }
- udev->do_remote_wakeup = w;
- return 0;
-}
-
-int usb_runtime_suspend(struct device *dev)
-{
- struct usb_device *udev = to_usb_device(dev);
- int status;
-
- /* A USB device can be suspended if it passes the various autosuspend
- * checks. Runtime suspend for a USB device means suspending all the
- * interfaces and then the device itself.
- */
- if (autosuspend_check(udev) != 0)
- return -EAGAIN;
-
- status = usb_suspend_both(udev, PMSG_AUTO_SUSPEND);
-
- /* Allow a retry if autosuspend failed temporarily */
- if (status == -EAGAIN || status == -EBUSY)
- usb_mark_last_busy(udev);
-
- /* The PM core reacts badly unless the return code is 0,
- * -EAGAIN, or -EBUSY, so always return -EBUSY on an error.
- */
- if (status != 0)
- return -EBUSY;
- return status;
-}
-
-int usb_runtime_resume(struct device *dev)
-{
- struct usb_device *udev = to_usb_device(dev);
- int status;
-
- /* Runtime resume for a USB device means resuming both the device
- * and all its interfaces.
- */
- status = usb_resume_both(udev, PMSG_AUTO_RESUME);
- return status;
-}
-
-int usb_runtime_idle(struct device *dev)
-{
- struct usb_device *udev = to_usb_device(dev);
-
- /* An idle USB device can be suspended if it passes the various
- * autosuspend checks.
- */
- if (autosuspend_check(udev) == 0)
- pm_runtime_autosuspend(dev);
- return 0;
-}
-
-int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable)
-{
- struct usb_hcd *hcd = bus_to_hcd(udev->bus);
- int ret = -EPERM;
-
- if (hcd->driver->set_usb2_hw_lpm) {
- ret = hcd->driver->set_usb2_hw_lpm(hcd, udev, enable);
- if (!ret)
- udev->usb2_hw_lpm_enabled = enable;
- }
-
- return ret;
-}
-
-#endif /* CONFIG_USB_SUSPEND */
-
-struct bus_type usb_bus_type = {
- .name = "usb",
- .match = usb_device_match,
- .uevent = usb_uevent,
-};
diff --git a/ANDROID_3.4.5/drivers/usb/core/endpoint.c b/ANDROID_3.4.5/drivers/usb/core/endpoint.c
deleted file mode 100644
index db7fe50c..00000000
--- a/ANDROID_3.4.5/drivers/usb/core/endpoint.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * drivers/usb/core/endpoint.c
- *
- * (C) Copyright 2002,2004,2006 Greg Kroah-Hartman
- * (C) Copyright 2002,2004 IBM Corp.
- * (C) Copyright 2006 Novell Inc.
- *
- * Endpoint sysfs stuff
- *
- */
-
-#include
-#include
-#include
-#include
-#include
-#include "usb.h"
-
-struct ep_device {
- struct usb_endpoint_descriptor *desc;
- struct usb_device *udev;
- struct device dev;
-};
-#define to_ep_device(_dev) \
- container_of(_dev, struct ep_device, dev)
-
-struct device_type usb_ep_device_type = {
- .name = "usb_endpoint",
-};
-
-struct ep_attribute {
- struct attribute attr;
- ssize_t (*show)(struct usb_device *,
- struct usb_endpoint_descriptor *, char *);
-};
-#define to_ep_attribute(_attr) \
- container_of(_attr, struct ep_attribute, attr)
-
-#define usb_ep_attr(field, format_string) \
-static ssize_t show_ep_##field(struct device *dev, \
- struct device_attribute *attr, \
- char *buf) \
-{ \
- struct ep_device *ep = to_ep_device(dev); \
- return sprintf(buf, format_string, ep->desc->field); \
-} \
-static DEVICE_ATTR(field, S_IRUGO, show_ep_##field, NULL);
-
-usb_ep_attr(bLength, "%02x\n")
-usb_ep_attr(bEndpointAddress, "%02x\n")
-usb_ep_attr(bmAttributes, "%02x\n")
-usb_ep_attr(bInterval, "%02x\n")
-
-static ssize_t show_ep_wMaxPacketSize(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct ep_device *ep = to_ep_device(dev);
- return sprintf(buf, "%04x\n",
- usb_endpoint_maxp(ep->desc) & 0x07ff);
-}
-static DEVICE_ATTR(wMaxPacketSize, S_IRUGO, show_ep_wMaxPacketSize, NULL);
-
-static ssize_t show_ep_type(struct device *dev, struct device_attribute *attr,
- char *buf)
-{
- struct ep_device *ep = to_ep_device(dev);
- char *type = "unknown";
-
- switch (usb_endpoint_type(ep->desc)) {
- case USB_ENDPOINT_XFER_CONTROL:
- type = "Control";
- break;
- case USB_ENDPOINT_XFER_ISOC:
- type = "Isoc";
- break;
- case USB_ENDPOINT_XFER_BULK:
- type = "Bulk";
- break;
- case USB_ENDPOINT_XFER_INT:
- type = "Interrupt";
- break;
- }
- return sprintf(buf, "%s\n", type);
-}
-static DEVICE_ATTR(type, S_IRUGO, show_ep_type, NULL);
-
-static ssize_t show_ep_interval(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct ep_device *ep = to_ep_device(dev);
- char unit;
- unsigned interval = 0;
- unsigned in;
-
- in = (ep->desc->bEndpointAddress & USB_DIR_IN);
-
- switch (usb_endpoint_type(ep->desc)) {
- case USB_ENDPOINT_XFER_CONTROL:
- if (ep->udev->speed == USB_SPEED_HIGH)
- /* uframes per NAK */
- interval = ep->desc->bInterval;
- break;
-
- case USB_ENDPOINT_XFER_ISOC:
- interval = 1 << (ep->desc->bInterval - 1);
- break;
-
- case USB_ENDPOINT_XFER_BULK:
- if (ep->udev->speed == USB_SPEED_HIGH && !in)
- /* uframes per NAK */
- interval = ep->desc->bInterval;
- break;
-
- case USB_ENDPOINT_XFER_INT:
- if (ep->udev->speed == USB_SPEED_HIGH)
- interval = 1 << (ep->desc->bInterval - 1);
- else
- interval = ep->desc->bInterval;
- break;
- }
- interval *= (ep->udev->speed == USB_SPEED_HIGH) ? 125 : 1000;
- if (interval % 1000)
- unit = 'u';
- else {
- unit = 'm';
- interval /= 1000;
- }
-
- return sprintf(buf, "%d%cs\n", interval, unit);
-}
-static DEVICE_ATTR(interval, S_IRUGO, show_ep_interval, NULL);
-
-static ssize_t show_ep_direction(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct ep_device *ep = to_ep_device(dev);
- char *direction;
-
- if (usb_endpoint_xfer_control(ep->desc))
- direction = "both";
- else if (usb_endpoint_dir_in(ep->desc))
- direction = "in";
- else
- direction = "out";
- return sprintf(buf, "%s\n", direction);
-}
-static DEVICE_ATTR(direction, S_IRUGO, show_ep_direction, NULL);
-
-static struct attribute *ep_dev_attrs[] = {
- &dev_attr_bLength.attr,
- &dev_attr_bEndpointAddress.attr,
- &dev_attr_bmAttributes.attr,
- &dev_attr_bInterval.attr,
- &dev_attr_wMaxPacketSize.attr,
- &dev_attr_interval.attr,
- &dev_attr_type.attr,
- &dev_attr_direction.attr,
- NULL,
-};
-static struct attribute_group ep_dev_attr_grp = {
- .attrs = ep_dev_attrs,
-};
-static const struct attribute_group *ep_dev_groups[] = {
- &ep_dev_attr_grp,
- NULL
-};
-
-static void ep_device_release(struct device *dev)
-{
- struct ep_device *ep_dev = to_ep_device(dev);
-
- kfree(ep_dev);
-}
-
-int usb_create_ep_devs(struct device *parent,
- struct usb_host_endpoint *endpoint,
- struct usb_device *udev)
-{
- struct ep_device *ep_dev;
- int retval;
-
- ep_dev = kzalloc(sizeof(*ep_dev), GFP_KERNEL);
- if (!ep_dev) {
- retval = -ENOMEM;
- goto exit;
- }
-
- ep_dev->desc = &endpoint->desc;
- ep_dev->udev = udev;
- ep_dev->dev.groups = ep_dev_groups;
- ep_dev->dev.type = &usb_ep_device_type;
- ep_dev->dev.parent = parent;
- ep_dev->dev.release = ep_device_release;
- dev_set_name(&ep_dev->dev, "ep_%02x", endpoint->desc.bEndpointAddress);
-
- retval = device_register(&ep_dev->dev);
- if (retval)
- goto error_register;
-
- device_enable_async_suspend(&ep_dev->dev);
- endpoint->ep_dev = ep_dev;
- return retval;
-
-error_register:
- put_device(&ep_dev->dev);
-exit:
- return retval;
-}
-
-void usb_remove_ep_devs(struct usb_host_endpoint *endpoint)
-{
- struct ep_device *ep_dev = endpoint->ep_dev;
-
- if (ep_dev) {
- device_unregister(&ep_dev->dev);
- endpoint->ep_dev = NULL;
- }
-}
diff --git a/ANDROID_3.4.5/drivers/usb/core/file.c b/ANDROID_3.4.5/drivers/usb/core/file.c
deleted file mode 100644
index d95760de..00000000
--- a/ANDROID_3.4.5/drivers/usb/core/file.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * drivers/usb/core/file.c
- *
- * (C) Copyright Linus Torvalds 1999
- * (C) Copyright Johannes Erdfelt 1999-2001
- * (C) Copyright Andreas Gal 1999
- * (C) Copyright Gregory P. Smith 1999
- * (C) Copyright Deti Fliegl 1999 (new USB architecture)
- * (C) Copyright Randy Dunlap 2000
- * (C) Copyright David Brownell 2000-2001 (kernel hotplug, usb_device_id,
- more docs, etc)
- * (C) Copyright Yggdrasil Computing, Inc. 2000
- * (usb_device_id matching changes by Adam J. Richter)
- * (C) Copyright Greg Kroah-Hartman 2002-2003
- *
- */
-
-#include
-#include
-#include
-#include
-#include
-
-#include "usb.h"
-
-#define MAX_USB_MINORS 256
-static const struct file_operations *usb_minors[MAX_USB_MINORS];
-static DECLARE_RWSEM(minor_rwsem);
-
-static int usb_open(struct inode * inode, struct file * file)
-{
- int minor = iminor(inode);
- const struct file_operations *c;
- int err = -ENODEV;
- const struct file_operations *old_fops, *new_fops = NULL;
-
- down_read(&minor_rwsem);
- c = usb_minors[minor];
-
- if (!c || !(new_fops = fops_get(c)))
- goto done;
-
- old_fops = file->f_op;
- file->f_op = new_fops;
- /* Curiouser and curiouser... NULL ->open() as "no device" ? */
- if (file->f_op->open)
- err = file->f_op->open(inode,file);
- if (err) {
- fops_put(file->f_op);
- file->f_op = fops_get(old_fops);
- }
- fops_put(old_fops);
- done:
- up_read(&minor_rwsem);
- return err;
-}
-
-static const struct file_operations usb_fops = {
- .owner = THIS_MODULE,
- .open = usb_open,
- .llseek = noop_llseek,
-};
-
-static struct usb_class {
- struct kref kref;
- struct class *class;
-} *usb_class;
-
-static char *usb_devnode(struct device *dev, umode_t *mode)
-{
- struct usb_class_driver *drv;
-
- drv = dev_get_drvdata(dev);
- if (!drv || !drv->devnode)
- return NULL;
- return drv->devnode(dev, mode);
-}
-
-static int init_usb_class(void)
-{
- int result = 0;
-
- if (usb_class != NULL) {
- kref_get(&usb_class->kref);
- goto exit;
- }
-
- usb_class = kmalloc(sizeof(*usb_class), GFP_KERNEL);
- if (!usb_class) {
- result = -ENOMEM;
- goto exit;
- }
-
- kref_init(&usb_class->kref);
- usb_class->class = class_create(THIS_MODULE, "usb");
- if (IS_ERR(usb_class->class)) {
- result = IS_ERR(usb_class->class);
- printk(KERN_ERR "class_create failed for usb devices\n");
- kfree(usb_class);
- usb_class = NULL;
- goto exit;
- }
- usb_class->class->devnode = usb_devnode;
-
-exit:
- return result;
-}
-
-static void release_usb_class(struct kref *kref)
-{
- /* Ok, we cheat as we know we only have one usb_class */
- class_destroy(usb_class->class);
- kfree(usb_class);
- usb_class = NULL;
-}
-
-static void destroy_usb_class(void)
-{
- if (usb_class)
- kref_put(&usb_class->kref, release_usb_class);
-}
-
-int usb_major_init(void)
-{
- int error;
-
- error = register_chrdev(USB_MAJOR, "usb", &usb_fops);
- if (error)
- printk(KERN_ERR "Unable to get major %d for usb devices\n",
- USB_MAJOR);
-
- return error;
-}
-
-void usb_major_cleanup(void)
-{
- unregister_chrdev(USB_MAJOR, "usb");
-}
-
-/**
- * usb_register_dev - register a USB device, and ask for a minor number
- * @intf: pointer to the usb_interface that is being registered
- * @class_driver: pointer to the usb_class_driver for this device
- *
- * This should be called by all USB drivers that use the USB major number.
- * If CONFIG_USB_DYNAMIC_MINORS is enabled, the minor number will be
- * dynamically allocated out of the list of available ones. If it is not
- * enabled, the minor number will be based on the next available free minor,
- * starting at the class_driver->minor_base.
- *
- * This function also creates a usb class device in the sysfs tree.
- *
- * usb_deregister_dev() must be called when the driver is done with
- * the minor numbers given out by this function.
- *
- * Returns -EINVAL if something bad happens with trying to register a
- * device, and 0 on success.
- */
-int usb_register_dev(struct usb_interface *intf,
- struct usb_class_driver *class_driver)
-{
- int retval;
- int minor_base = class_driver->minor_base;
- int minor;
- char name[20];
- char *temp;
-
-#ifdef CONFIG_USB_DYNAMIC_MINORS
- /*
- * We don't care what the device tries to start at, we want to start
- * at zero to pack the devices into the smallest available space with
- * no holes in the minor range.
- */
- minor_base = 0;
-#endif
-
- if (class_driver->fops == NULL)
- return -EINVAL;
- if (intf->minor >= 0)
- return -EADDRINUSE;
-
- retval = init_usb_class();
- if (retval)
- return retval;
-
- dev_dbg(&intf->dev, "looking for a minor, starting at %d", minor_base);
-
- down_write(&minor_rwsem);
- for (minor = minor_base; minor < MAX_USB_MINORS; ++minor) {
- if (usb_minors[minor])
- continue;
-
- usb_minors[minor] = class_driver->fops;
- intf->minor = minor;
- break;
- }
- up_write(&minor_rwsem);
- if (intf->minor < 0)
- return -EXFULL;
-
- /* create a usb class device for this usb interface */
- snprintf(name, sizeof(name), class_driver->name, minor - minor_base);
- temp = strrchr(name, '/');
- if (temp && (temp[1] != '\0'))
- ++temp;
- else
- temp = name;
- intf->usb_dev = device_create(usb_class->class, &intf->dev,
- MKDEV(USB_MAJOR, minor), class_driver,
- "%s", temp);
- if (IS_ERR(intf->usb_dev)) {
- down_write(&minor_rwsem);
- usb_minors[minor] = NULL;
- intf->minor = -1;
- up_write(&minor_rwsem);
- retval = PTR_ERR(intf->usb_dev);
- }
- return retval;
-}
-EXPORT_SYMBOL_GPL(usb_register_dev);
-
-/**
- * usb_deregister_dev - deregister a USB device's dynamic minor.
- * @intf: pointer to the usb_interface that is being deregistered
- * @class_driver: pointer to the usb_class_driver for this device
- *
- * Used in conjunction with usb_register_dev(). This function is called
- * when the USB driver is finished with the minor numbers gotten from a
- * call to usb_register_dev() (usually when the device is disconnected
- * from the system.)
- *
- * This function also removes the usb class device from the sysfs tree.
- *
- * This should be called by all drivers that use the USB major number.
- */
-void usb_deregister_dev(struct usb_interface *intf,
- struct usb_class_driver *class_driver)
-{
- if (intf->minor == -1)
- return;
-
- dbg ("removing %d minor", intf->minor);
-
- down_write(&minor_rwsem);
- usb_minors[intf->minor] = NULL;
- up_write(&minor_rwsem);
-
- device_destroy(usb_class->class, MKDEV(USB_MAJOR, intf->minor));
- intf->usb_dev = NULL;
- intf->minor = -1;
- destroy_usb_class();
-}
-EXPORT_SYMBOL_GPL(usb_deregister_dev);
diff --git a/ANDROID_3.4.5/drivers/usb/core/generic.c b/ANDROID_3.4.5/drivers/usb/core/generic.c
deleted file mode 100644
index ec4bfde3..00000000
--- a/ANDROID_3.4.5/drivers/usb/core/generic.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * drivers/usb/generic.c - generic driver for USB devices (not interfaces)
- *
- * (C) Copyright 2005 Greg Kroah-Hartman
- *
- * based on drivers/usb/usb.c which had the following copyrights:
- * (C) Copyright Linus Torvalds 1999
- * (C) Copyright Johannes Erdfelt 1999-2001
- * (C) Copyright Andreas Gal 1999
- * (C) Copyright Gregory P. Smith 1999
- * (C) Copyright Deti Fliegl 1999 (new USB architecture)
- * (C) Copyright Randy Dunlap 2000
- * (C) Copyright David Brownell 2000-2004
- * (C) Copyright Yggdrasil Computing, Inc. 2000
- * (usb_device_id matching changes by Adam J. Richter)
- * (C) Copyright Greg Kroah-Hartman 2002-2003
- *
- */
-
-#include
-#include
-#include "usb.h"
-extern int usb_power_insuf_skip=0; //read from uboot,default is false;
-
-static inline const char *plural(int n)
-{
- return (n == 1 ? "" : "s");
-}
-
-static int is_rndis(struct usb_interface_descriptor *desc)
-{
- return desc->bInterfaceClass == USB_CLASS_COMM
- && desc->bInterfaceSubClass == 2
- && desc->bInterfaceProtocol == 0xff;
-}
-
-static int is_activesync(struct usb_interface_descriptor *desc)
-{
- return desc->bInterfaceClass == USB_CLASS_MISC
- && desc->bInterfaceSubClass == 1
- && desc->bInterfaceProtocol == 1;
-}
-
-int usb_choose_configuration(struct usb_device *udev)
-{
- int i;
- int num_configs;
- int insufficient_power = 0;
- struct usb_host_config *c, *best;
-
- best = NULL;
- c = udev->config;
- num_configs = udev->descriptor.bNumConfigurations;
- for (i = 0; i < num_configs; (i++, c++)) {
- struct usb_interface_descriptor *desc = NULL;
-
- /* It's possible that a config has no interfaces! */
- if (c->desc.bNumInterfaces > 0)
- desc = &c->intf_cache[0]->altsetting->desc;
-
- /*
- * HP's USB bus-powered keyboard has only one configuration
- * and it claims to be self-powered; other devices may have
- * similar errors in their descriptors. If the next test
- * were allowed to execute, such configurations would always
- * be rejected and the devices would not work as expected.
- * In the meantime, we run the risk of selecting a config
- * that requires external power at a time when that power
- * isn't available. It seems to be the lesser of two evils.
- *
- * Bugzilla #6448 reports a device that appears to crash
- * when it receives a GET_DEVICE_STATUS request! We don't
- * have any other way to tell whether a device is self-powered,
- * but since we don't use that information anywhere but here,
- * the call has been removed.
- *
- * Maybe the GET_DEVICE_STATUS call and the test below can
- * be reinstated when device firmwares become more reliable.
- * Don't hold your breath.
- */
-#if 0
- /* Rule out self-powered configs for a bus-powered device */
- if (bus_powered && (c->desc.bmAttributes &
- USB_CONFIG_ATT_SELFPOWER))
- continue;
-#endif
-
- /*
- * The next test may not be as effective as it should be.
- * Some hubs have errors in their descriptor, claiming
- * to be self-powered when they are really bus-powered.
- * We will overestimate the amount of current such hubs
- * make available for each port.
- *
- * This is a fairly benign sort of failure. It won't
- * cause us to reject configurations that we should have
- * accepted.
- */
-
- /* Rule out configs that draw too much bus current */
- if(!usb_power_insuf_skip)
- if (c->desc.bMaxPower * 2 > udev->bus_mA) {
- insufficient_power++;
- continue;
- }
-
- /* When the first config's first interface is one of Microsoft's
- * pet nonstandard Ethernet-over-USB protocols, ignore it unless
- * this kernel has enabled the necessary host side driver.
- * But: Don't ignore it if it's the only config.
- */
- if (i == 0 && num_configs > 1 && desc &&
- (is_rndis(desc) || is_activesync(desc))) {
-#if !defined(CONFIG_USB_NET_RNDIS_HOST) && !defined(CONFIG_USB_NET_RNDIS_HOST_MODULE)
- continue;
-#else
- best = c;
-#endif
- }
-
- /* From the remaining configs, choose the first one whose
- * first interface is for a non-vendor-specific class.
- * Reason: Linux is more likely to have a class driver
- * than a vendor-specific driver. */
- else if (udev->descriptor.bDeviceClass !=
- USB_CLASS_VENDOR_SPEC &&
- (desc && desc->bInterfaceClass !=
- USB_CLASS_VENDOR_SPEC)) {
- best = c;
- break;
- }
-
- /* If all the remaining configs are vendor-specific,
- * choose the first one. */
- else if (!best)
- best = c;
- }
-
- if (insufficient_power > 0)
- dev_info(&udev->dev, "rejected %d configuration%s "
- "due to insufficient available bus power\n",
- insufficient_power, plural(insufficient_power));
-
- if (best) {
- i = best->desc.bConfigurationValue;
- dev_dbg(&udev->dev,
- "configuration #%d chosen from %d choice%s\n",
- i, num_configs, plural(num_configs));
- } else {
- i = -1;
- dev_warn(&udev->dev,
- "no configuration chosen from %d choice%s\n",
- num_configs, plural(num_configs));
- }
- return i;
-}
-
-static int generic_probe(struct usb_device *udev)
-{
- int err, c;
-
- /* Choose and set the configuration. This registers the interfaces
- * with the driver core and lets interface drivers bind to them.
- */
- if (usb_device_is_owned(udev))
- ; /* Don't configure if the device is owned */
- else if (udev->authorized == 0)
- dev_err(&udev->dev, "Device is not authorized for usage\n");
- else {
- c = usb_choose_configuration(udev);
- if (c >= 0) {
- err = usb_set_configuration(udev, c);
- if (err) {
- dev_err(&udev->dev, "can't set config #%d, error %d\n",
- c, err);
- /* This need not be fatal. The user can try to
- * set other configurations. */
- }
- }
- }
- /* USB device state == configured ... usable */
- usb_notify_add_device(udev);
-
- return 0;
-}
-
-static void generic_disconnect(struct usb_device *udev)
-{
- usb_notify_remove_device(udev);
-
- /* if this is only an unbind, not a physical disconnect, then
- * unconfigure the device */
- if (udev->actconfig)
- usb_set_configuration(udev, -1);
-}
-
-#ifdef CONFIG_PM
-
-static int generic_suspend(struct usb_device *udev, pm_message_t msg)
-{
- int rc;
-
- /* Normal USB devices suspend through their upstream port.
- * Root hubs don't have upstream ports to suspend,
- * so we have to shut down their downstream HC-to-USB
- * interfaces manually by doing a bus (or "global") suspend.
- */
- if (!udev->parent)
- rc = hcd_bus_suspend(udev, msg);
-
- /* Non-root devices don't need to do anything for FREEZE or PRETHAW */
- else if (msg.event == PM_EVENT_FREEZE || msg.event == PM_EVENT_PRETHAW)
- rc = 0;
- else
- rc = usb_port_suspend(udev, msg);
-
- return rc;
-}
-
-static int generic_resume(struct usb_device *udev, pm_message_t msg)
-{
- int rc;
-
- /* Normal USB devices resume/reset through their upstream port.
- * Root hubs don't have upstream ports to resume or reset,
- * so we have to start up their downstream HC-to-USB
- * interfaces manually by doing a bus (or "global") resume.
- */
- if (!udev->parent)
- rc = hcd_bus_resume(udev, msg);
- else
- rc = usb_port_resume(udev, msg);
- return rc;
-}
-
-#endif /* CONFIG_PM */
-
-struct usb_device_driver usb_generic_driver = {
- .name = "usb",
- .probe = generic_probe,
- .disconnect = generic_disconnect,
-#ifdef CONFIG_PM
- .suspend = generic_suspend,
- .resume = generic_resume,
-#endif
- .supports_autosuspend = 1,
-};
diff --git a/ANDROID_3.4.5/drivers/usb/core/hcd-pci.c b/ANDROID_3.4.5/drivers/usb/core/hcd-pci.c
deleted file mode 100644
index 622b4a48..00000000
--- a/ANDROID_3.4.5/drivers/usb/core/hcd-pci.c
+++ /dev/null
@@ -1,602 +0,0 @@
-/*
- * (C) Copyright David Brownell 2000-2002
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#ifdef CONFIG_PPC_PMAC
-#include
-#include
-#include
-#include
-#endif
-
-#include "usb.h"
-
-
-/* PCI-based HCs are common, but plenty of non-PCI HCs are used too */
-
-#ifdef CONFIG_PM_SLEEP
-
-/* Coordinate handoffs between EHCI and companion controllers
- * during system resume
- */
-
-static DEFINE_MUTEX(companions_mutex);
-
-#define CL_UHCI PCI_CLASS_SERIAL_USB_UHCI
-#define CL_OHCI PCI_CLASS_SERIAL_USB_OHCI
-#define CL_EHCI PCI_CLASS_SERIAL_USB_EHCI
-
-enum companion_action {
- SET_HS_COMPANION, CLEAR_HS_COMPANION, WAIT_FOR_COMPANIONS
-};
-
-static void companion_common(struct pci_dev *pdev, struct usb_hcd *hcd,
- enum companion_action action)
-{
- struct pci_dev *companion;
- struct usb_hcd *companion_hcd;
- unsigned int slot = PCI_SLOT(pdev->devfn);
-
- /* Iterate through other PCI functions in the same slot.
- * If pdev is OHCI or UHCI then we are looking for EHCI, and
- * vice versa.
- */
- companion = NULL;
- for_each_pci_dev(companion) {
- if (companion->bus != pdev->bus ||
- PCI_SLOT(companion->devfn) != slot)
- continue;
-
- companion_hcd = pci_get_drvdata(companion);
- if (!companion_hcd)
- continue;
-
- /* For SET_HS_COMPANION, store a pointer to the EHCI bus in
- * the OHCI/UHCI companion bus structure.
- * For CLEAR_HS_COMPANION, clear the pointer to the EHCI bus
- * in the OHCI/UHCI companion bus structure.
- * For WAIT_FOR_COMPANIONS, wait until the OHCI/UHCI
- * companion controllers have fully resumed.
- */
-
- if ((pdev->class == CL_OHCI || pdev->class == CL_UHCI) &&
- companion->class == CL_EHCI) {
- /* action must be SET_HS_COMPANION */
- dev_dbg(&companion->dev, "HS companion for %s\n",
- dev_name(&pdev->dev));
- hcd->self.hs_companion = &companion_hcd->self;
-
- } else if (pdev->class == CL_EHCI &&
- (companion->class == CL_OHCI ||
- companion->class == CL_UHCI)) {
- switch (action) {
- case SET_HS_COMPANION:
- dev_dbg(&pdev->dev, "HS companion for %s\n",
- dev_name(&companion->dev));
- companion_hcd->self.hs_companion = &hcd->self;
- break;
- case CLEAR_HS_COMPANION:
- companion_hcd->self.hs_companion = NULL;
- break;
- case WAIT_FOR_COMPANIONS:
- device_pm_wait_for_dev(&pdev->dev,
- &companion->dev);
- break;
- }
- }
- }
-}
-
-static void set_hs_companion(struct pci_dev *pdev, struct usb_hcd *hcd)
-{
- mutex_lock(&companions_mutex);
- dev_set_drvdata(&pdev->dev, hcd);
- companion_common(pdev, hcd, SET_HS_COMPANION);
- mutex_unlock(&companions_mutex);
-}
-
-static void clear_hs_companion(struct pci_dev *pdev, struct usb_hcd *hcd)
-{
- mutex_lock(&companions_mutex);
- dev_set_drvdata(&pdev->dev, NULL);
-
- /* If pdev is OHCI or UHCI, just clear its hs_companion pointer */
- if (pdev->class == CL_OHCI || pdev->class == CL_UHCI)
- hcd->self.hs_companion = NULL;
-
- /* Otherwise search for companion buses and clear their pointers */
- else
- companion_common(pdev, hcd, CLEAR_HS_COMPANION);
- mutex_unlock(&companions_mutex);
-}
-
-static void wait_for_companions(struct pci_dev *pdev, struct usb_hcd *hcd)
-{
- /* Only EHCI controllers need to wait.
- * No locking is needed because a controller cannot be resumed
- * while one of its companions is getting unbound.
- */
- if (pdev->class == CL_EHCI)
- companion_common(pdev, hcd, WAIT_FOR_COMPANIONS);
-}
-
-#else /* !CONFIG_PM_SLEEP */
-
-static inline void set_hs_companion(struct pci_dev *d, struct usb_hcd *h) {}
-static inline void clear_hs_companion(struct pci_dev *d, struct usb_hcd *h) {}
-static inline void wait_for_companions(struct pci_dev *d, struct usb_hcd *h) {}
-
-#endif /* !CONFIG_PM_SLEEP */
-
-/*-------------------------------------------------------------------------*/
-
-/* configure so an HC device and id are always provided */
-/* always called with process context; sleeping is OK */
-
-/**
- * usb_hcd_pci_probe - initialize PCI-based HCDs
- * @dev: USB Host Controller being probed
- * @id: pci hotplug id connecting controller to HCD framework
- * Context: !in_interrupt()
- *
- * Allocates basic PCI resources for this USB host controller, and
- * then invokes the start() method for the HCD associated with it
- * through the hotplug entry's driver_data.
- *
- * Store this function in the HCD's struct pci_driver as probe().
- */
-int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
-{
- struct hc_driver *driver;
- struct usb_hcd *hcd;
- int retval;
-
- if (usb_disabled())
- return -ENODEV;
-
- if (!id)
- return -EINVAL;
- driver = (struct hc_driver *)id->driver_data;
- if (!driver)
- return -EINVAL;
-
- if (pci_enable_device(dev) < 0)
- return -ENODEV;
- dev->current_state = PCI_D0;
-
- /* The xHCI driver supports MSI and MSI-X,
- * so don't fail if the BIOS doesn't provide a legacy IRQ.
- */
- if (!dev->irq && (driver->flags & HCD_MASK) != HCD_USB3) {
- dev_err(&dev->dev,
- "Found HC with no IRQ. Check BIOS/PCI %s setup!\n",
- pci_name(dev));
- retval = -ENODEV;
- goto disable_pci;
- }
-
- hcd = usb_create_hcd(driver, &dev->dev, pci_name(dev));
- if (!hcd) {
- retval = -ENOMEM;
- goto disable_pci;
- }
-
- if (driver->flags & HCD_MEMORY) {
- /* EHCI, OHCI */
- hcd->rsrc_start = pci_resource_start(dev, 0);
- hcd->rsrc_len = pci_resource_len(dev, 0);
- if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
- driver->description)) {
- dev_dbg(&dev->dev, "controller already in use\n");
- retval = -EBUSY;
- goto clear_companion;
- }
- hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
- if (hcd->regs == NULL) {
- dev_dbg(&dev->dev, "error mapping memory\n");
- retval = -EFAULT;
- goto release_mem_region;
- }
-
- } else {
- /* UHCI */
- int region;
-
- for (region = 0; region < PCI_ROM_RESOURCE; region++) {
- if (!(pci_resource_flags(dev, region) &
- IORESOURCE_IO))
- continue;
-
- hcd->rsrc_start = pci_resource_start(dev, region);
- hcd->rsrc_len = pci_resource_len(dev, region);
- if (request_region(hcd->rsrc_start, hcd->rsrc_len,
- driver->description))
- break;
- }
- if (region == PCI_ROM_RESOURCE) {
- dev_dbg(&dev->dev, "no i/o regions available\n");
- retval = -EBUSY;
- goto clear_companion;
- }
- }
-
- pci_set_master(dev);
-
- retval = usb_add_hcd(hcd, dev->irq, IRQF_SHARED);
- if (retval != 0)
- goto unmap_registers;
- set_hs_companion(dev, hcd);
-
- if (pci_dev_run_wake(dev))
- pm_runtime_put_noidle(&dev->dev);
- return retval;
-
-unmap_registers:
- if (driver->flags & HCD_MEMORY) {
- iounmap(hcd->regs);
-release_mem_region:
- release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
- } else
- release_region(hcd->rsrc_start, hcd->rsrc_len);
-clear_companion:
- clear_hs_companion(dev, hcd);
- usb_put_hcd(hcd);
-disable_pci:
- pci_disable_device(dev);
- dev_err(&dev->dev, "init %s fail, %d\n", pci_name(dev), retval);
- return retval;
-}
-EXPORT_SYMBOL_GPL(usb_hcd_pci_probe);
-
-
-/* may be called without controller electrically present */
-/* may be called with controller, bus, and devices active */
-
-/**
- * usb_hcd_pci_remove - shutdown processing for PCI-based HCDs
- * @dev: USB Host Controller being removed
- * Context: !in_interrupt()
- *
- * Reverses the effect of usb_hcd_pci_probe(), first invoking
- * the HCD's stop() method. It is always called from a thread
- * context, normally "rmmod", "apmd", or something similar.
- *
- * Store this function in the HCD's struct pci_driver as remove().
- */
-void usb_hcd_pci_remove(struct pci_dev *dev)
-{
- struct usb_hcd *hcd;
-
- hcd = pci_get_drvdata(dev);
- if (!hcd)
- return;
-
- if (pci_dev_run_wake(dev))
- pm_runtime_get_noresume(&dev->dev);
-
- /* Fake an interrupt request in order to give the driver a chance
- * to test whether the controller hardware has been removed (e.g.,
- * cardbus physical eject).
- */
- local_irq_disable();
- usb_hcd_irq(0, hcd);
- local_irq_enable();
-
- usb_remove_hcd(hcd);
- if (hcd->driver->flags & HCD_MEMORY) {
- iounmap(hcd->regs);
- release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
- } else {
- release_region(hcd->rsrc_start, hcd->rsrc_len);
- }
- clear_hs_companion(dev, hcd);
- usb_put_hcd(hcd);
- pci_disable_device(dev);
-}
-EXPORT_SYMBOL_GPL(usb_hcd_pci_remove);
-
-/**
- * usb_hcd_pci_shutdown - shutdown host controller
- * @dev: USB Host Controller being shutdown
- */
-void usb_hcd_pci_shutdown(struct pci_dev *dev)
-{
- struct usb_hcd *hcd;
-
- hcd = pci_get_drvdata(dev);
- if (!hcd)
- return;
-
- if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) &&
- hcd->driver->shutdown) {
- hcd->driver->shutdown(hcd);
- pci_disable_device(dev);
- }
-}
-EXPORT_SYMBOL_GPL(usb_hcd_pci_shutdown);
-
-#ifdef CONFIG_PM
-
-#ifdef CONFIG_PPC_PMAC
-static void powermac_set_asic(struct pci_dev *pci_dev, int enable)
-{
- /* Enanble or disable ASIC clocks for USB */
- if (machine_is(powermac)) {
- struct device_node *of_node;
-
- of_node = pci_device_to_OF_node(pci_dev);
- if (of_node)
- pmac_call_feature(PMAC_FTR_USB_ENABLE,
- of_node, 0, enable);
- }
-}
-
-#else
-
-static inline void powermac_set_asic(struct pci_dev *pci_dev, int enable)
-{}
-
-#endif /* CONFIG_PPC_PMAC */
-
-static int check_root_hub_suspended(struct device *dev)
-{
- struct pci_dev *pci_dev = to_pci_dev(dev);
- struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
-
- if (HCD_RH_RUNNING(hcd)) {
- dev_warn(dev, "Root hub is not suspended\n");
- return -EBUSY;
- }
- if (hcd->shared_hcd) {
- hcd = hcd->shared_hcd;
- if (HCD_RH_RUNNING(hcd)) {
- dev_warn(dev, "Secondary root hub is not suspended\n");
- return -EBUSY;
- }
- }
- return 0;
-}
-
-#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_RUNTIME)
-static int suspend_common(struct device *dev, bool do_wakeup)
-{
- struct pci_dev *pci_dev = to_pci_dev(dev);
- struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
- int retval;
-
- /* Root hub suspend should have stopped all downstream traffic,
- * and all bus master traffic. And done so for both the interface
- * and the stub usb_device (which we check here). But maybe it
- * didn't; writing sysfs power/state files ignores such rules...
- */
- retval = check_root_hub_suspended(dev);
- if (retval)
- return retval;
-
- if (hcd->driver->pci_suspend && !HCD_DEAD(hcd)) {
- /* Optimization: Don't suspend if a root-hub wakeup is
- * pending and it would cause the HCD to wake up anyway.
- */
- if (do_wakeup && HCD_WAKEUP_PENDING(hcd))
- return -EBUSY;
- if (do_wakeup && hcd->shared_hcd &&
- HCD_WAKEUP_PENDING(hcd->shared_hcd))
- return -EBUSY;
- retval = hcd->driver->pci_suspend(hcd, do_wakeup);
- suspend_report_result(hcd->driver->pci_suspend, retval);
-
- /* Check again in case wakeup raced with pci_suspend */
- if ((retval == 0 && do_wakeup && HCD_WAKEUP_PENDING(hcd)) ||
- (retval == 0 && do_wakeup && hcd->shared_hcd &&
- HCD_WAKEUP_PENDING(hcd->shared_hcd))) {
- if (hcd->driver->pci_resume)
- hcd->driver->pci_resume(hcd, false);
- retval = -EBUSY;
- }
- if (retval)
- return retval;
- }
-
- /* If MSI-X is enabled, the driver will have synchronized all vectors
- * in pci_suspend(). If MSI or legacy PCI is enabled, that will be
- * synchronized here.
- */
- if (!hcd->msix_enabled)
- synchronize_irq(pci_dev->irq);
-
- /* Downstream ports from this root hub should already be quiesced, so
- * there will be no DMA activity. Now we can shut down the upstream
- * link (except maybe for PME# resume signaling). We'll enter a
- * low power state during suspend_noirq, if the hardware allows.
- */
- pci_disable_device(pci_dev);
- return retval;
-}
-
-static int resume_common(struct device *dev, int event)
-{
- struct pci_dev *pci_dev = to_pci_dev(dev);
- struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
- int retval;
-
- if (HCD_RH_RUNNING(hcd) ||
- (hcd->shared_hcd &&
- HCD_RH_RUNNING(hcd->shared_hcd))) {
- dev_dbg(dev, "can't resume, not suspended!\n");
- return 0;
- }
-
- retval = pci_enable_device(pci_dev);
- if (retval < 0) {
- dev_err(dev, "can't re-enable after resume, %d!\n", retval);
- return retval;
- }
-
- pci_set_master(pci_dev);
-
- if (hcd->driver->pci_resume && !HCD_DEAD(hcd)) {
- if (event != PM_EVENT_AUTO_RESUME)
- wait_for_companions(pci_dev, hcd);
-
- retval = hcd->driver->pci_resume(hcd,
- event == PM_EVENT_RESTORE);
- if (retval) {
- dev_err(dev, "PCI post-resume error %d!\n", retval);
- if (hcd->shared_hcd)
- usb_hc_died(hcd->shared_hcd);
- usb_hc_died(hcd);
- }
- }
- return retval;
-}
-#endif /* SLEEP || RUNTIME */
-
-#ifdef CONFIG_PM_SLEEP
-
-static int hcd_pci_suspend(struct device *dev)
-{
- return suspend_common(dev, device_may_wakeup(dev));
-}
-
-static int hcd_pci_suspend_noirq(struct device *dev)
-{
- struct pci_dev *pci_dev = to_pci_dev(dev);
- struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
- int retval;
-
- retval = check_root_hub_suspended(dev);
- if (retval)
- return retval;
-
- pci_save_state(pci_dev);
-
- /* If the root hub is dead rather than suspended, disallow remote
- * wakeup. usb_hc_died() should ensure that both hosts are marked as
- * dying, so we only need to check the primary roothub.
- */
- if (HCD_DEAD(hcd))
- device_set_wakeup_enable(dev, 0);
- dev_dbg(dev, "wakeup: %d\n", device_may_wakeup(dev));
-
- /* Possibly enable remote wakeup,
- * choose the appropriate low-power state, and go to that state.
- */
- retval = pci_prepare_to_sleep(pci_dev);
- if (retval == -EIO) { /* Low-power not supported */
- dev_dbg(dev, "--> PCI D0 legacy\n");
- retval = 0;
- } else if (retval == 0) {
- dev_dbg(dev, "--> PCI %s\n",
- pci_power_name(pci_dev->current_state));
- } else {
- suspend_report_result(pci_prepare_to_sleep, retval);
- return retval;
- }
-
- powermac_set_asic(pci_dev, 0);
- return retval;
-}
-
-static int hcd_pci_resume_noirq(struct device *dev)
-{
- struct pci_dev *pci_dev = to_pci_dev(dev);
-
- powermac_set_asic(pci_dev, 1);
-
- /* Go back to D0 and disable remote wakeup */
- pci_back_from_sleep(pci_dev);
- return 0;
-}
-
-static int hcd_pci_resume(struct device *dev)
-{
- return resume_common(dev, PM_EVENT_RESUME);
-}
-
-static int hcd_pci_restore(struct device *dev)
-{
- return resume_common(dev, PM_EVENT_RESTORE);
-}
-
-#else
-
-#define hcd_pci_suspend NULL
-#define hcd_pci_suspend_noirq NULL
-#define hcd_pci_resume_noirq NULL
-#define hcd_pci_resume NULL
-#define hcd_pci_restore NULL
-
-#endif /* CONFIG_PM_SLEEP */
-
-#ifdef CONFIG_PM_RUNTIME
-
-static int hcd_pci_runtime_suspend(struct device *dev)
-{
- int retval;
-
- retval = suspend_common(dev, true);
- if (retval == 0)
- powermac_set_asic(to_pci_dev(dev), 0);
- dev_dbg(dev, "hcd_pci_runtime_suspend: %d\n", retval);
- return retval;
-}
-
-static int hcd_pci_runtime_resume(struct device *dev)
-{
- int retval;
-
- powermac_set_asic(to_pci_dev(dev), 1);
- retval = resume_common(dev, PM_EVENT_AUTO_RESUME);
- dev_dbg(dev, "hcd_pci_runtime_resume: %d\n", retval);
- return retval;
-}
-
-#else
-
-#define hcd_pci_runtime_suspend NULL
-#define hcd_pci_runtime_resume NULL
-
-#endif /* CONFIG_PM_RUNTIME */
-
-const struct dev_pm_ops usb_hcd_pci_pm_ops = {
- .suspend = hcd_pci_suspend,
- .suspend_noirq = hcd_pci_suspend_noirq,
- .resume_noirq = hcd_pci_resume_noirq,
- .resume = hcd_pci_resume,
- .freeze = check_root_hub_suspended,
- .freeze_noirq = check_root_hub_suspended,
- .thaw_noirq = NULL,
- .thaw = NULL,
- .poweroff = hcd_pci_suspend,
- .poweroff_noirq = hcd_pci_suspend_noirq,
- .restore_noirq = hcd_pci_resume_noirq,
- .restore = hcd_pci_restore,
- .runtime_suspend = hcd_pci_runtime_suspend,
- .runtime_resume = hcd_pci_runtime_resume,
-};
-EXPORT_SYMBOL_GPL(usb_hcd_pci_pm_ops);
-
-#endif /* CONFIG_PM */
diff --git a/ANDROID_3.4.5/drivers/usb/core/hcd.c b/ANDROID_3.4.5/drivers/usb/core/hcd.c
deleted file mode 100644
index 8318901f..00000000
--- a/ANDROID_3.4.5/drivers/usb/core/hcd.c
+++ /dev/null
@@ -1,2656 +0,0 @@
-/*
- * (C) Copyright Linus Torvalds 1999
- * (C) Copyright Johannes Erdfelt 1999-2001
- * (C) Copyright Andreas Gal 1999
- * (C) Copyright Gregory P. Smith 1999
- * (C) Copyright Deti Fliegl 1999
- * (C) Copyright Randy Dunlap 2000
- * (C) Copyright David Brownell 2000-2002
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include
-#include
-#include