History log of /linux-master/drivers/usb/serial/generic.c
Revision Date Author Comments
# 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>


# eb0c68ea 08-Jul-2020 Johan Hovold <johan@kernel.org>

USB: serial: drop redundant transfer-buffer casts

Drop redundant URB transfer-buffer casts.

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


# 4b5cf2b8 08-Jul-2020 Johan Hovold <johan@kernel.org>

USB: serial: add sysrq break-handler dummy

Add inline sysrq break-handler dummy to allow the compiler to eliminate
further code when either console or sysrq support isn't enabled and to
clearly mark the two sysrq functions as belonging together.

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


# 4fbfbdb5 08-Jul-2020 Johan Hovold <johan@kernel.org>

USB: serial: inline sysrq dummy function

Inline the dummy sysrq character handling when either console support or
magic-sysrq support isn't enabled to allow the compiler to eliminate
unused code.

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


# 8c6a2231 08-Jul-2020 Johan Hovold <johan@kernel.org>

USB: serial: only process sysrq when enabled

Do not set the sysrq timestamp unless CONFIG_MAGIC_SYSRQ is enabled to
avoid unnecessary per-character processing for consoles.

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


# 37ae2315 08-Jul-2020 Johan Hovold <johan@kernel.org>

USB: serial: only set sysrq timestamp for consoles

Only set the sysrq timestamp for console ports to avoid having every
driver also check the console flag when processing incoming data.

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


# 5e95dbb6 25-Feb-2020 Johan Hovold <johan@kernel.org>

USB: serial: clean up carrier-detect helper

Drop the struct tty_port pointer and rename the struct usb_serial_port
pointer "port", which is the named used throughout the subsystem and
incidentally also matches the kernel-doc comment.

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


# 32553441 30-Jan-2020 Johan Hovold <johan@kernel.org>

USB: serial: relax unthrottle memory barrier

Commit a8d78d9f3856 ("USB: serial: clean up throttle handling")
converted the throttle handling to use atomic bitops. This means that we
can relax the smp_mb() in unthrottle() to smp_mb__after_atomic(), which
for example is a no-op on architectures like x86 that provide fully
ordered atomics.

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


# 5b67b10a 25-Apr-2019 Johan Hovold <johan@kernel.org>

USB: serial: drop unnecessary goto

Drop an unnecessary goto from a write-urb completion error path.

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


# a8d78d9f 25-Apr-2019 Johan Hovold <johan@kernel.org>

USB: serial: clean up throttle handling

Clean up the throttle implementation by dropping the redundant
throttle_req flag which was a remnant from back when there was only a
single read URB.

Also convert the throttled flag to an atomic bit flag.

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


# 3f5edd58 25-Apr-2019 Johan Hovold <johan@kernel.org>

USB: serial: fix unthrottle races

Fix two long-standing bugs which could potentially lead to memory
corruption or leave the port throttled until it is reopened (on weakly
ordered systems), respectively, when read-URB completion races with
unthrottle().

First, the URB must not be marked as free before processing is complete
to prevent it from being submitted by unthrottle() on another CPU.

CPU 1 CPU 2
================ ================
complete() unthrottle()
process_urb();
smp_mb__before_atomic();
set_bit(i, free); if (test_and_clear_bit(i, free))
submit_urb();

Second, the URB must be marked as free before checking the throttled
flag to prevent unthrottle() on another CPU from failing to observe that
the URB needs to be submitted if complete() sees that the throttled flag
is set.

CPU 1 CPU 2
================ ================
complete() unthrottle()
set_bit(i, free); throttled = 0;
smp_mb__after_atomic(); smp_mb();
if (throttled) if (test_and_clear_bit(i, free))
return; submit_urb();

Note that test_and_clear_bit() only implies barriers when the test is
successful. To handle the case where the URB is still in use an explicit
barrier needs to be added to unthrottle() for the second race condition.

Fixes: d83b405383c9 ("USB: serial: add support for multiple read urbs")
Signed-off-by: Johan Hovold <johan@kernel.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>


# 6538808c 16-Mar-2017 Johan Hovold <johan@kernel.org>

USB: serial: relax generic driver bulk-endpoint requirement

Relax the generic driver bulk-endpoint requirement. The driver handles
devices without bulk-out endpoints just fine these days.

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


# a794499b 16-Mar-2017 Johan Hovold <johan@kernel.org>

USB: serial: add calc_num_ports callback to generic driver

Add a calc_num_ports callback to the generic driver and verify that the
device has the required endpoints there instead of in core.

Note that the generic driver num_ports field was never used.

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


# 415d7b3a 16-Mar-2017 Johan Hovold <johan@kernel.org>

USB: serial: add probe callback to generic driver

Add a probe callback to the generic driver and print the
only-for-testing message there.

This is a first step in getting rid of the CONFIG_USB_SERIAL_GENERIC
ifdef from usb-serial core.

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


# 174cd4b1 02-Feb-2017 Ingo Molnar <mingo@kernel.org>

sched/headers: Prepare to move signal wakeup & sigpending methods from <linux/sched.h> into <linux/sched/signal.h>

Fix up affected files that include this signal functionality via sched.h.

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>


# 3161da97 14-Jul-2016 Oliver Neukum <oneukum@suse.com>

USB: serial: use variable for status

This patch turns status in a variable read once from the URB.
The long term plan is to deliver status to the callback.
In addition it makes the code a bit more elegant.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
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>


# f528bf4f 04-Mar-2015 Johan Hovold <johan@kernel.org>

USB: serial: fix infinite wait_until_sent timeout

Make sure to handle an infinite timeout (0).

Note that wait_until_sent is currently never called with a 0-timeout
argument due to a bug in tty_wait_until_sent.

