Commit 2b2e41e3 authored by Ming Lei's avatar Ming Lei Committed by David S. Miller

usbnet: smsc75xx: apply introduced usb command APIs

Acked-by: default avatarOliver Neukum <oneukum@suse.de>
Signed-off-by: default avatarMing Lei <ming.lei@canonical.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f7385ec9
...@@ -85,26 +85,21 @@ MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction"); ...@@ -85,26 +85,21 @@ MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
static int __must_check smsc75xx_read_reg(struct usbnet *dev, u32 index, static int __must_check smsc75xx_read_reg(struct usbnet *dev, u32 index,
u32 *data) u32 *data)
{ {
u32 *buf = kmalloc(4, GFP_KERNEL); u32 buf;
int ret; int ret;
BUG_ON(!dev); BUG_ON(!dev);
if (!buf) ret = usbnet_read_cmd(dev, USB_VENDOR_REQUEST_READ_REGISTER,
return -ENOMEM; USB_DIR_IN | USB_TYPE_VENDOR |
USB_RECIP_DEVICE,
ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), 0, index, &buf, 4);
USB_VENDOR_REQUEST_READ_REGISTER,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
00, index, buf, 4, USB_CTRL_GET_TIMEOUT);
if (unlikely(ret < 0)) if (unlikely(ret < 0))
netdev_warn(dev->net, netdev_warn(dev->net,
"Failed to read reg index 0x%08x: %d", index, ret); "Failed to read reg index 0x%08x: %d", index, ret);
le32_to_cpus(buf); le32_to_cpus(&buf);
*data = *buf; *data = buf;
kfree(buf);
return ret; return ret;
} }
...@@ -112,28 +107,22 @@ static int __must_check smsc75xx_read_reg(struct usbnet *dev, u32 index, ...@@ -112,28 +107,22 @@ static int __must_check smsc75xx_read_reg(struct usbnet *dev, u32 index,
static int __must_check smsc75xx_write_reg(struct usbnet *dev, u32 index, static int __must_check smsc75xx_write_reg(struct usbnet *dev, u32 index,
u32 data) u32 data)
{ {
u32 *buf = kmalloc(4, GFP_KERNEL); u32 buf;
int ret; int ret;
BUG_ON(!dev); BUG_ON(!dev);
if (!buf) buf = data;
return -ENOMEM; cpu_to_le32s(&buf);
*buf = data;
cpu_to_le32s(buf);
ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
USB_VENDOR_REQUEST_WRITE_REGISTER,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
00, index, buf, 4, USB_CTRL_SET_TIMEOUT);
ret = usbnet_write_cmd(dev, USB_VENDOR_REQUEST_WRITE_REGISTER,
USB_DIR_OUT | USB_TYPE_VENDOR |
USB_RECIP_DEVICE,
0, index, &buf, 4);
if (unlikely(ret < 0)) if (unlikely(ret < 0))
netdev_warn(dev->net, netdev_warn(dev->net,
"Failed to write reg index 0x%08x: %d", index, ret); "Failed to write reg index 0x%08x: %d", index, ret);
kfree(buf);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment