Commit Graph

80 Commits

Author SHA1 Message Date
Dan Carpenter e33eab9ded USB: serial: ch341: fix type promotion bug in ch341_control_in()
The "r" variable is an int and "bufsize" is an unsigned int so the
comparison is type promoted to unsigned.  If usb_control_msg() returns a
negative that is treated as a high positive value and the error handling
doesn't work.

Fixes: 2d5a9c72d0 ("USB: serial: ch341: fix control-message error handling")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-07-04 15:40:54 +02:00
Johan Hovold 627cfa89b1 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>
2017-11-04 11:58:00 +01:00
Greg Kroah-Hartman 6ca98bc284 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>
2017-11-04 11:55:38 +01:00
Greg Kroah-Hartman 5fd54ace47 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>
2017-11-04 11:48:02 +01:00
Johan Hovold 7c61b0d5e8 USB: serial: ch341: change initial line-control settings
Some CH340 devices appear unable to change the initial LCR settings, so
set a sane 8N1 default during probe to enable basic support for such
devices.

Also drop a redundant LCR read during device initialisation.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-01-16 12:32:21 +01:00
Johan Hovold 448b6dc5a9 USB: serial: ch341: rename LCR variable in set_termios
Rename the line-control-register variable in set_termios to "lcr" and
use u8 type to match the shadow register.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-01-16 12:32:21 +01:00
Johan Hovold e802446035 USB: serial: ch341: rename modem-status register
Rename the shadow modem-status register currently named "line_status" to
the less confusing "msr".

Also rename the helper function used to parse the interrupt data.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-01-16 12:32:20 +01:00
Johan Hovold beea33d4f9 USB: serial: ch341: rename shadow modem-control register
Rename the shadow modem-control register currently named "line_control"
to the less confusing "mcr".

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-01-16 12:32:20 +01:00
Johan Hovold 91e0efcd4c USB: serial: ch341: clean up control debug messages
Clean up the control-transfer debug messages by dropping redundant
information and unnecessary casts.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-01-16 12:31:56 +01:00
Johan Hovold a0467a967f USB: serial: ch341: fix modem-status handling
The modem-status register was read as part of device configuration at
port_probe and then again at open (and reset-resume). During open (and
reset-resume) the MSR was read before submitting the interrupt URB,
something which could lead to an MSR-change going unnoticed when it
races with open (reset-resume).

Fix this by dropping the redundant reconfiguration of the port at every
open, and only read the MSR after the interrupt URB has been submitted.

Fixes: 664d5df92e ("USB: usb-serial ch341: support for DTR/RTS/CTS")
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-01-16 12:30:45 +01:00
Johan Hovold 2d5a9c72d0 USB: serial: ch341: fix control-message error handling
A short control transfer would currently fail to be detected, something
which could lead to stale buffer data being used as valid input.

Check for short transfers, and make sure to log any transfer errors.

Note that this also avoids leaking heap data to user space (TIOCMGET)
and the remote device (break control).

Fixes: 6ce7610478 ("USB: Driver for CH341 USB-serial adaptor")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-01-11 12:08:57 +01:00
Johan Hovold 55fa15b598 USB: serial: ch341: fix baud rate and line-control handling
Revert to using direct register writes to set the divisor and
line-control registers.

A recent change switched to using the init vendor command to update
these registers, something which also enabled support for CH341A
devices. It turns out that simply setting bit 7 in the divisor register
is sufficient to support CH341A and specifically prevent data from being
buffered until a full endpoint-size packet (32 bytes) has been received.

Using the init command also had the side-effect of temporarily
deasserting the DTR/RTS signals on every termios change (including
initialisation on open) something which for example could cause problems
in setups where DTR is used to trigger a reset.

