Code cleanup. Driver contains too many ASSERTs.
Roland Vossen (3):
staging: brcm80211: delete ASSERTs in 4 files in brcmsmac dir
staging: brcm80211: removed all ASSERTs from wl_mac80211.c
staging: brcm80211: removed all ASSERTs from wlc_ampdu.c
drivers/staging/brcm80211/brcmsmac/wl_mac80211.c | 60 +++++++---------------
drivers/staging/brcm80211/brcmsmac/wlc_ampdu.c | 9 +--
drivers/staging/brcm80211/brcmsmac/wlc_antsel.c | 3 -
drivers/staging/brcm80211/brcmsmac/wlc_channel.c | 18 +------
drivers/staging/brcm80211/brcmsmac/wlc_rate.c | 6 +--
drivers/staging/brcm80211/brcmsmac/wlc_stf.c | 19 +------
6 files changed, 28 insertions(+), 87 deletions(-)
Either removed ASSERTs or replaced with WARN_ON in case of HW failure.
Signed-off-by: Roland Vossen <[email protected]>
---
drivers/staging/brcm80211/brcmsmac/wlc_ampdu.c | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/brcm80211/brcmsmac/wlc_ampdu.c b/drivers/staging/brcm80211/brcmsmac/wlc_ampdu.c
index 43aa232..dfdcc83 100644
--- a/drivers/staging/brcm80211/brcmsmac/wlc_ampdu.c
+++ b/drivers/staging/brcm80211/brcmsmac/wlc_ampdu.c
@@ -521,8 +521,6 @@ wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
f = ampdu->fifo_tb + prio2fifo[tid];
scb = wlc->pub->global_scb;
- ASSERT(scb->magic == SCB_MAGIC);
-
scb_ampdu = SCB_AMPDU_CUBBY(ampdu, scb);
ini = &scb_ampdu->ini[tid];
@@ -906,7 +904,6 @@ wlc_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb,
if (likely(scb)) {
scb_ampdu = SCB_AMPDU_CUBBY(ampdu, scb);
ini = SCB_AMPDU_INI(scb_ampdu, p->priority);
- ASSERT(ini->scb == scb);
wlc_ampdu_dotxstatus_complete(ampdu, scb, p, txs, s1, s2);
} else {
/* loop through all pkts and free */
@@ -989,13 +986,13 @@ wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
update_rate = false;
}
- ASSERT(txs->status & TX_STATUS_INTERMEDIATE);
+ WARN_ON(!(txs->status & TX_STATUS_INTERMEDIATE));
start_seq = txs->sequence >> SEQNUM_SHIFT;
bitmap[0] = (txs->status & TX_STATUS_BA_BMAP03_MASK) >>
TX_STATUS_BA_BMAP03_SHIFT;
- ASSERT(!(s1 & TX_STATUS_INTERMEDIATE));
- ASSERT(s1 & TX_STATUS_AMPDU);
+ WARN_ON(s1 & TX_STATUS_INTERMEDIATE);
+ WARN_ON(!(s1 & TX_STATUS_AMPDU));
bitmap[0] |=
(s1 & TX_STATUS_BA_BMAP47_MASK) <<
--
1.7.1
wlc_antsel.c, wlc_channel.c, wlc_rate.c and wlc_stf.c are now
ASSERT free.
Signed-off-by: Roland Vossen <[email protected]>
---
drivers/staging/brcm80211/brcmsmac/wlc_antsel.c | 3 ---
drivers/staging/brcm80211/brcmsmac/wlc_channel.c | 18 ++----------------
drivers/staging/brcm80211/brcmsmac/wlc_rate.c | 6 ++----
drivers/staging/brcm80211/brcmsmac/wlc_stf.c | 19 ++-----------------
4 files changed, 6 insertions(+), 40 deletions(-)
diff --git a/drivers/staging/brcm80211/brcmsmac/wlc_antsel.c b/drivers/staging/brcm80211/brcmsmac/wlc_antsel.c
index 4516377..7a154ab 100644
--- a/drivers/staging/brcm80211/brcmsmac/wlc_antsel.c
+++ b/drivers/staging/brcm80211/brcmsmac/wlc_antsel.c
@@ -130,7 +130,6 @@ struct antsel_info *wlc_antsel_attach(struct wlc_info *wlc)
asi->antsel_avail = false;
dev_err(wlc->dev, "wlc_antsel_attach: 2o3 "
"board cfg invalid\n");
- ASSERT(0);
}
break;
default:
@@ -298,8 +297,6 @@ static int wlc_antsel_cfgupd(struct antsel_info *asi, wlc_antselcfg_t *antsel)
u8 ant_cfg;
u16 mimo_antsel;
- ASSERT(asi->antsel_type != ANTSEL_NA);
-
/* 1) Update TX antconfig for all frames that are not unicast data
* (aka default TX)
*/
diff --git a/drivers/staging/brcm80211/brcmsmac/wlc_channel.c b/drivers/staging/brcm80211/brcmsmac/wlc_channel.c
index 124e9cd..55a741b 100644
--- a/drivers/staging/brcm80211/brcmsmac/wlc_channel.c
+++ b/drivers/staging/brcm80211/brcmsmac/wlc_channel.c
@@ -594,8 +594,7 @@ struct chan20_info chan20_info[] = {
static const locale_info_t *wlc_get_locale_2g(u8 locale_idx)
{
if (locale_idx >= ARRAY_SIZE(g_locale_2g_table)) {
- ASSERT(locale_idx < ARRAY_SIZE(g_locale_2g_table));
- return NULL;
+ return NULL; /* error condition */
}
return g_locale_2g_table[locale_idx];
}
@@ -603,8 +602,7 @@ static const locale_info_t *wlc_get_locale_2g(u8 locale_idx)
static const locale_info_t *wlc_get_locale_5g(u8 locale_idx)
{
if (locale_idx >= ARRAY_SIZE(g_locale_5g_table)) {
- ASSERT(locale_idx < ARRAY_SIZE(g_locale_5g_table));
- return NULL;
+ return NULL; /* error condition */
}
return g_locale_5g_table[locale_idx];
}
@@ -659,8 +657,6 @@ wlc_cm_info_t *wlc_channel_mgr_attach(struct wlc_info *wlc)
strncpy(country_abbrev, "X2", sizeof(country_abbrev) - 1);
country = wlc_country_lookup(wlc, country_abbrev);
- ASSERT(country != NULL);
-
/* save default country for exiting 11d regulatory mode */
strncpy(wlc->country_default, country_abbrev, WLC_CNTRY_BUF_SZ - 1);
@@ -715,7 +711,6 @@ wlc_set_countrycode_rev(wlc_cm_info_t *wlc_cm,
&mapped_regrev);
} else {
/* find the matching built-in country definition */
- ASSERT(0);
country = wlc_country_lookup_direct(ccode, regrev);
strncpy(mapped_ccode, ccode, WLC_CNTRY_BUF_SZ);
mapped_regrev = regrev;
@@ -745,8 +740,6 @@ wlc_set_country_common(wlc_cm_info_t *wlc_cm,
struct wlc_info *wlc = wlc_cm->wlc;
char prev_country_abbrev[WLC_CNTRY_BUF_SZ];
- ASSERT(country != NULL);
-
/* save current country state */
wlc_cm->country = country;
@@ -831,7 +824,6 @@ static const country_info_t *wlc_countrycode_map(wlc_cm_info_t *wlc_cm,
*mapped_regrev = srom_regrev;
mapped = 0;
dev_err(wlc->dev, "srom_code == ccode %s\n", __func__);
- ASSERT(0);
} else {
mapped =
wlc_country_aggregate_map(wlc_cm, ccode, mapped_ccode,
@@ -844,7 +836,6 @@ static const country_info_t *wlc_countrycode_map(wlc_cm_info_t *wlc_cm,
/* if there is not an exact rev match, default to rev zero */
if (country == NULL && *mapped_regrev != 0) {
*mapped_regrev = 0;
- ASSERT(0);
country =
wlc_country_lookup_direct(mapped_ccode, *mapped_regrev);
}
@@ -881,8 +872,6 @@ static const country_info_t *wlc_country_lookup_direct(const char *ccode,
return &cntry_locales[i].country;
}
}
-
- ASSERT(0);
return NULL;
}
@@ -903,12 +892,10 @@ wlc_channels_init(wlc_cm_info_t *wlc_cm, const country_info_t *country)
li = BAND_5G(band->bandtype) ?
wlc_get_locale_5g(country->locale_5G) :
wlc_get_locale_2g(country->locale_2G);
- ASSERT(li);
wlc_cm->bandstate[band->bandunit].locale_flags = li->flags;
li_mimo = BAND_5G(band->bandtype) ?
wlc_get_mimo_5g(country->locale_mimo_5G) :
wlc_get_mimo_2g(country->locale_mimo_2G);
- ASSERT(li_mimo);
/* merge the mimo non-mimo locale flags */
wlc_cm->bandstate[band->bandunit].locale_flags |=
@@ -1516,7 +1503,6 @@ wlc_valid_chanspec_ext(wlc_cm_info_t *wlc_cm, chanspec_t chspec, bool dualband)
if (wf_chspec_malformed(chspec)) {
dev_err(wlc->dev, "wl%d: malformed chanspec 0x%x\n",
wlc->pub->unit, chspec);
- ASSERT(0);
return false;
}
diff --git a/drivers/staging/brcm80211/brcmsmac/wlc_rate.c b/drivers/staging/brcm80211/brcmsmac/wlc_rate.c
index 1f3f320..87a2f62 100644
--- a/drivers/staging/brcm80211/brcmsmac/wlc_rate.c
+++ b/drivers/staging/brcm80211/brcmsmac/wlc_rate.c
@@ -315,7 +315,6 @@ wlc_rate_hwrs_filter_sort_validate(wlc_rateset_t *rs,
count = 0;
for (i = 0; i < hw_rs->count; i++) {
r = hw_rs->rates[i] & WLC_RATE_MASK;
- ASSERT(r <= WLC_MAXRATE);
if (rateset[r])
rs->rates[count++] = rateset[r];
}
@@ -364,8 +363,7 @@ ratespec_t BCMFASTPATH wlc_compute_rspec(d11rxhdr_t *rxh, u8 *plcp)
case PRXS0_STDN:
/* fallthru */
default:
- /* not supported */
- ASSERT(0);
+ /* not supported, error condition */
break;
}
if (PLCP3_ISSGI(plcp[3]))
@@ -451,7 +449,7 @@ wlc_rateset_default(wlc_rateset_t *rs_tgt, const wlc_rateset_t *rs_hw,
} else if (PHYTYPE_IS(phy_type, PHY_TYPE_G)) {
rs_dflt = &cck_ofdm_rates;
} else {
- ASSERT(0); /* should not happen */
+ /* should not happen, error condition */
rs_dflt = &cck_rates; /* force cck */
}
diff --git a/drivers/staging/brcm80211/brcmsmac/wlc_stf.c b/drivers/staging/brcm80211/brcmsmac/wlc_stf.c
index 26f1897..c58ab68 100644
--- a/drivers/staging/brcm80211/brcmsmac/wlc_stf.c
+++ b/drivers/staging/brcm80211/brcmsmac/wlc_stf.c
@@ -69,9 +69,6 @@ const u8 txcore_default[5] = {
static void wlc_stf_stbc_rx_ht_update(struct wlc_info *wlc, int val)
{
- ASSERT((val == HT_CAP_RX_STBC_NO)
- || (val == HT_CAP_RX_STBC_ONE_STREAM));
-
/* MIMOPHYs rev3-6 cannot receive STBC with only one rx core active */
if (WLC_STF_SS_STBC_RX(wlc)) {
if ((wlc->stf->rxstreams == 1) && (val != HT_CAP_RX_STBC_NO))
@@ -196,8 +193,6 @@ static int wlc_stf_txcore_set(struct wlc_info *wlc, u8 Nsts, u8 core_mask)
WL_TRACE("wl%d: %s: Nsts %d core_mask %x\n",
wlc->pub->unit, __func__, Nsts, core_mask);
- ASSERT((Nsts > 0) && (Nsts <= MAX_STREAMS_SUPPORTED));
-
if (WLC_BITSCNT(core_mask) > wlc->stf->txstreams) {
core_mask = 0;
}
@@ -208,8 +203,6 @@ static int wlc_stf_txcore_set(struct wlc_info *wlc, u8 Nsts, u8 core_mask)
core_mask = wlc->stf->txchain;
}
- ASSERT(!core_mask || Nsts <= WLC_BITSCNT(core_mask));
-
wlc->stf->txcore[Nsts] = core_mask;
/* Nsts = 1..4, txcore index = 1..4 */
if (Nsts == 1) {
@@ -321,9 +314,6 @@ int wlc_stf_ss_update(struct wlc_info *wlc, struct wlcband *band)
if (WLC_STBC_CAP_PHY(wlc) &&
wlc->stf->ss_algosel_auto
&& (wlc->stf->ss_algo_channel != (u16) -1)) {
- ASSERT(isset(&wlc->stf->ss_algo_channel, PHY_TXC1_MODE_CDD)
- || isset(&wlc->stf->ss_algo_channel,
- PHY_TXC1_MODE_SISO));
upd_stf_ss = (wlc->stf->no_cddstbc || (wlc->stf->txstreams == 1)
|| isset(&wlc->stf->ss_algo_channel,
PHY_TXC1_MODE_SISO)) ? PHY_TXC1_MODE_SISO
@@ -423,9 +413,6 @@ static void _wlc_stf_phy_txant_upd(struct wlc_info *wlc)
s8 txant;
txant = (s8) wlc->stf->txant;
- ASSERT(txant == ANT_TX_FORCE_0 || txant == ANT_TX_FORCE_1
- || txant == ANT_TX_LAST_RX);
-
if (WLC_PHY_11N_CAP(wlc->band)) {
if (txant == ANT_TX_FORCE_0) {
wlc->stf->phytxant = PHY_TXC_ANT_0;
@@ -441,8 +428,8 @@ static void _wlc_stf_phy_txant_upd(struct wlc_info *wlc)
if (WLCISLCNPHY(wlc->band) || WLCISSSLPNPHY(wlc->band))
wlc->stf->phytxant = PHY_TXC_LCNPHY_ANT_LAST;
else {
- /* keep this assert to catch out of sync wlc->stf->txcore */
- ASSERT(wlc->stf->txchain > 0);
+ /* catch out of sync wlc->stf->txcore */
+ WARN_ON(wlc->stf->txchain <= 0);
wlc->stf->phytxant =
wlc->stf->txchain << PHY_TXC_ANT_SHIFT;
}
@@ -506,7 +493,6 @@ static u16 _wlc_stf_phytxchain_sel(struct wlc_info *wlc, ratespec_t rspec)
u16 phytxant = wlc->stf->phytxant;
if (RSPEC_STF(rspec) != PHY_TXC1_MODE_SISO) {
- ASSERT(wlc->stf->txstreams > 1);
phytxant = wlc->stf->txchain << PHY_TXC_ANT_SHIFT;
} else if (wlc->stf->txant == ANT_TX_DEF)
phytxant = wlc->stf->txchain << PHY_TXC_ANT_SHIFT;
@@ -526,7 +512,6 @@ u16 wlc_stf_d11hdrs_phyctl_txant(struct wlc_info *wlc, ratespec_t rspec)
/* for non-siso rates or default setting, use the available chains */
if (WLCISNPHY(wlc->band)) {
- ASSERT(wlc->stf->txchain != 0);
phytxant = _wlc_stf_phytxchain_sel(wlc, rspec);
mask = PHY_TXC_HTANT_MASK;
}
--
1.7.1
Signed-off-by: Roland Vossen <[email protected]>
---
drivers/staging/brcm80211/brcmsmac/wl_mac80211.c | 60 +++++++---------------
1 files changed, 19 insertions(+), 41 deletions(-)
diff --git a/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c b/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c
index ba4d6de..169d26b 100644
--- a/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c
+++ b/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c
@@ -188,10 +188,6 @@ static int wl_ops_start(struct ieee80211_hw *hw)
static void wl_ops_stop(struct ieee80211_hw *hw)
{
-#ifdef BRCMDBG
- struct wl_info *wl = hw->priv;
- ASSERT(wl);
-#endif /*BRCMDBG*/
ieee80211_stop_queues(hw);
}
@@ -283,7 +279,6 @@ static int wl_ops_config(struct ieee80211_hw *hw, u32 changed)
goto config_out;
}
wlc_iovar_getint(wl->wlc, "bcn_li_bcn", &new_int);
- ASSERT(new_int == conf->listen_interval);
}
if (changed & IEEE80211_CONF_CHANGE_MONITOR)
wiphy_err(wiphy, "%s: change monitor mode: %s (implement)\n",
@@ -635,13 +630,12 @@ wl_ops_ampdu_action(struct ieee80211_hw *hw,
struct ieee80211_sta *sta, u16 tid, u16 *ssn,
u8 buf_size)
{
-#if defined(BCMDBG)
struct scb *scb = (struct scb *)sta->drv_priv;
-#endif
struct wl_info *wl = hw->priv;
int status;
- ASSERT(scb->magic == SCB_MAGIC);
+ if (WARN_ON(scb->magic != SCB_MAGIC))
+ return -EIDRM;
switch (action) {
case IEEE80211_AMPDU_RX_START:
no_printk("%s: action = IEEE80211_AMPDU_RX_START\n", __func__);
@@ -656,7 +650,7 @@ wl_ops_ampdu_action(struct ieee80211_hw *hw,
if (!status) {
dev_err(wl->dev, "START: tid %d is not agg\'able\n",
tid);
- return -1;
+ return -EINVAL;
}
/* XXX: Use the starting sequence number provided ... */
*ssn = 0;
@@ -746,7 +740,7 @@ static int wl_set_hint(struct wl_info *wl, char *abbrev)
static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs,
uint bustype, void *btparam, uint irq)
{
- struct wl_info *wl;
+ struct wl_info *wl = NULL;
int unit, err;
unsigned long base_addr;
@@ -759,14 +753,10 @@ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs,
/* allocate private info */
hw = pci_get_drvdata(btparam); /* btparam == pdev */
- wl = hw->priv;
- ASSERT(wl);
- wl->dev = &hw->wiphy->dev;
-
- if (unit < 0) {
- dev_err(wl->dev, "wl%d: unit number overflow, exiting\n", unit);
+ if (hw != NULL)
+ wl = hw->priv;
+ if (WARN_ON(hw == NULL) || WARN_ON(wl == NULL))
return NULL;
- }
atomic_set(&wl->callbacks, 0);
@@ -801,7 +791,7 @@ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs,
KBUILD_MODNAME, "/lib/firmware/brcm");
wl_release_fw(wl);
wl_remove((struct pci_dev *)btparam);
- goto fail1;
+ return NULL;
}
/* common load-time initialization */
@@ -817,9 +807,6 @@ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs,
wl->pub = wlc_pub(wl->wlc);
wl->pub->ieee_hw = hw;
- ASSERT(wl->pub->ieee_hw);
- ASSERT(wl->pub->ieee_hw->priv == wl);
-
if (wlc_iovar_setint(wl->wlc, "mpc", 0)) {
dev_err(wl->dev, "wl%d: Error setting MPC variable to 0\n",
@@ -844,7 +831,8 @@ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs,
}
memcpy(perm, &wl->pub->cur_etheraddr, ETH_ALEN);
- ASSERT(is_valid_ether_addr(perm));
+ if (WARN_ON(!is_valid_ether_addr(perm)))
+ goto fail;
SET_IEEE80211_PERM_ADDR(hw, perm);
err = ieee80211_register_hw(hw);
@@ -867,7 +855,6 @@ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs,
fail:
wl_free(wl);
-fail1:
return NULL;
}
@@ -1066,8 +1053,7 @@ static int ieee_hw_rate_init(struct ieee80211_hw *hw)
}
hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &wl_band_2GHz_nphy;
} else {
- BUG();
- return -1;
+ return -EPERM;
}
/* Assume all bands use the same phy. True for 11n devices. */
@@ -1077,7 +1063,7 @@ static int ieee_hw_rate_init(struct ieee80211_hw *hw)
hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
&wl_band_5GHz_nphy;
} else {
- return -1;
+ return -EPERM;
}
}
@@ -1130,8 +1116,6 @@ wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
struct ieee80211_hw *hw;
u32 val;
- ASSERT(pdev);
-
WL_TRACE("%s: bus %d slot %d func %d irq %d\n",
__func__, pdev->bus->number, PCI_SLOT(pdev->devfn),
PCI_FUNC(pdev->devfn), pdev->irq);
@@ -1158,8 +1142,7 @@ wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
hw = ieee80211_alloc_hw(sizeof(struct wl_info), &wl_ops);
if (!hw) {
pr_err("%s: ieee80211_alloc_hw failed\n", __func__);
- rc = -ENOMEM;
- goto err_1;
+ return -ENOMEM;
}
SET_IEEE80211_DEV(hw, &pdev->dev);
@@ -1177,9 +1160,6 @@ wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
return -ENODEV;
}
return 0;
- err_1:
- pr_err("%s: err_1: Major hoarkage\n", __func__);
- return 0;
}
static int wl_suspend(struct pci_dev *pdev, pm_message_t state)
@@ -1370,7 +1350,6 @@ static void wl_free(struct wl_info *wl)
{
struct wl_timer *t, *next;
- ASSERT(wl);
/* free ucode data */
if (wl->fw.fw_cnt)
wl_ucode_data_free();
@@ -1566,7 +1545,6 @@ static irqreturn_t BCMFASTPATH wl_isr(int irq, void *dev_id)
/* ...and call the second level interrupt handler */
/* schedule dpc */
- ASSERT(wl->resched == false);
tasklet_schedule(&wl->tasklet);
}
}
@@ -1694,8 +1672,6 @@ void wl_add_timer(struct wl_info *wl, struct wl_timer *t, uint ms, int periodic)
__func__, t->name, periodic);
}
#endif
- ASSERT(!t->set);
-
t->ms = ms;
t->periodic = (bool) periodic;
t->set = true;
@@ -1771,8 +1747,6 @@ static int wl_linux_watchdog(void *ctx)
uint id;
/* refresh stats */
if (wl->pub->up) {
- ASSERT(wl->stats_id < 2);
-
cnt = wl->pub->_cnt;
id = 1 - wl->stats_id;
stats = &wl->stats_watchdog[id];
@@ -1858,14 +1832,18 @@ int wl_ucode_init_uint(struct wl_info *wl, u32 *data, u32 idx)
entry++, hdr++) {
if (hdr->idx == idx) {
pdata = wl->fw.fw_bin[i]->data + hdr->offset;
- ASSERT(hdr->len == 4);
+ if (hdr->len != 4) {
+ dev_err(wl->dev,
+ "ERROR: fw hdr len\n");
+ return -ENOMSG;
+ }
*data = *((u32 *) pdata);
return 0;
}
}
}
dev_err(wl->dev, "ERROR: ucode tag:%d can not be found!\n", idx);
- return -1;
+ return -ENOMSG;
}
/*
--
1.7.1