Commit graph

10543 commits

Author SHA1 Message Date
Jingoo Han ab1f046a19 USB: ehci-spear: add CONFIG_PM_SLEEP to suspend/resume functions
Add CONFIG_PM_SLEEP to suspend/resume functions to fix the following
build warning when CONFIG_PM_SLEEP is not selected. This is because
sleep PM callbacks defined by SIMPLE_DEV_PM_OPS are only used when
the CONFIG_PM_SLEEP is enabled.

drivers/usb/host/ehci-spear.c:82:12: warning: 'ehci_spear_drv_suspend' defined but not used [-Wunused-function]
drivers/usb/host/ehci-spear.c:90:12: warning: 'ehci_spear_drv_resume' defined but not used [-Wunused-function]

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-28 11:14:47 -07:00
Nobuhiro Iwamatsu e7231be857 usb: echi-sh: Remove driver variable which is not used
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-28 11:14:47 -07:00
Nobuhiro Iwamatsu 1c3a46de66 usb: ehci-sh: Fix build error due to comma has been deleted
By commit 39d3568 (USB: remove incorrect __exit markups), comma following
ehci_hcd_sh_remove has been deleted. This fixes the error by the correction.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-28 11:14:46 -07:00
Alan Stern 84ebc10294 USB: remove CONFIG_USB_SUSPEND option
This patch (as1675) removes the CONFIG_USB_SUSPEND option, essentially
replacing it everywhere with CONFIG_PM_RUNTIME (except for one place
in hub.c, where it is replaced with CONFIG_PM because the code needs
to be used in both runtime and system PM).  The net result is code
shrinkage and simplification.

There's very little point in keeping CONFIG_USB_SUSPEND because almost
everybody enables it.  The few that don't will find that the usbcore
module has gotten somewhat bigger and they will have to take active
measures if they want to prevent hubs from being runtime suspended.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-28 11:10:22 -07:00
Alan Stern 0aa2832dd0 USB: use "global suspend" for system sleep on USB-2 buses
This patch (as1674) speeds up system sleep transitions by not
suspending each individual device on a USB-1.1 or USB-2 bus.  The
devices will automatically go into suspend when their root hubs are
suspended (i.e., stop sending out Start-Of-Frame packets) -- this is
what the USB spec calls "global suspend".

Since this is what we do already when CONFIG_USB_SUSPEND isn't
enabled, it shouldn't cause any problems.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-28 11:06:27 -07:00
Alan Stern e9e88fb7bc USB: avoid error messages when a device is disconnected
This patch (as1673) reduces the amount of log spew from the hub driver
by removing a bunch of error messages in the case where the device in
question is already known to have been disconnected.  Since the
disconnect event itself appears in the log, there's no need for other
error messages.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Jenya Y <jy.gerstmaier@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-28 11:05:52 -07:00
Greg Kroah-Hartman b13379758f Revert "USB: serial: fix hang when opening port"
This reverts commit eba0e3c3a0.

When merged together (usb-linus and usb-next), this fix isn't needed and
causes a build error.  Revert the commit to solve the build issue.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Ming Lei <tom.leiming@gmail.com>
Cc: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-28 11:02:24 -07:00
Greg Kroah-Hartman 02d5f0857b Merge branch 'usb-linus' into usb-next
This lets us fix the build error that happens when these two trees are merged
together.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-28 11:00:55 -07:00
Konstantin Holoborodko 482b0b5d82 usb: ftdi_sio: Add support for Mitsubishi FX-USB-AW/-BD
It enhances the driver for FTDI-based USB serial adapters
to recognize Mitsubishi Electric Corp. USB/RS422 Converters
as FT232BM chips and support them.
https://search.meau.com/?q=FX-USB-AW

Signed-off-by: Konstantin Holoborodko <klh.kernel@gmail.com>
Tested-by: Konstantin Holoborodko <klh.kernel@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-28 08:50:22 -07:00
Roland Stigge c8fa48d372 usb: Fix compile error by selecting USB_OTG_UTILS
The current lpc32xx_defconfig breaks like this, caused by recent phy
restructuring:

  LD      init/built-in.o
drivers/built-in.o: In function `usb_hcd_nxp_probe':
drivers/usb/host/ohci-nxp.c:224: undefined reference to `isp1301_get_client'
drivers/built-in.o: In function `lpc32xx_udc_probe':
drivers/usb/gadget/lpc32xx_udc.c:3104: undefined reference to
`isp1301_get_client' distcc[27867] ERROR: compile (null) on localhost failed
make: *** [vmlinux] Error 1

Caused by 1c2088812f (usb: Makefile: fix
drivers/usb/phy/ Makefile entry)

This patch fixes this by selecting USB_OTG_UTILS in Kconfig which
causes the phy driver to be built again.

Signed-off-by: Roland Stigge <stigge@antcom.de>
Acked-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-27 08:49:20 -07:00
Felipe Balbi 6b0cfc656f usb: musb: ux500_dma: fix sparse warning
fix the following sparse warning:

drivers/usb/musb/ux500_dma.c:60:6: warning: symbol 'ux500_dma_callback' was not declared. Should it be static?

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-27 13:19:00 +02:00
Felipe Balbi 6fbb2f7dae usb: gadget: mv_u3d: fix sparse warnings
fix the following sparse warnings:

drivers/usb/gadget/mv_u3d_core.c:223:20: warning: context imbalance in 'mv_u3d_done' - unexpected unlock
drivers/usb/gadget/mv_u3d_core.c:1562:25: warning: context imbalance in 'mv_u3d_handle_setup_packet' - unexpected unlock

Note that the non-trivial sparse warnings
are left out of this commit due to lack of
HW to test:

drivers/usb/gadget/mv_u3d_core.c:906:42: warning: incorrect type in argument 2 (different address spaces)
drivers/usb/gadget/mv_u3d_core.c:906:42:    expected void [noderef] <asn:2>*<noident>
drivers/usb/gadget/mv_u3d_core.c:906:42:    got unsigned int *<noident>

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-27 13:19:00 +02:00
Felipe Balbi 94a06018de usb: gadget: mv_udc_core: fix sparse warnings
fix the following sparse warnings:

drivers/usb/gadget/mv_udc_core.c:1850:6: warning: symbol 'irq_process_reset' was not declared. Should it be static?
drivers/usb/gadget/mv_udc_core.c:247:9: warning: context imbalance in 'done' - unexpected unlock
drivers/usb/gadget/mv_udc_core.c:1692:25: warning: context imbalance in 'handle_setup_packet' - unexpected unlock

Note that there are still other sparse warnings
which aren't trivial to fix, so I left them out:

drivers/usb/gadget/mv_udc_core.c:848:34: warning: incorrect type in argument 1 (different address spaces)
drivers/usb/gadget/mv_udc_core.c:848:34:    expected void const volatile [noderef] <asn:2>*addr
drivers/usb/gadget/mv_udc_core.c:848:34:    got unsigned int *<noident>
drivers/usb/gadget/mv_udc_core.c:849:42: warning: incorrect type in argument 2 (different address spaces)
drivers/usb/gadget/mv_udc_core.c:849:42:    expected void volatile [noderef] <asn:2>*addr
drivers/usb/gadget/mv_udc_core.c:849:42:    got unsigned int *<noident>

Acked-by: Neil Zhang <zhangwm@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-27 13:18:59 +02:00
Felipe Balbi 3f8b620124 usb: gadget: pch_udc: fix sparse warnings
fix the following sparse warnings:

drivers/usb/gadget/pch_udc.c:1483:9: warning: context imbalance in 'complete_req' - unexpected unlock
drivers/usb/gadget/pch_udc.c:2408:28: warning: context imbalance in 'pch_udc_svc_control_out' - unexpected unlock

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-27 13:18:59 +02:00
Felipe Balbi 814cf212f9 usb: gadget: dummy: fix sparse warning
fix the following sparse warning:

drivers/usb/gadget/dummy_hcd.c:1912:12: warning: symbol 'usb3_bos_desc' was not declared. Should it be static?

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-27 13:18:58 +02:00
Felipe Balbi ad303db62d usb: gadget: net2280: fix sparse warnings
fix the following sparse warnings:

drivers/usb/gadget/net2280.c:2063:13: warning: Using plain integer as NULL pointer
drivers/usb/gadget/net2280.c:2321:68: warning: Using plain integer as NULL pointer
drivers/usb/gadget/net2280.c:2349:68: warning: Using plain integer as NULL pointer
drivers/usb/gadget/net2280.c:2371:68: warning: Using plain integer as NULL pointer

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-27 13:18:58 +02:00
Felipe Balbi 69147121ab usb: gadget: net2272: fix sparse warnings
Fix the following sparse warnings:

drivers/usb/gadget/net2272.c:916:13: warning: Using plain integer as NULL pointer
drivers/usb/gadget/net2272.c:1624:9: warning: Using plain integer as NULL pointer
drivers/usb/gadget/net2272.c:1552:30: warning: right shift by bigger than source value

Note that the last warning is an actual bug,
since ep->dma is a one bit value which is
shifted by one bit in code.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-27 13:18:57 +02:00
Felipe Balbi 60630c2eab usb: gadget: mv_u3d: drop ARCH dependency
this driver compiles fine everywhere which
means we can use linux-next to compile it
for us frequently.

By dropping the arch dependency, we also
ensure driver writers don't add virtual
arch-depdencies to the driver by e.g. using
the wrong headers.

While at that, fix Marvell's USB3 PHY dependency,
that's the driver which depends on CPU_MM3, not
mv_u3d_core.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-27 13:18:20 +02:00
Greg Kroah-Hartman d78658d45e Misc xHCI fixes for 3.9
Hi Greg,
 
 Here's a couple of fixes for the xHCI driver.  Three patches are nothing
 major: build warning fix, macro field width fix, and removing some
 unnecessary log spam.
 
 The only interesting thing here is Tianyu's two patches to fix the USB
 port connection type discovery, for the USB port power off mechanism.
 This adds new USB host API, but as discussed, it's necessary to avoid
 powering off the wrong USB port.  It's not marked for backport to stable
 kernels, since the sysfs mechanism to manually power off a port didn't
 go in until 3.9.
 
 I've smoke tested these, including system suspend, USB device suspend,
 and rocking out in my cube with a pair of USB headphones.  They look
 fine to me.
 
 Hibernate is currently broken on my system, due to some nouveau MMIO
 read faults.  I'll report that separately.
 
 Sarah Sharp
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (GNU/Linux)
 
 iQIcBAABAgAGBQJRUgiCAAoJEBMGWMLi1Gc5e5EQAIdnyu6hE0tfv08wHF/MX6f6
 Rz2R9XrF2k5m7P0ILa3p1KLNCfOAXpEsnHZZKld+Idr3anNvSU9PlJ86DD3PlbMp
 OwFlMFO7mYIFoM9vGdTE91FQklhb2e6FOd6Fsev7MygZB6HofPeSB+4V7bRbeH9Z
 n6jZxwT8MUenixBUETilPBWvOwimloZzXa9C5gl/jYgUNcsEgcSZXGixO82hvZvq
 pPrC6ZyWkW2Nzpme6cQ6dWsAHWvy1vwXZe0RYxmRbXa/no+vIAEYG720BQou/xjc
 89duRZNQFr+7z2MMkuMrqSVncqnt94Tmvf9CS4JKBdUyXpdeoxOMS+ZZM7w7EuFX
 uCT+p7oFmDGUXAdQPcpD49AjjGRgPFmTTKpuv4Mxdo95ZhurdEAbjeL3A9KjYM3P
 M5HH1ZZqJOd35EJvjT01a5/d5aauk+Hre65D7Lr4anJAlE/BgyKwJ3yug0RaoCeR
 fmQnlp/wcMxG0yU5mWfA2tJCOTQKZcGNX+ZxqL1s8Ru4o9SlBZ094ai8VK1Bdur2
 u1Z3JwPexoowjH8azdndHlDN1/ehdOjY7j+kmcRj+IMP4SdLdYON+oN4djh738h6
 bpkp0LyQMVBdT/YsAABYlqbbPpWtk2JmNf19V16rUXxpatZ5gOfhlBxd3lQxqHel
 KVm6tlGgSy+iGR3scEib
 =pF5D
 -----END PGP SIGNATURE-----

Merge tag 'for-usb-linus-2013-03-26' of git://git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci into usb-linus

Misc xHCI fixes for 3.9

Hi Greg,

Here's a couple of fixes for the xHCI driver.  Three patches are nothing
major: build warning fix, macro field width fix, and removing some
unnecessary log spam.

The only interesting thing here is Tianyu's two patches to fix the USB
port connection type discovery, for the USB port power off mechanism.
This adds new USB host API, but as discussed, it's necessary to avoid
powering off the wrong USB port.  It's not marked for backport to stable
kernels, since the sysfs mechanism to manually power off a port didn't
go in until 3.9.

