net/usb/r815x: replace USB buffer from stack to DMA-able
Some USB buffers use stack which may not be DMA-able. Use the buffers from kmalloc to replace those one. Signed-off-by: Hayes Wang <hayeswang@realtek.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
06693f305e
commit
b2f47377e8
1 changed files with 27 additions and 17 deletions
|
@ -24,34 +24,43 @@
|
||||||
|
|
||||||
static int pla_read_word(struct usb_device *udev, u16 index)
|
static int pla_read_word(struct usb_device *udev, u16 index)
|
||||||
{
|
{
|
||||||
int data, ret;
|
int ret;
|
||||||
u8 shift = index & 2;
|
u8 shift = index & 2;
|
||||||
__le32 ocp_data;
|
__le32 *tmp;
|
||||||
|
|
||||||
|
tmp = kmalloc(sizeof(*tmp), GFP_KERNEL);
|
||||||
|
if (!tmp)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
index &= ~3;
|
index &= ~3;
|
||||||
|
|
||||||
ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
|
ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
|
||||||
RTL815x_REQ_GET_REGS, RTL815x_REQT_READ,
|
RTL815x_REQ_GET_REGS, RTL815x_REQT_READ,
|
||||||
index, MCU_TYPE_PLA, &ocp_data, sizeof(ocp_data),
|
index, MCU_TYPE_PLA, tmp, sizeof(*tmp), 500);
|
||||||
500);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
goto out2;
|
||||||
|
|
||||||
|
ret = __le32_to_cpu(*tmp);
|
||||||
|
ret >>= (shift * 8);
|
||||||
|
ret &= 0xffff;
|
||||||
|
|
||||||
|
out2:
|
||||||
|
kfree(tmp);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
data = __le32_to_cpu(ocp_data);
|
|
||||||
data >>= (shift * 8);
|
|
||||||
data &= 0xffff;
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pla_write_word(struct usb_device *udev, u16 index, u32 data)
|
static int pla_write_word(struct usb_device *udev, u16 index, u32 data)
|
||||||
{
|
{
|
||||||
__le32 ocp_data;
|
__le32 *tmp;
|
||||||
u32 mask = 0xffff;
|
u32 mask = 0xffff;
|
||||||
u16 byen = BYTE_EN_WORD;
|
u16 byen = BYTE_EN_WORD;
|
||||||
u8 shift = index & 2;
|
u8 shift = index & 2;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
tmp = kmalloc(sizeof(*tmp), GFP_KERNEL);
|
||||||
|
if (!tmp)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
data &= mask;
|
data &= mask;
|
||||||
|
|
||||||
if (shift) {
|
if (shift) {
|
||||||
|
@ -63,19 +72,20 @@ static int pla_write_word(struct usb_device *udev, u16 index, u32 data)
|
||||||
|
|
||||||
ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
|
ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
|
||||||
RTL815x_REQ_GET_REGS, RTL815x_REQT_READ,
|
RTL815x_REQ_GET_REGS, RTL815x_REQT_READ,
|
||||||
index, MCU_TYPE_PLA, &ocp_data, sizeof(ocp_data),
|
index, MCU_TYPE_PLA, tmp, sizeof(*tmp), 500);
|
||||||
500);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
goto out3;
|
||||||
|
|
||||||
data |= __le32_to_cpu(ocp_data) & ~mask;
|
data |= __le32_to_cpu(*tmp) & ~mask;
|
||||||
ocp_data = __cpu_to_le32(data);
|
*tmp = __cpu_to_le32(data);
|
||||||
|
|
||||||
ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
|
ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
|
||||||
RTL815x_REQ_SET_REGS, RTL815x_REQT_WRITE,
|
RTL815x_REQ_SET_REGS, RTL815x_REQT_WRITE,
|
||||||
index, MCU_TYPE_PLA | byen, &ocp_data,
|
index, MCU_TYPE_PLA | byen, tmp, sizeof(*tmp),
|
||||||
sizeof(ocp_data), 500);
|
500);
|
||||||
|
|
||||||
|
out3:
|
||||||
|
kfree(tmp);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue