Skip to contentSkip to conversation

d80211: Make MACSTR/MAC2STR macro available to drivers

PATCH In review Michael Wu 3 participants 5 messages Jul 23, 2006 – Jul 24, 2006

Subsystems (3)
lore
Share & tools
lore

Michael Wu

author
#0 lore raw

PATCH 1/1 d80211: Make MACSTR/MAC2STR macro available to drivers

d80211: Make MACSTR/MAC2STR macro available to drivers

This patch moves the MACSTR/MAC2STR macros to d80211.h so that they are available to drivers. It also converts the adm8211 and bcm43xx drivers to use this macro.

---

 drivers/net/wireless/d80211/adm8211/adm8211.c      |    7 ++-----
 drivers/net/wireless/d80211/bcm43xx/bcm43xx.h      |    6 ------
 drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c |    8 ++++----
 drivers/net/wireless/d80211/bcm43xx/bcm43xx_xmit.c |    4 ++--
 include/net/d80211.h                               |    4 ++++
 net/d80211/ieee80211_i.h                           |    5 -----
 6 files changed, 12 insertions(+), 22 deletions(-)
drivers/net/wireless/d80211/adm8211/adm8211.c +2 -5
index be4a058..0a762d7 100644
@@ -74,9 +74,6 @@ #define PLCP_SIGNAL_2M		0x14
 #define PLCP_SIGNAL_5M5		0x37
 #define PLCP_SIGNAL_11M		0x6e
 
-#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
-#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
-
 struct adm8211_tx_hdr {
 	u8 da[6];
 	u8 signal; /* PLCP signal / TX rate in 100 Kbps */
@@ -2085,8 +2082,8 @@ #endif
 		goto err_free_desc;
 	}
 
-	printk("%s: hwaddr " MAC_FMT ", Rev 0x%02x\n",
-	       dev->name, MAC_ARG(dev->dev_addr), priv->revid);
+	printk("%s: hwaddr " MACSTR ", Rev 0x%02x\n",
+	       dev->name, MAC2STR(dev->dev_addr), priv->revid);
 
 	return 0;
 
drivers/net/wireless/d80211/bcm43xx/bcm43xx.h +0 -6
index af4bb46..91a98a9 100644
@@ -991,10 +991,4 @@ #define limit_value(value, min, max)  \
 	 	__value;				\
 	})
 
-/** Helpers to print MAC addresses. */
-#define BCM43xx_MACFMT		"%02x:%02x:%02x:%02x:%02x:%02x"
-#define BCM43xx_MACARG(x)	((u8*)(x))[0], ((u8*)(x))[1], \
-				((u8*)(x))[2], ((u8*)(x))[3], \
-				((u8*)(x))[4], ((u8*)(x))[5]
-
 #endif /* BCM43xx_H_ */
drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c +4 -4
index b6425e3..82985f2 100644
@@ -4561,9 +4561,9 @@ static int bcm43xx_add_interface(struct 
 
 	dprintk(KERN_INFO PFX "Virtual interface added "
 			      "(type: 0x%08X, ID: %d, MAC: "
-			      BCM43xx_MACFMT ")\n",
+			      MACSTR ")\n",
 		conf->type, conf->if_id,
-		BCM43xx_MACARG(conf->mac_addr));
+		MAC2STR(conf->mac_addr));
 
 out_unlock:
 	bcm43xx_unlock_irqsafe(bcm, flags);
