Commit Graph

282 Commits (6cf5c951175abcec4da470c50565cc0afe6cd11d)

Author SHA1 Message Date
Russ Nelson c3baa19b0a USB: cdc-acm: add another device quirk
The Maretron USB100 needs this quirk in order to work properly.

Signed-off-by: Russ Nelson <nelson@crynwr.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-04-30 09:25:10 -07:00
Tejun Heo 5a0e3ad6af include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files.  percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed.  Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability.  As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

  http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
  only the necessary includes are there.  ie. if only gfp is used,
  gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
  blocks and try to put the new include such that its order conforms
  to its surrounding.  It's put in the include block which contains
  core kernel includes, in the same order that the rest are ordered -
  alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
  doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
  because the file doesn't have fitting include block), it prints out
  an error message indicating which .h file needs to be added to the
  file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
   over 4000 files, deleting around 700 includes and adding ~480 gfp.h
   and ~3000 slab.h inclusions.  The script emitted errors for ~400
   files.

2. Each error was manually checked.  Some didn't need the inclusion,
   some needed manual addition while adding it to implementation .h or
   embedding .c file was more appropriate for others.  This step added
   inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
   from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
   e.g. lib/decompress_*.c used malloc/free() wrappers around slab
   APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
   editing them as sprinkling gfp.h and slab.h inclusions around .h
   files could easily lead to inclusion dependency hell.  Most gfp.h
   inclusion directives were ignored as stuff from gfp.h was usually
   wildly available and often used in preprocessor macros.  Each
   slab.h inclusion directive was examined and added manually as
   necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
   were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
   distributed build env didn't work with gcov compiles) and a few
   more options had to be turned off depending on archs to make things
   build (like ipr on powerpc/64 which failed due to missing writeq).

   * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
   * powerpc and powerpc64 SMP allmodconfig
   * sparc and sparc64 SMP allmodconfig
   * ia64 SMP allmodconfig
   * s390 SMP allmodconfig
   * alpha SMP allmodconfig
   * um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
   a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-30 22:02:32 +09:00
Oliver Neukum 338124c1f1 usb: cdc-wdm: Fix deadlock between write and resume
The new runtime PM scheme allows resume() to have no locks.
This fixes the deadlock.

Signed-off-by: Oliver Neukum <neukum@b1-systems.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-19 07:24:17 -07:00
Oliver Neukum d93d16e9aa usb: cdc-wdm: Fix order in disconnect and fix locking
- as the callback can schedule work, URBs must be killed first
- if the driver causes an autoresume, the caller must handle locking

Signed-off-by: Oliver Neukum <neukum@b1-systems.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-19 07:24:17 -07:00
Oliver Neukum 62e6685470 usb: cdc-wdm:Fix loss of data due to autosuspend
The guarding flag must be set and tested under spinlock
and cleared before the URBs are resubmitted in resume.

Signed-off-by: Oliver Neukum <neukum@b1-systems.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-19 07:24:16 -07:00
Oliver Neukum beb1d35f16 usb: cdc-wdm: Fix submission of URB after suspension
There's a window under which cdc-wdm may submit
an URB to a device about to be suspended. This
introduces a flag to prevent it.

Signed-off-by: Oliver Neukum <neukum@b1-systems.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-19 07:24:16 -07:00
Oliver Neukum d855fe2e9c usb: cdc-wdm: Fix race between disconnect and debug messages
dev_dbg() and dev_err() cannot be used to report failures
that may have been caused by a device's removal

Signed-off-by: Oliver Neukum <neukum@b1-systems.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-19 07:24:15 -07:00
Oliver Neukum 922a5eadd5 usb: cdc-wdm: Fix race between autosuspend and reading from the device
While an available response is read the device must not
be autosuspended. This requires a flag dedicated to that
purpose.

Signed-off-by: Oliver Neukum <neukum@b1-systems.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-19 07:24:15 -07:00
Oliver Neukum 860e41a71c usb: cdc-wdm: Fix race between write and disconnect
Unify mutexes to fix a race between write and disconnect
and shift the test for disconnection to always report it.

Signed-off-by: Oliver Neukum <neukum@b1-systems.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-19 07:24:14 -07:00
Oliver Neukum f0730924e9 USB: cdc-acm: Fix stupid NULL pointer in resume()
Stupid logic bug passing a just nulled pointer

Signed-off-by: Oliver Neukum <neukum@b1-systems.de>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-19 07:24:06 -07:00
Alan Cox b6a2f10ca0 USB: tty: kill request_room for USB ACM class
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02 14:55:09 -08:00
Oliver Neukum 2b626dc134 USB: cdc-acm: fix possible deadlock with multiple openers
The lock must be dropped before usb_autopm_interface_put() is called

Signed-off-by: Oliver Neukum <oliver@neukum.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02 14:54:54 -08:00
Oliver Neukum 94015f6e6b USB: BKL removal: cdc-wdm
BKL not needed at all. Removed without replacement.

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02 14:54:27 -08:00
Oliver Neukum 0022457a54 USB: BKL removal: usbtmc
BKL not needed at all. Removed without replacement.

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02 14:54:27 -08:00
Oliver Neukum c8b492a86d usb: BKL removal: usblp
BKL was not needed at all. Removed without replacement.

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Acked-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02 14:54:26 -08:00
Oliver Neukum 86266452f8 USB: Push BKL on open down into the drivers
Straightforward push into the drivers to allow
auditing individual drivers separately

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02 14:54:23 -08:00
Németh Márton 6ef4852b13 USB class: make USB device id constant
The id_table field of the struct usb_device_id is constant in <linux/usb.h>
so it is worth to make the initialization data also constant.

The semantic match that finds this kind of pattern is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r@
disable decl_init,const_decl_init;
identifier I1, I2, x;
@@
	struct I1 {
	  ...
	  const struct I2 *x;
	  ...
	};
@s@
identifier r.I1, y;
identifier r.x, E;
@@
	struct I1 y = {
	  .x = E,
	};
@c@
identifier r.I2;
identifier s.E;
@@
	const struct I2 E[] = ... ;
@depends on !c@
identifier r.I2;
identifier s.E;
@@
+	const
	struct I2 E[] = ...;
// </smpl>

Signed-off-by: Németh Márton <nm127@freemail.hu>
Cc: Julia Lawall <julia@diku.dk>
Cc: cocci@diku.dk
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02 14:54:15 -08:00
Oliver Neukum 3a90f81872 USB: usblp: Remove checks no longer needed with the new runtime PM system
Under the new system a device cannot be suspended against
the driver's wish. Therefore this condition no longer needs
to be checked for.

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Cc: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02 14:53:39 -08:00
Julian Calaby ce126644aa USB: cdc_acm: Silence "It is not a modem." error for pbLua devices
The pbLua console port is known to not be a modem, so it is
unnecessary to be told this when it is plugged in.

Add NOT_A_MODEM quirk to tell the driver that we know this already
and hence not to warn us, and mark the pbLua console port.

