aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2021-04-12 11:47:31 +0200
committerJohan Hovold <johan@kernel.org>2021-04-13 18:23:29 +0200
commit13c613393cee59a6f6fd4627f7003606392690d1 (patch)
tree2aa40c6b487f854afc9e8fdb169b023c91880baa /drivers/usb/serial
parentUSB: serial: io_ti: add send-port-command helper (diff)
downloadlinux-dev-13c613393cee59a6f6fd4627f7003606392690d1.tar.xz
linux-dev-13c613393cee59a6f6fd4627f7003606392690d1.zip
USB: serial: io_ti: add read-port-command helper
Add a read-port-command helper analogous to the send-port-command helper to take care of the UART module id instead of open coding. Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r--drivers/usb/serial/io_ti.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index f65a712078ab..480a73aff78f 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -284,6 +284,14 @@ static int ti_vsend_sync(struct usb_device *dev, u8 request, u16 value,
return 0;
}
+static int read_port_cmd(struct usb_serial_port *port, u8 command, u16 value,
+ void *data, int size)
+{
+ return ti_vread_sync(port->serial->dev, command, value,
+ UMPM_UART1_PORT + port->port_number,
+ data, size);
+}
+
static int send_port_cmd(struct usb_serial_port *port, u8 command, u16 value,
void *data, int size)
{
@@ -1826,7 +1834,6 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
struct edgeport_serial *edge_serial;
struct usb_device *dev;
struct urb *urb;
- int port_number;
int status;
u16 open_settings;
u8 transaction_timeout;
@@ -1834,8 +1841,6 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
if (edge_port == NULL)
return -ENODEV;
- port_number = port->port_number;
-
dev = port->serial->dev;
/* turn off loopback */
@@ -1892,9 +1897,7 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
}
/* Read Initial MSR */
- status = ti_vread_sync(dev, UMPC_READ_MSR, 0,
- (__u16)(UMPM_UART1_PORT + port_number),
- &edge_port->shadow_msr, 1);
+ status = read_port_cmd(port, UMPC_READ_MSR, 0, &edge_port->shadow_msr, 1);
if (status) {
dev_err(&port->dev, "%s - cannot send read MSR command, %d\n",
__func__, status);