@@ -4589,9 +4589,9 @@ static void bcm43xx_remove_interface(str
 
 	dprintk(KERN_INFO PFX "Virtual interface removed "
 			      "(type: 0x%08X, ID: %d, MAC: "
-			      BCM43xx_MACFMT ")\n",
+			      MACSTR ")\n",
 		conf->type, conf->if_id,
-		BCM43xx_MACARG(conf->mac_addr));
+		MAC2STR(conf->mac_addr));
 }
 
 static int bcm43xx_config_interface(struct net_device *net_dev,
drivers/net/wireless/d80211/bcm43xx/bcm43xx_xmit.c +2 -2
index 562c6a1..6ebe9fa 100644
@@ -259,8 +259,8 @@ assert(dur);
 
 	txhdr->rts_cts_frame_control = cpu_to_le16(fctl);
 	txhdr->rts_cts_dur = cpu_to_le16(dur);
-//printk(BCM43xx_MACFMT "  " BCM43xx_MACFMT "  " BCM43xx_MACFMT "\n", BCM43xx_MACARG(wlhdr->addr1), BCM43xx_MACARG(wlhdr->addr2), BCM43xx_MACARG(wlhdr->addr3));
-//printk(BCM43xx_MACFMT "  " BCM43xx_MACFMT "\n", BCM43xx_MACARG(sa), BCM43xx_MACARG(da));
+//printk(MACSTR "  " MACSTR "  " MACSTR "\n", MAC2STR(wlhdr->addr1), MAC2STR(wlhdr->addr2), MAC2STR(wlhdr->addr3));
+//printk(MACSTR "  " MACSTR "\n", MAC2STR(sa), MAC2STR(da));
 	memcpy(txhdr->rts_cts_mac1, wlhdr->addr1, ETH_ALEN);//FIXME!
 	memcpy(txhdr->rts_cts_mac2, sa, ETH_ALEN);
 
include/net/d80211.h +4 -0
index e6dcb0e..b9d4b24 100644
@@ -999,4 +999,8 @@ static inline int ieee80211_get_morefrag
 	return (le16_to_cpu(hdr->frame_control) & WLAN_FC_MOREFRAG) != 0;
 }
 
+#define MAC2STR(a) ((a)[0] & 0xff), ((a)[1] & 0xff), ((a)[2] & 0xff), \
+		   ((a)[3] & 0xff), ((a)[4] & 0xff), ((a)[5] & 0xff)
+#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
+
 #endif /* D80211_H */
net/d80211/ieee80211_i.h +0 -5
index 691edd0..df8a43e 100644
@@ -46,11 +46,6 @@ #define AP_MAX_BC_BUFFER 128
 #define TOTAL_MAX_TX_BUFFER 512
 
 
-#define MAC2STR(a) ((a)[0] & 0xff), ((a)[1] & 0xff), ((a)[2] & 0xff), \
-		   ((a)[3] & 0xff), ((a)[4] & 0xff), ((a)[5] & 0xff)
-#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
-
-
 /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
  * reception of at least three fragmented frames. This limit can be increased
  * by changing this define, at the cost of slower frame reassembly and
#1 lore raw
Quoted 5 lines · Michael Wu

d80211: Make MACSTR/MAC2STR macro available to drivers

This patch moves the MACSTR/MAC2STR macros to d80211.h so that they are available to drivers. It also converts the adm8211 and bcm43xx drivers to use this macro.

I'd say d80211.h is still the wrong place for this. What about etherdevice.h?

Signature · 1 line
Greetings Michael.
author
#2 lore raw
Quoted 8 lines · Michael Buesch
Quoted 5 lines · Michael Wu

d80211: Make MACSTR/MAC2STR macro available to drivers

This patch moves the MACSTR/MAC2STR macros to d80211.h so that they are available to drivers. It also converts the adm8211 and bcm43xx drivers to use this macro.

I'd say d80211.h is still the wrong place for this.

But it's less wrong than before. :)

Quoted 1 line

What about etherdevice.h?

Sure, but I'll have to update many more drivers to make that happen. Using macros to print mac addrs seems to be mostly confined to wireless drivers at this point.

-Michael Wu

#3 lore raw
In reply to Michael Wu
Quoted 3 lines · Michael Wu

This patch moves the MACSTR/MAC2STR macros to d80211.h so that they are available to drivers. It also converts the adm8211 and bcm43xx drivers to use this macro.

I really dislike those MACSTR/MAC2STR names. I always fail to remember which one is which. What about renaming them when we are touching them?

And why not to use MAC_FMT/MAC_ARG names as used in net/ieee80211.h? ;-)

Thanks,

Jiri

Signature · 2 lines
Jiri Benc
SUSE Labs
author
#4 lore raw
Quoted 5 lines · Jiri Benc

I really dislike those MACSTR/MAC2STR names. I always fail to remember which one is which. What about renaming them when we are touching them?

And why not to use MAC_FMT/MAC_ARG names as used in net/ieee80211.h? ;-)

I dislike MACSTR/MAC2STR too, but I was trying to minimize changes to the d80211 code. I'll switch to MAC_FMT/MAC_ARG.

-Michael Wu