Skip to content

Commit

Permalink
net: rtl8150: Use the new usb control message API.
Browse files Browse the repository at this point in the history
The old usb_control_msg() let the caller handle the error and also did not
account for partial reads.  Since these are now considered harmful, move the
driver over to usb_control_msg_recv/send() calls.

Signed-off-by: Petko Manolov <petko.manolov@konsulko.com>
Acked-by: David S. Miller <davem@davemloft.net>
Link: https://lore.kernel.org/r/20200927124909.16380-3-petko.manolov@konsulko.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Petko Manolov authored and Greg Kroah-Hartman committed Oct 2, 2020
1 parent 5789051 commit b2a0f27
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions drivers/net/usb/rtl8150.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,36 +152,16 @@ static const char driver_name [] = "rtl8150";
*/
static int get_registers(rtl8150_t * dev, u16 indx, u16 size, void *data)
{
void *buf;
int ret;

buf = kmalloc(size, GFP_NOIO);
if (!buf)
return -ENOMEM;

ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
RTL8150_REQ_GET_REGS, RTL8150_REQT_READ,
indx, 0, buf, size, 500);
if (ret > 0 && ret <= size)
memcpy(data, buf, ret);
kfree(buf);
return ret;
return usb_control_msg_recv(dev->udev, 0, RTL8150_REQ_GET_REGS,
RTL8150_REQT_READ, indx, 0, data, size,
1000, GFP_NOIO);
}

static int set_registers(rtl8150_t * dev, u16 indx, u16 size, const void *data)
{
void *buf;
int ret;

buf = kmemdup(data, size, GFP_NOIO);
if (!buf)
return -ENOMEM;

ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
RTL8150_REQ_SET_REGS, RTL8150_REQT_WRITE,
indx, 0, buf, size, 500);
kfree(buf);
return ret;
return usb_control_msg_send(dev->udev, 0, RTL8150_REQ_SET_REGS,
RTL8150_REQT_WRITE, indx, 0, data, size,
1000, GFP_NOIO);
}

static void async_set_reg_cb(struct urb *urb)
Expand Down

0 comments on commit b2a0f27

Please sign in to comment.