safe/jmp/linux-2.6
14 years agoUSB: OMAP: ISP1301: Compile fix
Anand Gadiyar [Mon, 24 Aug 2009 14:44:45 +0000 (20:14 +0530)]
USB: OMAP: ISP1301: Compile fix

OMAP: ISP1301: Compile fix

Fix this build error on non- OMAP-H2/H3/H4 systems:
(factored out two empty functions as part of the fix)

  CC      drivers/usb/otg/isp1301_omap.o
drivers/usb/otg/isp1301_omap.c: In function 'otg_update_isp':
drivers/usb/otg/isp1301_omap.c:635: error: implicit declaration of function 'notresponding'
drivers/usb/otg/isp1301_omap.c: In function 'b_peripheral':
drivers/usb/otg/isp1301_omap.c:973: error: implicit declaration of function 'enable_vbus_draw'
drivers/usb/otg/isp1301_omap.c: In function 'isp_update_otg':
drivers/usb/otg/isp1301_omap.c:1003: error: implicit declaration of function 'enable_vbus_source'
make[2]: *** [drivers/usb/otg/isp1301_omap.o] Error 1
make[1]: *** [drivers/usb/otg] Error 2
make: *** [drivers] Error 2

Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: gadget: double free_irq() in at91udc_probe()
Roel Kluin [Mon, 24 Aug 2009 16:27:23 +0000 (18:27 +0200)]
USB: gadget: double free_irq() in at91udc_probe()

If request_irq() fails, udp_irq is freed twice.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Clean up root hub string descriptors
George Spelvin [Tue, 25 Aug 2009 02:06:41 +0000 (22:06 -0400)]
USB: Clean up root hub string descriptors

The previous code had a bug that would add a trailing null byte to
the returned descriptor.

Signed-off-by: George Spelvin <linux@horizon.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: double put_tty_driver(gs_tty_driver) in gserial_setup()
Roel Kluin [Tue, 25 Aug 2009 08:26:57 +0000 (10:26 +0200)]
USB: double put_tty_driver(gs_tty_driver) in gserial_setup()

If the driver cannot be registered, put_tty_driver(gs_tty_driver)
occurred here as well as at label fail.

put_tty_driver() already occurs at label fail

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: make usb_buffer_map_sg consistent with doc
Jiri Slaby [Sat, 22 Aug 2009 18:24:49 +0000 (20:24 +0200)]
USB: make usb_buffer_map_sg consistent with doc

usb_buffer_map_sg should return negative on error according to
its documentation. But dma_map_sg returns 0 on error. Take this
into account and return -ENOMEM in such situation.

While at it, return -EINVAL instead of -1 when wrong input is
passed in.

If this wasn't done, usb_sg_* operations used after usb_sg_init
which returned 0 may cause oopses/deadlocks since we don't init
structures/entries, esp. completion and status entry.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: EHCI: change deschedule logic for interrupt QHs
Alan Stern [Wed, 19 Aug 2009 16:22:44 +0000 (12:22 -0400)]
USB: EHCI: change deschedule logic for interrupt QHs

This patch (as1281) changes the way ehci-hcd deschedules interrupt
QHs, copying the approach used for async QHs.  The caller is no longer
responsible for rescheduling the QH if its queue is non-empty; instead
the reschedule is done directly by intr_deschedule(), after calling
qh_completions().  This is exactly the same as how end_unlink_async()
works.

ehci_urb_dequeue() and intr_deschedule() now correctly handle the case
where they are called while another interrupt URB for the same QH is
being given back.  This was a surprisingly large blind spot.  And
scan_periodic() now respects the new needs_rescan flag.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: EHCI: rescan the queue after an unlink
Alan Stern [Wed, 19 Aug 2009 16:22:06 +0000 (12:22 -0400)]
USB: EHCI: rescan the queue after an unlink

This patch (as1280) fixes an obscure bug in ehci-hcd's dequeuing logic
for async URBs.  If a later URB is unlinked and the completion
routine unlinks an earlier URB, then the earlier URB won't be given
back in a timely manner because the endpoint queue isn't rescanned as
it should be.

Similar bugs occur if an endpoint is reset or a halt is cleared while
a completion routine is running, because the subroutines don't test
for the COMPLETING state.

All these problems are solved by adding a new needs_rescan flag to the
ehci_qh structure.  If the flag is set while scanning through an idle
QH, the scan will be repeated.  If the QH isn't idle then an unlink
cycle will be initiated, and the proper action will be taken when it
becomes idle.

Also, an unnecessary test is removed from qh_link_async(): That
routine is never called if the QH's state isn't IDLE.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: fsl_qe_udc: Add fsl,mpc8323-qe-usb compatible entry
Anton Vorontsov [Tue, 18 Aug 2009 22:23:35 +0000 (02:23 +0400)]
USB: fsl_qe_udc: Add fsl,mpc8323-qe-usb compatible entry

Current bindings specify that "fsl,mpc8323-qe-usb" compatible entry
should be used as a base match for QE UDCs, so update the driver to
comply with the bindings.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB-serial: pl2303: use 1.5 instead of 2 stop bits with 5 data bits
Frank Schaefer [Tue, 18 Aug 2009 18:34:24 +0000 (20:34 +0200)]
USB-serial: pl2303: use 1.5 instead of 2 stop bits with 5 data bits

This is how "real" UARTs (e.g. 16550) work and AFAIK what RS232 specifies, too.
Make the driver more compliant.

Signed-off-by: Frank Schaefer <schaefer.frank@gmx.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB-serial: pl2303: add space/mark parity
Frank Schaefer [Tue, 18 Aug 2009 18:31:11 +0000 (20:31 +0200)]
USB-serial: pl2303: add space/mark parity

The device supports it, so why not use it ? Works fine !

Signed-off-by: Frank Schaefer <schaefer.frank@gmx.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB-serial: pl2303: fix baud rate handling in case of unsupported values
Frank Schaefer [Tue, 18 Aug 2009 18:15:07 +0000 (20:15 +0200)]
USB-serial: pl2303: fix baud rate handling in case of unsupported values

According to the datasheets, the PL2303 supports a set of 25 baudrates.
The baudrate is set as a 4 byte value directly.

During my experiments with device 067b:2303 (PL2303X), I noticed that
 - the bridge-controller always uses 9600 baud if invalid/unsupported baud rate
   values are set
 - the baud rate value returned by usb_control_msg(..., GET_LINE_REQUEST, ...)
   does not reflect the actually used baudrate. Always the last set value is
   returned, even if it was invalid and not used by the controller.

This patch fixes the following issues with the current code:
1.) make sure that only supported baudrates are set (are there any buggy
    chip revisions out there which don't "like" other values... ?).
2.) always set the baudrate to the next nearest supported baudrate.
3.) applications can now read back the resulting baudrate properly, because
    tty_encode_baud_rate(...) is now fed with the actually used baudrate.