Fixes: dcf010503966 ("USB: serial: add generic wait_until_sent
implementation")
Cc: stable <stable@vger.kernel.org> # v3.10

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


# 04f9c6e6 11-Jan-2015 Jeremiah Mahler <jmmahler@gmail.com>

usb: serial: handle -ENODEV quietly in generic_submit_read_urb

If a USB serial device (e.g. /dev/ttyUSB0) with an active program is
unplugged, an -ENODEV (19) error will be produced after it gives up
trying to resubmit a read.

usb_serial_generic_submit_read_urb - usb_submit_urb failed: -19

Add -ENODEV as one of the permanent errors along with -EPERM that
usb_serial_generic_submit_read_urb() handles quietly without an error.

Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>


# aa8e2212 11-Jan-2015 Jeremiah Mahler <jmmahler@gmail.com>

usb: serial: silence all non-critical read errors

If a USB serial device is unplugged while there is an active program
using the device it may spam the logs with -EPROTO (71) messages as it
attempts to retry.

Most serial usb drivers (metro-usb, pl2303, mos7840, ...) only output
these messages for debugging. The generic driver treats these as
errors.

Change the default output for the generic serial driver from error to
debug to silence these non-critical errors.

Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>


# ca0400d2 12-Mar-2014 Johan Hovold <johan@kernel.org>

USB: serial: add missing braces

Add missing braces to conditional branches and one loop in usb-serial
core and generic implementation.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>


# bd58c7bd 12-Mar-2014 Johan Hovold <johan@kernel.org>

USB: serial: continue to write on errors

Do not discard buffered data and make sure to try to resubmit the write
urbs on errors.

Currently a recoverable error would lead to more data than necessary
being dropped.

Also upgrade error messages from debug to error log level.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>


# fc11efe2 12-Mar-2014 Johan Hovold <johan@kernel.org>

USB: serial: continue to read on errors

Make sure to try to resubmit the read urb on errors.

Currently a recoverable error would lead to reduced throughput as only
one urb will be used until the port is closed and reopened (or
resumed or unthrottled).

Also upgrade error messages from debug to error log level.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>


# 043e3f83 08-Nov-2013 Johan Hovold <johan@kernel.org>

USB: serial: fix write memory-allocation flag

Fix regression introduced by commit 818f60365a29 ("USB: serial: add
memory flags to usb_serial_generic_write_start"), which incorrectly used
GFP_KERNEL in write(), which must not not sleep.

Reported-by: Dave Jones <davej@fedoraproject.org>
Tested-by: Dave Jones <davej@fedoraproject.org>
Cc: Dave Jones <davej@fedoraproject.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6f648546 08-Nov-2013 Johan Hovold <johan@kernel.org>

USB: serial: fix race in generic write

Fix race in generic write implementation, which could lead to
temporarily degraded throughput.

The current generic write implementation introduced by commit
27c7acf22047 ("USB: serial: reimplement generic fifo-based writes") has
always had this bug, although it's fairly hard to trigger and the
consequences are not likely to be noticed.

Specifically, a write() on one CPU while the completion handler is
running on another could result in only one of the two write urbs being
utilised to empty the remainder of the write fifo (unless there is a
second write() that doesn't race during that time).

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


# 706cd17e 09-Oct-2013 Johan Hovold <johan@kernel.org>

USB: serial: export usb_serial_generic_write_start

Export usb_serial_generic_write_start which is needed when implementing
a custom resume function while still relying on the generic write
implementation.

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


# 818f6036 09-Oct-2013 Johan Hovold <johan@kernel.org>

USB: serial: add memory flags to usb_serial_generic_write_start

Add memory-flags parameter to usb_serial_generic_write_start which is
called from write, resume and completion handler, all with different
allocation requirements.

Note that by using the memory flag to determine when called from the
completion handler, everything will work as before even if the
completion handler is run with interrupts enabled (as suggested).

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


# 92ad2479 09-Oct-2013 Johan Hovold <johan@kernel.org>

USB: serial: clean up comments in generic driver

Clean up some comments, drop excessive comments and fix-up style.

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


# 833efc0e 16-Sep-2013 Paul Chavent <Paul.Chavent@onera.fr>

USB: serial: invoke dcd_change ldisc's handler.

The DCD pin of the serial port can receive a PPS signal. By calling
the port line discipline dcd handle, this patch allow to monitor PPS
through USB serial devices.

However the performance aren't as good as the uart drivers, so
document this point too.

Signed-off-by: Paul Chavent <paul.chavent@onera.fr>
Acked-by: Rodolfo Giometti <giometti@enneenne.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 91c4211c 26-Jun-2013 Johan Hovold <johan@kernel.org>

USB: serial: remove hupping check from tiocmiwait

Since commit 31ca020b ("TTY: wake up processes last at hangup") there no
longer any need to check the hupping flag in the generic tiocmiwait
implementation, so remove it.

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


# dcf01050 08-May-2013 Johan Hovold <johan@kernel.org>

USB: serial: add generic wait_until_sent implementation

Add generic wait_until_sent implementation which polls for empty
hardware buffers using the new port-operation tx_empty.

The generic implementation will be used for all sub-drivers that
implement tx_empty but does not define wait_until_sent.

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


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

USB: serial: update copyright information

Update copyright information.

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


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

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>


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

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>


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

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>


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

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>


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

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>


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

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>


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

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>


# 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>


# 92a19f9c 03-Jan-2013 Jiri Slaby <jirislaby@kernel.org>

TTY: switch tty_insert_flip_char

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_char is the next one to proceed. This one is used all
over the code, so the patch is huge.

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


# 428d9988 29-Oct-2012 Johan Hovold <johan@kernel.org>

USB: serial: export usb_serial_generic_chars_in_buffer

Export generic chars_in_buffer implementation so it can be used in
subdrivers in combination with checks of any hardware buffers.

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


# 3033bc8d 18-Sep-2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: Serial: usb-serial: remove debug module parameter

Now that all usb-serial modules are only using dev_dbg()
the debug module parameter does not do anything at all, so
remove it to reduce any confusion if someone were to try
to use it.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 59d33f2f 18-Sep-2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: serial: remove debug parameter from usb_serial_debug_data()

We should use dev_dbg() for usb_serial_debug_data() like all of the rest
of the usb-serial drivers use, so remove the debug parameter as it's not
needed.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0b84704a 31-May-2012 Alan Stern <stern@rowland.harvard.edu>

USB: serial-generic: use a single set of device IDs

The usb-serial-generic driver uses different device IDs for its USB
matching and its serial matching. This can lead to problems: The
driver can end up getting bound to a USB interface without being
allowed to bind to the corresponding serial port.

This patch (as1557) fixes the problem by using the same device ID
table (the one that can be altered by the "vendor=" and "product="
module parameters) for both purposes. The unused table is removed.
Now the driver will bind only to the intended devices.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 689c2781 15-May-2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: generic.c: remove dbg() usage

dbg() is a usb-serial specific macro. This patch converts
the generic.c driver to use dev_dbg() instead to tie into the
dynamic debug infrastructure.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 68e24113 08-May-2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: serial: rework usb_serial_register/deregister_drivers()

This reworks the usb_serial_register_drivers() and
usb_serial_deregister_drivers() to not need a pointer to a struct
usb_driver anymore. The usb_driver structure is now created dynamically
and registered and unregistered as needed.

This saves lines of code in each usb-serial driver. All in-kernel users
of these functions were also fixed up at this time. The pl2303 driver
was tested that everything worked properly.

Thanks for the idea to do this from Alan Stern.

Cc: Adhir Ramjiawan <adhirramjiawan0@gmail.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Al Borchers <alborchers@steinerpoint.com>
Cc: Aleksey Babahin <tamerlan311@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrew Worsley <amworsley@gmail.com>
Cc: Bart Hartgers <bart.hartgers@gmail.com>
Cc: Bill Pemberton <wfp5p@virginia.edu>
Cc: Dan Carpenter <error27@gmail.com>
Cc: Dan Williams <dcbw@redhat.com>
Cc: Donald Lee <donald@asix.com.tw>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Gary Brubaker <xavyer@ix.netcom.com>
Cc: Jesper Juhl <jj@chaosbits.net>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Johan Hovold <jhovold@gmail.com>
Cc: Julia Lawall <julia@diku.dk>
Cc: Kautuk Consul <consul.kautuk@gmail.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Lonnie Mendez <dignome@gmail.com>
Cc: Matthias Bruestle and Harald Welte <support@reiner-sct.com>
Cc: Matthias Urlichs <smurf@smurf.noris.de>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Michal Sroczynski <msroczyn@gmail.com>
Cc: "Michał Wróbel" <michal.wrobel@flytronic.pl>
Cc: Oliver Neukum <oliver@neukum.name>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Peter Berger <pberger@brimson.com>
Cc: Preston Fick <preston.fick@silabs.com>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Rigbert Hamisch <rigbert@gmx.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Simon Arlott <simon@fire.lp0.eu>
Cc: Support Department <support@connecttech.com>
Cc: Thomas Tuttle <ttuttle@chromium.org>
Cc: Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Cc: Wang YanQing <Udknight@gmail.com>
Cc: William Greathouse <wgreathouse@smva.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2edd284b 07-May-2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: serial: remove bizarre generic_serial probe function

I can't remember why I wrote it like this many many years ago, but it's
not needed at all, let's rely on the usb-serial core for this function,
especially as it is being overridden by it anyway.

This lets us make usb_serial_probe() a static function, which it should
be.

Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 32078f91 07-May-2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: serial: remove usb_serial_disconnect call in all drivers

This is now set by the usb-serial core, no need for the driver to
individually set it.

Thanks to Alan Stern for the idea to get rid of it.

Cc: William Greathouse <wgreathouse@smva.com>
Cc: Matthias Bruestle and Harald Welte <support@reiner-sct.com>
Cc: Lonnie Mendez <dignome@gmail.com>
Cc: Peter Berger <pberger@brimson.com>
Cc: Al Borchers <alborchers@steinerpoint.com>
Cc: Gary Brubaker <xavyer@ix.netcom.com>
Cc: Oliver Neukum <oliver@neukum.name>
Cc: Matthias Urlichs <smurf@smurf.noris.de>
Cc: Support Department <support@connecttech.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Kautuk Consul <consul.kautuk@gmail.com>
Cc: Bill Pemberton <wfp5p@virginia.edu>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Bart Hartgers <bart.hartgers@gmail.com>
Cc: Johan Hovold <jhovold@gmail.com>
Cc: Preston Fick <preston.fick@silabs.com>
Cc: Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Cc: Simon Arlott <simon@fire.lp0.eu>
Cc: Andrew Worsley <amworsley@gmail.com>
Cc: "Michał Wróbel" <michal.wrobel@flytronic.pl>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Aleksey Babahin <tamerlan311@gmail.com>
Cc: Dan Carpenter <error27@gmail.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Donald Lee <donald@asix.com.tw>
Cc: Julia Lawall <julia@diku.dk>
Cc: Michal Sroczynski <msroczyn@gmail.com>
Cc: Wang YanQing <Udknight@gmail.com>
Cc: Dan Williams <dcbw@redhat.com>
Cc: Thomas Tuttle <ttuttle@chromium.org>
Cc: Rigbert Hamisch <rigbert@gmx.de>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Jesper Juhl <jj@chaosbits.net>
Cc: Adhir Ramjiawan <adhirramjiawan0@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

USB: generic.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.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c1d830c5 25-Apr-2012 Johan Hovold <johan@kernel.org>

USB: serial: fix double newlines in debug output

Remove trailing newlines from debug messages.

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


# c5b4ee64 25-Apr-2012 Johan Hovold <johan@kernel.org>

USB: serial: remove redundant write-urb kill

Since commit 1ce7b9349fad ("USB: serial: reuse generic write urb and
bulk-out buffer") the port write_urb is simply a pointer to the first
member of write_urbs so there's no need to kill it twice.

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


# 765e0ba6 23-Feb-2012 Alan Stern <stern@rowland.harvard.edu>

usb-serial: new API for driver registration

This patch (as1522) adds two new routines to the usb-serial core, for
registering and unregistering serial drivers. Instead of registering
the usb_driver and usb_serial_drivers separately, with error checking
for each one, the drivers can all be registered and unregistered by a
single function call. This reduces duplicated code.

More importantly, the new core routines change the order in which the
drivers are registered. Currently the usb-serial drivers are all
registered first and the usb_driver is done last, which leaves a
window for problems. A udev script may quickly add a new dynamic-ID
for a usb-serial driver, causing the corresponding usb_driver to be
probed. If the usb_driver hasn't been registered yet then an oops
will occur.

The new routine prevents such problems by registering the usb_driver
first. To insure that it gets probed properly for already-attached
serial devices, we call driver_attach() after all the usb-serial
drivers have been registered.

Along with adding the new routines, the patch modifies the "generic"
serial driver to use them. Further patches will similarly modify all
the other in-tree USB serial drivers.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f1475a00 10-Feb-2012 Johan Hovold <johan@kernel.org>

USB: serial: use dev_err_console in generic write

Use dev_err_console in write path so that an error at least gets
reported once.

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


# 548dd4b6 10-Feb-2012 Johan Hovold <johan@kernel.org>

USB: serial: fix console error reporting

Do not report errors in write path if port is used as a console as this
may trigger the same error (and error report) resulting in a loop.

Reported-by: Stephen Hemminger <shemminger@vyatta.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d83b4053 06-Nov-2011 Johan Hovold <johan@kernel.org>

USB: serial: add support for multiple read urbs

Add support for multiple read urbs to generic read implementation.

Use a static array of two read urbs for now which is enough to get a
50% throughput increase in one test setup.

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


# d14fc1a7 14-Jan-2011 Libor Pechacek <lpechacek@suse.cz>

USB: serial: handle Data Carrier Detect changes

Alan's commit 335f8514f200e63d689113d29cb7253a5c282967 introduced
.carrier_raised function in several drivers. That also means
tty_port_block_til_ready can now suspend the process trying to open the serial
port when Carrier Detect is low and put it into tty_port.open_wait queue. We
need to wake up the process when Carrier Detect goes high and trigger TTY
hangup when CD goes low.

Some of the devices do not report modem status line changes, or at least we
don't understand the status message, so for those we remove .carrier_raised
again.

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 5c7efeb7 05-Aug-2010 Bill Pemberton <wfp5p@virginia.edu>

USB: serial: export symbol usb_serial_generic_disconnect

This is needed by the ssu100 driver to use this function.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 6ee9f4b4 17-Aug-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

USB: drop tty argument from usb_serial_handle_sysrq_char()

Since handle_sysrq() does not take tty as argument anymore we can
drop it from usb_serial_handle_sysrq_char() as well.

Acked-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Acked-by: Jason Wessel <jason.wessel@windriver.com>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# f335397d 17-Aug-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: sysrq - drop tty argument form handle_sysrq()

Sysrq operations do not accept tty argument anymore so no need to pass
it to us.

[Stephen Rothwell <sfr@canb.auug.org.au>: fix build breakage in drm code
caused by sysrq using bool but not including linux/types.h]

[Sachin Sant <sachinp@in.ibm.com>: fix build breakage in s390 keyboadr
driver]

Acked-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Acked-by: Jason Wessel <jason.wessel@windriver.com>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# b58af406 04-Aug-2010 Johan Hovold <johan@kernel.org>

USB: serial: fix stalled writes

As David VomLehn points out, it was possible to receive an interrupt
before clearing the free-urb flag which could lead to the urb being
incorrectly marked as busy.

For the same reason, move tx_bytes accounting so that it will never be
negative.

Note that the free-flags set and clear operations do not need any
additional locking as they are manipulated while USB_SERIAL_WRITE_BUSY
is set.

Reported-by: David VomLehn <dvomlehn@cisco.com>
Tested-by: David VomLehn <dvomlehn@cisco.com>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 56a1df46 15-May-2010 Johan Hovold <johan@kernel.org>

USB: serial: add special case for processing of empty read urbs

Return immediately from generic process_read_urb if urb is empty.

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


# c23e5fc1 05-May-2010 Johan Hovold <johan@kernel.org>

USB: serial: remove multi-urb write from generic driver

Remove multi-urb write from the generic driver and simplify the
prepare_write_buffer prototype:

int (*prepare_write_buffer)(struct usb_serial_port *port,
void *dest, size_t size);

The default implementation simply fills dest with data from port write
fifo but drivers can override it if they need to process the outgoing
data (e.g. add headers).

Turn ftdi_sio into a generic fifo-based driver, which lowers CPU usage
significantly for small writes while retaining maximum throughput.

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


# 27c7acf2 05-May-2010 Johan Hovold <johan@kernel.org>

USB: serial: reimplement generic fifo-based writes

Reimplement fifo-based writes in the generic driver using a multiple
pre-allocated urb scheme.

In contrast to multi-urb writes, no allocations (of urbs or buffers) are
made during run-time and there is less pressure on the host stack
queues as currently only two urbs are used (implementation is generic
and can handle more than two urbs as well, though).

Initial tests using ftdi_sio show that the implementation achieves the
same (maximum) throughput at high baudrates as multi-urb writes. The CPU
usage is much lower than for multi-urb writes for small write requests
and only slightly higher for large (e.g. 2k) requests (due to extra copy
via fifo?).

Also outperforms multi-urb writes for small write requests on an
embedded arm-9 system, where multi-urb writes are CPU-bound at high
baudrates (perf reveals that a lot of time is spent in the host stack
enqueue function -- could perhaps be a bug as well).

Keeping the original write_urb, buffer and flag for now as there are
other drivers depending on them.

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


# eaa3bcb0 17-Mar-2010 Johan Hovold <johan@kernel.org>

USB: serial: generalise write buffer preparation

Generalise write buffer preparation.

This allows for drivers to manipulate (e.g. add headers) to bulk out
data before it is sent.

This adds a new function pointer to usb_serial_driver:

int (*prepare_write_buffer)(struct usb_serial_port *port,
void **dest, size_t size, const void *src, size_t count);

The function is generic and can be used with either kfifo-based or
multi-urb writes:

If *dest is NULL the implementation should allocate dest.
If src is NULL the implementation should use the port write fifo.

If not set, a generic implementation is used which simply uses memcpy or
kfifo_out.

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


# 25d514ca 17-Mar-2010 Johan Hovold <johan@kernel.org>

USB: serial: re-implement multi-urb writes in generic driver

Use dynamic transfer buffer sizes since it is more efficient to let the
host controller do the partitioning to fit endpoint size. This way we
also do not use more than one urb per write request.

Replace max_in_flight_urbs with multi_urb_write flag in struct
usb_serial_driver to enable multi-urb writes.

Use MAX_TX_URBS=40 and a max buffer size of PAGE_SIZE to prevent DoS
attacks.

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


# 40f92f0d 17-Mar-2010 Johan Hovold <johan@kernel.org>

USB: serial: allow custom multi-urb write bulk callbacks

Allow drivers to implement their own multi-urb write bulk callbacks as
we do for single urb writes.

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


# 50a5f70c 17-Mar-2010 Johan Hovold <johan@kernel.org>

USB: serial: clean up generic write start busy test

Submit write urb if it is not already in use and we have buffered data.

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


# 1a1405e2 17-Mar-2010 Johan Hovold <johan@kernel.org>

USB: serial: clean up some error and debug messages in generic driver

Clean up error messages on usb_submit_urb failure.
Remove debug message on zero-length writes.

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


# f1e949ac 17-Mar-2010 Johan Hovold <johan@kernel.org>

USB: serial: export generic throttle and unthrottle

Allow drivers to use the generic throttle and unthrottle implementation.
This makes sense for drivers using the generic read functionality.

Note that drivers need to set these explicitly in order to enable them
(i.e., we do not set them at port probe if not defined).

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


# 23154320 17-Mar-2010 Johan Hovold <johan@kernel.org>

USB: serial: generalise generic read implementation

Add process_read_urb to usb_serial_driver so that a driver can rely on
the generic read (and throttle) mechanism but still do device specific
processing of incoming data (such as adding tty_flags before pushing to
line discipline).

The default generic implementation handles sysrq for consoles but
otherwise simply pushes to tty.

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


# 0f3d5bae 17-Mar-2010 Johan Hovold <johan@kernel.org>

USB: serial: clean up read processing in generic driver

Always process and flush read urb, but only resubmit when not throttled.
The new tty-layer supply plenty of slack so there is really no need to
cache and delay processing of a single urb while throttled.

Note that unthrottle now submits using GFP_KERNEL as we are not in
atomic context (so there is no need to save irq state either).

Note also that the process_read_urb function could be added to
usb_serial_driver should any driver need to do any device specific
processing.

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


# 056afc0f 17-Mar-2010 Johan Hovold <johan@kernel.org>

USB: serial: remove unnecessary re-initialisation of generic urbs

The generic read and write bulk urbs are initialised when allocated in
usb_serial_probe. The only field that needs to be updated after that is
the transfer_buffer_length of the write urb.

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


# 41bd72f9 17-Mar-2010 Johan Hovold <johan@kernel.org>

USB: serial: refactor read urb submission in generic driver

Use the already exported function for submitting the read urb associated
with a usb_serial_port.

Make sure it returns the result of usb_submit_urb and rename to the
more descriptive usb_serial_generic_submit_read_urb.

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


# f26788da 17-Mar-2010 Johan Hovold <johan@kernel.org>

USB: serial: refactor generic close

Export usb_serial_generic_close so that drivers can easily kill the read
and write urb and make sure that the write fifo is reset.

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


# ec3ee508 17-Mar-2010 Johan Hovold <johan@kernel.org>

USB: serial: clear fifo on close

Make sure fifo is emptied on close.

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


# 50dbb852 17-Mar-2010 Johan Hovold <johan@kernel.org>

USB: serial: fix missing locking on fifo in write callback

On errors the fifo was reset without any locking. This could race with
write which do kfifo_put and perhaps also chars_in_buffer and write_room.

Every other access to the fifo is protected using the port lock so
better add it to the error path as well.

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


# 30af7fb5 17-Mar-2010 Johan Hovold <johan@kernel.org>

USB: serial: fix generic chars_in_buffer

Make sure chars_in_buffer accounts also for data in host stack queues.

This fixes the problem with tty_wait_until_sent returning too soon at
close which could cause the final write urb to be cancelled.

Reported-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 7f0ae3a8 25-Mar-2010 Randy Dunlap <randy.dunlap@oracle.com>

usb: fix serial build when SYSRQ is disabled

Fix build error when CONFIG_MAGIC_SYSRQ is not enabled:

drivers/usb/serial/generic.c:566: error: implicit declaration of function 'handle_sysrq'

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# bd5afa9e 08-Mar-2010 Jason Wessel <jason.wessel@windriver.com>

usb-serial: Use tty_port version console instead of usb_serial_port

Replace all instances of using the console variable in struct
usb_serial_port with the struct tty_port version.

CC: Alan Cox <alan@linux.intel.com>
CC: Alan Stern <stern@rowland.harvard.edu>
CC: Oliver Neukum <oliver@neukum.org>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: linux-usb@vger.kernel.org
CC: linux-kernel@vger.kernel.org
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# eb8878a8 27-Feb-2010 Johan Hovold <johan@kernel.org>

USB: serial: use port endpoint size to determine if ep is available

It is possible to have a multi-port device with a port lacking an in or
out bulk endpoint. Only checking for num_bulk_in or num_bulk_out is thus not
sufficient to determine whether a specific port has an in or out bulk
endpoint.

This fixes potential null pointer dereferences in the generic open and
write routines, as well as access to uninitialised fifo in write_room
and chars_in_buffer.

Also let write fail with ENODEV (instead of 0) on missing out endpoint
(also on zero-length writes).

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


# 63136202 27-Feb-2010 Johan Hovold <johan@kernel.org>

USB: serial: fix softint not being called on errors

Make sure usb_serial_port_softint is called on errors also when using
multi urb writes.

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


# 0ae14743 27-Feb-2010 Johan Hovold <johan@kernel.org>

USB: serial: fix error message on close in generic driver

Resubmitting read urb fails with -EPERM if completion handler runs while
urb is being killed on close. This should not be reported as an error.

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


# 1f87158e 17-Feb-2010 Alan Stern <stern@rowland.harvard.edu>

USB: remove references to port->port.count from the serial drivers

This patch (as1344) removes references to port->port.count from the
USB serial drivers. Now that serial ports are properly reference
counted, port.count checking is unnecessary and incorrect. Drivers
should assume that the port is in use from the time the open method
runs until the close method is called.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 759f3634 05-Feb-2010 Joe Perches <joe@perches.com>

USB: serial: Remove unnecessary \n's from dbg uses

#define dbg adds the newline, messages shouldn't.
Converted dbg("%s", "some string") to dbg("some string")

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 7d40d7e8 10-Jan-2010 Németh Márton <nm127@freemail.hu>

USB serial: 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>


# 25915302 06-Jan-2010 Johan Hovold <johan@kernel.org>

usb: serial: fix memory leak in generic driver

Fix a regression introduced by commit
715b1dc01fe44537e8fce9566e4bb48d6821d84b ("USB: usb_debug,
usb_generic_serial: implement multi urb write").

URB transfer buffer was never freed when using multi-urb writes.
Currently the only driver enabling multi-urb writes is usb_debug.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Cc: Greg KH <greg@kroah.com>
Acked-by: Jason Wessel <jason.wessel@windriver.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 25719e6b 05-Jan-2010 Stefani Seibold <stefani@seibold.net>

USB: serial: fix USB serial fix kfifo_len locking

This patch fix a possible race bug in drivers/usb/serial/generic with
the new kfifo API.

Please apply it to the 2.6.33-rc* tree.

Signed-off-by: Stefani Seibold <stefani@seibold.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 119eecc8 23-Dec-2009 Stefani Seibold <stefani@seibold.net>

Fix usb_serial_probe() problem introduced by the recent kfifo changes

The USB serial code was a new user of the kfifo API, and it was missed
when porting things to the new kfifo API.

Please make the write_fifo in place. Here is my patch to fix the
regression and full ported version.

Signed-off-by: Stefani Seibold <stefani@seibold.net>
Reported-and-tested-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Greg KH <greg@kroah.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 7acd72eb 21-Dec-2009 Stefani Seibold <stefani@seibold.net>

kfifo: rename kfifo_put... into kfifo_in... and kfifo_get... into kfifo_out...

rename kfifo_put... into kfifo_in... to prevent miss use of old non in
kernel-tree drivers

ditto for kfifo_get... -> kfifo_out...

Improve the prototypes of kfifo_in and kfifo_out to make the kerneldoc
annotations more readable.

Add mini "howto porting to the new API" in kfifo.h

Signed-off-by: Stefani Seibold <stefani@seibold.net>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Acked-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# e64c026d 21-Dec-2009 Stefani Seibold <stefani@seibold.net>

kfifo: cleanup namespace

change name of __kfifo_* functions to kfifo_*, because the prefix __kfifo
should be reserved for internal functions only.

Signed-off-by: Stefani Seibold <stefani@seibold.net>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Acked-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# c1e13f25 21-Dec-2009 Stefani Seibold <stefani@seibold.net>

kfifo: move out spinlock

Move the pointer to the spinlock out of struct kfifo. Most users in
tree do not actually use a spinlock, so the few exceptions now have to
call kfifo_{get,put}_locked, which takes an extra argument to a
spinlock.

Signed-off-by: Stefani Seibold <stefani@seibold.net>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Acked-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 63a96095 24-Sep-2009 Joris van Rantwijk <jorispubl@xs4all.nl>

USB: Fix throttling in generic usbserial driver

The generic usbserial driver in Linux 2.6.31 halts its receiving
channel in response to throttle requests from the line discipline.
Unfortunately it drops the contents of the first URB received after
throttling takes effect. This patch corrects that problem.

Signed-off-by: Joris van Rantwijk <jorispubl@xs4all.nl>
Acked-by: Johan Hovold <jhovold@gmail.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 8e8dce06 28-Aug-2009 David VomLehn <dvomlehn@cisco.com>

USB: use kfifo to buffer usb-generic serial writes

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

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

Signed-off-by: David VomLehn <dvomlehn@cisco.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# a509a7e4 19-Sep-2009 Alan Cox <alan@linux.intel.com>

tty: USB does not need the filp argument in the drivers

And indeed none of them use it. Clean this up as it will make moving to a
standard open method rather easier.

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


# 24a15a62 09-Jul-2009 Alan Cox <alan@linux.intel.com>

tty: Fix USB kref leak

The sysrq code acquired a kref leak. Fix it by passing the tty separately
from the caller (thus effectively using the callers kref which all the
callers hold anyway)

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 4cd1de0a 09-Jul-2009 Alan Cox <alan@linux.intel.com>

tty: Sort out the USB sysrq changes that wrecked performance

We can't go around calling all sorts of magic per character functions at
full rate 3G data speed.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# f9c99bb8 02-Jun-2009 Alan Stern <stern@rowland.harvard.edu>

USB: usb-serial: replace shutdown with disconnect, release

This patch (as1254) splits up the shutdown method of usb_serial_driver
into a disconnect and a release method.

The problem is that the usb-serial core was calling shutdown during
disconnect handling, but drivers didn't expect it to be called until
after all the open file references had been closed. The result was an
oops when the close method tried to use memory that had been
deallocated by shutdown.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 568d422e 29-May-2009 Jason Wessel <jason.wessel@windriver.com>

USB: usb_serial: only allow sysrq on a console port

The only time a sysrq should get processed is if the attached device
is a console. This is intended to protect sysrq execution on a host
connected with a terminal program.

Here is the problem scenario:

host A <-- rs232 link --> host B

Host A is using mincom and a usb pl2303 device to connect to host b
which is a linux system with a usb pl2303 device acting as the serial
console. When host B is rebooted the pl2303 emits random junk
characters on reset. These character sequences contain serial break
signals most of the time and when translated to a sysrq have caused
host A to get random processes killed, reboots or power down.

It is true that in this setup with this patch host B might still have
the same problem as host A if you reboot host A. In most cases host A
is a development host which seldom gets rebooted, and you could turn
off sysrq temporarily on host B if you need to reboot host A.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 98fcb5f7 11-May-2009 Jason Wessel <jason.wessel@windriver.com>

USB: serial: usb_debug,usb_generic_serial: implement sysrq and serial break

The usb_debug driver was modified to implement serial break handling
by using a "magic" data packet comprised of the sequence:

0x00 0xff 0x01 0xfe 0x00 0xfe 0x01 0xff

When the tty layer requests a serial break the usb_debug driver sends
the magic packet. On the receiving side the magic packet is thrown
away or a sysrq is activated depending on what kernel .config options
have been set.

The generic serial driver was modified as well as the usb serial
headers to generically implement sysrq processing in the same way the
non usb uart based drivers implement the sysrq handling. This will
allow other usb serial devices to implement sysrq handling as desired.

The new usb serial functions are named similarly and implemented
similarly to the uart functions as follows:

usb_serial_handle_break <-> uart_handle_break
usb_serial_handle_sysrq_char <-> uart_handle_sysrq_char

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 715b1dc0 11-May-2009 Jason Wessel <jason.wessel@windriver.com>

USB: usb_debug, usb_generic_serial: implement multi urb write

The usb_debug driver, when used as the console, will always fail to
insert the carriage return and new line sequence as well as randomly
drop console output. This is a result of only having the single
write_urb and that the tty layer will have a lock that prevents the
processing of the back to back urb requests.

The solution is to allow more than one urb to be outstanding and have
a slightly deeper transmit queue. The idea and some code is borrowed
from the ftdi_sio usb driver.

The generic usb serial driver was modified so as to allow the classic
method of 1 write urb, or a multi write urb scheme with N allowed
outstanding urbs where N is controlled by max_in_flight_urbs. When
max_in_flight_urbs in a "struct usb_serial_driver" is non zero the
multi write urb scheme will be used.

The size of 4000 was selected for the usb_debug driver so that the
driver lowers possibility of losing the queued console messages during
the kernel startup.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 335f8514 10-Jun-2009 Alan Cox <alan@lxorguk.ukuu.org.uk>

tty: Bring the usb tty port structure into more use

This allows us to clean stuff up, but is probably also going to cause
some app breakage with buggy apps as we now implement proper POSIX behaviour
for USB ports matching all the other ports. This does also mean other apps
that break on USB will now work properly.

Signed-off-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 2400a2bf 20-Apr-2009 Oliver Neukum <oliver@neukum.org>

USB: removal of tty->low_latency hack dating back to the old serial code

This removes tty->low_latency from all USB serial drivers that push
data into the tty layer at hard interrupt context. It's no longer needed
and actually harmful.

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 81d043c2 06-Feb-2009 Oliver Neukum <oliver@neukum.org>

USB: serial: export symbol of usb_serial_generic_resume

This exports a symbol for usb_serial_generic_resume, so that modules can
use it.

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


# d55c0ae6 06-Feb-2009 Oliver Neukum <oliver@neukum.org>

USB: serial generic resume function fix

This removes an unnecessary check for autoresume from the generic
resume method. The check has been obsoleted by the now delayed
increase of the usage counter which makes the error this check prevented
impossible. This change allows drivers which only use the bulk read URB
the use of the generic method even if they support autosuspend.

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


# 4a90f09b 13-Oct-2008 Alan Cox <alan@redhat.com>

tty: usb-serial krefs

Use kref in the USB serial drivers so that we don't free tty structures
from under the URB receive handlers as has historically been the case if
you were unlucky. This also gives us a framework for general tty drivers to
use tty_port objects and refcount.

Contains two err->dev_err changes merged together to fix clashes in the
-next tree.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# ae64387a 22-Jul-2008 Alan Cox <alan@redhat.com>

tty-usb-generic: Code cleanup

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 95da310e 22-Jul-2008 Alan Cox <alan@redhat.com>

usb_serial: API all change

USB serial likes to use port->tty back pointers for the real work it does and
to do so without any actual locking. Unfortunately when you consider hangup
events, hangup/parallel reopen or even worse hangup followed by parallel close
events the tty->port and port->tty pointers are not guaranteed to be the same
as port->tty is the active tty while tty->port is the port the tty may or
may not still be attached to.

So rework the entire API to pass the tty struct. For console cases we need
to pass both for now. This shows up multiple drivers that immediately crash
with USB console some of which have been fixed in the process.

Longer term we need a proper tty as console abstraction

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# cdc97792 24-Feb-2008 Ming Lei <tom.leiming@gmail.com>

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>


# a5b6f60c 08-Apr-2008 Alan Cox <alan@lxorguk.ukuu.org.uk>

usb serial: more fixes and groundwork for tty changes

- If a termios change fails due to lack of memory we should copy the
old settings back over as the device has not changed
- Note various locking problems
- kl5kusb105 had various remaining tty flag handling problems
- Make safe_serial use tty_insert_flip_string not open coded loops
- set termios speed properly in usb_serial

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


# 441b62c1 03-Mar-2008 Harvey Harrison <harvey.harrison@gmail.com>

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>


# 0ba4034e 16-Apr-2008 Greg Kroah-Hartman <gregkh@suse.de>

USB: serial: remove unneeded number endpoints settings

The usb-serial core no longer checks these fields so remove them from
all of the individual drivers. They will be removed from the usb-serial
core in a patch later in the series.

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


# b507cc97 05-Mar-2008 Pete Zaitcev <zaitcev@redhat.com>

USB: fix usb-serial generic recursive lock

Nobody should be using the generic usb-serial for anything other than
testing. Still, it's not a good thing that it's easy to lock up. There
is a traceback from NMI oopser here:
https://bugzilla.redhat.com/show_bug.cgi?id=431379

But in short, if a line discipline has a chance to echo anything, input
can loop back a write method. So, don't call tty_flip_buffer_push from
under a lock taken on write path.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# f0fbd5b9 13-Nov-2007 Sarah Sharp <sarah.a.sharp@intel.com>

USB: Prepare serial core for autosuspend.

Claim the interface for a USB to serial converter when the tty is open,
and release the interface when the tty is closed.

If a driver doesn't provide a resume function, use the generic resume
instead.

Make sure the generic resume function does not submit the URBs if we're
coming back from autosuspend. On autoresume, we know that the open
function will be called next, which will attempt to submit the URBs. If
we submit them in the resume function, the open will fail.

This works for:
- autosuspend
- suspending with the tty open or closed
- hibernate with the tty closed

A hibernate (or a suspend that causes the USB subsystem to lose power)
has issues. If you have the tty open when you hibernate, a new tty will
be created when the device re-enumerates during resume.

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


# bfaeafcf 28-Oct-2007 Borislav Petkov <bbpetkov@yahoo.de>

usbserial: fix inconsistent lock state

In commit acd2a847e7fee7df11817f67dba75a2802793e5d usb_serial_generic_write()
disables interrupts when taking &port->lock which is also taken in
usb_serial_generic_read_bulk_callback() resulting in an inconsistent lock state
due to the latter not disabling interrupts on the local cpu. Fix that by
disabling interrupts in the latter call site also.

Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# acd2a847 19-Oct-2007 Jiri Kosina <jkosina@suse.cz>

USB: usbserial - fix potential deadlock between write() and IRQ

USB: usbserial - fix potential deadlock between write() and IRQ

usb_serial_generic_write() doesn't disable interrupts when taking port->lock,
and could therefore deadlock with usb_serial_generic_read_bulk_callback()
being called from interrupt, taking the same lock. Fix it.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Acked-by: Larry Finger <larry.finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# fbd27225 15-Jun-2007 Greg Kroah-Hartman <gregkh@suse.de>

USB: serial: generic: 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.


Cc: <linux-usb-devel@lists.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 1abdeeb1 06-May-2007 Oliver Neukum <oneukum@suse.de>

USB: generic usb serial to new buffering scheme

the generic driver also had its own buffering.

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


# ec22559e 27-Apr-2007 Oliver Neukum <oneukum@suse.de>

USB: suspend support for usb serial

this implements generic support for suspend/resume for usb serial.

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


# b46d60fc 23-Mar-2007 David Brownell <david-b@pacbell.net>

USB: fix usb-serial/generic build warning

Fix annoying build warning when CONFIG_USB_SERIAL_GENERIC is undefined.

drivers/usb/serial/generic.c:24: warning: `generic_probe' declared `static' but never defined

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 253ca923 01-Feb-2007 Joris van Rantwijk <jorispubl@xs4all.nl>

USB: add flow control to usb-serial generic driver.

I added two fields to struct usb_serial_port to keep track of the
throttle state. Other usb-serial drivers typically use private data for
such things, but the generic driver can not really do that because some
of its code is also used by other drivers (which may have their own
private data needs).

As it is, I am not sure that this patch is useful in all scenarios.
It is certainly helpful for low-bandwidth devices that can hold their
data in response to throttling. But for devices that pump data in
real-time as fast as possible (webcam, A/D converter, etc), throttling
may actually cause more data loss.

From: Joris van Rantwijk <jorispubl@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# d9b1b787 17-Dec-2006 Johannes Hölzl <johannes.hoelzl@gmx.de>

USB serial: add driver pointer to all usb-serial drivers

Every usb serial driver should have a pointer to the corresponding usb driver.
So the usb serial core can add a new id not only to the usb serial driver, but
also to the usb driver.

Also the usb drivers of ark3116, mos7720 and mos7840 missed the flag
no_dynamic_id=1. This is added now.

Signed-off-by: Johannes Hölzl <johannes.hoelzl@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 7d12e780 05-Oct-2006 David Howells <dhowells@redhat.com>

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)


# e81ee637 24-Sep-2006 Peter Zijlstra <a.p.zijlstra@chello.nl>

usb-serial: possible irq lock inversion (PPP vs. usb/serial)

=========================================================
[ INFO: possible irq lock inversion dependency detected ]


# a969888c 11-Jul-2006 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] USB: move usb-serial.h to include/linux/usb/

USB serial outside of the kernel tree can not build properly due to
usb-serial.h being buried down in the source tree. This patch moves the
location of the file to include/linux/usb and fixes up all of the usb
serial drivers to handle the move properly.

Cc: Sergei Organov <osv@javad.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 166ffccf 11-Jul-2006 Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>

[PATCH] USB: Anydata: Fixes wrong URB callback.

Anydata is using usb_serial_generic_write_bulk_callback() for its
read URB, but it should use usb_serial_generic_read_bulk_callback()
instead (it's a read URB, isn't it?).

Reported by Jon K Hellan <hellan@acm.org>.

Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 6ab3d562 30-Jun-2006 Jörn Engel <joern@wohnheim.fh-wedel.de>

Remove obsolete #include <linux/config.h>

Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>


# cf2c7481 22-May-2006 Pete Zaitcev <zaitcev@redhat.com>

[PATCH] USB serial: encapsulate schedule_work, remove double-calling

I'm going to throw schedule_work away, it's retarded. But for starters,
let's have it encapsulated.

Also, generic and whiteheat were both calling usb_serial_port_softint
and scheduled work. Only one was necessary.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 815ddc99 12-May-2006 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] USB: add ark3116 usb to serial driver

Based on Simon's original driver, with some minor code cleanups and
tidying by me.

Cc: Simon Schulz <simon@auctionant.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 33f0f88f 09-Jan-2006 Alan Cox <alan@lxorguk.ukuu.org.uk>

[PATCH] TTY layer buffering revamp

The API and code have been through various bits of initial review by
serial driver people but they definitely need to live somewhere for a
while so the unconverted drivers can get knocked into shape, existing
drivers that have been updated can be better tuned and bugs whacked out.

This replaces the tty flip buffers with kmalloc objects in rings. In the
normal situation for an IRQ driven serial port at typical speeds the
behaviour is pretty much the same, two buffers end up allocated and the
kernel cycles between them as before.

When there are delays or at high speed we now behave far better as the
buffer pool can grow a bit rather than lose characters. This also means
that we can operate at higher speeds reliably.

For drivers that receive characters in blocks (DMA based, USB and
especially virtualisation) the layer allows a lot of driver specific
code that works around the tty layer with private secondary queues to be
removed. The IBM folks need this sort of layer, the smart serial port
people do, the virtualisers do (because a virtualised tty typically
operates at infinite speed rather than emulating 9600 baud).

Finally many drivers had invalid and unsafe attempts to avoid buffer
overflows by directly invoking tty methods extracted out of the innards
of work queue structs. These are no longer needed and all go away. That
fixes various random hangs with serial ports on overflow.

The other change in here is to optimise the receive_room path that is
used by some callers. It turns out that only one ldisc uses receive room
except asa constant and it updates it far far less than the value is
read. We thus make it a variable not a function call.

I expect the code to contain bugs due to the size alone but I'll be
watching and squashing them and feeding out new patches as it goes.

Because the buffers now dynamically expand you should only run out of
buffering when the kernel runs out of memory for real. That means a lot of
the horrible hacks high performance drivers used to do just aren't needed any
more.

Description:

tty_insert_flip_char is an old API and continues to work as before, as does
tty_flip_buffer_push() [this is why many drivers dont need modification]. It
does now also return the number of chars inserted

There are also

tty_buffer_request_room(tty, len)

which asks for a buffer block of the length requested and returns the space
found. This improves efficiency with hardware that knows how much to
transfer.

and tty_insert_flip_string_flags(tty, str, flags, len)

to insert a string of characters and flags

For a smart interface the usual code is

len = tty_request_buffer_room(tty, amount_hardware_says);
tty_insert_flip_string(tty, buffer_from_card, len);

More description!

At the moment tty buffers are attached directly to the tty. This is causing a
lot of the problems related to tty layer locking, also problems at high speed
and also with bursty data (such as occurs in virtualised environments)

I'm working on ripping out the flip buffers and replacing them with a pool of
dynamically allocated buffers. This allows both for old style "byte I/O"
devices and also helps virtualisation and smart devices where large blocks of
data suddenely materialise and need storing.

So far so good. Lots of drivers reference tty->flip.*. Several of them also
call directly and unsafely into function pointers it provides. This will all
break. Most drivers can use tty_insert_flip_char which can be kept as an API
but others need more.

At the moment I've added the following interfaces, if people think more will
be needed now is a good time to say

int tty_buffer_request_room(tty, size)

Try and ensure at least size bytes are available, returns actual room (may be
zero). At the moment it just uses the flipbuf space but that will change.
Repeated calls without characters being added are not cumulative. (ie if you
call it with 1, 1, 1, and then 4 you'll have four characters of space. The
other functions will also try and grow buffers in future but this will be a
more efficient way when you know block sizes.

int tty_insert_flip_char(tty, ch, flag)

As before insert a character if there is room. Now returns 1 for success, 0
for failure.

int tty_insert_flip_string(tty, str, len)

Insert a block of non error characters. Returns the number inserted.

int tty_prepare_flip_string(tty, strptr, len)

Adjust the buffer to allow len characters to be added. Returns a buffer
pointer in strptr and the length available. This allows for hardware that
needs to use functions like insl or mencpy_fromio.

Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 75318d2d 21-Nov-2005 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] USB: remove .owner field from struct usb_driver

It is no longer needed, so let's remove it, saving a bit of memory.

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


# ba9dc657 16-Nov-2005 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] USB: allow usb drivers to disable dynamic ids

This lets drivers, like the usb-serial ones, disable the ability to add
ids from sysfs.

The usb-serial drivers are "odd" in that they are really usb-serial bus
drivers, not usb bus drivers, so the dynamic id logic will have to go
into the usb-serial bus core for those drivers to get that ability.

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


# bb833986 17-Nov-2005 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] USB: add the anydata usb-serial driver

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 269bda1c 20-Jun-2005 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] USB Serial: move name to driver structure

This fixes up a lot of problems in sysfs with some of the usb serial
drivers, they had incorrect driver names. Also saves a tiny ammount
of memory.

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


# 18fcac35 20-Jun-2005 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] USB Serial: get rid of the .owner field in usb_serial_driver

Don't duplicate something that's already in struct driver.

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


# ea65370d 20-Jun-2005 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] USB Serial: rename usb_serial_device_type to usb_serial_driver

I'm tired of trying to explain why a "device_type" is really a driver.
This better describes exactly what this structure is.

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


# 7a3ca7d2 14-Oct-2005 Randall Nortman <linuxkernellist@wonderclown.com>

[PATCH] usbserial: Regression in USB generic serial driver

Kernel version 2.6.13 introduced a regression in the generic USB
serial converter driver (usbserial.o, drivers/usb/serial/generic.c).
The bug manifests, as far as I can tell, whenever you attempt to write
to the device -- the write will never complete (write() returns 0, or
blocks).

Signed-off-by: Randall Nortman <oss@wonderclown.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 507ca9bc 23-Apr-2005 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] USB: add ability for usb-serial drivers to determine if their write urb is currently being used.

This removes a lot of racy and buggy code by trying to check the status of the urb.

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


# 1da177e4 16-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org>

Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!