Signed-off-by: Julian Calaby <julian.calaby@gmail.com>
Cc: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02 14:53:32 -08:00
Julian Calaby 7c5d8c394a USB: cdc_acm: Add support for pbLua console port
The pbLua firmware (http://pblua.com/) for the Lego Mindstorms NXT
provides a CDC ACM port for it's serial console.

This used to be detected automatically, but this support has been
dropped, probably for sensible reasons.

Explicitly add support for this device by adding an item to the
device ID table.

Signed-off-by: Julian Calaby <julian.calaby@gmail.com>
Cc: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02 14:53:31 -08:00
Oliver Neukum 97d35f9555 USB: cdc-acm: Update to new autopm API
Update cdc-acm to the async methods eliminating the workqueue

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02 14:53:19 -08:00
Francesco Lavra a91b0c5022 cdc_acm: add reset_resume method
Add reset resume logic to the cdc acm driver

Signed-off-by: Francesco Lavra <francescolavra@interfree.it>
Acked-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02 14:53:07 -08:00
Sarah Sharp 3342ecda3f USB: usbtmc: Use usb_clear_halt() instead of custom code.
Make the USB Test & Measurement driver use usb_clear_halt() instead of
usb_control_msg() to clear a stalled endpoint.  This will allow devices to
be tested under an xHCI host controller.  The endpoint stall will not be
cleared in the internal xHCI hardware state unless usb_clear_halt() is
used.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: Steve Holland <sdh4@iastate.edu>
Cc: Oliver Neukum <oliver@neukum.org>
Cc: Jouni Ryno <Jouni.Ryno@fmi.fi>
Cc: Gergely Imreh <imrehg@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-11 11:55:27 -08:00
Andre Herms ec412b92db USB: usbtmc: repeat usb_bulk_msg until whole message is transfered
usb_bulk_msg() transfers only bytes up to the maximum packet size.
It must be repeated by the usbtmc driver until all bytes of a TMC message
are transfered.

Without this patch, ETIMEDOUT is reported when writing TMC messages
larger than the maximum USB bulk size and the transfer remains incomplete.
The user will notice that the device hangs and must be reset by either closing
the application or pulling the plug.

Signed-off-by: Andre Herms <andre.herms@tec-venture.de>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-11 11:55:25 -08:00
Adrian Taylor c1479a92cf USB: Exposing second ACM channel as tty for Nokia S60 phones.
Nokia S60 phones expose two ACM channels. The first is a modem and is picked
up by the standard AT-command interface information in the CDC-ACM driver. The
second is marked as having a vendor-specific protocol. Normally, we don't
expose those as ttys. (On some other devices, they may be claimed by the
rndis_host driver and used as a network interface).

But on S60 this second ACM channel is the way that third-party S60 application
developers are expected to communicate over USB. It acts as a serial device
at the S60 end, and so it should on Linux too.

The list of devices is largely derived from:
http://wiki.forum.nokia.com/index.php/S60_Platform_and_device_identification_codes
http://wiki.forum.nokia.com/index.php/Nokia_USB_Product_IDs
and includes only the S60 3rd Edition+ devices documented there.

There are many devices for which the USB device ID is not documented,
including:
    Nokia 6290
    Nokia E63
    Nokia 5630 XpressMusic
    Nokia 5730 XpressMusic
    Nokia 6710 Navigator
    Nokia 6720 classic
    Nokia 6730 Classic
    Nokia 6760 slide
    Nokia 6790 slide
    Nokia 6790 Surge
    Nokia E52
    Nokia E55
    Nokia E71x (AT&T)
    Nokia E72
    Nokia E75
    Nokia E75 US+LTA variant
    Nokia N79
    Nokia N86 8MP
    Nokia 5230 (RM-588)
    Nokia 5230 (RM-594)
    Nokia 5530 XpressMusic
    Nokia 5530 XpressMusic (china)
    Nokia 5800 XM
    Nokia N97 (RM-506)
    Nokia N97 mini
    Nokia X6
It would be good to add those subsequently.

Signed-off-by: Adrian Taylor <aat@realvnc.com>
Acked-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-11 11:55:20 -08:00
Oliver Neukum dca8cd04df USB: usbtmc: minor formatting cleanups
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-11 11:55:16 -08:00
Jiri Kosina d014d04386 Merge branch 'for-next' into for-linus
Conflicts:

	kernel/irq/chip.c
2009-12-07 18:36:35 +01:00
André Goddard Rosa af901ca181 tree-wide: fix assorted typos all over the place
That is "success", "unknown", "through", "performance", "[re|un]mapping"
, "access", "default", "reasonable", "[con]currently", "temperature"
, "channel", "[un]used", "application", "example","hierarchy", "therefore"
, "[over|under]flow", "contiguous", "threshold", "enough" and others.

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-12-04 15:39:55 +01:00
Francesco Lavra 051522bb47 USB: cdc_acm: Fix memory leak after hangup
Am Donnerstag, 10. September 2009 15:43:53 schrieb Dietmar Hilbrich:
> Hello,
>
> i have the following problem with the cdc-acm - driver:
>
> I'm using the driver with an "Ericsson F3507G" on a Thinkpad T400.
>
> If a disable the device (with the RFKill-Switch) while it is used by a
> programm like ppp, the driver doesn't seem to correctly clean up the tty,
> even after the program has been closed)
>
> The tty is still active (e.g. there still exists an entry in
> /sys/dev/char/166:0 if ttyACM0 was used) and if a reacticate the device,
> this device entry will be skipped and the Device-Nodes ttyACM1, ttyACM2
> and ttyACM3 will be used.
>
> This problem was introduced with the commit
> 10077d4a66 (before 2.6.31-rc1) and still
> exists in 2.6.31.
>
> I was able the fix this problem with the following patch:
>
> diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
> index 2bfc41e..0970d2f 100644
> --- a/drivers/usb/class/cdc-acm.c
> +++ b/drivers/usb/class/cdc-acm.c
> @@ -676,6 +676,7 @@ static void acm_tty_hangup(struct tty_struct *tty)
>         struct acm *acm = tty->driver_data;
>         tty_port_hangup(&acm->port);
>         acm_port_down(acm, 0);
> +       acm_tty_unregister(acm);
>  }

