From 13c613393cee59a6f6fd4627f7003606392690d1 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Mon, 12 Apr 2021 11:47:31 +0200 Subject: 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 Signed-off-by: Johan Hovold --- drivers/usb/serial/io_ti.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'drivers/usb') 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); -- cgit v1.2.3