History log of /linux-master/drivers/usb/serial/usb_wwan.c
Revision Date Author Comments
# 688ee1d1 25-Jul-2022 Johan Hovold <johan@kernel.org>

USB: serial: fix tty-port initialized comments

Fix up the tty-port initialized comments which got truncated and
obfuscated when replacing the old ASYNCB_INITIALIZED flag.

Fixes: d41861ca19c9 ("tty: Replace ASYNC_INITIALIZED bit and update atomically")
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>


# d5e22360 25-Jul-2022 Yan Xinyu <sdlyyxy@bupt.edu.cn>

USB: serial: usb_wwan: replace DTR/RTS magic numbers with macros

The usb_wwan_send_setup function generates DTR/RTS signals in compliance
with CDC ACM standard. This patch changes magic numbers in this function
to equivalent macros.

Link: https://lore.kernel.org/r/20220722085040.704885-1-sdlyyxy@bupt.edu.cn
[ johan: use the new CDC control-line defines ]
Signed-off-by: Yan Xinyu <sdlyyxy@bupt.edu.cn>
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20220725075841.1187-8-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4ac56b1f 07-Mar-2022 Colin Ian King <colin.king@intel.com>

USB: serial: usb_wwan: remove redundant assignment to variable i

Variable i is being assigned a value that is never read, it is being
re-assigned two statements later in a for-loop. The assignment is
redundant and can be removed.

Cleans up clang scan build warning:
drivers/usb/serial/usb_wwan.c:151:2: warning: Value stored to 'i'
is never read [deadcode.DeadStores]

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>


# 155591d3 05-May-2021 Jiri Slaby <jirislaby@kernel.org>

USB: serial: make usb_serial_driver::chars_in_buffer return uint

tty_operations::chars_in_buffer is being switched to return uint. Do the
same for usb_serial_driver's chars_in_buffer.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
[ johan: amend commit message ]
Signed-off-by: Johan Hovold <johan@kernel.org>


# 94cc7aea 05-May-2021 Jiri Slaby <jirislaby@kernel.org>

USB: serial: make usb_serial_driver::write_room return uint

Line disciplines expect a positive value or zero returned from
tty->ops->write_room (invoked by tty_write_room). Both of them are being
updated to return an unsigned int. Switch also
usb_serial_driver::write_room and all its users.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
[ johan: amend commit message, drop unrelated comment change ]
Signed-off-by: Johan Hovold <johan@kernel.org>


# 01fd45f6 06-Apr-2021 Johan Hovold <johan@kernel.org>

USB: serial: add generic support for TIOCSSERIAL

TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
serial devices is only useful for setting the close_delay and
closing_wait parameters.

The closing_wait parameter determines how long to wait for the transfer
buffers to drain during close and the default timeout of 30 seconds may
not be sufficient at low line speeds. In other cases, when for example
flow is stopped, the default timeout may instead be too long.

Add generic support for TIOCSSERIAL and TIOCGSERIAL with handling of the
three common parameters close_delay, closing_wait and line for the
benefit of all USB serial drivers while still allowing drivers to
implement further functionality through the existing callbacks.

This currently includes a few drivers that report their base baud clock
rate even if that is really only of interest when setting custom
divisors through the deprecated ASYNC_SPD_CUST interface; an interface
which only the FTDI driver actually implements.

Some drivers have also been reporting back a fake UART type, something
which should no longer be needed and will be dropped by a follow-on
patch.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>


# b6be5562 06-Apr-2021 Johan Hovold <johan@kernel.org>

USB: serial: usb_wwan: fix TIOCGSERIAL implementation

TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
serial devices is only useful for setting the close_delay and
closing_wait parameters.

The port parameter is used to set the I/O port and does not make any
sense to use for USB serial devices.

The baud_base parameter could be used to set the UART base clock when it
could not be detected but might as well be left unset when it is not
known.

Fix the usb_wwan TIOCGSERIAL implementation by dropping its custom
interpretation of the unused port and baud_base fields, which were set
to the port index and current line speed, respectively.

Fixes: 02303f73373a ("usb-wwan: implement TIOCGSERIAL and TIOCSSERIAL to avoid blocking close(2)")
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>


# a3cb01e2 06-Apr-2021 Johan Hovold <johan@kernel.org>

USB: serial: usb_wwan: fix unprivileged TIOCCSERIAL

TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
serial devices is only useful for setting the close_delay and
closing_wait parameters.

A non-privileged user has only ever been able to set the since long
deprecated ASYNC_SPD flags and trying to change any other *supported*
feature should result in -EPERM being returned. Setting the current
values for any supported features should return success.

Fix the usb_wwan implementation which instead indicated that the
TIOCSSERIAL ioctl was not even implemented when a non-privileged user
set the current values.

Fixes: 02303f73373a ("usb-wwan: implement TIOCGSERIAL and TIOCSSERIAL to avoid blocking close(2)")
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>


# 3d732690 06-Apr-2021 Johan Hovold <johan@kernel.org>

USB: serial: usb_wwan: fix TIOCSSERIAL jiffies conversions

The port close_delay and closing_wait parameters set by TIOCSSERIAL are
specified in jiffies and not milliseconds.

