All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Johan Hovold <johan@kernel.org>
Cc: Himadri Pandya <himadrispandya@gmail.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] USB: serial: kl5kusb105: clean up line-status handling
Date: Tue, 21 Sep 2021 15:30:07 +0200	[thread overview]
Message-ID: <20210921133009.13739-2-johan@kernel.org> (raw)
In-Reply-To: <20210921133009.13739-1-johan@kernel.org>

Clean up the line-status handling by dropping redundant initialisations
and returning early on errors.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/serial/kl5kusb105.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index 72d3920c9c48..7681671ddb79 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -172,8 +172,6 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
 	u8 status_buf[KLSI_STATUSBUF_LEN];
 	__u16 status;
 
-	status_buf[0] = 0xff;
-	status_buf[1] = 0xff;
 	rc = usb_control_msg_recv(port->serial->dev, 0,
 				  KL5KUSB105A_SIO_POLL,
 				  USB_TYPE_VENDOR | USB_DIR_IN,
@@ -184,16 +182,17 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
 				  GFP_KERNEL);
 	if (rc) {
 		dev_err(&port->dev, "reading line status failed: %d\n", rc);
-	} else {
-		status = get_unaligned_le16(status_buf);
+		return rc;
+	}
 
-		dev_dbg(&port->dev, "read status %02x %02x\n",
-			status_buf[0], status_buf[1]);
+	status = get_unaligned_le16(status_buf);
 
-		*line_state_p = klsi_105_status2linestate(status);
-	}
+	dev_dbg(&port->dev, "read status %02x %02x\n",
+		status_buf[0], status_buf[1]);
 
-	return rc;
+	*line_state_p = klsi_105_status2linestate(status);
+
+	return 0;
 }
 
 
-- 
2.32.0


  reply	other threads:[~2021-09-21 13:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-21 13:30 [PATCH 0/3] USB: serial: kl5kusb105: clean up line-status handling Johan Hovold
2021-09-21 13:30 ` Johan Hovold [this message]
2021-09-21 13:30 ` [PATCH 2/3] USB: serial: kl5kusb105: simplify " Johan Hovold
2021-09-21 13:30 ` [PATCH 3/3] USB: serial: kl5kusb105: drop line-status helper Johan Hovold
2021-09-21 14:08 ` [PATCH 0/3] USB: serial: kl5kusb105: clean up line-status handling Greg KH

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=20210921133009.13739-2-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=himadrispandya@gmail.com \
    --cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.