linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Johan Hovold <johan@kernel.org>
Cc: linux-usb@vger.kernel.org
Subject: [PATCH 03/10] USB: serial: io_ti: add read-port-command helper
Date: Mon, 12 Apr 2021 11:47:31 +0200	[thread overview]
Message-ID: <20210412094738.944-4-johan@kernel.org> (raw)
In-Reply-To: <20210412094738.944-1-johan@kernel.org>

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.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/serial/io_ti.c | 15 +++++++++------
 1 file 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);
-- 
2.26.3


  parent reply	other threads:[~2021-04-12  9:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12  9:47 [PATCH 00/10] USB: serial: clean up the ti drivers Johan Hovold
2021-04-12  9:47 ` [PATCH 01/10] USB: serial: io_ti: clean up vendor-request helpers Johan Hovold
2021-04-12  9:47 ` [PATCH 02/10] USB: serial: io_ti: add send-port-command helper Johan Hovold
2021-04-12  9:47 ` Johan Hovold [this message]
2021-04-12  9:47 ` [PATCH 04/10] USB: serial: io_ti: use kernel types consistently Johan Hovold
2021-04-12  9:47 ` [PATCH 05/10] USB: serial: io_ti: drop unnecessary packed attributes Johan Hovold
2021-04-12  9:47 ` [PATCH 06/10] USB: serial: ti_usb_3410_5052: " Johan Hovold
2021-04-12  9:47 ` [PATCH 07/10] USB: serial: ti_usb_3410_5052: clean up vendor-request helpers Johan Hovold
2021-04-12  9:47 ` [PATCH 08/10] USB: serial: ti_usb_3410_5052: add port-command helpers Johan Hovold
2021-04-12  9:47 ` [PATCH 09/10] USB: serial: ti_usb_3410_5052: use kernel types consistently Johan Hovold
2021-04-12  9:47 ` [PATCH 10/10] USB: serial: ti_usb_3410_5052: clean up termios CSIZE handling Johan Hovold
2021-04-12 10:59 ` [PATCH 00/10] USB: serial: clean up the ti drivers Greg KH
2021-04-13 16:31   ` Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210412094738.944-4-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).