aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/brcm80211/brcmfmac
diff options
context:
space:
mode:
authorHante Meuleman <meuleman@broadcom.com>2013-12-12 05:59:00 -0500
committerJohn W. Linville <linville@tuxdriver.com>2013-12-18 15:22:50 -0500
commit8141083c48192b63a39b77adffd9a8e0dcfab034 (patch)
treef84f4ab6c319b71b2d0c3b5ddd574de18135ab61 /drivers/net/wireless/brcm80211/brcmfmac
parenta7cdd821e37fa5809ce1fb3793ab0e0e7e6e9d75 (diff)
brcmfmac: Move common BCDC code in single function.
The BCDC functions query_dcmd and set_dcmd both create a msgbuf to be sent to dongle this code is very similar and for optimisation best put in a function. Reviewed-by: Arend Van Spriel <arend@broadcom.com> Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com> Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com> Signed-off-by: Hante Meuleman <meuleman@broadcom.com> Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/brcm80211/brcmfmac')
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/bcdc.c68
1 files changed, 25 insertions, 43 deletions
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcdc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcdc.c
index 06848e426f9a..ee861427117e 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/bcdc.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/bcdc.c
@@ -101,35 +101,41 @@ struct brcmf_proto_bcdc_header {
101 * plus any space that might be needed 101 * plus any space that might be needed
102 * for bus alignment padding. 102 * for bus alignment padding.
103 */ 103 */
104#define ROUND_UP_MARGIN 2048 /* Biggest bus block size possible for
105 * round off at the end of buffer
106 * Currently is SDIO
107 */
108
109struct brcmf_bcdc { 104struct brcmf_bcdc {
110 u16 reqid; 105 u16 reqid;
111 u8 bus_header[BUS_HEADER_LEN]; 106 u8 bus_header[BUS_HEADER_LEN];
112 struct brcmf_proto_bcdc_dcmd msg; 107 struct brcmf_proto_bcdc_dcmd msg;
113 unsigned char buf[BRCMF_DCMD_MAXLEN + ROUND_UP_MARGIN]; 108 unsigned char buf[BRCMF_DCMD_MAXLEN];
114}; 109};
115 110
116static int brcmf_proto_bcdc_msg(struct brcmf_pub *drvr) 111
112static int
113brcmf_proto_bcdc_msg(struct brcmf_pub *drvr, int ifidx, uint cmd, void *buf,
114 uint len, bool set)
117{ 115{
118 struct brcmf_bcdc *bcdc = (struct brcmf_bcdc *)drvr->proto->pd; 116 struct brcmf_bcdc *bcdc = (struct brcmf_bcdc *)drvr->proto->pd;
119 int len = le32_to_cpu(bcdc->msg.len) + 117 struct brcmf_proto_bcdc_dcmd *msg = &bcdc->msg;
120 sizeof(struct brcmf_proto_bcdc_dcmd); 118 u32 flags;
121 119
122 brcmf_dbg(BCDC, "Enter\n"); 120 brcmf_dbg(BCDC, "Enter\n");
123 121
124 /* NOTE : bcdc->msg.len holds the desired length of the buffer to be 122 memset(msg, 0, sizeof(struct brcmf_proto_bcdc_dcmd));
125 * returned. Only up to BCDC_MAX_MSG_SIZE of this buffer area 123
126 * is actually sent to the dongle 124 msg->cmd = cpu_to_le32(cmd);
127 */ 125 msg->len = cpu_to_le32(len);
128 if (len > BCDC_MAX_MSG_SIZE) 126 flags = (++bcdc->reqid << BCDC_DCMD_ID_SHIFT);
129 len = BCDC_MAX_MSG_SIZE; 127 if (set)
128 flags |= BCDC_DCMD_SET;
129 flags = (flags & ~BCDC_DCMD_IF_MASK) |
130 (ifidx << BCDC_DCMD_IF_SHIFT);
131 msg->flags = cpu_to_le32(flags);
132
133 if (buf)
134 memcpy(bcdc->buf, buf, len);
130 135
131 /* Send request */ 136 /* Send request */
132 return brcmf_bus_txctl(drvr->bus_if, (unsigned char *)&bcdc->msg, len); 137 return brcmf_bus_txctl(drvr->bus_if, (unsigned char *)&bcdc->msg,
138 len + sizeof(struct brcmf_proto_bcdc_dcmd));
133} 139}
134 140
135static int brcmf_proto_bcdc_cmplt(struct brcmf_pub *drvr, u32 id, u32 len) 141static int brcmf_proto_bcdc_cmplt(struct brcmf_pub *drvr, u32 id, u32 len)
@@ -161,19 +167,7 @@ brcmf_proto_bcdc_query_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd,
161 167
162 brcmf_dbg(BCDC, "Enter, cmd %d len %d\n", cmd, len); 168 brcmf_dbg(BCDC, "Enter, cmd %d len %d\n", cmd, len);
163 169
164 memset(msg, 0, sizeof(struct brcmf_proto_bcdc_dcmd)); 170 ret = brcmf_proto_bcdc_msg(drvr, ifidx, cmd, buf, len, false);
165
166 msg->cmd = cpu_to_le32(cmd);
167 msg->len = cpu_to_le32(len);
168 flags = (++bcdc->reqid << BCDC_DCMD_ID_SHIFT);
169 flags = (flags & ~BCDC_DCMD_IF_MASK) |
170 (ifidx << BCDC_DCMD_IF_SHIFT);
171 msg->flags = cpu_to_le32(flags);
172
173 if (buf)
174 memcpy(bcdc->buf, buf, len);
175
176 ret = brcmf_proto_bcdc_msg(drvr);
177 if (ret < 0) { 171 if (ret < 0) {
178 brcmf_err("brcmf_proto_bcdc_msg failed w/status %d\n", 172 brcmf_err("brcmf_proto_bcdc_msg failed w/status %d\n",
179 ret); 173 ret);
@@ -227,19 +221,7 @@ brcmf_proto_bcdc_set_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd,
227 221
228 brcmf_dbg(BCDC, "Enter, cmd %d len %d\n", cmd, len); 222 brcmf_dbg(BCDC, "Enter, cmd %d len %d\n", cmd, len);
229 223
230 memset(msg, 0, sizeof(struct brcmf_proto_bcdc_dcmd)); 224 ret = brcmf_proto_bcdc_msg(drvr, ifidx, cmd, buf, len, true);
231
232 msg->cmd = cpu_to_le32(cmd);
233 msg->len = cpu_to_le32(len);
234 flags = (++bcdc->reqid << BCDC_DCMD_ID_SHIFT) | BCDC_DCMD_SET;
235 flags = (flags & ~BCDC_DCMD_IF_MASK) |
236 (ifidx << BCDC_DCMD_IF_SHIFT);
237 msg->flags = cpu_to_le32(flags);
238
239 if (buf)
240 memcpy(bcdc->buf, buf, len);
241
242 ret = brcmf_proto_bcdc_msg(drvr);
243 if (ret < 0) 225 if (ret < 0)
244 goto done; 226 goto done;
245 227
@@ -369,7 +351,7 @@ int brcmf_proto_bcdc_attach(struct brcmf_pub *drvr)
369 351
370 drvr->hdrlen += BCDC_HEADER_LEN + BRCMF_PROT_FW_SIGNAL_MAX_TXBYTES; 352 drvr->hdrlen += BCDC_HEADER_LEN + BRCMF_PROT_FW_SIGNAL_MAX_TXBYTES;
371 drvr->bus_if->maxctl = BRCMF_DCMD_MAXLEN + 353 drvr->bus_if->maxctl = BRCMF_DCMD_MAXLEN +
372 sizeof(struct brcmf_proto_bcdc_dcmd) + ROUND_UP_MARGIN; 354 sizeof(struct brcmf_proto_bcdc_dcmd);
373 return 0; 355 return 0;
374 356
375fail: 357fail: