USB: serial: keyspan_pda: use usb_control_msg_recv()
Use the wrapper function usb_control_msg_recv() that accepts stack variables and remove dma buffers from callers of usb_control_msg(). Signed-off-by: Himadri Pandya <himadrispandya@gmail.com> Link: https://lore.kernel.org/r/20210801203122.3515-6-himadrispandya@gmail.com [ johan: simplify write-room error handling further ] Signed-off-by: Johan Hovold <johan@kernel.org>
This commit is contained in:
parent
a738859264
commit
c9129371cb
@ -77,36 +77,27 @@ static int keyspan_pda_get_write_room(struct keyspan_pda_private *priv)
|
|||||||
{
|
{
|
||||||
struct usb_serial_port *port = priv->port;
|
struct usb_serial_port *port = priv->port;
|
||||||
struct usb_serial *serial = port->serial;
|
struct usb_serial *serial = port->serial;
|
||||||
u8 *room;
|
u8 room;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
room = kmalloc(1, GFP_KERNEL);
|
rc = usb_control_msg_recv(serial->dev,
|
||||||
if (!room)
|
0,
|
||||||
return -ENOMEM;
|
6, /* write_room */
|
||||||
|
USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_IN,
|
||||||
rc = usb_control_msg(serial->dev,
|
0, /* value: 0 means "remaining room" */
|
||||||
usb_rcvctrlpipe(serial->dev, 0),
|
0, /* index */
|
||||||
6, /* write_room */
|
&room,
|
||||||
USB_TYPE_VENDOR | USB_RECIP_INTERFACE
|
1,
|
||||||
| USB_DIR_IN,
|
2000,
|
||||||
0, /* value: 0 means "remaining room" */
|
GFP_KERNEL);
|
||||||
0, /* index */
|
if (rc) {
|
||||||
room,
|
|
||||||
1,
|
|
||||||
2000);
|
|
||||||
if (rc != 1) {
|
|
||||||
if (rc >= 0)
|
|
||||||
rc = -EIO;
|
|
||||||
dev_dbg(&port->dev, "roomquery failed: %d\n", rc);
|
dev_dbg(&port->dev, "roomquery failed: %d\n", rc);
|
||||||
goto out_free;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_dbg(&port->dev, "roomquery says %d\n", *room);
|
dev_dbg(&port->dev, "roomquery says %d\n", room);
|
||||||
rc = *room;
|
|
||||||
out_free:
|
|
||||||
kfree(room);
|
|
||||||
|
|
||||||
return rc;
|
return room;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void keyspan_pda_request_unthrottle(struct work_struct *work)
|
static void keyspan_pda_request_unthrottle(struct work_struct *work)
|
||||||
@ -381,22 +372,20 @@ static int keyspan_pda_get_modem_info(struct usb_serial *serial,
|
|||||||
unsigned char *value)
|
unsigned char *value)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
u8 *data;
|
u8 data;
|
||||||
|
|
||||||
data = kmalloc(1, GFP_KERNEL);
|
rc = usb_control_msg_recv(serial->dev, 0,
|
||||||
if (!data)
|
3, /* get pins */
|
||||||
return -ENOMEM;
|
USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_IN,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
&data,
|
||||||
|
1,
|
||||||
|
2000,
|
||||||
|
GFP_KERNEL);
|
||||||
|
if (rc == 0)
|
||||||
|
*value = data;
|
||||||
|
|
||||||
rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
|
|
||||||
3, /* get pins */
|
|
||||||
USB_TYPE_VENDOR|USB_RECIP_INTERFACE|USB_DIR_IN,
|
|
||||||
0, 0, data, 1, 2000);
|
|
||||||
if (rc == 1)
|
|
||||||
*value = *data;
|
|
||||||
else if (rc >= 0)
|
|
||||||
rc = -EIO;
|
|
||||||
|
|
||||||
kfree(data);
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user