brcmutil: add helper function to format board revision
authorArend van Spriel <arend@broadcom.com>
Tue, 25 Nov 2014 19:55:53 +0000 (20:55 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 1 Dec 2014 20:57:20 +0000 (15:57 -0500)
The board revision that is available in hardware can be translated
so it matches the labelling on the board. This is accomplished by
this helper function.

Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/brcm80211/brcmutil/utils.c
drivers/net/wireless/brcm80211/include/brcmu_utils.h

index 0f7e1c7b6f58c914b5b6f8d42814481d057d3d5d..906e89ddf31903fb4c18969b46655d8d0bd50457 100644 (file)
@@ -261,6 +261,21 @@ struct sk_buff *brcmu_pktq_mdeq(struct pktq *pq, uint prec_bmp,
 }
 EXPORT_SYMBOL(brcmu_pktq_mdeq);
 
+/* Produce a human-readable string for boardrev */
+char *brcmu_boardrev_str(u32 brev, char *buf)
+{
+       char c;
+
+       if (brev < 0x100) {
+               snprintf(buf, 8, "%d.%d", (brev & 0xf0) >> 4, brev & 0xf);
+       } else {
+               c = (brev & 0xf000) == 0x1000 ? 'P' : 'A';
+               snprintf(buf, 8, "%c%03x", c, brev & 0xfff);
+       }
+       return buf;
+}
+EXPORT_SYMBOL(brcmu_boardrev_str);
+
 #if defined(DEBUG)
 /* pretty hex print a pkt buffer chain */
 void brcmu_prpkt(const char *msg, struct sk_buff *p0)
@@ -292,4 +307,5 @@ void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...)
        print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, data, size);
 }
 EXPORT_SYMBOL(brcmu_dbg_hex_dump);
+
 #endif                         /* defined(DEBUG) */
index 8ba445b3fd72a92ca78cbd1042dcc38528df8efb..a043e29f07e2cd16382b00cccc17d615d75cd5bf 100644 (file)
@@ -218,4 +218,6 @@ void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...)
 }
 #endif
 
+char *brcmu_boardrev_str(u32 brev, char *buf);
+
 #endif                         /* _BRCMU_UTILS_H_ */