Signed-off-by: Frank Schaefer <schaefer.frank@gmx.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: iuu_phoenix: add a way to select the default VCC
Olivier Bornet [Tue, 18 Aug 2009 19:05:57 +0000 (21:05 +0200)]
USB: iuu_phoenix: add a way to select the default VCC

Using the module parameter vcc_default, you can choose the default VCC value.

Signed-off-by: Olivier Bornet <Olivier.Bornet@puck.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: iuu_phoenix: increment version number
Olivier Bornet [Tue, 18 Aug 2009 19:05:56 +0000 (21:05 +0200)]
USB: iuu_phoenix: increment version number

Signed-off-by: Olivier Bornet <Olivier.Bornet@puck.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: iuu_phoenix: add support for changing VCC
Olivier Bornet [Tue, 18 Aug 2009 19:05:55 +0000 (21:05 +0200)]
USB: iuu_phoenix: add support for changing VCC

You can now set the IUU reader to 3.3V VCC instead of 5V VCC, using the sysfs
parameter vcc_mode. Valid values are 3 and 5.

Signed-off-by: Olivier Bornet <Olivier.Bornet@puck.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: iuu_phoenix: clean-up parameter's descriptions
Olivier Bornet [Tue, 18 Aug 2009 19:05:54 +0000 (21:05 +0200)]
USB: iuu_phoenix: clean-up parameter's descriptions

Signed-off-by: Olivier Bornet <Olivier.Bornet@puck.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: iuu_phoenix: Don't reset the device at close
Olivier Bornet [Tue, 18 Aug 2009 19:05:53 +0000 (21:05 +0200)]
USB: iuu_phoenix: Don't reset the device at close

Resetting the device cause the device to have a new name in the /dev.

Signed-off-by: Olivier Bornet <Olivier.Bornet@puck.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usbtmc: correct termination condition for reads.
Steve Holland [Thu, 18 Jun 2009 22:37:49 +0000 (17:37 -0500)]
USB: usbtmc: correct termination condition for reads.

Follow T&M convention of obeying EOM flag.  Avoid exception cases where
instrument response size matches a buffer size.

Signed-off-by: Steve Holland <sdh4@iastate.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usbtmc: inhibit corruption
Steve Holland [Thu, 18 Jun 2009 22:37:49 +0000 (17:37 -0500)]
USB: usbtmc: inhibit corruption

Limit data copied to userspace to amount requested.  Prevents a faulty
instrument from overwriting user memory.

Signed-off-by: Steve Holland <sdh4@iastate.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usbtmc: Fix short reads in usbtmc_read()
Steve Holland [Thu, 18 Jun 2009 22:37:49 +0000 (17:37 -0500)]
USB: usbtmc: Fix short reads in usbtmc_read()

The header size should not be included in the number of bytes requested of the
instrument

Signed-off-by: Steve Holland <sdh4@iastate.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSb: Break support for WinChipHead CH341 340 USB->Serial "chip"
Tim Small [Mon, 17 Aug 2009 12:21:57 +0000 (13:21 +0100)]
USb: Break support for WinChipHead CH341 340 USB->Serial "chip"

Here is a patch to the ch341 driver which adds serial break support.

Signed-off-by: Tim Small <tim@seoss.co.uk>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: s3c2410: unregister should call unbind, not disconnect
Alan Stern [Mon, 3 Aug 2009 15:05:59 +0000 (11:05 -0400)]
USB: s3c2410: unregister should call unbind, not disconnect

This patch (as1275) fixes the s3c2410 device controller driver.  Its
usb_gadget_unregister_driver() routine is supposed to call the gadget
driver's unbind method, not the disconnect method.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: gadget: Add EEM gadget driver
Brian Niebuhr [Fri, 14 Aug 2009 15:04:22 +0000 (10:04 -0500)]
USB: gadget: Add EEM gadget driver

This patch adds a CDC EEM ethernet gadget driver.  CDC EEM is a newer
USB ethernet specification that uses a simpler interface than the older
CDC ECM.  This makes CDC EEM usable by a wider set of USB hardware.
By default the ethernet gadget will still use CDC ECM/Subset, but kernel
configuration and/or a module parameter will allow alternative use of
the CDC EEM protocol.

Changes since last version:
- Brought in missing RNDIS changes that caused compile error
- Modified 'sentinel CRC' checking to match EEM host driver

Signed-off-by: Brian Niebuhr <bniebuhr@efjohnson.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: remove unneeded printks from microtek driver
Oliver Neukum [Tue, 18 Aug 2009 14:17:45 +0000 (16:17 +0200)]
USB: remove unneeded printks from microtek driver

These printks can be removed as they only provide information
about the driver not the device and nobody has ever provided
feedback.

Signed-off-by: Oliver Neukum <oliver@neukum.org>
14 years agoUSB: use kfifo to buffer usb-generic serial writes
David VomLehn [Fri, 28 Aug 2009 19:54:27 +0000 (12:54 -0700)]
USB: use kfifo to buffer usb-generic serial writes

When do_output_char() attempts to write a carriage return/line feed sequence,
it first checks to see how much buffer room is available. If there are at least
two characters free, it will write the carriage return/line feed with two calls
to tty_put_char(). It calls the tty_operation functions write() for devices that
don't support the tty_operations function put_char(). If the USB generic serial
device's write URB is not in use, it will return the buffer size when asked how
much room is available. The write() of the carriage return will cause it to mark
the write URB busy, so the subsequent write() of the line feed will be ignored.

This patch uses the kfifo infrastructure to implement a write FIFO that
accurately returns the amount of space available in the buffer.

Signed-off-by: David VomLehn <dvomlehn@cisco.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: ohci-ep93xx.c: remove unused variable
H Hartley Sweeten [Thu, 13 Aug 2009 17:18:02 +0000 (13:18 -0400)]
USB: ohci-ep93xx.c: remove unused variable

Remove unused variable in ohci-ep93xx.c.

This only shows up when CONFIG_PM is enabled.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Lennert Buytenhek <kernel@wantstofly.org>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: otg: fix twl4030-usb build
Randy Dunlap [Tue, 11 Aug 2009 18:31:31 +0000 (11:31 -0700)]
USB: otg: fix twl4030-usb build

subsys_initcall_sync() is only defined for built-in code, not for
loadable modules, so this driver build fails when built as a module.
However, the _sync() forms of the initcalls are not implemented,
so this should not be used -- just use the non-sync form of it.

drivers/usb/otg/twl4030-usb.c:777: warning: data definition has no type or storage class
drivers/usb/otg/twl4030-usb.c:777: warning: type defaults to 'int' in declaration of 'subsys_initcall_sync'
drivers/usb/otg/twl4030-usb.c:777: warning: parameter names (without types) in function declaration

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Felipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Fix CDC EEM host driver 'sentinel' CRC validation
Brian Niebuhr [Mon, 10 Aug 2009 21:46:59 +0000 (16:46 -0500)]
USB: Fix CDC EEM host driver 'sentinel' CRC validation