Add the missing conversions so that the TIOCSSERIAL works as expected
also when HZ is not 1000.

Fixes: 02303f73373a ("usb-wwan: implement TIOCGSERIAL and TIOCSSERIAL to avoid blocking close(2)")
Cc: stable@vger.kernel.org # 2.6.38
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>


# c5d1448f 08-Feb-2021 Uwe Kleine-König <uwe@kleine-koenig.org>

USB: serial: make remove callback return void

All usb_serial drivers return 0 in their remove callbacks and driver
core ignores the value returned by usb_serial_device_remove(). So change
the remove callback to return void and return 0 unconditionally in
usb_serial_device_remove().

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Link: https://lore.kernel.org/r/20210208143149.963644-2-uwe@kleine-koenig.org
Signed-off-by: Johan Hovold <johan@kernel.org>


# 986c1748 13-May-2020 Bin Liu <b-liu@ti.com>

USB: serial: usb_wwan: do not resubmit rx urb on fatal errors

usb_wwan_indat_callback() shouldn't resubmit rx urb if the previous urb
status is a fatal error. Or the usb controller would keep processing the
new urbs then run into interrupt storm, and has no chance to recover.

Fixes: 6c1ee66a0b2b ("USB-Serial: Fix error handling of usb_wwan")
Cc: stable@vger.kernel.org
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Johan Hovold <johan@kernel.org>


# 2438c3a1 19-Dec-2019 Daniele Palmas <dnlplm@gmail.com>

USB: serial: option: add ZLP support for 0x1bc7/0x9010

Telit FN980 flashing device 0x1bc7/0x9010 requires zero packet
to be sent if out data size is is equal to the endpoint max size.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
[ johan: switch operands in conditional ]
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>


# 15cc7bad 12-Sep-2018 Al Viro <viro@zeniv.linux.org.uk>

usb_wwan: switch to ->[sg]et_serial()

Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# a323f946 23-Jun-2018 John Ogness <john.ogness@linutronix.de>

USB: serial: usb_wwan: use irqsave() in USB's complete callback

The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>


# 627cfa89 03-Nov-2017 Johan Hovold <johan@kernel.org>

USB: serial: fix module-license macros

Several GPL-2.0 drivers used "GPL" rather than "GPL v2" in their
MODULE_LICENSE macros; fix the macros to match the licenses.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6ca98bc2 02-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: serial: Remove redundant license text

Now that the SPDX tag is in all USB files, that identifies the license
in a specific and legally-defined manner. So the extra GPL text wording
can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text. And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5fd54ace 03-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: add SPDX identifiers to all remaining files in drivers/usb/

It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Update the drivers/usb/ and include/linux/usb* files with the correct
SPDX license identifier based on the license text in the file itself.
The SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2fbd69c4 08-Nov-2016 Johan Hovold <johan@kernel.org>

USB: serial: fix invalid user-pointer checks

Drop invalid user-pointer checks from ioctl handlers.

A NULL-pointer can be valid in user space and copy_to_user() takes care
of sanity checking.

Signed-off-by: Johan Hovold <johan@kernel.org>


# d41861ca 09-Apr-2016 Peter Hurley <peter@hurleysoftware.com>

tty: Replace ASYNC_INITIALIZED bit and update atomically

Replace ASYNC_INITIALIZED bit in the tty_port::flags field with
TTY_PORT_INITIALIZED bit in the tty_port::iflags field. Introduce helpers
tty_port_set_initialized() and tty_port_initialized() to abstract
atomic bit ops.

Note: the transforms for test_and_set_bit() and test_and_clear_bit()
are unnecessary as the state transitions are already mutually exclusive;
the tty lock prevents concurrent open/close/hangup.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 669e729f 15-Sep-2015 David Ward <david.ward@ll.mit.edu>

USB: usb_wwan/option: generalize option_send_setup for other drivers

Only the option driver implements the send_setup callback; it uses the
SET_CONTROL_LINE_STATE request in CDC ACM to generate DTR/RTS signals
on the port. This is not driver-specific though and is needed by other
drivers, so move the function to the usb_wwan driver (with formatting
tweaks), and replace the callback pointer with a flag that enables the
request.

Suggested-by: Bjørn Mork <bjorn@mork.no>
Suggested-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David Ward <david.ward@ll.mit.edu>
Signed-off-by: Johan Hovold <johan@kernel.org>


# d2958d1b 17-Aug-2015 Johan Hovold <johan@kernel.org>

USB: usb_wwan: silence read errors on disconnect

Silence read-urb resubmission errors when the device is going away.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b0a9aa6d 26-May-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: do not resume I/O on closing ports

Use tty-port initialised flag rather than private flag to determine when
port is closing down.

Since the tty-port flag is set prior to dropping DTR/RTS (when HUPCL is
set) this avoid submitting the read urbs when resuming the interface in
dtr_rts() only to immediately kill them again in shutdown().

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8bb7ec65 26-May-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: report failed submissions as errors

Promote failed-submission messages in open() and write() to error log
level.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7d5dddda 26-May-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: remove some superfluous comments

Remove some more outdated or superfluous comments.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9fdf7063 26-May-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: remove comment from close

