Commit graph

3313 commits

Author SHA1 Message Date
Mans Rullgard a49e1abf07 USB: serial: cp210x: support all gpios on CP2102N QFN28 package
The QFN28 package version of the CP2102N has three additional gpio pins.
Add support for these.

Signed-off-by: Mans Rullgard <mans@mansr.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2019-01-25 10:35:04 +01:00
Greg Kroah-Hartman cae8dc3b68 USB: add missing SPDX lines to Kconfig and Makefiles
There are a few remaining drivers/usb/ files that do not have SPDX
identifiers in them, all of these are either Kconfig or Makefiles.  Add
the correct GPL-2.0 identifier to them to make scanning tools happy.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-01-22 09:08:17 +01:00
Greg Kroah-Hartman 527c1e567e USB: serial: keyspan_usa: add proper SPDX lines for .h files
The keyspan_usa??msg.h files are under a BSD-3 style license, so
properly label them as such with a SPDX line at the top of the file.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2019-01-18 11:09:32 +01:00
Charles Yeh 4dcf9ddc9a USB: serial: pl2303: add new PID to support PL2303TB
Add new PID to support PL2303TB (TYPE_HX)

Signed-off-by: Charles Yeh <charlesyeh522@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2019-01-17 17:24:39 +01:00
Karoly Pados a8eda9fa1b USB: serial: ftdi_sio: fix GPIO not working in autosuspend
There is a bug in the current GPIO code for ftdi_sio: it failed to take USB
autosuspend into account. If the device is in autosuspend, calls to
usb_control_msg() fail with -EHOSTUNREACH. Because the standard value for
autosuspend timeout is usually 2-5 seconds, this made it almost impossible
to use the GPIOs on machines that have USB autosuspend enabled. This patch
fixes the issue by acquiring a PM lock on the device for the duration of
the USB transfers. Tested on an FT231X device.

Signed-off-by: Karoly Pados <pados@pados.hu>
[ johan: simplify code somewhat ]
Fixes: ba93cc7da8 ("USB: serial: ftdi_sio: implement GPIO support for FT-X devices")
Cc: stable <stable@vger.kernel.org>	# 4.20
Signed-off-by: Johan Hovold <johan@kernel.org>
2019-01-14 14:40:11 +01:00
Max Schulze b81c2c33ea USB: serial: simple: add Motorola Tetra TPG2200 device id
Add new Motorola Tetra device id for Motorola Solutions TETRA PEI device

T:  Bus=02 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  4 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0cad ProdID=9016 Rev=24.16
S:  Manufacturer=Motorola Solutions, Inc.
S:  Product=TETRA PEI interface
C:  #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=usb_serial_simple
I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=usb_serial_simple

Signed-off-by: Max Schulze <max.schulze@posteo.de>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2019-01-07 16:37:52 +01:00
Jörgen Storvist 4b2c01ad90 USB: serial: option: add Fibocom NL678 series
Added USB serial option driver support for Fibocom NL678 series cellular
module: VID 2cb7 and PIDs 0x0104 and 0x0105.
Reserved network and ADB interfaces.

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=2cb7 ProdID=0104 Rev=03.10
S:  Manufacturer=Fibocom
S:  Product=Fibocom NL678-E Modem
S:  SerialNumber=12345678
C:  #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
I:  If#= 5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none)

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  3 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=2cb7 ProdID=0105 Rev=03.10
S:  Manufacturer=Fibocom
S:  Product=Fibocom NL678-E Modem
S:  SerialNumber=12345678
C:  #Ifs= 7 Cfg#= 1 Atr=a0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 4 Alt= 0 #EPs= 1 Cls=02(commc) Sub=06 Prot=00 Driver=cdc_ether
I:  If#= 5 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether
I:  If#= 6 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none)

Signed-off-by: Jörgen Storvist <jorgen.storvist@gmail.com>
Cc: stable <stable@vger.kernel.org>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-21 16:47:02 +01:00
Greg Kroah-Hartman cd6a22310e Merge USB 4.20-rc8 mergepoint into usb-next
We need the USB changes in here for additional patches to be able to
apply cleanly.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-21 16:46:08 +01:00
Greg Kroah-Hartman 1e12a521d6 USB-serial updates for 4.21-rc1
Here are the USB-serial updates for 4.21-rc1, including:
 
  - support for mos7840 3-port devices
  - improved ftdi baud-rate divisor calculations
  - support for a new class of f81534 devices
 
 Included are also various clean ups and some new pl2303 device ids.
 
 All have been in linux-next with no reported issues.
 
 Signed-off-by: Johan Hovold <johan@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQQHbPq+cpGvN/peuzMLxc3C7H1lCAUCXBva9AAKCRALxc3C7H1l
 CP6XAQClpmmKj59AiAJK+hlWIbNpznPUUrkGHS7mFyuWkDrllQEAsK2IofNWbs9y
 g0ot/v4UgUVZHySGl5yYoV4A0uKJdAQ=
 =oyPx
 -----END PGP SIGNATURE-----

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

Johan writes:

USB-serial updates for 4.21-rc1

Here are the USB-serial updates for 4.21-rc1, including:

 - support for mos7840 3-port devices
 - improved ftdi baud-rate divisor calculations
 - support for a new class of f81534 devices

Included are also various clean ups and some new pl2303 device ids.

All have been in linux-next with no reported issues.

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

* tag 'usb-serial-4.21-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial:
  USB: serial: pl2303: add ids for Hewlett-Packard HP POS pole displays
  USB: serial: mos7840: remove set but not used variables 'number, serial'
  USB: serial: mos7840: add a product ID for the new product
  USB: serial: mos7840: clean up register handling
  USB: serial: ftdi_sio: use rounding when calculating baud rate divisors
  USB: serial: f81534: fix reading old/new IC config
  USB: serial: mos7840: remove set but not used variables 'st, data1, iflag'
  USB: serial: quatech2: remove set but not used variable 'port_priv'
2018-12-21 08:36:54 +01:00
Scott Chen 8d503f206c USB: serial: pl2303: add ids for Hewlett-Packard HP POS pole displays
Add device ids to pl2303 for the HP POS pole displays:
LM920:   03f0:026b
TD620:   03f0:0956
LD960TA: 03f0:4439
LD220TA: 03f0:4349
LM940:   03f0:5039

Signed-off-by: Scott Chen <scott@labau.com.tw>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-12-18 10:22:37 +01:00
Jörgen Storvist 28a86092b1 USB: serial: option: add Telit LN940 series
Added USB serial option driver support for Telit LN940 series cellular
modules. Covering both QMI and MBIM modes.

usb-devices output (0x1900):
T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 21 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1bc7 ProdID=1900 Rev=03.10
S:  Manufacturer=Telit
S:  Product=Telit LN940 Mobile Broadband
S:  SerialNumber=0123456789ABCDEF
C:  #Ifs= 5 Cfg#= 1 Atr=a0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
I:  If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option

usb-devices output (0x1901):
T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 20 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1bc7 ProdID=1901 Rev=03.10
S:  Manufacturer=Telit
S:  Product=Telit LN940 Mobile Broadband
S:  SerialNumber=0123456789ABCDEF
C:  #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 4 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0e Prot=00 Driver=cdc_mbim
I:  If#= 5 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim

Signed-off-by: Jörgen Storvist <jorgen.storvist@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-12-13 20:08:00 +01:00
Jörgen Storvist 3036022444 USB: serial: option: add Fibocom NL668 series
Added USB serial option driver support for Fibocom NL668 series cellular
modules. Reserved USB endpoints 4, 5 and 6 for network + ADB interfaces.

usb-devices output (QMI mode)
T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 16 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1508 ProdID=1001 Rev=03.18
S:  Manufacturer=Nodecom NL668 Modem
S:  Product=Nodecom NL668-CN Modem
S:  SerialNumber=
C:  #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
I:  If#= 5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none)

usb-devices output (ECM mode)
T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 17 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1508 ProdID=1001 Rev=03.18
S:  Manufacturer=Nodecom NL668 Modem
S:  Product=Nodecom NL668-CN Modem
S:  SerialNumber=
C:  #Ifs= 7 Cfg#= 1 Atr=a0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 4 Alt= 0 #EPs= 1 Cls=02(commc) Sub=06 Prot=00 Driver=cdc_ether
I:  If#= 5 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether
I:  If#= 6 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none)

Signed-off-by: Jörgen Storvist <jorgen.storvist@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-12-13 11:24:58 +01:00
Jörgen Storvist cc6730df08 USB: serial: option: add Simcom SIM7500/SIM7600 (MBIM mode)
Added USB serial option driver support for Simcom SIM7500/SIM7600 series
cellular modules exposing MBIM interface (VID 0x1e0e,PID 0x9003)

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 14 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1e0e ProdID=9003 Rev=03.18
S:  Manufacturer=SimTech, Incorporated
S:  Product=SimTech, Incorporated
S:  SerialNumber=0123456789ABCDEF
C:  #Ifs= 7 Cfg#= 1 Atr=a0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 5 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0e Prot=00 Driver=cdc_mbim
I:  If#= 6 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim

Signed-off-by: Jörgen Storvist <jorgen.storvist@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-12-12 17:13:39 +01:00
Jörgen Storvist 70a7444c55 USB: serial: option: add GosunCn ZTE WeLink ME3630
Added USB serial option driver support for GosunCn ZTE WeLink ME3630
series cellular modules for USB modes ECM/NCM and MBIM.

usb-devices output MBIM mode:
T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 10 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=19d2 ProdID=0602 Rev=03.18
S:  Manufacturer=Android
S:  Product=Android
S:  SerialNumber=
C:  #Ifs= 5 Cfg#= 1 Atr=a0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 3 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0e Prot=00 Driver=cdc_mbim
I:  If#= 4 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim

usb-devices output ECM/NCM mode:
T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 11 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=19d2 ProdID=1476 Rev=03.18
S:  Manufacturer=Android
S:  Product=Android
S:  SerialNumber=
C:  #Ifs= 5 Cfg#= 1 Atr=a0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 3 Alt= 0 #EPs= 1 Cls=02(commc) Sub=06 Prot=00 Driver=cdc_ether
I:  If#= 4 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether

Signed-off-by: Jörgen Storvist <jorgen.storvist@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-12-12 17:13:38 +01:00
YueHaibing 01688a6d66 USB: serial: mos7840: remove set but not used variables 'number, serial'
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/usb/serial/mos7840.c: In function 'mos7840_send_cmd_write_baud_rate':
drivers/usb/serial/mos7840.c:1584:16: warning:
 variable 'number' set but not used [-Wunused-but-set-variable]

drivers/usb/serial/mos7840.c: In function 'mos7840_change_port_settings':
drivers/usb/serial/mos7840.c:1695:21: warning:
 variable 'serial' set but not used [-Wunused-but-set-variable]