This is an alternate solution to the EEM 'sentinel' CRC valiation issue.

CDC EEM allows using a 'sentinel' ethernet frame CRC of 0xdeadbeef in
place of a real CRC.  The 'sentinel' value is transmitted in big-endian
order whereas the normal CRC is little-endian.  This patch handles both
cases appropriately.

Signed-off-by: Brian Niebuhr <bniebuhr@efjohnson.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: gadget: Update Freescale UDC entry in MAINTAINERS
Li Yang [Tue, 11 Aug 2009 03:11:11 +0000 (11:11 +0800)]
USB: gadget: Update Freescale UDC entry in MAINTAINERS

Change the F entry for file rename, and make it also cover fsl_qe_udc
driver.  Update the name accordingly.

Signed-off-by: Li Yang <leoli@freescale.com>
Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: isp1362: Correct use of ! and &
Julia Lawall [Wed, 12 Aug 2009 14:51:09 +0000 (16:51 +0200)]
USB: isp1362: Correct use of ! and &

Correct priority problem in the use of ! and &.

The semantic patch that makes this change is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@ expression E; constant C; @@
- !E & C
+ !(E & C)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: EHCI: ensure all watchdog timer events are deleted when suspending usb
Jon Hunter [Wed, 12 Aug 2009 15:57:59 +0000 (11:57 -0400)]
USB: EHCI: ensure all watchdog timer events are deleted when suspending usb

This patch was previously discussed in the following thread:
http://thread.gmane.org/gmane.linux.usb.general/19472/focus=19484

On the OMAP3 device the usbhost controller is in a separate internal
power-domain. So when the usbhost is inactive or suspend is called,
we can disable clocks and power-down the usbhost to save power.

Recently we found that after calling ehci_bus_suspend() and disabling
the usbhost clocks we would see the ehci watchdog timer event fire. This
was causing a kernel panic because the usbhost controllers clocks were
disabled and inside the watchdog timer function the clocks were not
being re-enabled, so when the ehci registers were accessed this resulted
in a CPU data-abort.

To avoid this panic, per recommendation from Alan Stern (see above thread), we
make sure any pending timer events (that may have been scheduled by calling
ehci_work within the ehci_bus_suspend() function) are deleted before returning.

Signed-off-by: Fei Yang <fei.yang@motorola.com>
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: otg: twl4030-usb.c: mark .init as subsys_initcall_sync
Ming Lei [Sat, 1 Aug 2009 12:39:57 +0000 (20:39 +0800)]
USB: otg: twl4030-usb.c: mark .init as subsys_initcall_sync

This patch fixes the .probe failure of twl4030_usb driver if
it is compiled into kernel.

Since twl4030_usb USB transceiver .probe depends on
twl4030-regulator, marking twl4030_usb_init as subsys_initcall_sync
can make it called after twl4030-regulator initialization is finished,
then twl4030_usb USB transceiver driver can be probed successfully.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: musb: fix put_device() call sequence
Ajay Kumar Gupta [Mon, 3 Aug 2009 06:13:40 +0000 (11:43 +0530)]
USB: musb: fix put_device() call sequence

Invoke put_device(musb->xceiv->dev) before musb_platform_exit()as
xceiv is getting unregistered in musb_platform_exit().

Fixes put_device() panic when module insert/removal is performed
multiple times.

Signed-off-by: Ajay Kumar Gupta <ajay.gupta@ti.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Work around BIOS bugs by quiescing USB controllers earlier
David Woodhouse [Mon, 3 Aug 2009 11:40:27 +0000 (12:40 +0100)]
USB: Work around BIOS bugs by quiescing USB controllers earlier

We are seeing a number of crashes in SMM, when VT-d is enabled while
'Legacy USB support' is enabled in various BIOSes.

The BIOS is supposed to indicate which addresses it uses for DMA in a
special ACPI table ("RMRR"), so that we can punch a hole for it when we
set up the IOMMU.

The problem is, as usual, that BIOS engineers are totally incompetent.
They write code which will crash if the DMA goes AWOL, and then they
either neglect to provide an RMRR table at all, or they put the wrong
addresses in it. And of course they don't do _any_ QA, since that would
take too much time away from their crack-smoking habit.

The real fix, of course, is for consumers to refuse to buy motherboards
which only have closed-source firmware available. If we had _open_
firmware, bugs like this would be easy to fix.

Since that's something I can only dream about, this patch implements an
alternative -- ensuring that the USB controllers are handed off from the
BIOS and quiesced _before_ the IOMMU is initialised. That would have
been a much better design than this RMRR nonsense in the first place, of
course. The bootloader has no business doing DMA after the OS has booted
anyway.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: increase usbdevfs max isoc buffer size
Markus Rechberger [Sun, 9 Aug 2009 19:23:34 +0000 (21:23 +0200)]
USB: increase usbdevfs max isoc buffer size

The current limit only allows isochronous transfers up to 32kbyte/urb,
updating this to 192 kbyte/urb improves the reliability of the
transfer. USB 2.0 transfer is possible with 32kbyte but increases the
chance of corrupted/incomplete data when the system is performing some
other tasks in the background.

http://www.spinics.net/lists/linux-usb/msg19955.html

Signed-off-by: Markus Rechberger <mrechberger@gmail.com>
Cc: Oliver Neukum <oliver@neukum.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: isp1362: fix pulldown register defines and conf logic
Ken MacLeod [Thu, 6 Aug 2009 19:18:27 +0000 (14:18 -0500)]
USB: isp1362: fix pulldown register defines and conf logic

HCHWCFG_PULLDOWN_DS2 and HCHWCFG_PULLDOWN_DS1 were swapped.  Incorrect
operator precedence in isp1362_hc_start() hid part of the problem.
This fixes a problem where Port 1 in Host mode fails to see disconnects.

Signed-Off-By: Ken MacLeod <ken@bitsko.slc.ut.us>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: gadget: audio driver seg-fault fix
Robin Callender [Sun, 2 Aug 2009 18:38:58 +0000 (11:38 -0700)]
USB: gadget: audio driver seg-fault fix

The included patch can be applied to the new usb gadget audio driver.

It addresses a seg-fault in uncovered in g_audio.ko.
The fault occurs in the function u_audio.c::gaudio_open_end_dev() when
device /dev/snd/pcmC0D0c (FILE_PCM_CAPTURE) is not present.

I suspect there may be similar problems with device /dev/snd/pcmC0D0p
(FILE_PCM_PLAYBACK) handling also.  I leave that for the developer(s),
as I was unsure as to the side-effects of not calling
playback_default_hw_params() in the initialization phase.

