diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c index 3715bb18bd78..3355183fc86c 100644 --- a/drivers/staging/wfx/bh.c +++ b/drivers/staging/wfx/bh.c @@ -56,7 +56,7 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf) int release_count; int piggyback = 0; - WARN_ON(read_len < 4); + WARN(read_len < 4, "corrupted read"); WARN(read_len > round_down(0xFFF, 2) * sizeof(u16), "%s: request exceed WFx capability", __func__); @@ -173,7 +173,7 @@ static void tx_helper(struct wfx_dev *wdev, struct hif_msg *hif) bool is_encrypted = false; size_t len = le16_to_cpu(hif->len); - BUG_ON(len < sizeof(*hif)); + WARN(len < sizeof(*hif), "try to send corrupted data"); hif->seqnum = wdev->hif.tx_seqnum; wdev->hif.tx_seqnum = (wdev->hif.tx_seqnum + 1) % (HIF_COUNTER_MAX + 1); diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c index 05f02c278782..f97360513150 100644 --- a/drivers/staging/wfx/bus_sdio.c +++ b/drivers/staging/wfx/bus_sdio.c @@ -37,7 +37,7 @@ static int wfx_sdio_copy_from_io(void *priv, unsigned int reg_id, unsigned int sdio_addr = reg_id << 2; int ret; - BUG_ON(reg_id > 7); + WARN(reg_id > 7, "chip only has 7 registers"); WARN(((uintptr_t) dst) & 3, "unaligned buffer size"); WARN(count & 3, "unaligned buffer address"); @@ -58,7 +58,7 @@ static int wfx_sdio_copy_to_io(void *priv, unsigned int reg_id, unsigned int sdio_addr = reg_id << 2; int ret; - BUG_ON(reg_id > 7); + WARN(reg_id > 7, "chip only has 7 registers"); WARN(((uintptr_t) src) & 3, "unaligned buffer size"); WARN(count & 3, "unaligned buffer address"); diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index 1891bcaaf9fc..b2ca3986c6d0 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -44,7 +44,7 @@ static void tx_policy_build(struct wfx_vif *wvif, struct tx_policy *policy, size_t count; struct wfx_dev *wdev = wvif->wdev; - BUG_ON(rates[0].idx < 0); + WARN(rates[0].idx < 0, "invalid rate policy"); memset(policy, 0, sizeof(*policy)); for (i = 1; i < IEEE80211_TX_MAX_RATES; i++) if (rates[i].idx < 0) @@ -162,7 +162,7 @@ static int tx_policy_get(struct wfx_vif *wvif, struct ieee80211_tx_rate *rates, tx_policy_build(wvif, &wanted, rates); spin_lock_bh(&cache->lock); - if (WARN_ON_ONCE(list_empty(&cache->free))) { + if (WARN_ON(list_empty(&cache->free))) { spin_unlock_bh(&cache->lock); return WFX_INVALID_RATE_ID; } diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h index 4f132348f5fa..3339ad95f732 100644 --- a/drivers/staging/wfx/hif_tx_mib.h +++ b/drivers/staging/wfx/hif_tx_mib.h @@ -138,7 +138,7 @@ static inline int hif_set_mfp(struct wfx_vif *wvif, bool capable, bool required) { struct hif_mib_protected_mgmt_policy val = { }; - WARN_ON(required && !capable); + WARN(required && !capable, "incoherent arguments"); if (capable) { val.pmf_enable = 1; val.host_enc_auth_frames = 1; diff --git a/drivers/staging/wfx/key.c b/drivers/staging/wfx/key.c index 4e7d2b510a9c..6d03abec20e4 100644 --- a/drivers/staging/wfx/key.c +++ b/drivers/staging/wfx/key.c @@ -26,7 +26,7 @@ static int wfx_alloc_key(struct wfx_dev *wdev) static void wfx_free_key(struct wfx_dev *wdev, int idx) { - BUG_ON(!(wdev->key_map & BIT(idx))); + WARN(!(wdev->key_map & BIT(idx)), "inconsistent key allocation"); memset(&wdev->keys[idx], 0, sizeof(wdev->keys[idx])); wdev->key_map &= ~BIT(idx); } @@ -34,7 +34,7 @@ static void wfx_free_key(struct wfx_dev *wdev, int idx) static uint8_t fill_wep_pair(struct hif_wep_pairwise_key *msg, struct ieee80211_key_conf *key, u8 *peer_addr) { - WARN_ON(key->keylen > sizeof(msg->key_data)); + WARN(key->keylen > sizeof(msg->key_data), "inconsistent data"); msg->key_length = key->keylen; memcpy(msg->key_data, key->key, key->keylen); ether_addr_copy(msg->peer_address, peer_addr); @@ -44,7 +44,7 @@ static uint8_t fill_wep_pair(struct hif_wep_pairwise_key *msg, static uint8_t fill_wep_group(struct hif_wep_group_key *msg, struct ieee80211_key_conf *key) { - WARN_ON(key->keylen > sizeof(msg->key_data)); + WARN(key->keylen > sizeof(msg->key_data), "inconsistent data"); msg->key_id = key->keyidx; msg->key_length = key->keylen; memcpy(msg->key_data, key->key, key->keylen); @@ -56,9 +56,9 @@ static uint8_t fill_tkip_pair(struct hif_tkip_pairwise_key *msg, { uint8_t *keybuf = key->key; - WARN_ON(key->keylen != sizeof(msg->tkip_key_data) - + sizeof(msg->tx_mic_key) - + sizeof(msg->rx_mic_key)); + WARN(key->keylen != sizeof(msg->tkip_key_data) + + sizeof(msg->tx_mic_key) + + sizeof(msg->rx_mic_key), "inconsistent data"); memcpy(msg->tkip_key_data, keybuf, sizeof(msg->tkip_key_data)); keybuf += sizeof(msg->tkip_key_data); memcpy(msg->tx_mic_key, keybuf, sizeof(msg->tx_mic_key)); @@ -75,8 +75,8 @@ static uint8_t fill_tkip_group(struct hif_tkip_group_key *msg, { uint8_t *keybuf = key->key; - WARN_ON(key->keylen != sizeof(msg->tkip_key_data) - + 2 * sizeof(msg->rx_mic_key)); + WARN(key->keylen != sizeof(msg->tkip_key_data) + + 2 * sizeof(msg->rx_mic_key), "inconsistent data"); msg->key_id = key->keyidx; memcpy(msg->rx_sequence_counter, &seq->tkip.iv16, sizeof(seq->tkip.iv16)); memcpy(msg->rx_sequence_counter + sizeof(uint16_t), &seq->tkip.iv32, sizeof(seq->tkip.iv32)); @@ -94,7 +94,7 @@ static uint8_t fill_tkip_group(struct hif_tkip_group_key *msg, static uint8_t fill_ccmp_pair(struct hif_aes_pairwise_key *msg, struct ieee80211_key_conf *key, u8 *peer_addr) { - WARN_ON(key->keylen != sizeof(msg->aes_key_data)); + WARN(key->keylen != sizeof(msg->aes_key_data), "inconsistent data"); ether_addr_copy(msg->peer_address, peer_addr); memcpy(msg->aes_key_data, key->key, key->keylen); return HIF_KEY_TYPE_AES_PAIRWISE; @@ -104,7 +104,7 @@ static uint8_t fill_ccmp_group(struct hif_aes_group_key *msg, struct ieee80211_key_conf *key, struct ieee80211_key_seq *seq) { - WARN_ON(key->keylen != sizeof(msg->aes_key_data)); + WARN(key->keylen != sizeof(msg->aes_key_data), "inconsistent data"); memcpy(msg->aes_key_data, key->key, key->keylen); memcpy(msg->rx_sequence_counter, seq->ccmp.pn, sizeof(seq->ccmp.pn)); memreverse(msg->rx_sequence_counter, sizeof(seq->ccmp.pn)); @@ -117,8 +117,8 @@ static uint8_t fill_sms4_pair(struct hif_wapi_pairwise_key *msg, { uint8_t *keybuf = key->key; - WARN_ON(key->keylen != sizeof(msg->wapi_key_data) - + sizeof(msg->mic_key_data)); + WARN(key->keylen != sizeof(msg->wapi_key_data) + + sizeof(msg->mic_key_data), "inconsistent data"); ether_addr_copy(msg->peer_address, peer_addr); memcpy(msg->wapi_key_data, keybuf, sizeof(msg->wapi_key_data)); keybuf += sizeof(msg->wapi_key_data); @@ -132,8 +132,8 @@ static uint8_t fill_sms4_group(struct hif_wapi_group_key *msg, { uint8_t *keybuf = key->key; - WARN_ON(key->keylen != sizeof(msg->wapi_key_data) - + sizeof(msg->mic_key_data)); + WARN(key->keylen != sizeof(msg->wapi_key_data) + + sizeof(msg->mic_key_data), "inconsistent data"); memcpy(msg->wapi_key_data, keybuf, sizeof(msg->wapi_key_data)); keybuf += sizeof(msg->wapi_key_data); memcpy(msg->mic_key_data, keybuf, sizeof(msg->mic_key_data)); @@ -145,7 +145,7 @@ static uint8_t fill_aes_cmac_group(struct hif_igtk_group_key *msg, struct ieee80211_key_conf *key, struct ieee80211_key_seq *seq) { - WARN_ON(key->keylen != sizeof(msg->igtk_key_data)); + WARN(key->keylen != sizeof(msg->igtk_key_data), "inconsistent data"); memcpy(msg->igtk_key_data, key->key, key->keylen); memcpy(msg->ipn, seq->aes_cmac.pn, sizeof(seq->aes_cmac.pn)); memreverse(msg->ipn, sizeof(seq->aes_cmac.pn)); @@ -163,7 +163,7 @@ static int wfx_add_key(struct wfx_vif *wvif, struct ieee80211_sta *sta, int idx = wfx_alloc_key(wvif->wdev); bool pairwise = key->flags & IEEE80211_KEY_FLAG_PAIRWISE; - WARN_ON(key->flags & IEEE80211_KEY_FLAG_PAIRWISE && !sta); + WARN(key->flags & IEEE80211_KEY_FLAG_PAIRWISE && !sta, "inconsistent data"); ieee80211_get_key_rx_seq(key, 0, &seq); if (idx < 0) return -EINVAL; diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index 6f1be4f6f463..ee9b2c3fde5a 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -78,7 +78,7 @@ void wfx_tx_queues_unlock(struct wfx_dev *wdev) for (i = 0; i < IEEE80211_NUM_ACS; ++i) { queue = &wdev->tx_queue[i]; spin_lock_bh(&queue->queue.lock); - BUG_ON(!queue->tx_locked_cnt); + WARN(!queue->tx_locked_cnt, "queue already unlocked"); if (--queue->tx_locked_cnt == 0) ieee80211_wake_queue(wdev->hw, queue->queue_id); spin_unlock_bh(&queue->queue.lock); @@ -295,8 +295,8 @@ struct sk_buff *wfx_pending_get(struct wfx_dev *wdev, u32 packet_id) return skb; } } - WARN_ON(1); spin_unlock_bh(&stats->pending.lock); + WARN(1, "cannot find packet in pending queue"); return NULL; } @@ -408,7 +408,7 @@ static bool hif_handle_tx_data(struct wfx_vif *wvif, struct sk_buff *skb, switch (action) { case do_drop: - BUG_ON(wfx_pending_remove(wvif->wdev, skb)); + wfx_pending_remove(wvif->wdev, skb); handled = true; break; case do_wep: diff --git a/drivers/staging/wfx/scan.c b/drivers/staging/wfx/scan.c index ea5001c915f6..cba735c1e73c 100644 --- a/drivers/staging/wfx/scan.c +++ b/drivers/staging/wfx/scan.c @@ -107,7 +107,7 @@ int wfx_hw_scan(struct ieee80211_hw *hw, wfx_tx_lock_flush(wdev); - BUG_ON(wvif->scan.req); + WARN(wvif->scan.req, "unexpected concurrent scan"); wvif->scan.req = req; wvif->scan.n_ssids = 0; wvif->scan.status = 0; diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 12198b8f3685..733b93a8f830 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -1454,6 +1454,7 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) }, }; + BUILD_BUG_ON(ARRAY_SIZE(default_edca_params) != ARRAY_SIZE(wvif->edca.params)); if (wfx_api_older_than(wdev, 2, 0)) { default_edca_params[IEEE80211_AC_BE].queue_id = HIF_QUEUE_ID_BACKGROUND; default_edca_params[IEEE80211_AC_BK].queue_id = HIF_QUEUE_ID_BESTEFFORT; @@ -1526,7 +1527,6 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mutex_unlock(&wdev->conf_mutex); hif_set_macaddr(wvif, vif->addr); - BUG_ON(ARRAY_SIZE(default_edca_params) != ARRAY_SIZE(wvif->edca.params)); for (i = 0; i < IEEE80211_NUM_ACS; i++) { memcpy(&wvif->edca.params[i], &default_edca_params[i], sizeof(default_edca_params[i])); wvif->edca.uapsd_enable[i] = false;