I have the same problem with cdc-acm (I'm using a Samsung SGH-U900): when I
unplug it from the USB port during a PPP connection, the ppp daemon gets the
hangup correctly (and closes the device), but the struct acm corresponding to
the device disconnected is not freed. Hence reconnecting the device results in
creation of /dev/ttyACM(x+1). The same happens when the system is hibernated
during a PPP connection.

This memory leak is due to the fact that when the tty is hung up,
tty_port_close_start() returns always zero, and acm_tty_close() never reaches
the point where acm_tty_unregister() is called.

Here is a fix for this.

Signed-off-by: Francesco Lavra <francescolavra@interfree.it>
Acked-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-11-17 16:46:33 -08:00
Henry Gebhardt 18a77b5d23 USB: cdc_acm: Fix race condition when opening tty
If acm_rx_tasklet() gets called before tty_port_block_til_ready()
returns, then bulk IN urbs may not be sent. This fixes it.

Signed-off-by: Henry Gebhardt <gebhardt@astro.uni-tuebingen.de>
Acked-by: Oliver Neukum <oliver@neukum.org>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-11-17 16:46:33 -08:00
Gergely Imreh 35f76e897d USB: usbtmc: fix timeout increase
The current 10ms timeout is too short for some normal USBTMC device
operation, increase it to a value which was tested with previously
affected Tektronix oscilloscopes.

Signed-off-by: Gergely Imreh <imrehg@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-10-09 13:52:06 -07:00
Alexey Dobriyan 828c09509b const: constify remaining file_operations
[akpm@linux-foundation.org: fix KVM]
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-10-01 16:11:11 -07:00
Gergely Imreh d0a38365d9 USB: fix USBTMC get_capabilities success handling
In order:
Add reference to relevant section of USBTMC usb488 subclass specs.
Print debug output of capabilities only when it was retrieved successfully.
Clear return value on success, otherwise driver always reports failure.

Signed-off-by: Gergely Imreh <imrehg@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-09-23 06:46:39 -07:00
Steve Holland 4143d178e7 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>
2009-09-23 06:46:35 -07:00
Steve Holland 92d07e422d 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>
2009-09-23 06:46:35 -07:00
Steve Holland c2cd26e15b 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>
2009-09-23 06:46:35 -07:00
Randy Dunlap a2fbf10eba 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>
2009-09-23 06:46:30 -07:00
Guus Sliepen 665d7662d1 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>
2009-09-23 06:46:30 -07:00
Oliver Neukum a4708103ad 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>
2009-09-23 06:46:28 -07:00
Oliver Neukum 86286883fc 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>
2009-09-23 06:46:28 -07:00
Oliver Neukum 7af25b4b34 USB: fix cdc-acm regression in open
cdc-acm needs to set a flag during open to tell the
tty layer that the device is initialized

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Paul Martin <pm@debian.org>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-09-23 06:46:16 -07:00
Oliver Neukum 7f1dc313d0 USB: CDC WDM driver doesn't support non-blocking reads
support for O_NONBLOCK in read and write path
by simply not waiting for data in read or availability
of the write urb in write but returning -EAGAIN

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Tested-by: Marcel Holtmann <marcel@holtmann.org>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-09-23 06:46:16 -07:00
Joe Perches a419aef8b8 trivial: remove unnecessary semicolons
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-09-21 15:14:58 +02:00
Linus Torvalds a57c21c715 Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6:
  Driver-Core: extend devnode callbacks to provide permissions
2009-09-20 15:55:39 -07:00
Alan Cox 9b80fee149 cdc_acm: Fix to use modern speed interfaces
This changed in 2006 so its about time the ACM driver caught up

Signed-off-by: Alan Cox <alan@linux.intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-09-19 13:13:23 -07:00
Kay Sievers e454cea20b Driver-Core: extend devnode callbacks to provide permissions
This allows subsytems to provide devtmpfs with non-default permissions
for the device node. Instead of the default mode of 0600, null, zero,
random, urandom, full, tty, ptmx now have a mode of 0666, which allows
non-privileged processes to access standard device nodes in case no
other userspace process applies the expected permissions.

This also fixes a wrong assignment in pktcdvd and a checkpatch.pl complain.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-09-19 12:50:38 -07:00
Oliver Neukum cf7fdd57f9 USB: fix oops on disconnect in cdc-acm
This patch fixes an oops caused when during an unplug a device's table
of endpoints is zeroed before the driver is notified. A pointer to
the endpoint must be cached.

this fixes a regression caused by commit
5186ffee23
Therefore it should go into 2.6.31

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-07 16:05:14 -07:00
Alan Cox 23198fda71 tty: fix chars_in_buffers
This function does not have an error return and returning an error is
instead interpreted as having a lot of pending bytes.

Reported by Jeff Harris who provided a list of some of the remaining
offenders.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-07-20 16:38:43 -07:00
Linus Torvalds 51feb98d25 Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (48 commits)
  USB: otg: fix module reinsert issue
  USB: handle zero-length usbfs submissions correctly
  USB: EHCI: report actual_length for iso transfers
  USB: option: remove unnecessary and erroneous code
  USB: cypress_m8: remove invalid Clear-Halt
  USB: musb_host: undo incorrect change in musb_advance_schedule()
  USB: fix LANGID=0 regression
  USB: serial: sierra driver id_table additions
  USB serial: Add ID for Turtelizer, an FT2232L-based JTAG/RS-232 adapter.
  USB: fix race leading to a write after kfree in usbfs
  USB: Sierra: fix oops upon device close
  USB: option.c: add A-Link 3GU device id
  USB: Serial: Add support for Arkham Technology adapters
  USB: Fix option_ms regression in 2.6.31-rc2
  USB: gadget audio: select SND_PCM
  USB: ftdi: support NDI devices
  Revert USB: usbfs: deprecate and hide option for !embedded
  USB: usb.h: fix kernel-doc notation
  USB: RNDIS gadget, fix issues talking from PXA
  USB: serial: FTDI with product code FB80 and vendor id 0403
  ...
2009-07-13 10:23:03 -07:00
Arseniy Lartsev 5186ffee23 USB: cdc-acm: work around some broken devices
This patch introduces a work around for cdc-acm devices which are
low speed contrary to the specification, which requires bulk endpoints
which are banned in low speed and converted by usbcore to virtual
interrupt endpoints if they are used nevertheless.

Signed-off-by: Arseniy Lartsev <ars3n@yandex.ru>
Cc: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-07-12 15:16:37 -07:00
Oliver Neukum ca157c4a51 USB: fix memory leak in usbtmc
If an error is returned kfree must also be called.


Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-07-12 15:16:37 -07:00
Alexey Dobriyan 405f55712d headers: smp_lock.h redux
* Remove smp_lock.h from files which don't need it (including some headers!)
* Add smp_lock.h to files which do need it
* Make smp_lock.h include conditional in hardirq.h
  It's needed only for one kernel_locked() usage which is under CONFIG_PREEMPT

  This will make hardirq.h inclusion cheaper for every PREEMPT=n config
  (which includes allmodconfig/allyesconfig, BTW)

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-07-12 12:22:34 -07:00
Thadeu Lima de Souza Cascardo 922b13565b acm: Fix oops when closing ACM tty device right after open has failed.
This commit 10077d4a66 has stopped
checking if there was a valid acm device associated to the tty, which is
not true right after open fails and tty subsystem tries to close the
device.

As an example, open fails with a non-existing device, when probe has
never been called, because the device has never been plugged. This is
common in systems with static modules and no udev.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-06-25 11:24:26 -07:00
Thadeu Lima de Souza Cascardo 42dd2aa649 acm: Return ENODEV instead of EINVAL when trying to open ACM device.
This is required, otherwise a user will get a EINVAL while opening a
non-existing device, instead of ENODEV.

This is what I get with this patch applied now instead of an "Invalid
argument".

  cascardo@vespa:~$ cat /dev/ttyACM0
  cat: /dev/ttyACM0: No such device
  cascardo@vespa:~$

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-06-25 11:24:26 -07:00
Linus Torvalds e1f5b94fd0 Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (143 commits)
  USB: xhci depends on PCI.
  USB: xhci: Add Makefile, MAINTAINERS, and Kconfig entries.
  USB: xhci: Respect critical sections.
  USB: xHCI: Fix interrupt moderation.
  USB: xhci: Remove packed attribute from structures.
  usb; xhci: Fix TRB offset calculations.
  USB: xhci: replace if-elseif-else with switch-case
  USB: xhci: Make xhci-mem.c include linux/dmapool.h
  USB: xhci: drop spinlock in xhci_urb_enqueue() error path.
  USB: Change names of SuperSpeed ep companion descriptor structs.
  USB: xhci: Avoid compiler reordering in Link TRB giveback.
  USB: xhci: Clean up xhci_irq() function.
  USB: xhci: Avoid global namespace pollution.
  USB: xhci: Fix Link TRB handoff bit twiddling.
  USB: xhci: Fix register write order.
  USB: xhci: fix some compiler warnings in xhci.h
  USB: xhci: fix lots of compiler warnings.
  USB: xhci: use xhci_handle_event instead of handle_event
  USB: xhci: URB cancellation support.
  USB: xhci: Scatter gather list support for bulk transfers.
  ...
2009-06-16 13:06:10 -07:00
Greg Kroah-Hartman a92b63e7e4 USB: usbtmc: fix switch statment
Steve Holland pointed out that we forgot to call break; in the switch
statment.  This probably resolves a lot of the bug reports I've gotten
for the driver lately.

Stupid me...

Reported-by: Steve Holland <sdh4@iastate.edu>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-06-15 21:44:48 -07:00
Kir Kolyshkin 1f17c5026c USB: cdc-acm: quirk for Alcatel OT-I650
This mobile phone fails to work as a modem, failing with:
 cdc_acm: Zero length descriptor references
 cdc_acm: probe of 1-6.1.3:1.1 failed with error -22

Tested to work fine with this patch.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-06-15 21:44:46 -07:00
Oliver Neukum a2bfb4a346 USB: support for cdc-acm of single interface devices
This implement support in cdc-acm for acm devices another popular OS can handle

- adds support for autodetection of devices that use one interface
- autodetection of endpoints
- add a quirk for surpressing a setting that OS doesn't use
- autoassume that quirk for single interface devices

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-06-15 21:44:45 -07:00
Kay Sievers f7a386c5b8 Driver Core: usb: add nodename support for usb drivers.
This adds support for USB drivers to report their requested nodename to
userspace.  It also updates a number of USB drivers to provide the
needed subdirectory and device name to be used for them.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-06-15 21:30:25 -07:00
Alan Cox 6e47e069eb tty: Clean up the ACM driver to CodingStyle
Or at least most of it. There are further clean ups possible and there are
are also thing checkpatch moans about that would be silly to "fix".

Also note some FIXME points found as the cleanup was done.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-06-11 08:50:58 -07:00
Alan Cox 10077d4a66 tty: cdc_acm add krefs
Now we have a port structure begin using the fields and kref counts

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-06-11 08:50:58 -07:00
Alan Cox 739e0285cb tty: Update cdc_acm
The CDC ACM driver uses the tty layer correctly so needs conversion. Start by
adding and initializing the port structures.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-06-11 08:50:57 -07:00
Xiao Kaijian cab98a0a34 USB: Yet another Conexant Clone to add to cdc-acm.c
This patch adds another quirky Conexant USB Modem Clone to usb cdc-acm.c

Signed-off-by: Xiao Kaijian <xiaokj@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-05-28 13:54:41 -07:00
Oliver Neukum 052fbc0d7f USB: correct error handling in cdc-wdm
This patch to cdc-wdm

- checks for partial extra descriptors
- fixes a leak in the error case of probe
- checks for an exact number of endpoints
- adds a clarifying comment

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-04-23 14:15:30 -07:00
Oliver Neukum e13c594f3a USB: fix oops in cdc-wdm in case of malformed descriptors
cdc-wdm needs to ignore extremely malformed descriptors.

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-04-17 10:50:24 -07:00
Alan Cox 7a9a65ced1 cdc-acm: Fix long standing abuse of tty->low_latency
ACM sets the low latency flag but calls the flip buffer routines from
IRQ context which isn't permitted (and as of 2.6.29 causes a warning
hence this one was caught)

