linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/3] rt2x00: add platform_data mac address
@ 2012-12-11 10:04 Daniel Golle
  2012-12-11 21:51 ` Gertjan van Wingerde
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Golle @ 2012-12-11 10:04 UTC (permalink / raw)
  To: linux-wireless; +Cc: users, juhosg, sgruszka, helmut.schaa, gwingerde, john

[-- Attachment #1: Type: text/plain, Size: 2523 bytes --]


Signed-off-by: Daniel Golle <dgolle@allnet.de>

diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index c67e769..8b82e77 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -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.
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index b7856bf..f9868d1 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -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)
 {
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index f95792c..7dbc0ba 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -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);
diff --git a/include/linux/rt2x00_platform.h b/include/linux/rt2x00_platform.h
index b4c7768..e10377e 100644
--- a/include/linux/rt2x00_platform.h
+++ b/include/linux/rt2x00_platform.h
@@ -14,6 +14,7 @@
 
 struct rt2x00_platform_data {
 	char *eeprom_file_name;
+	const u8 *mac_address;
 
 	int disable_2ghz;
 	int disable_5ghz;
-- 
1.8.0.1


[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 3/3] rt2x00: add platform_data mac address
  2012-12-11 10:04 [PATCH 3/3] rt2x00: add platform_data mac address Daniel Golle
@ 2012-12-11 21:51 ` Gertjan van Wingerde
  2013-01-25 12:08   ` Helmut Schaa
  0 siblings, 1 reply; 3+ messages in thread
From: Gertjan van Wingerde @ 2012-12-11 21:51 UTC (permalink / raw)
  To: Daniel Golle
  Cc: <linux-wireless@vger.kernel.org>,
	<users@rt2x00.serialmonkey.com>, <juhosg@openwrt.org>,
	<sgruszka@redhat.com>, <helmut.schaa@googlemail.com>,
	<john@phrozen.org>

Hi Daniel,

On 11 dec. 2012, at 11:04, Daniel Golle <dgolle@allnet.de> wrote:

> 
> Signed-off-by: Daniel Golle <dgolle@allnet.de>

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

> 
> diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
> index c67e769..8b82e77 100644
> --- a/drivers/net/wireless/rt2x00/rt2x00.h
> +++ b/drivers/net/wireless/rt2x00/rt2x00.h
> @@ -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.
> diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
> index b7856bf..f9868d1 100644
> --- a/drivers/net/wireless/rt2x00/rt2x00dev.c
> +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
> @@ -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)
> {
> diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
> index f95792c..7dbc0ba 100644
> --- a/drivers/net/wireless/rt2x00/rt61pci.c
> +++ b/drivers/net/wireless/rt2x00/rt61pci.c
> @@ -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);
> diff --git a/include/linux/rt2x00_platform.h b/include/linux/rt2x00_platform.h
> index b4c7768..e10377e 100644
> --- a/include/linux/rt2x00_platform.h
> +++ b/include/linux/rt2x00_platform.h
> @@ -14,6 +14,7 @@
> 
> struct rt2x00_platform_data {
>    char *eeprom_file_name;
> +    const u8 *mac_address;
> 
>    int disable_2ghz;
>    int disable_5ghz;
> -- 
> 1.8.0.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 3/3] rt2x00: add platform_data mac address
  2012-12-11 21:51 ` Gertjan van Wingerde
@ 2013-01-25 12:08   ` Helmut Schaa
  0 siblings, 0 replies; 3+ messages in thread
From: Helmut Schaa @ 2013-01-25 12:08 UTC (permalink / raw)
  To: Gertjan van Wingerde
  Cc: Daniel Golle, <linux-wireless@vger.kernel.org>,
	<users@rt2x00.serialmonkey.com>, <juhosg@openwrt.org>,
	<sgruszka@redhat.com>, <john@phrozen.org>

Hi,

On Tue, Dec 11, 2012 at 10:51 PM, Gertjan van Wingerde
<gwingerde@gmail.com> wrote:
> 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.

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

Good point.

Helmut

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-01-25 12:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-11 10:04 [PATCH 3/3] rt2x00: add platform_data mac address Daniel Golle
2012-12-11 21:51 ` Gertjan van Wingerde
2013-01-25 12:08   ` Helmut Schaa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).