Fixes: 4e46c410e0 ("USB: serial: ch341: reinitialize chip on
reconfiguration")
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-01-09 14:55:40 +01:00
Johan Hovold 3cca8624b6 USB: serial: ch341: fix line settings after reset-resume
A recent change added support for modifying the default line-control
settings, but did not make sure that the modified settings were used as
part of reconfiguration after a device has been reset during resume.

This caused a port that was open before suspend to be unusable until
being closed and reopened.

Fixes: ba781bdf86 ("USB: serial: ch341: add support for parity, frame
length, stop bits")
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-01-09 14:55:39 +01:00
Johan Hovold ce5e292828 USB: serial: ch341: fix resume after reset
Fix reset-resume handling which failed to resubmit the read and
interrupt URBs, thereby leaving a port that was open before suspend in a
broken state until closed and reopened.

Fixes: 1ded7ea47b ("USB: ch341 serial: fix port number changed after
resume")
Fixes: 2bfd1c96a9 ("USB: serial: ch341: remove reset_resume callback")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-01-09 14:55:38 +01:00
Johan Hovold f2950b7854 USB: serial: ch341: fix open error handling
Make sure to stop the interrupt URB before returning on errors during
open.

Fixes: 664d5df92e ("USB: usb-serial ch341: support for DTR/RTS/CTS")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-01-09 14:55:38 +01:00
Johan Hovold 030ee7ae52 USB: serial: ch341: fix modem-control and B0 handling
The modem-control signals are managed by the tty-layer during open and
should not be asserted prematurely when set_termios is called from
driver open.

Also make sure that the signals are asserted only when changing speed
from B0.

Fixes: 664d5df92e ("USB: usb-serial ch341: support for DTR/RTS/CTS")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-01-09 14:55:37 +01:00
Johan Hovold a20047f36e USB: serial: ch341: fix open and resume after B0
The private baud_rate variable is used to configure the port at open and
reset-resume and must never be set to (and left at) zero or reset-resume
and all further open attempts will fail.

Fixes: aa91def41a ("USB: ch341: set tty baud speed according to tty
struct")
Fixes: 664d5df92e ("USB: usb-serial ch341: support for DTR/RTS/CTS")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-01-09 14:55:37 +01:00
Johan Hovold 4e2da44691 USB: serial: ch341: fix initial modem-control state
DTR and RTS will be asserted by the tty-layer when the port is opened
and deasserted on close (if HUPCL is set). Make sure the initial state
is not-asserted before the port is first opened as well.

Fixes: 664d5df92e ("USB: usb-serial ch341: support for DTR/RTS/CTS")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-01-09 14:55:37 +01:00
Aidan Thornton a98b69002a USB: serial: ch341: add debug output for chip version
Will probably be helpful if there are any more compatibility issues.

Signed-off-by: Aidan Thornton <makosoft@gmail.com>
Reviewed-by: Grigori Goronzy <greg@chown.ath.cx>
Signed-off-by: Johan Hovold <johan@kernel.org>
2016-10-24 17:41:30 +02:00
Aidan Thornton ba781bdf86 USB: serial: ch341: add support for parity, frame length, stop bits
With the new reinitialization method, configuring parity, different
frame lengths and different stop bit settings should work as expected
on both CH340G and CH341A. Tested on a loopback-connected CH340G
with a logic analyzer in a number of different configurations.

Based on a patch by Grigori Goronzy

Signed-off-by: Aidan Thornton <makosoft@gmail.com>
Reviewed-by: Grigori Goronzy <greg@chown.ath.cx>
Signed-off-by: Johan Hovold <johan@kernel.org>
2016-10-24 17:41:25 +02:00
Aidan Thornton 4e46c410e0 USB: serial: ch341: reinitialize chip on reconfiguration
Changing the LCR register after initialization does not seem to be reliable
on all chips (particularly not on CH341A). Restructure initialization and
configuration to always reinit the chip on configuration changes instead and
pass the LCR register value directly to the initialization command.

(Note that baud rates above 500kbaud are incorrect, but they're incorrect in
the same way both before and after this patch at least on the CH340G. Fixing
this isn't a priority as higher baud rates don't seem that reliable anyway.)

Cleaned-up version of a patch by Grigori Goronzy

Signed-off-by: Aidan Thornton <makosoft@gmail.com>
Reviewed-by: Grigori Goronzy <greg@chown.ath.cx>
Signed-off-by: Johan Hovold <johan@kernel.org>
2016-10-24 17:41:19 +02:00
Aidan Thornton 6fde8d29b0 USB: serial: ch341: add register and USB request definitions
No functional changes, this just gives names to some registers and USB
requests based on Grigori Goronzy's work and WinChipTech's Linux driver
(which reassuringly agree), then uses them in place of magic numbers.
This also renames the misnamed BREAK2 register (actually UART config)

Signed-off-by: Aidan Thornton <makosoft@gmail.com>
Reviewed-by: Grigori Goronzy <greg@chown.ath.cx>
Signed-off-by: Johan Hovold <johan@kernel.org>
2016-10-24 17:41:07 +02:00
Mathieu OTHACEHE fb571101af USB: serial: fix compare_const_fl.cocci warnings
Move constants to the right of binary operators where it increases
readability.

Generated by: scripts/coccinelle/misc/compare_const_fl.cocci

Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
[johan: drop some chunks and fix others, amend commit message ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2016-02-28 14:35:58 +01:00
Greg Kroah-Hartman 3510c8164c USB-serial updates for v4.1-rc1
Fix up the f81232 driver, which up to this point has mostly been a
 placeholder without a proper implementation.
 
 Included is also a minor clean up of ch341.
 
 Signed-off-by: Johan Hovold <johan@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABAgAGBQJVHlMkAAoJEEEN5E/e4bSVeAgP/38Kgb18NoGrjA98nFif9Qnc
 9g2Okg9EkSViWneFubUrCvn69a8YWy16v7uosJTGA5ODPNyJRKOFOYIN/IL/itl6
 MqFtSwbz+VbHQQZPH6UuKQQhLUXUG4X/BUzJuehb+Zw3/nY0VWaUBKt8gcPeSnUA
 iGwy3UPxrt7toLiiEBiORQpGMrNeJg6+ZHxBxez2aPDIPi95/j/TaznEoiA1Wb3A
 CroEqh1EZRL+uyze5PI/DLSWWH4yagEVHpGofpum6rbxmKhybkfZbp/NQLNZ6/GV
 2MCjWKfo4KL7bSvgB0pwliUu/5+0dfS848T2RkVPBiVGq9JrIMcgFty86xMJTN2m
 AHo6fw0NKXumOg+G3uXbAZkG6GyLFoqa5K1QCDoThR/9YJbhuInyid6GclHcEjh9
 /lQQoWetUdcw8jS3GP+74IOpiH5+R1MAg6dvnpeA/30Sjn3oNHKbqDq0YKclWUxN
 YrVCt2oWq5cCHVAWemyC2O9Uj65TdK83N/44WGqEbuIPidF/esymJ2Vy0e9aykrh
 K9uMZryg/wq0bb5ru68TqCwVw22EgyVBTNWc3bCA16Jq8TstGNqcRjDsoaQ4jCbz
 ukuuqZc84NcdSDFx5jUEVZ/4vjg4mZ52NPJOQhVD4XFgG0UlNoF2/4uhVC94uUgZ
 GxMJJP3k5lZ7mAsXFZ2h
 =OFj7
 -----END PGP SIGNATURE-----

Merge tag 'usb-serial-4.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-next

Johan writes:

USB-serial updates for v4.1-rc1

Fix up the f81232 driver, which up to this point has mostly been a
placeholder without a proper implementation.

Included is also a minor clean up of ch341.

Signed-off-by: Johan Hovold <johan@kernel.org>
2015-04-03 18:59:34 +02:00
Nicolas PLANEL aa91def41a USB: ch341: set tty baud speed according to tty struct
The ch341_set_baudrate() function initialize the device baud speed
according to the value on priv->baud_rate. By default the ch341_open() set
it to a hardcoded value (DEFAULT_BAUD_RATE 9600). Unfortunately, the
tty_struct is not initialized with the same default value. (usually 56700)

This means that the tty_struct and the device baud rate generator are not
synchronized after opening the port.

Fixup is done by calling ch341_set_termios() if tty exist.
Remove unnecessary variable priv->baud_rate setup as it's already done by
ch341_port_probe().
Remove unnecessary call to ch341_set_{handshake,baudrate}() in
ch341_open() as there already called in ch341_configure() and
ch341_set_termios()

Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2015-03-02 09:31:02 +01:00
Johan Hovold 394a10331a USB: ch341: remove redundant close from open error path
Remove redundant call to ch341_close from error path when submission of
the interrupt urb fails in open.

Signed-off-by: Johan Hovold <johan@kernel.org>
2015-02-26 18:13:02 +01:00
Johan Hovold d9a38a8741 USB: serial: add missing newlines to dev_<level> messages.
Add missing newlines to dev_<level> messages.

Also make some messages less verbose where appropriate.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-03-12 12:44:50 -07:00
Paul Gortmaker 803a536243 usb: delete non-required instances of include <linux/init.h>
None of these files are actually using any __init type directives
and hence don't need to include <linux/init.h>.  Most are just a
left over from __devinit and __cpuinit removal, or simply due to
code getting copied from one driver to the next.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-08 15:01:39 -08:00
Johan Hovold 271ec2d2d7 USB: ch341: clean up interrupt handler
Clean up interrupt completion handler somewhat.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-03 12:42:24 -08:00
Johan Hovold 5e409a265d USB: ch341: switch to generic TIOCMIWAIT implementation
Switch to the generic TIOCMIWAIT implementation which does not suffer
from the races involved when using the deprecated sleep_on functions.

Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-03 12:42:24 -08:00
Johan Hovold d984fe91a8 USB: ch341: only wake up MSR queue on changes
Only wake up MSR wait queue on actual modem-status changes.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-03 12:42:24 -08:00
Johan Hovold fd74b0b144 USB: ch341: fix ignored TIOCMIWAIT mask
Make sure the TIOCMIWAIT mask is always honoured.

The CH341 interrupt status has a multiple-status changed flag which
indicates that multiple status changes has occurred since last interrupt
event. Unfortunately, if the final status is the same, there appears to
be no way to determine which signal(s) has changed (an even number of
times).

This means that the multiple-status flag should not be used in
TIOCMIWAIT as it leads to the signal mask argument being ignored (e.g.
TIOCMIWAIT could return if DSR changes twice, even though the user only
cares about carrier changes).

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-03 12:42:24 -08:00
Johan Hovold b770081f88 USB: ch341: clean up line-status handling
Clean up line-status handling.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-03 12:42:24 -08:00
Johan Hovold ac035628a9 USB: ch341: refactor line-status handling
Refactor line-status handling.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-03 12:42:24 -08:00
Johan Hovold 10c642d077 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>
2014-01-03 12:31:46 -08:00
Johan Hovold 3f55043192 USB: ch341: fix TIOCMIWAIT and disconnect
Use tty-port modem-status-change wait queue on which processes are woken
up at hangup and disconnect.

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

Also remove the redundant wake-up call from dtr_rts.

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

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 13:50:52 -07:00
Johan Hovold fa1e11d523 USB: ch341: fix use-after-free in TIOCMIWAIT
Use the port wait queue and make sure to check the serial disconnected
flag before accessing private port data after waking up.

This is is needed as the private port data (including the wait queue
itself) can be gone when waking up after a disconnect.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-21 15:59:03 -07:00
Johan Hovold 456c5be56e USB: ch341: fix port-data memory leak
Fix port-data memory leak by moving port data allocation to port_probe
and actually implementing deallocation.

Note that this driver has never even bothered to try to deallocate it's
port data...

Compile-only tested.

Cc: <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-10-25 09:36:57 -07:00
Greg Kroah-Hartman 67ef930191 USB: Serial: ch341.c: 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.

CC: Johan Hovold <jhovold@gmail.com>
CC: Alan Stern <stern@rowland.harvard.edu>
CC: Rusty Russell <rusty@rustcorp.com.au>
CC: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-09-18 10:15:17 +01:00
Greg Kroah-Hartman 59d33f2fc2 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>
2012-09-18 09:58:57 +01:00
Greg Kroah-Hartman 79cbeeaf26 USB: serial: ch341.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: Johan Hovold <jhovold@gmail.com>
CC: Alan Stern <stern@rowland.harvard.edu>
CC: Rusty Russell <rusty@rustcorp.com.au>
CC: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-09-13 17:18:10 -07:00
Greg Kroah-Hartman 1c1eaba8e7 USB: serial: ch341: make the reset_resume callback actually work.
I hooked up the wrong callback in my previous patch, this should fix it.

Reported-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Johan Hovold <jhovold@gmail.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-16 08:36:13 -07:00
Greg Kroah-Hartman 622b80cf6a USB: serial: ch341: put reset_resume callback back.
A few patches ago, I removed the reset_resume callback, changing it to
resume instead.  Now that the usb-serial core supports reset_resume, put
this driver callback back as well, so it should work identically to how
it was originally.

Now if this function really is doing what it should be doing, well,
that's a different story, but we are at least doing the identical thing
that we were before...

Cc: Johan Hovold <jhovold@gmail.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-15 15:41:47 -07:00
Greg Kroah-Hartman 68e2411345 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>
2012-05-08 15:46:14 -07:00
Greg Kroah-Hartman 2bfd1c96a9 USB: serial: ch341: remove reset_resume callback
This really just is the resume callback for the device, so use that,
especially as the usb-serial core just overrode this callback so it
wasn't being made anyway.

Cc: Johan Hovold <jhovold@gmail.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-07 14:10:27 -07:00
Greg Kroah-Hartman 32078f915d 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>
2012-05-07 14:02:13 -07:00
Greg Kroah-Hartman 5026bb07be USB: serial: remove usb_serial_probe 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>
2012-05-07 13:48:33 -07:00
Alan Stern c7f3619b90 usb-serial: clean up unneeded PM-related fields
This patch (as1551) cleans up the PM-related entries in the usb_driver
structures of the various USB serial driver modules.  Those entries
are now filled in by the usb-serial core during driver registration,
so they don't need to be initialized explicitly in the source code.

The same is true of the one remaining no_dynamic_id entry.

reset_resume remains a small problem, because the serial core doesn't
support it.  The patch ignores these entries.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-07 13:05:51 -07:00
Greg Kroah-Hartman 2ec7d459c0 USB: ch341.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: Johan Hovold <jhovold@gmail.com>
CC: Rusty Russell <rusty@rustcorp.com.au>
CC: Alan Stern <stern@rowland.harvard.edu>
CC: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-03 16:43:55 -07:00