Commit graph

361827 commits

Author SHA1 Message Date
Johan Hovold 128434ab56 USB: mct_u232: switch to generic TIOCMIWAIT implementation
Switch to the generic TIOCMIWAIT implementation.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Also remove the redundant wake-up call from dtr_rts.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Remove some out-commented bogus code while at it.

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:42:13 -07:00