Commit 44760651 authored by Alwin Beukers's avatar Alwin Beukers Committed by John W. Linville

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: default avatarJohannes Berg <johannes@sipsolutions.net>
Reviewed-by: default avatarRoland Vossen <rvossen@broadcom.com>
Reviewed-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 53a2277d
...@@ -325,6 +325,12 @@ static u16 frametype(u32 rspec, u8 mimoframe) ...@@ -325,6 +325,12 @@ static u16 frametype(u32 rspec, u8 mimoframe)
*/ */
#define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1) #define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1)
/* brcmu_format_flags() bit description structure */
struct brcms_c_bit_desc {
u32 bit;
const char *name;
};
/* /*
* The following table lists the buffer memory allocated to xmt fifos in HW. * The following table lists the buffer memory allocated to xmt fifos in HW.
* the size is in units of 256bytes(one block), total size is HW dependent * the size is in units of 256bytes(one block), total size is HW dependent
...@@ -6151,6 +6157,62 @@ void brcms_c_print_txdesc(struct d11txh *txh) ...@@ -6151,6 +6157,62 @@ void brcms_c_print_txdesc(struct d11txh *txh)
} }
#endif /* defined(BCMDBG) */ #endif /* defined(BCMDBG) */
#if defined(BCMDBG)
int
brcms_c_format_flags(const struct brcms_c_bit_desc *bd, u32 flags, char *buf,
int len)
{
int i;
char *p = buf;
char hexstr[16];
int slen = 0, nlen = 0;
u32 bit;
const char *name;
if (len < 2 || !buf)
return 0;
buf[0] = '\0';
for (i = 0; flags != 0; i++) {
bit = bd[i].bit;
name = bd[i].name;
if (bit == 0 && flags != 0) {
/* print any unnamed bits */
snprintf(hexstr, 16, "0x%X", flags);
name = hexstr;
flags = 0; /* exit loop */
} else if ((flags & bit) == 0)
continue;
flags &= ~bit;
nlen = strlen(name);
slen += nlen;
/* count btwn flag space */
if (flags != 0)
slen += 1;
/* need NULL char as well */
if (len <= slen)
break;
/* copy NULL char but don't count it */
strncpy(p, name, nlen + 1);
p += nlen;
/* copy btwn flag space and NULL char */
if (flags != 0)
p += snprintf(p, 2, " ");
len -= slen;
}
/* indicate the str was too short */
if (flags != 0) {
if (len < 2)
p -= 2 - len; /* overwrite last char */
p += snprintf(p, 2, ">");
}
return (int)(p - buf);
}
#endif /* defined(BCMDBG) */
#if defined(BCMDBG) #if defined(BCMDBG)
void brcms_c_print_rxh(struct d11rxhdr *rxh) void brcms_c_print_rxh(struct d11rxhdr *rxh)
{ {
...@@ -6163,7 +6225,7 @@ void brcms_c_print_rxh(struct d11rxhdr *rxh) ...@@ -6163,7 +6225,7 @@ void brcms_c_print_rxh(struct d11rxhdr *rxh)
u16 macstatus2 = rxh->RxStatus2; u16 macstatus2 = rxh->RxStatus2;
char flagstr[64]; char flagstr[64];
char lenbuf[20]; char lenbuf[20];
static const struct brcmu_bit_desc macstat_flags[] = { static const struct brcms_c_bit_desc macstat_flags[] = {
{RXS_FCSERR, "FCSErr"}, {RXS_FCSERR, "FCSErr"},
{RXS_RESPFRAMETX, "Reply"}, {RXS_RESPFRAMETX, "Reply"},
{RXS_PBPRES, "PADDING"}, {RXS_PBPRES, "PADDING"},
...@@ -6177,7 +6239,7 @@ void brcms_c_print_rxh(struct d11rxhdr *rxh) ...@@ -6177,7 +6239,7 @@ void brcms_c_print_rxh(struct d11rxhdr *rxh)
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, rxh, print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, rxh,
sizeof(struct d11rxhdr)); sizeof(struct d11rxhdr));
brcmu_format_flags(macstat_flags, macstatus1, flagstr, 64); brcms_c_format_flags(macstat_flags, macstatus1, flagstr, 64);
snprintf(lenbuf, sizeof(lenbuf), "0x%x", len); snprintf(lenbuf, sizeof(lenbuf), "0x%x", len);
......
...@@ -365,61 +365,6 @@ EXPORT_SYMBOL(brcmu_prpkt); ...@@ -365,61 +365,6 @@ EXPORT_SYMBOL(brcmu_prpkt);
#endif /* defined(BCMDBG) */ #endif /* defined(BCMDBG) */
#if defined(BCMDBG) #if defined(BCMDBG)
int
brcmu_format_flags(const struct brcmu_bit_desc *bd, u32 flags, char *buf,
int len)
{
int i;
char *p = buf;
char hexstr[16];
int slen = 0, nlen = 0;
u32 bit;
const char *name;
if (len < 2 || !buf)
return 0;
buf[0] = '\0';
for (i = 0; flags != 0; i++) {
bit = bd[i].bit;
name = bd[i].name;
if (bit == 0 && flags != 0) {
/* print any unnamed bits */
snprintf(hexstr, 16, "0x%X", flags);
name = hexstr;
flags = 0; /* exit loop */
} else if ((flags & bit) == 0)
continue;
flags &= ~bit;
nlen = strlen(name);
slen += nlen;
/* count btwn flag space */
if (flags != 0)
slen += 1;
/* need NULL char as well */
if (len <= slen)
break;
/* copy NULL char but don't count it */
strncpy(p, name, nlen + 1);
p += nlen;
/* copy btwn flag space and NULL char */
if (flags != 0)
p += snprintf(p, 2, " ");
len -= slen;
}
/* indicate the str was too short */
if (flags != 0) {
if (len < 2)
p -= 2 - len; /* overwrite last char */
p += snprintf(p, 2, ">");
}
return (int)(p - buf);
}
EXPORT_SYMBOL(brcmu_format_flags);
/* /*
* print bytes formatted as hex to a string. return the resulting * print bytes formatted as hex to a string. return the resulting
* string length * string length
......
...@@ -186,17 +186,9 @@ extern void brcmu_prpkt(const char *msg, struct sk_buff *p0); ...@@ -186,17 +186,9 @@ extern void brcmu_prpkt(const char *msg, struct sk_buff *p0);
#define brcmu_prpkt(a, b) #define brcmu_prpkt(a, b)
#endif /* BCMDBG */ #endif /* BCMDBG */
/* brcmu_format_flags() bit description structure */
struct brcmu_bit_desc {
u32 bit;
const char *name;
};
/* externs */ /* externs */
/* format/print */ /* format/print */
#if defined(BCMDBG) #if defined(BCMDBG)
extern int brcmu_format_flags(const struct brcmu_bit_desc *bd, u32 flags,
char *buf, int len);
extern int brcmu_format_hex(char *str, const void *bytes, int len); extern int brcmu_format_hex(char *str, const void *bytes, int len);
#endif #endif
......
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