aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Roskin <proski@gnu.org>2007-06-13 21:11:06 -0400
committerGuido Guenther <agx@sigxcpu.org>2007-06-14 10:11:07 +0200
commit66eecc9d6348e934e51bf51a86e63e5502473c33 (patch)
treee8f5d750cea54f8d8ab328bd40497f10a87c0167
parent3e0e4421eb69816e0518e8843065055dc7a88750 (diff)
[PATCH] Simplify dumping hex data
Use rotating buffer pool in mac2str() and hex2str(). This makes it unnecessary to allocate any buffers for either function, and also allows to use mac2str() more than once in the same expression. Move mac2str() and hex2str() closer together. Replace hex2str() with mac2str() where appropriate. For other hex2str() calls, always use "-" separator to improve readability. Check buffer length in hex2str(). Reformat some expressions along the way. Signed-off-by: Pavel Roskin <proski@gnu.org>
-rw-r--r--at76_usb.c316
-rw-r--r--at76_usb.h1
2 files changed, 134 insertions, 183 deletions
diff --git a/at76_usb.c b/at76_usb.c
index 5039288..edc002b 100644
--- a/at76_usb.c
+++ b/at76_usb.c
@@ -486,63 +486,48 @@ static inline void at76_iwevent_bss_disconnect(struct net_device *netdev)
}
-#define BIN2HEX(x) ((x) < 10 ? '0'+(x) : (x)+'A'-10)
+#define HEX2STR_BUFFERS 4
+#define HEX2STR_MAX_LEN 64
+#define BIN2HEX(x) ((x) < 10 ? '0' + (x) : (x) + 'A' - 10)
-/* hexdump len many bytes from buf into obuf, separated by delim,
- add a trailing \0 into obuf */
-static char *hex2str(char *obuf, void *buf, int len, char delim)
+/* Convert binary data into hex string */
+static char *hex2str(void *buf, int len)
{
+ static atomic_t a = ATOMIC_INIT(0);
+ static char bufs[3 * HEX2STR_MAX_LEN + 1][HEX2STR_BUFFERS];
+ char *ret = bufs[atomic_inc_return(&a) & (HEX2STR_BUFFERS - 1)];
+ char *obuf = ret;
u8 *ibuf = buf;
- char *ret = obuf;
+
+ if (len > HEX2STR_MAX_LEN)
+ len = HEX2STR_MAX_LEN;
+
+ if (len <= 0) {
+ ret[0] = '\0';
+ return ret;
+ }
while (len--) {
*obuf++ = BIN2HEX(*ibuf >> 4);
*obuf++ = BIN2HEX(*ibuf & 0xf);
- if (delim != '\0')
- *obuf++ = delim;
+ *obuf++ = '-';
ibuf++;
}
- if (delim != '\0' && obuf > ret)
- obuf--; /* remove last inserted delimiter */
- *obuf = '\0';
+ *(--obuf) = '\0';
return ret;
}
-/* check if the given ssid is cloaked */
-static inline int at76_is_cloaked_ssid(u8 *ssid, int length)
-{
- static const u8 zeros[32];
-
- return (length == 0) ||
- (length == 1 && *ssid == ' ') ||
- (length > 0 && !memcmp(ssid, zeros, length));
-}
-
-
-static inline void at76_free_bss_list(struct at76_priv *priv)
-{
- struct list_head *next, *ptr;
- unsigned long flags;
-
- spin_lock_irqsave(&priv->bss_list_spinlock, flags);
-
- priv->curr_bss = priv->new_bss = NULL;
-
- list_for_each_safe(ptr, next, &priv->bss_list) {
- list_del(ptr);
- kfree(list_entry(ptr, struct bss_info, list));
- }
-
- spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
-}
-
+#define MAC2STR_BUFFERS 4
static inline char *mac2str(u8 *mac)
{
- static char str[6 * 3];
+ static atomic_t a = ATOMIC_INIT(0);
+ static char bufs[6 * 3][MAC2STR_BUFFERS];
+ char *str;
+ str = bufs[atomic_inc_return(&a) & (MAC2STR_BUFFERS - 1)];
sprintf(str, "%02x:%02x:%02x:%02x:%02x:%02x",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
return str;
@@ -578,6 +563,35 @@ static void at76_ledtrig_tx_activity(void)
}
+/* check if the given ssid is cloaked */
+static inline int at76_is_cloaked_ssid(u8 *ssid, int length)
+{
+ static const u8 zeros[32];
+
+ return (length == 0) ||
+ (length == 1 && *ssid == ' ') ||
+ (length > 0 && !memcmp(ssid, zeros, length));
+}
+
+
+static inline void at76_free_bss_list(struct at76_priv *priv)
+{
+ struct list_head *next, *ptr;
+ unsigned long flags;
+
+ spin_lock_irqsave(&priv->bss_list_spinlock, flags);
+
+ priv->curr_bss = priv->new_bss = NULL;
+
+ list_for_each_safe(ptr, next, &priv->bss_list) {
+ list_del(ptr);
+ kfree(list_entry(ptr, struct bss_info, list));
+ }
+
+ spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
+}
+
+
static int at76_remap(struct usb_device *udev)
{
int ret;
@@ -1144,8 +1158,7 @@ static int at76_dump_mib_mac_addr(struct at76_priv *priv)
dbg("%s: MIB MAC_ADDR: mac_addr %s res 0x%x 0x%x group_addr %s status %d %d %d %d",
priv->netdev->name, mac2str(mac_addr->mac_addr),
mac_addr->res[0], mac_addr->res[1],
- hex2str(priv->obuf, mac_addr->group_addr,
- min((int)(sizeof(priv->obuf)-1)/2, 4*ETH_ALEN), '\0'),
+ hex2str(mac_addr->group_addr, 4 * ETH_ALEN),
mac_addr->group_addr_status[0], mac_addr->group_addr_status[1],
mac_addr->group_addr_status[2], mac_addr->group_addr_status[3]);
@@ -1174,25 +1187,16 @@ static int at76_dump_mib_mac_wep(struct at76_priv *priv)
}
dbg("%s: MIB MAC_WEP: priv_invoked %u def_key_id %u key_len %u "
- "excl_unencr %u wep_icv_err %u wep_excluded %u encr_level %u key %d: %s",
- priv->netdev->name, mac_wep->privacy_invoked,
- mac_wep->wep_default_key_id, mac_wep->wep_key_mapping_len,
- mac_wep->exclude_unencrypted,
- le32_to_cpu(mac_wep->wep_icv_error_count),
- le32_to_cpu(mac_wep->wep_excluded_count),
- mac_wep->encryption_level, mac_wep->wep_default_key_id,
- mac_wep->wep_default_key_id < 4 ? hex2str(priv->obuf,
- mac_wep->
- wep_default_keyvalue
- [mac_wep->
- wep_default_key_id],
- min((int)
- (sizeof(priv->obuf)
- - 1) / 2,
- mac_wep->
- encryption_level ==
- 2 ? 13 : 5),
- '\0') :
+ "excl_unencr %u wep_icv_err %u wep_excluded %u encr_level %u key %d: %s",
+ priv->netdev->name, mac_wep->privacy_invoked,
+ mac_wep->wep_default_key_id, mac_wep->wep_key_mapping_len,
+ mac_wep->exclude_unencrypted,
+ le32_to_cpu(mac_wep->wep_icv_error_count),
+ le32_to_cpu(mac_wep->wep_excluded_count),
+ mac_wep->encryption_level, mac_wep->wep_default_key_id,
+ mac_wep->wep_default_key_id < 4 ?
+ hex2str(mac_wep->wep_default_keyvalue[mac_wep->wep_default_key_id],
+ mac_wep->encryption_level == 2 ? 13 : 5) :
"<invalid key id>");
err:
@@ -1241,9 +1245,7 @@ static int at76_dump_mib_mac_mgmt(struct at76_priv *priv)
mac_mgmt->DTIM_period,
mac_mgmt->CFP_period,
mac2str(mac_mgmt->current_bssid),
- hex2str(priv->obuf, mac_mgmt->current_essid,
- min((int)(sizeof(priv->obuf) - 1) / 2,
- IW_ESSID_MAX_SIZE), '\0'),
+ hex2str(mac_mgmt->current_essid, IW_ESSID_MAX_SIZE),
mac_mgmt->current_bss_type,
mac_mgmt->power_mgmt_mode,
mac_mgmt->ibss_change,
@@ -1295,9 +1297,7 @@ static int at76_dump_mib_mac(struct at76_priv *priv)
le16_to_cpu(mac->min_channel_time),
le16_to_cpu(mac->max_channel_time),
le16_to_cpu(mac->listen_interval),
- hex2str(priv->obuf, mac->desired_ssid,
- min((int)(sizeof(priv->obuf) - 1) / 2,
- IW_ESSID_MAX_SIZE), '\0'),
+ hex2str(mac->desired_ssid, IW_ESSID_MAX_SIZE),
mac2str(mac->desired_bssid), mac->desired_bsstype);
err:
kfree(mac);
@@ -1405,22 +1405,22 @@ static int at76_get_mib_mdomain(struct at76_priv *priv, struct mib_mdomain *val)
static void at76_dump_mib_mdomain(struct at76_priv *priv)
{
- char obuf1[2*14+1], obuf2[2*14+1]; /* to hexdump tx_powerlevel,
- channel_list */
int ret;
struct mib_mdomain mdomain;
- if ((ret=at76_get_mib_mdomain(priv, &mdomain)) < 0) {
+ ret = at76_get_mib_mdomain(priv, &mdomain);
+ if (ret < 0) {
err("%s: at76_get_mib_mdomain returned %d", __FUNCTION__, ret);
return;
}
- at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: channel_list %s tx_powerlevel %s",
+ at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: channel_list %s",
+ priv->netdev->name,
+ hex2str(mdomain.channel_list, sizeof(mdomain.channel_list)));
+
+ at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: tx_powerlevel %s",
priv->netdev->name,
- hex2str(obuf1, mdomain.channel_list,
- (sizeof(obuf1) - 1) / 2, '\0'),
- hex2str(obuf2, mdomain.tx_powerlevel,
- (sizeof(obuf2) - 1) / 2, '\0'));
+ hex2str(mdomain.tx_powerlevel, sizeof(mdomain.tx_powerlevel)));
}
@@ -1740,8 +1740,7 @@ static int at76_send_mgmt_bulk(struct at76_priv *priv,
implement a queue or silently modify the old msg */
err("%s: %s removed pending mgmt buffer %s",
priv->netdev->name, __FUNCTION__,
- hex2str(priv->obuf, priv->next_mgmt_bulk,
- min((int)(sizeof(priv->obuf)) / 3, 64), ' '));
+ hex2str(priv->next_mgmt_bulk, 64));
kfree(priv->next_mgmt_bulk);
}
@@ -1758,9 +1757,7 @@ static int at76_send_mgmt_bulk(struct at76_priv *priv,
at76_dbg(DBG_TX_MGMT, "%s: tx mgmt: wlen %d tx_rate %d pad %d %s",
priv->netdev->name, le16_to_cpu(txbuf->wlength),
txbuf->tx_rate, txbuf->padding,
- hex2str(priv->obuf, txbuf->packet,
- min((sizeof(priv->obuf) - 1) / 2,
- (size_t) le16_to_cpu(txbuf->wlength)), '\0'));
+ hex2str(txbuf->packet, le16_to_cpu(txbuf->wlength)));
/* txbuf was not consumed above -> send mgmt msg immediately */
memcpy(priv->bulk_out_buffer, txbuf,
@@ -1841,8 +1838,7 @@ static int at76_auth_req(struct at76_priv *priv, struct bss_info *bss,
if (seq_nr == 3) {
at76_dbg(DBG_TX_MGMT, "%s: AuthReq challenge: %s ...",
priv->netdev->name,
- hex2str(priv->obuf, req->info_element,
- min((int)sizeof(priv->obuf) / 3, 18), ' '));
+ hex2str(req->info_element, 18));
}
/* either send immediately (if no data tx is pending
@@ -1857,6 +1853,8 @@ static int at76_assoc_req(struct at76_priv *priv, struct bss_info *bss)
struct ieee80211_hdr_3addr *mgmt;
struct ieee80211_assoc_request *req;
struct ieee80211_info_element *tlv;
+ char essid[IW_ESSID_MAX_SIZE + 1];
+ int len;
at76_assert(bss != NULL);
@@ -1903,22 +1901,16 @@ static int at76_assoc_req(struct at76_priv *priv, struct bss_info *bss)
/* init. at76_priv tx header */
tx_buffer->wlength = cpu_to_le16((u8 *) tlv - (u8 *) mgmt);
- {
- /* output buffer for ssid and rates */
- char orates[4 * 2 + 1];
- int len;
-
- tlv = req->info_element;
- len = min_t(int, IW_ESSID_MAX_SIZE, tlv->len);
- memcpy(priv->obuf, tlv->data, len);
- priv->obuf[len] = '\0';
- next_ie(&tlv); /* points to IE of rates now */
- at76_dbg(DBG_TX_MGMT, "%s: AssocReq bssid %s capa x%04x ssid %s rates %s",
- priv->netdev->name, mac2str(mgmt->addr3),
- le16_to_cpu(req->capability), priv->obuf,
- hex2str(orates,tlv->data,min((sizeof(orates)-1)/2,(size_t)tlv->len),
- '\0'));
- }
+ tlv = req->info_element;
+ len = min_t(int, IW_ESSID_MAX_SIZE, tlv->len);
+ memcpy(essid, tlv->data, len);
+ essid[len] = '\0';
+ next_ie(&tlv); /* points to IE of rates now */
+ at76_dbg(DBG_TX_MGMT,
+ "%s: AssocReq bssid %s capa x%04x ssid %s rates %s",
+ priv->netdev->name, mac2str(mgmt->addr3),
+ le16_to_cpu(req->capability), essid,
+ hex2str(tlv->data, tlv->len));
/* either send immediately (if no data tx is pending
or put it in pending list */
@@ -1935,6 +1927,8 @@ static int at76_reassoc_req(struct at76_priv *priv, struct bss_info *curr_bss,
struct ieee80211_hdr_3addr *mgmt;
struct ieee80211_reassoc_request *req;
struct ieee80211_info_element *tlv;
+ char essid[IW_ESSID_MAX_SIZE + 1];
+ int len;
at76_assert(curr_bss != NULL);
at76_assert(new_bss != NULL);
@@ -1986,21 +1980,16 @@ static int at76_reassoc_req(struct at76_priv *priv, struct bss_info *curr_bss,
/* init. at76_priv tx header */
tx_buffer->wlength = cpu_to_le16((u8 *)tlv-(u8 *)mgmt);
- {
- /* output buffer for rates and bssid */
- char orates[4*2+1];
- char ocurr[6*3+1];
- tlv = req->info_element;
- memcpy(priv->obuf, tlv->data, min(sizeof(priv->obuf),(size_t)tlv->len));
- priv->obuf[IW_ESSID_MAX_SIZE] = '\0';
- next_ie(&tlv); /* points to IE of rates now */
- at76_dbg(DBG_TX_MGMT, "%s: ReAssocReq curr %s new %s capa x%04x ssid %s rates %s",
- priv->netdev->name,
- hex2str(ocurr, req->current_ap, ETH_ALEN, ':'),
- mac2str(mgmt->addr3), le16_to_cpu(req->capability), priv->obuf,
- hex2str(orates,tlv->data,min((sizeof(orates)-1)/2,(size_t)tlv->len),
- '\0'));
- }
+ tlv = req->info_element;
+ len = min_t(int, IW_ESSID_MAX_SIZE, tlv->len);
+ memcpy(essid, tlv->data, len);
+ essid[len] = '\0';
+ next_ie(&tlv); /* points to IE of rates now */
+ at76_dbg(DBG_TX_MGMT,
+ "%s: ReAssocReq curr %s new %s capa x%04x ssid %s rates %s",
+ priv->netdev->name, mac2str(req->current_ap),
+ mac2str(mgmt->addr3), le16_to_cpu(req->capability), essid,
+ hex2str(tlv->data, tlv->len));
/* either send immediately (if no data tx is pending
or put it in pending list */
@@ -2090,7 +2079,6 @@ static void at76_dump_bss_table(struct at76_priv *priv)
struct bss_info *ptr;
unsigned long flags;
struct list_head *lptr;
- char obuf_s[3*32];
spin_lock_irqsave(&priv->bss_list_spinlock, flags);
@@ -2104,13 +2092,9 @@ static void at76_dump_bss_table(struct at76_priv *priv)
ptr, mac2str(ptr->bssid),
ptr->channel,
ptr->ssid,
- hex2str(priv->obuf, ptr->ssid,
- min((sizeof(priv->obuf) - 1) / 2,
- (size_t) ptr->ssid_len), '\0'),
+ hex2str(ptr->ssid, ptr->ssid_len),
ptr->capa,
- hex2str(obuf_s, ptr->rates,
- min(sizeof(obuf_s) / 3,
- (size_t) ptr->rates_len), ' '),
+ hex2str(ptr->rates, ptr->rates_len),
ptr->rssi, ptr->link_qual, ptr->noise_level);
}
spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
@@ -2166,17 +2150,15 @@ static void at76_handle_mgmt_timeout_scan(struct at76_priv *priv)
case 1:
at76_assert(priv->international_roaming);
- if ((ret=at76_get_mib_mdomain(priv, &mdomain)) < 0) {
+ if ((ret = at76_get_mib_mdomain(priv, &mdomain)) < 0) {
err("at76_get_mib_mdomain returned %d", ret);
} else {
- char obuf1[2*14+1], obuf2[2*14+1];
-
at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: channel_list %s "
"tx_powerlevel %s", priv->netdev->name,
- hex2str(obuf1, mdomain.channel_list,
- (sizeof(obuf1) - 1) / 2, '\0'),
- hex2str(obuf2, mdomain.tx_powerlevel,
- (sizeof(obuf2) - 1) / 2, '\0'));
+ hex2str(mdomain.channel_list,
+ sizeof(mdomain.channel_list)),
+ hex2str(mdomain.tx_powerlevel,
+ sizeof(mdomain.tx_powerlevel)));
}
if ((ret = at76_start_scan(priv, 0, 1)) < 0) {
err("%s: %s: start_scan (ANY) failed with %d",
@@ -3828,21 +3810,15 @@ static int at76_tx(struct sk_buff *skb, struct net_device *netdev)
tx_buffer->padding = at76_calc_padding(wlen);
submit_len = wlen + AT76_TX_HDRLEN + tx_buffer->padding;
- {
- at76_dbg(DBG_TX_DATA_CONTENT, "%s skb->data %s", priv->netdev->name,
- hex2str(priv->obuf, skb->data,
- min((int)(sizeof(priv->obuf) - 1) / 2, 32), '\0'));
- at76_dbg(DBG_TX_DATA, "%s tx wlen x%x pad x%x rate %d hdr %s",
- priv->netdev->name,
- le16_to_cpu(tx_buffer->wlength),
- tx_buffer->padding, tx_buffer->tx_rate,
- hex2str(priv->obuf, i802_11_hdr,
- min((sizeof(priv->obuf) - 1) / 2,
- sizeof(struct ieee80211_hdr_3addr)), '\0'));
- at76_dbg(DBG_TX_DATA_CONTENT, "%s payload %s", priv->netdev->name,
- hex2str(priv->obuf, payload,
- min((int)(sizeof(priv->obuf) - 1) / 2, 48), '\0'));
- }
+ at76_dbg(DBG_TX_DATA_CONTENT, "%s skb->data %s", priv->netdev->name,
+ hex2str(skb->data, 32));
+ at76_dbg(DBG_TX_DATA, "%s tx wlen x%x pad x%x rate %d hdr %s",
+ priv->netdev->name,
+ le16_to_cpu(tx_buffer->wlength),
+ tx_buffer->padding, tx_buffer->tx_rate,
+ hex2str(i802_11_hdr, sizeof(*i802_11_hdr)));
+ at76_dbg(DBG_TX_DATA_CONTENT, "%s payload %s", priv->netdev->name,
+ hex2str(payload, 48));
/* send stuff */
netif_stop_queue(netdev);
@@ -4612,9 +4588,7 @@ static int at76_startup_device(struct at76_priv *priv)
dbg("%s param: ssid %s (%s) mode %s ch %d wep %s key %d keylen %d",
priv->netdev->name, ossid,
- hex2str(priv->obuf, priv->essid,
- min((int)(sizeof(priv->obuf)-1)/2,
- IW_ESSID_MAX_SIZE), '\0'),
+ hex2str(priv->essid, IW_ESSID_MAX_SIZE),
priv->iw_mode == IW_MODE_ADHOC ? "adhoc" : "infra",
priv->channel,
priv->wep_enabled ? "enabled" : "disabled",
@@ -4822,9 +4796,9 @@ static void at76_rx_mgmt_assoc(struct at76_priv *priv,
u16 capa = le16_to_cpu(resp->capability);
at76_dbg(DBG_RX_MGMT, "%s: rx AssocResp bssid %s capa x%04x status x%04x "
"assoc_id x%04x rates %s",
- priv->netdev->name, mac2str(mgmt->addr3), capa, status, assoc_id,
- hex2str(priv->obuf, resp->info_element->data,
- min((size_t)resp->info_element->len, (sizeof(priv->obuf)-1)/2), '\0'));
+ priv->netdev->name, mac2str(mgmt->addr3), capa, status,
+ assoc_id, hex2str(resp->info_element->data,
+ resp->info_element->len));
if (priv->istate == ASSOCIATING) {
at76_assert(priv->curr_bss != NULL);
if (priv->curr_bss == NULL)
@@ -4865,9 +4839,7 @@ static void at76_rx_mgmt_reassoc(struct at76_priv *priv,
at76_dbg(DBG_RX_MGMT, "%s: rx ReAssocResp bssid %s capa x%04x status x%04x "
"assoc_id x%04x rates %s",
priv->netdev->name, mac2str(mgmt->addr3), capa, status, assoc_id,
- hex2str(priv->obuf, resp->info_element->data,
- min((size_t) resp->info_element->len,
- (sizeof(priv->obuf) - 1) / 2), '\0'));
+ hex2str(resp->info_element->data, resp->info_element->len));
if (priv->istate == REASSOCIATING) {
at76_assert(priv->new_bss != NULL);
if (priv->new_bss == NULL)
@@ -4915,8 +4887,7 @@ static void at76_rx_mgmt_disassoc(struct at76_priv *priv,
at76_dbg(DBG_RX_MGMT, "%s: rx DisAssoc bssid %s reason x%04x destination %s",
priv->netdev->name, mac2str(mgmt->addr3),
le16_to_cpu(resp->reason),
- hex2str(priv->obuf, mgmt->addr1,
- min((int)sizeof(priv->obuf) / 3, ETH_ALEN), ':'));
+ mac2str(mgmt->addr1));
if (priv->istate == SCANNING || priv->istate == INIT)
return;
@@ -4968,15 +4939,12 @@ static void at76_rx_mgmt_auth(struct at76_priv *priv, struct at76_rx_buffer *buf
at76_dbg(DBG_RX_MGMT, "%s: rx AuthFrame bssid %s alg %d seq_nr %d status %d "
"destination %s",
priv->netdev->name, mac2str(mgmt->addr3),
- alg, seq_nr, status,
- hex2str(priv->obuf, mgmt->addr1,
- min((int)sizeof(priv->obuf) / 3, ETH_ALEN), ':'));
+ alg, seq_nr, status, mac2str(mgmt->addr1));
if (alg == WLAN_AUTH_SHARED_KEY && seq_nr == 2) {
at76_dbg(DBG_RX_MGMT, "%s: AuthFrame challenge %s ...",
priv->netdev->name,
- hex2str(priv->obuf, resp->info_element,
- min((int)sizeof(priv->obuf) / 3, 18), ' '));
+ hex2str(resp->info_element, 18));
}
if (priv->istate != AUTHENTICATING) {
info("%s: ignored AuthFrame in state %d",
@@ -5036,8 +5004,7 @@ static void at76_rx_mgmt_deauth(struct at76_priv *priv,
"%s: rx DeAuth bssid %s reason x%04x destination %s",
priv->netdev->name, mac2str(mgmt->addr3),
le16_to_cpu(resp->reason),
- hex2str(priv->obuf, mgmt->addr1,
- min((int)sizeof(priv->obuf) / 3, ETH_ALEN), ':'));
+ mac2str(mgmt->addr1));
if (priv->istate == DISASSOCIATING ||
priv->istate == AUTHENTICATING ||
priv->istate == ASSOCIATING ||
@@ -5200,9 +5167,7 @@ static void at76_rx_mgmt_beacon(struct at76_priv *priv,
at76_dbg(DBG_RX_BEACON,
"%s: SUPPORTED RATES %s",
priv->netdev->name,
- hex2str(priv->obuf, tlv->data,
- min_t(int, (sizeof(priv->obuf)-1)/2,
- tlv->len), '\0'));
+ hex2str(tlv->data, tlv->len));
}
break;
@@ -5221,9 +5186,7 @@ static void at76_rx_mgmt_beacon(struct at76_priv *priv,
default:
at76_dbg(DBG_RX_BEACON, "%s: beacon IE id %d len %d %s",
priv->netdev->name, tlv->id, tlv->len,
- hex2str(priv->obuf, tlv->data,
- min_t(int, (sizeof(priv->obuf)-1)/2,
- tlv->len), '\0'));
+ hex2str(tlv->data, tlv->len));
break;
}
@@ -5337,9 +5300,7 @@ static void at76_rx_mgmt(struct at76_priv *priv, struct at76_rx_buffer *buf)
at76_dbg(DBG_RX_MGMT_CONTENT, "%s rx mgmt subtype x%x %s",
priv->netdev->name, subtype,
- hex2str(priv->obuf, mgmt,
- min((sizeof(priv->obuf) - 1) / 2,
- (size_t) le16_to_cpu(buf->wlength)), '\0'));
+ hex2str(mgmt, le16_to_cpu(buf->wlength)));
switch (subtype) {
case IEEE80211_STYPE_BEACON:
@@ -5413,8 +5374,7 @@ static void at76_ieee80211_to_eth(struct sk_buff *skb, int iw_mode)
i802_11_hdr = (struct ieee80211_hdr_3addr *)skb->data;
dbg("%s: ENTRY skb len %d data %s", __FUNCTION__,
- skb->len, hex2str(priv->obuf, skb->data,
- min((int)sizeof(priv->obuf) / 3, 64), ' '));
+ skb->len, hex2str(skb->data, 64));
skb_pull(skb, sizeof(struct ieee80211_hdr_3addr));
@@ -5478,15 +5438,9 @@ static void at76_ieee80211_to_eth(struct sk_buff *skb, int iw_mode)
skb->protocol = htons(ETH_P_802_2);
}
-#ifdef DEBUG
- char da[3*ETH_ALEN], sa[3*ETH_ALEN];
-#endif
dbg("%s: EXIT skb da %s sa %s proto x%04x len %d data %s", __FUNCTION__,
- hex2str(da, eth_hdr(skb)->h_dest, ETH_ALEN, ':'),
- hex2str(sa, eth_hdr(skb)->h_source, ETH_ALEN, ':'),
- ntohs(skb->protocol), skb->len,
- hex2str(priv->obuf, skb->data,
- min((int)sizeof(priv->obuf)/3,64), ' '));
+ mac2str(eth_hdr(skb)->h_dest), mac2str(eth_hdr(skb)->h_source),
+ ntohs(skb->protocol), skb->len, hex2str(skb->data, 64));
}
@@ -5528,8 +5482,7 @@ static struct sk_buff *at76_check_for_rx_frags(struct at76_priv *priv)
priv->netdev->name, frame_ctl,
mac2str(i802_11_hdr->addr2),
seqnr, fragnr, length, data_len,
- hex2str(priv->obuf, data,
- min((int)(sizeof(priv->obuf) - 1) / 2, 32), '\0'));
+ hex2str(data, 32));
at76_dbg(DBG_RX_FRAGS_SKB, "%s: incoming skb: head %p data %p "
"tail %p end %p len %d", priv->netdev->name, skb->head,
@@ -5889,8 +5842,7 @@ static void at76_rx_tasklet(unsigned long param)
priv->netdev->name,
buf->rx_rate, buf->rssi, buf->noise_level,
buf->link_quality,
- hex2str(priv->obuf, i802_11_hdr,
- min((int)(sizeof(priv->obuf)-1)/2,48),'\0'));
+ hex2str(i802_11_hdr, 48));
if (priv->istate == MONITORING) {
at76_rx_monitor_mode(priv);
goto finish;
diff --git a/at76_usb.h b/at76_usb.h
index 396dfc4..2a292b5 100644
--- a/at76_usb.h
+++ b/at76_usb.h
@@ -582,7 +582,6 @@ struct at76_priv {
struct fwentry *fwe;
unsigned int device_unplugged:1;
unsigned int netdev_registered:1;
- char obuf[2 * 256 + 1]; /* global debug output buffer to reduce stack usage */
struct set_mib_buffer mib_buf; /* global buffer for set_mib calls */
/* beacon counting */