I've smoke tested these, including system suspend, USB device suspend,
and rocking out in my cube with a pair of USB headphones.  They look
fine to me.

Hibernate is currently broken on my system, due to some nouveau MMIO
read faults.  I'll report that separately.

Sarah Sharp
2013-03-26 14:14:54 -07:00
Ming Lei eba0e3c3a0 USB: serial: fix hang when opening port
Johan's 'fix use-after-free in TIOCMIWAIT' patchset[1] introduces
one bug which can cause kernel hang when opening port.

This patch initialized the 'port->delta_msr_wait' waitqueue head
to fix the bug which is introduced in 3.9-rc4.

[1], http://marc.info/?l=linux-usb&m=136368139627876&w=2

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Acked-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-26 09:28:29 -07:00
Greg Kroah-Hartman e58b9a25ee ASoC/extcon: arizona: Fix interaction between HPDET and headphone outputs
This patch series covers both ASoC and extcon subsystems and fixes an
 interaction between the HPDET function and the headphone outputs - we
 really shouldn't run HPDET while the headphone is active.  The first
 patch is a refactoring to make the extcon side easier.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.12 (GNU/Linux)
 
 iQIcBAABAgAGBQJRUcMYAAoJELSic+t+oim9PkAP/RQWC98LrD3kQgVk22MIDdyk
 P7dr37AePy+nMHP/sp3XIVyeD6pwuRWrlf31jAgMsXSb/+8ymJ3oO3t6aPUa9V9+
 KsxxoSUW+/ZO+88aK4r/w/Y45XMqMXsoEwllIxZoEpHXhDIxYFyF8wloPBXLzzbw
 AALowigrNbeYuijr5R1oV+kUOcT8DpzbamoK0jSbpdBdoPEP3ypD/yJTdi/RSyu/
 ELRNZFy4jUw2B3HVOB1YxUeCPpPA63u1oTypFgD7XrQX5v4MDuWyCv5bbBd7KhBk
 vbK/PHti5CMvi5RbA2EHbkI+n/Lb1qfnxIggN5BaSOQ1tlqrHnMlHYoSE/Sjterh
 TDGyYDNrWU1Wve2NTDJEd8oECPwm+8ABBnRYgwtnth/4D/EFkT+6Pv8FuIlYg1ku
 Tj/jwS2q/q26WfssDOph/GfUXtaagMALY99yy/HXM9RPYztOnUyvJIXLzKUUdapT
 KluChggzbj5ytsSy3L808BkgDxYTwHxva4q+n0ST4hDIeqe95HyE8gZA8jrYOf7T
 oA4tsBL3i0YGkPoPkVhMY9qeV0AOwDVlZioGP9Qcs8EI/Z9Bri8NZ4iW8VWkNoTt
 QG7EyuJy90VI/XvGgpITXKXxWQStMZG4+df6pXcn1h47K6ujtDyK/PBBt3t0OPCp
 WihSDHwuFQPSDWYULbZQ
 =gc7f
 -----END PGP SIGNATURE-----

Merge tag 'arizona-extcon-asoc' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc into char-misc-next

Mark writes:

	ASoC/extcon: arizona: Fix interaction between HPDET and headphone outputs

	This patch series covers both ASoC and extcon subsystems and fixes an
	interaction between the HPDET function and the headphone outputs - we
	really shouldn't run HPDET while the headphone is active.  The first
	patch is a refactoring to make the extcon side easier.
2013-03-26 09:19:02 -07:00
Soeren Moch 85ecd0322b USB: EHCI: fix bug in iTD/siTD DMA pool allocation
[Description written by Alan Stern]

Soeren tracked down a very difficult bug in ehci-hcd's DMA pool
management of iTD and siTD structures.  Some background: ehci-hcd
gives each isochronous endpoint its own set of active and free itd's
(or sitd's for full-speed devices).  When a new itd is needed, it is
taken from the head of the free list, if possible.  However, itd's
must not be used twice in a single frame because the hardware
continues to access the data structure for the entire duration of a
frame.  Therefore if the itd at the head of the free list has its
"frame" member equal to the current value of ehci->now_frame, it
cannot be reused and instead a new itd is allocated from the DMA pool.
The entries on the free list are not released back to the pool until
the endpoint is no longer in use.

The bug arises from the fact that sometimes an itd can be moved back
onto the free list before itd->frame has been set properly.  In
Soeren's case, this happened because ehci-hcd can allocate one more
itd than it actually needs for an URB; the extra itd may or may not be
required depending on how the transfer aligns with a frame boundary.
For example, an URB with 8 isochronous packets will cause two itd's to
be allocated.  If the URB is scheduled to start in microframe 3 of
frame N then it will require both itds: one for microframes 3 - 7 of
frame N and one for microframes 0 - 2 of frame N+1.  But if the URB
had been scheduled to start in microframe 0 then it would require only
the first itd, which could cover microframes 0 - 7 of frame N.  The
second itd would be returned to the end of the free list.

The itd allocation routine initializes the entire structure to 0, so
the extra itd ends up on the free list with itd->frame set to 0
instead of a meaningful value.  After a while the itd reaches the head
of the list, and occasionally this happens when ehci->now_frame is
equal to 0.  Then, even though it would be okay to reuse this itd, the
driver thinks it must get another itd from the DMA pool.

For as long as the isochronous endpoint remains in use, this flaw in
the mechanism causes more and more itd's to be taken slowly from the
DMA pool.  Since none are released back, the pool eventually becomes
exhausted.

This reuslts in memory allocation failures, which typically show up
during a long-running audio stream.  Video might suffer the same
effect.

The fix is very simple.  To prevent allocations from the pool when
they aren't needed, make sure that itd's sent back to the free list
prematurely have itd->frame set to an invalid value which can never be
equal to ehci->now_frame.

This should be applied to -stable kernels going back to 3.6.

Signed-off-by: Soeren Moch <smoch@web.de>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:59:04 -07:00
Johan Hovold 659597b774 USB: serial: update copyright information
Update copyright information.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:54:32 -07:00
Johan Hovold 8976f1df91 USB: iuu_phoenix: remove bogus disconnect test in close
Remove bogus disconnect test for serial device being NULL in close. This
can never happen as close is guaranteed to be called before the last tty
reference is dropped (and port->serial is cleared).

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:54:32 -07:00
Johan Hovold 5dbabace4f USB: garmin_gps: remove bogus disconnect test in bulk callback
Remove bogus disconnect test for serial device being NULL in read bulk
callback. This can never happen as the port read urb is killed (and
poisoned) at close, which in turn is guaranteed to be called before the
last tty reference is dropped (and port->serial is cleared).

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:54:32 -07:00
Johan Hovold 9197272452 USB: garmin_gps: remove bogus disconnect test in close
Remove bogus disconnect test for serial device being NULL in close. This
can never happen as close is guaranteed to be called before the last tty
reference is dropped (and port->serial is cleared).

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:54:32 -07:00
Johan Hovold 7620c33afb USB: visor: always disable uart on close
Always try to disable the uart on close.

Since the switch to tty ports, close will be called as part of shutdown
before disconnect returns. Hence there is no need to check the
disconnected flag, and we can put devices in disabled states also on
driver unbind.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:54:32 -07:00
Johan Hovold 81ae1b3c31 USB: quatech2: always disable uart on close
Always try to disable the uart on close.

Since the switch to tty ports, close will be called as part of shutdown
before disconnect returns. Hence there is no need to check the
disconnected flag, and we can put devices in disabled states also on
driver unbind.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:54:32 -07:00
Johan Hovold 5ddbb26b8b USB: pl2303: remove disconnect test from tiocmset
Remove unnecessary disconnect test in tiocmset. No ioctls will be made
after disconnect returns.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:54:32 -07:00
Johan Hovold aff5b323b3 USB: pl2303: fix return value of tiocmset
Make sure we return 0 or a negative error number appropriate for
userspace on errors.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:54:31 -07:00
Johan Hovold 94bcef6245 USB: opticon: remove disconnect test from tiocmset
Remove unnecessary disconnect test in tiocmset. No ioctls will be made
after disconnect returns.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:54:31 -07:00
Johan Hovold 94c51dca2c USB: opticon: fix return value of tiocmset
Make sure we return 0 or a negative error number appropriate for
userspace on errors.

Currently 1 rather than 0 is returned on successful operation.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:54:31 -07:00
Johan Hovold cf41aa9e19 USB: mos7720: always disable uart on close
Always try to disable the uart on close.

Since the switch to tty ports, close will be called as part of shutdown
before disconnect returns. Hence there is no need to check the
disconnected flag, and we can put devices in disabled states also on
driver unbind.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:54:31 -07:00
Johan Hovold 5813f281bb USB: metro-usb: always disable uart on close
Always try to disable the uart on close.

Since the switch to tty ports, close will be called as part of shutdown
before disconnect returns. Hence there is no need to check the
disconnected flag, and we can put devices in disabled states also on
driver unbind.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:54:31 -07:00
Johan Hovold 9fcb2e6e7e USB: kl5kusb105: always disable uart on close
Always try to disable the uart on close.

Since the switch to tty ports, close will be called as part of shutdown
before disconnect returns. Hence there is no need to check the
disconnected flag, and we can put devices in disabled states also on
driver unbind.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:54:31 -07:00
Johan Hovold bca87e9efb USB: io_ti: always disable uart on close
Always try to disable the uart on close.

Since the switch to tty ports, close will be called as part of shutdown
before disconnect returns. Hence there is no need to check the
disconnected flag, and we can put devices in disabled states also on
driver unbind.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:54:31 -07:00
Johan Hovold 87ddf4dc16 USB: cypress_m8: remove bogus disconnect test from close
Remove disconnected test from close which did not protect any device IO
at all.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:54:30 -07:00
Johan Hovold ecb9eb8064 USB: cp210x: always disable uart on close
Always try to disable the uart on close.

Since the switch to tty ports, close will be called as part of shutdown
before disconnect returns. Hence there is no need to check the
disconnected flag, and we can put devices in disabled states also on
driver unbind.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:54:30 -07:00
Johan Hovold 6c75e26067 USB: ti_usb_3410_5052: switch to generic TIOCMIWAIT implementation
Switch to the generic TIOCMIWAIT implementation which does not suffer
from the races involved when using the deprecated sleep_on functions.

This also fixes the issue with processes waiting for
modem-status-changes not being woken up at disconnect.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:28 -07:00
Johan Hovold 783ca3557b USB: ti_usb_3410_5052: switch to generic get_icount implementation
Switch to the generic get_icount implementation.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:28 -07:00
Johan Hovold c24c838e8e USB: ssu100: switch to generic TIOCMIWAIT implementation
Switch to the generic TIOCMIWAIT implementation.

This also fixes the issue with processes waiting for
modem-status-changes not being woken up at disconnect.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:28 -07:00
Johan Hovold 31ecdb6bef USB: ssu100: switch to generic get_icount implementation
Switch to the generic get_icount implementation.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:28 -07:00
Johan Hovold e1ed212d85 USB: spcp8x5: add proper modem-status support
Fetch modem status on carrier_raised and tiocmget.

This driver appeared to support modem-status but only read the modem
status registers once at open and then used that cached value for all
further enquires.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:28 -07:00
Johan Hovold 4d63143db1 USB: spcp8x5: reimplement device type detection
Reimplement device type detection using the device id table and quirks.

Device type was used to detect one device type which did not support to
control functions. Add quirks to the device table and store them in the
private port data at probe instead.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:28 -07:00
Johan Hovold 0a967f62e6 USB: spcp8x5: clean up modem status retrieval
Clean up modem status retrieval.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:27 -07:00
Johan Hovold 8413d2fd80 USB: spcp8x5: pass usb-serial port to control functions
Pass usb-serial port to the control functions for uart status and work
mode.

Use port device for debugging and use dev_err to report errors.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:27 -07:00
Johan Hovold 2d816ac6f5 USB: spcp8x5: clean up code
Clean up this driver somewhat.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:27 -07:00
Johan Hovold 23bd364dcf USB: spcp8x5: remove broken uart-error handling
Remove broken uart-error handling.

This driver appears to implement uart-error handling but does not
receive status interrupts or status information with bulk in transfers.

Instead status was retrieved at open and used to flag only the first
bulk in transfer.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:26 -07:00
Johan Hovold f65f9a50dd USB: spcp8x5: remove broken TIOCMIWAIT support
Remove broken TIOCMIWAIT support.

This drivers appears to implement TIOCMIWAIT but has no means of
receiving modem-status interrupts.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:25 -07:00
Johan Hovold b59597047a USB: quatech2: switch to generic TIOCMIWAIT implementation
Switch to the generic TIOCMIWAIT implementation.

This also fixes the issue with processes waiting for
modem-status-changes not being woken up at disconnect.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:25 -07:00
Johan Hovold 0a4142fb9c USB: quatech2: switch to generic get_icount implementation
Switch to the generic get_icount implementation.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:25 -07:00
Johan Hovold 6d0cad657a USB: pl2303: fix TIOCMIWAIT and disconnect
Use tty-port modem-status-change wait queue on which processes are woken
up at hangup and disconnect.

Currently a process waiting on modem-status changes will not be woken on
device disconnect.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:25 -07:00
Johan Hovold 824d11bef5 USB: pl2303: add custom tiocmiwait operation
Break out TIOCMIWAIT handling from custom ioctl operation and use
tiocmiwait operation field instead.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:25 -07:00
Johan Hovold 215f6f0466 USB: oti6858: fix TIOCMIWAIT and disconnect
Use tty-port modem-status-change wait queue on which processes are woken
up at hangup and disconnect.

Currently a process waiting on modem-status changes will not be woken on
device disconnect.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:25 -07:00
Johan Hovold 1c9f995363 USB: oti6858: replace custom ioctl operation with tiocmiwait
Replace custom ioctl operation with tiocmiwait.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:25 -07:00
Johan Hovold 0c61337138 USB: mos7840: switch to generic TIOCMIWAIT implementation
Switch to the generic TIOCMIWAIT implementation.

This also fixes the issue with processes waiting for
modem-status-changes not being woken up at disconnect.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:24 -07:00
Johan Hovold 8c1a07ff7f USB: mos7840: switch to generic get_icount implementation
Switch to the generic get_icount implementation.

Note that the interrupt counters will no longer be reset at open which
is in accordance with which how the other drivers work.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:24 -07:00
Johan Hovold c9fac85345 USB: mos7840: remove smp barriers from icount handling
Remove SMP memory barriers from icount handling and rely on the barriers
implied by wait_event, sleep and locks, while using the port lock to
guarantee atomicity.

This is a step in moving over to the generic icount implementations.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:24 -07:00
Johan Hovold 3571157804 USB: mos7720: remove broken get_icount and TIOCMIWAIT
Remove broken get_icount and TIOCMIWAIT support.

The driver has an icount structure but it is never been updated which
makes get_icount rather pointless and causes TIOCMIWAIT to always return
-EIO.

Note that the TIOCMIWAIT implementation has always been broken and would
not work even if icount support was added as it does not wait for the
modem status to change (does not use a work queue at all).

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:52:24 -07:00
Johan Hovold 128434ab56 USB: mct_u232: switch to generic TIOCMIWAIT implementation
Switch to the generic TIOCMIWAIT implementation.

This also fixes the issue with processes waiting for
modem-status-changes not being woken up at disconnect.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:53 -07:00
Johan Hovold 468c740ee5 USB: mct_u232: switch to generic get_icount implementation
Switch to the generic get_icount implementation.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:53 -07:00
Johan Hovold 09b0e39575 USB: iuu_phoenix: remove unused MSR-wait queue
Remove unused, private modem-status wait queue from driver. If
TIOCMIWAIT is ever implemented it must not rely on a private wait queue
which may have been released when woken up.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:53 -07:00
Johan Hovold 48ee580138 USB: io_ti: switch to generic TIOCMIWAIT implementation
Switch to the generic TIOCMIWAIT implementation which does not suffer
from the races involved when using the deprecated sleep_on functions.

This also fixes the issue with processes waiting for
modem-status-changes not being woken up at disconnect.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:53 -07:00
Johan Hovold cf9a9d66bd USB: io_ti: switch to generic get_icount implementation
Switch to the generic get_icount implementation.

Note that the interrupt counters will no longer be reset at open which
is in accordance with which how the other drivers work.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:53 -07:00
Johan Hovold 8b8070d858 USB: io_edgeport: switch to generic TIOCMIWAIT implementation
Switch to the generic TIOCMIWAIT implementation.

This also fixes the issue with processes waiting for
modem-status-changes not being woken up at disconnect.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:53 -07:00
Johan Hovold d36a771249 USB: io_edgeport: switch to generic get_icount implementation
Switch to the generic get_icount implementation.

Note that the interrupt counters will no longer be reset at open which
is in accordance with which how the other drivers work.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:53 -07:00
Johan Hovold 3018bb5158 USB: f81232: fix TIOCMIWAIT and disconnect
Use tty-port modem-status-change wait queue on which processes are woken
up at hangup and disconnect.

Currently a process waiting on modem-status changes will not be woken on
device disconnect.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:52 -07:00
Johan Hovold 4bb4e6384a USB: f81232: add custom tiocmiwait operation
Break out TIOCMIWAIT handling from custom ioctl operation and use
tiocmiwait operation field instead.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:52 -07:00
Johan Hovold a7fa57742e USB: digi_acceleport: remove unused MSR-wait queue
Remove unused, private modem-status wait queue from driver. If
TIOCMIWAIT is ever implemented it must not rely on a private wait queue
which may have been released when woken up.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:52 -07:00
Johan Hovold c648e94ebf USB: cypress_m8: fix TIOCMIWAIT and disconnect
Use tty-port modem-status-change wait queue on which processes are woken
up at hangup and disconnect.

Currently a process waiting on modem-status changes will not be woken on
device disconnect.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:52 -07:00
Johan Hovold 493516e344 USB: cypress_m8: replace custom ioctl operation with tiocmiwait
Replace custom ioctl operation with tiocmiwait.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:52 -07:00
Johan Hovold 3f55043192 USB: ch341: fix TIOCMIWAIT and disconnect
Use tty-port modem-status-change wait queue on which processes are woken
up at hangup and disconnect.

Currently a process waiting on modem-status changes will not be woken on
device disconnect as wake up was only done in dtr_rts which isn't
guaranteed to be called (e.g. if HUPCL is not set).

Also remove the redundant wake-up call from dtr_rts.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:52 -07:00
Johan Hovold 7bb98f0edd USB: ch341: replace custom ioctl operation with tiocmiwait
Replace custom ioctl operation with tiocmiwait.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:52 -07:00
Johan Hovold 7caed7e78c USB: ark3116: switch to generic TIOCMIWAIT implementation
Switch to the generic TIOCMIWAIT implementation which does not suffer
from the races involved when using the deprecated sleep_on functions.

This also fixes the issue with processes waiting for
modem-status-changes not being woken up at disconnect.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:52 -07:00
Johan Hovold b4cb7536cc USB: ark3116: switch to generic get_icount implementation
Switch to the generic get_icount implementation.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:51 -07:00
Johan Hovold 6f86fec9fa USB: ftdi_sio: switch to generic get_icount implementation
Switch to the generic get_icount implementation.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:51 -07:00
Johan Hovold f307e5cd3f USB: ftdi_sio: switch to generic TIOCMIWAIT implementation
Switch to the generic TIOCMIWAIT implementation which does not suffer
from the races involved when using the deprecated sleep_on functions.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:51 -07:00
Johan Hovold cb1676a61a USB: ftdi_sio: use port icount
Use the port-data icount for interrupt counters.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:51 -07:00
Johan Hovold befefcda4b USB: serial: add generic get_icount implementation
Add generic get_icount implementation that subdrivers relying on the
port interrupt counters can use.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:51 -07:00
Johan Hovold c371de14b9 USB: serial: wake up MSR-wait queue on disconnect
Make sure processes waiting for modem-status changes are woken up at
disconnect.

This is needed for custom subdriver TIOCMIWAIT-implementations which do
not yet handle hangup.

Even though processes on the tty-port wait queue are woken up at hangup
the wake-up call in usb-serial disconnect is still needed if a woken-up
process may go back to sleep (e.g. due to an incomplete
TIOCMIWAIT-implementation). If a disconnect occurs after a hangup, any
process waiting for changes will not be woken up a second time by the
tty-layer as the port will then have been disassociated from the tty.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:51 -07:00
Johan Hovold 980373b791 USB: serial: add generic TIOCMIWAIT implementation
Add generic TIOCMIWAIT implementation which correctly handles hangup,
USB-device disconnect, does not rely on the deprecated sleep_on
functions and hence does not suffer from the races currently affecting
several usb-serial drivers.

This makes it much easier to add TIOCMIWAIT support to subdrivers as the
tricky details related to hangup and disconnect (e.g. atomicity, that
the private port data may have been freed when woken up, and waking up
processes at disconnect) have been handled once and for all.

To add support to a subdriver, simply set the tiocmiwait-port-operation
field, update the port icount fields and wake up any process sleeping on
the tty-port modem-status-change wait queue on changes.

Note that the tty-port initialised flag can be used to detect
disconnected as the port will be hung up as part of disconnect (and
cannot be reactivated due to the disconnected flag). However, as the
tty-port implementation currently wakes up processes before calling port
shutdown, the tty-hupping flag must also be checked to detect hangup for
now.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:51 -07:00
Johan Hovold 143d9d9616 USB: serial: add tiocmiwait subdriver operation
Add tiocmiwait operation to struct usb_serial_driver.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:50 -07:00
Johan Hovold 5cb27dde2e USB: serial: clean up usb-serial bus device removal
Make sure to unregister the tty-device before calling subdriver
port_remove.

This way remove will reverse probe, and specifically any port data
released in port_remove will be available throughout tty unregister.

Note that the order currently does not matter as the tty-layer can make
callbacks also after the device has been unregistered. This is
handled in usb-serial core using the disconnected flag, which is
already set when usb-serial bus device remove is called.

Cc: Peter Hurley <peter@hurleysoftware.com>
Reported-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:48:27 -07:00
Johan Hovold 6a5c821cad USB: serial: use urb poison to reliably kill traffic
Use usb_poison_urb to reliably kill all urbs on disconnect and suspend.

This way there will be no question that the urbs cannot be resubmitted
by buggy subdrivers.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:48:27 -07:00
Johan Hovold 68a2bed130 USB: fix urb-poison imbalance
The calls to usb_poison_urb and usb_unpoison_urb are expected to be
balanced. However, if an urb that has not yet been submitted is
poisoned, its reject counter will not be increased as its ep-field is
NULL. A consecutive call to unpoison will thus in fact poison the urb
as its reject counter will be decremented to a negative value,
effectively preventing the urb from being submitted.

Note that there are currently no in-kernel drivers affected by this.

Cc: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:48:27 -07:00
Johan Hovold 69a3d21257 USB: serial: rename port release
Rename port_release so that all usb_serial_port functions have a common
prefix.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:48:27 -07:00
Johan Hovold a4a83100a1 USB: serial: fix port release
We should not call kill_traffic (and usb_kill_urb) once disconnect
returns. Any pending urbs are killed at disconnect and new submissions
are prevented by usb_unbind_interface (and usb_disable_interface).

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:48:27 -07:00
Johan Hovold 30d9d42e9a USB: cyberjack: fix disconnect handling
Make sure the interrupt urb submitted in port_probe is killed in
port_remove.

The interrupt-urb completion handler references the port and may get
called after port_remove has returned and the port has been
unregistered (although this is currently prevented by usb-serial core as
we are using a non-private urb).

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:48:26 -07:00
Johan Hovold c3452f5e44 USB: serial: clean up generic-operation handling
Most USB serial drivers are, and should be, using as much of the generic
implementation as possible.

Rename the fixup_generic function to a more descriptive name.
Reword the related debug message in a more neutral tone (and remember to
add the missing newline).
Finally, move the operations initialisation to after the initial sanity
checks.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:48:26 -07:00
Johan Hovold 79b80b8a11 USB: serial: remove generic release callback
Remove empty generic release implementation and make the release
callback non-mandatory (like attach, probe and disconnect).

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:48:26 -07:00
Johan Hovold 0f16cfe39e USB: serial: remove generic disconnect callback
Remove the now empty generic disconnect callback and make the disconnect
callback non-mandatory.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:48:26 -07:00
Johan Hovold f8f0ad8621 USB: serial: fix generic disconnect implementation
There is no need for the generic disconnect callback to stop the read
and write urbs a second time as this has already been taken care of by
close (which is called from hangup as part of disconnect).

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:48:26 -07:00
Johan Hovold 618e183d03 USB: ssu100: remove custom close operation
The generic close operation will be used if the close field is left
uninitialised.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:48:26 -07:00
Johan Hovold bf8773c6ea USB: ssu100: remove explicit initialisation of disconnect
The disconnect callback is set to the generic implementation by
usb-serial core if NULL.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:48:26 -07:00
Johan Hovold 19c6185383 USB: serial: remove bogus disconnect test in cleanup
Remove bogus (and unnecessary) test for serial->dev being NULL in
cleanup.

The device is never cleared, and cleanup is never called after a
completed disconnect anyway.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:44:18 -07:00
Johan Hovold e6d144bc27 USB: usb_wwan: remove bogus disconnect test in close
Remove bogus (and unnecessary) test for serial->dev being NULL in close.

The device is never cleared, and close is never called after a completed
disconnect anyway.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:44:18 -07:00
Johan Hovold 9c210bfa29 USB: sierra: remove bogus disconnect test in close
Remove bogus (and unnecessary) test for serial->dev being NULL in close.

The device is never cleared, and close is never called after a completed
disconnect anyway.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:44:18 -07:00
Johan Hovold bb3529c6a0 USB: mos7840: remove bogus disconnect test in close
Remove bogus (and unnecessary) test for serial->dev being NULL in close.

The device is never cleared, and close is never called after a completed
disconnect anyway.

Simplify urb killing, and remove some related debug and dead code while
at it.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:44:18 -07:00
Johan Hovold 75d22b323f USB: keyspan_pda: remove bogus disconnect test in close
Remove bogus (and unnecessary) test for serial->dev being NULL in close.

The device is never cleared, and close is never called after a completed
disconnect anyway.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:44:18 -07:00
Johan Hovold d7f08452ff USB: keyspan_pda: remove bogus disconnect test from dtr_rts
Remove bogus (and unnecessary) test for serial->dev being NULL in
dtr_rts.

The device is never cleared, and disconnect is handled for dtr_rts in
usb-serial core anyway.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:44:18 -07:00
Johan Hovold 80dfe0ceb3 USB: keyspan: remove bogus disconnect test in close
Remove bogus (and unnecessary) test for serial->dev being NULL in close.

The device is never cleared, and close is never called after a completed
disconnect anyway.

Remove some out-commented bogus code while at it.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:44:17 -07:00
Johan Hovold 853127faa4 USB: iuu_phoenix: remove bogus disconnect test in close
Remove bogus (and unnecessary) test for serial->dev being NULL in close.

The device is never cleared, and close is never called after a completed
disconnect anyway.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:44:17 -07:00
Johan Hovold 28e679ae6f USB: digi_acceleport: remove bogus disconnect test in close
Remove bogus (and unnecessary) test for serial->dev being NULL in close.

The device is never cleared, and close is never called after a completed
disconnect anyway.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:44:17 -07:00
Johan Hovold 1bc77f4df6 USB: cyberjack: remove bogus disconnect test in close
Remove bogus (and unnecessary) test for serial->dev being NULL in close.

The device is never cleared, and close is never called after a completed
disconnect anyway.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:44:17 -07:00
Johan Hovold 5c32752824 USB: ark3116: remove bogus disconnect test in close
Remove bogus (and unnecessary) test for serial->dev being NULL in close.

The device is never cleared, and close is never called after a completed
disconnect anyway.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:44:17 -07:00
Johan Hovold 49bd196dc6 USB: serial: remove port number from generic-driver debug
Remove redundant port number from debug output (already printed as part
of device name).

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:42:13 -07:00
Johan Hovold 6b03f7f79f USB: serial: remove redundant allocation error messages
Failed allocations already get an OOM message and a stack dump.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:42:13 -07:00
Johan Hovold d12e211d44 USB: serial: clean up debug info
Remove redundant port number from debug output (already printed as part
of device name).

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:42:13 -07:00
Johan Hovold 9993b42b63 USB: serial: remove redundant comments
Remove redundant comments and fix some minor coding style issues.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:42:13 -07:00
Johan Hovold 395e08da8a USB: serial: rename tty-port callbacks
Rename the tty-port callbacks using a common prefix to more clearly
separate them from the tty and usb driver callbacks.

Rename serial_down to serial_port_shutdown to match the callback name.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:41:32 -07:00
Johan Hovold f45d0a5aa5 USB: pl2303: make set_control_lines a port operation
Pass usb-serial port rather than usb device to set_control_lines, and
make sure port device is used for all port related debugging.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:39:22 -07:00
Johan Hovold 7b5789a868 USB: pl2303: use interface device for debug
Use interface rather than usb-serial device for debugging interface
related operations. This gives more descriptive messages, such as

[  905.669436] pl2303 1-4.1:1.0: 0x40:0x1:0x8:0x0  0

rather than

[  341.943535] usb 1-4.1: 0x40:0x1:0x8:0x0  0

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:39:22 -07:00
Johan Hovold 83e86c79a6 USB: iuu_phoenix: remove unnecessary urb kill on close
Remove kill of interrupt-in urb on close as it has never been submitted.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:39:22 -07:00
Johan Hovold 6f60b34c4d USB: kl5kusb105: remove unnecessary urb kill on close
Remove kill of interrupt-in urb on close as it has never been submitted.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:39:22 -07:00
Johan Hovold 4cba98ff87 USB: ftdi_sio: remove obsolete port data refcounting
Remove the port data refcounting and release the private data
explicitly at port remove.

The port data refcounting was used to make sure the port data was not
freed until the last tty reference was closed. Since moving over to tty
ports, the underlying assumptions are no longer valid as close is now
called as part of tty port shutdown, which can occur before the final
tty reference is dropped on device disconnect.

This means that the private port data refcounting is now completely
useless, as the last reference will always be dropped on port_remove.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:39:22 -07:00
Alan Stern afc2c9a2c3 USB: EHCI: remove unused variable in unlink_empty_async()
This patch (as1669) removes the check_unlinks_later flag in ehci-hcd's
unlink_empty_async().  It wasn't being used for anything and should
have been removed in an earlier patch, but I forgot about it.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:36:32 -07:00
Alan Stern 214ac7a077 USB: EHCI: improve end_unlink_async()
This patch (as1665) changes the way ehci-hcd's end_unlink_async()
routine works in order to avoid recursive execution and to be more
efficient:

	Now when an IAA cycle ends, a new one gets started up right
	away (if it is needed) instead of waiting until the
	just-unlinked QH has been processed.

	The async_iaa list is renamed to async_idle, which better
	expresses its new purpose: It is now the list of QHs which are
	now completely idle and are waiting to be processed by
	end_unlink_async().

	A new flag is added to track whether an IAA cycle is in
	progress, because the list formerly known as async_iaa no
	longer stores the QHs waiting for the IAA to finish.

	The decision about how many QHs to process when an IAA cycle
	ends is now made at the end of the cycle, when we know the
	current state of the hardware, rather than at the beginning.
	This means a bunch of logic got moved from start_iaa_cycle()
	to end_unlink_async().

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:36:32 -07:00
Alan Stern 6e018751a3 USB: EHCI: convert singly-linked lists to list_heads
This patch (as1664) converts ehci-hcd's async_unlink, async_iaa, and
intr_unlink from singly-linked lists to standard doubly-linked
list_heads.  Originally it didn't seem necessary to use list_heads,
because items are always added to and removed from these lists in FIFO
order.  But now with more list processing going on, it's easier to use
the standard routines than continue with a roll-your-own approach.

I don't know if the code ends up being notably shorter, but the
patterns will be more familiar to any kernel hacker.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:35:05 -07:00
Alan Stern 7655e3160c USB: EHCI: consolidate code in ehci_urb_dequeue()
This patch (as1668) consolidates two nearly identical code paths in
ehci_urb_dequeue().  The test for !qh can be removed because it will
never succeed; the fact that usb_hcd_check_unlink_urb() returned 0
means that urb must be queued and therefore urb->hcpriv must point to
a QH.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:35:05 -07:00
Alan Stern 7bc782d73c USB: EHCI: split needs_rescan into two flags
This patch (as1662) does some more QH-related cleanup in ehci-hcd.
The qh->needs_rescan flag is currently used for two different
purposes; the patch replaces it with two separate flags for greater
clarity: qh->dequeue_during_giveback indicates that a completion
handler dequeued an URB (implying that a rescan is needed), and
qh->exception indicates that the QH is in an exceptional state
requiring an unlink (either it encountered an I/O error or an unlink
was requested).

The new flags get set where the dequeue, exception, or unlink request
occurred, rather than where the unlink is started.  This is so that in
the future, if we need to, we will be able to tell apart unlinks that
truly were required from those that were carried out merely because
the QH wasn't being used.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:35:05 -07:00
Alan Stern 79bcf7b02b USB: EHCI: change return value of qh_completions()
This patch (as1658) cleans up the usage of qh_completions() in
ehci-hcd.  Currently the function's return value indicates whether any
URBs were given back; the idea was that the caller can scan the QH
over again to handle any URBs that were dequeued by a completion
handler.  This is not necessary; when qh_completions() is ready to
give back dequeued URBs, it does its own rescanning.

Therefore the new return value will be a flag indicating whether the
caller needs to unlink the QH.  This is more convenient than forcing
the caller to check qh->needs_rescan, and it makes a lot more sense --
why should "needs_rescan" imply that an unlink is needed?  The callers
are also changed to remove the unneeded rescans.

Lastly, the check for whether qh->qtd_list is non-empty is removed
from the start of qh_completions().  Two of the callers have to make
this test anyway, so the same test can simply be added to the other
two callers.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:35:05 -07:00
Alan Stern c1fdb68e3d USB: EHCI: changes related to qh_refresh()
This patch (as1638) makes several changes to the ehci-hcd driver, all
related to the qh_refresh() function.  This function must be called
whenever an idle QH gets linked back into either the async or the
periodic schedule.

	Change a BUG_ON() in the qh_update routine to a WARN_ON().
	Since this code runs in atomic context, a BUG_ON() would
	immediately freeze the whole system.

	Remove two unneeded calls to qh_refresh(), one when a QH is
	initialized and one when a QH becomes idle.  Adjust the
	adjacent comments accordingly.

	Move the qh_refresh() and qh_link_periodic() calls for new
	interrupt URBs to after the new TDs have been added.

	As a result of the previous two changes, qh_refresh() is never
	called when the qtd_list is empty.  The corresponding check in
	qh_refresh() can be removed, along with an indentation level.

These changes should not cause any alteration of behavior.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:35:05 -07:00
Du Xing c79041a440 USB: usb-skeleton.c: fix blocked forever in skel_read
In skel_read,the reader blocked in wait_for_completion before submit
bulk in urb.
Using processed_urb is for retaining the completion in the case that
previous interruptible wait in skel_read was interrupted and complete
before next skel_read.  Replacing completion with waitqueue can avoid
working around the counting nature of completions
and fix the bug.

Signed-off-by: Du Xing duxing2007@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:32:20 -07:00
Bjørn Mork 3edce1cf81 USB: cdc-wdm: implement IOCTL_WDM_MAX_COMMAND
Userspace applications need to know the maximum supported message
size.

The cdc-wdm driver translates between a character device stream
and a message based protocol.  Each message is transported as a
usb control message with no further encapsulation or syncronization.
Each read or write on the character device should translate to
exactly one usb control message to ensure that message boundaries
are kept intact.  That means that the userspace application must
know the maximum message size supported by the device and driver,
making this size a vital part of the cdc-wdm character device API.

CDC WDM and CDC MBIM functions export the maximum supported
message size through CDC functional descriptors.  The cdc-wdm and
cdc_mbim drivers will parse these descriptors and use the value
chosen by the device.  The only current way for a userspace
application to retrive the value is by duplicating the descriptor
parsing. This is an unnecessary complex task, and application
writers are likely to postpone it, using a fixed value and adding
a "todo" item.

QMI functions have no way to tell the host what message size they
support.  The qmi_wwan driver use a fixed value based on protocol
recommendations and observed device behaviour.  Userspace
applications must know and hard code the same value.  This scheme
will break if we ever encounter a QMI device needing a device
specific message size quirk.  We are currently unable to support
such a device because using a non default size would break the
implicit userspace API.

The message size is currently a hidden attribute of the cdc-wdm
userspace API.  Retrieving it is unnecessarily complex, increasing
the possibility of drivers and applications using different limits.
The resulting errors are hard to debug, and can only be replicated
on identical hardware.

Exporting the maximum message size from the driver simplifies the
task for the userspace application, and creates a unified
information source independent of device and function class. It also
serves to document that the message size is part of the cdc-wdm
userspace API.

This proposed API extension has been presented for the authors of
userspace applications and libraries using the current API: libmbim,
libqmi, uqmi, oFono and ModemManager.  The replies were:

Aleksander Morgado:
 "We do really need max message size for MBIM; and as you say, it may be
  good to have the max message size info also for QMI, so the new ioctl
  seems a good addition. So +1 from my side, for what it's worth."

Dan Williams:
 "Yeah, +1 here.  I'd prefer the sysfs file, but the fact that that
  doesn't work for fd passing pretty much kills it."

No negative replies are so far received.

Cc: Aleksander Morgado <aleksander@lanedo.com>
Cc: Dan Williams <dcbw@redhat.com>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Acked-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:32:20 -07:00
David Linares 769d7368b1 USB: hub: Avoid NULL pointer dereference when hub doesn't have any ports
Return an error if hub->descriptor->bNbrPorts==0. Without this additional
check, we can end up doing a "hub->ports = kzalloc(0, GFP_KERNEL)".
This hub->ports pointer will therefore be non-NULL and will be used.
Example of dmesg:
   INIT: usb 1-1: New USB device found, idVendor=0424, idProduct=2512
   usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
   hub 1-1:1.0: USB hub found
   version 2.86 bootinghub 1-1:1.0: 0 ports detected
   Unable to handle kernel NULL pointer dereference at virtual address 00000010

Signed-off-by: David Linares <dlinares.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 10:57:37 -07:00
Ming Lei 93e4f47f4d USB: serial: comments on suspend failure
If suspend callback fails in system sleep context, usb core will
ignore the failure and let system sleep go ahead further, so
this patch comments on the case and requires that serial->type->suspend()
MUST return 0 in system sleep context.

Acked-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 10:55:46 -07:00
Ming Lei 303f084792 USB: adds comment on suspend callback
This patch adds comments on interface driver suspend callback
to emphasize that the failure return value is ignored by
USB core in system sleep context, so do not try to recover
device for this case and let resume/reset_resume callback
handle the suspend failure if needed.

Also kerneldoc for usb_suspend_both() is updated with the
fact.

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 10:55:46 -07:00
Sarah Sharp a83d675581 xhci: Don't warn on empty ring for suspended devices.
When a device attached to the roothub is suspended, the endpoint rings
are stopped.  The host may generate a completion event with the
completion code set to 'Stopped' or 'Stopped Invalid' when the ring is
halted.  The current xHCI code prints a warning in that case, which can
be really annoying if the USB device is coming into and out of suspend.

Remove the unnecessary warning.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Tested-by: Stephen Hemminger <stephen@networkplumber.org>
2013-03-25 10:39:19 -07:00
Vivek Gautam 1c11a172cb usb: xhci: Fix TRB transfer length macro used for Event TRB.
Use proper macro while extracting TRB transfer length from
Transfer event TRBs. Adding a macro EVENT_TRB_LEN (bits 0:23)
for the same, and use it instead of TRB_LEN (bits 0:16) in
case of event TRBs.

This patch should be backported to kernels as old as 2.6.31, that
contain the commit b10de14211 "USB: xhci:
Bulk transfer support".  This patch will have issues applying to older
kernels.

Signed-off-by: Vivek gautam <gautam.vivek@samsung.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable@vger.kernel.org
2013-03-25 10:39:18 -07:00
Lan Tianyu bafcaf6d84 usb/acpi: binding xhci root hub usb port with ACPI
This patch is to bind xhci root hub usb port with its acpi node.
The port num in the acpi table matches with the sequence in the xhci
extended capabilities table. So call usb_hcd_find_raw_port_number() to
transfer hub port num into raw port number which associates with
the sequence in the xhci extended capabilities table before binding.

Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2013-03-25 10:39:17 -07:00
Lan Tianyu 3f5eb14135 usb: add find_raw_port_number callback to struct hc_driver()
xhci driver divides the root hub into two logical hubs which work
respectively for usb 2.0 and usb 3.0 devices. They are independent
devices in the usb core. But in the ACPI table, it's one device node
and all usb2.0 and usb3.0 ports are under it. Binding usb port with
its acpi node needs the raw port number which is reflected in the xhci
extended capabilities table. This patch is to add find_raw_port_number
callback to struct hc_driver(), fill it with xhci_find_raw_port_number()
which will return raw port number and add a wrap usb_hcd_find_raw_port_number().

Otherwise, refactor xhci_find_real_port_number(). Using
xhci_find_raw_port_number() to get real index in the HW port status
registers instead of scanning through the xHCI roothub port array.
This can help to speed up.

All addresses in xhci->usb2_ports and xhci->usb3_ports array are
kown good ports and don't include following bad ports in the extended
capabilities talbe.
     (1) root port that doesn't have an entry
     (2) root port with unknown speed
     (3) root port that is listed twice and with different speeds.

So xhci_find_raw_port_number() will only return port num of good ones
and never touch bad ports above.

Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2013-03-25 10:39:17 -07:00
Peter Chen 09ce0c0c8a usb: xhci: fix build warning
/home/b29397/work/code/git/linus/linux-2.6/drivers/usb/host/xhci-ring.c: In function ‘handle_port_status’:
/home/b29397/work/code/git/linus/linux-2.6/drivers/usb/host/xhci-ring.c:1580: warning: ‘hcd’ may be used uninitialized in this function

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2013-03-25 10:39:16 -07:00
Greg Kroah-Hartman 2849a3a945 Merge 3.9-rc4 into usb-next
This picks up the fixes we had for USB in 3.9-rc4

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 10:05:37 -07:00
Felipe Balbi e6667ef7ac usb: gadget: mv_u3d: fix sparse warnings
Fix the following sparse warnings:

drivers/usb/gadget/mv_u3d_core.c: In function ‘mv_u3d_ep_queue’:
drivers/usb/gadget/mv_u3d_core.c:812:2: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/usb/gadget/mv_u3d_core.c:822:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/usb/gadget/mv_u3d_core.c:823:4: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/usb/gadget/mv_u3d_core.c:823:28: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/usb/gadget/mv_u3d_core.c: In function ‘mv_u3d_ep_dequeue’:
drivers/usb/gadget/mv_u3d_core.c:905:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/usb/gadget/mv_u3d_core.c: In function ‘mv_u3d_probe’:
drivers/usb/gadget/mv_u3d_core.c:1840:3: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/usb/gadget/mv_u3d_core.c:1855:51: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/usb/gadget/mv_u3d_core.c:1855:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
drivers/usb/gadget/mv_u3d_core.c:1858:53: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/usb/gadget/mv_u3d_core.c:1858:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
drivers/usb/gadget/mv_u3d_core.c: In function ‘mv_u3d_irq_process_tr_complete’:
drivers/usb/gadget/mv_u3d_core.c:163:21: warning: ‘remaining_length’ may be used uninitialized in this function [-Wmaybe-uninitialized]
drivers/usb/gadget/mv_u3d_core.c:125:28: note: ‘remaining_length’ was declared here

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-22 09:15:10 +02:00
Felipe Balbi af593da481 usb: gadget: mv_u3d: remove outdated selects
USB_GADGET_{DUAL,SUPER}SPEED symbols have
been removed by commit 85b8614 (usb: gadget:
get rid of USB_GADGET_{DUAL,SUPER}SPEED), for
some reason mv_u3d_core was lost.

Remove those selects now.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-22 09:12:23 +02:00
Felipe Balbi a10713a59a usb: gadget: mv_u3d: remove unused headers
none of those headers are used by the driver,
removing them still compiles fine.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-22 09:11:17 +02:00
Jingoo Han 4895a2ee5d usb: gadget: mv_u3d: make mv_u3d_pm_ops static
Make mv_u3d_pm_ops static because mv_u3d_pm_ops is not exported.
Also, CONFIG_PM_SLEEP is used to remove unnecessary ifdefs.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-22 08:45:12 +02:00
Grazvydas Ignotas 54485116cd usb: musb: core: log VBUS error
VBUS_ERROR is a serious error that the driver often doesn't recover from
in my tests, so we should at least inform the user about it.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-22 08:44:24 +02:00
Grazvydas Ignotas e21de10cd8 usb: musb: gadget: clear gadget_driver when gadget is stopped
Some musb glue drivers use gadget_driver pointer to know if any gadget
drivers are loaded at some moment and base further decisions on it,
like to do runtime suspend/resume or not. Right now the pointer is
left alone on stop and OMAP musb glue later does wrong runtime_pm
decisions because of it.

Clear the gadget_driver pointer on remove, it's invalid after stop
anyway.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-22 08:41:28 +02:00
Grazvydas Ignotas e561511280 usb: musb: core: honour initial transceiver state
As the usb transceiver driver usually starts first, it should already
have default_a variable set according to ID pin state, so don't
override it. In case default_a was not changed by trasceiver, it will
default to 0 and this code will work as before.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-22 08:40:48 +02:00
Greg Kroah-Hartman 2be818a116 Revert "USB: quatech2: only write to the tty if the port is open."
This reverts commit 27b351c554.  It caused
problems with the build.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Bill Pemberton <wfp5p@viridian.itc.virginia.edu>
Cc: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 16:07:57 -07:00
Greg Kroah-Hartman 23a376f98c Merge 3.9-rc3 into tty-next 2013-03-21 16:07:34 -07:00
Johan Hovold fc98ab873a USB: ti_usb_3410_5052: fix use-after-free in TIOCMIWAIT
Use the port wait queue and make sure to check the serial disconnected
flag before accessing private port data after waking up.

This is is needed as the private port data (including the wait queue
itself) can be gone when waking up after a disconnect.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:05 -07:00
Johan Hovold 43a66b4c41 USB: ssu100: fix use-after-free in TIOCMIWAIT
Use the port wait queue and make sure to check the serial disconnected
flag before accessing private port data after waking up.

This is is needed as the private port data (including the wait queue
itself) can be gone when waking up after a disconnect.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:05 -07:00
Johan Hovold dbcea7615d USB: spcp8x5: fix use-after-free in TIOCMIWAIT
Use the port wait queue and make sure to check the serial disconnected
flag before accessing private port data after waking up.

This is is needed as the private port data (including the wait queue
itself) can be gone when waking up after a disconnect.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:05 -07:00
Johan Hovold 69f87f40d2 USB: quatech2: fix use-after-free in TIOCMIWAIT
Use the port wait queue and make sure to check the serial disconnected
flag before accessing private port data after waking up.

This is is needed as the private port data (including the wait queue
itself) can be gone when waking up after a disconnect.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:05 -07:00
Johan Hovold 40509ca982 USB: pl2303: fix use-after-free in TIOCMIWAIT
Use the port wait queue and make sure to check the serial disconnected
flag before accessing private port data after waking up.

This is is needed as the private port data (including the wait queue
itself) can be gone when waking up after a disconnect.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:05 -07:00
Johan Hovold 8edfdab371 USB: oti6858: fix use-after-free in TIOCMIWAIT
Use the port wait queue and make sure to check the serial disconnected
flag before accessing private port data after waking up.

This is is needed as the private port data (including the wait queue
itself) can be gone when waking up after a disconnect.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:04 -07:00
Johan Hovold a14430db68 USB: mos7840: fix use-after-free in TIOCMIWAIT
Use the port wait queue and make sure to check the serial disconnected
flag before accessing private port data after waking up.

This is is needed as the private port data (including the wait queue
itself) can be gone when waking up after a disconnect.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:04 -07:00
Johan Hovold e670c6af12 USB: mos7840: fix broken TIOCMIWAIT
Make sure waiting processes are woken on modem-status changes.

Currently processes are only woken on termios changes regardless of
whether the modem status has changed.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:04 -07:00
Johan Hovold cf1d244436 USB: mct_u232: fix use-after-free in TIOCMIWAIT
Use the port wait queue and make sure to check the serial disconnected
flag before accessing private port data after waking up.

This is is needed as the private port data (including the wait queue
itself) can be gone when waking up after a disconnect.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:04 -07:00
Johan Hovold 7b24596905 USB: io_ti: fix use-after-free in TIOCMIWAIT
Use the port wait queue and make sure to check the serial disconnected
flag before accessing private port data after waking up.

This is is needed as the private port data (including the wait queue
itself) can be gone when waking up after a disconnect.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:04 -07:00
Johan Hovold 333576255d USB: io_edgeport: fix use-after-free in TIOCMIWAIT
Use the port wait queue and make sure to check the serial disconnected
flag before accessing private port data after waking up.

This is is needed as the private port data (including the wait queue
itself) can be gone when waking up after a disconnect.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:03 -07:00
Johan Hovold 71ccb9b019 USB: ftdi_sio: fix use-after-free in TIOCMIWAIT
Use the port wait queue and make sure to check the serial disconnected
flag before accessing private port data after waking up.

This is is needed as the private port data (including the wait queue
itself) can be gone when waking up after a disconnect.

When switching to tty ports, some lifetime assumptions were changed.
Specifically, close can now be called before the final tty reference is
dropped as part of hangup at device disconnect. Even with the ftdi
private-data refcounting this means that the port private data can be
freed while a process is sleeping on modem-status changes and thus
cannot be relied on to detect disconnects when woken up.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:03 -07:00
Johan Hovold 508f940f14 USB: f81232: fix use-after-free in TIOCMIWAIT
Use the port wait queue and make sure to check the serial disconnected
flag before accessing private port data after waking up.

This is is needed as the private port data (including the wait queue
itself) can be gone when waking up after a disconnect.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:03 -07:00
Johan Hovold 356050d8b1 USB: cypress_m8: fix use-after-free in TIOCMIWAIT
Use the port wait queue and make sure to check the serial disconnected
flag before accessing private port data after waking up.

This is is needed as the private port data (including the wait queue
itself) can be gone when waking up after a disconnect.

Also remove bogus test for private data pointer being NULL as it is
never assigned in the loop.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:03 -07:00
Johan Hovold fa1e11d523 USB: ch341: fix use-after-free in TIOCMIWAIT
Use the port wait queue and make sure to check the serial disconnected
flag before accessing private port data after waking up.

This is is needed as the private port data (including the wait queue
itself) can be gone when waking up after a disconnect.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:03 -07:00
Johan Hovold 5018860321 USB: ark3116: fix use-after-free in TIOCMIWAIT
Use the port wait queue and make sure to check the serial disconnected
flag before accessing private port data after waking up.

This is is needed as the private port data (including the wait queue
itself) can be gone when waking up after a disconnect.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:02 -07:00
Johan Hovold d7971051e4 USB: serial: fix interface refcounting
Make sure the interface is not released before our serial device.

Note that drivers are still not allowed to access the interface in
any way that may interfere with another driver that may have gotten
bound to the same interface after disconnect returns.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:02 -07:00
Johan Hovold 5492bf3d56 USB: io_ti: fix get_icount for two port adapters
Add missing get_icount field to two-port driver.

The two-port driver was not updated when switching to the new icount
interface in commit 0bca1b913a ("tty: Convert the USB drivers to the
new icount interface").

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:02 -07:00
Johan Hovold 618aa1068d USB: garmin_gps: fix memory leak on disconnect
Remove bogus disconnect test introduced by 95bef012e ("USB: more serial
drivers writing after disconnect") which prevented queued data from
being freed on disconnect.

The possible IO it was supposed to prevent is long gone.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:02 -07:00
Johan Hovold cb25505fc6 USB: cdc-acm: fix device unregistration
Unregister tty device in disconnect as is required by the USB stack.

By deferring unregistration to when the last tty reference is dropped,
the parent interface device can get unregistered before the child
resulting in broken hotplug events being generated when the tty is
finally closed:

KERNEL[2290.798128] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1:3.1 (usb)
KERNEL[2290.804589] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-1 (usb)
KERNEL[2294.554799] remove   /2-1:3.1/tty/ttyACM0 (tty)

The driver must deal with tty callbacks after disconnect by checking the
disconnected flag. Specifically, further opens must be prevented and
this is already implemented.

Cc: stable <stable@vger.kernel.org>
Cc: Oliver Neukum <oneukum@suse.de>
Acked-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:01 -07:00
Alexey Khoroshilov c93d819550 usb: cdc-acm: fix error handling in acm_probe()
acm_probe() ignores errors in tty_port_register_device()
and leaves intfdata pointing to freed memory on alloc_fail7
error path. The patch fixes the both issues.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Acked-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:01 -07:00
Alan Stern 417c765af9 USB: EHCI: fix up incorrect merge resolution
This patch (as1671) fixes up an incorrect resolution of a merge
conflict between Greg KH's usb-linus branch and his usb-next branch.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:00:18 -07:00
Felipe Balbi 4261b8f353 usb: host: ehci-tegra: fix PHY error handling
PHY layer no longer returns NULL, we must
switch from IS_ERR_OR_NULL() to IS_ERR().

Acked-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-21 20:14:12 +02:00
Greg Kroah-Hartman d93acbcacd usb: fixes for v3.9-rc4
udc-core learned that it shouldn't use invalid pointers
 when unloading a gadget driver.
 
 net2272 and net2280 got a fix for a regression caused by
 the udc_start/udc_stop conversion.
 
 We're defining a static inline no-op for otg_ulpi_create()
 to prevent build errors when that driver isn't enabled.
 
 FunctionFS got a fix for an off-by-one error when binding
 and unbinding instances of FunctionFS.
 
 MUSB learned that it shouldn't try to unmap buffers which
 weren't previously mapped.
 
 f_rndis got a fix for a possible NULL pointer dereference
 in a debugging message code.
 
 MUSB's DA8xx glue layer got a build fix due to a typo.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.12 (GNU/Linux)
 
 iQIcBAABAgAGBQJRSu6dAAoJEIaOsuA1yqREdA8P/R4iKKZ3H23xfSJirQaEYADY
 ejeCefHeev+QFXcRVtkhTMGV1Kt6ZLAJ19wrTT3xdENjUbBZdx+9GzN/bUsr5yAO
 SjBFSzVkbbELn4es+hbUPIJgGDa+/DOs9nLgDLlzdaaWbbyvpsl5cbokGAYFgstn
 xy/36e5wctm066cZzG78+cewtuvKxXHANhZt7tTNLWfu/ARaBfiDoYH+fhobJwzq
 poZ47hZPxPE5nn9ppB16jtvpAFAXT8AQZg4SGA2yIRKXkExNNCOUh2xxIHnmWdI2
 k3Qp0YUlCUsoCifFu6k0vhJBxctbi9AVTnnBJXWokw4tX4bVt9uglDkXXZdOfQ/y
 vA3j+lY9rSjuBixmNjVlvwP77qyR85ILFF9WDhwsGrSNJyeUyV/Fmy2s7sRZFLjL
 X6ziN2Tj/3gC6uaO5Rbgmw7aURy8UyML/byBVq/uRMTu0NJPGxnC5xM2WPmGl9nz
 dWP2mcd193rxys8GYH7G6zz4MJ3WFyPgJ0VszsT/kGI/rL0ij1xTuKnw7zsP38Mk
 RINfeBcY2Msi0Mt4KnXJ8vgSIyI3XOwVCebKCAIdc4rktVAryKCJTjtXMlHD4niI
 rTztkXPkM4bcEiqa29FIhGkiYsQfQ66N8a9RbH6nWZSvhbgs1p8Y721FYfTKt+54
 oTvm35fUgthYTtpig5bN
 =wGIr
 -----END PGP SIGNATURE-----

Merge tag 'fixes-for-v3.9-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-linus

Felipe writes:

	usb: fixes for v3.9-rc4

	udc-core learned that it shouldn't use invalid pointers
	when unloading a gadget driver.

	net2272 and net2280 got a fix for a regression caused by
	the udc_start/udc_stop conversion.

	We're defining a static inline no-op for otg_ulpi_create()
	to prevent build errors when that driver isn't enabled.

	FunctionFS got a fix for an off-by-one error when binding
	and unbinding instances of FunctionFS.

	MUSB learned that it shouldn't try to unmap buffers which
	weren't previously mapped.

	f_rndis got a fix for a possible NULL pointer dereference
	in a debugging message code.

	MUSB's DA8xx glue layer got a build fix due to a typo.
2013-03-21 08:40:22 -07:00
Grazvydas Ignotas 249751f223 usb: phy: twl4030-usb: poll for ID disconnect
On pandora, STS_USB interrupt doesn't arrive on USB host cable disconnect
for some reason while VBUS is driven by twl itself, but STS_HW_CONDITIONS
is updated correctly. It does work fine when PHY is powered down though.
To work around that we have to poll.

This patch also moves twl->linkstat update code to callers so that
changes can be handled in thread safe way (as polling work can trigger
at the same time as real irq now).

TI PSP kernels have similar workarounds, so (many?) more boards are likely
affected.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-21 14:20:30 +02:00
Grazvydas Ignotas 15460de7f3 usb: phy: twl4030-usb: don't switch the phy on/off needlessly
With runtime_pm in place there is no longer need to turn the phy
on/off in OTG layer on cable connect/disconnect, OMAP glue does
this through otg.set_suspend() callback after it's called through
omap_musb_mailbox() on VBUS/ID interrupt. Not doing this will save
power when cable is connected but no gadget driver is loaded.

This will also have side effect of automatic USB charging no longer
working without twl4030_charger driver, because a regulator needed
for charging will no longer be enabled, so be sure to enable charger
driver if charging is needed.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-21 14:20:29 +02:00
Grazvydas Ignotas ca4f70ce78 usb: phy: twl4030-usb: ignore duplicate events
In some rare cases we may get multiple interrupts that will generate
duplicate omap_musb_mailbox() calls. This is a problem because each
VBUS/ID event generates runtime_pm call in OMAP glue code, causing
unbalanced gets or puts and breaking PM.

The same goes for initial state, glue already defaults to "no cable"
state, so only bother it if we have VBUS or ID.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Reviewed-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-21 14:20:29 +02:00
Grazvydas Ignotas 44a50d088a usb: phy: twl4030-usb: don't enable PHY during init
There is no need to do it, otg.set_suspend(false) (which itself
comes from runtime_pm OMAP glue calls) will enable it later anyway.
This used to be the place where things were enabled if booted with
cable connected before runtime_pm conversion, but now can be dropped.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-21 14:20:28 +02:00
Paul Bolle eda81bea89 usb: gadget: net2272: finally convert "CONFIG_USB_GADGET_NET2272_DMA"
The Kconfig symbol USB_GADGET_NET2272_DMA was renamed to USB_NET2272_DMA
in commit 193ab2a607 ("usb: gadget: allow
multiple gadgets to be built"). That commit did not convert the only
occurrence of the corresponding Kconfig macro. Convert that macro now.

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-21 12:14:05 +02:00
Bill Pemberton 29727f3bc2 Revert "USB: quatech2: only write to the tty if the port is open."
This reverts commit 27b351c554.

Calling tty_flip_buffer_push on an unopened tty is legal, so the
driver doesn't need track if port has been opened.  Reverting this
allows the entire is_open logic to be removed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-20 16:27:55 -07:00
Greg Kroah-Hartman cf2d9500a5 Merge branch 'usb-linus' into usb-next
This is to pick up the fixes in that branch, and let Alan fix the merge
error in drivers/usb/host/ehci-timer.c better than I just did (as I know
I messed it up...)

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-20 16:21:47 -07:00
Alan Stern d714aaf649 USB: EHCI: fix regression in QH unlinking
This patch (as1670) fixes a regression caused by commit
6402c796d3 (USB: EHCI: work around
silicon bug in Intel's EHCI controllers).  The workaround goes through
two IAA cycles for each QH being unlinked.  During the first cycle,
the QH is not added to the async_iaa list (because it isn't fully gone
from the hardware yet), which means that list will be empty.

Unfortunately, I forgot to update the IAA watchdog timer routine.  It
thinks that an empty async_iaa list means the timer expiration was an
error, which isn't true any more.  This problem didn't show up during
initial testing because the controllers being tested all had working
IAA interrupts.  But not all controllers do, and when the watchdog
timer expires, the empty-list check prevents the second IAA cycle from
starting.  As a result, URB unlinks never complete.  The check needs
to be removed.

Among the symptoms of the regression are processes stuck in D wait
states and hangs during system shutdown.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-and-tested-by: Stephen Warren <swarren@wwwdotorg.org>
Reported-and-tested-by: Sven Joachim <svenjoac@gmx.de>
Reported-by: Andreas Bombe <aeb@debian.org>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-20 16:17:22 -07:00
Felipe Balbi 75f32ec1de arm: tegra: fix Kconfig select clauses
USB_ULPI and USB_ULPI_VIEWPORT shouldn't really
be selected directly by anyone, but since Tegra
still needs some time before turning ulpi viewport
into a proper PHY driver, we need to keep the
selects in place.

This patch just fixes the conditional select
so that it will continue to build after merging
the latest PHY layer changes.

Acked-by: Stephen Warren <swarren@nvidia.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-20 19:56:21 +02:00
Truls Bengtsson 967baed40e usb: gadget: f_rndis: Avoid to use ERROR macro if cdev can be null
The udc_irq service runs the isr_tr_complete_handler which in turn
"nukes" the endpoints, including a call to rndis_response_complete,
if appropriate. If the rndis_msg_parser fails here, an error will
be printed using a dev_err call (through the ERROR() macro).

However, if the usb cable was just disconnected the device (cdev)
might not be available and will be null. Since the dev_err macro will
dereference the cdev pointer we get a null pointer exception.

Reviewed-by: Radovan Lekanovic <radovan.lekanovic@sonymobile.com>
Signed-off-by: Truls Bengtsson <truls.bengtsson@sonymobile.com>
Signed-off-by: Oskar Andero <oskar.andero@sonymobile.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-20 17:30:51 +02:00
Andrzej Pietrasiewicz 3416905ba0 usb: gadget: ffs: fix enable multiple instances
This patch fixes an "off-by-one" bug found in
581791f (FunctionFS: enable multiple functions).

During gfs_bind/gfs_unbind the functionfs_bind/functionfs_unbind should be
called for every functionfs instance. With the "i" pre-decremented they
were not called for the zeroth instance.

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: <stable@vger.kernel.org>

[ balbi@ti.com : added offending commit's subject ]

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-20 16:46:34 +02:00
Alan Stern 8119b55aed USB: gadget: net2280: remove leftover driver->unbind call in error pathway
This patch (as1667) removes an incorrect driver->unbind() call from
the net2280 driver.  If startup fails, the UDC core takes care of
unbinding the gadget driver automatically; the controller driver
shouldn't do it too.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-20 16:46:34 +02:00
Alan Stern 511f3c5326 usb: gadget: udc-core: fix a regression during gadget driver unbinding
This patch (as1666) fixes a regression in the UDC core.  The core
takes care of unbinding gadget drivers, and it does the unbinding
before telling the UDC driver to turn off the controller hardware.
When the call to the udc_stop callback is made, the gadget no longer
has a driver.  The callback routine should not be invoked with a
pointer to the old driver; doing so can cause problems (such as
use-after-free accesses in net2280).

This patch should be applied, with appropriate context changes, to all
the stable kernels going back to 3.1.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: <stable@vger.kernel.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-20 16:46:33 +02:00
Felipe Balbi 699412d951 usb: gadget: net22xx: fix ->disconnect reporting
with the latest udc_start/udc_stop conversion,
too much code was deleted which ended up creating
a regression in net2272 and net2280 drivers.

To fix the regression we revert one hunk of the
original commits.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-20 16:46:28 +02:00
Felipe Balbi e8d891fb7b usb: phy: gpio-vbus: don't ignore regulator APIs return value
Due to recent changes to regulator API, all
users which don't check regulator_{en,dis}able()'s
return value will generate compile warnings.

Add such checks to gpio-vbus.

Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-20 08:01:53 +02:00
Felipe Balbi b64a15930c usb: phy: samsung: fix sparse warning
Fix the following sparse warning:

drivers/usb/phy/phy-samsung-usb2.c:50:26: sparse: incorrect type in argument 1 (different address spaces)
drivers/usb/phy/phy-samsung-usb2.c:50:26:    expected void const volatile [noderef] <asn:2>*addr
drivers/usb/phy/phy-samsung-usb2.c:50:26:    got void *

Cc: Vivek Gautam <gautam.vivek@samsung.com>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-19 10:14:35 +02:00
Jiri Slaby aa27a094e2 TTY: add tty_port_tty_hangup helper
It allows for cleaning up on a considerable amount of places. They did
port_get, hangup, kref_put. Now the only thing needed is to call
tty_port_tty_hangup which does exactly that. And they can also decide
whether to consider CLOCAL or completely ignore that.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-18 16:24:29 -07:00
Jiri Slaby e4408ce3c2 TTY: quatech2, remove unneeded is_open
tty->ops->break_ctl cannot be called outside the gap between open and
close. So there is no need to check whether the port is open in
break_ctl in quatech2. Remove the check and also that member
completely.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-18 16:21:26 -07:00
Jiri Slaby 6aad04f213 TTY: add tty_port_tty_wakeup helper
It allows for cleaning up on a considerable amount of places. They did
port_get, wakeup, kref_put. Now the only thing needed is to call
tty_port_tty_wakeup which does exactly that.

One exception is ifx6x60 where tty_wakeup was open-coded. We now call
tty_wakeup properly there.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-18 16:19:45 -07:00
Doug Anderson 3f3b55bf78 usb: ehci-s5p: Use devm for requesting ehci_vbus_gpio
The ehci_vbus_gpio is requested but never freed.  This can cause
problems with deferred probes and would cause problems if
s5p_ehci_remove was ever called.  Use devm to fix this.

Signed-off-by: Doug Anderson <dianders@chromium.org>
Acked-by: Jingoo Han <jg1.han@samsung.com>
Tested-by: Vivek Gautam <gautam.vivek@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-18 16:10:12 -07:00
Alan Stern 24b90814fb USB: EHCI: don't turn on PORT_SUSPEND during port resume
This patch (as1637) cleans up the way ehci-hcd handles end-of-resume
port signalling.  When the PORT_RESUME bit in the port's status and
control register is cleared, we shouldn't be setting the PORT_SUSPEND
bit at the same time.  Not doing this doesn't seem to have hurt so
far, but we might as well do the right thing.

Also, the patch replaces an estimated value for what the port status
should be following a resume with the actual register value.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-18 16:05:58 -07:00
Alan Stern 60fd4aa742 USB: EHCI: reorganize ehci_iaa_watchdog()
This patch (as1635) rearranges the control-flow logic in
ehci_iaa_watchdog() slightly to agree better with the comments.  It
also changes a verbose-debug message to a regular debug message.
Expiration of the IAA watchdog is an unusual event and can lead to
problems; we need to know about it if it happens during debugging.  It
should not be necessary to set a "verbose" compilation option.

No behavioral changes other than the debug message.  Lots of apparent
changes to the source text, though, because the indentation level was
decreased.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-18 16:05:58 -07:00
Alan Stern 4dd405a4b0 USB: EHCI: improve use of per-port status-change bits
This patch (as1634) simplifies some of the code associated with the
per-port change bits added in EHCI-1.1, and in particular it fixes a
bug in the logic of ehci_hub_status_data().  Even if the change bit
doesn't indicate anything happened on a particular port, we still have
to notify the core about changes to the suspend or reset status.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-18 16:05:58 -07:00
Alan Stern 6d5df89762 USB: EHCI: decrease schedule-status poll timeout
This patch (as1657) decreases the timeout used by ehci-hcd for polling
the async and periodic schedule statuses.  The timeout is currently
set to 20 ms, which is much too high.  Controllers should always
update the schedule status within one or two ms of being told to do
so; if they don't then something is wrong.

Furthermore, bug reports have shown that sometimes controllers
(particularly those made by VIA) don't update the status bit at all,
even when the schedule does change state.  When this happens, polling
for 20 ms would cause an unnecessarily long delay.

The delay is reduced to somewhere between 2 and 4 ms, depending on the
slop allowed by the kernel's high-res timers.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-18 16:05:58 -07:00
Dmitry Torokhov f8264340e6 USB: xhci - fix bit definitions for IMAN register
According to XHCI specification (5.5.2.1) the IP is bit 0 and IE is bit 1
of IMAN register. Previously their definitions were reversed.

Even though there are no ill effects being observed from the swapped
definitions (because IMAN_IP is RW1C and in legacy PCI case we come in
with it already set to 1 so it was clearing itself even though we were
setting IMAN_IE instead of IMAN_IP), we should still correct the values.

This patch should be backported to kernels as old as 2.6.36, that
contain the commit 4e833c0b87 "xhci: don't
re-enable IE constantly".

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable@vger.kernel.org
2013-03-18 08:25:13 -07:00
Masanari Iida cf2fbdd26f treewide: Fix typos in printk and comment
Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-03-18 14:57:53 +01:00
Zhang Yanfei 53140e062b driver: usb: storage: remove cast for kmalloc return value
remove cast for kmalloc return value.

Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Cc: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-usb@vger.kernel.org
Cc: usb-storage@lists.one-eyed-alien.net
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-03-18 14:16:01 +01:00
Fabio Baltieri af6882be36 usb: phy: ab8500-usb: update irq handling code
Update irq handling code to notify all possible link status changes of
AB8500 and AB8505 to the ux500-musb glue driver.  The additional event
codes will be used for pm-runtime implementation, and are defined in a
separate ux500-specific header.

This also modify the irq registration code to use devm_* helpers and
drop all non necessary fail path code.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 14:41:33 +02:00
Fabio Baltieri 73f226cbd7 usb: otg: ab8500-usb: drop support for ab8500 pre v2.0
AB8500 versions preceding 2.0 were only used internally by ST-Ericsson
and are not supported anymore.  This patch drops all v1.0 and v1.1
support code.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 14:41:33 +02:00
Fabio Baltieri 0135522c48 usb: musb: ux500: add otg notifier support
Add transceiver notifier event handling to the ux500 driver to set vbus
on specific transceiver events.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>

[ balbi@ti.com: fix build error due to missing
	otg_state_string() ]

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 14:41:32 +02:00
Fabio Baltieri 996a9d26d3 usb: musb: ux500: implement musb_set_vbus
Add ux500_musb_set_vbus() implementation for ux500.

This is based on the version originally developed inside ST-Ericsson.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>

[ balbi@ti.com: fix a build error due to
	missing otg_state_string() ]

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 14:41:32 +02:00
Virupax Sadashivpetimath 399e0f4f00 usb: musb: ux500_dma: add missing MEM resource check
Fix dma_controller_create() fail path in case memory resource is
missing.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Virupax Sadashivpetimath <virupax.sadashivpetimath@stericsson.com>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 14:41:31 +02:00
Felipe Balbi 9ee1c7fbea usb: host: ohci-exynos: fix PHY error handling
PHY layer no longer returns NULL. We must
switch from IS_ERR_OR_NULL() to IS_ERR().

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 14:41:30 +02:00
Felipe Balbi a16283e11d usb: host: ehci-s5p: fix PHY error handling
PHY layer no longer returns NULL. We must
switch from IS_ERR_OR_NULL() to IS_ERR().

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:31 +02:00
Felipe Balbi 6f3ed4ec18 usb: host: ehci-mv: fix PHY error handling
PHY layer no longer returns NULL. We must
switch from IS_ERR_OR_NULL() to IS_ERR().

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:31 +02:00
Felipe Balbi e299bd93e4 usb: host: ehci-msm: fix PHY error handling
PHY layer no longer returns NULL. We must
switch from IS_ERR_OR_NULL() to IS_ERR().

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:30 +02:00
Felipe Balbi a90199bb94 usb: musb: omap2430: fix PHY error handling
PHY layer no longer returns NULL. It will
return -ENXIO when PHY layer isn't enabled
and we can use that to bail out instead of
request a probe deferral.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:29 +02:00
Felipe Balbi f4f5ba5e7d usb: gadget: s3c-hsotg: fix PHY error handling
PHY laye rno longer return NULL. We need to
switch over from IS_ERR_OR_NULL() to IS_ERR().

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:29 +02:00
Felipe Balbi 4dbb716125 usb: gadget: mv_udc_core: fix PHY error handling
PHY layer no longer returns NULL. It will
return -ENXIO when PHY layer isn't enabled
and we can use that to bail out instead of
request a probe deferral.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:28 +02:00
Felipe Balbi d105e7f86f usb: dwc3: fix PHY error handling
PHY layer no longer returns NULL. It will
return -ENXIO when PHY layer isn't enabled
and we can use that to bail out instead of
request a probe deferral.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:28 +02:00
Kishon Vijay Abraham I 817e5f33d0 usb: phy: twl4030: fix cold plug on OMAP3
Having twl4030_usb_phy_init() (detects if a cable is connected before
twl4030 is probed) in twl4030 probe makes cable connect events to be
missed by musb glue, since it gets loaded after twl4030. Having
twl4030_usb_phy_init as a usb_phy ops lets twl4030_usb_phy_init to be
called when glue is ready.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Tested-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:27 +02:00
Kishon Vijay Abraham I 9166902c43 usb: phy: twl4030: use devres API for regulator get and request irq
Used devres APIs devm_request_threaded_irq and devm_regulator_get for
requesting irq and for getting regulator respectively.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Tested-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:27 +02:00
Kishon Vijay Abraham I 3bf6db9bbe usb: musb: omap: add usb_phy_init in omap2430_musb_init
Some PHYs load too early (twl4030) making omap glue to miss cable connect events
if the board is booted with cable connected. So adding usb_phy_init in
omap2430_musb_init lets PHYs to report events once glue is ready.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:26 +02:00
Kishon Vijay Abraham I bb467cf569 usb: musb: omap: remove the check before calling otg_set_vbus
No functional change. otg_set_vbus is already protected so removed the
check before calling otg_set_vbus.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:25 +02:00
Dan Carpenter a5eaaa1f33 usb: gadget: uvc: use capped length value
"req->length" is a capped version of "data->length".

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:25 +02:00
Felipe Balbi a33bb21208 usb: dwc3: omap: fix sparse warning
our global '_omap' pointer wasn't marked
static. This patch solves the following sparse
warning:

	warning: symbol '_omap' was not declared. \
	Should it be static?

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:24 +02:00
Kishon Vijay Abraham I eee44da045 usb: musb: omap2430: replace *_* with *-* in property names
No functional change. Replace *_* with *-* in property names of otg to
follow the general convention.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:23 +02:00
Chen Gang c3ec830d89 usb: gadget: uvc: Use strlcpy instead of strncpy
For NULL terminated string, better notice '\0' in the end.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:23 +02:00
Cyril Roelandt 6854bcdc6f usb: gadget: uvc: Use GFP_ATOMIC under spin lock
Found using the following semantic patch:
<spml>
@@
@@
spin_lock_irqsave(...);
... when != spin_unlock_irqrestore(...);
* GFP_KERNEL
</spml>

Signed-off-by: Cyril Roelandt <tipecaml@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:22 +02:00
Bhupesh Sharma 326b0e613b usb: gadget: uvc: Make video streaming buffer size comply with USB3.0 SS
As per the USB3.0 specs, the bandwidth requirements of a UVC's video
streaming endpoint will change to support super-speed. These changes
will be dependent on whether the UVC video streaming endpoint is Bulk or
Isochronous:

- If video streaming endpoint is Isochronous:
  As per Section 4.4.8.2 (Isochronous Transfer Bandwidth Requirements)
  of the USB3.0 specs:

    A SuperSpeed isochronous endpoint can move up to three burst
    transactions of up to 16 maximum sized packets (3 * 16 * 1024 bytes)
    per service interval.

- If video streaming endpoint is Bulk:
  As per 4.4.6.1 (Bulk Transfer Data Packet Size) of the USB3.0 specs:

    An endpoint for bulk transfers shall set the maximum data packet
    payload size in its endpoint descriptor to 1024 bytes. It also
    specifies the burst size that the endpoint can accept from or
    transmit on the SuperSpeed bus. The allowable burst size for a bulk
    endpoint shall be in the range of 1 to 16.

So, in the Isochronous case, we can define the USB request's buffer to
be equal to = (Maximum packet size) * (bMaxBurst + 1) * (Mult + 1), so
that the UDC driver can try to send out this buffer in one Isochronous
service interval.

The same computation will hold good for the Bulk case as the Mult
value is 0 here and we can have a USB request buffer of maximum
16 * 1024 bytes size, which can be sent out by the UDC driver as
per the Bulk bandwidth allocation on the USB3 bus.

This patch adds the above-mentioned support and is also USB2.0 backward
compliant.

Signed-off-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:22 +02:00
Bhupesh Sharma 41837c352f usb: gadget: uvc: Delay the status stage when setting alternate setting 1
This patch adds the support in UVC webcam gadget design for providing
USB_GADGET_DELAYED_STATUS in response to a set_interface(alt setting 1)
command issue by the Host.

The current UVC webcam gadget design generates a STREAMON event
corresponding to a set_interface(alt setting 1) command from the Host.
This STREAMON event will eventually be routed to a real V4L2 device.

To start video streaming, it may be required to perform some register
writes to a camera sensor device over slow external busses like I2C or
SPI. So, it makes sense to ensure that we delay the STATUS stage of the
set_interface (alt setting 1) command.

Otherwise, a lot of ISOC IN tokens sent by the Host will be replied to
by zero-length packets by the webcam device. On certain Hosts this may
even lead to ISOC URBs been cancelled from the Host side.

So, as soon as we finish doing all the "streaming" related stuff on the
real V4L2 device, we call a STREAMON ioctl on the UVC side and from here
we call the 'usb_composite_setup_continue' function to complete the
status stage of the set_interface(alt setting 1) command.

Further, we need to ensure that we queue no video buffers on the UVC
webcam gadget, until we de-queue a video buffer from the V4L2 device.
So, the application should call the STREAMON on UVC side only when it
has dequeued sufficient buffers from the V4L2 side and queued them to
the UVC gadget.

Signed-off-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:21 +02:00
Bhupesh Sharma 43ff05e20c usb: gadget: uvc: Add fix for UVC compliance test suite's assertion 6.1.25 failure
As per the UVC compliance test suite's assertion 6.1.25, the `iFunction`
field of the Interface Association Descriptor (IAD) should the match the
`iInterface` field of the standard Video Control (VC) Interface Descriptor for
this Video Interface Collection (VIC).

This mandatory case is captured in section 3.11 of the
USB Video Class Compliance specification revision 1.1

This patch fixes this test assertion's failure and has been tested on
Linux FC16, WinXP, WIN7 and WIN8 High speed and Super Speed hosts
for successful enumeration.

Signed-off-by: Bhupesh Sharma <bhupesh.sharma@st.com>
[Merged the association and control string descriptors]
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:21 +02:00
Bhupesh Sharma 609a0532a4 usb: gadget: uvc: Add fix for UVC compliance test suite assertion 6.3.90 failure
As per UVC compliance test specification's assertion number 6.3.90
related to 'Standard VS Isochronous Video Data Endpoint Descriptor Assertions',
the bits D3..2 of 'bmAttributes' field of Standard VS Isochronous Video Data
Endpoint Descriptor should be 01 (binary) to indicate that the
synchronization type is ASYNCHRONOUS.

This mandatory requirement has been captured in section 3.10.1.1 of the UVC
Video Class Specification version 1.1

This patch adds a fix for the same.

Signed-off-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:20 +02:00
Laurent Pinchart 0485ec0d3b usb: gadget: uvc: Configure the streaming endpoint based on the speed
Call the appropriate usb_ep_autoconf*() function depending on the device
speed, and pass it the corresponding streaming endpoint.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:20 +02:00
Laurent Pinchart 20777dde02 usb: gadget: uvc: Merge the streaming maxpacket and mult parameters
Compute the multiplier from the maximum packet size based on the speed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:19 +02:00
Laurent Pinchart 48eee0b41a usb: gadget: uvc: Merge the SS/HS/FS control endpoint descriptors
The descriptors are identical, there's no need to have several copies of
them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:18 +02:00
Laurent Pinchart ee6a4d870b usb: gadget: uvc: Fix coding style issues introduced by SS support
Let's keep the code consistent, people might want to read it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:18 +02:00
Laurent Pinchart 912ca429fc usb: gadget: uvc: Rename STATUS_BYTECOUNT to UVC_STATUS_MAX_PACKET_SIZE
Descriptive names make the code more readable.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:17 +02:00
Laurent Pinchart f9e612002f usb: gadget: uvc: clarify comment about string descriptors
The comment that describes string descriptors allocation isn't clear,
fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:17 +02:00
Vivek Gautam ddb5147cea usb: dwc3: exynos: use clk_prepare_enable and clk_disable_unprepare
Convert clk_enable/clk_disable to clk_prepare_enable/clk_disable_unprepare
calls as required by common clock framework.

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
CC: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:16 +02:00
Vivek Gautam adcf20dcd2 usb: dwc3: exynos: Use of_platform API to create dwc3 core pdev
Used of_platform_populate() to create dwc3 core platform_device
from device tree data. Additionally some cleanup is also done.

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
CC: Felipe Balbi <balbi@ti.com>
CC: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:16 +02:00
Vivek Gautam b527675817 usb: phy: samsung: Add PHY support for USB 3.0 controller
Adding PHY driver support for USB 3.0 controller for Samsung's
SoCs.

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
Acked-by: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:15 +02:00
Vivek Gautam dc2377d0b0 usb: phy: samsung: Common out the generic stuff
Moving register and structure definitions to header file,
and keeping the generic functions to be used across
multiple PHYs in common phy helper driver under SAMSUNG_USBPHY,
and moving USB 2.0 PHY driver under SAMSUNG_USB2PHY.

Also allowing samsung PHY drivers be built as modules.

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
Acked-by: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:15 +02:00
Kishon Vijay Abraham I 2ba7943af0 usb: dwc3: dwc3-omap: return -EPROBE_DEFER if probe has not yet executed
return -EPROBE_DEFER from dwc3_omap_mailbox in dwc3-omap.c, if the probe of
dwc3-omap has not yet been executed or failed.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:14 +02:00
Kishon Vijay Abraham I ddff14f1ab usb: dwc3: set dma_mask for dwc3_omap device
*dma_mask* is not set for devices created from dt data. So filled dma_mask
for dwc3_omap device here. And dwc3 core will copy the dma_mask from its
parent.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:14 +02:00
George Cherian d4436c3a6e usb: dwc3: core: fix wrong OTG event regitser offset
This patch fixes the wrong OTG_EVT,OTG_EVTEN and OTG_STS register
offsets.

While at that, also add a missing register to debugfs regdump
utility.

Signed-off-by: George Cherian <george.cherian@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:13 +02:00
Felipe Balbi 40b8156f94 usb: renesas: remove unused DMA_ADDR_INVALID
DMA_ADDR_INVALID isn't used anymore, it's safe
to remove it.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:13 +02:00
Felipe Balbi 482ef1d2fe usb: gadget: uvc: remove references to DMA_ADDR_INVALID
gadget drivers shouldn't touch req->dma at all,
since UDC drivers are the ones required to handle
mapping and unmapping of the request buffer.

Remove references to DMA_ADDR_INVALID so we don't
creat false expectations to gadget driver writers.

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:12 +02:00
Felipe Balbi 853f97b5f3 usb: gadget: net2280: remove unused DMA_ADDR_INVALID
DMA_ADDR_INVALID isn't used anymore, it's safe
to remove it.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:12 +02:00
Felipe Balbi c36cbfc045 usb: gadget: net2272: remove unused DMA_ADDR_INVALID
DMA_ADDR_INVALID isn't used anymore, it's safe
to remove it.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:11 +02:00
Felipe Balbi 662e9469cb usb: gadget: atmel: remove unused DMA_ADDR_INVALID
DMA_ADDR_INVALID isn't (and shouldn't) be used
anymore, let's remove it.

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:11 +02:00
Chen Gang 38678f2568 usb: gadget: s3c-hsudc: delete outdated comment
since commit d93e260 (usb: gadget: s3c-hsudc: use udc_start and udc_stop
functions) the 'driver' parameter has been deleted from
s3c_hsudc_stop_activity() but its documentation was left outdated. This
patch deletes the comment since it makes no sense anymore.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:10 +02:00
Felipe Balbi c38a4f3f50 usb: phy: isp1301: implement PHY API
this patch implements ->init() and ->set_vbus()
methods for isp1301 transceiver driver.

Later patches can now come in order to remove
the hackery from ohci-nxp and lpc32xx udc drivers.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:10 +02:00
Felipe Balbi 790d3a5ab6 usb: phy: isp1301: give it a context structure
this patch is a small preparation to fix
isp1301 driver so that other platforms can
use it.

We're defining our private data structure
to represent this device and adding the
PHY to the PHY list.

Later patches will come implementing proper
PHY API and removing bogus code from ohci_nxp
and lpc32xx_udc drivers.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:09 +02:00
Felipe Balbi 94ae98433a usb: phy: rename all phy drivers to phy-$name-usb.c
this will make sure that we have sensible names
for all phy drivers. Current situation was already
quite bad with too generic names being used.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:08 +02:00
Felipe Balbi fd89149875 usb: phy: remove CONFIG_USB_OTG_UTILS
there are no more users of CONFIG_USB_OTG_UTILS
left in tree, we can remove it just fine.

[ kishon@ti.com : fixed a linking error due
	to original patch forgetting to change
	drivers/usb/Makefile ]

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:08 +02:00
Felipe Balbi a948712d2a usb: ehci: tegra: check against CONFIG_USB_PHY
CONFIG_USB_OTG_UTILS will be removed very
soon, so we should check CONFIG_USB_PHY
instead.

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:07 +02:00
Felipe Balbi fcd12b9711 usb: ehci: marvel: check against CONFIG_USB_PHY
CONFIG_USB_OTG_UTILS will be removed very
soon, so we should check CONFIG_USB_PHY
instead.

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:06 +02:00
Felipe Balbi 1d3dbfc3a7 usb: gadget: mv_udc_core: check against CONFIG_USB_PHY
CONFIG_USB_OTG_UTILS will be removed very
soon, so we should check CONFIG_USB_PHY
instead.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:06 +02:00
Felipe Balbi edc7cb2e95 usb: phy: make it a menuconfig
We already have a considerable amount of USB
PHY drivers, making it a menuconfig just
prevents us from adding too much churn to
USB's menuconfig.

While at that, also select USB_OTG_UTILS from
this new menuconfig just to keep backwards
compatibility until we manage to remove
that symbol.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:05 +02:00
Felipe Balbi a0e631235a usb: phy: move all PHY drivers to drivers/usb/phy/
that's a much more reasonable location for
those drivers. It helps us saving drivers/usb/otg/
for when we actually start adding generic OTG
code.

Also completely delete drivers/usb/otg/ as there's
nothing left there.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:04 +02:00
Felipe Balbi 110ff6d041 usb: phy: convert EXPORT_SYMBOL to EXPORT_SYMBOL_GPL
we only want GPL users for our generic functions,
so let's switch over to EXPORT_SYMBOL_GPL.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:04 +02:00
Felipe Balbi 7009bdd7f3 usb: otg: move usb_otg_state_string to usb-common.c
otg.c only had a single function definition
which might make more sense to be placed in
usb-common.c. While doing that, we also delete
otg.c since it's now empty.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:03 +02:00
Felipe Balbi 42c0bf1ce7 usb: otg: prefix otg_state_string with usb_
all other functions under drivers/usb/ start
with usb_, let's do the same thing.

This patch is in preparation for moving otg_state_string
to usb-common.c and deleting otg.c completely.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-03-18 11:18:03 +02:00