Fortunatelt ACM doesn't need to set this flag in the first place as it
only set it to work around problems in ancient (pre tty flip rewrite)
kernels.

Reported-by: Chuck Ebbert <cebbert@redhat.com>
Signed-off-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-04-14 08:48:50 -07:00
Alan Cox 7abcf20b8f cdc-acm: zydas 1602 identifier needed
Bugzilla #9095 and a couple of other confirmations

Signed-off-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-04-06 14:36:38 -07:00
Scott James Remnant e766aeb882 usb: Auto-load cdc_acm module when device opened.
The cdc_acm module is missing the char-major-166-* alias that would
cause it to be auto-loaded when a device of that type is opened.  This
patch adds the alias.

Signed-off-by: Scott James Remnant <scott@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Signed-off-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-04-06 14:36:31 -07:00
Pete Zaitcev dd44be6b17 usblp: continuously poll for status
The usblp in 2.6.18 polled for status regardless if we actually needed it.
At some point I dropped it, to save the batteries if nothing else.
As it turned out, printers exist (e.g. Canon BJC-3000) that need prodding
this way or else they stop. This patch restores the old behaviour.
If you want to save battery, don't leave jobs in the print queue.

I tested this on my printers by printing and examining usbmon traces
to make sure status is being requested and printers continue to print.
Tuomas Jäntti verified the fix on BJC-3000.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-03-24 16:20:26 -07:00
Greg Kroah-Hartman 228dd05dbf USB: usbtmc: add protocol 1 support
The driver already supports the 1 protocol support, so just add it to
the MODULE_DEVICE_TABLE entry so it properly picks up these devices.

Thanks to Jouni Rynö for pointing this out.

Reported-by: Jouni Ryno <Jouni.Ryno@fmi.fi>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-03-17 14:01:28 -07:00
Greg Kroah-Hartman 5b10916ea0 USB: usbtmc: fix stupid bug in open()
open() will never succeed, as we always return -ENODEV.  Fix this
obvious bug.

Thanks to Jouni Ryno for reporting it.

Reported-by: Jouni Ryno <Jouni.Ryno@fmi.fi>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-03-17 14:01:28 -07:00
Adam Richter c332b4e1bf USB: Quirk for Hummingbird huc56s / Conexant ACM modem
Signed-off-by: Adam J. Richter <adam_richter2004@yahoo.com>
Cc: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-02-27 14:40:50 -08:00
Dmitriy Taychenachev 155df65ae1 USB: cdc-acm: add usb id for motomagx phones
The Motorola MOTOMAGX phones (Z6, E8, Zn5 so far) are providing
combined ACM/BLAN USB configuration. Since it has Vendor Specific
class, the corresponding drivers (cdc-acm, zaurus) can't find it just
by interface info. This patch adds usb id so the cdc-acm driver can
properly handle this combined device.

Signed-off-by: Dmitriy Taychenachev <dimichxp@gmail.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-02-27 14:40:50 -08:00
James Treacy 2057ac86da USB: cdc-acm.c: remove duplicate lines for MTK gps support
The same patch to add support for MTK gps loggers was submitted by two
different people and applied twice. Remove the redundant lines.

Signed-off-by: James Treacy <treacy@debian.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-02-09 11:19:47 -08:00
Alan Cox c89c60e9d6 USB: cdc-acm: Add another conexant modem to the quirks
Another Conexant, another device with the same quirk

Signed-off-by: Alan Cox <alan@redhat.com>
Acked-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-01-27 16:15:37 -08:00
Brandon Philips 06a743bfc4 USB: usblp.c: add USBLP_QUIRK_BIDIR to Brother HL-1440
My Brother HL-1440 would print one document before CUPS would stop
printing with the error "Printer not connected; will retry in 30
seconds...". I traced this down to the CUPS usb backend getting an EIO
out of usblp on the IOCNR_GET_DEVICE_ID IOCTL. Adding the
USBLP_QUIRK_BIDIR fixes the problem but is it the right solution?

output from strace /usr/lib/cups/backend/usb after printing a document
(Note: SNDCTL_DSP_SYNC == IOCNR_GET_DEVICE_ID):

before patch

open("/dev/usb/lp0", O_RDWR|O_EXCL)     = 3
ioctl(3, SNDCTL_DSP_SYNC, 0x7fff2478cef0) = -1 EIO (Input/output error)

after patch

open("/dev/usb/lp0", O_RDWR|O_EXCL)     = 3
ioctl(3, SNDCTL_DSP_SYNC, 0x7fffb8d474c0) = 0

Possibly related bug: https://bugs.launchpad.net/ubuntu/+source/cupsys/+bug/35638

Signed-off-by: Brandon Philips <bphilips@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-01-27 16:15:36 -08:00
Andrew Lunn 0f9c7b4a1c USB: CDC-ACM quirk for MTK GPS
This patch adds a device quirk for a MediaTek Inc GPS chipset. The
device implements USB CDC ACM, but is missing the union descriptor, so
the ACM class driver fails to probe the device.

I've tested this patch with an iBlue A+ GPS which uses this chipset
and using kernel 2.6.28-rc9.

Signed-off-by: Andrew Lunn, <andrew@lunn.ch>
Acked-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-01-27 16:15:36 -08:00
James A. Treacy 837d842496 USB: cdc-acm: support some gps data loggers
Below is a patch which allows a number of GPS loggers to work
under linux. It is known to support the i-Blue 747 (all models),
i-Blue 757, Qstarz BT-Q1000, i.Trek Z1, Konet BGL-32, and the Holux
M-241.

