Commit ed833be6 authored by Karun Eagalapati's avatar Karun Eagalapati Committed by Kalle Valo

rsi: USB tx headroom cleanup

USB headroom is added while submitting the data to URB as per
firmware's requirement. This logic is moved to rsi_usb_card_write() so
that caller need not worry about it.
Signed-off-by: default avatarKarun Eagalapati <karun256@gmail.com>
Signed-off-by: default avatarAmitkumar Karwar <amit.karwar@redpinesignals.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent ea0676c4
...@@ -29,19 +29,24 @@ ...@@ -29,19 +29,24 @@
* Return: status: 0 on success, a negative error code on failure. * Return: status: 0 on success, a negative error code on failure.
*/ */
static int rsi_usb_card_write(struct rsi_hw *adapter, static int rsi_usb_card_write(struct rsi_hw *adapter,
void *buf, u8 *buf,
u16 len, u16 len,
u8 endpoint) u8 endpoint)
{ {
struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev; struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;
int status; int status;
s32 transfer; u8 *seg = dev->tx_buffer;
int transfer;
int ep = dev->bulkout_endpoint_addr[endpoint - 1];
memset(seg, 0, len + RSI_USB_TX_HEAD_ROOM);
memcpy(seg + RSI_USB_TX_HEAD_ROOM, buf, len);
len += RSI_USB_TX_HEAD_ROOM;
transfer = len;
status = usb_bulk_msg(dev->usbdev, status = usb_bulk_msg(dev->usbdev,
usb_sndbulkpipe(dev->usbdev, usb_sndbulkpipe(dev->usbdev, ep),
dev->bulkout_endpoint_addr[endpoint - 1]), (void *)seg,
buf, (int)len,
len,
&transfer, &transfer,
HZ * 5); HZ * 5);
...@@ -68,23 +73,19 @@ static int rsi_write_multiple(struct rsi_hw *adapter, ...@@ -68,23 +73,19 @@ static int rsi_write_multiple(struct rsi_hw *adapter,
u8 *data, u8 *data,
u32 count) u32 count)
{ {
struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev; struct rsi_91x_usbdev *dev =
u8 *seg = dev->tx_buffer; (struct rsi_91x_usbdev *)adapter->rsi_dev;
if (dev->write_fail) if (!adapter)
return 0; return -ENODEV;
if (endpoint == MGMT_EP) { if (endpoint == 0)
memset(seg, 0, RSI_USB_TX_HEAD_ROOM); return -EINVAL;
memcpy(seg + RSI_USB_TX_HEAD_ROOM, data, count);
} else { if (dev->write_fail)
seg = ((u8 *)data - RSI_USB_TX_HEAD_ROOM); return -ENETDOWN;
}
return rsi_usb_card_write(adapter, return rsi_usb_card_write(adapter, data, count, endpoint);
seg,
count + RSI_USB_TX_HEAD_ROOM,
endpoint);
} }
/** /**
......
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