aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Roskin <proski@gnu.org>2007-07-12 02:53:34 -0400
committerGuido Guenther <agx@bogon.sigxcpu.org>2007-07-15 12:19:06 -0400
commit195f0fc6a8740c25cf2b4453e4189f02f1e01838 (patch)
tree9614174ddaf53f0ac5167b236dbdb3a275439e3a
parent8a755100a64f182efeb2e8dd367a16401f0b43b0 (diff)
[PATCH] Replace at76_assert with standard WARN_ON and BUG_ON macros
Signed-off-by: Pavel Roskin <proski@gnu.org>
-rw-r--r--at76_usb.c78
-rw-r--r--at76_usb.h6
2 files changed, 27 insertions, 57 deletions
diff --git a/at76_usb.c b/at76_usb.c
index 05d3b85..085c1c2 100644
--- a/at76_usb.c
+++ b/at76_usb.c
@@ -1473,7 +1473,7 @@ static int at76_start_ibss(struct at76_priv *priv)
struct at76_req_ibss bss;
int ret;
- at76_assert(priv->istate == STARTIBSS);
+ WARN_ON(priv->istate != STARTIBSS);
memset(&bss, 0, sizeof(struct at76_req_ibss));
memset(bss.bssid, 0xff, ETH_ALEN);
@@ -1526,7 +1526,7 @@ static int at76_join_bss(struct at76_priv *priv, struct bss_info *ptr)
{
struct at76_req_join join;
- at76_assert(ptr != NULL);
+ BUG_ON(ptr == NULL);
memset(&join, 0, sizeof(struct at76_req_join));
memcpy(join.bssid, ptr->bssid, ETH_ALEN);
@@ -1710,8 +1710,8 @@ static int at76_auth_req(struct at76_priv *priv, struct bss_info *bss,
int buf_len = (seq_nr != 3 ? AUTH_FRAME_SIZE :
AUTH_FRAME_SIZE + 1 + 1 + challenge->len);
- at76_assert(bss != NULL);
- at76_assert(seq_nr != 3 || challenge != NULL);
+ BUG_ON(bss == NULL);
+ BUG_ON(seq_nr == 3 && challenge == NULL);
tx_buffer = kmalloc(buf_len + MAX_PADDING_SIZE, GFP_ATOMIC);
if (!tx_buffer)
return -ENOMEM;
@@ -1763,7 +1763,7 @@ static int at76_assoc_req(struct at76_priv *priv, struct bss_info *bss)
int len;
u16 capa;
- at76_assert(bss != NULL);
+ BUG_ON(bss == NULL);
tx_buffer = kmalloc(ASSOCREQ_MAX_SIZE + MAX_PADDING_SIZE, GFP_ATOMIC);
if (!tx_buffer)
@@ -1839,8 +1839,8 @@ static int at76_reassoc_req(struct at76_priv *priv, struct bss_info *curr_bss,
int len;
int capa;
- at76_assert(curr_bss != NULL);
- at76_assert(new_bss != NULL);
+ BUG_ON(curr_bss == NULL);
+ BUG_ON(new_bss == NULL);
if (curr_bss == NULL || new_bss == NULL)
return -EFAULT;
@@ -1914,9 +1914,7 @@ static int at76_disassoc_req(struct at76_priv *priv, struct bss_info *bss)
struct ieee80211_hdr_3addr *mgmt;
struct ieee80211_disassoc *req;
- at76_assert(bss != NULL);
- if (bss == NULL)
- return -EFAULT;
+ BUG_ON(bss == NULL);
tx_buffer = kmalloc(DISASSOC_FRAME_SIZE + MAX_PADDING_SIZE, GFP_ATOMIC);
if (!tx_buffer)
@@ -2042,7 +2040,7 @@ static void at76_handle_mgmt_timeout_scan(struct at76_priv *priv)
switch (priv->scan_runs) {
case 1:
- at76_assert(priv->international_roaming);
+ WARN_ON(!priv->international_roaming);
ret = at76_get_mib_mdomain(priv, &mdomain);
if (ret < 0) {
err("at76_get_mib_mdomain returned %d", ret);
@@ -2102,10 +2100,9 @@ static void at76_work_assoc_done(struct work_struct *work)
mutex_lock(&priv->mtx);
- at76_assert(priv->istate == ASSOCIATING
- || priv->istate == REASSOCIATING);
+ WARN_ON(priv->istate != ASSOCIATING && priv->istate != REASSOCIATING);
if (priv->iw_mode == IW_MODE_INFRA) {
- at76_assert(priv->curr_bss != NULL);
+ WARN_ON(priv->curr_bss == NULL);
if (priv->curr_bss != NULL && priv->pm_mode != AT76_PM_OFF) {
/* calculate the listen interval in units of
beacon intervals of the curr_bss */
@@ -4265,7 +4262,7 @@ static void at76_work_join(struct work_struct *work)
if (priv->istate == INIT)
goto end_join;
- at76_assert(priv->istate == JOINING);
+ WARN_ON(priv->istate != JOINING);
/* priv->curr_bss == NULL signals a new round,
starting with list_entry(priv->bss_list.next, ...) */
@@ -4355,11 +4352,6 @@ static void at76_work_mgmt_timeout(struct work_struct *work)
at76_handle_mgmt_timeout_scan(priv);
break;
- case MONITORING:
- case JOINING:
- at76_assert(0);
- break;
-
case CONNECTED: /* we haven't received the beacon of this BSS for
BEACON_TIMEOUT seconds */
printk(KERN_INFO "%s: lost beacon bssid %s\n",
@@ -4440,7 +4432,8 @@ static void at76_work_mgmt_timeout(struct work_struct *work)
break;
default:
- at76_assert(0);
+ WARN_ON(1);
+ break;
}
mutex_unlock(&priv->mtx);
}
@@ -4490,7 +4483,7 @@ static int at76_startup_device(struct at76_priv *priv)
char ossid[IW_ESSID_MAX_SIZE + 1];
/* make priv->essid printable */
- at76_assert(priv->essid_size <= IW_ESSID_MAX_SIZE);
+ WARN_ON(priv->essid_size > IW_ESSID_MAX_SIZE);
memcpy(ossid, priv->essid, priv->essid_size);
ossid[priv->essid_size] = '\0';
@@ -4639,7 +4632,7 @@ static void at76_work_scan(struct work_struct *work)
mutex_lock(&priv->mtx);
- at76_assert(priv->istate == SCANNING);
+ WARN_ON(priv->istate != SCANNING);
/* only clear the bss list when a scan is actively initiated,
* otherwise simply rely on at76_bss_list_timeout */
if (priv->scan_state == SCAN_IN_PROGRESS)
@@ -4714,9 +4707,7 @@ static void at76_rx_mgmt_assoc(struct at76_priv *priv,
return;
}
- at76_assert(priv->curr_bss != NULL);
- if (priv->curr_bss == NULL)
- return;
+ BUG_ON(priv->curr_bss == NULL);
if (status == WLAN_STATUS_SUCCESS) {
struct bss_info *ptr = priv->curr_bss;
@@ -4757,9 +4748,7 @@ static void at76_rx_mgmt_reassoc(struct at76_priv *priv,
return;
}
- at76_assert(priv->new_bss != NULL);
- if (priv->new_bss == NULL)
- return;
+ BUG_ON(priv->new_bss == NULL);
if (status == WLAN_STATUS_SUCCESS) {
struct bss_info *bptr = priv->new_bss;
@@ -4802,14 +4791,8 @@ static void at76_rx_mgmt_disassoc(struct at76_priv *priv,
if (priv->istate == SCANNING || priv->istate == INIT)
return;
- at76_assert(priv->curr_bss != NULL);
- if (priv->curr_bss == NULL)
- return;
- if (priv->istate == REASSOCIATING) {
- at76_assert(priv->new_bss != NULL);
- if (priv->new_bss == NULL)
- return;
- }
+ BUG_ON(priv->curr_bss == NULL);
+ BUG_ON(priv->istate == REASSOCIATING && priv->new_bss == NULL);
/* Not our BSSID, ignore */
if (compare_ether_addr(mgmt->addr3, priv->curr_bss->bssid))
@@ -4870,9 +4853,7 @@ static void at76_rx_mgmt_auth(struct at76_priv *priv,
return;
}
- at76_assert(priv->curr_bss != NULL);
- if (priv->curr_bss == NULL)
- return;
+ BUG_ON(priv->curr_bss == NULL);
/* Not our BSSID or not for our STA, ignore */
if (compare_ether_addr(mgmt->addr3, priv->curr_bss->bssid)
@@ -4897,7 +4878,7 @@ static void at76_rx_mgmt_auth(struct at76_priv *priv,
return;
}
- at76_assert(seq_nr == 2);
+ WARN_ON(seq_nr != 2);
at76_auth_req(priv, priv->curr_bss, seq_nr + 1, resp->info_element);
at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer + HZ", __func__,
__LINE__);
@@ -4924,9 +4905,7 @@ static void at76_rx_mgmt_deauth(struct at76_priv *priv,
return;
}
- at76_assert(priv->curr_bss != NULL);
- if (priv->curr_bss == NULL)
- return;
+ BUG_ON(priv->curr_bss == NULL);
/* Not our BSSID, ignore */
if (compare_ether_addr(mgmt->addr3, priv->curr_bss->bssid))
@@ -4972,9 +4951,8 @@ static void at76_rx_mgmt_beacon(struct at76_priv *priv,
if (priv->istate == CONNECTED) {
/* in state CONNECTED we use the mgmt_timer to control
the beacon of the BSS */
- at76_assert(priv->curr_bss != NULL);
- if (priv->curr_bss == NULL)
- goto rx_mgmt_beacon_end;
+ BUG_ON(priv->curr_bss == NULL);
+
if (!compare_ether_addr(priv->curr_bss->bssid, mgmt->addr3)) {
/* We got our AP's beacon, defer the timeout handler.
Kill pending work first, as schedule_delayed_work()
@@ -5413,7 +5391,7 @@ static struct sk_buff *at76_check_for_rx_frags(struct at76_priv *priv)
return NULL;
}
- at76_assert(length > AT76_RX_HDRLEN);
+ WARN_ON(length <= AT76_RX_HDRLEN);
/* remove the at76_rx_buffer header - we don't need it anymore */
/* we need the IEEE802.11 header (for the addresses) if this packet
@@ -5545,10 +5523,8 @@ static struct sk_buff *at76_check_for_rx_frags(struct at76_priv *priv)
priv->netdev->name, fragnr);
return NULL;
}
- at76_assert(optr != NULL);
- if (optr == NULL)
- return NULL;
+ BUG_ON(optr == NULL);
if (optr->skb != NULL) {
/* swap the skb's */
skb = optr->skb;
diff --git a/at76_usb.h b/at76_usb.h
index 9980f05..afc4af0 100644
--- a/at76_usb.h
+++ b/at76_usb.h
@@ -663,10 +663,4 @@ struct at76_rx_radiotap {
printk(KERN_DEBUG DRIVER_NAME ": " format "\n" , ## arg); \
} while (0)
-#define at76_assert(x) \
- do { \
- if (!(x)) \
- err("%d: assertion " #x " failed", __LINE__); \
- } while (0)
-
#endif /* _AT76_USB_H */