summaryrefslogtreecommitdiff
path: root/drivers/usb/serial/xr_serial.c
AgeCommit message (Collapse)Author
2021-03-09USB: serial: xr: fix NULL-deref on disconnectJohan Hovold
Claiming the sibling control interface is a bit more involved and specifically requires adding support to USB-serial core for managing either interface being unbound first, something which could otherwise lead to a NULL-pointer dereference. Similarly, additional infrastructure is also needed to handle suspend properly. Since the driver currently isn't actually using the control interface, we can defer this for now by simply not claiming the control interface. Fixes: c2d405aa86b4 ("USB: serial: add MaxLinear/Exar USB to Serial driver") Reported-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Tested-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Manivannan Sadhasivam <mani@kernel.org> Signed-off-by: Johan Hovold <johan@kernel.org>
2021-01-26USB: serial: xr: fix B0 handlingJohan Hovold
Fix up B0 handling which should leave the baud rate unchanged and specifically not report back a non-B0 rate when B0 is requested; must temporarily disable hardware flow control so that RTS can be deasserted; and should reassert DTR/RTS when moving from B0. Fixes: c2d405aa86b4 ("USB: serial: add MaxLinear/Exar USB to Serial driver") Signed-off-by: Johan Hovold <johan@kernel.org>
2021-01-26USB: serial: xr: fix pin configurationJohan Hovold
Make sure that the modem pins are set up correctly when opening the port to avoid leaving, for example, DTR and RTS configured as inputs, which is the device default. This is specifically needed to be able to control DTR and RTS when hardware flow control is disabled. Fixes: c2d405aa86b4 ("USB: serial: add MaxLinear/Exar USB to Serial driver") Signed-off-by: Johan Hovold <johan@kernel.org>
2021-01-26USB: serial: xr: fix gpio-mode handlingJohan Hovold
Fix the gpio-mode handling so that all the pins are under driver control (i.e. in gpio mode) when hardware flow control is disabled. This is specifically needed to be able to control RTS. Fixes: c2d405aa86b4 ("USB: serial: add MaxLinear/Exar USB to Serial driver") Signed-off-by: Johan Hovold <johan@kernel.org>
2021-01-26USB: serial: xr: simplify line-speed logicJohan Hovold
Simplify the changed-line-speed conditional expression. Signed-off-by: Johan Hovold <johan@kernel.org>
2021-01-26USB: serial: xr: clean up line-settings handlingJohan Hovold
Shift the line-setting values when defining them rather than in set_termios() for consistency and improved readability. Signed-off-by: Johan Hovold <johan@kernel.org>
2021-01-26USB: serial: xr: document vendor-request recipientJohan Hovold
Add the missing device-recipient define to the vendor control requests for completeness. Signed-off-by: Johan Hovold <johan@kernel.org>
2021-01-26USB: serial: xr: use termios flag helpersJohan Hovold
Use the termios flag helpers consistently, including for CRTSCTS. Signed-off-by: Johan Hovold <johan@kernel.org>
2021-01-26USB: serial: xr: use subsystem usb_device at probeJohan Hovold
Use the subsystem struct usb_device pointer at probe instead of deriving it from the interface pointer. Signed-off-by: Johan Hovold <johan@kernel.org>
2021-01-26USB: serial: xr: fix interface leak at disconnectJohan Hovold
Make sure to release the control interface at disconnect so that the driver can be unbound without leaking resources (and later rebound). Fixes: c2d405aa86b4 ("USB: serial: add MaxLinear/Exar USB to Serial driver") Signed-off-by: Johan Hovold <johan@kernel.org>
2021-01-26USB: serial: xr: fix NULL-deref at probeJohan Hovold
Make sure that the probed device has an interface 0 to avoid dereferencing a NULL pointer in case of a malicious device or during USB-descriptor fuzzing. Fixes: c2d405aa86b4 ("USB: serial: add MaxLinear/Exar USB to Serial driver") Signed-off-by: Johan Hovold <johan@kernel.org>
2021-01-21USB: serial: add MaxLinear/Exar USB to Serial driverManivannan Sadhasivam
Add support for MaxLinear/Exar USB to Serial converters. This driver only supports XR21V141X series but it can be extended to other series from Exar as well in future. This driver is inspired from the initial one submitted by Patong Yang: https://lore.kernel.org/r/20180404070634.nhspvmxcjwfgjkcv@advantechmxl-desktop While the initial driver was a custom tty USB driver exposing whole new serial interface ttyXRUSBn, this version is completely based on USB serial core thus exposing the interfaces as ttyUSBn. This will avoid the overhead of exposing a new USB serial interface which the userspace tools are unaware of. The Exar XR21V141X can be used in either ACM mode using the cdc-acm driver or in "custom driver" mode in which further features such as hardware and software flow control, GPIO control and in-band line-status reporting are available. In ACM mode the device always enables RTS/CTS flow control, something which could prevent transmission in case the CTS input isn't wired up corrently. A follow-on patch will prevent cdc_acm from binding whenever this driver is enabled. Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Link: https://lore.kernel.org/r/20201122170822.21715-2-mani@kernel.org [ johan: fix some style nits, group related functions, drop unused callbacks, and amend commit message; a few remaining non-trivial issues will be fixed separately ] Signed-off-by: Johan Hovold <johan@kernel.org>