'number' never used since introduction in commit 3f5429746d ("USB: Moschip
7840 USB-Serial Driver")

'serial' not used since commit 5833041f1b ("USB: serial: remove unnecessary
reinitialisations of urb->dev")

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-12-10 10:20:44 +01:00
Tore Anderson d57ec3c83b USB: serial: option: add HP lt4132
The HP lt4132 is a rebranded Huawei ME906s-158 LTE modem.

The interface with protocol 0x16 is "CDC ECM & NCM" according to the *.inf
files included with the Windows driver. Attaching the option driver to it
doesn't result in a /dev/ttyUSB* device being created, so I've excluded it.
Note that it is also excluded for corresponding Huawei-branded devices, cf.
commit d544db293a ("USB: support new huawei devices in option.c").

T:  Bus=01 Lev=01 Prnt=01 Port=02 Cnt=02 Dev#=  3 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=ff MxPS=64 #Cfgs=  3
P:  Vendor=03f0 ProdID=a31d Rev=01.02
S:  Manufacturer=HP Inc.
S:  Product=HP lt4132 LTE/HSPA+ 4G Module
S:  SerialNumber=0123456789ABCDEF
C:  #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=2mA
I:  If#=0x0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=06 Prot=10 Driver=option
I:  If#=0x1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=13 Driver=option
I:  If#=0x2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=12 Driver=option
I:  If#=0x3 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=06 Prot=16 Driver=(none)
I:  If#=0x4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=14 Driver=option
I:  If#=0x5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=1b Driver=option

T:  Bus=01 Lev=01 Prnt=01 Port=02 Cnt=02 Dev#=  3 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=ff MxPS=64 #Cfgs=  3
P:  Vendor=03f0 ProdID=a31d Rev=01.02
S:  Manufacturer=HP Inc.
S:  Product=HP lt4132 LTE/HSPA+ 4G Module
S:  SerialNumber=0123456789ABCDEF
C:  #Ifs= 7 Cfg#= 2 Atr=a0 MxPwr=2mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=06 Prot=00 Driver=cdc_ether
I:  If#=0x1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=06 Prot=00 Driver=cdc_ether
I:  If#=0x2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=06 Prot=10 Driver=option
I:  If#=0x3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=13 Driver=option
I:  If#=0x4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=12 Driver=option
I:  If#=0x5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=14 Driver=option
I:  If#=0x6 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=1b Driver=option

T:  Bus=01 Lev=01 Prnt=01 Port=02 Cnt=02 Dev#=  3 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=ff MxPS=64 #Cfgs=  3
P:  Vendor=03f0 ProdID=a31d Rev=01.02
S:  Manufacturer=HP Inc.
S:  Product=HP lt4132 LTE/HSPA+ 4G Module
S:  SerialNumber=0123456789ABCDEF
C:  #Ifs= 3 Cfg#= 3 Atr=a0 MxPwr=2mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0e Prot=00 Driver=cdc_mbim
I:  If#=0x1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim
I:  If#=0x2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=14 Driver=option

Signed-off-by: Tore Anderson <tore@fud.no>
Cc: stable@vger.kernel.org
[ johan: drop id defines ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-12-10 09:59:00 +01:00
Johan Hovold f51ccf4621 USB: serial: console: fix reported terminal settings
The USB-serial console implementation has never reported the actual
terminal settings used. Despite storing the corresponding cflags in its
struct console, these were never honoured on later tty open() where the
tty termios would be left initialised to the driver defaults.

Unlike the serial console implementation, the USB-serial code calls
subdriver open() already at console setup. While calling set_termios()
and write() before open() looks like it could work for some USB-serial
drivers, others definitely do not expect this, so modelling this after
serial core is going to be intrusive, if at all possible.

Instead, use a (renamed) tty helper to save the termios data used at
console setup so that the tty termios reflects the actual terminal
settings after a subsequent tty open().

Note that the calls to tty_init_termios() (tty_driver_install()) and
tty_save_termios() are serialised using the disconnect mutex.

This specifically fixes a regression that was triggered by a recent
change adding software flow control to the pl2303 driver: a getty trying
to disable flow control while leaving the baud rate unchanged would now
also set the baud rate to the driver default (prior to the flow-control
change this had been a noop).

Fixes: 7041d9c3f0 ("USB: serial: pl2303: add support for tx xon/xoff flow control")
Cc: stable <stable@vger.kernel.org>	# 4.18
Cc: Florian Zumbiehl <florz@florz.de>
Reported-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-12-05 11:29:10 +01:00
JackyChou 32899682cf USB: serial: mos7840: add a product ID for the new product
Add a new PID 0x7843 to the driver.
Let the new products be able to set up 3 serial ports with the driver.

Note that this depends on e8603076f5 ("USB: serial: mos7840: clean up
register handling").

Signed-off-by: JackyChou <jackychou@asix.com.tw>
[ johan: mention dependency in case anyone wants to backport this ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-12-05 07:05:11 +01:00
JackyChou e8603076f5 USB: serial: mos7840: clean up register handling
In the read/write function, set port 2 independently in the 2-port case.

When setting the offset of port registers, the offset between port 1 and
other ports is different, so port 1 is set independently.
Then in the rest of ports, the port 2 between 2-ports case and 4-ports case
is different, so port 2 in 2-ports case is set independently.

Specifically, port 2 in the 2-port case maps to the registers used by
port 3 in the 4-port case.

Signed-off-by: JackyChou <jackychou@asix.com.tw>
[ johan: simplify register-offset handling at port probe, add a comment
         and amend commit message ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-12-05 06:58:30 +01:00
Nikolaj Fogh 6abd837104 USB: serial: ftdi_sio: use rounding when calculating baud rate divisors
Improve baud-rate generation by using rounding-to-closest instead of
truncation in divisor calculation.

Results have been verified by logic analyzer on an FT232RT (232BM) chip.
The following table shows the wanted baud rate, the baud rate obtained
with the old method (truncation), with the new method (rounding) and the
baud rate generated by the windows 10 driver. The numbers in parentheses
is the error.

+- Wanted --+------ Old -------+------ New -------+------ Win -------+
|    9600   |    9600 (0.00%)  |    9604 (0.05%)  |    9605 (0.05%)  |
|   19200   |   19200 (0.00%)  |   19199 (0.01%)  |   19198 (0.01%)  |
|   38400   |   38395 (0.01%)  |   38431 (0.08%)  |   38394 (0.02%)  |
|   57600   |   57725 (0.22%)  |   57540 (0.10%)  |   57673 (0.13%)  |
|  115200   |  115307 (0.09%)  |  115330 (0.11%)  |  115320 (0.10%)  |
|  921600   |  919963 (0.18%)  |  920386 (0.13%)  |  920810 (0.09%)  |
|  961200   |  996512 (3.67%)  |  956480 (0.49%)  |  956937 (0.44%)  |
+-----------+------------------+------------------+------------------+

The error due to noise in the measurements is in the order of a few
tenths of a %. As can be seen, the baud rate is significantly improved
for some rates (e.g. 961200), and corresponds to the output given by the
windows driver.

The theoretical baud rate has been calculated for all baud rates from 1
to 3M, and as expected, the error is centered around 0, with a triangle
shape instead of a sawtooth, so the maximum error is decreased to half.

Signed-off-by: Nikolaj Fogh <nikolajfogh@gmail.com>
[ johan: edit commit message slightly ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-11-23 09:49:37 +01:00
Ji-Ze Hong (Peter Hong) ab60075f2a USB: serial: f81534: fix reading old/new IC config
The F81532/534 had a internal configuration space to save & control
IC state with address F81534_CUSTOM_ADDRESS_START (0x2f00). Layout
as following:
	+00h: to indicate the section is valid
	+01h~04h: UART Mode & port availability
	+05h~08h: Output pin control on IC power on
	+09h~12h: Output pin control on working <-- New added

Old driver will use +05~08h as default on working, but newer IC will
configed with shutdown mode(7) in 05h~08h and working mode with RS232(1)
in 09h~12h. It'll make mainstream driver not working.

This patch will make mainstream driver compatible older and newer IC.
If using a old IC, the +05h~08h will be 00h~06h, we'll direct apply it.
If using a new IC, the +05h~08h will be 07h or larger, we'll read +09h~12h
to apply newer configuration.

Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-11-20 18:25:44 +01:00
YueHaibing 32d8a6fc5b USB: serial: mos7840: remove set but not used variables 'st, data1, iflag'
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/usb/serial/mos7840.c: In function 'mos7840_interrupt_callback':
drivers/usb/serial/mos7840.c:604:14: warning:
 variable 'st' set but not used [-Wunused-but-set-variable]

drivers/usb/serial/mos7840.c: In function 'mos7840_write':
drivers/usb/serial/mos7840.c:1303:17: warning:
 variable 'data1' set but not used [-Wunused-but-set-variable]

drivers/usb/serial/mos7840.c:1700:11: warning:
 variable 'iflag' set but not used [-Wunused-but-set-variable]

They are never used since introduction in commit 3f5429746d ("USB:
Moschip 7840 USB-Serial Driver")

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-11-12 10:35:14 +01:00
YueHaibing 548f32f594 USB: serial: quatech2: remove set but not used variable 'port_priv'
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/usb/serial/quatech2.c: In function 'qt2_process_read_urb':
drivers/usb/serial/quatech2.c:503:27: warning:
 variable 'port_priv' set but not used [-Wunused-but-set-variable]

It not used any more after commit 2be818a116 ('Revert "USB: quatech2:
only write to the tty if the port is open."')

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-11-12 10:08:10 +01:00
Linus Torvalds 9703fc8caf USB/PHY patches for 4.20-rc1
Here is the big USB/PHY driver patches for 4.20-rc1
 
 Lots of USB changes in here, primarily in these areas:
   - typec updates and new drivers
   - new PHY drivers
   - dwc2 driver updates and additions (this old core keeps getting added
     to new devices.)
   - usbtmc major update based on the industry group coming together and
     working to add new features and performance to the driver.
   - USB gadget additions for new features
   - USB gadget configfs updates
   - chipidea driver updates
   - other USB gadget updates
   - USB serial driver updates
   - renesas driver updates
   - xhci driver updates
   - other tiny USB driver updates
 
 All of these have been in linux-next for a while with no reported
 issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCW9LlHw8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ymnvwCffYmMWyMG9zSOw1oSzFPl7TVN1hYAoMyJqzLg
 umyLwWxC9ZWWkrpc3iD8
 =ux+Y
 -----END PGP SIGNATURE-----

Merge tag 'usb-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB/PHY updates from Greg KH:
 "Here is the big USB/PHY driver patches for 4.20-rc1

  Lots of USB changes in here, primarily in these areas:

   - typec updates and new drivers

   - new PHY drivers

   - dwc2 driver updates and additions (this old core keeps getting
     added to new devices.)

   - usbtmc major update based on the industry group coming together and
     working to add new features and performance to the driver.

   - USB gadget additions for new features

   - USB gadget configfs updates

   - chipidea driver updates

   - other USB gadget updates

   - USB serial driver updates

   - renesas driver updates

   - xhci driver updates

   - other tiny USB driver updates

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'usb-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (229 commits)
  usb: phy: ab8500: silence some uninitialized variable warnings
  usb: xhci: tegra: Add genpd support
  usb: xhci: tegra: Power-off power-domains on removal
  usbip:vudc: BUG kmalloc-2048 (Not tainted): Poison overwritten
  usbip: tools: fix atoi() on non-null terminated string
  USB: misc: appledisplay: fix backlight update_status return code
  phy: phy-pxa-usb: add a new driver
  usb: host: add DT bindings for faraday fotg2
  usb: host: ohci-at91: fix request of irq for optional gpio
  usb/early: remove set but not used variable 'remain_length'
  usb: typec: Fix copy/paste on typec_set_vconn_role() kerneldoc
  usb: typec: tcpm: Report back negotiated PPS voltage and current
  USB: core: remove set but not used variable 'udev'
  usb: core: fix memory leak on port_dev_path allocation
  USB: net2280: Remove ->disconnect() callback from net2280_pullup()
  usb: dwc2: disable power_down on rockchip devices
  usb: gadget: udc: renesas_usb3: add support for r8a77990
  dt-bindings: usb: renesas_usb3: add bindings for r8a77990
  usb: gadget: udc: renesas_usb3: Add r8a774a1 support
  USB: serial: cypress_m8: remove set but not used variable 'iflag'
  ...
2018-10-26 08:14:13 -07:00
Linus Torvalds 44adbac8f7 Merge branch 'work.tty-ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull tty ioctl updates from Al Viro:
 "This is the compat_ioctl work related to tty ioctls.

  Quite a bit of dead code taken out, all tty-related stuff gone from
  fs/compat_ioctl.c. A bunch of compat bugs fixed - some still remain,
  but all more or less generic tty-related ioctls should be covered
  (remaining issues are in things like driver-private ioctls in a pcmcia
  serial card driver not getting properly handled in 32bit processes on
  64bit host, etc)"

* 'work.tty-ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (53 commits)
  kill TIOCSERGSTRUCT
  change semantics of ldisc ->compat_ioctl()
  kill TIOCSER[SG]WILD
  synclink_gt(): fix compat_ioctl()
  pty: fix compat ioctls
  compat_ioctl - kill keyboard ioctl handling
  gigaset: add ->compat_ioctl()
  vt_compat_ioctl(): clean up, use compat_ptr() properly
  gigaset: don't try to printk userland buffer contents
  dgnc: don't bother with (empty) stub for TCXONC
  dgnc: leave TIOC[GS]SOFTCAR to ldisc
  remove fallback to drivers for TIOCGICOUNT
  dgnc: break-related ioctls won't reach ->ioctl()
  kill the rest of tty COMPAT_IOCTL() entries
  dgnc: TIOCM... won't reach ->ioctl()
  isdn_tty: TCSBRK{,P} won't reach ->ioctl()
  kill capinc_tty_ioctl()
  take compat TIOC[SG]SERIAL treatment into tty_compat_ioctl()
  synclink: reduce pointless checks in ->ioctl()
  complete ->[sg]et_serial() switchover
  ...
2018-10-24 14:43:41 +01:00
Greg Kroah-Hartman 89303c7ea7 USB-serial updates for v4.20-rc1
Here are the USB-serial updates for 4.20-rc1, including:
 
  - support for CBUS GPIO on FTDI devices (FTX and FT232R)
  - fix of a long-standing transfer-length bug
 
 Included are also various clean ups.
 
 All have been in linux-next with no reported issues.
 
 Signed-off-by: Johan Hovold <johan@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEHszNKQClByu0A+9RQQ3kT97htJUFAlvIZhIRHGpvaGFuQGtl
 cm5lbC5vcmcACgkQQQ3kT97htJUNIQ//fv+Jn/XQ4H9Ystik+uJbHOSXYG0OJPkz
 IYZcFdlJBwdH9fF0Bof6vRVIlltJH6ZE636qWZi4D0fuS+pjGoyV3XXYAmiJc+d3
 jXZSvuib08s89SYz2sK8CYrlgZYnMkn/HO8SIs/dLE81HvGpb+3qS0kcqBoepo5f
 MP6TA4jBcRkLVe9gEvgNDwm+Vc1I9Myg6Co5SClaNZRnuj4UyreqX1DIp2lU3evw
 gMq1AHZkwijrdES1FbW9SQ4cVujG3KXbKCrrQyXMcTNPX+4BlayiEqC12eNcoP2Q
 Ng1IAXTZWP1jFCDWZ5B2gn6r0jGILn2leFKcazt9B5lN/YTE51YgbV2JHlnc+8IV
 z1dOs3IIINfwTchh8DSW9nS1j8krFzrGebXlcMApuSqq7s7MGZVy7P48FsgtUd6Y
 B2msIjAWxnLf4XQcKWLA9tZj5stBNInSfFFHi4oUhC/A62teC/XFF8505N9y9MVr
 PhgWnH2zd7cayuUoHQTVvVpvmnRyJBLmyawqSCGLQvo22II58zvsvRX7K/Mop1WB
 u7+dxVfVb+fgpBM5RjfNRK/qXux7BqgXQFhNzzCREiKDi+Mv+2VOe3rmXOi8bMHs
 SKY2r70Fk1ihmxSTcUMCTG1bc3BNZwpccgpW9vWw5Kia3lo3JUgd8OSIfxFnLi03
 /GAnh8pnSh8=
 =V6Jo
 -----END PGP SIGNATURE-----

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

Johan writes:

USB-serial updates for v4.20-rc1

Here are the USB-serial updates for 4.20-rc1, including:

 - support for CBUS GPIO on FTDI devices (FTX and FT232R)
 - fix of a long-standing transfer-length bug

Included are also various clean ups.

All have been in linux-next with no reported issues.

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

* tag 'usb-serial-4.20-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial:
  USB: serial: cypress_m8: remove set but not used variable 'iflag'
  USB: serial: cypress_m8: fix interrupt-out transfer length
  USB: serial: ftdi_sio: add support for FT232R CBUS gpios
  USB: serial: ftdi_sio: fix gpio name collisions
  USB: serial: ftdi_sio: implement GPIO support for FT-X devices
  USB: serial: cypress_m8: fix spelling mistake "retreiving" -> "retrieving"
2018-10-18 14:59:04 +02:00
Al Viro 930236a308 complete ->[sg]et_serial() switchover
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:43 -04:00
Al Viro 15cc7bad48 usb_wwan: switch to ->[sg]et_serial()
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:42 -04:00
Al Viro fc6cc979e4 whiteheat: switch to ->get_serial()
... and fix the return value - on success it used to have ioctl(2)
fill the user-supplied struct serial_struct and return -ENOTTY.

Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:42 -04:00
Al Viro 57e5723611 ti_usb_3410_5052: switch to ->[sg]et_serial()
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:41 -04:00
Al Viro ee08cefbb5 ssu100: switch to ->get_serial()
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:41 -04:00
Al Viro 8fbde7984e quatech2: switch to ->get_serial()
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:40 -04:00
Al Viro 9326ec59ec pl2303: switch to ->get_serial()
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:40 -04:00
Al Viro 30296aa419 opticon: switch to ->get_serial()
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:39 -04:00
Al Viro b27ef409b4 mos7840: switch to ->get_serial()
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:39 -04:00
Al Viro 7cf3e600a0 mos7720: switch to ->get_serial()
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:38 -04:00
Al Viro 2a5357e563 io_ti: switch to ->get_serial()
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:38 -04:00
Al Viro e27235eda5 io_edgeport: switch to ->get_serial()
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:37 -04:00
Al Viro 3ae36bed3a fdti_sio: switch to ->[sg]et_serial()
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:37 -04:00
Al Viro c8f97e77d5 f81534: switch to ->get_serial()
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:36 -04:00
Al Viro 056abede09 f81232: switch to ->get_serial()
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:35 -04:00
Al Viro aadcd0a178 ark3116: switch to ->get_serial()
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:35 -04:00
Al Viro 81732b26e0 usb-serial: begin switching to ->[sg]et_serial()
add such methods for usb_serial_driver, provide tty_operations
->[sg]et_serial() calling those.  For now the lack of methods
in driver means ENOIOCTLCMD from usb-serial ->[sg]et_serial(),
making tty_ioctl() fall back to calling ->ioctl().  Once all
drivers are converted, we'll be returning -ENOTTY instead,
completing the switchover.

Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-13 00:50:34 -04:00
YueHaibing 17c42e3499 USB: serial: cypress_m8: remove set but not used variable 'iflag'
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/usb/serial/cypress_m8.c: In function 'cypress_set_termios':
drivers/usb/serial/cypress_m8.c:866:18: warning:
 variable 'iflag' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-10-05 08:58:42 +02:00
Johan Hovold 56445eef55 USB: serial: cypress_m8: fix interrupt-out transfer length
Fix interrupt-out transfer length which was being set to the
transfer-buffer length rather than the size of the outgoing packet.

Note that no slab data was leaked as the whole transfer buffer is always
cleared before each transfer.

Fixes: 9aa8dae7b1 ("cypress_m8: use usb_fill_int_urb where appropriate")
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-10-05 08:58:12 +02:00
Johan Hovold ff32d97e39 USB: serial: ftdi_sio: add support for FT232R CBUS gpios
Enable support for cbus gpios on FT232R. The cbus configuration is
stored in one word in the EEPROM at offset 0x0a (byte-offset 0x14) with
the mux config for CBUS0, CBUS1, CBUS2 and CBUS3 in bits 0..3, 4..7,
8..11 and 12..15, respectively.

Tested using FT232RL by configuring one cbus pin at a time.

Signed-off-by: Johan Hovold <johan@kernel.org>
2018-10-05 08:57:06 +02:00
Johan Hovold e0658e3074 USB: serial: ftdi_sio: fix gpio name collisions
Drop the gpio line names, which cause gpiolib to complain loudly
whenever a second ftdi gpiochip is registered:

	gpio gpiochip5: Detected name collision for GPIO name 'CBUS0'
	gpio gpiochip5: Detected name collision for GPIO name 'CBUS1'
	gpio gpiochip5: Detected name collision for GPIO name 'CBUS2'
	gpio gpiochip5: Detected name collision for GPIO name 'CBUS3'

and also prevents the legacy sysfs interface from being used (as the
line names are used as device names whenever they are set):

	sysfs: cannot create duplicate filename '/class/gpio/CBUS0'

Until non-unique names are supported by gpiolib (without warnings and
stack dumps), let's leave the gpio lines unnamed.

Signed-off-by: Johan Hovold <johan@kernel.org>
2018-10-05 08:57:05 +02:00
Karoly Pados ba93cc7da8 USB: serial: ftdi_sio: implement GPIO support for FT-X devices
This patch allows using the CBUS pins of FT-X devices as GPIO in CBUS
bitbanging mode. There is no conflict between the GPIO and VCP
functionality in this mode. Tested on FT230X and FT231X.

As there is no way to request the current CBUS register configuration
from the device, all CBUS pins are set to a known state when the first
GPIO is requested. This allows using libftdi to set the GPIO pins
before loading this module for UART functionality, a behavior that
existing applications might be relying upon (though no specific case
is known to the authors of this patch).

Signed-off-by: Karoly Pados <pados@pados.hu>
[ johan: minor style changes ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-09-26 11:59:56 +02:00
Johan Hovold f5fad711c0 USB: serial: simple: add Motorola Tetra MTP6550 id
Add device-id for the Motorola Tetra radio MTP6550.

Bus 001 Device 004: ID 0cad:9012 Motorola CGISS
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x0cad Motorola CGISS
  idProduct          0x9012
  bcdDevice           24.16
  iManufacturer           1 Motorola Solutions, Inc.
  iProduct                2 TETRA PEI interface
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           55
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          3 Generic Serial config
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0000
  (Bus Powered)

Reported-by: Hans Hult <hanshult35@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-09-24 15:30:16 +02:00
Colin Ian King bbc1f57aa8 USB: serial: cypress_m8: fix spelling mistake "retreiving" -> "retrieving"
Trivial fix to spelling mistake in dev_dbg message

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-09-24 10:48:36 +02:00
Al Viro 7eaec37e04 mos7720: bury dead TIOCM... in ->ioctl()
These ioctls never reach driver's ->ioctl() - tty_ioctl() handles
them on its own.  ->tiocm[gs]et() is what actually gets called,
and mos7720 provides those, with results equivalent to what the
unreachable code would be doing when called.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-09-14 11:12:37 -04:00
Johan Hovold 35aecc02b5 USB: serial: option: add two-endpoints device-id flag
Allow matching on interfaces having two endpoints by adding a new
device-id flag.

This allows for the handling of devices whose interface numbers can
change (e.g. Quectel EP06) to be contained in the device-id table.

Tested-by: Kristian Evensen <kristian.evensen@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-09-14 10:37:41 +02:00
Kristian Evensen 36cae56840 USB: serial: option: improve Quectel EP06 detection
The Quectel EP06 (and EM06/EG06) LTE modem supports updating the USB
configuration, without the VID/PID or configuration number changing.
When the configuration is updated and interfaces are added/removed, the
interface numbers are updated. This causes our current code for matching
EP06 not to work as intended, as the assumption about reserved
interfaces no longer holds. If for example the diagnostic (first)
interface is removed, option will (try to) bind to the QMI interface.

This patch improves EP06 detection by replacing the current match with
two matches, and those matches check class, subclass and protocol as
well as VID and PID. The diag interface exports class, subclass and
protocol as 0xff. For the other serial interfaces, class is 0xff and
subclass and protocol are both 0x0.

The modem can export the following devices and always in this order:
diag, nmea, at, ppp. qmi and adb. This means that diag can only ever be
interface 0, and interface numbers 1-5 should be marked as reserved. The
three other serial devices can have interface numbers 0-3, but I have
not marked any interfaces as reserved. The reason is that the serial
devices are the only interfaces exported by the device where subclass
and protocol is 0x0.

QMI exports the same class, subclass and protocol values as the diag
interface. However, the two interfaces have different number of
endpoints, QMI has three and diag two. I have added a check for number
of interfaces if VID/PID matches the EP06, and we ignore the device if
number of interfaces equals three (and subclass is set).

Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
Acked-by: Dan Williams <dcbw@redhat.com>
[ johan: drop uneeded RSVD(5) for ADB ]
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-09-14 10:37:41 +02:00
Johan Hovold 5dfdd24eb3 USB: serial: ti_usb_3410_5052: fix array underflow in completion handler
Similarly to a recently reported bug in io_ti, a malicious USB device
could set port_number to a negative value and we would underflow the
port array in the interrupt completion handler.

As these devices only have one or two ports, fix this by making sure we
only consider the seventh bit when determining the port number (and
ignore bits 0xb0 which are typically set to 0x30).

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-08-27 11:53:19 +02:00
Johan Hovold 691a03cfe8 USB: serial: io_ti: fix array underflow in completion handler
As reported by Dan Carpenter, a malicious USB device could set
port_number to a negative value and we would underflow the port array in
the interrupt completion handler.

As these devices only have one or two ports, fix this by making sure we
only consider the seventh bit when determining the port number (and
ignore bits 0xb0 which are typically set to 0x30).

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-08-27 11:52:34 +02:00
Movie Song 29c692c96b USB: serial: pl2303: add a new device id for ATEN
Signed-off-by: Movie Song <MovieSong@aten-itlab.cn>
Cc: Johan Hovold <johan@kernel.org>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-08-02 10:37:04 +02:00
Aleksander Morgado 7bab01ecc6 USB: option: add support for DW5821e
The device exposes AT, NMEA and DIAG ports in both USB configurations.

The patch explicitly ignores interfaces 0 and 1, as they're bound to
other drivers already; and also interface 6, which is a GNSS interface
for which we don't have a driver yet.

T:  Bus=01 Lev=03 Prnt=04 Port=00 Cnt=01 Dev#= 18 Spd=480 MxCh= 0
D:  Ver= 2.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  2
P:  Vendor=413c ProdID=81d7 Rev=03.18
S:  Manufacturer=DELL
S:  Product=DW5821e Snapdragon X20 LTE
S:  SerialNumber=0123456789ABCDEF
C:  #Ifs= 7 Cfg#= 2 Atr=a0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0e Prot=00 Driver=cdc_mbim
I:  If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim
I:  If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#= 6 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)

T:  Bus=01 Lev=03 Prnt=04 Port=00 Cnt=01 Dev#= 16 Spd=480 MxCh= 0
D:  Ver= 2.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  2
P:  Vendor=413c ProdID=81d7 Rev=03.18
S:  Manufacturer=DELL
S:  Product=DW5821e Snapdragon X20 LTE
S:  SerialNumber=0123456789ABCDEF
C:  #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
I:  If#= 1 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid
I:  If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option

Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-28 16:49:50 +02:00
Greg Kroah-Hartman 78fbe864c3 USB-serial updates for v4.19-rc1
Here are the USB-serial updates for 4.19-rc1, including:
 
  - gpio support for CP2102N devices
  - improved line-speed handling for cp210x
  - conversion to spin_lock_irqsave() in completion handlers
  - dropped kl5kusb105 support from the kl5kusb105 driver (sic!)
 
 Included are also various lower-priority fixes and clean ups.
 
 All but the final commit have been in linux-next, and with no reported
 issues.
 
 Signed-off-by: Johan Hovold <johan@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEHszNKQClByu0A+9RQQ3kT97htJUFAltSEpQRHGpvaGFuQGtl
 cm5lbC5vcmcACgkQQQ3kT97htJUXJA//UaE1M6D5LefGKEitn1CMMqaCxc6M4U/y
 PyuGnGds22VXYgscQlur++bhetJ12qGWoo8r1IOl4QgZl5dWOISx19F5kgMXBMr7
 GKEPraRCdxCvZ4RSKbjinlUIjFBij131doI2NIOP6lVdbnwA+z0fX5OH6zAf61p2
 Tr/aNyJmN2eIJJx+ez7PszEB3pczWNpv7uP7tmoZ/cmyLdpRYYJzsaSv4I0KA4dz
 d87IQ9G2eG1BGbs3cYN7fUwwNhcsKG7wfonXMfQPEENdyPWdle7sh/EiubRlquv4
 I7xs8+E5zDKChrwavbMQr4uCmXf3L1O7Ueev9718pHzYkQTfxiCvAqt6nhlmkyEx
 yZdo3DncTMGT3A8/MZk3C66I30xul8z7BH2X0DVXr8yeV4ZN17u7F65Qzyr5Tmni
 aUYPXaov6JuyLtIBNii3cXMtMuG9ghJoEbXZ2U9DcCFuYeDW6xJuTUd0sKmctTWa
 htXgW9lvndw0C3ojTXgp6dT2KQyEYhKDM6qdgVhoZV2x4M2XErEMSxTTIm0nlG7O
 dnrIT3q+iqarxU4vBC6doOq7vbQP5L7UPfpYJcD/AqMvjLX0ZEFInKz+eI2KLUg0
 MM8DatTs6z80lClKfKmpNw/bWWcUdKyH9acFXvjrflwwMU2hqsJB9RcsN0d4ppNL
 QtaT/uY6zls=
 =0ukW
 -----END PGP SIGNATURE-----

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

Johan writes:

USB-serial updates for v4.19-rc1

Here are the USB-serial updates for 4.19-rc1, including:

 - gpio support for CP2102N devices
 - improved line-speed handling for cp210x
 - conversion to spin_lock_irqsave() in completion handlers
 - dropped kl5kusb105 support from the kl5kusb105 driver (sic!)

Included are also various lower-priority fixes and clean ups.

All but the final commit have been in linux-next, and with no reported
issues.

Signed-off-by: Johan Hovold <johan@kernel.org>
2018-07-20 21:47:15 +02:00
Karoly Pados c8acfe0aad USB: serial: cp210x: implement GPIO support for CP2102N
This patch adds GPIO support for CP2102N devices.

It introduces new generic code to support emulating separate
input and outputs directions even though these devices
only know output modes (open-drain and pushpull). Existing
GPIO support for CP2105 has been migrated over to the new
code structure.

Only limitation is that for the QFN28 variant, only 4 out of
7 GPIOs are supported. This is because the config array
locations of the last 3 pins are not documented, and reverse
engineering revealed offsets that conflicted with other
documented functions. Hence we'll play it safe instead
until somebody clears this up further.

Signed-off-by: Karoly Pados <pados@pados.hu>
[ johan: fix style issues and a couple of minor bugs; use Karoly's
         updated commit message ]
Acked-by: Martyn Welch <martyn.welch@collabora.co.uk>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-07-20 18:22:52 +02:00
Johan Hovold 5edb65a337 USB: serial: cp210x: improve line-speed handling for CP2104 and CP2105
CP2104 and the ECI interface of CP2105 support further baud rates than
the ones specified in AN205 table 1, and we can use the same equations
as for CP2102N to determine and report back the actual baud rates used.

Note that this could eventually be generalised also to CP2108, which
uses a different base clock. There appears to be an error in the CP2108
equations which needs to be confirmed on actual hardware first however
(specifically, the subtraction of one from the divisor appears to be
incorrect as it introduces larger errors).

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-07-18 21:54:56 +02:00
Johan Hovold 7aecd7fc5d USB: serial: cp210x: generalise CP2102N line-speed handling
The CP2102N equations for determining the actual baud rate can be used
also for other device types, so let's factor it out.

Note that this removes the now unused cp210x_is_cp2102n() helper.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-07-18 21:54:49 +02:00
Karoly Pados 6f0bcf720e USB: serial: cp210x: improve baudrate support for CP2102N
CP2102N devices support a lot more baudrates than earlier chips by
SiLabs. These devices are not constrained anymore by the table in AN205,
and are able to generate almost any baudrate in the supported range
with only minimal errors. This has also been verified with a scope on
a physical device. This patch adds support for all baudrates supported
by the CP2102N.

Signed-off-by: Karoly Pados <pados@pados.hu>
[johan: rework on top of an205 and max-speed patches ]
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-07-18 21:53:58 +02:00
Johan Hovold d4706c05c5 USB: serial: cp210x: honour device-type maximum line speed
Newer cp210x devices support higher line speeds than the older ones
which supported a discrete set of speeds up to 921.6 kbaud.

To support these higher speeds, we have for some time mapped speeds
lower than 1 Mbaud to the speeds supported by older devices, while
allowing the device to pick the closest possible rate for higher speeds
(without trying to guess and report back what rate was actually chosen).

As this implementation can lead to undefined behaviour for older devices
which do not support the higher rates, let's use the later-added
device-type detection to determine the maximum supported speed.

This will also be useful when adding support for cp2102n which can
handle rates up to 3 Mbaud.

As per the data sheets the following maximum speeds are used

	cp2101		921.6 kbaud
	cp2102/3	1 Mbaud
	cp2104/8	2 Mbaud
	cp2105
	 - ECI port	2 Mbaud
	 - SCI port	921.6 kbaud

while keeping the maximum 2 Mbaud for unknown device types in order to
avoid any regressions.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-07-18 21:53:50 +02:00
Johan Hovold 95fd4f47c8 USB: serial: cp210x: make line-speed quantisation data driven
Older cp210x devices only support a fixed set of line speeds to which a
requested speed is mapped. Reimplement this mapping using a table
instead of a long if-else construct.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-07-18 21:53:31 +02:00
Johan Hovold 3528651e89 USB: serial: iuu_phoenix: drop redundant input-speed re-encoding
Drop redundant input-speed re-encoding at every open(). The output and
input speeds are initialised to the same value and are kept in sync on
termios updates.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-07-16 14:12:11 +02:00
Johan Hovold b8f6515445 USB: serial: iuu_phoenix: drop unused driver-data baud rate
Drop unused driver-data baud rate.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-07-16 14:11:27 +02:00
Colin Ian King 1e2ae1d7e4 USB: serial: mos7720: remove redundant variables iflag, mask and serial
Variables iflag, mask and serial are being assigned but are never used
hence are redundant and can be removed.

Cleans up clang warnings:
warning: variable 'iflag' set but not used [-Wunused-but-set-variable]
warning: variable 'mask' set but not used [-Wunused-but-set-variable]
warning: variable 'serial' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-07-16 14:10:00 +02:00
Johan Hovold d118851a4d USB: serial: kl5kusb105: remove KLSI device id
This driver was apparently never tested with an actual KLSI device. In
fact, even the device-id entry which was supposed to allow for this had
a typo in it.

Tests now reveal that the predicted firmware differences with the
PalmConnect adapters are real and that the driver does not support KLSI
devices with PID 0x000c, so let's remove the broken entry.

Reported-by: Chris Jakob <chris.jakob@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-07-11 10:11:29 +02:00
Johan Hovold af846a6f6d USB: serial: kobil_sct: add missing version error handling
Add missing version-request error handling and suppress printing of the
(zeroed) transfer-buffer content in case of errors.

Signed-off-by: Johan Hovold <johan@kernel.org>
2018-07-06 10:42:42 +02:00
Johan Hovold a420b5d939 USB: serial: kobil_sct: fix modem-status error handling
Make sure to return -EIO in case of a short modem-status read request.

While at it, split the debug message to not include the (zeroed)
transfer-buffer content in case of errors.

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-07-06 10:42:24 +02:00
Johan Hovold 794744abff USB: serial: mos7840: fix status-register error handling
Add missing transfer-length sanity check to the status-register
completion handler to avoid leaking bits of uninitialised slab data to
user space.

Fixes: 3f5429746d ("USB: Moschip 7840 USB-Serial Driver")
Cc: stable <stable@vger.kernel.org>     # 2.6.19
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-07-06 10:32:28 +02:00
Johan Hovold 01b3cdfca2 USB: serial: keyspan_pda: fix modem-status error handling
Fix broken modem-status error handling which could lead to bits of slab
data leaking to user space.

Fixes: 3b36a8fd67 ("usb: fix uninitialized variable warning in keyspan_pda")
Cc: stable <stable@vger.kernel.org>     # 2.6.27
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-07-06 10:32:14 +02:00
Olli Salonen 367b160fe4 USB: serial: cp210x: add another USB ID for Qivicon ZigBee stick
There are two versions of the Qivicon Zigbee stick in circulation. This
adds the second USB ID to the cp210x driver.

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-07-04 15:44:07 +02:00
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 1d1de580a3 USB: serial: digi_acceleport: rename tty flag variable
Add a "tty_" prefix to the tty "flag" variable to avoid any future
mixups with the recently added irq-mask "flags" one.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-06-27 07:59:03 +02:00
John Ogness a323f94611 USB: serial: usb_wwan: use irqsave() in USB's complete callback
The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-06-26 15:28:15 +02:00
John Ogness cf83be24b2 USB: serial: ti_usb_3410_5052: use irqsave() in USB's complete callback
The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-06-26 15:26:18 +02:00
John Ogness 5e02bfcf3f USB: serial: symbolserial: use irqsave() in USB's complete callback
The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-06-26 15:25:01 +02:00
John Ogness d4bf25b3fc USB: serial: sierra: use irqsave() in USB's complete callback
The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-06-26 15:22:25 +02:00
John Ogness e60870012e USB: serial: sierra: fix potential deadlock at close
The portdata spinlock can be taken in interrupt context (via
sierra_outdat_callback()).
Disable interrupts when taking the portdata spinlock when discarding
deferred URBs during close to prevent a possible deadlock.

Fixes: 014333f77c ("USB: sierra: fix urb and memory leak on disconnect")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
[ johan: amend commit message and add fixes and stable tags ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-06-26 15:12:49 +02:00
John Ogness 2ba02c8dd0 USB: serial: quatech2: use irqsave() in USB's complete callback
The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-06-26 14:52:15 +02:00
John Ogness 19bfbf462e USB: serial: mos7840: use irqsave() in USB's complete callback
The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-06-26 14:49:34 +02:00
John Ogness f7c8a9ccc9 USB: serial: mos7720: use irqsave() in USB's complete callback
The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-06-26 14:45:35 +02:00
John Ogness 6778b0cbdb USB: serial: io_ti: use irqsave() in USB's complete callback
The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-06-26 14:34:32 +02:00
John Ogness dd1fae5276 USB: serial: io_edgeport: use irqsave() in USB's complete callback
The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-06-26 14:30:17 +02:00
John Ogness 041b7db966 USB: serial: digi_acceleport: use irqsave() in USB's complete callback
The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-06-26 14:14:50 +02:00
John Ogness c75d18cc5a USB: serial: cyberjack: use irqsave() in USB's complete callback
The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-06-26 14:13:53 +02:00
Chengguang Xu 3391ca1dcd USB: serial: cast sizeof() to int when comparing with error code
Negative error code will be larger than sizeof().

Note that none of these bugs prevent errors from being detected, even if
the ir-usb one would cause a less precise debug message to printed.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
[ johan: add comment about implications ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-06-25 10:34:31 +02:00
Johan Hovold 24160628a3 USB: serial: cp210x: add CESINEL device ids
Add device ids for CESINEL products.

Reported-by: Carlos Barcala Lara <cabl@cesinel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-06-18 11:25:09 +02:00
Karoly Pados 2f83982338 USB: serial: cp210x: add Silicon Labs IDs for Windows Update
Silicon Labs defines alternative VID/PID pairs for some chips that when
used will automatically install drivers for Windows users without manual
intervention. Unfortunately, these IDs are not recognized by the Linux
module, so using these IDs improves user experience on one platform but
degrades it on Linux. This patch addresses this problem.

Signed-off-by: Karoly Pados <pados@pados.hu>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-06-18 09:37:10 +02:00
Kees Cook 6da2ec5605 treewide: kmalloc() -> kmalloc_array()
The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
patch replaces cases of:

        kmalloc(a * b, gfp)

with:
        kmalloc_array(a * b, gfp)

as well as handling cases of:

        kmalloc(a * b * c, gfp)

with:

        kmalloc(array3_size(a, b, c), gfp)

as it's slightly less ugly than:

        kmalloc_array(array_size(a, b), c, gfp)

This does, however, attempt to ignore constant size factors like:

        kmalloc(4 * 1024, gfp)

though any constants defined via macros get caught up in the conversion.

Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.

The tools/ directory was manually excluded, since it has its own
implementation of kmalloc().

The Coccinelle script used for this was:

// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@

(
  kmalloc(
-	(sizeof(TYPE)) * E
+	sizeof(TYPE) * E
  , ...)
|
  kmalloc(
-	(sizeof(THING)) * E
+	sizeof(THING) * E
  , ...)
)

// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@

(
  kmalloc(
-	sizeof(u8) * (COUNT)
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(__u8) * (COUNT)
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(char) * (COUNT)
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(unsigned char) * (COUNT)
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(u8) * COUNT
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(__u8) * COUNT
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(char) * COUNT
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(unsigned char) * COUNT
+	COUNT
  , ...)
)

// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@

(
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * (COUNT_ID)
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * COUNT_ID
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * (COUNT_CONST)
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * COUNT_CONST
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * (COUNT_ID)
+	COUNT_ID, sizeof(THING)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * COUNT_ID
+	COUNT_ID, sizeof(THING)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * (COUNT_CONST)
+	COUNT_CONST, sizeof(THING)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * COUNT_CONST
+	COUNT_CONST, sizeof(THING)
  , ...)
)

// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@

- kmalloc
+ kmalloc_array
  (
-	SIZE * COUNT
+	COUNT, SIZE
  , ...)

// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@

(
  kmalloc(
-	sizeof(TYPE) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kmalloc(
-	sizeof(TYPE) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kmalloc(
-	sizeof(TYPE) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kmalloc(
-	sizeof(TYPE) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kmalloc(
-	sizeof(THING) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kmalloc(
-	sizeof(THING) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kmalloc(
-	sizeof(THING) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kmalloc(
-	sizeof(THING) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
)

// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@

(
  kmalloc(
-	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  kmalloc(
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  kmalloc(
-	sizeof(THING1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  kmalloc(
-	sizeof(THING1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  kmalloc(
-	sizeof(TYPE1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
|
  kmalloc(
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
)

// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@

(
  kmalloc(
-	(COUNT) * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	COUNT * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	COUNT * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	(COUNT) * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	COUNT * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	(COUNT) * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	(COUNT) * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	COUNT * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
)

// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@

(
  kmalloc(C1 * C2 * C3, ...)
|
  kmalloc(
-	(E1) * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  kmalloc(
-	(E1) * (E2) * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  kmalloc(
-	(E1) * (E2) * (E3)
+	array3_size(E1, E2, E3)
  , ...)
|
  kmalloc(
-	E1 * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
)

// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@

(
  kmalloc(sizeof(THING) * C2, ...)
|
  kmalloc(sizeof(TYPE) * C2, ...)
|
  kmalloc(C1 * C2 * C3, ...)
|
  kmalloc(C1 * C2, ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * (E2)
+	E2, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * E2
+	E2, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * (E2)
+	E2, sizeof(THING)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * E2
+	E2, sizeof(THING)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	(E1) * E2
+	E1, E2
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	(E1) * (E2)
+	E1, E2
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	E1 * E2
+	E1, E2
  , ...)
)

Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-12 16:19:22 -07:00
Linus Torvalds 07c4dd3435 USB/PHY patches for 4.18-rc1
Here is the big USB pull request for 4.18-rc1.
 
 Lots of stuff here, the highlights are:
 	- phy driver updates and new additions
 	- usual set of xhci driver updates
 	- normal set of musb updates
 	- gadget driver updates and new controllers
 	- typec work, it's getting closer to getting fully out of the
 	  staging portion of the tree.
 	- lots of minor cleanups and bugfixes.
 
 All of these have been in linux-next for a while with no reported
 issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWxba6w8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ykumQCg2abWE5LijR0SNJIwX8xk64HLUAMAnAxBZDG3
 aB0GyOQd54L+09q4LAdn
 =ZCEx
 -----END PGP SIGNATURE-----

Merge tag 'usb-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB and PHY updates from Greg KH:
 "Here is the big USB pull request for 4.18-rc1.

  Lots of stuff here, the highlights are:

   - phy driver updates and new additions

   - usual set of xhci driver updates

   - normal set of musb updates

   - gadget driver updates and new controllers

   - typec work, it's getting closer to getting fully out of the staging
     portion of the tree.

   - lots of minor cleanups and bugfixes.

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'usb-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (263 commits)
  Revert "xhci: Reset Renesas uPD72020x USB controller for 32-bit DMA issue"
  xhci: Add quirk to zero 64bit registers on Renesas PCIe controllers
  xhci: Allow more than 32 quirks
  usb: xhci: force all memory allocations to node
  selftests: add test for USB over IP driver
  USB: typec: fsusb302: no need to check return value of debugfs_create_dir()
  USB: gadget: udc: s3c2410_udc: no need to check return value of debugfs_create functions
  USB: gadget: udc: renesas_usb3: no need to check return value of debugfs_create functions
  USB: gadget: udc: pxa27x_udc: no need to check return value of debugfs_create functions
  USB: gadget: udc: gr_udc: no need to check return value of debugfs_create functions
  USB: gadget: udc: bcm63xx_udc: no need to check return value of debugfs_create functions
  USB: udc: atmel_usba_udc: no need to check return value of debugfs_create functions
  USB: dwc3: no need to check return value of debugfs_create functions
  USB: dwc2: no need to check return value of debugfs_create functions
  USB: core: no need to check return value of debugfs_create functions
  USB: chipidea: no need to check return value of debugfs_create functions
  USB: ehci-hcd: no need to check return value of debugfs_create functions
  USB: fhci-hcd: no need to check return value of debugfs_create functions
  USB: fotg210-hcd: no need to check return value of debugfs_create functions
  USB: imx21-hcd: no need to check return value of debugfs_create functions
  ...
2018-06-05 16:14:12 -07:00
Greg Kroah-Hartman 7eeb11190f USB-serial updates for v4.18-rc1
Here are the USB-serial updates for 4.18-rc1, including:
 
  - support for hardware-assisted XON/XOFF output flow control for pl2303
  - fix for a long-standing IXON/IXOFF mixup in ftdi_sio
  - blacklist of two apparently unused dwm-158 modem interfaces that
    confused some user space daemon (option)
  - add missing const to a tty helper currently used by USB serial only
 
 Included are also various clean ups.
 
 All have been in linux-next with no reported issues.
 
 Signed-off-by: Johan Hovold <johan@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEHszNKQClByu0A+9RQQ3kT97htJUFAlsPvjYRHGpvaGFuQGtl
 cm5lbC5vcmcACgkQQQ3kT97htJV/DA/9Huw/RMPo8uSeTiBErvglMf6UJGU8m4qp
 YKFzLCkyThPIBBDTYKe1pTWebx422EFCGJwm4zG309ZNxpBcDOmp19FMcQsqCoqN
 nRANSJ6L73sbsOLy48/zv59z8vpvVLn0Ob1mQi6iM4KfDdor9PVwHH8zSFHVWO6M
 izOLgfeRcfvp8OHPQEodFseQ25jH8SaKA4HSjDmr1vryiMxB8Bh7cVWovC0z2SP8
 s8FseAgnhbGp1RF6S4CDUR0OIr064RvoLZjBjVe7iyRiNW6LeruO9I9ctHQQZAh+
 D7iVFNj5xTeZQTfgXual7Vbvt5eOBpptcRJqI4Zr+8RR9yIGCpvSh8Kzufkl1uc2
 i+0KSo/so2AjBiGS99fxNHrSMD30wL+9Vc2qsq0CuZdkbHamr/8FLtPIuPdq99CW
 LBvjJxmzRTl2LDIWDa3fv5Dkfp42asWtg7iN33pf7UcobwgXT8MHrNd6rvsJTMg0
 AZHVyZvuplWP3kyZlOCSbZEcIZGiV5lEKLnI0kDtc0io2pJ3+0D6Ys7+lz9o2IHx
 zyznyB+dHoiPFd55BooFRIKN75uOLszzA0AhrZLGtUZ20gsdhfLWWgg9VzoaZUsz
 NSJIV9tFbBYsnzLDX3W7Q1/VLuvYGidi8Hw7czR5mkWYWFIxShywf4xyaeY3VoiN
 i73ad0YjmE8=
 =gsOA
 -----END PGP SIGNATURE-----

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

Johan writes:

USB-serial updates for v4.18-rc1

Here are the USB-serial updates for 4.18-rc1, including:

 - support for hardware-assisted XON/XOFF output flow control for pl2303
 - fix for a long-standing IXON/IXOFF mixup in ftdi_sio
 - blacklist of two apparently unused dwm-158 modem interfaces that
   confused some user space daemon (option)
 - add missing const to a tty helper currently used by USB serial only

Included are also various clean ups.

All have been in linux-next with no reported issues.

Signed-off-by: Johan Hovold <johan@kernel.org>
2018-05-31 12:15:20 +02:00
Florian Zumbiehl 7041d9c3f0 USB: serial: pl2303: add support for tx xon/xoff flow control
Support hardware-level Xon/Xoff flow control in transmit direction with
pl2303.

I only know how to get the hardware to do IXON/!IXANY with ^S/^Q as control
characters, so I preserve the old behaviour for all other cases.

Signed-off-by: Florian Zumbiehl <florz@florz.de>
[ johan: rewrite logic using pl2303_termios_change() helper ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-05-22 10:08:05 +02:00
Johan Hovold df1cd63d6d USB: serial: ftdi_sio: clean up flow control management
Clean up the somewhat convoluted hardware-assisted flow control
handling.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-05-21 10:04:30 +02:00
Johan Hovold 1641011549 USB: serial: ftdi_sio: drop unnecessary urb_ variable prefixes
Drop urb_ prefixes from value and index variables used in control
requests.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-05-21 10:04:26 +02:00
Johan Hovold fd54a99aec USB: serial: ftdi_sio: use non-underscore fixed types
Replace all __u types with their u counterparts throughout the driver
(whose structures are not exported to user space).

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-05-21 10:04:20 +02:00
Johan Hovold 5ada98427f USB: serial: ftdi_sio: fix IXON/IXOFF mixup
Since forever this driver has had IXON and IXOFF mixed up, and has used
the latter rather than the former to enable hardware-assisted software
flow control on output.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-05-21 10:03:49 +02:00
Johan Hovold 79ef51894a USB: serial: use tty_port_register_device()
We already have the tty port when probing a usb-serial port so use
tty_port_register_device() directly instead of tty_port_install() later
to set up the port link.

This is a step towards enabling serdev for usb-serial (but we need to
determine how to handle hotplugging first).

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-05-17 11:22:00 +02:00
Christoph Hellwig 8a8dcabffb tty: replace ->proc_fops with ->proc_show
Just set up the show callback in the tty_operations, and use
proc_create_single_data to create the file without additional
boilerplace code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-05-16 07:24:30 +02:00
Greg Kroah-Hartman 4842ed5bfc USB: serial: visor: handle potential invalid device configuration
If we get an invalid device configuration from a palm 3 type device, we
might incorrectly parse things, and we have the potential to crash in
"interesting" ways.

Fix this up by verifying the size of the configuration passed to us by
the device, and only if it is correct, will we handle it.

Note that this also fixes an information leak of slab data.

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Reviewed-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ johan: add comment about the info leak ]
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-05-02 09:37:19 +02:00
SZ Lin (林上智) 4205cb01f6 USB: serial: option: adding support for ublox R410M
This patch adds support for ublox R410M PID 0x90b2 USB modem to option
driver, this module supports LTE Cat M1 / NB1.

Interface layout:
0: QCDM/DIAG
1: ADB
2: AT
3: RMNET

Signed-off-by: SZ Lin (林上智) <sz.lin@moxa.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-05-02 09:15:22 +02:00
Giuseppe Lippolis 4d304a6fe9 USB: serial: option: blacklist unused dwm-158 interfaces
The dwm-158 interface 4 and 5 doesn't answer to the AT commands
and doesn't appears a option interface.
Tested on openwrt distribution (kernel 4.14 using the old blacklist
definitions).

Lars Melin also writes:

	Blacklisting interface 4 and 5 is correct because:

	MI_00 D-Link Mobile Broadband Device  (cdc_ether)
	MI_02 D-Link HSPA+DataCard Diagnostics Interface (also ppp modem)
	MI_03 D-Link HSPA+DataCard NMEA Device
	MI_04 D-Link HSPA+DataCard Speech Port
	MI_05 D-Link HSPA+DataCard Debug Port
	MI_06 USB Mass Storage Device

Signed-off-by: Giuseppe Lippolis <giu.lippolis@gmail.com>
[ johan: add Lars's comment on the interface layout and reword summary ]
Cc: Lars Melin <larsm17@gmail.com>
Cc: Dan Williams <dcbw@redhat.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-05-02 09:09:48 +02:00
Vasyl Vavrychuk 470b5d6f0c USB: serial: ftdi_sio: use jtag quirk for Arrow USB Blaster
Arrow USB Blaster integrated on MAX1000 board uses the same vendor ID
(0x0403) and product ID (0x6010) as the "original" FTDI device.

This patch avoids picking up by ftdi_sio of the first interface of this
USB device. After that this device can be used by Arrow user-space JTAG
driver.

Signed-off-by: Vasyl Vavrychuk <vvavrychuk@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-04-16 11:19:21 +02:00
Kyle Roeschley 1e23aace21 USB: serial: cp210x: add ID for NI USB serial console
Added the USB VID and PID for the USB serial console on some National
Instruments devices.

Signed-off-by: Kyle Roeschley <kyle.roeschley@ni.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-04-16 11:19:11 +02:00
Collin May fe710508b6 USB: serial: simple: add libtransistor console
Add simple driver for libtransistor USB console.
This device is implemented in software:
https://github.com/reswitched/libtransistor/blob/development/lib/usb_serial.c

Signed-off-by: Collin May <collin@collinswebsite.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-04-16 09:19:53 +02:00
Johan Hovold 5267c5e09c Revert "USB: serial: ftdi_sio: add Id for Physik Instrumente E-870"
This reverts commit 79a0b33165.

Turns out this is not an FTDI device after all.

Fixes: 79a0b33165 ("USB: serial: ftdi_sio: add Id for Physik Instrumente E-870")
Reported-by: Martin Teichmann <martin.teichmann@xfel.eu>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-29 18:37:28 +02:00
Greg Kroah-Hartman 1ca5033101 USB-serial updates for v4.17-rc1
Here are the USB-serial updates for 4.17-rc1, including a
 reimplementation of the option-driver interface masking which allows
 for a more compact notation when adding new device entries.
 
 Included are also a couple of clean ups and a new ftdi_sio device id.
 
 All but the device-id commit have been in linux-next (without any
 reported issues).
 
 Signed-off-by: Johan Hovold <johan@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEHszNKQClByu0A+9RQQ3kT97htJUFAlq8prERHGpvaGFuQGtl
 cm5lbC5vcmcACgkQQQ3kT97htJUr7RAAgOKKs9niLJEc0BXJH4m3jgoLrpOQvXjT
 tjR+YRh3DpALQSgFtkhADeG224VGOMFYgW81BblXJF01Syfl0IHxKjAETSIk+UHt
 cLdGdi7qXaulXR8IS5qqTMeWCznOCIGQdp8SQ44vTtLCTLtyL3ci8Ge05pxSX7LP
 YLOu5020PZFwdkjnB6Jt126BF0fX8sfIVSs4TTrVGF3Zx7reWd3RhZe5a9k+ImG5
 Pl8b0CJ8Q0eQjEPSRiX4aNDD7BxLOjU9nNX0/Dp3GJNyHfBOjYFay26L74rKZI5w
 mRed3WLG6LbsrWsUI5SN8LzDKz34JkO9qic1lmVuk23bBccFUGqCmmWuw4zLXVOf
 uKyGHymzHYQr77B/aIlyQcDWAEgTUrgTGPCok1zXIf2AwkSMw7DgkC+LUcuuQ4TT
 LvS0FYBvJ0YyY966bRpDTbQIAmfacXGwW6j/jqGxQIhMNtAEWhhZbAtn9GG6WCiH
 vNM+pv8brSZeREX42TjMUFB/GA9TJbkZV/1ijTjxAjVanww/hwRwpWKK8OCNjxPB
 9z+HGJ9e1B+9YHNsOUZgSDoYngPYpeMUw/WjZdOeFItvlvmD54rX+L1MUA5dp53C
 5LjMSYXowsbX+F81w3cKRsv3ZsPIQT38on0Td1QxV54s1glt2RWCqTCseGC9Vakh
 V0d04WUx+gg=
 =E3H0
 -----END PGP SIGNATURE-----

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

Johan writes:

USB-serial updates for v4.17-rc1

Here are the USB-serial updates for 4.17-rc1, including a
reimplementation of the option-driver interface masking which allows
for a more compact notation when adding new device entries.

Included are also a couple of clean ups and a new ftdi_sio device id.

All but the device-id commit have been in linux-next (without any
reported issues).

Signed-off-by: Johan Hovold <johan@kernel.org>
2018-03-29 11:22:53 +02:00
Teichmann, Martin 79a0b33165 USB: serial: ftdi_sio: add Id for Physik Instrumente E-870
This adds support for the Physik Instrumente E-870 PIShift Drive
Electronics, a Piezo motor driver.

Signed-off-by: Martin Teichmann <martin.teichmann@xfel.eu>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-03-29 10:06:45 +02:00
Clemens Werther 6555ad13a0 USB: serial: ftdi_sio: add support for Harman FirmwareHubEmulator
Add device id for Harman FirmwareHubEmulator to make the device
auto-detectable by the driver.

Signed-off-by: Clemens Werther <clemens.werther@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-23 12:17:40 +01:00
Johan Hovold 1f1e82f74c USB: serial: cp210x: add ELDAT Easywave RX09 id
Add device id for ELDAT Easywave RX09 tranceiver.

Reported-by: Jan Jansen <nattelip@hotmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-23 12:17:40 +01:00
Major Hayden 9608e5c0f0 USB: serial: ftdi_sio: add RT Systems VX-8 cable
This patch adds a device ID for the RT Systems cable used to
program Yaesu VX-8R/VX-8DR handheld radios. It uses the main
FTDI VID instead of the common RT Systems VID.

Signed-off-by: Major Hayden <major@mhtx.net>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-23 12:17:40 +01:00
Johan Hovold 9b284d8e64 USB: serial: option: use mass-storage class define
Use the USB class define rather than a magic number when refusing to
bind to mass-storage interfaces.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-03-19 12:20:18 +01:00
Johan Hovold a0bf2ef978 USB: serial: option: drop redundant interface-class test
Drop redundant interface-class test for Samsung GT-B3730 modems for
which we only match and probe the CDC data interface.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-03-19 12:20:11 +01:00
Johan Hovold c3a65808f0 USB: serial: option: reimplement interface masking
Reimplement interface masking using device flags stored directly in the
device-id table. This will make it easier to add and maintain device-id
entries by using a more compact and readable notation compared to the
current implementation (which manages pairs of masks in separate
blacklist structs).

Two convenience macros are used to flag an interface as either reserved
or as not supporting modem-control requests:

	{ USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM),
	  .driver_info = NCTRL(0) | RSVD(3) },

For now, we limit the highest maskable interface number to seven, which
allows for (up to 16) additional device flags to be added later should
need arise.

Note that this will likely need to be backported to stable in order to
make future device-id backports more manageable.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-03-19 12:20:01 +01:00
Kristian Evensen 71a0483d56 USB: serial: option: Add support for Quectel EP06
The Quectel EP06 is a Cat. 6 LTE modem, and the interface mapping is as
follows:

0: Diag
1: NMEA
2: AT
3: Modem

Interface 4 is QMI and interface 5 is ADB, so they are blacklisted.

This patch should also be considered for -stable. The QMI-patch for this
modem is already in the -stable-queue.

v1->v2:
* Updated commit prefix (thanks Johan Hovold)
* Updated commit message slightly.

Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-15 18:36:19 +01:00
Linus Torvalds 47fcc0360c Driver Core updates for 4.16-rc1
Here is the set of "big" driver core patches for 4.16-rc1.
 
 The majority of the work here is in the firmware subsystem, with reworks
 to try to attempt to make the code easier to handle in the long run, but
 no functional change.  There's also some tree-wide sysfs attribute
 fixups with lots of acks from the various subsystem maintainers, as well
 as a handful of other normal fixes and changes.
 
 And finally, some license cleanups for the driver core and sysfs code.
 
 All have been in linux-next for a while with no reported issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWnLvPw8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ynNzACgkzjPoBytJWbpWFt6SR6L33/u4kEAnRFvVCGL
 s6ygQPQhZIjKk2Lxa2hC
 =Zihy
 -----END PGP SIGNATURE-----

Merge tag 'driver-core-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core updates from Greg KH:
 "Here is the set of "big" driver core patches for 4.16-rc1.

  The majority of the work here is in the firmware subsystem, with
  reworks to try to attempt to make the code easier to handle in the
  long run, but no functional change. There's also some tree-wide sysfs
  attribute fixups with lots of acks from the various subsystem
  maintainers, as well as a handful of other normal fixes and changes.

  And finally, some license cleanups for the driver core and sysfs code.

  All have been in linux-next for a while with no reported issues"

* tag 'driver-core-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (48 commits)
  device property: Define type of PROPERTY_ENRTY_*() macros
  device property: Reuse property_entry_free_data()
  device property: Move property_entry_free_data() upper
  firmware: Fix up docs referring to FIRMWARE_IN_KERNEL
  firmware: Drop FIRMWARE_IN_KERNEL Kconfig option
  USB: serial: keyspan: Drop firmware Kconfig options
  sysfs: remove DEBUG defines
  sysfs: use SPDX identifiers
  drivers: base: add coredump driver ops
  sysfs: add attribute specification for /sysfs/devices/.../coredump
  test_firmware: fix missing unlock on error in config_num_requests_store()
  test_firmware: make local symbol test_fw_config static
  sysfs: turn WARN() into pr_warn()
  firmware: Fix a typo in fallback-mechanisms.rst
  treewide: Use DEVICE_ATTR_WO
  treewide: Use DEVICE_ATTR_RO
  treewide: Use DEVICE_ATTR_RW
  sysfs.h: Use octal permissions
  component: add debugfs support
  bus: simple-pm-bus: convert bool SIMPLE_PM_BUS to tristate
  ...
2018-02-01 10:00:28 -08:00
Benjamin Gilbert 003948c54e USB: serial: keyspan: Drop firmware Kconfig options
The USB_SERIAL_KEYSPAN_* firmware options no longer do anything.

Fixes: 5620a0d1aa ("firmware: delete in-kernel firmware")
Signed-off-by: Benjamin Gilbert <benjamin.gilbert@coreos.com>
Cc: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-25 12:46:30 +01:00
Greg Kroah-Hartman d08dd3f3dd USB: serial: pl2303: new device id for Chilitag
This adds a new device id for Chilitag devices to the pl2303 driver.

Reported-by: "Chu.Mike [朱堅宜]" <Mike-Chu@prolific.com.tw>
Cc: stable <stable@vger.kernel.org>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-25 10:39:59 +01:00
Greg Kroah-Hartman ca35910a1b USB: move many drivers to use DEVICE_ATTR_WO
Instead of "open coding" a DEVICE_ATTR() define, use the
DEVICE_ATTR_WO() macro instead, which does everything properly instead.

This does require a few static functions to be renamed to work properly,
but thanks to a script from Joe Perches, this was easily done.

Reported-by: Joe Perches <joe@perches.com>
Cc: Peter Chen <Peter.Chen@nxp.com>
Cc: Valentina Manea <valentina.manea.m@gmail.com>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-24 08:49:52 +01:00
Colin Ian King f0b4198f07 USB: serial: remove redundant initializations of 'mos_parport'
The pointer mos_parport is being initialized to pp->private_data and
then the assignment is duplicated after a spin lock.  Remove the
initialization as it occurs before the spin lock and it is a redundant
assignment.

Cleans up clang warnings:
drivers/usb/serial/mos7720.c:521:26: warning: Value stored to
'mos_parport' during its initialization is never read
drivers/usb/serial/mos7720.c:557:26: warning: Value stored to
'mos_parport' during its initialization is never read

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-22 15:34:37 +01:00
Johan Hovold 46fe895e22 USB: serial: simple: add Motorola Tetra driver
Add new Motorola Tetra (simple) driver for Motorola Solutions TETRA PEI
devices.

D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0cad ProdID=9011 Rev=24.16
S:  Manufacturer=Motorola Solutions Inc.
S:  Product=Motorola Solutions TETRA PEI interface
C:  #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)

Note that these devices do not support the CDC SET_CONTROL_LINE_STATE
request (for any interface).

Reported-by: Max Schulze <max.schulze@posteo.de>
Tested-by: Max Schulze <max.schulze@posteo.de>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-22 15:34:37 +01:00
OKAMOTO Yoshiaki 69341bd150 usb: option: Add support for FS040U modem
FS040U modem is manufactured by omega, and sold by Fujisoft. This patch
adds ID of the modem to use option1 driver. Interface 3 is used as
qmi_wwan, so the interface is ignored.

Signed-off-by: Yoshiaki Okamoto <yokamoto@allied-telesis.co.jp>
Signed-off-by: Hiroyuki Yamamoto <hyamamo@allied-telesis.co.jp>
Cc: stable <stable@vger.kernel.org>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-22 15:22:27 +01:00
Greg Kroah-Hartman c182ce9bc8 Merge 4.15-rc8 into usb-next
We want the USB fixes in here as well for merge issues.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-15 15:00:11 +01:00
Greg Kroah-Hartman 2da050e4f1 USB-serial updates for v4.16-rc1
Here are the USB-serial updates for 4.16-rc1, including:
 
  - a fix for a potential sleep-while-atomic (warning) in an io_edgeport
    error path
  - removal of a dummy TIOCSSERIAL implementation in ark3116
  - new features for Fintek F81532/534 devices:
    - support for higher baud rates (up to 1.5 Mbps)
    - support for auto-RTS (for RS-485)
    - support for transceiver configuration
    - support for detecting disabled ports
 
 Included are also various clean ups.
 
 All have been (at least compile tested) in linux-next without any
 reported issues.
 
 Signed-off-by: Johan Hovold <johan@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEHszNKQClByu0A+9RQQ3kT97htJUFAlpY9EkRHGpvaGFuQGtl
 cm5lbC5vcmcACgkQQQ3kT97htJXbOg//aD2Pl64/bzAA22t2KYzXlFcciktnvNNG
 aE8vf4u8VM3INr+4IdwAH+8cgl6lb2cLxdat/CCTofhjgJKUQE5Kb71JEUgUlOyZ
 DE3blC9UFBe4qL1fe1IwXCK/WhlJCGzwuEECsDzG2jb0EuClpSU1sKh9K9cBYtfT
 ozNSGYse9Kcym6PHaemDzU2u30nXcBirldpdu2W7x1qepYWwJcP7x8IQWKrZvwY7
 PCDqo3fDwS+Q/5GuPw2SX9IK0jZiuKyIhE6JBlsKQEpzfFPZv7XWeP+AKitgCsAp
 SfF1+C33P/qO5X2IprlVr9EhDk5Q5FoRBMhcb2OODiTwHaLpPH9hAScGuRFDkXuf
 x/obA2IowKsisulYCAo9scRdpnDZFrPp1csJpgPSYVW/K0rXG7XVe89k96iEgdOS
 BqvJQoRwOa2ctvM4VoDTAdCtlyV2cnEVQXIYlK+5jggTP8CpTqyvVvCnwoaHC/CP
 asg+Zgxf5cNaaNsw0VA+zEkdi+KsZl7K1aqI8VVWaMcKasMChA+YywX/T9WSL4+c
 dnkw09AHXbJbcQ9HAL5kqJfvc2OlpN1le+nrRQ8+uPpzhqqBV/0dqnH7uA8HLkcs
 ilQ5L+IVWSuY1v7YULXTPydM4uAY+rLBz4VEHUCrC7IWdTYw4t/CfrvQDnsBh/uw
 9OBUIFD/HX0=
 =ZTZB
 -----END PGP SIGNATURE-----

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

Johan writes:

USB-serial updates for v4.16-rc1

Here are the USB-serial updates for 4.16-rc1, including:

 - a fix for a potential sleep-while-atomic (warning) in an io_edgeport
   error path
 - removal of a dummy TIOCSSERIAL implementation in ark3116
 - new features for Fintek F81532/534 devices:
   - support for higher baud rates (up to 1.5 Mbps)
   - support for auto-RTS (for RS-485)
   - support for transceiver configuration
   - support for detecting disabled ports

Included are also various clean ups.

All have been (at least compile tested) in linux-next without any
reported issues.

Signed-off-by: Johan Hovold <johan@kernel.org>
2018-01-13 15:05:21 +01:00
Ji-Ze Hong (Peter Hong) d1c48227d7 USB: serial: f81534: fix tx error on some baud rate
The F81532/534 had 4 clocksource 1.846/18.46/14.77/24MHz and baud rates
can be up to 1.5Mbits with 24MHz. But on some baud rate (384~500kps), the
TX side will send the data frame too close to treat frame error on RX
side. This patch will force all TX data frame with delay 1bit gap.

Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-01-11 11:00:25 +01:00
Ji-Ze Hong (Peter Hong) bb543ca287 USB: serial: f81534: add H/W disable port support
The F81532/534 can be disable port by manufacturer with
following H/W design.
    1: Connect DCD/DSR/CTS/RI pin to ground.
    2: Connect RX pin to ground.

In driver, we'll implements some detect method likes following:
    1: Read MSR.
    2: Turn MCR LOOP bit on, off and read LSR after delay with 60ms.
       It'll contain BREAK status in LSR.

Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-01-11 11:00:25 +01:00
Ji-Ze Hong (Peter Hong) f047d35782 USB: serial: f81534: only read configuration once
In the original code, We'll read configuration in calc_num_ports()
and read again in attach(). In fact, we can move all content from
attach() to calc_num_ports() to simplify the code.

Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
[ johan: replace commit summary ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-01-11 11:00:25 +01:00
Ji-Ze Hong (Peter Hong) 138651e118 USB: serial: f81534: add output pin control
The F81532/534 had 3 output pin (M0/SD, M1, M2) with open-drain mode to
control transceiver. We'll read it from internal Flash with address
0x2f05~0x2f08 for 4 ports. The value is range from 0 to 7. The M0/SD is
MSB of this value. For a examples, If read value is 6, we'll write M0/SD,
M1, M2 as 1, 1, 0.

Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-01-11 11:00:24 +01:00
Ji-Ze Hong (Peter Hong) ee0309b46a USB: serial: f81534: add auto RTS direction support
The F81532/534 had auto RTS direction support for RS485 mode.
We'll read it from internal Flash with address 0x2f01~0x2f04 for 4 ports.
There are 4 conditions below:
	0: F81534_PORT_CONF_RS232.
	1: F81534_PORT_CONF_RS485.
	2: value error, default to F81534_PORT_CONF_RS232.
	3: F81534_PORT_CONF_RS485_INVERT.

F81532/534 Clock register (offset +08h)

Bit0:	UART Enable (always on)
Bit2-1:	Clock source selector
			00: 1.846MHz.
			01: 18.46MHz.
			10: 24MHz.
			11: 14.77MHz.
Bit4:	Auto direction(RTS) control (RTS pin Low when TX)
Bit5:	Invert direction(RTS) when Bit4 enabled (RTS pin high when TX)

Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
[ johan: rename mode-mask define, and only use GENMASK() for masks ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-01-11 11:00:16 +01:00
Ji-Ze Hong (Peter Hong) 3aacac02f3 USB: serial: f81534: add high baud rate support
The F81532/534 had 4 clocksource 1.846/18.46/14.77/24MHz and baud rates
can be up to 1.5Mbits with 24MHz.

This device may generate data overrun when baud rate setting to 921600bps
or higher with old UART trigger level setting (8x14=112) with full
loading. We'll change trigger level from 8x14=112 to 8x8=64 to avoid data
overrun.

Also the read/write of EP0 will be affected by this patch. The worst case
of responding time is 20s when all serial port are full loading and trying
to access EP0, so we change EP0 timeout from 10 to 20s.

F81532/534 Clock register (offset +08h)

Bit0:	UART Enable (always on)
Bit2-1:	Clock source selector
			00: 1.846MHz.
			01: 18.46MHz.
			10: 24MHz.
			11: 14.77MHz.

Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
[ johan: only use GENMASK() for masks ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-01-11 10:56:24 +01:00
Mikhail Zaytsev e255f2078b USB: serial: ark3116: move TIOCGSERIAL ioctl case to function
The patch moves TIOCGSERIAL ioctl case to get_serial_info function.

Signed-off-by: Mikhail Zaytsev <flashed@mail.ru>
[johan: keep the automatic __user pointer variable in ioctl callback ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-01-09 12:53:27 +01:00
Mikhail Zaytsev 63443a0b2a USB: serial: ark3116: remove dummy TIOCSSERIAL ioctl
The patch removes unused TIOCSSERIAL ioctl case and adds the default block
to the switch. This will make the ioctl return -ENOTTY to user space (e.g.
setserial), which indicates that TIOCSSERIAL really isn't supported for
these devices currently.

Note that these (dummy) ioctl implementations where added by commit
2f430b4bba ("USB: ark3116: Add TIOCGSERIAL and TIOCSSERIAL ioctl
calls.") back in 2006. This in turn appears to have been triggered by a
change in a user space tool, wvdial, which started erroring out if
either was missing.

There are some bug reports about that against wvdial from around that
time, and looking at the wvstreams (library) code now, it looks like the
issue has indeed been resolved by handling errors more gracefully (e.g.
just logging them).

User space really should not make assumptions about these ioctl always
being implemented, but if this turns out to be a problem for anyone
using this driver, we'll add TIOCSSERIAL back in some form.

Signed-off-by: Mikhail Zaytsev <flashed@mail.ru>
[johan: amend commit message with backstory ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-01-09 12:50:59 +01:00
Christian Holl d14ac576d1 USB: serial: cp210x: add new device ID ELV ALC 8xxx
This adds the ELV ALC 8xxx Battery Charging device
to the list of USB IDs of drivers/usb/serial/cp210x.c

Signed-off-by: Christian Holl <cyborgx1@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-01-04 15:52:06 +01:00
Diego Elio Pettenò 4307413256 USB: serial: cp210x: add IDs for LifeScan OneTouch Verio IQ
Add IDs for the OneTouch Verio IQ that comes with an embedded
USB-to-serial converter.

Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.eu>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-01-02 10:47:29 +01:00
Max Schulze c6a36ad383 USB: serial: ftdi_sio: add id for Airbus DS P8GR
Add AIRBUS_DS_P8GR device IDs to ftdi_sio driver.

Signed-off-by: Max Schulze <max.schulze@posteo.de>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-12-27 11:47:31 +01:00
SZ Lin (林上智) 3920bb7130 USB: serial: option: adding support for YUGA CLM920-NC5
This patch adds support for YUGA CLM920-NC5 PID 0x9625 USB modem to option
driver.

Interface layout:
0: QCDM/DIAG
1: ADB
2: MODEM
3: AT
4: RMNET

Signed-off-by: Taiyi Wu <taiyity.wu@moxa.com>
Signed-off-by: SZ Lin (林上智) <sz.lin@moxa.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-12-19 11:25:12 +01:00
Reinhard Speyerer 92a18a657f USB: serial: qcserial: add Sierra Wireless EM7565
Sierra Wireless EM7565 devices use the QCSERIAL_SWI layout for their
serial ports

T:  Bus=01 Lev=03 Prnt=29 Port=01 Cnt=02 Dev#= 31 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1199 ProdID=9091 Rev= 0.06
S:  Manufacturer=Sierra Wireless, Incorporated
S:  Product=Sierra Wireless EM7565 Qualcomm Snapdragon X16 LTE-A
S:  SerialNumber=xxxxxxxx
C:* #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=qcserial
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=qcserial
E:  Ad=83(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=qcserial
E:  Ad=85(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 8 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
E:  Ad=86(I) Atr=03(Int.) MxPS=   8 Ivl=32ms
E:  Ad=8e(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=0f(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

but need sendsetup = true for the NMEA port to make it work properly.

Simplify the patch compared to v1 as suggested by Bjørn Mork by taking
advantage of the fact that existing devices work with sendsetup = true
too.

Use sendsetup = true for the NMEA interface of QCSERIAL_SWI and add
DEVICE_SWI entries for the EM7565 PID 0x9091 and the EM7565 QDL PID
0x9090.

Tests with several MC73xx/MC74xx/MC77xx devices have been performed in
order to verify backward compatibility.

Signed-off-by: Reinhard Speyerer <rspmn@arcor.de>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-12-15 09:41:46 +01:00
Daniele Palmas 08933099e6 USB: serial: option: add support for Telit ME910 PID 0x1101
This patch adds support for PID 0x1101 of Telit ME910.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-12-15 09:37:08 +01:00
Jia-Ju Bai c7b8f77872 USB: serial: io_edgeport: fix possible sleep-in-atomic
According to drivers/usb/serial/io_edgeport.c, the driver may sleep
under a spinlock.
The function call path is:
edge_bulk_in_callback (acquire the spinlock)
   process_rcvd_data
     process_rcvd_status
       change_port_settings
         send_iosp_ext_cmd
           write_cmd_usb
             usb_kill_urb --> may sleep

To fix it, the redundant usb_kill_urb() is removed from the error path
after usb_submit_urb() fails.

This possible bug is found by my static analysis tool (DSAC) and checked
by my code review.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-12-14 10:32:29 +01:00
Lu Baolu 762ff4678e USB: serial: usb_debug: add new USB device id
USB vendor id and product id for Linux USB Debug Target is added.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-11-28 09:54:11 +01:00
Gimcuan Hui d8a42b1ff8 USB: serial: ark3116: clean up return values of register accessors
write_reg returns 0 on success, we can make it more explicit by returning
number 0 instead of result variable.

read_reg should return 0 on success since this is a more common pattern.

The user of read_reg has been clean-up and should be at the same commit.

Signed-off-by: Gimcuan Hui <gimcuan@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-11-28 09:42:50 +01:00
Colin Ian King 5f0337b549 USB: serial: iuu_phoenix: remove redundant assignment of DIV to itself
The assignment of DIV to itself is redundant and can be removed.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-11-27 13:51:07 +01:00
Sebastian Sjoholm c654b21ede USB: serial: option: add Quectel BG96 id
Quectel BG96 is an Qualcomm MDM9206 based IoT modem, supporting both
CAT-M and NB-IoT. Tested hardware is BG96 mounted on Quectel
development board (EVB). The USB id is added to option.c to allow
DIAG,GPS,AT and modem communication with the BG96.

Signed-off-by: Sebastian Sjoholm <ssjoholm@mac.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-11-27 10:46:57 +01:00
Kees Cook e99e88a9d2 treewide: setup_timer() -> timer_setup()
This converts all remaining cases of the old setup_timer() API into using
timer_setup(), where the callback argument is the structure already
holding the struct timer_list. These should have no behavioral changes,
since they just change which pointer is passed into the callback with
the same available pointers after conversion. It handles the following
examples, in addition to some other variations.

Casting from unsigned long:

    void my_callback(unsigned long data)
    {
        struct something *ptr = (struct something *)data;
    ...
    }
    ...
    setup_timer(&ptr->my_timer, my_callback, ptr);

and forced object casts:

    void my_callback(struct something *ptr)
    {
    ...
    }
    ...
    setup_timer(&ptr->my_timer, my_callback, (unsigned long)ptr);

become:

    void my_callback(struct timer_list *t)
    {
        struct something *ptr = from_timer(ptr, t, my_timer);
    ...
    }
    ...
    timer_setup(&ptr->my_timer, my_callback, 0);

Direct function assignments:

    void my_callback(unsigned long data)
    {
        struct something *ptr = (struct something *)data;
    ...
    }
    ...
    ptr->my_timer.function = my_callback;

have a temporary cast added, along with converting the args:

    void my_callback(struct timer_list *t)
    {
        struct something *ptr = from_timer(ptr, t, my_timer);
    ...
    }
    ...
    ptr->my_timer.function = (TIMER_FUNC_TYPE)my_callback;

And finally, callbacks without a data assignment:

    void my_callback(unsigned long data)
    {
    ...
    }
    ...
    setup_timer(&ptr->my_timer, my_callback, 0);

have their argument renamed to verify they're unused during conversion:

    void my_callback(struct timer_list *unused)
    {
    ...
    }
    ...
    timer_setup(&ptr->my_timer, my_callback, 0);

The conversion is done with the following Coccinelle script:

spatch --very-quiet --all-includes --include-headers \
	-I ./arch/x86/include -I ./arch/x86/include/generated \
	-I ./include -I ./arch/x86/include/uapi \
	-I ./arch/x86/include/generated/uapi -I ./include/uapi \
	-I ./include/generated/uapi --include ./include/linux/kconfig.h \
	--dir . \
	--cocci-file ~/src/data/timer_setup.cocci

@fix_address_of@
expression e;
@@

 setup_timer(
-&(e)
+&e
 , ...)

// Update any raw setup_timer() usages that have a NULL callback, but
// would otherwise match change_timer_function_usage, since the latter
// will update all function assignments done in the face of a NULL
// function initialization in setup_timer().
@change_timer_function_usage_NULL@
expression _E;
identifier _timer;
type _cast_data;
@@

(
-setup_timer(&_E->_timer, NULL, _E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E->_timer, NULL, (_cast_data)_E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, &_E);
+timer_setup(&_E._timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, (_cast_data)&_E);
+timer_setup(&_E._timer, NULL, 0);
)

@change_timer_function_usage@
expression _E;
identifier _timer;
struct timer_list _stl;
identifier _callback;
type _cast_func, _cast_data;
@@

(
-setup_timer(&_E->_timer, _callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
 _E->_timer@_stl.function = _callback;
|
 _E->_timer@_stl.function = &_callback;
|
 _E->_timer@_stl.function = (_cast_func)_callback;
|
 _E->_timer@_stl.function = (_cast_func)&_callback;
|
 _E._timer@_stl.function = _callback;
|
 _E._timer@_stl.function = &_callback;
|
 _E._timer@_stl.function = (_cast_func)_callback;
|
 _E._timer@_stl.function = (_cast_func)&_callback;
)

// callback(unsigned long arg)
@change_callback_handle_cast
 depends on change_timer_function_usage@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
identifier _handle;
@@

 void _callback(
-_origtype _origarg
+struct timer_list *t
 )
 {
(
	... when != _origarg
	_handletype *_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
	... when != _origarg
|
	... when != _origarg
	_handletype *_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
	... when != _origarg
|
	... when != _origarg
	_handletype *_handle;
	... when != _handle
	_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
	... when != _origarg
|
	... when != _origarg
	_handletype *_handle;
	... when != _handle
	_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
	... when != _origarg
)
 }

// callback(unsigned long arg) without existing variable
@change_callback_handle_cast_no_arg
 depends on change_timer_function_usage &&
                     !change_callback_handle_cast@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
@@

 void _callback(
-_origtype _origarg
+struct timer_list *t
 )
 {
+	_handletype *_origarg = from_timer(_origarg, t, _timer);
+
	... when != _origarg
-	(_handletype *)_origarg
+	_origarg
	... when != _origarg
 }

// Avoid already converted callbacks.
@match_callback_converted
 depends on change_timer_function_usage &&
            !change_callback_handle_cast &&
	    !change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier t;
@@

 void _callback(struct timer_list *t)
 { ... }

// callback(struct something *handle)
@change_callback_handle_arg
 depends on change_timer_function_usage &&
	    !match_callback_converted &&
            !change_callback_handle_cast &&
            !change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
@@

 void _callback(
-_handletype *_handle
+struct timer_list *t
 )
 {
+	_handletype *_handle = from_timer(_handle, t, _timer);
	...
 }

// If change_callback_handle_arg ran on an empty function, remove
// the added handler.
@unchange_callback_handle_arg
 depends on change_timer_function_usage &&
	    change_callback_handle_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
identifier t;
@@

 void _callback(struct timer_list *t)
 {
-	_handletype *_handle = from_timer(_handle, t, _timer);
 }

// We only want to refactor the setup_timer() data argument if we've found
// the matching callback. This undoes changes in change_timer_function_usage.
@unchange_timer_function_usage
 depends on change_timer_function_usage &&
            !change_callback_handle_cast &&
            !change_callback_handle_cast_no_arg &&
	    !change_callback_handle_arg@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type change_timer_function_usage._cast_data;
@@

(
-timer_setup(&_E->_timer, _callback, 0);
+setup_timer(&_E->_timer, _callback, (_cast_data)_E);
|
-timer_setup(&_E._timer, _callback, 0);
+setup_timer(&_E._timer, _callback, (_cast_data)&_E);
)

// If we fixed a callback from a .function assignment, fix the
// assignment cast now.
@change_timer_function_assignment
 depends on change_timer_function_usage &&
            (change_callback_handle_cast ||
             change_callback_handle_cast_no_arg ||
             change_callback_handle_arg)@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_func;
typedef TIMER_FUNC_TYPE;
@@

(
 _E->_timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
 ;
|
 _E->_timer.function =
-&_callback
+(TIMER_FUNC_TYPE)_callback
 ;
|
 _E->_timer.function =
-(_cast_func)_callback;
+(TIMER_FUNC_TYPE)_callback
 ;
|
 _E->_timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
 ;
|
 _E._timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
 ;
|
 _E._timer.function =
-&_callback;
+(TIMER_FUNC_TYPE)_callback
 ;
|
 _E._timer.function =
-(_cast_func)_callback
+(TIMER_FUNC_TYPE)_callback
 ;
|
 _E._timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
 ;
)

// Sometimes timer functions are called directly. Replace matched args.
@change_timer_function_calls
 depends on change_timer_function_usage &&
            (change_callback_handle_cast ||
             change_callback_handle_cast_no_arg ||
             change_callback_handle_arg)@
expression _E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_data;
@@

 _callback(
(
-(_cast_data)_E
+&_E->_timer
|
-(_cast_data)&_E
+&_E._timer
|
-_E
+&_E->_timer
)
 )

// If a timer has been configured without a data argument, it can be
// converted without regard to the callback argument, since it is unused.
@match_timer_function_unused_data@
expression _E;
identifier _timer;
identifier _callback;
@@

(
-setup_timer(&_E->_timer, _callback, 0);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0L);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0UL);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0L);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0UL);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0L);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0UL);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0L);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0UL);
+timer_setup(_timer, _callback, 0);
)

@change_callback_unused_data
 depends on match_timer_function_unused_data@
identifier match_timer_function_unused_data._callback;
type _origtype;
identifier _origarg;
@@

 void _callback(
-_origtype _origarg
+struct timer_list *unused
 )
 {
	... when != _origarg
 }

Signed-off-by: Kees Cook <keescook@chromium.org>
2017-11-21 15:57:07 -08:00
Linus Torvalds 894025f24b USB/PHY patches for 4.15-rc1
Here is the big set of USB and PHY driver updates for 4.15-rc1.
 
 There is the usual amount of gadget and xhci driver updates, along with
 phy and chipidea enhancements.  There's also a lot of SPDX tags and
 license boilerplate cleanups as well, which provide some churn in the
 diffstat.
 
 Other major thing is the typec code that moved out of staging and into
 the "real" part of the drivers/usb/ tree, which was nice to see happen.
 
 All of these have been in linux-next with no reported issues for a
 while.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWgm/Vw8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+yktXwCdGgpInfOEvOGFd83EPDL7a1ncyc4AoM5wI8yl
 1CeLipqVIN3IsMMJptvb
 =zvDI
 -----END PGP SIGNATURE-----

Merge tag 'usb-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB/PHY updates from Greg KH:
 "Here is the big set of USB and PHY driver updates for 4.15-rc1.

  There is the usual amount of gadget and xhci driver updates, along
  with phy and chipidea enhancements. There's also a lot of SPDX tags
  and license boilerplate cleanups as well, which provide some churn in
  the diffstat.

  Other major thing is the typec code that moved out of staging and into
  the "real" part of the drivers/usb/ tree, which was nice to see
  happen.

  All of these have been in linux-next with no reported issues for a
  while"

* tag 'usb-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (263 commits)
  usb: gadget: f_fs: Fix use-after-free in ffs_free_inst
  USB: usbfs: compute urb->actual_length for isochronous
  usb: core: message: remember to reset 'ret' to 0 when necessary
  USB: typec: Remove remaining redundant license text
  USB: typec: add SPDX identifiers to some files
  USB: renesas_usbhs: rcar?.h: add SPDX tags
  USB: chipidea: ci_hdrc_tegra.c: add SPDX line
  USB: host: xhci-debugfs: add SPDX lines
  USB: add SPDX identifiers to all remaining Makefiles
  usb: host: isp1362-hcd: remove a couple of redundant assignments
  USB: adutux: remove redundant variable minor
  usb: core: add a new usb_get_ptm_status() helper
  usb: core: add a 'type' parameter to usb_get_status()
  usb: core: introduce a new usb_get_std_status() helper
  usb: core: rename usb_get_status() 'type' argument to 'recip'
  usb: core: add Status Type definitions
  USB: gadget: Remove redundant license text
  USB: gadget: function: Remove redundant license text
  USB: gadget: udc: Remove redundant license text
  USB: gadget: legacy: Remove redundant license text
  ...
2017-11-13 21:14:07 -08:00
Greg Kroah-Hartman 3efe891f61 USB: add SPDX identifiers to all remaining Makefiles
It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

This updates the remaining drivers/usb/*Makefile* that were missing SPDX
identifiers.  They all get the following identifier:
	SPDX-License-Identifier: GPL-2.0

The SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Peter Korsgaard <jacmet@sunsite.dk>
Cc: Thomas Winischhofer <thomas@winischhofer.net>
Cc: Johan Hovold <johan@kernel.org>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-07 15:53:48 +01:00
Lu Baolu 12f28144cf USB: serial: Change DbC debug device binding ID
The product ID for "Linux USB GDB Target device" has been
changed. Change the driver binding table accordingly.

This patch should be back-ported to kernels as old as v4.12,
that contain the commit 57fb47279a ("usb/serial: Add DBC
debug device support to usb_debug").

Cc: <stable@vger.kernel.org> # v4.12+
Cc: Johan Hovold <johan@kernel.org>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-07 15:34:08 +01: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
Greg Kroah-Hartman 29ce32ecca USB-serial updates for v4.15-rc1
Here are the USB-serial updates for 4.15-rc1, including:
 
  - three fixes for longstanding issues in garmin_gps and metro-usb which
    could lead to NULL-pointer dereferences and memory leaks
 
  - a workaround for broken f81534 firmware-handling of overruns
 
  - f81534 break support, and
 
  - conversion to timer_setup()
 
 Included are also various clean ups and a new qcserial device id.
 
 All have been in linux-next with no reported issues.
 
 Signed-off-by: Johan Hovold <johan@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEHszNKQClByu0A+9RQQ3kT97htJUFAln7RnoRHGpvaGFuQGtl
 cm5lbC5vcmcACgkQQQ3kT97htJXDyw//UbJ1M8HAIGTUwt73mtWJEqHxq98MM76t
 2DntL+Mv1sFcmyVx9EK5UUGrr9ayCSMb/ZmJnYrFoQq9t5e+dnSAW48fRPyK8Nig
 AZcA1SCcM6qj1y7WE0yKNSybMx4VSmi7I8TGgw4bcLMTlxIzkkO78m2EWLzsCPSV
 nYeFWYJKSXFiMNIISjqDj6VfDd8qphlQn61PHx1a+4AUWCrIz8YsfTh03owsEmdg
 u/nMzJPjJf3+DpPjTpXMlTyR3PQr3Ud/nqADpS8t1UacQmWMVp7CDYjZE9AFB7hg
 KCd6kc6Px8/2p0xew7wuwvPSaneRnGvEs3QUhE+Jr5SxIz6vQW/GG3pMVEP1pOOO
 NDmeOG1d3FrihveddRFvM//fHKxOFjJVk2ml+LXM9LbtU0Tzv523wtqRzugt3YkE
 gq1gJyiVF4DWrL+pJsKyARejO7C42/g43rMAM1hcr2DgW9KcZL3FedjmLhaW62Mn
 ewiG1qVgHU+DFS2qFDYQpIAWi6D/p/XLgJfmfU9Tv29N1jFKXQuhjivS5rk4//w6
 fGOjGS8R0Iwn7smtHU/l32t3jI4pE1sjG7O1iKSVjNLG+VTXg9HvdHtIorZA385a
 uMEh4zRwiG3g+PWI04/nkwa69TWelDugwZL+1fLTnaq2qR3dWLk7OIZIpXPXTOgE
 /yta7rLMAmM=
 =GqYH
 -----END PGP SIGNATURE-----

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

Johan writes:

USB-serial updates for v4.15-rc1

Here are the USB-serial updates for 4.15-rc1, including:

 - three fixes for longstanding issues in garmin_gps and metro-usb which
   could lead to NULL-pointer dereferences and memory leaks

 - a workaround for broken f81534 firmware-handling of overruns

 - f81534 break support, and

 - conversion to timer_setup()

Included are also various clean ups and a new qcserial device id.

All have been in linux-next with no reported issues.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-11-02 17:42:47 +01:00
Greg Kroah-Hartman b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.

By default all files without license information are under the default
license of the kernel, which is GPL version 2.

Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier.  The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.

This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.

How this work was done:

Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
 - file had no licensing information it it.
 - file was a */uapi/* one with no licensing information in it,
 - file was a */uapi/* one with existing licensing information,

Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.

The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne.  Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.

The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed.  Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.

Criteria used to select files for SPDX license identifier tagging was:
 - Files considered eligible had to be source code files.
 - Make and config files were included as candidates if they contained >5
   lines of source
 - File already had some variant of a license header in it (even if <5
   lines).

All documentation files were explicitly excluded.

The following heuristics were used to determine which SPDX license
identifiers to apply.

 - when both scanners couldn't find any license traces, file was
   considered to have no license information in it, and the top level
   COPYING file license applied.

   For non */uapi/* files that summary was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0                                              11139

   and resulted in the first patch in this series.

   If that file was a */uapi/* path one, it was "GPL-2.0 WITH
   Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0 WITH Linux-syscall-note                        930

   and resulted in the second patch in this series.

 - if a file had some form of licensing information in it, and was one
   of the */uapi/* ones, it was denoted with the Linux-syscall-note if
   any GPL family license was found in the file or had no licensing in
   it (per prior point).  Results summary:

   SPDX license identifier                            # files
   ---------------------------------------------------|------
   GPL-2.0 WITH Linux-syscall-note                       270
   GPL-2.0+ WITH Linux-syscall-note                      169
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
   LGPL-2.1+ WITH Linux-syscall-note                      15
   GPL-1.0+ WITH Linux-syscall-note                       14
   ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
   LGPL-2.0+ WITH Linux-syscall-note                       4
   LGPL-2.1 WITH Linux-syscall-note                        3
   ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
   ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1

   and that resulted in the third patch in this series.

 - when the two scanners agreed on the detected license(s), that became
   the concluded license(s).

 - when there was disagreement between the two scanners (one detected a
   license but the other didn't, or they both detected different
   licenses) a manual inspection of the file occurred.

 - In most cases a manual inspection of the information in the file
   resulted in a clear resolution of the license that should apply (and
   which scanner probably needed to revisit its heuristics).

 - When it was not immediately clear, the license identifier was
   confirmed with lawyers working with the Linux Foundation.

 - If there was any question as to the appropriate license identifier,
   the file was flagged for further research and to be revisited later
   in time.

In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.

Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights.  The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.

Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.

In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.

Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
 - a full scancode scan run, collecting the matched texts, detected
   license ids and scores
 - reviewing anything where there was a license detected (about 500+
   files) to ensure that the applied SPDX license was correct
 - reviewing anything where there was no detection but the patch license
   was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
   SPDX license was correct

This produced a worksheet with 20 files needing minor correction.  This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.

These .csv files were then reviewed by Greg.  Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected.  This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.)  Finally Greg ran the script using the .csv files to
generate the patches.

Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-02 11:10:55 +01:00
Ji-Ze Hong (Peter Hong) 7c36e6e14d USB: serial: f81534: implement break control
Implement Fintek f81534 break on/off with LCR register.
It's the same with 16550A LCR register layout.

Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-31 09:50:40 +01:00
Ji-Ze Hong (Peter Hong) dea744bae7 USB: serial: f81534: fix hang-up on overrun
The F81532/534 without this patch will hang-up on data overrun.

It's caused by enable LSR interrupt in IER by default and occur data
overrun, the chip will busy for process LSR interrupt but not read LSR
internally. It will not responed for USB control endpoint0 and we can't
read LSR from driver in this situration.

So we'll disable the LSR interrupt in probe() and submit the LSR worker to
clear LSR state when reported LSR error bit with bulk-in data in
f81534_process_per_serial_block().

Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-31 09:19:33 +01:00
Douglas Fischer 771394a541 USB: serial: qcserial: add pid/vid for Sierra Wireless EM7355 fw update
Add USB PID/VID for Sierra Wireless EM7355 LTE modem QDL firmware update
mode.

Signed-off-by: Douglas Fischer <douglas.fischer@outlook.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-31 07:52:31 +01:00
Gustavo A. R. Silva fe1f68a08f USB: serial: kobil_sct: mark expected switch fall-through
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Addresses-Coverity-ID: 115014
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-30 15:24:56 +01:00
Johan Hovold 31dc3f819b USB: serial: metro-usb: add MS7820 device id
Add device-id entry for (Honeywell) Metrologic MS7820 bar code scanner.

The device has two interfaces (in this mode?); a vendor-specific
interface with two interrupt endpoints and a second HID interface, which
we do not bind to.

Reported-by: Ladislav Dobrovsky <ladislav.dobrovsky@gmail.com>
Tested-by: Ladislav Dobrovsky <ladislav.dobrovsky@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-16 09:34:58 +02:00
Johan Hovold 2944fd27d1 USB: serial: drop unused core USB driver
Drop the usb-serial-core USB driver that was registered at module init
but then never used.

This was a remnant dating back to 2004 (!) when this struct usb_driver
was used for the generic driver; see commit bbc53b7d7322 ("USB: fix bug
where removing usb-serial modules or usb serial devices could oops") in
the tglx bitkeeper-history archive.

Note that every usb-serial driver (including the generic one) registers
its own USB (interface) driver along with its usb-serial bus drivers.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-13 09:48:55 +02:00
Johan Hovold ee13a25fc3 USB: serial: metro-usb: add missing interrupt-out endpoint check
One class of "unidirectional" devices managed by this driver uses an
interrupt-out endpoint to send control messages at open and close. Due
to a missing endpoint sanity check, this could result in an interrupt
URB being submitted to endpoint 0 instead. This would be caught by
USB core (without a WARN dump), but let's verify that the expected
endpoints are present at probe rather than when a port is later opened.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-13 09:45:09 +02:00
Johan Hovold 6f792f471f USB: serial: metro-usb: simplify endpoint check
Let usb-serial core verify that the interrupt-in endpoint is present
when binding the interface instead of the driver verifying this at every
open.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-13 09:45:09 +02:00
Johan Hovold 2339536d22 USB: serial: metro-usb: stop I/O after failed open
Make sure to kill the interrupt-in URB after a failed open request.
Apart from saving power (and avoiding stale input after a later
successful open), this also prevents a NULL-deref in the completion
handler if the port is manually unbound.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Fixes: 704577861d ("USB: serial: metro-usb: get data from device in Uni-Directional mode.")
Cc: stable <stable@vger.kernel.org>	# 3.5
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-13 09:44:31 +02:00
Johan Hovold 9eabd28e8b USB: serial: garmin_gps: simplify init-session logic
Clean up the somewhat convoluted init-session logic to improve
readability.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-11 15:25:00 +02:00
Johan Hovold c1a357b686 USB: serial: garmin_gps: clean up init-session messages
Use the port device for any init-session error and debug messages,
remove one redundant debug message and simplify one error message.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-11 15:24:55 +02:00
Johan Hovold b943cee8a5 USB: serial: garmin_gps: drop unused timer initialisation
Drop out-commented timer expiry initialisation which would not even
compile anymore.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-11 15:24:49 +02:00
Johan Hovold 74d471b598 USB: serial: garmin_gps: fix memory leak on probe errors
Make sure to free the port private data before returning after a failed
probe attempt.

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-11 15:24:42 +02:00
Johan Hovold 19a565d9af USB: serial: garmin_gps: fix I/O after failed probe and remove
Make sure to stop any submitted interrupt and bulk-out URBs before
returning after failed probe and when the port is being unbound to avoid
later NULL-pointer dereferences in the completion callbacks.

Also fix up the related and broken I/O cancellation on failed open and
on close. (Note that port->write_urb was never submitted.)

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org>	# 51a2f077 ("USB: introduce usb_anchor")
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-11 15:24:22 +02:00
Kees Cook 29d1536138 USB: serial: garmin_gps: convert timers to use timer_setup()
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Johan Hovold <johan@kernel.org>
Cc: Allen Pais <allen.lkml@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-11 09:21:46 +02:00
Johan Hovold 299d7572e4 USB: serial: console: fix use-after-free after failed setup
Make sure to reset the USB-console port pointer when console setup fails
in order to avoid having the struct usb_serial be prematurely freed by
the console code when the device is later disconnected.

Fixes: 73e487fdb7 ("[PATCH] USB console: fix disconnection issues")
Cc: stable <stable@vger.kernel.org>	# 2.6.18
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-09 12:33:31 +02:00
Johan Hovold bd998c2e0d USB: serial: console: fix use-after-free on disconnect
A clean-up patch removing two redundant NULL-checks from the console
disconnect handler inadvertently also removed a third check. This could
lead to the struct usb_serial being prematurely freed by the console
code when a driver accepts but does not register any ports for an
interface which also lacks endpoint descriptors.

Fixes: 0e517c93dc ("USB: serial: console: clean up sanity checks")
Cc: stable <stable@vger.kernel.org>     # 4.11
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-09 12:33:04 +02:00
Shrirang Bagul f5d9644c5f USB: serial: qcserial: add Dell DW5818, DW5819
Dell Wireless 5819/5818 devices are re-branded Sierra Wireless MC74
series which will by default boot with vid 0x413c and pid's 0x81cf,
0x81d0, 0x81d1, 0x81d2.

Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-10-03 15:33:50 +02:00
Andreas Engel c496ad835c USB: serial: cp210x: add support for ELV TFD500
Add the USB device id for the ELV TFD500 data logger.

Signed-off-by: Andreas Engel <anen-nospam@gmx.net>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-09-19 09:42:28 +02:00
Sebastian Frei 7eac35ea29 USB: serial: cp210x: fix partnum regression
When adding GPIO support for the cp2105, the mentioned commit by Martyn
Welch introduced a query for the part number of the chip. Unfortunately
the driver aborts probing when this query fails, so currently the driver
can not be used with chips not supporting this query.
I have a data cable for Siemens mobile phones (ID 10ab:10c5) where this
is the case.
With this patch the driver can be bound even if the part number can not
be queried.

Fixes: cf5276ce78 ("USB: serial: cp210x: Adding GPIO support for CP2105")
Signed-off-by: Sebastian Frei <dr.nop@gmx.net>
[ johan: amend commit message; shorten error message and demote to
         warning; drop unnecessary move of usb_set_serial_data() ]
Cc: stable <stable@vger.kernel.org>	# 4.9
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-09-19 09:37:48 +02:00
Henryk Heisig 837ddc4793 USB: serial: option: add support for TP-Link LTE module
This commit adds support for TP-Link LTE mPCIe module is used
in in TP-Link MR200v1, MR6400v1 and v2 routers.

Signed-off-by: Henryk Heisig <hyniu@o2.pl>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-09-18 10:41:02 +02:00
Jeffrey Chu a6c215e21b USB: serial: ftdi_sio: add id for Cypress WICED dev board
Add CYPRESS_VID vid and CYPRESS_WICED_BT_USB and CYPRESS_WICED_WL_USB
device IDs to ftdi_sio driver.

Signed-off-by: Jeffrey Chu <jeffrey.chu@cypress.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-09-18 10:32:51 +02:00
Bjørn Mork b5fdde28d4 USB: serial: option: simplify 3 D-Link device entries
All the vendor specific interfaces on these devices are serial
functions handled by this driver, so we can use a single class
match entry for each.

 P:  Vendor=2001 ProdID=7d01 Rev= 3.00
 S:  Manufacturer=D-Link,Inc
 S:  Product=D-Link DWM-156
 C:* #Ifs= 7 Cfg#= 1 Atr=a0 MxPwr=500mA
 A:  FirstIf#= 0 IfCount= 2 Cls=02(comm.) Sub=0e Prot=00
 I:* If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=0e Prot=00 Driver=cdc_mbim
 E:  Ad=88(I) Atr=03(Int.) MxPS=  64 Ivl=125us
 I:  If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim
 I:* If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim
 E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=02 Prot=01 Driver=option
 E:  Ad=87(I) Atr=03(Int.) MxPS=  64 Ivl=500us
 E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 I:* If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
 E:  Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 I:* If#= 4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
 E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 I:* If#= 5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
 E:  Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E:  Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 I:* If#= 6 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
 E:  Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E:  Ad=06(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-08-30 09:41:25 +02:00
Maciej S. Szmigiero 169e86546f USB: serial: option: add support for D-Link DWM-157 C1
This commit adds support (an ID, really) for D-Link DWM-157 hardware
version C1 USB modem to option driver.

According to manufacturer-provided Windows INF file the device has four
serial ports:
"D-Link HSPA+DataCard Diagnostics Interface" (interface 2; modem port),
"D-Link HSPA+DataCard NMEA Device" (interface 3),
"D-Link HSPA+DataCard Speech Port" (interface 4),
"D-Link HSPA+DataCard Debug Port" (interface 5).

usb-devices output:
T:  Bus=05 Lev=01 Prnt=01 Port=04 Cnt=01 Dev#=  3 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=2001 ProdID=7d0e Rev=03.00
S:  Manufacturer=D-Link,Inc
S:  Product=D-Link DWM-157
C:  #Ifs= 7 Cfg#= 1 Atr=a0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0e Prot=00 Driver=cdc_mbim
I:  If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim
I:  If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=02 Prot=01 Driver=option
I:  If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 6 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-08-30 09:34:34 +02:00
Greg Kroah-Hartman 3b6bcd3d09 USB: serial: pl2303: add new ATEN device id
This adds a new ATEN device id for a new pl2303-based device.

Reported-by: Peter Kuo <PeterKuo@aten.com.tw>
Cc: stable <stable@vger.kernel.org>
Cc: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-08-10 11:55:00 -07:00
Hector Martin fd1b8668af USB: serial: option: add D-Link DWM-222 device ID
Add device id for D-Link DWM-222.

Cc: stable@vger.kernel.org
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-08-01 21:22:59 +02:00
Stefan Triller 9585e340db USB: serial: cp210x: add support for Qivicon USB ZigBee dongle
The German Telekom offers a ZigBee USB Stick under the brand name Qivicon
for their SmartHome Home Base in its 1. Generation. The productId is not
known by the according kernel module, this patch adds support for it.

Signed-off-by: Stefan Triller <github@stefantriller.de>
Reviewed-by: Frans Klaver <fransklaver@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-07-17 12:40:56 +02:00
Joe Perches 4abf87f41a USB: serial: safe_serial: move __inline__ before return type
Make the code like the rest of the kernel.
Also use inline instead of __inline__.

Link: http://lkml.kernel.org/r/a5072b74b6c293e6ec93c4900482e9d3267f15b2.1499284835.git.joe@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-07-12 16:26:04 -07:00
Linus Torvalds 6481352082 USB fixes for 4.13-rc1
Here are some remaining USB fixes for 4.13-rc1.  They were originally
 scheduled for 4.12-final, but I didn't send them to you in time.
 Because of that, they were in a separate branch from the larger USB set
 of patches, so here they are in a separate pull request.
 
 Nothing major here a all, just 3 small patches:
 	- some usb-serial new device ids
 	- xhci bugfix for some crazy AMD hardware
 
 All of these have been in linux-next for a long time with no reported
 issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWV9FRg8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ylHxgCfTT31v4FaxH2k76qA1ZnHdXWHqyQAn3oyOE4T
 uJhpp1FbFR1VNXM/jRox
 =PCPm
 -----END PGP SIGNATURE-----

Merge tag 'usb-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH:
 "Here are some remaining USB fixes for 4.13-rc1. They were originally
  scheduled for 4.12-final, but I didn't send them to you in time.
  Because of that, they were in a separate branch from the larger USB
  set of patches, so here they are in a separate pull request.

  Nothing major here a all, just three small patches:

   - some usb-serial new device ids
   - xhci bugfix for some crazy AMD hardware

  All of these have been in linux-next for a long time with no reported
  issues"

* tag 'usb-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
  xhci: Limit USB2 port wake support for AMD Promontory hosts
  USB: serial: qcserial: new Sierra Wireless EM7305 device ID
  USB: serial: option: add two Longcheer device ids
2017-07-07 13:42:04 -07:00
Linus Torvalds 9a715cd543 TTY/Serial patches for 4.13-rc1
Here is the large tty/serial patchset for 4.13-rc1.
 
 A lot of tty and serial driver updates are in here, along with some
 fixups for some __get/put_user usages that were reported.  Nothing huge,
 just lots of development by a number of different developers, full
 details in the shortlog.
 
 All of these have been in linux-next for a while.  There will be a merge
 issue with the arm-soc tree in the include/linux/platform_data/atmel.h
 file.  Stephen has sent out a fixup for it, so it shouldn't be that
 difficult to merge.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWVpZ9w8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ylkTgCfV2HhbxIph/aEL1nJmwW64oCXFrMAoK59ZH65
 tBZIosv0d91K1A+mObBT
 =adPL
 -----END PGP SIGNATURE-----

Merge tag 'tty-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty

Pull tty/serial updates from Greg KH:
 "Here is the large tty/serial patchset for 4.13-rc1.

  A lot of tty and serial driver updates are in here, along with some
  fixups for some __get/put_user usages that were reported. Nothing
  huge, just lots of development by a number of different developers,
  full details in the shortlog.

  All of these have been in linux-next for a while"

* tag 'tty-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (71 commits)
  tty: serial: lpuart: add a more accurate baud rate calculation method
  tty: serial: lpuart: add earlycon support for imx7ulp
  tty: serial: lpuart: add imx7ulp support
  dt-bindings: serial: fsl-lpuart: add i.MX7ULP support
  tty: serial: lpuart: add little endian 32 bit register support
  tty: serial: lpuart: refactor lpuart32_{read|write} prototype
  tty: serial: lpuart: introduce lpuart_soc_data to represent SoC property
  serial: imx-serial - move DMA buffer configuration to DT
  serial: imx: Enable RTSD only when needed
  serial: imx: Remove unused members from imx_port struct
  serial: 8250: 8250_omap: Fix race b/w dma completion and RX timeout
  serial: 8250: Fix THRE flag usage for CAP_MINI
  tty/serial: meson_uart: update to stable bindings
  dt-bindings: serial: Add bindings for the Amlogic Meson UARTs
  serial: Delete dead code for CIR serial ports
  serial: sirf: make of_device_ids const
  serial/mpsc: switch to dma_alloc_attrs
  tty: serial: Add Actions Semi Owl UART earlycon
  dt-bindings: serial: Document Actions Semi Owl UARTs
  tty/serial: atmel: make the driver DT only
  ...
2017-07-03 20:04:16 -07:00
Jeremie Rapin fd90f73a99 USB: serial: cp210x: add ID for CEL EM3588 USB ZigBee stick
Added the USB serial device ID for the CEL ZigBee EM3588
radio stick.

Signed-off-by: Jeremie Rapin <rapinj@gmail.com>
Cc: stable <stable@vger.kernel.org>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-28 20:14:00 +02:00
Johan Hovold c22ac6d29f USB: serial: propagate late probe errors
Propagate errnos for late probe errors (e.g. -ENOMEM on allocation
failures) instead of always returning -EIO.

Note that some drivers are currently returning -ENODEV from their attach
callbacks when a device is not supported, but this has also been mapped
to -EIO.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-06-21 09:40:07 +02:00
Johan Hovold 45e5d4d418 USB: serial: refactor port endpoint setup
Make the probe callback more readable by refactoring the port
endpoint-resource setup by adding four helper functions.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-06-21 09:38:58 +02:00
Bjørn Mork 996fab55d8 USB: serial: qcserial: new Sierra Wireless EM7305 device ID
A new Sierra Wireless EM7305 device ID used in a Toshiba laptop.

Reported-by: Petr Kloc <petr_kloc@yahoo.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-06-14 09:27:57 +02:00
Johan Hovold 8fb060da71 USB: serial: option: add two Longcheer device ids
Add two Longcheer device-id entries which specifically enables a
Telewell TW-3G HSPA+ branded modem (0x9801).

Reported-by: Teemu Likonen <tlikonen@iki.fi>
Reported-by: Bjørn Mork <bjorn@mork.no>
Reported-by: Lars Melin <larsm17@gmail.com>
Tested-by: Teemu Likonen <tlikonen@iki.fi>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-06-14 09:23:57 +02:00
Johan Hovold 83c9a2d1a6 USB: serial: ftdi_sio: remove broken alt-speed handling
Remove the broken alt_speed code, and warn when trying to set the line
speed using TIOCSSERIAL and SPD flags.

The use of SPD flags to set the line speed has been deprecated since
v2.1.69 and support for alt_speed (e.g. "warp") has even been removed
from TTY core in v3.10 by commit 6865ff222c ("TTY: do not warn about
setting speed via SPD_*"), effectively breaking all driver
implementations of this except for serial core.

Also remove the verbose and outdated comment on how to set baud rates.

Note that setting a custom divisor will continue to work with the
caveat that 38400 must again be selected every time the divisor is
changed since v2.6.24 and commit 669a6db103 ("USB: ftd_sio: cleanups
and updates for new termios work") which started reporting back the
actual baud rate used.

Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-13 11:49:58 +02:00
Johan Hovold f3e8ae657e USB: serial: ftdi_sio: simplify TIOCSSERIAL flag logic
Simplify TIOCSSERIAL flag logic somewhat.

Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-13 11:49:58 +02:00
Magnus Lynch 08f741a933 USB: serial: qcserial: expose methods for modem control
The qcserial driver fails to expose the .tiocmget and .tiocmset methods
available from usb_wwan. These methods are required by ioctl commands
dealing with the modem control signals DTR, RTS, etc.

With these methods not set ioctl calls intended to control the DTR state
will fail. For example, pppd drops and raises DTR in preparation to
dialing the modem, which handles the case of the modem already being
connected by making it hang up and return to command mode. DTR control
being unavailable will lead to a protracted failure to connect as the
modem will be stuck in a state not responsive to command.

I have tested that with this patch the described case is handled
successfully. There is an analogous method for .ioctl available from
usb_wwan (as used in option.c) but I conservatively omitted that for
lack of familiarity.

Signed-off-by: Magnus Lynch <maglyx@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-06-13 09:06:25 +02:00
Maksim Salau 4cd4475eff USB: serial: upd78f0730: make constants static
Some local constants don't change from call to call and are good
candidates to become static. This will prevent copying of these
constants to stack during runtime.

Signed-off-by: Maksim Salau <maksim.salau@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-06-01 11:07:50 +02:00
Bjørn Mork 8d7a10dd32 USB: serial: qcserial: add more Lenovo EM74xx device IDs
In their infinite wisdom, and never ending quest for end user frustration,
Lenovo has decided to use new USB device IDs for the wwan modules in
their 2017 laptops.  The actual hardware is still the Sierra Wireless
EM7455 or EM7430, depending on region.

Cc: <stable@vger.kernel.org>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-05-17 17:10:57 +02:00
Andrey Korolyov 5f63424ab7 USB: serial: ftdi_sio: add Olimex ARM-USB-TINY(H) PIDs
This patch adds support for recognition of ARM-USB-TINY(H) devices which
are almost identical to ARM-USB-OCD(H) but lacking separate barrel jack
and serial console.

By suggestion from Johan Hovold it is possible to replace
ftdi_jtag_quirk with a bit more generic construction. Since all
Olimex-ARM debuggers has exactly two ports, we could safely always use
only second port within the debugger family.

Signed-off-by: Andrey Korolyov <andrey@xdel.ru>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-05-17 10:31:20 +02:00
Johan Hovold 6aeb75e6ad USB: serial: io_ti: fix div-by-zero in set_termios
Fix a division-by-zero in set_termios when debugging is enabled and a
high-enough speed has been requested so that the divisor value becomes
zero.

Instead of just fixing the offending debug statement, cap the baud rate
at the base as a zero divisor value also appears to crash the firmware.

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org>     # 2.6.12
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-05-15 11:52:04 +02:00
Johan Hovold 26cede3436 USB: serial: mct_u232: fix big-endian baud-rate handling
Drop erroneous cpu_to_le32 when setting the baud rate, something which
corrupted the divisor on big-endian hosts.

Found using sparse:

	warning: incorrect type in argument 1 (different base types)
	    expected unsigned int [unsigned] [usertype] val
	    got restricted __le32 [usertype] <noident>

Fixes: af2ac1a091 ("USB: serial mct_usb232: move DMA buffers to heap")
Cc: stable <stable@vger.kernel.org>     # 2.6.34
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-By: Pete Zaitcev <zaitcev@yahoo.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-05-15 11:51:15 +02:00
Johan Hovold ad0ccac76d USB: serial: ir-usb: fix big-endian baud-rate debug printk
Add missing endianness conversion when printing the supported baud
rates.

Found using sparse:

	warning: restricted __le16 degrades to integer

Fixes: e0d795e4f3 ("usb: irda: cleanup on ir-usb module")
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-05-15 11:50:34 +02:00
Anthony Mallet bb246681b3 USB: serial: ftdi_sio: fix setting latency for unprivileged users
Commit 557aaa7ffa ("ft232: support the ASYNC_LOW_LATENCY
flag") enables unprivileged users to set the FTDI latency timer,
but there was a logic flaw that skipped sending the corresponding
USB control message to the device.

Specifically, the device latency timer would not be updated until next
open, something which was later also inadvertently broken by commit
c19db4c9e4 ("USB: ftdi_sio: set device latency timeout at port
probe").

A recent commit c6dce26266 ("USB: serial: ftdi_sio: fix extreme
low-latency setting") disabled the low-latency mode by default so we now
need this fix to allow unprivileged users to again enable it.

Signed-off-by: Anthony Mallet <anthony.mallet@laas.fr>
[johan: amend commit message]
Fixes: 557aaa7ffa ("ft232: support the ASYNC_LOW_LATENCY flag")
Fixes: c19db4c9e4 ("USB: ftdi_sio: set device latency timeout at port probe").
Cc: stable <stable@vger.kernel.org>     # 2.6.31
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-05-15 10:20:25 +02:00
Daniele Palmas 40dd46048c usb: serial: option: add Telit ME910 support
This patch adds support for Telit ME910 PID 0x1100.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-05-15 10:02:26 +02:00
Linus Torvalds 8f28472a73 USB patches for 4.12-rc1
Here is the big USB patchset for 4.12-rc1.
 
 Lots of good stuff here, after many many many attempts, the kernel
 finally has a working typeC interface, many thanks to the Heikki and
 Guenter and others who have taken the time to get this merged.  It
 wasn't an easy path for them at all.
 
 There's also a staging driver that uses this new api, which is why it's
 coming in through this tree.
 
 Along with that, there's the usual huge number of changes for gadget
 drivers, xhci, and other stuff.  Johan also finally refactored pretty
 much every driver that was looking at USB endpoints to do it in a common
 way, which will help prevent any "badly-formed" devices from causing
 problems in drivers.  That too wasn't a simple task.
 
 All of these have been in linux-next for a while with no reported
 issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWQvEIQ8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+yny4gCePCXxnrQdMWE+IMXf1H1hMubLkVkAn0ZWgQkq
 BspgO7ZmGb+9Fpf6YvNz
 =nwAu
 -----END PGP SIGNATURE-----

Merge tag 'usb-4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB updates from Greg KH:
 "Here is the big USB patchset for 4.12-rc1.

  Lots of good stuff here, after many many many attempts, the kernel
  finally has a working typeC interface, many thanks to Heikki and
  Guenter and others who have taken the time to get this merged. It
  wasn't an easy path for them at all.

  There's also a staging driver that uses this new api, which is why
  it's coming in through this tree.

  Along with that, there's the usual huge number of changes for gadget
  drivers, xhci, and other stuff. Johan also finally refactored pretty
  much every driver that was looking at USB endpoints to do it in a
  common way, which will help prevent any "badly-formed" devices from
  causing problems in drivers. That too wasn't a simple task.

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'usb-4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (263 commits)
  staging: typec: Fairchild FUSB302 Type-c chip driver
  staging: typec: Type-C Port Controller Interface driver (tcpci)
  staging: typec: USB Type-C Port Manager (tcpm)
  usb: host: xhci: remove #ifdef around PM functions
  usb: musb: don't mark of_dev_auxdata as initdata
  usb: misc: legousbtower: Fix buffers on stack
  USB: Revert "cdc-wdm: fix "out-of-sync" due to missing notifications"
  usb: Make sure usb/phy/of gets built-in
  USB: storage: e-mail update in drivers/usb/storage/unusual_devs.h
  usb: host: xhci: print correct command ring address
  usb: host: xhci: delete sp_dma_buffers for scratchpad
  usb: host: xhci: using correct specification chapter reference for DCBAAP
  xhci: switch to pci_alloc_irq_vectors
  usb: host: xhci-plat: set resume_quirk() for R-Car controllers
  usb: host: xhci-plat: add resume_quirk()
  usb: host: xhci-plat: enable clk in resume timing
  usb: host: plat: Enable xHCI plat runtime PM
  USB: serial: ftdi_sio: add device ID for Microsemi/Arrow SF2PLUS Dev Kit
  USB: serial: constify static arrays
  usb: fix some references for /proc/bus/usb
  ...
2017-05-04 18:03:51 -07:00
Linus Torvalds 7d6a31c394 Merge branch 'x86-debug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 debug updates from Ingo Molnar:
 "The biggest update is the addition of USB3 debug port based
  early-console.

  Greg was fine with the USB changes and with the routing of these
  patches:

    https://www.spinics.net/lists/linux-usb/msg155093.html"

* 'x86-debug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  usb/doc: Add document for USB3 debug port usage
  usb/serial: Add DBC debug device support to usb_debug
  x86/earlyprintk: Add support for earlyprintk via USB3 debug port
  usb/early: Add driver for xhci debug capability
  x86/timers: Add simple udelay calibration
2017-05-01 23:00:21 -07:00
Greg Kroah-Hartman 8ebe0e20bf USB-serial updates for v4.12-rc1
Here are the USB-serial updates for 4.12, including:
 
  - support for devices with up to 16 ports (e.g. some Moxa devices)
 
  - support for endpoint sanity checks in core, which allows for code sharing
    and avoids allocating resources for rejected interfaces
 
  - support for endpoint-port remapping, which allows some driver hacks to
    be removed as well as omninet to use the generic write implementation
 
  - removal of an obsolete tty open-race workaround which prevented a
    port from being opened immediately after having been registered
 
  - generic-driver support for interfaces with just a bulk-in endpoint
 
  - improved ftdi_sio event-char and latency-timer handling
 
  - improved ftdi_sio support for some broken BM chips
 
 Included are also various clean ups and a new ftdi_sio device id.
 
 All have been in linux-next with no reported issues.
 
 Signed-off-by: Johan Hovold <johan@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEHszNKQClByu0A+9RQQ3kT97htJUFAlj4xWkRHGpvaGFuQGtl
 cm5lbC5vcmcACgkQQQ3kT97htJX65A/+PHZaJ3roe7ue+T7NoxBd1MzrvwUiVHR7
 jtBbL5Jd/Glq5symeOM6oAnCmHszaS2Ch8YShdD5bEhT3339zNDo7X31cj07RUqS
 gw0UuEhDlvmYPAygm0omDPsHAJ9IDfYvvJ2GZk7lkHMhDbFL9j4S5ZJLqP1YFESs
 7/FT0AadaLT/lXRqW+y38SeGJJ/1tDhhyMFX8vAiD9jBWw6jCmvEGKcT8gQGFfhC
 iH7ZW/KrAzDCLRLv7g/ZdcB5FeShC++w9cDcKjq//EFZeiFujXtZMmD0EZOiavwf
 BW9hwSXZXZcDm5lLWH4QYMD/kX/wrgE6HPBnAqPe1jltq1O5ngspvfJtrvXsEJtI
 uA3MDw72EHbEVpRS5/IJVQoqjQuQuqTCZW0Ru+BNsS7duLNophcFqxZ5VVXS2LPm
 g9wS0z3PeNfKoPfqoEXCUqpHELpefAWMqDVXb6/Udf+Gv1jfcwDnKttMGGliqWMr
 cEA3Jdkq1P0kXgydA1Heb+0yHWwgiII57t0zBrNfQ5RSwGgxB9Tnj+ogljrh4l2U
 jrcyMJAWxOUFyTr+2z8RqgeuuCl5yzeTvWX3Qn3CdM/AcsjjmDqpEFW8TlTM9JBM
 kMp6QnVoyNsNtn8aXzPc2YkwWGWPGX9oclvhgsMyMSege4XnKaqejfKMl7d0XEk0
 NSD25i74wQc=
 =cSzy
 -----END PGP SIGNATURE-----

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

Johan writes:

USB-serial updates for v4.12-rc1

Here are the USB-serial updates for 4.12, including:

 - support for devices with up to 16 ports (e.g. some Moxa devices)

 - support for endpoint sanity checks in core, which allows for code sharing
   and avoids allocating resources for rejected interfaces

 - support for endpoint-port remapping, which allows some driver hacks to
   be removed as well as omninet to use the generic write implementation

 - removal of an obsolete tty open-race workaround which prevented a
   port from being opened immediately after having been registered

 - generic-driver support for interfaces with just a bulk-in endpoint

 - improved ftdi_sio event-char and latency-timer handling

 - improved ftdi_sio support for some broken BM chips

Included are also various clean ups and a new ftdi_sio device id.

All have been in linux-next with no reported issues.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-04-20 17:22:51 +02:00
Marek Vasut 31c5d1922b USB: serial: ftdi_sio: add device ID for Microsemi/Arrow SF2PLUS Dev Kit
This development kit has an FT4232 on it with a custom USB VID/PID.
The FT4232 provides four UARTs, but only two are used. The UART 0
is used by the FlashPro5 programmer and UART 2 is connected to the
SmartFusion2 CortexM3 SoC UART port.

Note that the USB VID is registered to Actel according to Linux USB
VID database, but that was acquired by Microsemi.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-04-19 09:58:50 +02:00
Johan Hovold 4f37fa549d USB: serial: constify static arrays
Declare three immutable static driver arrays as const.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-04-19 09:45:43 +02:00
Johan Hovold 185fcb3fbe USB: serial: quatech2: drop redundant tty_buffer_request_room
Drop redundant calls to tty_buffer_request_room and use the more
efficient tty_insert_flip_char when inserting single characters.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-04-10 09:42:00 +02:00
Johan Hovold 7aac5e7d20 USB: serial: iuu_phoenix: drop excessive sanity checks
The transfer buffers and URBs are allocated and initialised by USB
serial core during probe, and there's no need to check for NULL transfer
buffers in the bulk-in completion handlers.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-04-10 09:42:00 +02:00
Johan Hovold e1fdd5b262 USB: serial: drop obsolete open-race workaround
Commit a65a6f14dc ("USB: serial: fix race between probe and open")
fixed a race between probe and open, which could lead to crashes when a
not yet fully initialised port was being opened.

This race was later incidentally closed by commit 7e73eca6a7 ("TTY:
move cdev_add to tty_register_device") which moved character-device
registration from tty_register_driver to tty_register_device, which
isn't called until the port has been fully set up.

Remove the now redundant workaround which had the negative side effect
of not allowing a port to be opened immediately after user space had
been notified of a new tty device.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-31 13:14:39 +02:00
Johan Hovold bc242fc107 USB: serial: drop termios-flag debugging
Drop some unnecessary termios-flag debugging that have been faithfully
reproduced in a few old drivers, including the "clfag" typo and all.

This also addresses a compiler warning on sparc where tcflag_t is
unsigned long and would have required an explicit cast.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-29 16:14:35 +02:00
Johan Hovold d5ccfce092 USB: serial: f81534: clean up port bulk-out setup
Setup each port to use the first bulk-out endpoint in calc_num_ports so
that core allocates the corresponding port resources for us.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:14:13 +02:00
Johan Hovold 5e07240a12 USB: serial: f81534: clean up calc_num_ports
Clean up calc_num_ports with respect to handling older chips that lack
config data.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:14:13 +02:00
Johan Hovold d69f138747 USB: serial: mxuport: clean up port bulk-out setup
Setup each port to use the first bulk-out endpoint in calc_num_ports so
that core allocates the corresponding port resources for us.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:14:13 +02:00
Johan Hovold 6b0464c9d7 USB: serial: mxuport: add endpoint sanity check
Add an explicit sanity check to make sure we have the expected
endpoints. This will provide a descriptive error message in case an
expected endpoint is missing when probing.

Note that the driver already gracefully fails to probe (albeit with a
less descriptive error message) if a bulk-in endpoint is missing, and an
attempt to write to a port whose device lack a bulk-out endpoint would
fail with -ENODEV.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:14:12 +02:00
Johan Hovold bc4c2c15cb USB: serial: mxuport: register two ports for unknown devices
Print a message and register two ports for interfaces for which we do
not know how many ports there are instead of binding, allocating
resources, but not register any ports.

This provides a hint that anyone adding a dynamic device id must also
provide a reference id (driver info) from which the port count can be
retrieved, for example:

	echo <vid> <pid> 0 0x110A 0x1410 > new_id

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:14:12 +02:00
Johan Hovold ea3c6ebdcb USB: serial: visor: clean up treo endpoint hack
Use the new endpoint-remap functionality to configure the ports for
treo devices instead of poking around in the port structures after the
ports have been setup.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:14:11 +02:00
Johan Hovold da2befa6d5 USB: serial: visor: clean up clie_5 endpoint hack
Use the new endpoint-remap functionality to configure the ports for
clie_5 devices.

Note that the same bulk-out endpoint is being used for both ports.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:14:11 +02:00
Johan Hovold a5b669f4c6 USB: serial: visor: drop redundant calc_num_ports callback
Drop the redundant calc_num_ports callback from the clie_5 type, for
which the callback always returns zero and hence falls back to the type
num_ports value (2).

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:14:11 +02:00
Johan Hovold c0dcf242d2 USB: serial: ti_usb_3410_5052: always require a bulk-out endpoint
These devices always require at least one bulk-out endpoint so let core
verify that.

This avoids attempting to send bulk data to the default pipe when
downloading firmware in boot mode.

Note that further endpoints are still needed when not in boot mode.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:14:10 +02:00
Johan Hovold d27444152c USB: serial: omninet: use generic write implementation
Now that the endpoint-port mapping has been properly set up during
probe, we can switch to using the more efficient generic write
implementation.

Note that this currently means that chars_in_buffer now overcounts
slightly as we always write a full endpoint-sized packet.

Also add a copyright entry.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:13:55 +02:00
Johan Hovold 2dc1071b34 USB: serial: omninet: clean up port setup
These devices use the second bulk-out endpoint for writing. Instead of
using the resources of the second port structure setup by core, use the
new endpoint-remap functionality to simply ignore the first bulk-out
endpoint. This specifically avoids allocating resources for the unused
endpoint.

Note that the disconnect callback was always redundant as all URBs would
have been killed by USB core on disconnect.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:00:12 +02:00
Johan Hovold 9525402023 USB: serial: mos7840: clean up endpoint sanity check
Clean up the endpoint sanity check by letting core verify the single
interrupt endpoint, and verifying the bulk endpoints in calc_num_ports
after having determined the number of ports.

Note that the static type num_ports field was neither correct or used
(since calc_num_ports never returns zero).

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:00:12 +02:00
Johan Hovold 6a1eaf19f5 USB: serial: mos7720: always require an interrupt endpoint
This driver have treated the interrupt endpoint as optional despite it
always being present (according to the datasheet). Let's consider it
mandatory instead.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:00:12 +02:00
Johan Hovold d760557d38 USB: serial: mos7720: clean up mcs7715 port setup
Clean up the mcs7715 port setup by using the new endpoint-remap
functionality provided by core. Instead of poking around in internal
port-structure fields, simply swap the endpoint descriptors of the two
ports in calc_num_ports before the port structures are even allocated.

Note that we still need to override the default interrupt completion
handler.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:00:11 +02:00
Johan Hovold 772b2c5d6c USB: serial: io_ti: drop redundant read-urb check
Drop the redundant read-urb check from open. The presence of a bulk-in
endpoint is now verified during probe and core has allocated the
corresponding resources.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:00:11 +02:00
Johan Hovold 9c8299b43e USB: serial: io_ti: verify interrupt endpoint at probe
Verify that the required interrupt endpoint is present at probe rather
than at open to avoid allocating resources for an unusable device.

Note that the endpoint is only required when in download mode.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:00:11 +02:00
Johan Hovold 8d9c4d9ebf USB: serial: io_ti: always require a bulk-out endpoint
These devices always require at least one bulk-out endpoint so let core
verify that.

This avoids attempting to send bulk data to the default pipe when
downloading firmware in boot mode.

Note that further endpoints are still needed when not in boot mode.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:00:10 +02:00
Johan Hovold 49f4ff2d74 USB: serial: io_ti: use calc_num_endpoints to verify endpoints
Use the calc_num_ports rather than attach callback to verify that the
required endpoints are present when in download mode.

This avoids allocating port resources for interfaces that won't be bound.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:00:10 +02:00
Johan Hovold 204cc473bc USB: serial: ipaq: always register a single port
Use the calc_num_ports callback to ignore unused endpoints.

The driver binds to any interface with at least one bulk-in and one
bulk-out endpoint, but some devices can have three or more endpoints of
which only either the first or second pair of endpoints is needed.

This avoids allocating resources for unused endpoints, and specifically
a port is no longer registered for the unused first endpoint pair when
there are more than three endpoints.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:00:09 +02:00
Johan Hovold 03b72aecad USB: serial: ipaq: use calc_num_endpoints to verify endpoints
Use the calc_num_ports rather than attach callback to determine which
interface to bind to in order to avoid allocating port-resources for
interfaces that won't be bound.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:00:09 +02:00
Johan Hovold 2f16621b9a USB: serial: f81534: abort probe on early errors
We can now abort probe early after an error in calc_num_ports by
returning an errno instead of attempting to continue probing but not
register any ports.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:00:08 +02:00
Johan Hovold cac4cea513 USB: serial: f81534: use calc_num_endpoints to verify endpoints
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present and moving the max-packet check to
calc_num_ports.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:00:08 +02:00
Johan Hovold 5f391979c9 USB: serial: aircable: use calc_num_endpoints to verify endpoints
Use the calc_num_ports rather than probe callback to determine which
interface to bind to.

This allows us to remove some duplicate code.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:00:08 +02:00
Johan Hovold 9d717271d6 USB: serial: pl2303: clean up legacy endpoint hack
Implement the "horrible endpoint hack" for some legacy devices as a
quirk and clean up the code somewhat.

Note that the bulk-endpoint check can be removed as core will already
have verified this.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 11:00:07 +02:00
Johan Hovold 9fda620a5f USB: serial: move pl2303 hack out of usb-serial core
Some pl2303 devices require the use of the interrupt endpoint of an
unrelated interface. This has so far been dealt with in usb-serial core,
but can now be moved to a driver calc_num_ports callback.

Note that we relax the endpoint requirements checked by core and instead
verify that we have an interrupt-in endpoint in calc_num_ports for all
devices so that the hack can first be applied.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 10:59:01 +02:00
Johan Hovold 6538808c56 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>
2017-03-28 10:54:39 +02:00
Johan Hovold a794499b26 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>
2017-03-28 10:54:39 +02:00
Johan Hovold 415d7b3a54 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>
2017-03-28 10:54:39 +02:00
Johan Hovold 07814246dd USB: serial: allow subdrivers to modify port-endpoint mapping
Allow subdrivers to modify the port-endpoint mapping by passing the
endpoint descriptors to calc_num_ports.

The callback can now also be used to verify that the required endpoints
exists and abort probing otherwise.

This will allow us to get rid of a few hacks in subdrivers that are
already modifying the port-endpoint mapping (or aborting probe due to
missing endpoints), but only after the port structures have been setup.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-28 10:54:39 +02:00
Lu Baolu 57fb47279a usb/serial: Add DBC debug device support to usb_debug
This patch adds DBC debug device support to the usb_debug driver.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Johan Hovold <johan@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mathias Nyman <mathias.nyman@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-usb@vger.kernel.org
Link: http://lkml.kernel.org/r/1490083293-3792-5-git-send-email-baolu.lu@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-03-21 12:30:17 +01:00
Bjørn Mork 436ecf5519 USB: serial: qcserial: add Dell DW5811e
This is a Dell branded Sierra Wireless EM7455.

Cc: <stable@vger.kernel.org>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-18 09:57:14 +01:00
Johan Hovold 2ac8fc51dd USB: serial: whiteheat: simplify endpoint check
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present.

Note that the driver registers four ports but uses five bulk-endpoint
pairs.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-16 10:33:47 +01:00
Johan Hovold e2cd017f1b USB: serial: symbolserial: simplify endpoint check
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-16 10:33:47 +01:00
Johan Hovold bdd1544360 USB: serial: spcp8x5: simplify endpoint check
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-16 10:33:46 +01:00
Johan Hovold 590298b223 USB: serial: pl2303: simplify endpoint check
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-16 10:33:46 +01:00
Johan Hovold 32814c87f4 USB: serial: oti6858: simplify endpoint check
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-16 10:33:46 +01:00
Johan Hovold 5e5b6444d0 USB: serial: opticon: simplify endpoint check
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-16 10:33:45 +01:00
Johan Hovold 8ee1592d12 USB: serial: omninet: simplify endpoint check
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present.

Note that the driver uses the second bulk-out endpoint for writing.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-16 10:33:45 +01:00
Johan Hovold 206ff831be USB: serial: mos7720: simplify endpoint check
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present.

Note that the driver expects two bulk-endpoint pairs also for mcs7715
devices for which only one serial port is registered.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-16 10:33:44 +01:00
Johan Hovold 35194572b4 USB: serial: kobil_sct: simplify endpoint check
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-16 10:33:44 +01:00
Johan Hovold b714d5dc06 USB: serial: keyspan_pda: simplify endpoint check
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-16 10:33:44 +01:00
Johan Hovold fb527736eb USB: serial: iuu_phoenix: simplify endpoint check
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present.

Signed-off-by: Johan Hovold <johan@kernel.org>
2017-03-16 10:33:43 +01:00