Signed-off-by: Robin Callender <robin_callender@hotmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: gadget: Read buffer overflow
Roel Kluin [Thu, 6 Aug 2009 23:09:51 +0000 (16:09 -0700)]
USB: gadget: Read buffer overflow

Check whether index is within bounds before testing the element.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usb-storage fails to attach to Huawei Datacard cdrom device
fangxiaozhi [Fri, 7 Aug 2009 04:30:35 +0000 (12:30 +0800)]
USB: usb-storage fails to attach to Huawei Datacard cdrom device

In this patch, we always make the return value of function
usb_stor_huawei_e220_init to be zero. Then it will not prevent usb-storage
driver from attaching to the CDROM device of Huawei Datacard.

Signed-off-by: fangxiaozhi <huananhu@huawei.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: ark3116: add IrDA support for Gembird UIR-22
Ondrej Zary [Thu, 6 Aug 2009 23:09:52 +0000 (16:09 -0700)]
USB: ark3116: add IrDA support for Gembird UIR-22

Add IrDA support to ark3116 driver.  This makes Gembird UIR-22 USB to IrDA
adapter work (vendor ID 0x18ec, device ID 0x3118).  This adapter contains
ARK3116T USB serial chip and an IrDA transceiver, thus a command like
"irattach /dev/ttyUSB0 -s" is needed.

All magic numbers were captured using usbsnoop from windows driver that
came with the device.

Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: ohci-pxa27x: Allow NOCP and OCPM to be cleared
Aric Blumer [Thu, 30 Jul 2009 17:26:58 +0000 (13:26 -0400)]
USB: ohci-pxa27x: Allow NOCP and OCPM to be cleared

Some ohci-pxa27x platforms may require OCPM and NOCP in UHCRHDA to be
clear, but the existing code was only allowing setting.  This patch
ensures that these bits are clear if the respective flags are not set.
This is particularly important for the PXA3xx family where the
documentation says OCPM must be cleared, but it is set after reset.

Signed-off-by: Aric Blumer <aric@sdgsystems.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: EHCI: OHCI: Remove unnecessary includes of reboot.h
Anand Gadiyar [Tue, 28 Jul 2009 18:22:21 +0000 (23:52 +0530)]
USB: EHCI: OHCI: Remove unnecessary includes of reboot.h

EHCI: OHCI: Remove unnecessary includes of reboot.h

Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: audio: guard kernel-only code with __KERNEL__
Michael S. Tsirkin [Wed, 29 Jul 2009 11:23:25 +0000 (14:23 +0300)]
USB: audio: guard kernel-only code with __KERNEL__

include/linux/usb/audio.h is exported to userspace,
so part of this file that is for internal kernel
usage need to be guarded with ifdef __KERNEL__.
This way make headers_install will stript it out.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: at91: modify OHCI driver to allow shared interrupts
Nicolas Ferre [Mon, 27 Jul 2009 21:59:24 +0000 (14:59 -0700)]
USB: at91: modify OHCI driver to allow shared interrupts

At91sam9g45 series has a set of high speed USB interfaces.
The host driver is an EHCI with its companion OHCI. OHCI is
always handled by ohci-at91.c.
This wrapper is just modified to allow IRQ sharing
between two controllers.

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: at91: Add USB gadget driver selection for at91sam9g45 series
Nicolas Ferre [Mon, 27 Jul 2009 22:00:35 +0000 (15:00 -0700)]
USB: at91: Add USB gadget driver selection for at91sam9g45 series

Add gadget USB drivers for at91sam9g45 series. Those SOC include
high speed USB interfaces.
The gadget driver is the already available atmel_usba_udc.

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: at91: Add USB EHCI driver for at91sam9g45 series
Nicolas Ferre [Mon, 27 Jul 2009 21:47:40 +0000 (14:47 -0700)]
USB: at91: Add USB EHCI driver for at91sam9g45 series

Add host USB High speed driver for at91sam9g45 series.
The host driver is an EHCI with its companion OHCI. EHCI is
handled by the new ehci-atmel.c whereas the OHCI is always
handled by ohci-at91.c.

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
14 years agoUSB: uhci: rm repeatedly evaluation for urbp->qh
Bob Liu [Tue, 28 Jul 2009 14:31:06 +0000 (22:31 +0800)]
USB: uhci: rm repeatedly evaluation for urbp->qh

Signed-off-by: Bob Liu <yjfpb04@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usbtmc: fix printk format warnings
Randy Dunlap [Tue, 28 Jul 2009 18:22:41 +0000 (11:22 -0700)]
USB: usbtmc: fix printk format warnings

Fix printk format warnings:
drivers/usb/class/usbtmc.c:466: warning: format '%zu' expects type 'size_t', but argument 4 has type 'u32'
drivers/usb/class/usbtmc.c:466: warning: format '%zu' expects type 'size_t', but argument 5 has type 'int'

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usbtmc: sanity checks for DEV_DEP_MSG_IN urbs
Guus Sliepen [Wed, 22 Jul 2009 15:39:42 +0000 (17:39 +0200)]
USB: usbtmc: sanity checks for DEV_DEP_MSG_IN urbs

According to the specifications, an instrument should not return more data in a
DEV_DEP_MSG_IN urb than requested.  However, some instruments can send more
than requested. This could cause the kernel to write the extra data past the
end of the buffer provided by read().

Fix this by checking that the value of the TranserSize field is not larger than
the urb itself and not larger than the size of the userspace buffer. Also
correctly decrement the remaining size of the buffer when userspace read()s
more than USBTMC_SIZE_IOBUFFER.

Signed-off-by: Guus Sliepen <guus@sliepen.org>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: NXP ISP1362 USB host driver
Lothar Wassmann [Fri, 17 Jul 2009 00:51:21 +0000 (20:51 -0400)]
USB: NXP ISP1362 USB host driver

Signed-off-by: Lothar Wassmann <LW@KARO-electronics.de>
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: dummy-hcd: accept mismatch between wLength and transfer length
Alan Stern [Wed, 22 Jul 2009 18:44:17 +0000 (14:44 -0400)]
USB: dummy-hcd: accept mismatch between wLength and transfer length

This patch (as1269) fixes a bug in the way dummy_hcd handles control
URBs.  Currently it returns a -EOVERFLOW error if the wLength value in
the setup packet is different from the URB's transfer_buffer_length.

Other host controller drivers don't do this.  There's no reason the
two length values have to be equal, and in fact they sometimes aren't
-- a driver might set the transfer length to the maxpacket value in
order to handle buggy devices that don't respect wLength.

This patch simply removes the unnecessary check and error return.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: don't lose mode switch events on suspended devices
Alan Stern [Wed, 22 Jul 2009 18:42:54 +0000 (14:42 -0400)]
USB: don't lose mode switch events on suspended devices

This patch (as1268) changes the way usbcore handles child devices that
undergo a disconnection and reconnection while the parent hub is
suspended.  Currently, if the child isn't enabled for remote wakeup we
leave it alone, figuring that it will go through a reset-resume when
somebody tries to use it.

However this isn't a good approach if the reason for the disconnection
is that the child decided to switch modes or in some other way alter
its descriptors.  In that case we want to re-enumerate it as soon as
possible, not wait until somebody forces a reset-resume.

To resolve the issue, this patch treats reconnected suspended child
devices as though they had requested a remote wakeup, even if they
weren't enabled for it.  The mode switch or descriptor change will be
detected during the reset part of the reset-resume, and the device
will be re-enumerated immediately.

The disadvantage of this change is that it will cause autosuspended
devices to be resumed when the computer wakes up from a system sleep
during which the root hub was reset or lost power.  This shouldn't
matter much; some people would even argue that autosuspended devices
should _always_ be resumed when the system wakes up!

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: "Yang Fei-AFY095" <fei.yang@motorola.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: check for hub driver not bound to root hub device
Alan Stern [Wed, 22 Jul 2009 18:41:18 +0000 (14:41 -0400)]
USB: check for hub driver not bound to root hub device

This patch (as1267) changes usb_kick_khubd() and hdev_to_hub() to make
them more resilient against situations where a hub device isn't bound
to the hub driver.  The code assumes that if a root hub was
successfully registered then it must be bound to the hub driver.

But this assumption can fail if the user manually unbinds the hub
driver, or more importantly, if the host controller dies causing
usb_set_configuration to fail.

To protect against these possibilities, make hdev_to_hub() check that
the hub device is configured before dereferencing the active
configuration, and make usb_kick_khubd() check that the pointer to the
hub's private data structure isn't NULL.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: fix wrong order of events in usb serial suspension
Oliver Neukum [Tue, 21 Jul 2009 06:47:34 +0000 (08:47 +0200)]
USB: fix wrong order of events in usb serial suspension

if a subdriver has an additional suspend method, it must be called
first to allow the subdriver to return -EBUSY, because the second
half cannot be easily undone.

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: au1xxx: add dev_pm_ops
Manuel Lauss [Wed, 29 Jul 2009 17:13:13 +0000 (19:13 +0200)]
USB: au1xxx: add dev_pm_ops

move both ohci-au1xxx and ehci-au1xxx over to dev_pm_ops.

Tested on Au1200.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: storage: Drop an unneeded a NULL test
Julia Lawall [Sun, 19 Jul 2009 15:29:57 +0000 (17:29 +0200)]
USB: storage: Drop an unneeded a NULL test

In each case, the NULL test is not necessary because the function is static
and at the only places where it is called, the us argument has already been
dereferenced.

The semantic patch that finds the problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
type T;
expression E,E1;
identifier i,fld;
statement S;
@@

- T i = E->fld;
+ T i;
  ... when != E=E1
      when != i
  if (E == NULL||...) S
+ i = E->fld;
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Cc: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: serial: Spelling correction in Motorola USB Phone driver
Maxin John [Mon, 20 Jul 2009 09:46:42 +0000 (15:16 +0530)]
USB: serial: Spelling correction in Motorola USB Phone driver

Spelling correction in Motorola USB Phone driver

Changed: * Mororola should be using the CDC ACM USB spec, but instead
To: * Motorola should be using the CDC ACM USB spec, but instead

Signed-off-by: Maxin B. John <maxinbjohn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: isp1760: allow platform devices to customize devflags
Michael Hennerich [Thu, 16 Jul 2009 03:22:54 +0000 (23:22 -0400)]
USB: isp1760: allow platform devices to customize devflags

Platform device support was merged earlier, but support for boards to
customize the devflags aspect of the controller was not.  We want this on
Blackfin systems to control the bus width, but might as well expose all of
the fields while we're at it.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: EHCI: Add Intel Moorestown EHCI controller HOSTPCx extensions and support phy...
Alek Du [Mon, 13 Jul 2009 04:41:20 +0000 (12:41 +0800)]
USB: EHCI: Add Intel Moorestown EHCI controller HOSTPCx extensions and support phy low power mode

The Intel Moorestown EHCI controller supports non-standard HOSTPCx register
extension. This register controls the LPM behaviour and controls the behaviour
of each USB port.

Signed-off-by: Jacob Pan <jacob.jun.pan@intel.com>
Signed-off-by: Alek Du <alek.du@intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: EHCI: split ehci_qh into hw and sw parts
Alek Du [Mon, 13 Jul 2009 23:23:29 +0000 (07:23 +0800)]
USB: EHCI: split ehci_qh into hw and sw parts

The ehci_qh structure merged hw and sw together which is not good:
1. More and more items are being added into ehci_qh, the ehci_qh software
   part are unnecessary to be allocated in DMA qh_pool.
2. If HCD has local SRAM, the sw part will consume it too, and it won't
   bring any benefit.
3. For non-cache-coherence system, the entire ehci_qh is uncachable, actually
   we only need the hw part to be uncacheable. Spliting them will let the sw
   part to be cacheable.

Signed-off-by: Alek Du <alek.du@intel.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
CC: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: EHCI: add need_io_watchdog flag to ehci_hcd
Alek Du [Mon, 13 Jul 2009 09:30:41 +0000 (17:30 +0800)]
USB: EHCI: add need_io_watchdog flag to ehci_hcd

Basically the io watchdog is only useful for those quirk HCDs. For most
good ones, it only brings unnecessary wakeups.  At least, I know the
Intel EHCI HCDs should turn off the flag.

Signed-off-by: Alek Du <alek.du@intel.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: full autosuspend and power management support for usbsevseg
Oliver Neukum [Mon, 13 Jul 2009 14:45:47 +0000 (16:45 +0200)]
USB: full autosuspend and power management support for usbsevseg

This patch adds to the usbsevseg driver:

- suspend/resume support
- reset_resume support
- autosuspend using the display's power state to determine idleness

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Harrison Metzger <harrisonmetz@gmail.com>
14 years agoUSB: full power management support for the idmouse driver
Oliver Neukum [Sun, 12 Jul 2009 21:58:23 +0000 (23:58 +0200)]
USB: full power management support for the idmouse driver

usb: full runtime PM support for idmouse driver

- add suspend/resume support
- add reset_resume support
- add support for autosuspend

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Tested-by: Andreas Deresch <aderesch@fs.tum.de>
14 years agoUSB: gadget: s3c-hsotg: missing parentheses
Roel Kluin [Wed, 15 Jul 2009 18:12:30 +0000 (20:12 +0200)]
USB: gadget: s3c-hsotg: missing parentheses

