Skip to contentSkip to conversation

rt2x00: add platform_data mac address

PATCH In review Daniel Golle 3 participants 3 messages Dec 11, 2012 – Jan 25, 2013 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 rt2x00: add platform_data mac address

drivers/net/wireless/rt2x00/rt2x00.h +1 -0
index c67e769..8b82e77 100644
@@ -1294,6 +1294,7 @@ static inline void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
  */
 u32 rt2x00lib_get_bssidx(struct rt2x00_dev *rt2x00dev,
 			 struct ieee80211_vif *vif);
+const u8 *rt2x00lib_get_mac_address(struct rt2x00_dev *rt2x00dev);
 
 /*
  * Interrupt context handlers.
drivers/net/wireless/rt2x00/rt2x00dev.c +12 -0
index b7856bf..f9868d1 100644
@@ -826,6 +826,18 @@ static void rt2x00lib_rate(struct ieee80211_rate *entry,
 		entry->flags |= IEEE80211_RATE_SHORT_PREAMBLE;
 }
 
+const u8 *rt2x00lib_get_mac_address(struct rt2x00_dev *rt2x00dev)
+{
+	struct rt2x00_platform_data *pdata;
+
+	pdata = rt2x00dev->dev->platform_data;
+	if (!pdata)
+		return NULL;
+
+	return pdata->mac_address;
+}
+EXPORT_SYMBOL_GPL(rt2x00lib_get_mac_address);
+
 static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
 				    struct hw_mode_spec *spec)
 {
drivers/net/wireless/rt2x00/rt61pci.c +5 -0
index f95792c..7dbc0ba 100644
@@ -2392,6 +2392,7 @@ static int rt61pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 	u32 reg;
 	u16 word;
 	u8 *mac;
+	const u8 *pdata_mac;
 	s8 value;
 
 	rt2x00pci_register_read(rt2x00dev, E2PROM_CSR, &reg);
@@ -2412,7 +2413,11 @@ static int rt61pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Start validation of the data that has been read.
 	 */
+	pdata_mac = rt2x00lib_get_mac_address(rt2x00dev);
 	mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
+	if (pdata_mac)
+		memcpy(mac, pdata_mac, 6);
+
 	if (!is_valid_ether_addr(mac)) {
 		eth_random_addr(mac);
 		EEPROM(rt2x00dev, "MAC: %pM\n", mac);
include/linux/rt2x00_platform.h +1 -0
index b4c7768..e10377e 100644
@@ -14,6 +14,7 @@
 
 struct rt2x00_platform_data {
 	char *eeprom_file_name;
+	const u8 *mac_address;
 
 	int disable_2ghz;
 	int disable_5ghz;
Signature · 1 line
1.8.0.1
#1 lore raw

Hi Daniel,

Quoted 2 lines · Daniel Golle

Again we need a proper patch description.

And for this patch I have the same question as for the previous patch: why do we need to arrange this via platform data, as opposed to using the standard user space ifconfig facility to set a mac address?

As a second question: why is this only implemented for rt61pci, and not the other PCI / SOC drivers?

---
Gertjan

Quoted 75 lines
drivers/net/wireless/rt2x00/rt2x00.h +1 -0
index c67e769..8b82e77 100644
@@ -1294,6 +1294,7 @@ static inline void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
 */
 u32 rt2x00lib_get_bssidx(struct rt2x00_dev *rt2x00dev,
            struct ieee80211_vif *vif);
+const u8 *rt2x00lib_get_mac_address(struct rt2x00_dev *rt2x00dev);
 
 /*
 * Interrupt context handlers.
drivers/net/wireless/rt2x00/rt2x00dev.c +12 -0
index b7856bf..f9868d1 100644
@@ -826,6 +826,18 @@ static void rt2x00lib_rate(struct ieee80211_rate *entry,
       entry->flags |= IEEE80211_RATE_SHORT_PREAMBLE;
 }
 
+const u8 *rt2x00lib_get_mac_address(struct rt2x00_dev *rt2x00dev)
+{
+    struct rt2x00_platform_data *pdata;
+
+    pdata = rt2x00dev->dev->platform_data;
+    if (!pdata)
+        return NULL;
+
+    return pdata->mac_address;
+}
+EXPORT_SYMBOL_GPL(rt2x00lib_get_mac_address);
+
 static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
                   struct hw_mode_spec *spec)
 {
drivers/net/wireless/rt2x00/rt61pci.c +5 -0
index f95792c..7dbc0ba 100644
@@ -2392,6 +2392,7 @@ static int rt61pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
   u32 reg;
   u16 word;
   u8 *mac;
+    const u8 *pdata_mac;
   s8 value;
 
   rt2x00pci_register_read(rt2x00dev, E2PROM_CSR, &reg);
@@ -2412,7 +2413,11 @@ static int rt61pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
   /*
    * Start validation of the data that has been read.
    */
+    pdata_mac = rt2x00lib_get_mac_address(rt2x00dev);
   mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
+    if (pdata_mac)
+        memcpy(mac, pdata_mac, 6);
+
   if (!is_valid_ether_addr(mac)) {
       eth_random_addr(mac);
       EEPROM(rt2x00dev, "MAC: %pM\n", mac);
include/linux/rt2x00_platform.h +1 -0
index b4c7768..e10377e 100644
@@ -14,6 +14,7 @@
 
 struct rt2x00_platform_data {
   char *eeprom_file_name;
+    const u8 *mac_address;
 
   int disable_2ghz;
   int disable_5ghz;
Signature · 1 line
1.8.0.1
#2 lore raw

Hi,

Quoted 2 lines · Gertjan van Wingerde

And for this patch I have the same question as for the previous patch: why do we need to arrange this via platform data, as opposed to using the standard user space ifconfig facility to set a mac address?

This looks fine to me. I'd also prefer to pass in a MAC address from the platform data on SoC devices
instead of having to write some user space code. And this is how it is done by other drivers as well.

Quoted 1 line

As a second question: why is this only implemented for rt61pci, and not the other PCI / SOC drivers?

Good point.

Helmut