[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201104064703.15123-6-himadrispandya@gmail.com>
Date: Wed, 4 Nov 2020 12:16:53 +0530
From: Himadri Pandya <himadrispandya@...il.com>
To: johan@...nel.org, gregkh@...uxfoundation.org,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: linux-kernel-mentees@...ts.linuxfoundation.org,
Himadri Pandya <himadrispandya@...il.com>
Subject: [PATCH 05/15] usb: serial: cypress_m8: use usb_control_msg_recv() and usb_control_msg_send()
The new usb_control_msg_recv() and usb_control_msg_send() nicely wraps
usb_control_msg() with proper error check. Hence use the wrappers
instead of calling usb_control_msg() directly.
Signed-off-by: Himadri Pandya <himadrispandya@...il.com>
---
drivers/usb/serial/cypress_m8.c | 38 +++++++++++++++++----------------
1 file changed, 20 insertions(+), 18 deletions(-)
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index cc028601c388..4d66cab8eece 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -341,20 +341,21 @@ static int cypress_serial_control(struct tty_struct *tty,
feature_buffer[4]);
do {
- retval = usb_control_msg(port->serial->dev,
- usb_sndctrlpipe(port->serial->dev, 0),
- HID_REQ_SET_REPORT,
- USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
- 0x0300, 0, feature_buffer,
- feature_len, 500);
+ retval = usb_control_msg_send(port->serial->dev, 0,
+ HID_REQ_SET_REPORT,
+ USB_DIR_OUT |
+ USB_RECIP_INTERFACE |
+ USB_TYPE_CLASS, 0x0300,
+ 0, feature_buffer,
+ feature_len, 500,
+ GFP_KERNEL);
if (tries++ >= 3)
break;
- } while (retval != feature_len &&
- retval != -ENODEV);
+ } while (retval != -ENODEV);
- if (retval != feature_len) {
+ if (retval) {
dev_err(dev, "%s - failed sending serial line settings - %d\n",
__func__, retval);
cypress_set_dead(port);
@@ -379,19 +380,20 @@ static int cypress_serial_control(struct tty_struct *tty,
}
dev_dbg(dev, "%s - retrieving serial line settings\n", __func__);
do {
- retval = usb_control_msg(port->serial->dev,
- usb_rcvctrlpipe(port->serial->dev, 0),
- HID_REQ_GET_REPORT,
- USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
- 0x0300, 0, feature_buffer,
- feature_len, 500);
+ retval = usb_control_msg_recv(port->serial->dev, 0,
+ HID_REQ_GET_REPORT,
+ USB_DIR_IN |
+ USB_RECIP_INTERFACE |
+ USB_TYPE_CLASS, 0x0300,
+ 0, feature_buffer,
+ feature_len, 500,
+ GFP_KERNEL);
if (tries++ >= 3)
break;
- } while (retval != feature_len
- && retval != -ENODEV);
+ } while (retval != -ENODEV);
- if (retval != feature_len) {
+ if (retval) {
dev_err(dev, "%s - failed to retrieve serial line settings - %d\n",
__func__, retval);
cypress_set_dead(port);
--
2.17.1
Powered by blists - more mailing lists