Remove superfluous and cryptic comment from close.

It should be obvious that we're balancing the autopm_put in open (and
that operation already mentions the autopm_get done in the USB serial
core).

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3362c91c 26-May-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: clean up delayed-urb submission

Clean up and rename delay-urb submission function using a more
descriptive name.

Also add comment on locking assumptions.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 37357ca5 26-May-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: use interface-data accessors

Use usb_get_serial_data() rather than accessing the private pointer
directly.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b0f9d003 26-May-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: make resume error messages uniform

Make resume error messages uniform.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ae75c940 26-May-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: kill interrupt urb explicitly at suspend

As the port interrupt URB is submitted by the subdriver at open, we
should also kill it explicitly at suspend (even though this will be
taken care of by USB serial core otherwise).

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2b4aceab 26-May-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: remove redundant urb kill from port remove

Remove redundant usb_kill_urb from port remove, which is called
post-shutdown (close).

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a427c179 26-May-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: remove unimplemented set_termios

The driver does not implement set_termios so the operation can be left
unset (tty will do the tty_termios_copy_hw for us).

Note that the send_setup call is bogus as it really only sets DTR/RTS
to their current values.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 02803542 26-May-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: remove redundant modem-control request

The tty-port implementation has already made sure that DTR/RTS have been
raised by calling dtr_rts so remove the redundant call from open.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c1c01803 26-May-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: fix remote wakeup

Make sure that needs_remote_wake up is always set when there are open
ports.

Currently close() would unconditionally set needs_remote_wakeup to 0
even though there might still be open ports. This could lead to blocked
input and possibly dropped data on devices that do not support remote
wakeup (and which must therefore not be runtime suspended while open).

Add an open_ports counter (protected by the susp_lock) and only clear
needs_remote_wakeup when the last port is closed.

Note that there are currently no multi-port drivers using the usb_wwan
implementation.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7436f412 26-May-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: fix discarded writes on resume errors

There's no reason not to try sending off any further delayed write urbs,
should one urb-submission fail.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# fb7ad4f9 26-May-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: fix potential blocked I/O after resume

Keep trying to submit urbs rather than bail out on first read-urb
submission error, which would also prevent I/O for any further ports
from being resumed.

Instead keep an error count, for all types of failed submissions, and
let USB core know that something went wrong.

Also make sure to always clear the suspended flag. Currently a failed
read-urb submission would prevent cached writes as well as any
subsequent writes from being submitted until next suspend-resume cycle,
something which may not even necessarily happen.

Note that USB core currently only logs an error if an interface resume
failed.

