Skip to content

Commit 2e0b78d

Browse files
committed
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. Reviewed-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Johan Hovold <[email protected]>
1 parent a692d0e commit 2e0b78d

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

drivers/usb/serial/kl5kusb105.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,32 +163,28 @@ static unsigned long klsi_105_status2linestate(const __u16 status)
163163
* Read line control via vendor command and return result through
164164
* *line_state_p
165165
*/
166-
/* It seems that the status buffer has always only 2 bytes length */
167-
#define KLSI_STATUSBUF_LEN 2
168166
static int klsi_105_get_line_state(struct usb_serial_port *port,
169167
unsigned long *line_state_p)
170168
{
169+
u16 status;
171170
int rc;
172-
u8 status_buf[KLSI_STATUSBUF_LEN];
173-
__u16 status;
174171

175172
rc = usb_control_msg_recv(port->serial->dev, 0,
176173
KL5KUSB105A_SIO_POLL,
177174
USB_TYPE_VENDOR | USB_DIR_IN,
178175
0, /* value */
179176
0, /* index */
180-
status_buf, KLSI_STATUSBUF_LEN,
177+
&status, sizeof(status),
181178
10000,
182179
GFP_KERNEL);
183180
if (rc) {
184181
dev_err(&port->dev, "reading line status failed: %d\n", rc);
185182
return rc;
186183
}
187184

188-
status = get_unaligned_le16(status_buf);
185+
le16_to_cpus(&status);
189186

190-
dev_dbg(&port->dev, "read status %02x %02x\n",
191-
status_buf[0], status_buf[1]);
187+
dev_dbg(&port->dev, "read status %04x\n", status);
192188

193189
*line_state_p = klsi_105_status2linestate(status);
194190

0 commit comments

Comments
 (0)