diff options
author | Alwin Beukers <alwin@broadcom.com> | 2011-10-12 14:51:31 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-10-14 14:48:19 -0400 |
commit | 447606514450655885c5369782d7baa2478916a7 (patch) | |
tree | ee2fb529d989a3935d92dca45edc354d91cec0a3 /drivers/net | |
parent | 53a2277d2ad411b440d2f102ced7bebef42c2fd7 (diff) |
brcm80211: moved function brcmu_format_flags
Moved the brcmu_format_flags function and brcmu_bit_desc structure
into smac. Names were adjusted accordingly.
Reported-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Roland Vossen <rvossen@broadcom.com>
Reviewed-by: Arend van Spriel <arend@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')
-rw-r--r-- | drivers/net/wireless/brcm80211/brcmsmac/main.c | 66 | ||||
-rw-r--r-- | drivers/net/wireless/brcm80211/brcmutil/utils.c | 55 | ||||
-rw-r--r-- | drivers/net/wireless/brcm80211/include/brcmu_utils.h | 8 |
3 files changed, 64 insertions, 65 deletions
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index cce6228c0c03..510e9bb52287 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c | |||
@@ -325,6 +325,12 @@ static u16 frametype(u32 rspec, u8 mimoframe) | |||
325 | */ | 325 | */ |
326 | #define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1) | 326 | #define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1) |
327 | 327 | ||
328 | /* brcmu_format_flags() bit description structure */ | ||
329 | struct brcms_c_bit_desc { | ||
330 | u32 bit; | ||
331 | const char *name; | ||
332 | }; | ||
333 | |||
328 | /* | 334 | /* |
329 | * The following table lists the buffer memory allocated to xmt fifos in HW. | 335 | * The following table lists the buffer memory allocated to xmt fifos in HW. |
330 | * the size is in units of 256bytes(one block), total size is HW dependent | 336 | * the size is in units of 256bytes(one block), total size is HW dependent |
@@ -6152,6 +6158,62 @@ void brcms_c_print_txdesc(struct d11txh *txh) | |||
6152 | #endif /* defined(BCMDBG) */ | 6158 | #endif /* defined(BCMDBG) */ |
6153 | 6159 | ||
6154 | #if defined(BCMDBG) | 6160 | #if defined(BCMDBG) |
6161 | int | ||
6162 | brcms_c_format_flags(const struct brcms_c_bit_desc *bd, u32 flags, char *buf, | ||
6163 | int len) | ||
6164 | { | ||
6165 | int i; | ||
6166 | char *p = buf; | ||
6167 | char hexstr[16]; | ||
6168 | int slen = 0, nlen = 0; | ||
6169 | u32 bit; | ||
6170 | const char *name; | ||
6171 | |||
6172 | if (len < 2 || !buf) | ||
6173 | return 0; | ||
6174 | |||
6175 | buf[0] = '\0'; | ||
6176 | |||
6177 | for (i = 0; flags != 0; i++) { | ||
6178 | bit = bd[i].bit; | ||
6179 | name = bd[i].name; | ||
6180 | if (bit == 0 && flags != 0) { | ||
6181 | /* print any unnamed bits */ | ||
6182 | snprintf(hexstr, 16, "0x%X", flags); | ||
6183 | name = hexstr; | ||
6184 | flags = 0; /* exit loop */ | ||
6185 | } else if ((flags & bit) == 0) | ||
6186 | continue; | ||
6187 | flags &= ~bit; | ||
6188 | nlen = strlen(name); | ||
6189 | slen += nlen; | ||
6190 | /* count btwn flag space */ | ||
6191 | if (flags != 0) | ||
6192 | slen += 1; | ||
6193 | /* need NULL char as well */ | ||
6194 | if (len <= slen) | ||
6195 | break; | ||
6196 | /* copy NULL char but don't count it */ | ||
6197 | strncpy(p, name, nlen + 1); | ||
6198 | p += nlen; | ||
6199 | /* copy btwn flag space and NULL char */ | ||
6200 | if (flags != 0) | ||
6201 | p += snprintf(p, 2, " "); | ||
6202 | len -= slen; | ||
6203 | } | ||
6204 | |||
6205 | /* indicate the str was too short */ | ||
6206 | if (flags != 0) { | ||
6207 | if (len < 2) | ||
6208 | p -= 2 - len; /* overwrite last char */ | ||
6209 | p += snprintf(p, 2, ">"); | ||
6210 | } | ||
6211 | |||
6212 | return (int)(p - buf); | ||
6213 | } | ||
6214 | #endif /* defined(BCMDBG) */ | ||
6215 | |||
6216 | #if defined(BCMDBG) | ||
6155 | void brcms_c_print_rxh(struct d11rxhdr *rxh) | 6217 | void brcms_c_print_rxh(struct d11rxhdr *rxh) |
6156 | { | 6218 | { |
6157 | u16 len = rxh->RxFrameSize; | 6219 | u16 len = rxh->RxFrameSize; |
@@ -6163,7 +6225,7 @@ void brcms_c_print_rxh(struct d11rxhdr *rxh) | |||
6163 | u16 macstatus2 = rxh->RxStatus2; | 6225 | u16 macstatus2 = rxh->RxStatus2; |
6164 | char flagstr[64]; | 6226 | char flagstr[64]; |
6165 | char lenbuf[20]; | 6227 | char lenbuf[20]; |
6166 | static const struct brcmu_bit_desc macstat_flags[] = { | 6228 | static const struct brcms_c_bit_desc macstat_flags[] = { |
6167 | {RXS_FCSERR, "FCSErr"}, | 6229 | {RXS_FCSERR, "FCSErr"}, |
6168 | {RXS_RESPFRAMETX, "Reply"}, | 6230 | {RXS_RESPFRAMETX, "Reply"}, |
6169 | {RXS_PBPRES, "PADDING"}, | 6231 | {RXS_PBPRES, "PADDING"}, |
@@ -6177,7 +6239,7 @@ void brcms_c_print_rxh(struct d11rxhdr *rxh) | |||
6177 | print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, rxh, | 6239 | print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, rxh, |
6178 | sizeof(struct d11rxhdr)); | 6240 | sizeof(struct d11rxhdr)); |
6179 | 6241 | ||
6180 | brcmu_format_flags(macstat_flags, macstatus1, flagstr, 64); | 6242 | brcms_c_format_flags(macstat_flags, macstatus1, flagstr, 64); |
6181 | 6243 | ||
6182 | snprintf(lenbuf, sizeof(lenbuf), "0x%x", len); | 6244 | snprintf(lenbuf, sizeof(lenbuf), "0x%x", len); |
6183 | 6245 | ||
diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c index d3ab7f5f0ef9..4ca85a40be5c 100644 --- a/drivers/net/wireless/brcm80211/brcmutil/utils.c +++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c | |||
@@ -365,61 +365,6 @@ EXPORT_SYMBOL(brcmu_prpkt); | |||
365 | #endif /* defined(BCMDBG) */ | 365 | #endif /* defined(BCMDBG) */ |
366 | 366 | ||
367 | #if defined(BCMDBG) | 367 | #if defined(BCMDBG) |
368 | int | ||
369 | brcmu_format_flags(const struct brcmu_bit_desc *bd, u32 flags, char *buf, | ||
370 | int len) | ||
371 | { | ||
372 | int i; | ||
373 | char *p = buf; | ||
374 | char hexstr[16]; | ||
375 | int slen = 0, nlen = 0; | ||
376 | u32 bit; | ||
377 | const char *name; | ||
378 | |||
379 | if (len < 2 || !buf) | ||
380 | return 0; | ||
381 | |||
382 | buf[0] = '\0'; | ||
383 | |||
384 | for (i = 0; flags != 0; i++) { | ||
385 | bit = bd[i].bit; | ||
386 | name = bd[i].name; | ||
387 | if (bit == 0 && flags != 0) { | ||
388 | /* print any unnamed bits */ | ||
389 | snprintf(hexstr, 16, "0x%X", flags); | ||
390 | name = hexstr; | ||
391 | flags = 0; /* exit loop */ | ||
392 | } else if ((flags & bit) == 0) | ||
393 | continue; | ||
394 | flags &= ~bit; | ||
395 | nlen = strlen(name); | ||
396 | slen += nlen; | ||
397 | /* count btwn flag space */ | ||
398 | if (flags != 0) | ||
399 | slen += 1; | ||
400 | /* need NULL char as well */ | ||
401 | if (len <= slen) | ||
402 | break; | ||
403 | /* copy NULL char but don't count it */ | ||
404 | strncpy(p, name, nlen + 1); | ||
405 | p += nlen; | ||
406 | /* copy btwn flag space and NULL char */ | ||
407 | if (flags != 0) | ||
408 | p += snprintf(p, 2, " "); | ||
409 | len -= slen; | ||
410 | } | ||
411 | |||
412 | /* indicate the str was too short */ | ||
413 | if (flags != 0) { | ||
414 | if (len < 2) | ||
415 | p -= 2 - len; /* overwrite last char */ | ||
416 | p += snprintf(p, 2, ">"); | ||
417 | } | ||
418 | |||
419 | return (int)(p - buf); | ||
420 | } | ||
421 | EXPORT_SYMBOL(brcmu_format_flags); | ||
422 | |||
423 | /* | 368 | /* |
424 | * print bytes formatted as hex to a string. return the resulting | 369 | * print bytes formatted as hex to a string. return the resulting |
425 | * string length | 370 | * string length |
diff --git a/drivers/net/wireless/brcm80211/include/brcmu_utils.h b/drivers/net/wireless/brcm80211/include/brcmu_utils.h index f8664b20ccc3..7d0f46e0eb95 100644 --- a/drivers/net/wireless/brcm80211/include/brcmu_utils.h +++ b/drivers/net/wireless/brcm80211/include/brcmu_utils.h | |||
@@ -186,17 +186,9 @@ extern void brcmu_prpkt(const char *msg, struct sk_buff *p0); | |||
186 | #define brcmu_prpkt(a, b) | 186 | #define brcmu_prpkt(a, b) |
187 | #endif /* BCMDBG */ | 187 | #endif /* BCMDBG */ |
188 | 188 | ||
189 | /* brcmu_format_flags() bit description structure */ | ||
190 | struct brcmu_bit_desc { | ||
191 | u32 bit; | ||
192 | const char *name; | ||
193 | }; | ||
194 | |||
195 | /* externs */ | 189 | /* externs */ |
196 | /* format/print */ | 190 | /* format/print */ |
197 | #if defined(BCMDBG) | 191 | #if defined(BCMDBG) |
198 | extern int brcmu_format_flags(const struct brcmu_bit_desc *bd, u32 flags, | ||
199 | char *buf, int len); | ||
200 | extern int brcmu_format_hex(char *str, const void *bytes, int len); | 192 | extern int brcmu_format_hex(char *str, const void *bytes, int len); |
201 | #endif | 193 | #endif |
202 | 194 | ||