From: James A. Treacy <treacy@debian.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-01-27 16:15:36 -08:00
Alan Stern 65bfd2967c USB: Enhance usage of pm_message_t
This patch (as1177) modifies the USB core suspend and resume
routines.  The resume functions now will take a pm_message_t argument,
so they will know what sort of resume is occurring.  The new argument
is also passed to the port suspend/resume and bus suspend/resume
routines (although they don't use it for anything but debugging).

In addition, special pm_message_t values are used for user-initiated,
device-initiated (i.e., remote wakeup), and automatic suspend/resume.
By testing these values, drivers can tell whether or not a particular
suspend was an autosuspend.  Unfortunately, they can't do the same for
resumes -- not until the pm_message_t argument is also passed to the
drivers' resume methods.  That will require a bigger change.

IMO, the whole Power Management framework should have been set up this
way in the first place.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-01-07 10:00:03 -08:00
Ilpo Järvinen 857cc4dfb6 USB: usbtmc: indent & braces disagree, something else is desired
It seems that there's rather involved way to say something
which is commonly written in a plain simple form.

Some type changes would probably be necessary to get gcc
to do bitops instead of divide but it's no worse after my
change than before I think.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-01-07 09:59:51 -08:00
Greg Kroah-Hartman 5413aa4678 USB: fix problem with usbtmc driver not loading properly
The usbtmc driver forgot to export its device table to userspace.
Without this, it is never loaded properly when such a device is seen by
the system.

Cc: Marcel Janssen <marcel.janssen@admesy.nl>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-12-17 10:49:10 -08:00
Brandon Philips ad0b65efd1 USB: cdc-acm.c: fix recursive lock in acm_start_wb error path
Fixes an obvious bug in cdc-acm by avoiding a recursive lock on
acm_start_wb()'s error path. Should apply towards 2.6.27 stable and
2.6.28.

=============================================
[ INFO: possible recursive locking detected ]
2.6.27-2-pae #109
---------------------------------------------
python/31449 is trying to acquire lock:
 (&acm->write_lock){++..}, at: [<f89a0348>] acm_start_wb+0x5c/0x7b [cdc_acm]

but task is already holding lock:
 (&acm->write_lock){++..}, at: [<f89a04fb>] acm_tty_write+0xe1/0x167 [cdc_acm]

other info that might help us debug this:
2 locks held by python/31449:
 #0:  (&tty->atomic_write_lock){--..}, at: [<c0260fae>] tty_write_lock+0x14/0x3b
 #1:  (&acm->write_lock){++..}, at: [<f89a04fb>] acm_tty_write+0xe1/0x167 [cdc_acm]

stack backtrace:
Pid: 31449, comm: python Not tainted 2.6.27-2-pae #109
 [<c030f42f>] ? printk+0xf/0x18
 [<c0149f33>] __lock_acquire+0xc7b/0x1316
 [<c014a63e>] lock_acquire+0x70/0x97
 [<f89a0348>] ? acm_start_wb+0x5c/0x7b [cdc_acm]
 [<c0312109>] _spin_lock_irqsave+0x37/0x47
 [<f89a0348>] ? acm_start_wb+0x5c/0x7b [cdc_acm]
 [<f89a0348>] acm_start_wb+0x5c/0x7b [cdc_acm]
 [<f89a055d>] acm_tty_write+0x143/0x167 [cdc_acm]
 [<c0262a98>] write_chan+0x1cd/0x297
 [<c012527e>] ? default_wake_function+0x0/0xd
 [<c026111e>] tty_write+0x149/0x1b9
 [<c02628cb>] ? write_chan+0x0/0x297
 [<c01912c5>] ? rw_verify_area+0x76/0x98
 [<c0260fd5>] ? tty_write+0x0/0x1b9
 [<c01919ba>] vfs_write+0x8c/0x136
 [<c0191afd>] sys_write+0x3b/0x60
 [<c0103beb>] sysenter_do_call+0x12/0x3f
 =======================

Signed-off-by: Brandon Philips <bphilips@suse.de>
Cc: Oliver Neukum <oliver@neukum.org>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-11-13 14:45:02 -08:00
Chris Malley b361a6e348 USB: usbtmc: Use explicit unsigned type for input buffer instead of char*
Silences compiler warning about comparison with 0x80, and type now matches the
corresponding _bulk_out function.

drivers/usb/class/usbtmc.c: In function ‘usbtmc_ioctl_abort_bulk_in’:
drivers/usb/class/usbtmc.c:163: warning: comparison is always false due to limited range of data type

Signed-off-by: Chris Malley <mail@chrismalley.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-10-29 14:54:40 -07:00
Oliver Neukum a496c64f13 USB: fix memory leak in cdc-acm
This fixes a memory leak on disconnect in cdc-acm

Thanks to 施金前 for finding it.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-10-22 10:05:29 -07:00
Oliver Neukum aa5380b904 USB: cdc-wdm: make module autoload work
this fixes an omission that led to no alias being computed for the
cdc-wdm module.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-10-22 10:05:29 -07:00
Greg Kroah-Hartman 9908a32e94 USB: remove err() macro from usb class drivers
USB should not be having it's own printk macros, so remove err() and
use the system-wide standard of dev_err() wherever possible.  In the
few places that will not work out, use a basic printk().

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-10-17 14:41:10 -07:00
Greg Kroah-Hartman 5909f6ea2b USB: remove info() macro from remaining usb drivers
USB should not be having it's own printk macros, so remove info() and
use the system-wide standard of dev_info() wherever possible.  In the
few places that will not work out, use a basic printk().

Clean up the remaining usages of this in the drivers/usb/ directory.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-10-17 14:41:09 -07:00
Julia Lawall 49b707b90c drivers/usb/class/usblp.c: adjust error handling code
In this code, it is possible to tell statically whether usblp will be NULL
in the error handling code.

Oliver Neukum suggested to make a goto to the final return rather than 
return directly.

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

// <smpl>
@@
identifier f,err,l,l1;
type T;
expression x,E;
statement S;
@@

x = NULL
... when != goto l1;
* x = f(...)
... when != x
err = E;
goto l;
...
* if (x != NULL)
  S
return err;
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Cc: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-10-17 14:40:51 -07:00
Greg Kroah-Hartman 5b775f672c USB: add USB test and measurement class driver
This driver was originaly written by Stefan Kopp, but massively
reworked by Greg for submission.

Thanks to Felipe Balbi <me@felipebalbi.com> for lots of work in cleaning
up this driver.

Thanks to Oliver Neukum <oliver@neukum.org> for reviewing previous
versions and pointing out problems.


Cc: Stefan Kopp <stefan_kopp@agilent.com>
Cc: Marcel Janssen <korgull@home.nl>
Cc: Felipe Balbi <me@felipebalbi.com>
Cc: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-10-17 14:40:51 -07:00
Alexey Dobriyan 74573ee709 USB: cdc-acm: don't unlock acm->mutex on error path
On Wed, Jul 23, 2008 at 03:52:36PM +0300, Andrei Popa wrote:
> I installed gnokii-0.6.22-r2 and gave the command "gnokii --identify"
> and the kernel oopsed:
>
> BUG: unable to handle kernel NULL pointer dereference at 00000458
> IP: [<c0444b52>] mutex_unlock+0x0/0xb
>  [<c03830ae>] acm_tty_open+0x4c/0x214

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Tested-by: Andrei Popa <andrei.popa@i-neo.ro>
Cc: stable <stable@kernel.org>		[2.6.25.x, 2.6.26.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-08-21 10:26:35 -07:00
Eric Sandeen c8fd2c37b9 USB: cdc-acm: quirk for Conexant CX93010 USB modem
This patch gets my Rosewill RNX-56USB USB modem (with Conexant CX93010
chipset) up and running to the point where I can send AT commands and
retrieve caller ID data, which is all I want to do with it.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Acked-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-08-21 10:26:33 -07:00
David Brownell e5fbab51b4 usb: cdc-acm: drain writes on close
Add a mechanism to let the write queue drain naturally before
closing the TTY, rather than always losing that data.  There
is a timeout, so it can't wait too long.

Provide missing locking inside acm_wb_is_avail(); it matters
more now.  Note, this presumes an earlier patch was applied,
removing a call to this routine where the lock was held.

Slightly improved diagnostics on write URB completion, so we
can tell when a write URB gets killed and, if so, how much
data it wrote first ... and so that I/O path is normally
silent (and can't much change timings).

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-08-13 17:32:57 -07:00
David Brownell 934da4635c usb: cdc-acm: stop dropping tx buffers
The "increase cdc-acm write throughput" patch left in place two
now-obsolete mechanisms, either of which can make the cdc-acm
driver drop TX data (nasty!).  This patch removes them:

  - The write_ready flag ... if an URB and buffer were found,
    they can (and should!) always be used.

  - TX path acm_wb_is_used() ... used when the buffer was just
    allocated, so that check is pointless.

Also fix a won't-yet-matter leak of a write buffer on a disconnect path.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Cc:  David Engraf <david.engraf@netcom.eu>
Acked-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-08-13 17:32:57 -07:00
David Brownell 672c4e1843 usb: cdc-acm: bugfix release()
Bugfixes to the usb_driver_release_interface() usage;

  (a) make sure releasing *either* interface first will release
      the other, instead of insisting it be the control interface;

  (b) remove the recently-added self-deadlock.

(The "fix disconnect bug in cdc-acm" patch was incomplete and incorrect.)

Plus a small "sparse" fix:  rename a local variable so it doesn't
shadow a function parameter.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Acked-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-08-13 17:32:57 -07:00
Takashi Iwai 81eb8adfce USB: cdc-acm.c: Fix compile warnings
The irq flags should be unsigned long.

  CC [M]  drivers/usb/class/cdc-acm.o
drivers/usb/class/cdc-acm.c: In function 'acm_waker':
drivers/usb/class/cdc-acm.c:527: warning: comparison of distinct pointer types lacks a cast
drivers/usb/class/cdc-acm.c:529: warning: comparison of distinct pointer types lacks a cast

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-08-13 17:32:56 -07:00
Alan Cox 9e98966c7b tty: rework break handling
Some hardware needs to do break handling itself and may have partial
support only. Make break_ctl return an error code. Add a tty driver flag
so you can indicate driver hardware side break support.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-07-22 13:03:28 -07:00
Oliver Neukum 357585892e USB: fix build error in cdc-acm for CONFIG_PM=n
Here's the fix. cdc-wdm has the same problem. The fix is the same.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-07-21 15:16:47 -07:00
Oliver Neukum 830f4021a8 USB: fix disconnect bug in cdc-acm
cdc-acm must give up secondary interfaces if the primary is disconnected
and vice versa. This wasn't done correctly.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-07-21 15:16:37 -07:00
Oliver Neukum 17d80d562f USB: autosuspend for cdc-wdm
this patch implements

- suspend/resume
- aggressive autosuspend for the cdc-wdm driver
- pre/post_reset

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-07-21 15:16:36 -07:00
Oliver Neukum 11ea859d64 USB: additional power savings for cdc-acm devices that support remote wakeup
this patch saves power for cdc-acm devices that support remote wakeup
while the device is connected.

- request needs_remote_wakeup when needed
- delayed write while a device is autoresumed
- the device is marked busy when appropriate

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-07-21 15:16:36 -07:00
Oliver Neukum 87d65e54b6 USB: cdc-wdm cleanup
- fixes an error with filling out control requests
- increases grepability and error logging
- fixes the short read code path

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-07-21 15:16:31 -07:00
Oliver Neukum 4b828abed2 USB: fix cdc-acm resume()
cdc-acm has
- a memory leak in resume()
- will fail to reactivate the read code path if this is needed.
his corrects it by deleting the useless relict code.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-07-03 18:20:36 -07:00
Al Viro fa4144b758 cdc-wdm endianness fixes
* wMaxPacketSize is le16; copying it to a field of local structure and then
  using that field as host-endian (size of object to be allocated) is broken.
* bMaxPacketSize0 is 8-bit; feeding it to le16_to_cpu() is bogus and since the
  result is used as host-endian, it's not even misspelled cpu_to_le16().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-06-04 08:06:01 -07:00
Oliver Neukum afba937e54 USB: CDC WDM driver
Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-05-20 14:14:15 -07:00
Iain McFarlane 6149ed5e3a USB: add Zoom Telephonics Model 3095F V.92 USB Mini External modem to cdc-acm
The patch below is a necessary workaround to support the Zoom Telephonics Model 3095F V.92 USB Mini External modem, which fails to initialise properly during normal probing thus:

May  3 22:53:00 imcfarla kernel: drivers/usb/class/cdc-acm.c: Zero length descriptor references
May  3 22:53:00 imcfarla kernel: cdc_acm: probe of 5-2:1.0 failed with error -22

Adding the patch below causes the probing section to be skipped, and the modem
then initialises correctly.

Signed-off-by: Iain McFarlane <iain@imcfarla.homelinux.net>
Acked-by: Oliver Neukum <oneukum@suse.de>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-05-14 10:00:27 -07:00
Harvey Harrison a5abdeafed usb: use get/put_unaligned_* helpers
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-04-29 08:06:28 -07:00
Ming Lei cdc9779228 USB: remove unnecessary type casting of urb->context
urb->context code cleanup

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-04-24 21:16:55 -07:00
Harvey Harrison 441b62c1ed USB: replace remaining __FUNCTION__ occurrences
__FUNCTION__ is gcc-specific, use __func__

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-04-24 21:16:55 -07:00
David Brownell c6dbf554bc USB: cdc-acm: signedness fix
Fix bogus assignment of "unsigned char *" to "char *":  preserve
unsignedness.  These values are used directly as descriptor lengths
when iterating through the buffer, so this *could* cause oddness
that potentially includes oopsing.  (IMO not likely, except as
part of a malicious device...)

Fix the bogus warning in CDC ACM which highlighted this problem
(by showing a negative descriptor type).  It uses the undesirable
legacy err() for something that's not even an error; switch to
use dev_dbg, and show descriptor types in hex notation to match
the convention for such codes.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Acked-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-04-24 21:16:53 -07:00
David Engraf e4cf3aa8f9 USB: increase cdc-acm write throughput
the following patch uses 16 write urbs and a writsize of wMaxPacketSize
* 20.  With this patch I get the maximum througput from my linux system
with 20MB/sec read and 15 MB/sec write (full speed 1 MB/sec both)

I also deleted the flag URB_NO_FSBR for the writeurbs, because this
makes my full speed devices significant slower.

Signed-off-by: David Engraf <david.engraf@netcom.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-04-24 21:16:44 -07:00
David Engraf 28d1dfadd3 USB: cdc-acm tell tty layer not to split things up.
It ensures that the tty level do not split
the send buffer into 2KB blocks.


Signed-off-by: David Engraf <david.engraf@netcom.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-04-24 21:16:44 -07:00
Oliver Neukum 94409cc1e5 USB: fix usb open suspend race in cdc-acm
this fixes a race between open and disconnect in the CDC ACM driver.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-02-21 15:38:49 -08:00
Oliver Neukum 1902869019 USB: fix pm counter leak in usblp
if you fail in open() you must decrement the pm counter again.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Cc: stable <stable@kernel.org>
Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
2008-02-21 15:38:48 -08:00
Joe Perches dc0d5c1e5c USB: Spelling fixes
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-02-01 14:34:57 -08:00
Oliver Neukum 1365baf724 USB: autosuspend for cdc-acm
Here we go. This patch implements suspend/resume and autosuspend
for the CDC ACM driver.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-02-01 14:34:47 -08:00
Joe Perches 898eb71cb1 Add missing newlines to some uses of dev_<level> messages
Found these while looking at printk uses.

Add missing newlines to dev_<level> uses
Add missing KERN_<level> prefixes to multiline dev_<level>s
Fixed a wierd->weird spelling typo
Added a newline to a printk

Signed-off-by: Joe Perches <joe@perches.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Mark M. Hoffman <mhoffman@lightlink.com>
Cc: Roland Dreier <rolandd@cisco.com>
Cc: Tilman Schmidt <tilman@imap.cc>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Jeff Garzik <jeff@garzik.org>
Cc: Stephen Hemminger <shemminger@linux-foundation.org>
Cc: Greg KH <greg@kroah.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: David Brownell <david-b@pacbell.net>
Cc: James Smart <James.Smart@Emulex.Com>
Cc: Andrew Vasquez <andrew.vasquez@qlogic.com>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Cc: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Jaroslav Kysela <perex@suse.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-10-18 14:37:28 -07:00
Pete Zaitcev 42cb967fd0 usblp: Fix a double kfree
If submit fails, slab hits a BUG() because of a double kfree.
The today's lesson is, you cannot just slap USB_FREE_BUFFER on code
without adjusting the error paths.

The patch is made bigger by opportunistic refactoring.

Signed-Off-By: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-10-12 14:55:15 -07:00
Pete Zaitcev 283face86b usblp: Cosmetics
This is a small bunch of cosmetic fixes:
 - Timeout is not a write timeout anymore, rename
 - Condition in poll was confusingly backwards, invert and simplify
 - The comment log gave a wrong impression of version 0.13, terminate it.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-10-12 14:55:14 -07:00
Pete Zaitcev fc401e697f usblp: mutex in usblp_check_status
Add a mutex to protect the ->statusbuf. Not really an issue, because CUPS
is single-threaded when it talks to the printer, but I feel safer this way.
This should be deadlock-free, but I kept this as a separate patch in case
someone ends running a git bisect.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-10-12 14:55:14 -07:00
Pete Zaitcev e8fa0ce65c usblp: Make use of URB_FREE_BUFFER
Employ the new API URB_FREE_BUFFER that we've got. There was talk of a combined
constructor for this case, but apparently it's not happening, so just set the
flag explicitly for now.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-10-12 14:54:58 -07:00
Pete Zaitcev 7f477358e2 usblp: Implement the ENOSPC convention
This patch implements a mode when a printer returns ENOSPC when it runs
out of paper. The default remains the same as before. An application which
wishes to use this function has to enable it explicitly with an ioctl
LPABORT.

This is done on a request by our (Fedora) CUPS guy, Tim Waugh. The API is
similar enough to the lp0's one that CUPS works with both (but see below),
but it's has some differences.

Most importantly, the abort mode is persistent in case of lp0: once tunelp
was run your cat fill blow up until you reboot or run tunelp again. For
usblp, I made it so the abort mode is only in effect as long as device
is open. This way you can mix and match CUPS and cat(1) freely and nothing
bad happens even if you run out of paper. It is also safer in the face
of any unexpected crashes.

It has to be noted that mixing LPABORT and O_NONBLOCK is not advised.
It probably does not do what you want: instead of returning -ENOSPC
it will always return -EAGAIN (because it would otherwise block while
waiting for the paper). Applications which use O_NONBLOCK should continue
to use LPGETSTATUS like before.

Finally, CUPS actually requires patching to take full advantage of this.
It has several components; those which invoke LPABORT work, but some of
them need the ioctl added. This is completely compatible, you can mix
old CUPS and new kernels or vice versa.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-10-12 14:54:58 -07:00
Alan Stern 74da5d68a5 USB: cdc-acm: fix sysfs attribute registration bug
This patch (as950) fixes a bug in the cdc-acm driver.  It doesn't keep
track of which interface (control or data) the sysfs attributes get
registered for, and as a result, during disconnect it will sometimes
attempt to remove the attributes from the wrong interface.  The
left-over attributes can cause a crash later on, particularly if the driver
module has been unloaded.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Oliver Neukum <oneukum@suse.de>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-08-22 14:27:43 -07:00
Greg Kroah-Hartman 18ac301605 USB: class: usblp: clean up urb->status usage
This done in anticipation of removal of urb->status, which will make
that patch easier to review and apply in the future.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-07-19 17:46:06 -07:00
Greg Kroah-Hartman 185d40587d USB: class: cdc-acm: clean up urb->status usage
This done in anticipation of removal of urb->status, which will make
that patch easier to review and apply in the future.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-07-19 17:46:06 -07:00
Pete Zaitcev 10e485221e USB: usblp: "Big cleanup" breaks O_NONBLOCK
I found the first regresson in the rewritten ("all dynamic" and "no races")
driver. If application uses O_NONBLOCK, I return -EAGAIN despite the URB
being submitted successfuly. This causes the application to resubmit the
same data erroneously.

The fix is to pretend that the transfer has succeeded even if URB was
merely queued. It is the same behaviour as with the old version.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-07-19 17:46:03 -07:00
Andrey Arapov b0e2a705bf USB: cdc-acm: add new device id to option driver
USB: add new device id to option driver
device is Samsung X180 China cellphone

Signed-off-by: Andrey Arapov <andrey.arapov@gmail.com>
Acked-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-07-12 16:34:43 -07:00
Pete Zaitcev 317c67b8f7 USB: usblp: add dynamic URBs, fix races
This patch's main bulk aims to make usblp the premier driver for code
pillaging once again. The code is as streamlined as possible and is bug-free
as possible. The usb-skeleton performs the same function, but is somewhat
abstract. The usblp is usb-skeleton which is actually used by many.

Since I combed a few small bugs away, this also fixes the small races we
had in usblp for a while. For example, now it's possible for several threads
to make write(2) calls (sounds silly, but consider a printer for paper
record, where every line of text is self-contained and thus it's all right
to have them interleaved). Also gone are issues with interrupts using
barriers dangerously.

This patch makes use of Oliver's anchor, and so it must trail the anchor
patch on the way to Linus.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-07-12 16:34:39 -07:00
Pete Zaitcev 97cb95d1c4 usblp: Don't let suspend to kill ->used
Suspend destroys refcounting for open/release.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-06-08 16:24:29 -07:00
Pete Zaitcev bdc4abdd09 USB: usblp: Use correct DMA address in case of probe error
Looks like the error path had a copy-paste error. The normal exit path
uses correct URB already.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-05-22 23:45:50 -07:00
Randy Dunlap e63340ae6b header cleaning: don't include smp_lock.h when not used
Remove includes of <linux/smp_lock.h> where it is not used/needed.
Suggested by Al Viro.

Builds cleanly on x86_64, i386, alpha, ia64, powerpc, sparc,
sparc64, and arm (all 59 defconfigs).

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-08 11:15:07 -07:00
Oliver Neukum c4cabd28c7 USB: cdc-acm: export parsed capabilities through sysfs
this patch exports the attributes cdc-acm knows about a device through sysfs.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-04-27 13:28:33 -07:00
Alan Stern 5ec71db59a usblp: quirk flag and device entry for Seiko Epson M129C printer
This patch (as872) adds a device table entry and a new quirk flag to
the usblp driver for the Seiko Epson Receipt printer.  This printer
returns Vendor-Specific values for bInterfaceClass and
bInterfaceSubClass, but the bInterfaceProtocol value is valid and it
works with usblp.  The new quirks flag tells the driver to ignore the
Class and SubClass values in the interface descriptor.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Vojtech Pavlik <vojtech@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-03-19 13:22:18 -07:00
Oliver Neukum 834dbca5b6 USB: fix spinlock recursion in cdc-acm.c
this fixes the spinlock recursion issue. The older fix was incomplete.


Signed-off-by: Oliver Neukum <oneukum@suse.de>
Acked-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-03-09 19:52:25 -08:00
Oliver Neukum 9be8456c00 USB: quirky device for cdc-acm
here's a quirklist entry reported by Stephen Murphy.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-02-16 15:32:21 -08:00
Oliver Neukum ca79b7b415 USB: cdc-acm: fix incorrect throtteling, make set_control optional
this is Joris' fixes reshuffelled and features renamed as David requested.

- acm_set_control is not mandatory, honour that
- throtteling is reset upon open
- throtteling is read consistently when processing input data

Signed-off-by: Joris van Rantwijk <jorispubl@xs4all.nl>
Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-02-16 15:32:21 -08:00
Oliver Neukum d053218408 USB: autosuspend for usb printer driver
this implements autosuspend for usb printers. It compiles and is tested.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-02-07 15:44:39 -08:00
Martin Williges 4f45d0387b USB: usblp.c - add Kyocera Mita FS 820 to list of "quirky" printers
This patch gets the Kyocera FS-820 working with cups 1.2 via usb again. It
adds the printer to the list of "quirky" printers. The printer seems not
answer to ID requests some seconds after plugging in. Patch is based on
linux-2.6.19.1.

Background:
As far as I could see (strace, usbmon), the Kyocera FS-820 answers to ID
requests only a few seconds after plugging it in. This applies to detecting
it with cups and is also true for the printing itself, which is initiated
with an ID request. Since I have little usb knowledge, maybe someone can
interpret the data, especially the fist bulk transfer - why request 8192
bytes? This is the second version of the patch.

usbmon output of printing an email without patch:
tail -F /tmp/printlog.txt
c636e140 3374734463 S Bi:002:02 -115 8192 <
c9d43b40 3374734494 S Ci:002:00 s a1 00 0000 0000 03ff 1023 <
c9d43b40 3379732301 C Ci:002:00 -104 0
c636e140 3379733294 C Bi:002:02 -2 0
[...repeating...]

with patch:
tail -F /tmp/printlog.txt
d9cb82c0 3729790131 S Ci:002:00 s a1 00 0000 0000 03ff 1023 <
d9cb82c0 3729791725 C Ci:002:00 0 91 = 005b4944 3a46532d 3832303b 4d46473a
 4b796f63 6572613b 434d443a 50434c58 df956320 3732493190 S Bo:002:01 -115
 1347 = 1b252d31 32333435 5840504a 4c0a4050 4a4c2053 4554204d 414e5541
 4c464545 [...more data...]

Signed-off-by: Martin Williges <kernel@zut.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-01-05 12:19:10 -08:00
Oliver Neukum 8e42266965 USB: mutexification of usblp
this patch:
- converts usblp fully to mutex
- makes sleeping interruptible where EINTR can be returned anyway

Signed-off-by: Oliver Neukum <oliver@neukum.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-12-20 10:13:23 -08:00
Alan Cox 606d099cdd [PATCH] tty: switch to ktermios
This is the grungy swap all the occurrences in the right places patch that
goes with the updates.  At this point we have the same functionality as
before (except that sgttyb() returns speeds not zero) and are ready to
begin turning new stuff on providing nobody reports lots of bugs

If you are a tty driver author converting an out of tree driver the only
impact should be termios->ktermios name changes for the speed/property
setting functions from your upper layers.

If you are implementing your own TCGETS function before then your driver
was broken already and its about to get a whole lot more painful for you so
please fix it 8)

Also fill in c_ispeed/ospeed on init for most devices, although the current
code will do this for you anyway but I'd like eventually to lose that extra
paranoia

[akpm@osdl.org: bluetooth fix]
[mp3@de.ibm.com: sclp fix]
[mp3@de.ibm.com: warning fix for tty3270]
[hugh@veritas.com: fix tty_ioctl powerpc build]
[jdike@addtoit.com: uml: fix ->set_termios declaration]
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Martin Peschke <mp3@de.ibm.com>
Acked-by: Peter Oberparleiter <oberpar@de.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-08 08:28:57 -08:00
David Howells 4c1ac1b491 Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts:

	drivers/infiniband/core/iwcm.c
	drivers/net/chelsio/cxgb2.c
	drivers/net/wireless/bcm43xx/bcm43xx_main.c
	drivers/net/wireless/prism54/islpci_eth.c
	drivers/usb/core/hub.h
	drivers/usb/input/hid-core.c
	net/core/netpoll.c

Fix up merge failures with Linus's head and fix new compilation failures.

Signed-Off-By: David Howells <dhowells@redhat.com>
2006-12-05 14:37:56 +00:00
Luiz Fernando N. Capitulino 45aea704d1 USB: cdc-acm: Use usb_endpoint_* functions
Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-12-01 14:23:28 -08:00
David Howells c4028958b6 WorkStruct: make allyesconfig
Fix up for make allyesconfig.

Signed-Off-By: David Howells <dhowells@redhat.com>
2006-11-22 14:57:56 +00:00
Oliver Neukum 5a69ebe1e9 USB: usblp: fix system suspend for some systems
this has been confirmed to fix suspend problems with usblp.

Signed-off-by: Oliver Neukum <oliver@neukum.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-11-03 11:57:18 -08:00
Oliver Neukum 6c8df79f8c USB: failure in usblp's error path
if urb submission fails due to a transient error here eg. ENOMEM
, the driver is dead. This fixes it.

	Regards
		Oliver

Signed-off-by: Oliver Neukum <oliver@neukum.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-11-03 11:57:18 -08:00
Oliver Neukum 516077c1ee USB: fix suspend support for usblp
this implements suspend support for usblp. According to the CUPS people
ENODEV will make CUPS retry the job. Thus it is returned in the runtime
case. My printer survives suspend/resume cycles with it.

Signed-off-by: Oliver Neukum <oliver@neukum.name>
Signed-off-by: Vojtech Pavlik <vojtech@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-10-17 14:46:31 -07:00
Jarek Poplawski 762f007b05 USB: fix cdc-acm problems with hard irq? (inconsistent lock state)
Signed-off-by: Jarek Poplawski <jarkao2@o2.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-10-17 14:46:31 -07:00
Chris Malley 91a9c9214e USB: Support for BT On-Air USB modem in cdc-acm.c
The patch below is a necessary workaround to support the BT On-Air USB modem, which
fails to initialise properly during normal probing thus:

Sep 30 17:34:57 sled kernel: drivers/usb/class/cdc-acm.c: Zero length descriptor references
Sep 30 17:34:57 sled kernel: cdc_acm: probe of 1-1.2:1.0 failed with error -22

Adding the patch below causes the probing section to be skipped, and the modem
then initialises correctly.

Signed-off-by: Chris Malley <mail@chrismalley.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-10-17 14:46:30 -07:00
David Howells 7d12e780e0 IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.

The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around.  On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).

Where appropriate, an arch may override the generic storage facility and do
something different with the variable.  On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.

Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions.  Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller.  A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.

I've build this code with allyesconfig for x86_64 and i386.  I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.

This will affect all archs.  Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:

	struct pt_regs *old_regs = set_irq_regs(regs);

And put the old one back at the end:

	set_irq_regs(old_regs);

Don't pass regs through to generic_handle_irq() or __do_IRQ().

In timer_interrupt(), this sort of change will be necessary:

	-	update_process_times(user_mode(regs));
	-	profile_tick(CPU_PROFILING, regs);
	+	update_process_times(user_mode(get_irq_regs()));
	+	profile_tick(CPU_PROFILING);

I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().

Some notes on the interrupt handling in the drivers:

 (*) input_dev() is now gone entirely.  The regs pointer is no longer stored in
     the input_dev struct.

 (*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking.  It does
     something different depending on whether it's been supplied with a regs
     pointer or not.

 (*) Various IRQ handler function pointers have been moved to type
     irq_handler_t.

Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 15:10:12 +01:00
Jeff Dike b68e31d0eb [PATCH] const struct tty_operations
As part of an SMP cleanliness pass over UML, I consted a bunch of
structures in order to not have to document their locking.  One of these
structures was a struct tty_operations.  In order to const it in UML
without introducing compiler complaints, the declaration of
tty_set_operations needs to be changed, and then all of its callers need to
be fixed.

This patch declares all struct tty_operations in the tree as const.  In all
cases, they are static and used only as input to tty_set_operations.  As an
extra check, I ran an i386 allyesconfig build which produced no extra
warnings.

53 drivers are affected.  I checked the history of a bunch of them, and in
most cases, there have been only a handful of maintenance changes in the
last six months.  serial_core.c was the busiest one that I looked at.

Signed-off-by: Jeff Dike <jdike@addtoit.com>
Acked-by: Alan Cox <alan@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-10-02 07:57:14 -07:00
Greg Kroah-Hartman 96cede531c USB: fix __must_check warnings in drivers/usb/class/
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-09-27 11:58:58 -07:00