Fixes: 383cedc3bb43 ("USB: serial: full autosuspend support for the
option driver")

Cc: <stable@vger.kernel.org> # v2.6.32
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9096f1fb 26-May-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: fix potential NULL-deref at resume

The interrupt urb was submitted unconditionally at resume, something
which could lead to a NULL-pointer dereference in the urb completion
handler as resume may be called after the port and port data is gone.

Fix this by making sure the interrupt urb is only submitted and active
when the port is open.

Fixes: 383cedc3bb43 ("USB: serial: full autosuspend support for the
option driver")

Cc: <stable@vger.kernel.org> # v2.6.32: 032129cb03df
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 79eed03e 26-May-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: fix urb leak at shutdown

The delayed-write queue was never emptied at shutdown (close), something
which could lead to leaked urbs if the port is closed before being
runtime resumed due to a write.

When this happens the output buffer would not drain on close
(closing_wait timeout), and after consecutive opens, writes could be
corrupted with previously buffered data, transfered with reduced
throughput or completely blocked.

Note that unbusy_queued_urb() was simply moved out of CONFIG_PM.

Fixes: 383cedc3bb43 ("USB: serial: full autosuspend support for the
option driver")

Cc: <stable@vger.kernel.org> # v2.6.32
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 170fad9e 26-May-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: fix write and suspend race

Fix race between write() and suspend() which could lead to writes being
dropped (or I/O while suspended) if the device is runtime suspended
while a write request is being processed.

Specifically, suspend() releases the susp_lock after determining the
device is idle but before setting the suspended flag, thus leaving a
window where a concurrent write() can submit an urb.

Fixes: 383cedc3bb43 ("USB: serial: full autosuspend support for the
option driver")

Cc: <stable@vger.kernel.org> # v2.6.32
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d9e93c08 26-May-2014 xiao jin <jin.xiao@intel.com>

USB: usb_wwan: fix race between write and resume

We find a race between write and resume. usb_wwan_resume run play_delayed()
and spin_unlock, but intfdata->suspended still is not set to zero.
At this time usb_wwan_write is called and anchor the urb to delay
list. Then resume keep running but the delayed urb have no chance
to be commit until next resume. If the time of next resume is far
away, tty will be blocked in tty_wait_until_sent during time. The
race also can lead to writes being reordered.

This patch put play_Delayed and intfdata->suspended together in the
spinlock, it's to avoid the write race during resume.

Fixes: 383cedc3bb43 ("USB: serial: full autosuspend support for the
option driver")

Signed-off-by: xiao jin <jin.xiao@intel.com>
Signed-off-by: Zhang, Qi1 <qi1.zhang@intel.com>
Reviewed-by: David Cohen <david.a.cohen@linux.intel.com>
Cc: <stable@vger.kernel.org> # v2.6.32
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# db090473 26-May-2014 xiao jin <jin.xiao@intel.com>

USB: usb_wwan: fix urb leak in write error path

When enable usb serial for modem data, sometimes the tty is blocked
in tty_wait_until_sent because portdata->out_busy always is set and
have no chance to be cleared.

We find a bug in write error path. usb_wwan_write set portdata->out_busy
firstly, then try autopm async with error. No out urb submit and no
usb_wwan_outdat_callback to this write, portdata->out_busy can't be
cleared.

This patch clear portdata->out_busy if usb_wwan_write try autopm async
with error.

Fixes: 383cedc3bb43 ("USB: serial: full autosuspend support for the
option driver")

Signed-off-by: xiao jin <jin.xiao@intel.com>
Signed-off-by: Zhang, Qi1 <qi1.zhang@intel.com>
Reviewed-by: David Cohen <david.a.cohen@linux.intel.com>
Cc: <stable@vger.kernel.org> # v2.6.32
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4e857c58 17-Mar-2014 Peter Zijlstra <peterz@infradead.org>

arch: Mass conversion of smp_mb__*()

Mostly scripted conversion of the smp_mb__* barriers.

Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/n/tip-55dhyhocezdw1dg7u19hmh1u@git.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-arch@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>


# bd73bd88 03-Apr-2014 Johan Hovold <johan@kernel.org>

USB: usb_wwan: fix handling of missing bulk endpoints

Fix regression introduced by commit 8e493ca1767d ("USB: usb_wwan: fix
bulk-urb allocation") by making sure to require both bulk-in and out
endpoints during port probe.

The original option driver (which usb_wwan is based on) was written
under the assumption that either endpoint could be missing, but
evidently this cannot have been tested properly. Specifically, it would
handle opening a device without bulk-in (but would blow up during resume
which was implemented later), but not a missing bulk-out in write()
(although it is handled in some places such as write_room()).

Fortunately (?), the driver also got the test for missing endpoints
wrong so the urbs were in fact always allocated, although they would be
initialised using the wrong endpoint address (0) and any submission of
such an urb would fail.

The commit mentioned above fixed the test for missing endpoints but
thereby exposed the other bugs which would now generate null-pointer
exceptions rather than failed urb submissions.

The regression was introduced in v3.7, but the offending commit was also
marked for stable.

Reported-by: Rafał Miłecki <zajec5@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Tested-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 10c642d0 29-Dec-2013 Johan Hovold <johan@kernel.org>

USB: serial: remove redundant OOM messages

Remove redundant error messages on allocation failures, which have
already been logged.

Cc: Joe Perches <joe@perches.com>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6c1ee66a 12-Aug-2013 Matt Burtch <matt@grid-net.com>

USB-Serial: Fix error handling of usb_wwan

This fixes an issue where the bulk-in urb used for incoming data transfer
is not resubmitted if the packet recieved contains an error status. This
results in the driver locking until the port is closed and re-opened.

Tested on a custom board with a Cinterion GSM module.

Signed-off-by: Matt Burtch <matt@grid-net.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e5b1e206 07-Jun-2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: serial: make minor allocation dynamic

This moves the allocation of minor device numbers from a static array to
be dynamic, using the idr interface. This means that you could
potentially get "gaps" in a minor number range for a single USB serial
device with multiple ports, but all should still work properly.

We remove the 'minor' field from the usb_serial structure, as it no
longer makes any sense for it (use the field in the usb_serial_port
structure if you really want to know this number), and take the fact
that we were overloading a number in this field to determine if we had
initialized the minor numbers or not, and just use a flag variable
instead.

Note, we still have the limitation of 255 USB to serial devices in the
system, as that is all we are registering with the TTY layer at this
point in time.

Tested-by: Tobias Winter <tobias@linuxdingsda.de>
Reviewed-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1143832e 06-Jun-2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: serial: ports: add minor and port number

The usb_serial_port structure had the number field, which was the minor
number for the port, which almost no one really cared about. They
really wanted the number of the port within the device, which you had to
subtract from the minor of the parent usb_serial_device structure. To
clean this up, provide the real minor number of the port, and the number
of the port within the serial device separately, as these numbers might
not be related in the future.

Bonus is that this cleans up a lot of logic in the drivers, and saves
lines overall.

Tested-by: Tobias Winter <tobias@linuxdingsda.de>
Reviewed-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

--
drivers/staging/serqt_usb2/serqt_usb2.c | 21 +++--------
drivers/usb/serial/ark3116.c | 2 -
drivers/usb/serial/bus.c | 6 +--
drivers/usb/serial/console.c | 2 -
drivers/usb/serial/cp210x.c | 2 -
drivers/usb/serial/cypress_m8.c | 4 +-
drivers/usb/serial/digi_acceleport.c | 6 ---
drivers/usb/serial/f81232.c | 5 +-
drivers/usb/serial/garmin_gps.c | 6 +--
drivers/usb/serial/io_edgeport.c | 58 ++++++++++++--------------------
drivers/usb/serial/io_ti.c | 21 ++++-------
drivers/usb/serial/keyspan.c | 29 +++++++---------
drivers/usb/serial/metro-usb.c | 4 +-
drivers/usb/serial/mos7720.c | 37 +++++++++-----------
drivers/usb/serial/mos7840.c | 52 +++++++++-------------------
drivers/usb/serial/opticon.c | 2 -
drivers/usb/serial/pl2303.c | 2 -
drivers/usb/serial/quatech2.c | 7 +--
drivers/usb/serial/sierra.c | 2 -
drivers/usb/serial/ti_usb_3410_5052.c | 10 ++---
drivers/usb/serial/usb-serial.c | 7 ++-
drivers/usb/serial/usb_wwan.c | 2 -
drivers/usb/serial/whiteheat.c | 20 +++++------
include/linux/usb/serial.h | 6 ++-
24 files changed, 133 insertions(+), 180 deletions(-)


# e6d144bc 20-Mar-2013 Johan Hovold <johan@kernel.org>

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>


# b2ca6990 13-Feb-2013 Johan Hovold <johan@kernel.org>

USB: serial: fix null-pointer dereferences on disconnect

Make sure serial-driver dtr_rts is called with disc_mutex held after
checking the disconnected flag.

Due to a bug in the tty layer, dtr_rts may get called after a device has
been disconnected and the tty-device unregistered. Some drivers have had
individual checks for disconnect to make sure the disconnected interface
was not accessed, but this should really be handled in usb-serial core
(at least until the long-standing tty-bug has been fixed).

Note that the problem has been made more acute with commit 0998d0631001
("device-core: Ensure drvdata = NULL when no driver is bound") as the
port data is now also NULL when dtr_rts is called resulting in further
oopses.

Reported-by: Chris Ruehl <chris.ruehl@gtsys.com.hk>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2e124b4a 03-Jan-2013 Jiri Slaby <jirislaby@kernel.org>

TTY: switch tty_flip_buffer_push

Now, we start converting tty buffer functions to actually use
tty_port. This will allow us to get rid of the need of tty in many
call sites. Only tty_port will needed and hence no more
tty_port_tty_get in those paths.

Now, the one where most of tty_port_tty_get gets removed:
tty_flip_buffer_push.

IOW we also closed all the races in drivers not using tty_port_tty_get
at all yet.

Also we move tty_flip_buffer_push declaration from include/linux/tty.h
to include/linux/tty_flip.h to all others while we are changing it
anyway.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 05c7cd39 03-Jan-2013 Jiri Slaby <jirislaby@kernel.org>

TTY: switch tty_insert_flip_string

Now, we start converting tty buffer functions to actually use
tty_port. This will allow us to get rid of the need of tty in many
call sites. Only tty_port will needed and hence no more
tty_port_tty_get in those paths.

tty_insert_flip_string this time.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# bcbec053 31-Oct-2012 Johan Hovold <johan@kernel.org>

USB: serial: remove driver version information

Remove all MODULE_VERSION macros and driver-version information (except
for garmin_gps which uses it in a status reply).

It is the kernel version that matters and not some private version
scheme which rarely even gets updated.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8e493ca1 26-Oct-2012 Johan Hovold <johan@kernel.org>

USB: usb_wwan: fix bulk-urb allocation

Make sure we do not allocate urbs if we do not have a bulk endpoint.

Legacy code used incorrect assumption to test for bulk endpoints.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b8f0e820 25-Oct-2012 Johan Hovold <johan@kernel.org>

USB: usb-wwan: fix multiple memory leaks in error paths

Fix port-data memory leak in usb-serial probe error path by moving port
data allocation to port_probe.

Since commit a1028f0abf ("usb: usb_wwan: replace release and disconnect
with a port_remove hook") port data is deallocated in port_remove. This
leaves a possibility for memory leaks if usb-serial probe fails after
attach but before the port in question has been successfully registered.

Note that this patch also fixes two additional memory leaks in the error
path of attach should port initialisation fail for any port as the urbs
were never freed and neither was the data of any of the successfully
initialised ports.

Compile-only tested.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 061b2a22 14-Sep-2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: serial: usb_wwan.c: remove debug module parameter

Now that the dbg() macro is no longer being used in the driver,
the debug module parameter doesn't do anything at all. So remove
it so as to not confuse people.

CC: "Bjørn Mork" <bjorn@mork.no>
CC: Rusty Russell <rusty@rustcorp.com.au>
CC: Mauro Carvalho Chehab <mchehab@redhat.com>
CC: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a80be97d 13-Sep-2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: serial: usb_wwan.c: remove dbg() usage

dbg() was a very old USB-serial-specific macro.
This patch removes it from being used in the
driver and uses dev_dbg() instead.

CC: "Bjørn Mork" <bjorn@mork.no>
CC: Rusty Russell <rusty@rustcorp.com.au>
CC: Mauro Carvalho Chehab <mchehab@redhat.com>
CC: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 032129cb 26-Jul-2012 Bjørn Mork <bjorn@mork.no>

usb: usb_wwan: resume/suspend can be called after port is gone

We cannot unconditionally access any usb-serial port specific
data from the interface driver. Both supending and resuming
may happen after the port has been removed and portdata is
freed.

Treat ports with no portdata as closed ports to avoid a NULL
pointer dereference on resume. No need to kill URBs for
removed ports on suspend, avoiding the same NULL pointer
reference there.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a1028f0a 26-Jul-2012 Bjørn Mork <bjorn@mork.no>

usb: usb_wwan: replace release and disconnect with a port_remove hook

Doing port specific cleanup in the .port_remove hook is a
lot simpler and safer than doing it in the USB driver
.release or .disconnect methods. The removal of the port
from the usb-serial bus will happen before the USB driver
cleanup, so we must be careful about accessing port specific
driver data from any USB driver functions.

This problem surfaced after the commit

0998d0631 device-core: Ensure drvdata = NULL when no driver is bound

which turned the previous unsafe access into a reliable NULL
pointer dereference.

Fixes the following Oops:

[ 243.148471] BUG: unable to handle kernel NULL pointer dereference at (null)
[ 243.148508] IP: [<ffffffffa0468527>] stop_read_write_urbs+0x37/0x80 [usb_wwan]
[ 243.148556] PGD 79d60067 PUD 79d61067 PMD 0
[ 243.148590] Oops: 0000 [#1] SMP
[ 243.148617] Modules linked in: sr_mod cdrom qmi_wwan usbnet option cdc_wdm usb_wwan usbserial usb_storage uas fuse af_packet ip6table_filter ip6_tables iptable_filter ip_tables x_tables tun edd
cpufreq_conservative cpufreq_userspace cpufreq_powersave snd_pcm_oss snd_mixer_oss acpi_cpufreq snd_seq mperf snd_seq_device coretemp arc4 sg hp_wmi sparse_keymap uvcvideo videobuf2_core
videodev videobuf2_vmalloc videobuf2_memops rtl8192ce rtl8192c_common rtlwifi joydev pcspkr microcode mac80211 i2c_i801 lpc_ich r8169 snd_hda_codec_idt cfg80211 snd_hda_intel snd_hda_codec rfkill
snd_hwdep snd_pcm wmi snd_timer ac snd soundcore snd_page_alloc battery uhci_hcd i915 drm_kms_helper drm i2c_algo_bit ehci_hcd thermal usbcore video usb_common button processor thermal_sys
[ 243.149007] CPU 1
[ 243.149027] Pid: 135, comm: khubd Not tainted 3.5.0-rc7-next-20120720-1-vanilla #1 Hewlett-Packard HP Mini 110-3700 /1584
[ 243.149072] RIP: 0010:[<ffffffffa0468527>] [<ffffffffa0468527>] stop_read_write_urbs+0x37/0x80 [usb_wwan]
[ 243.149118] RSP: 0018:ffff880037e75b30 EFLAGS: 00010286
[ 243.149133] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff88005912aa28
[ 243.149150] RDX: ffff88005e95f028 RSI: 0000000000000000 RDI: ffff88005f7c1a10
[ 243.149166] RBP: ffff880037e75b60 R08: 0000000000000000 R09: ffffffff812cea90
[ 243.149182] R10: 0000000000000000 R11: 0000000000000001 R12: ffff88006539b440
[ 243.149198] R13: ffff88006539b440 R14: 0000000000000000 R15: 0000000000000000
[ 243.149216] FS: 0000000000000000(0000) GS:ffff88007ee80000(0000) knlGS:0000000000000000
[ 243.149233] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[ 243.149248] CR2: 0000000000000000 CR3: 0000000079fe0000 CR4: 00000000000007e0
[ 243.149264] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 243.149280] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[ 243.149298] Process khubd (pid: 135, threadinfo ffff880037e74000, task ffff880037d40600)
[ 243.149313] Stack:
[ 243.149323] ffff880037e75b40 ffff88006539b440 ffff8800799bc830 ffff88005f7c1800
[ 243.149348] 0000000000000001 ffff88006539b448 ffff880037e75b70 ffffffffa04685e9
[ 243.149371] ffff880037e75bc0 ffffffffa0473765 ffff880037354988 ffff88007b594800
[ 243.149395] Call Trace:
[ 243.149419] [<ffffffffa04685e9>] usb_wwan_disconnect+0x9/0x10 [usb_wwan]
[ 243.149447] [<ffffffffa0473765>] usb_serial_disconnect+0xd5/0x120 [usbserial]
[ 243.149511] [<ffffffffa0046b48>] usb_unbind_interface+0x58/0x1a0 [usbcore]
[ 243.149545] [<ffffffff8139ebd7>] __device_release_driver+0x77/0xe0
[ 243.149567] [<ffffffff8139ec67>] device_release_driver+0x27/0x40
[ 243.149587] [<ffffffff8139e5cf>] bus_remove_device+0xdf/0x150
[ 243.149608] [<ffffffff8139bc78>] device_del+0x118/0x1a0
[ 243.149661] [<ffffffffa0044590>] usb_disable_device+0xb0/0x280 [usbcore]
[ 243.149718] [<ffffffffa003c6fd>] usb_disconnect+0x9d/0x140 [usbcore]
[ 243.149770] [<ffffffffa003da7d>] hub_port_connect_change+0xad/0x8a0 [usbcore]
[ 243.149825] [<ffffffffa0043bf5>] ? usb_control_msg+0xe5/0x110 [usbcore]
[ 243.149878] [<ffffffffa003e6e3>] hub_events+0x473/0x760 [usbcore]
[ 243.149931] [<ffffffffa003ea05>] hub_thread+0x35/0x1d0 [usbcore]
[ 243.149955] [<ffffffff81061960>] ? add_wait_queue+0x60/0x60
[ 243.150004] [<ffffffffa003e9d0>] ? hub_events+0x760/0x760 [usbcore]
[ 243.150026] [<ffffffff8106133e>] kthread+0x8e/0xa0
[ 243.150047] [<ffffffff8157ec04>] kernel_thread_helper+0x4/0x10
[ 243.150068] [<ffffffff810612b0>] ? flush_kthread_work+0x120/0x120
[ 243.150088] [<ffffffff8157ec00>] ? gs_change+0xb/0xb
[ 243.150101] Code: fd 41 54 53 48 83 ec 08 80 7f 1a 00 74 57 49 89 fc 31 db 90 49 8b 7c 24 20 45 31 f6 48 81 c7 10 02 00 00 e8 bc 64 f3 e0 49 89 c7 <4b> 8b 3c 37 49 83 c6 08 e8 4c a5 bd ff 49 83 fe 20
75 ed 45 30
[ 243.150257] RIP [<ffffffffa0468527>] stop_read_write_urbs+0x37/0x80 [usb_wwan]
[ 243.150282] RSP <ffff880037e75b30>
[ 243.150294] CR2: 0000000000000000
[ 243.177170] ---[ end trace fba433d9015ffb8c ]---

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reported-by: Thomas Schäfer <tschaefer@t-online.de>
Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# adc8d746 14-Jul-2012 Alan Cox <alan@linux.intel.com>

tty: move the termios object into the tty

This will let us sort out a whole pile of tty related races. The
alternative would be to keep points and refcount the termios objects.
However
1. They are tiny anyway
2. Many devices don't use the stored copies
3. We can remove a pty special case

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d2bad781 03-May-2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: usb_wwan.c: remove dbg() tracing calls

dbg() was used a lot a long time ago to trace code flow. Now that we have
ftrace, this isn't needed at all, so remove these calls.

CC: Rusty Russell <rusty@rustcorp.com.au>
CC: Alan Stern <stern@rowland.harvard.edu>
CC: Mauro Carvalho Chehab <mchehab@redhat.com>
CC: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ec42899c 20-Apr-2012 Dan Carpenter <dan.carpenter@oracle.com>

USB: wwan: remove an unneeded check

We already verified that "status" was zero on this else branch. Since
zero is not equal to -ESHUTDOWN, this condition is always true. I
removed it and pull everything in an indent level.

This doesn't change how the code works, it's just a cleanup.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3a1c2a82 20-Apr-2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: usb_wwan.c: remove err() usage

err() was a very old USB-specific macro that I thought had
gone away. This patch removes it from being used in the
driver and uses dev_err() instead.

CC: Rusty Russell <rusty@rustcorp.com.au>
CC: Alan Stern <stern@rowland.harvard.edu>
CC: Mauro Carvalho Chehab <mchehab@redhat.com>
CC: "Rafael J. Wysocki" <rjw@sisk.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 90ab5ee9 12-Jan-2012 Rusty Russell <rusty@rustcorp.com.au>

module_param: make bool parameters really bool (drivers & misc)

module_param(bool) used to counter-intuitively take an int. In
fddd5201 (mid-2009) we allowed bool or int/unsigned int using a messy
trick.

It's time to remove the int/unsigned int option. For this version
it'll simply give a warning, but it'll break next kernel version.

Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>


# 5b1b0b81 19-Aug-2011 Alan Stern <stern@rowland.harvard.edu>

PM / Runtime: Add macro to test for runtime PM events

This patch (as1482) adds a macro for testing whether or not a
pm_message value represents an autosuspend or autoresume (i.e., a
runtime PM) event. Encapsulating this notion seems preferable to
open-coding the test all over the place.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>


# 97ac01d8 17-Mar-2011 Oliver Neukum <oliver@neukum.org>

usb: wwan: fix compilation without CONFIG_PM_RUNTIME

The pm usage counter must be accessed with the proper wrappers
to allow compilation under all configurations.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Reported-by: Tao Ma <boyu.mt@taobao.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 00a0d0d6 14-Feb-2011 Alan Cox <alan@linux.intel.com>

tty: remove filp from the USB tty ioctls

We don't use it so we can trim it from here as we try and stamp the file
object dependencies out of the serial code.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 20b9d177 14-Feb-2011 Alan Cox <alan@linux.intel.com>

tiocmset: kill the file pointer argument

Doing tiocmget was such fun we should do tiocmset as well for the same
reasons

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 60b33c13 14-Feb-2011 Alan Cox <alan@linux.intel.com>

tiocmget: kill off the passing of the struct file

We don't actually need this and it causes problems for internal use of
this functionality. Currently there is a single use of the FILE * pointer.
That is the serial core which uses it to check tty_hung_up_p. However if
that is true then IO_ERROR is also already set so the check may be removed.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 9a91aedc 10-Feb-2011 Oliver Neukum <oliver@neukum.org>

usb_wwan: fix error case in close()

The device never needs to be resumed in close(). But the counters
must be balanced. As resumption can fail, but the counters must
be balanced, use the _no_resume() version which cannot fail.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 16871dca 10-Feb-2011 Oliver Neukum <oliver@neukum.org>

usb_wwan: error case of resume

If an error happens during resumption.
The remaining data has to be cleanly discarded and the pm
counters have to be adjusted.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 433508ae 10-Feb-2011 Oliver Neukum <oliver@neukum.org>

usb_wwan: data consistency in error case

As soon as the first error happens, the write must
be stopped, lest we send mutilated messages.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 3d06bf15 10-Feb-2011 Oliver Neukum <oliver@neukum.org>

usb_wwan: fix runtime PM in error case

An error in the write code path would permanently disable
runtime PM in this driver

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# c9c4558f 10-Feb-2011 Oliver Neukum <oliver@neukum.org>

usb_wwan: fix error in marking device busy

This fixes two errors:
- the device is busy if a message was recieved even if resubmission fails
- the device is not busy if resubmission fails due to -EPERM

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 38237fd2 15-Feb-2011 Jiri Slaby <jirislaby@kernel.org>

USB: serial/usb_wwan, fix tty NULL dereference

tty_port_tty_get may return without any problems NULL. Handle this
case and do not oops in usb_wwan_indat_callback by dereferencing it.

The oops:
Unable to handle kernel paging request for data at address 0x000000d8
Faulting instruction address: 0xc0175b3c
Oops: Kernel access of bad area, sig: 11 [#1]
PowerPC 40x Platform
last sysfs file:
/sys/devices/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:09.2/usb1/idVendor
Modules linked in:
NIP: c0175b3c LR: c0175e7c CTR: c0215c90
REGS: c77f7d50 TRAP: 0300 Not tainted (2.6.37-rc5)
MSR: 00021030 <ME,CE,IR,DR> CR: 88482028 XER: 2000005f
DEAR: 000000d8, ESR: 00000000
TASK = c7141b90[1149] 'wvdial' THREAD: c2750000
GPR00: 00021030 c77f7e00 c7141b90 00000000 0000000e 00000000 0000000e c0410680
GPR08: c683db00 00000000 00000001 c03c81f8 88482028 10073ef4 ffffffb9 ffffff94
GPR16: 00000000 fde036c0 00200200 00100100 00000001 ffffff8d c34fabcc 00000000
GPR24: c71120d4 00000000 00000000 0000000e 00021030 00000000 00000000 0000000e
NIP [c0175b3c] tty_buffer_request_room+0x2c/0x194
LR [c0175e7c] tty_insert_flip_string_fixed_flag+0x3c/0xb0
Call Trace:
[c77f7e00] [00000003] 0x3 (unreliable)
[c77f7e30] [c0175e7c] tty_insert_flip_string_fixed_flag+0x3c/0xb0
[c77f7e60] [c0215df4] usb_wwan_indat_callback+0x164/0x170
...

References: https://bugzilla.kernel.org/show_bug.cgi?id=24582
Cc: Amit Shah <amitshah@gmx.net>
Cc: baoyb <baoyb@avit.org.cn>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 66921edd 09-Dec-2010 Peter Huewe <peterhuewe@gmx.de>

USB: serial: usb_wwan: Add missing uaccess.h / fix build failure

This patch fixes a build failure[1] by adding the missing uaccess.h needed
for copy_from_user and copy_to_user

References:
http://kisskb.ellerman.id.au/kisskb/buildresult/3607218/

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 02303f73 19-Nov-2010 Dan Williams <dcbw@redhat.com>

usb-wwan: implement TIOCGSERIAL and TIOCSSERIAL to avoid blocking close(2)

Some devices (ex ZTE 2726) simply don't respond at all when data is sent
to some of their USB interfaces. The data gets stuck in the TTYs queue
and sits there until close(2), which them blocks because closing_wait
defaults to 30 seconds (even though the fd is O_NONBLOCK). This is
rarely desired. Implement the standard mechanism to adjust closing_wait
and let applications handle it how they want to.

Signed-off-by: Dan Williams <dcbw@redhat.com>


# 7f26b3a7 04-Aug-2010 Joe Perches <joe@perches.com>

drivers/usb: Remove unnecessary return's from void functions

Greg prefers this to go through the trivial tree.
http://lkml.org/lkml/2010/6/24/1

There are about 2500 void functions in drivers/usb
Only a few used return; at end of function.

Standardize them a bit.

Moved a statement down a line in drivers/usb/host/u132-hcd.c

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 0d456194 31-Mar-2010 Matthew Garrett <mjg@redhat.com>

usb serial: Add generic USB wwan support

The generic USB serial code is ill-suited for high-speed USB wwan devices,
resulting in the option driver. However, other non-option devices may also
gain similar benefits from not using the generic code. Factorise out the
non-option specific code from the option driver and make it available to
other users.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>