lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 21 Sep 2021 15:30:08 +0200
From:   Johan Hovold <johan@...nel.org>
To:     Johan Hovold <johan@...nel.org>
Cc:     Himadri Pandya <himadrispandya@...il.com>,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 2/3] USB: serial: kl5kusb105: simplify line-status handling

Now that the driver is using usb_control_msg_recv(), the line status
handling can be simplified further by reading directly into the status
variable and doing the endian conversion in place.

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

diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index 7681671ddb79..99dffbdd3142 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -163,21 +163,18 @@ static unsigned long klsi_105_status2linestate(const __u16 status)
  * Read line control via vendor command and return result through
  * *line_state_p
  */
-/* It seems that the status buffer has always only 2 bytes length */
-#define KLSI_STATUSBUF_LEN	2
 static int klsi_105_get_line_state(struct usb_serial_port *port,
 				   unsigned long *line_state_p)
 {
+	u16 status;
 	int rc;
-	u8 status_buf[KLSI_STATUSBUF_LEN];
-	__u16 status;
 
 	rc = usb_control_msg_recv(port->serial->dev, 0,
 				  KL5KUSB105A_SIO_POLL,
 				  USB_TYPE_VENDOR | USB_DIR_IN,
 				  0, /* value */
 				  0, /* index */
-				  status_buf, KLSI_STATUSBUF_LEN,
+				  &status, sizeof(status),
 				  10000,
 				  GFP_KERNEL);
 	if (rc) {
@@ -185,10 +182,9 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
 		return rc;
 	}
 
-	status = get_unaligned_le16(status_buf);
+	le16_to_cpus(&status);
 
-	dev_dbg(&port->dev, "read status %02x %02x\n",
-		status_buf[0], status_buf[1]);
+	dev_dbg(&port->dev, "read status %04x\n", status);
 
 	*line_state_p = klsi_105_status2linestate(status);
 
-- 
2.32.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