aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Ptasinski <[email protected]>2011-06-29 16:46:56 -0700
committerGreg Kroah-Hartman <[email protected]>2011-07-05 09:57:14 -0700
commit4c5c488a3c0fdcbdce0e212c0e99c01cffce2039 (patch)
tree3bada203ad4443d6102b1306914d4ad8a522e7b8
parent521223a27a760658e04e65d8deaf5339070f15f6 (diff)
staging: brcm80211: reorg brcms_c_validboardtype for clarity
The structure of the function made it difficult to understand, so reorganize it to make it clearer. Reported-by: Greg Dietsche <[email protected]> Signed-off-by: Henry Ptasinski <[email protected]> Reviewed-by: Roland Vossen <[email protected]> Reviewed-by: Arend van Spriel <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r--drivers/staging/brcm80211/brcmsmac/bmac.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/drivers/staging/brcm80211/brcmsmac/bmac.c b/drivers/staging/brcm80211/brcmsmac/bmac.c
index f44f581068a4..4a220d4ed7e1 100644
--- a/drivers/staging/brcm80211/brcmsmac/bmac.c
+++ b/drivers/staging/brcm80211/brcmsmac/bmac.c
@@ -1905,28 +1905,33 @@ static bool brcms_c_isgoodchip(struct brcms_c_hw_info *wlc_hw)
return true;
}
+/* Validate some board info parameters */
static bool brcms_c_validboardtype(struct brcms_c_hw_info *wlc_hw)
{
- bool goodboard = true;
uint boardrev = wlc_hw->boardrev;
+ /* 4 bits each for board type, major, minor, and tiny version */
+ uint brt = (boardrev & 0xf000) >> 12;
+ uint b0 = (boardrev & 0xf00) >> 8;
+ uint b1 = (boardrev & 0xf0) >> 4;
+ uint b2 = boardrev & 0xf;
+
+ /* voards from other vendors are always considered valid */
+ if (wlc_hw->sih->boardvendor != PCI_VENDOR_ID_BROADCOM)
+ return true;
+
+ /* do some boardrev sanity checks when boardvendor is Broadcom */
if (boardrev == 0)
- goodboard = false;
- else if (boardrev > 0xff) {
- uint brt = (boardrev & 0xf000) >> 12;
- uint b0 = (boardrev & 0xf00) >> 8;
- uint b1 = (boardrev & 0xf0) >> 4;
- uint b2 = boardrev & 0xf;
+ return false;
- if ((brt > 2) || (brt == 0) || (b0 > 9) || (b0 == 0) || (b1 > 9)
- || (b2 > 9))
- goodboard = false;
- }
+ if (boardrev <= 0xff)
+ return true;
- if (wlc_hw->sih->boardvendor != PCI_VENDOR_ID_BROADCOM)
- return goodboard;
+ if ((brt > 2) || (brt == 0) || (b0 > 9) || (b0 == 0) || (b1 > 9)
+ || (b2 > 9))
+ return false;
- return goodboard;
+ return true;
}
static char *brcms_c_get_macaddr(struct brcms_c_hw_info *wlc_hw)