aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhayeswang <hayeswang@realtek.com>2013-07-31 05:21:22 -0400
committerDavid S. Miller <davem@davemloft.net>2013-07-31 17:49:12 -0400
commitb2f47377e871a5f3cc5bd0dd58d3ea1fbc58948d (patch)
tree0d6e3c3fb8be2f5d65f89fce7b7c70bdedf61cf9
parent06693f305e60202d2795a10bee7fb7da23bc2acc (diff)
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>
-rw-r--r--drivers/net/usb/r815x.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/drivers/net/usb/r815x.c b/drivers/net/usb/r815x.c
index 852392269718..e9b99bad02a7 100644
--- a/drivers/net/usb/r815x.c
+++ b/drivers/net/usb/r815x.c
@@ -24,34 +24,43 @@
24 24
25static int pla_read_word(struct usb_device *udev, u16 index) 25static int pla_read_word(struct usb_device *udev, u16 index)
26{ 26{
27 int data, ret; 27 int ret;
28 u8 shift = index & 2; 28 u8 shift = index & 2;
29 __le32 ocp_data; 29 __le32 *tmp;
30
31 tmp = kmalloc(sizeof(*tmp), GFP_KERNEL);
32 if (!tmp)
33 return -ENOMEM;
30 34
31 index &= ~3; 35 index &= ~3;
32 36
33 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 37 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
34 RTL815x_REQ_GET_REGS, RTL815x_REQT_READ, 38 RTL815x_REQ_GET_REGS, RTL815x_REQT_READ,
35 index, MCU_TYPE_PLA, &ocp_data, sizeof(ocp_data), 39 index, MCU_TYPE_PLA, tmp, sizeof(*tmp), 500);
36 500);
37 if (ret < 0) 40 if (ret < 0)
38 return ret; 41 goto out2;
39 42
40 data = __le32_to_cpu(ocp_data); 43 ret = __le32_to_cpu(*tmp);
41 data >>= (shift * 8); 44 ret >>= (shift * 8);
42 data &= 0xffff; 45 ret &= 0xffff;
43 46
44 return data; 47out2:
48 kfree(tmp);
49 return ret;
45} 50}
46 51
47static int pla_write_word(struct usb_device *udev, u16 index, u32 data) 52static int pla_write_word(struct usb_device *udev, u16 index, u32 data)
48{ 53{
49 __le32 ocp_data; 54 __le32 *tmp;
50 u32 mask = 0xffff; 55 u32 mask = 0xffff;
51 u16 byen = BYTE_EN_WORD; 56 u16 byen = BYTE_EN_WORD;
52 u8 shift = index & 2; 57 u8 shift = index & 2;
53 int ret; 58 int ret;
54 59
60 tmp = kmalloc(sizeof(*tmp), GFP_KERNEL);
61 if (!tmp)
62 return -ENOMEM;
63
55 data &= mask; 64 data &= mask;
56 65
57 if (shift) { 66 if (shift) {
@@ -63,19 +72,20 @@ static int pla_write_word(struct usb_device *udev, u16 index, u32 data)
63 72
64 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 73 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
65 RTL815x_REQ_GET_REGS, RTL815x_REQT_READ, 74 RTL815x_REQ_GET_REGS, RTL815x_REQT_READ,
66 index, MCU_TYPE_PLA, &ocp_data, sizeof(ocp_data), 75 index, MCU_TYPE_PLA, tmp, sizeof(*tmp), 500);
67 500);
68 if (ret < 0) 76 if (ret < 0)
69 return ret; 77 goto out3;
70 78
71 data |= __le32_to_cpu(ocp_data) & ~mask; 79 data |= __le32_to_cpu(*tmp) & ~mask;
72 ocp_data = __cpu_to_le32(data); 80 *tmp = __cpu_to_le32(data);
73 81
74 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 82 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
75 RTL815x_REQ_SET_REGS, RTL815x_REQT_WRITE, 83 RTL815x_REQ_SET_REGS, RTL815x_REQT_WRITE,
76 index, MCU_TYPE_PLA | byen, &ocp_data, 84 index, MCU_TYPE_PLA | byen, tmp, sizeof(*tmp),
77 sizeof(ocp_data), 500); 85 500);
78 86
87out3:
88 kfree(tmp);
79 return ret; 89 return ret;
80} 90}
81 91