Commit 34227316 authored by Arend van Spriel's avatar Arend van Spriel Committed by Greg Kroah-Hartman

staging: brcm80211: use print_hex_dump_bytes kernel function

The drivers had own implementation to dump buffer contents using
printk. This has been replaced by kernel function.

Cc: devel@linuxdriverproject.org
Reviewed-by: default avatarHenry Ptasinski <henryp@broadcom.com>
Reviewed-by: default avatarRoland Vossen <rvossen@broadcom.com>
Reviewed-by: default avatarBrett Rudley <brudley@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent de91ed29
...@@ -15,9 +15,11 @@ ...@@ -15,9 +15,11 @@
*/ */
#include <linux/types.h> #include <linux/types.h>
#include <linux/kernel.h>
#include <linux/printk.h>
#include <linux/pci_ids.h> #include <linux/pci_ids.h>
#include <bcmdefs.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <bcmdefs.h>
#include <bcmsdh.h> #include <bcmsdh.h>
#ifdef BCMEMBEDIMAGE #ifdef BCMEMBEDIMAGE
...@@ -1003,9 +1005,12 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan, ...@@ -1003,9 +1005,12 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan,
if (DHD_BYTES_ON() && if (DHD_BYTES_ON() &&
(((DHD_CTL_ON() && (chan == SDPCM_CONTROL_CHANNEL)) || (((DHD_CTL_ON() && (chan == SDPCM_CONTROL_CHANNEL)) ||
(DHD_DATA_ON() && (chan != SDPCM_CONTROL_CHANNEL))))) { (DHD_DATA_ON() && (chan != SDPCM_CONTROL_CHANNEL))))) {
bcm_prhex("Tx Frame", frame, len); printk(KERN_DEBUG "Tx Frame:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, frame, len);
} else if (DHD_HDRS_ON()) { } else if (DHD_HDRS_ON()) {
bcm_prhex("TxHdr", frame, min_t(u16, len, 16)); printk(KERN_DEBUG "TxHdr:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
frame, min_t(u16, len, 16));
} }
#endif #endif
...@@ -1333,10 +1338,15 @@ int dhd_bus_txctl(struct dhd_bus *bus, unsigned char *msg, uint msglen) ...@@ -1333,10 +1338,15 @@ int dhd_bus_txctl(struct dhd_bus *bus, unsigned char *msg, uint msglen)
if (ret == -1) { if (ret == -1) {
#ifdef DHD_DEBUG #ifdef DHD_DEBUG
if (DHD_BYTES_ON() && DHD_CTL_ON()) if (DHD_BYTES_ON() && DHD_CTL_ON()) {
bcm_prhex("Tx Frame", frame, len); printk(KERN_DEBUG "Tx Frame:\n");
else if (DHD_HDRS_ON()) print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
bcm_prhex("TxHdr", frame, min_t(u16, len, 16)); frame, len);
} else if (DHD_HDRS_ON()) {
printk(KERN_DEBUG "TxHdr:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
frame, min_t(u16, len, 16));
}
#endif #endif
do { do {
...@@ -3117,8 +3127,10 @@ dhdsdio_read_control(dhd_bus_t *bus, u8 *hdr, uint len, uint doff) ...@@ -3117,8 +3127,10 @@ dhdsdio_read_control(dhd_bus_t *bus, u8 *hdr, uint len, uint doff)
gotpkt: gotpkt:
#ifdef DHD_DEBUG #ifdef DHD_DEBUG
if (DHD_BYTES_ON() && DHD_CTL_ON()) if (DHD_BYTES_ON() && DHD_CTL_ON()) {
bcm_prhex("RxCtrl", bus->rxctl, len); printk(KERN_DEBUG "RxCtrl:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, bus->rxctl, len);
}
#endif #endif
/* Point to valid data and indicate its length */ /* Point to valid data and indicate its length */
...@@ -3309,8 +3321,9 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) ...@@ -3309,8 +3321,9 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
} }
#ifdef DHD_DEBUG #ifdef DHD_DEBUG
if (DHD_GLOM_ON()) { if (DHD_GLOM_ON()) {
bcm_prhex("SUPERFRAME", pfirst->data, printk(KERN_DEBUG "SUPERFRAME:\n");
min_t(int, pfirst->len, 48)); print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
pfirst->data, min_t(int, pfirst->len, 48));
} }
#endif #endif
...@@ -3391,8 +3404,11 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) ...@@ -3391,8 +3404,11 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
chan = SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]); chan = SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]);
doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]); doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]);
#ifdef DHD_DEBUG #ifdef DHD_DEBUG
if (DHD_GLOM_ON()) if (DHD_GLOM_ON()) {
bcm_prhex("subframe", dptr, 32); printk(KERN_DEBUG "subframe:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
dptr, 32);
}
#endif #endif
if ((u16)~(sublen ^ check)) { if ((u16)~(sublen ^ check)) {
...@@ -3469,8 +3485,11 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) ...@@ -3469,8 +3485,11 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
rxseq = seq; rxseq = seq;
} }
#ifdef DHD_DEBUG #ifdef DHD_DEBUG
if (DHD_BYTES_ON() && DHD_DATA_ON()) if (DHD_BYTES_ON() && DHD_DATA_ON()) {
bcm_prhex("Rx Subframe Data", dptr, dlen); printk(KERN_DEBUG "Rx Subframe Data:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
dptr, dlen);
}
#endif #endif
__skb_trim(pfirst, sublen); __skb_trim(pfirst, sublen);
...@@ -3513,7 +3532,8 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) ...@@ -3513,7 +3532,8 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
__func__, num, pfirst, pfirst->data, __func__, num, pfirst, pfirst->data,
pfirst->len, pfirst->next, pfirst->len, pfirst->next,
pfirst->prev)); pfirst->prev));
bcm_prhex("", (u8 *) pfirst->data, print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
pfirst->data,
min_t(int, pfirst->len, 32)); min_t(int, pfirst->len, 32));
} }
#endif /* DHD_DEBUG */ #endif /* DHD_DEBUG */
...@@ -3816,10 +3836,15 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) ...@@ -3816,10 +3836,15 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
bus->tx_max = txmax; bus->tx_max = txmax;
#ifdef DHD_DEBUG #ifdef DHD_DEBUG
if (DHD_BYTES_ON() && DHD_DATA_ON()) if (DHD_BYTES_ON() && DHD_DATA_ON()) {
bcm_prhex("Rx Data", rxbuf, len); printk(KERN_DEBUG "Rx Data:\n");
else if (DHD_HDRS_ON()) print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
bcm_prhex("RxHdr", bus->rxhdr, SDPCM_HDRLEN); rxbuf, len);
} else if (DHD_HDRS_ON()) {
printk(KERN_DEBUG "RxHdr:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
bus->rxhdr, SDPCM_HDRLEN);
}
#endif #endif
if (chan == SDPCM_CONTROL_CHANNEL) { if (chan == SDPCM_CONTROL_CHANNEL) {
...@@ -3874,8 +3899,11 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) ...@@ -3874,8 +3899,11 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
continue; continue;
} }
#ifdef DHD_DEBUG #ifdef DHD_DEBUG
if (DHD_BYTES_ON() || DHD_HDRS_ON()) if (DHD_BYTES_ON() || DHD_HDRS_ON()) {
bcm_prhex("RxHdr", bus->rxhdr, SDPCM_HDRLEN); printk(KERN_DEBUG "RxHdr:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
bus->rxhdr, SDPCM_HDRLEN);
}
#endif #endif
/* Extract hardware header fields */ /* Extract hardware header fields */
...@@ -4048,8 +4076,11 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) ...@@ -4048,8 +4076,11 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
memcpy(pkt->data, bus->rxhdr, firstread); memcpy(pkt->data, bus->rxhdr, firstread);
#ifdef DHD_DEBUG #ifdef DHD_DEBUG
if (DHD_BYTES_ON() && DHD_DATA_ON()) if (DHD_BYTES_ON() && DHD_DATA_ON()) {
bcm_prhex("Rx Data", pkt->data, len); printk(KERN_DEBUG "Rx Data:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
pkt->data, len);
}
#endif #endif
deliver: deliver:
...@@ -4060,7 +4091,10 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) ...@@ -4060,7 +4091,10 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
__func__, len)); __func__, len));
#ifdef DHD_DEBUG #ifdef DHD_DEBUG
if (DHD_GLOM_ON()) { if (DHD_GLOM_ON()) {
bcm_prhex("Glom Data", pkt->data, len); printk(KERN_DEBUG "Glom Data:\n");
print_hex_dump_bytes("",
DUMP_PREFIX_OFFSET,
pkt->data, len);
} }
#endif #endif
__skb_trim(pkt, len); __skb_trim(pkt, len);
...@@ -4621,7 +4655,8 @@ static void dhdsdio_pktgen(dhd_bus_t *bus) ...@@ -4621,7 +4655,8 @@ static void dhdsdio_pktgen(dhd_bus_t *bus)
#ifdef DHD_DEBUG #ifdef DHD_DEBUG
if (DHD_BYTES_ON() && DHD_DATA_ON()) { if (DHD_BYTES_ON() && DHD_DATA_ON()) {
data = (u8 *) (pkt->data) + SDPCM_HDRLEN; data = (u8 *) (pkt->data) + SDPCM_HDRLEN;
bcm_prhex("dhdsdio_pktgen: Tx Data", data, printk(KERN_DEBUG "dhdsdio_pktgen: Tx Data:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, data,
pkt->len - SDPCM_HDRLEN); pkt->len - SDPCM_HDRLEN);
} }
#endif #endif
......
...@@ -4681,8 +4681,9 @@ void wlc_print_txdesc(d11txh_t *txh) ...@@ -4681,8 +4681,9 @@ void wlc_print_txdesc(d11txh_t *txh)
char hexbuf[256]; char hexbuf[256];
/* add plcp header along with txh descriptor */ /* add plcp header along with txh descriptor */
bcm_prhex("Raw TxDesc + plcp header", (unsigned char *) txh, printk(KERN_DEBUG "Raw TxDesc + plcp header:\n");
sizeof(d11txh_t) + 48); print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
txh, sizeof(d11txh_t) + 48);
printk(KERN_DEBUG "TxCtlLow: %04x ", mtcl); printk(KERN_DEBUG "TxCtlLow: %04x ", mtcl);
printk(KERN_DEBUG "TxCtlHigh: %04x ", mtch); printk(KERN_DEBUG "TxCtlHigh: %04x ", mtch);
...@@ -4753,7 +4754,8 @@ void wlc_print_rxh(d11rxhdr_t *rxh) ...@@ -4753,7 +4754,8 @@ void wlc_print_rxh(d11rxhdr_t *rxh)
{0, NULL} {0, NULL}
}; };
bcm_prhex("Raw RxDesc", (unsigned char *) rxh, sizeof(d11rxhdr_t)); printk(KERN_DEBUG "Raw RxDesc:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, rxh, sizeof(d11rxhdr_t));
bcm_format_flags(macstat_flags, macstatus1, flagstr, 64); bcm_format_flags(macstat_flags, macstatus1, flagstr, 64);
......
...@@ -476,7 +476,6 @@ extern u8 bcm_crc8(u8 *p, uint nbytes, u8 crc); ...@@ -476,7 +476,6 @@ extern u8 bcm_crc8(u8 *p, uint nbytes, u8 crc);
extern int bcm_format_hex(char *str, const void *bytes, int len); extern int bcm_format_hex(char *str, const void *bytes, int len);
#endif #endif
extern char *bcm_chipname(uint chipid, char *buf, uint len); extern char *bcm_chipname(uint chipid, char *buf, uint len);
extern void bcm_prhex(const char *msg, unsigned char *buf, uint len);
extern bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen, extern bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen,
uint key); uint key);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/printk.h>
#include <bcmdefs.h> #include <bcmdefs.h>
#include <stdarg.h> #include <stdarg.h>
#include <bcmutils.h> #include <bcmutils.h>
...@@ -386,7 +387,7 @@ void bcm_prpkt(const char *msg, struct sk_buff *p0) ...@@ -386,7 +387,7 @@ void bcm_prpkt(const char *msg, struct sk_buff *p0)
printk(KERN_DEBUG "%s:\n", msg); printk(KERN_DEBUG "%s:\n", msg);
for (p = p0; p; p = p->next) for (p = p0; p; p = p->next)
bcm_prhex(NULL, p->data, p->len); print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, p->data, p->len);
} }
EXPORT_SYMBOL(bcm_prpkt); EXPORT_SYMBOL(bcm_prpkt);
#endif /* defined(BCMDBG) */ #endif /* defined(BCMDBG) */
...@@ -629,43 +630,6 @@ int bcm_format_hex(char *str, const void *bytes, int len) ...@@ -629,43 +630,6 @@ int bcm_format_hex(char *str, const void *bytes, int len)
EXPORT_SYMBOL(bcm_format_hex); EXPORT_SYMBOL(bcm_format_hex);
#endif /* defined(BCMDBG) */ #endif /* defined(BCMDBG) */
/* pretty hex print a contiguous buffer */
void bcm_prhex(const char *msg, unsigned char *buf, uint nbytes)
{
char line[128], *p;
int len = sizeof(line);
int nchar;
uint i;
if (msg && (msg[0] != '\0'))
printk(KERN_DEBUG "%s:\n", msg);
p = line;
for (i = 0; i < nbytes; i++) {
if (i % 16 == 0) {
nchar = snprintf(p, len, " %04d: ", i); /* line prefix */
p += nchar;
len -= nchar;
}
if (len > 0) {
nchar = snprintf(p, len, "%02x ", buf[i]);
p += nchar;
len -= nchar;
}
if (i % 16 == 15) {
printk(KERN_DEBUG "%s\n", line); /* flush line */
p = line;
len = sizeof(line);
}
}
/* flush last partial line */
if (p != line)
printk(KERN_DEBUG "%s\n", line);
}
EXPORT_SYMBOL(bcm_prhex);
char *bcm_chipname(uint chipid, char *buf, uint len) char *bcm_chipname(uint chipid, char *buf, uint len)
{ {
const char *fmt; const char *fmt;
......
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