Add missing parentheses

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
CC: Ben Dooks <ben@simtec.co.uk>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: gadget: Drop NULL test on list_entry result
Julia Lawall [Sun, 12 Jul 2009 07:43:52 +0000 (09:43 +0200)]
USB: gadget: Drop NULL test on list_entry result

list_entry, which is an alias for container_of, cannot return NULL, as
there is no way to add a NULL value to a doubly linked list.

A simplified version of the semantic match that findds this problem is as
follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r@
expression x,E;
statement S1,S2;
position p,p1;
@@

*x = list_entry@p(...)
... when != x = E
*if@p1 (x == NULL) S1 else S2
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: ldusb should signal an error in poll if the device is disconnected
Oliver Neukum [Thu, 2 Jul 2009 15:01:06 +0000 (17:01 +0200)]
USB: ldusb should signal an error in poll if the device is disconnected

poll() should test for a disconnection of the device.

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: legousbtower: make poll notice disconnect
Oliver Neukum [Thu, 2 Jul 2009 10:07:07 +0000 (12:07 +0200)]
USB: legousbtower: make poll notice disconnect

poll needs to return an error if a device is disconnected
  - make poll check for device's presence
  - wake all waiters in disconnect

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: suspend/resume support for usbtmc
Oliver Neukum [Thu, 2 Jul 2009 09:44:33 +0000 (11:44 +0200)]
USB: suspend/resume support for usbtmc

a class driver should have suspend/resume. This makes sure we
don't see a virtual disconnect unnecessarily.

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usbtmc can do IO to device after disconnect
Oliver Neukum [Thu, 2 Jul 2009 09:36:30 +0000 (11:36 +0200)]
USB: usbtmc can do IO to device after disconnect

usbtmc will happily complete read/write requests even after disconnect
has returned. The fix is to introduce a flag.

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usb-serial, remove unused variables
Jiri Slaby [Fri, 3 Jul 2009 21:09:41 +0000 (23:09 +0200)]
USB: usb-serial, remove unused variables

There are some unused variables in serial_do_down. Remove them.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: serial: full autosuspend support for the option driver
Oliver Neukum [Wed, 1 Jul 2009 14:00:32 +0000 (16:00 +0200)]
USB: serial: full autosuspend support for the option driver

this adds autosupport usable even in an always online mode.

- enables remote wakeup on open
- autoresume for sending
- timeout based autosuspend if nothing is sent or recieved
- autosuspend without remote wakeup support on open/close

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Tested-off-by: Zhao Ming <zhao.ming9@zte.com.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: gadget: pxa25x: basic transceiver support
Philipp Zabel [Wed, 1 Jul 2009 10:46:25 +0000 (03:46 -0700)]
USB: gadget: pxa25x: basic transceiver support

This adds very basic otg_transceiver support, with vbus_session
and vbus_draw callbacks.

Now VBUS sensing can be handled by an external driver which registers
the otg_transceiver interface. It also allows gadget drivers to configure
the current drawn from VBUS. The UDC driver just passes their requests
along to the transceiver driver.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: make the "usbfs_snoop" log more pertinent
Alan Stern [Mon, 29 Jun 2009 15:02:04 +0000 (11:02 -0400)]
USB: make the "usbfs_snoop" log more pertinent

This patch (as1261) reduces the amount of detailed URB information
logged by usbfs when the usbfs_snoop parameter is enabled.

Currently we don't display the final status value for a completed URB.
But we do display the entire data buffer twice: both before submission
and after completion.  The after-completion display doesn't limit
itself to the actual_length value.  But since usbmon is readily
available in virtually all distributions, there's no reason for usbfs
to print out any buffer contents at all!

So this patch restricts the information to: userspace buffer pointer,
endpoint number, type, and direction, length or actual_length, and
timeout value or status.  Now everything fits neatly into a single
line.

Along with those changes, the patch also fixes the snoop output for
the REAPURBNDELAY and REAPURBNDELAY32 ioctls.  The current version
omits the 'N' from the names.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: make intf.pm_usage an atomic_t
Alan Stern [Mon, 29 Jun 2009 15:00:01 +0000 (11:00 -0400)]
USB: make intf.pm_usage an atomic_t

This patch (as1260) changes the pm_usage_cnt field in struct
usb_interface from an int to an atomic_t.  This is so that drivers can
invoke the usb_autopm_get_interface_async() and
usb_autopm_put_interface_async() routines without locking and without
fear of corrupting the pm_usage_cnt value.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: add API for userspace drivers to "claim" ports
Alan Stern [Mon, 29 Jun 2009 14:56:54 +0000 (10:56 -0400)]
USB: add API for userspace drivers to "claim" ports

This patch (as1258) implements a feature that users have been asking
for: It gives programs the ability to "claim" a port on a hub, via a
new usbfs ioctl.  A device plugged into a "claimed" port will not be
touched by the kernel beyond the immediate necessities of
initialization and enumeration.

In particular, when a device is plugged into a "claimed" port, the
kernel will not select and install a configuration.  And when a config
is installed by usbfs or sysfs, the kernel will not probe any drivers
for any of the interfaces.  (However the kernel will fetch various
string descriptors during enumeration.  One could argue that this
isn't really necessary, but the strings are exported in sysfs.)

The patch does not guarantee exclusive access to these devices; it is
still possible for more than one program to open the device file
concurrently.  Programs are responsible for coordinating access among
themselves.

A demonstration program showing how to use the new interface can be
found in an attachment to

http://marc.info/?l=linux-usb&m=124345857431452&w=2

The patch also makes a small simplification to the hub driver,
replacing a bunch of more-or-less useless variants of "out of memory"
with a single message.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: whci-hcd: make endpoint_reset method async
David Vrabel [Wed, 24 Jun 2009 17:26:40 +0000 (18:26 +0100)]
USB: whci-hcd: make endpoint_reset method async

usb_hcd_endpoint_reset() may be called in atomic context and must not
sleep.  So make whci-hcd's endpoint_reset() asynchronous.  URBs
submitted while the reset is in progress will be queued (on the std
list) and transfers will resume once the reset is complete.

Signed-off-by: David Vrabel <david.vrabel@csr.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Add nuvoton Ehci driver for w90p910 platform
Wan ZongShun [Sat, 13 Jun 2009 01:14:28 +0000 (09:14 +0800)]
USB: Add nuvoton Ehci driver for w90p910 platform

Add ehci support for w90p910 platform.

Signed-off-by: Wan ZongShun <mcuos.com@gmail.com>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB audio gadget: Un-inline generic_[gs]et_cmd
Laurent Pinchart [Sun, 21 Jun 2009 21:21:55 +0000 (23:21 +0200)]
USB audio gadget: Un-inline generic_[gs]et_cmd

Those functions are used only used to fill the set/get members of
usb_audio_control. It doesn't make much sense to inline them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@skynet.be>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB audio gadget: Prefix all macro definitions with UAC_ in linux/usb/audio.h
Laurent Pinchart [Sun, 21 Jun 2009 21:23:05 +0000 (23:23 +0200)]
USB audio gadget: Prefix all macro definitions with UAC_ in linux/usb/audio.h

linux/usb/audio.h is a public header file that includes definitions
exported to userspace. To avoid namespace clashes, prefix all macro
definitions with UAC_. Existing macros and structures prefixed with
USB_AC_ and USB_AS_ are renamed for consistency.

Signed-off-by: Laurent Pinchart <laurent.pinchart@skynet.be>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Move vendor subclass definition from usb/audio.h to usb/ch9.h
Laurent Pinchart [Sun, 21 Jun 2009 21:20:39 +0000 (23:20 +0200)]
USB: Move vendor subclass definition from usb/audio.h to usb/ch9.h

USB_SUBCLASS_VENDOR_SPEC is common to several USB classes and as such belongs
to usb/ch9.h.

Signed-off-by: Laurent Pinchart <laurent.pinchart@skynet.be>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Move endpoint sync type definitions from usb/audio.h to usb/ch9.h
Laurent Pinchart [Sun, 21 Jun 2009 21:19:23 +0000 (23:19 +0200)]
USB: Move endpoint sync type definitions from usb/audio.h to usb/ch9.h

And use the new definitions in the USB Audio Class gadget driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart@skynet.be>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Let usb_sg_init to set transfer_buffer more often
Pete Zaitcev [Thu, 11 Jun 2009 14:40:39 +0000 (08:40 -0600)]
USB: Let usb_sg_init to set transfer_buffer more often

This fix permits the "new" usbmon to access usb-storage's data buffer
without DMA remapping tricks. It should be compatible with PIO controllers
and not add any new crashes. Note that from now on PIO controllers and
usbmon are uniform in their access pattern and if one crashes then
the other will too. Hopefuly neither does.

As a side effect, we get rid for #ifdefs, which were a little ugly.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usbmon: end ugly tricks with DMA peeking
Pete Zaitcev [Thu, 11 Jun 2009 14:53:20 +0000 (08:53 -0600)]
USB: usbmon: end ugly tricks with DMA peeking

This patch fixes crashes when usbmon attempts to access GART aperture.
The old code attempted to take a bus address and convert it into a
virtual address, which clearly was impossible on systems with actual
IOMMUs. Let us not persist in this foolishness, and use transfer_buffer
in all cases instead.

I think downsides are negligible. The ones I see are:
 - A driver may pass an address of one buffer down as transfer_buffer,
   and entirely different entity mapped for DMA, resulting in misleading
   output of usbmon. Note, however, that PIO based controllers would
   do transfer the same data that usbmon sees here.
 - Out of tree drivers may crash usbmon if they store garbage in
   transfer_buffer. I inspected the in-tree drivers, and clarified
   the documentation in comments.
 - Drivers that use get_user_pages will not be possible to monitor.
   I only found one driver with this problem (drivers/staging/rspiusb).
 - Same happens with with usb_storage transferring from highmem, but
   it works fine on 64-bit systems, so I think it's not a concern.
   At least we don't crash anymore.

Why didn't we do this in 2.6.10? That's because back in those days
it was popular not to fill in transfer_buffer, so almost all
traffic would be invisible (e.g. all of HID was like that).
But now, the tree is almost 100% PIO friendly, so we can do the
right thing at last.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usbmon: touch up the documentation
Pete Zaitcev [Wed, 10 Jun 2009 21:23:52 +0000 (15:23 -0600)]
USB: usbmon: touch up the documentation

I think this sentence was confusing regarding the possible size
of the data area.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usbmon: drop Kconfig defaults
Pete Zaitcev [Wed, 10 Jun 2009 21:21:24 +0000 (15:21 -0600)]
USB: usbmon: drop Kconfig defaults

These statements seem to be unnecessary. No idea why, but I built all
possible configurations and everything gets built just as before.

It's an old patch that popped from discussion with Paul in November 2008.
Obviously not a very high priority but better late than never.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: sisusbvga: drop usb_buffer_alloc
Pete Zaitcev [Wed, 10 Jun 2009 20:15:52 +0000 (14:15 -0600)]
USB: sisusbvga: drop usb_buffer_alloc

This patch falls out of my work to fix usbmon so it uses virtual addresses.
It is not necessary, the "new" usbmon should work just fine with sisusbvga.
However, it seems ridiculous that anyone would use uncached memory to
transfer bulk data. Dropping the unnecessary use of usb_buffer_alloc
should be beneficial here, in case anyone ever uses the dongle on
anything beyond x86.

I had no success in raising the author of the driver by e-mail, so
the patch is not actually tested.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: ehci-dbg.c: no need for checking it before call vfree
Figo.zhang [Sat, 6 Jun 2009 12:31:49 +0000 (20:31 +0800)]
USB: ehci-dbg.c: no need for checking it before call vfree

vfree() does it's own NULL checking,so no need for check before
calling it.

Signed-off-by: Figo.zhang <figo1802@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Fix SS endpoint companion descriptor parsing.
Sarah Sharp [Tue, 8 Sep 2009 20:20:16 +0000 (13:20 -0700)]
USB: Fix SS endpoint companion descriptor parsing.

When there's a descriptor after the SuperSpeed endpoint companion
descriptor, the previous code would have skipped over twice the length it
was supposed to.  This code fixes crashes seen with UASP devices (which
have a UASP descriptor after the SS endpoint companion descriptor).

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Support interrupt transfers.
Sarah Sharp [Wed, 2 Sep 2009 19:14:28 +0000 (12:14 -0700)]
USB: xhci: Support interrupt transfers.

Interrupt transfers are submitted to the xHCI hardware using the same TRB
type as bulk transfers.  Re-use the bulk transfer enqueueing code to
enqueue interrupt transfers.

Interrupt transfers are a bit different than bulk transfers.  When the
interrupt endpoint is to be serviced, the xHC will consume (at most) one
TD.  A TD (comprised of sg list entries) can take several service
intervals to transmit.  The important thing for device drivers to note is
that if they use the scatter gather interface to submit interrupt
requests, they will not get data sent from two different scatter gather
lists in the same service interval.

For now, the xHCI driver will use the service interval from the endpoint's
descriptor (bInterval).  Drivers will need a hook to poll at a more
frequent interval.  Set urb->interval to the interval that the xHCI
hardware will use.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Set -EREMOTEIO when xHC gives bad transfer length.
Sarah Sharp [Fri, 28 Aug 2009 21:28:18 +0000 (14:28 -0700)]
USB: xhci: Set -EREMOTEIO when xHC gives bad transfer length.

The xHCI hardware reports the number of bytes untransferred for a given
transfer buffer.  If the hardware reports a bytes untransferred value
greater than the submitted buffer size, we want to play it safe and say no
data was transferred.  If the driver considers a short packet to be an
error, remember to set -EREMOTEIO.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Check URB_SHORT_NOT_OK before setting short packet status.
Sarah Sharp [Fri, 28 Aug 2009 21:28:15 +0000 (14:28 -0700)]
USB: xhci: Check URB_SHORT_NOT_OK before setting short packet status.

Make sure that the driver that submitted the URB considers a short packet
an error before setting -EREMOTEIO during a short control transfer.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Check URB's actual transfer buffer size.
Sarah Sharp [Thu, 27 Aug 2009 21:36:24 +0000 (14:36 -0700)]
USB: xhci: Check URB's actual transfer buffer size.

Make sure that the amount of data the xHC says was transmitted is less
than or equal to the size of the requested transfer buffer.  Before, if
the host controller erroneously reported that the number of bytes
untransferred was bigger than the buffer in the URB, urb->actual_length
could be set to a very large size.

Make sure urb->actual_length <= urb->transfer_buffer_length.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Don't touch xhci_td after it's freed.
Sarah Sharp [Thu, 27 Aug 2009 21:36:14 +0000 (14:36 -0700)]
USB: xhci: Don't touch xhci_td after it's freed.

On a successful transfer, urb->td is freed before the URB is ready to be
given back to the driver.  Don't touch urb->td after it's freed.  This bug
would have only shown up when xHCI debugging was turned on, and the freed
memory was quickly reused for something else.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Handle babbling endpoints correctly.
Sarah Sharp [Thu, 27 Aug 2009 21:36:03 +0000 (14:36 -0700)]
USB: xhci: Handle babbling endpoints correctly.

The 0.95 xHCI spec says that non-control endpoints will be halted if a
babble is detected on a transfer.  The 0.96 xHCI spec says all types of
endpoints will be halted when a babble is detected.  Some hardware that
claims to be 0.95 compliant halts the control endpoint anyway.

When a babble is detected on a control endpoint, check the hardware's
output endpoint context to see if the endpoint is marked as halted.  If
the control endpoint is halted, a reset endpoint command must be issued
and the transfer ring dequeue pointer needs to be moved past the stopped
transfer.  Basically, we treat it as if the control endpoint had stalled.

Handle bulk babbling endpoints as if we got a completion event with a
stall completion code.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Make TRB completion code comparison readable.
Sarah Sharp [Thu, 27 Aug 2009 21:35:53 +0000 (14:35 -0700)]
USB: xhci: Make TRB completion code comparison readable.

Use trb_comp_code instead of getting the completion code from the transfer
event every time.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Add quirk for Fresco Logic xHCI hardware.
Sarah Sharp [Fri, 7 Aug 2009 21:04:55 +0000 (14:04 -0700)]
USB: xhci: Add quirk for Fresco Logic xHCI hardware.

This Fresco Logic xHCI host controller chip revision puts bad data into
the output endpoint context after a Reset Endpoint command.  It needs a
Configure Endpoint command (instead of a Set TR Dequeue Pointer command)
after the reset endpoint command.

Set up the input context before issuing the Reset Endpoint command so we
don't copy bad data from the output endpoint context.  The HW also can't
handle two commands queued at once, so submit the TRB for the Configure
Endpoint command in the event handler for the Reset Endpoint command.

Devices that stall on control endpoints before a configuration is selected
will not work under this Fresco Logic xHCI host controller revision.

This patch is for prototype hardware that will be given to other companies
for evaluation purposes only, and should not reach consumer hands.  Fresco
Logic's next chip rev should have this bug fixed.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Handle stalled control endpoints.
Sarah Sharp [Fri, 7 Aug 2009 21:04:52 +0000 (14:04 -0700)]
USB: xhci: Handle stalled control endpoints.

When a control endpoint stalls, the next control transfer will clear the
stall.  The USB core doesn't call down to the host controller driver's
endpoint_reset() method when control endpoints stall, so the xHCI driver
has to do all its stall handling for internal state in its interrupt handler.

When the host stalls on a control endpoint, it may stop on the data phase
or status phase of the control transfer.  Like other stalled endpoints,
the xHCI driver needs to queue a Reset Endpoint command and move the
hardware's control endpoint ring dequeue pointer past the failed control
transfer (with a Set TR Dequeue Pointer or a Configure Endpoint command).

Since the USB core doesn't call usb_hcd_reset_endpoint() for control
endpoints, we need to do this in interrupt context when we get notified of
the stalled transfer.  URBs may be queued to the hardware before these two
commands complete.  The endpoint queue will be restarted once both
commands complete.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Support full speed devices.
Sarah Sharp [Fri, 7 Aug 2009 21:04:49 +0000 (14:04 -0700)]
USB: xhci: Support full speed devices.

Full speed devices have varying max packet sizes (8, 16, 32, or 64) for
endpoint 0.  The xHCI hardware needs to know the real max packet size
that the USB core discovers after it fetches the first 8 bytes of the
device descriptor.

In order to fix this without adding a new hook to host controller drivers,
the xHCI driver looks for an updated max packet size for control
endpoints.  If it finds an updated size, it issues an evaluate context
command and waits for that command to finish.  This should only happen in
the initialization and device descriptor fetching steps in the khubd
thread, so blocking should be fine.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Set correct max packet size for HS/FS control endpoints.
Sarah Sharp [Fri, 7 Aug 2009 21:04:46 +0000 (14:04 -0700)]
USB: xhci: Set correct max packet size for HS/FS control endpoints.

Set the max packet size for the default control endpoint on high speed
devices to be 64 bytes.  High speed devices always have a max packet size
of 64 bytes.  There's no use setting it to eight for the initial 8 byte
descriptor fetch and then issuing (and waiting for) an evaluate context
command to update it to 64 bytes for the subsequent control transfers.

The USB core guesses that the max packet size on a full speed control
endpoint is 64 bytes, and then updates it after the first 8-byte
descriptor fetch.  Change the initial setup for the xHCI internal
representation of the full speed device to have a 64 byte max packet size.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Configure endpoint code refactoring.
Sarah Sharp [Fri, 7 Aug 2009 21:04:43 +0000 (14:04 -0700)]
USB: xhci: Configure endpoint code refactoring.

Refactor out the code issue, wait for, and parse the event completion code
for a configure endpoint command.  Modify it to support the evaluate
context command, which has a very similar submission process.  Add
functions to copy parts of the output context into the input context
(which will be used in the evaluate context command).

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Fix slot and endpoint context debugging.
Sarah Sharp [Fri, 7 Aug 2009 21:04:40 +0000 (14:04 -0700)]
USB: xhci: Fix slot and endpoint context debugging.

Use the virtual address of the memory hardware uses, not the address for
the container of that memory.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>