All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: ethernet: bgmac: Allow MAC address to be specified in DTB
@ 2017-03-16 15:48 Steve Lin
  2017-03-16 16:39 ` Florian Fainelli
  2017-03-16 18:58 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Steve Lin @ 2017-03-16 15:48 UTC (permalink / raw)
  To: davem, rafal, jon.mason, f.fainelli, tklauser
  Cc: netdev, linux-kernel, bcm-kernel-feedback-list, steven.lin1

Allows the BCMA version of the bgmac driver to obtain MAC address
from the device tree.  If no MAC address is specified there, then
the previous behavior (obtaining MAC address from SPROM) is
used.

Signed-off-by: Steve Lin <steven.lin1@broadcom.com>
---
 drivers/net/ethernet/broadcom/bgmac-bcma.c | 39 ++++++++++++++++++------------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bgmac-bcma.c b/drivers/net/ethernet/broadcom/bgmac-bcma.c
index cf15b7e..6322594 100644
--- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
+++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
@@ -11,6 +11,7 @@
 #include <linux/bcma/bcma.h>
 #include <linux/brcmphy.h>
 #include <linux/etherdevice.h>
+#include <linux/of_net.h>
 #include "bgmac.h"
 
 static inline bool bgmac_is_bcm4707_family(struct bcma_device *core)
@@ -114,7 +115,7 @@ static int bgmac_probe(struct bcma_device *core)
 	struct ssb_sprom *sprom = &core->bus->sprom;
 	struct mii_bus *mii_bus;
 	struct bgmac *bgmac;
-	u8 *mac;
+	const u8 *mac = NULL;
 	int err;
 
 	bgmac = bgmac_alloc(&core->dev);
@@ -127,21 +128,27 @@ static int bgmac_probe(struct bcma_device *core)
 
 	bcma_set_drvdata(core, bgmac);
 
-	switch (core->core_unit) {
-	case 0:
-		mac = sprom->et0mac;
-		break;
-	case 1:
-		mac = sprom->et1mac;
-		break;
-	case 2:
-		mac = sprom->et2mac;
-		break;
-	default:
-		dev_err(bgmac->dev, "Unsupported core_unit %d\n",
-			core->core_unit);
-		err = -ENOTSUPP;
-		goto err;
+	if (bgmac->dev->of_node)
+		mac = of_get_mac_address(bgmac->dev->of_node);
+
+	/* If no MAC address assigned via device tree, check SPROM */
+	if (!mac) {
+		switch (core->core_unit) {
+		case 0:
+			mac = sprom->et0mac;
+			break;
+		case 1:
+			mac = sprom->et1mac;
+			break;
+		case 2:
+			mac = sprom->et2mac;
+			break;
+		default:
+			dev_err(bgmac->dev, "Unsupported core_unit %d\n",
+				core->core_unit);
+			err = -ENOTSUPP;
+			goto err;
+		}
 	}
 
 	ether_addr_copy(bgmac->net_dev->dev_addr, mac);
-- 
2.1.0

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

* Re: [PATCH] net: ethernet: bgmac: Allow MAC address to be specified in DTB
  2017-03-16 15:48 [PATCH] net: ethernet: bgmac: Allow MAC address to be specified in DTB Steve Lin
@ 2017-03-16 16:39 ` Florian Fainelli
  2017-03-16 17:13   ` Jon Mason
  2017-03-16 18:58 ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Florian Fainelli @ 2017-03-16 16:39 UTC (permalink / raw)
  To: Steve Lin, davem, rafal, jon.mason, tklauser
  Cc: netdev, linux-kernel, bcm-kernel-feedback-list

On 03/16/2017 08:48 AM, Steve Lin wrote:
> Allows the BCMA version of the bgmac driver to obtain MAC address
> from the device tree.  If no MAC address is specified there, then
> the previous behavior (obtaining MAC address from SPROM) is
> used.
> 
> Signed-off-by: Steve Lin <steven.lin1@broadcom.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

PS: you might want to specify which tree this applies to by using [PATCH
net-next] or [PATCH net] in the subject, see the netdev-FAQ.txt for
details:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/netdev-FAQ.txt

> ---
>  drivers/net/ethernet/broadcom/bgmac-bcma.c | 39 ++++++++++++++++++------------
>  1 file changed, 23 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bgmac-bcma.c b/drivers/net/ethernet/broadcom/bgmac-bcma.c
> index cf15b7e..6322594 100644
> --- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
> +++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
> @@ -11,6 +11,7 @@
>  #include <linux/bcma/bcma.h>
>  #include <linux/brcmphy.h>
>  #include <linux/etherdevice.h>
> +#include <linux/of_net.h>
>  #include "bgmac.h"
>  
>  static inline bool bgmac_is_bcm4707_family(struct bcma_device *core)
> @@ -114,7 +115,7 @@ static int bgmac_probe(struct bcma_device *core)
>  	struct ssb_sprom *sprom = &core->bus->sprom;
>  	struct mii_bus *mii_bus;
>  	struct bgmac *bgmac;
> -	u8 *mac;
> +	const u8 *mac = NULL;
>  	int err;
>  
>  	bgmac = bgmac_alloc(&core->dev);
> @@ -127,21 +128,27 @@ static int bgmac_probe(struct bcma_device *core)
>  
>  	bcma_set_drvdata(core, bgmac);
>  
> -	switch (core->core_unit) {
> -	case 0:
> -		mac = sprom->et0mac;
> -		break;
> -	case 1:
> -		mac = sprom->et1mac;
> -		break;
> -	case 2:
> -		mac = sprom->et2mac;
> -		break;
> -	default:
> -		dev_err(bgmac->dev, "Unsupported core_unit %d\n",
> -			core->core_unit);
> -		err = -ENOTSUPP;
> -		goto err;
> +	if (bgmac->dev->of_node)
> +		mac = of_get_mac_address(bgmac->dev->of_node);
> +
> +	/* If no MAC address assigned via device tree, check SPROM */
> +	if (!mac) {
> +		switch (core->core_unit) {
> +		case 0:
> +			mac = sprom->et0mac;
> +			break;
> +		case 1:
> +			mac = sprom->et1mac;
> +			break;
> +		case 2:
> +			mac = sprom->et2mac;
> +			break;
> +		default:
> +			dev_err(bgmac->dev, "Unsupported core_unit %d\n",
> +				core->core_unit);
> +			err = -ENOTSUPP;
> +			goto err;
> +		}
>  	}
>  
>  	ether_addr_copy(bgmac->net_dev->dev_addr, mac);
> 


-- 
Florian

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

* Re: [PATCH] net: ethernet: bgmac: Allow MAC address to be specified in DTB
  2017-03-16 16:39 ` Florian Fainelli
@ 2017-03-16 17:13   ` Jon Mason
  0 siblings, 0 replies; 4+ messages in thread
From: Jon Mason @ 2017-03-16 17:13 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Steve Lin, David Miller, Rafał Miłecki, Tobias Klauser,
	Network Development, open list, BCM Kernel Feedback

On Thu, Mar 16, 2017 at 12:39 PM, Florian Fainelli <f.fainelli@gmail.com> wrote:
> On 03/16/2017 08:48 AM, Steve Lin wrote:
>> Allows the BCMA version of the bgmac driver to obtain MAC address
>> from the device tree.  If no MAC address is specified there, then
>> the previous behavior (obtaining MAC address from SPROM) is
>> used.
>>
>> Signed-off-by: Steve Lin <steven.lin1@broadcom.com>
>
> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
>
> PS: you might want to specify which tree this applies to by using [PATCH
> net-next] or [PATCH net] in the subject, see the netdev-FAQ.txt for
> details:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/netdev-FAQ.txt

I believe he wants this in net-next

Acked-by: Jon Mason <jon.mason@broadcom.com>

>> ---
>>  drivers/net/ethernet/broadcom/bgmac-bcma.c | 39 ++++++++++++++++++------------
>>  1 file changed, 23 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/broadcom/bgmac-bcma.c b/drivers/net/ethernet/broadcom/bgmac-bcma.c
>> index cf15b7e..6322594 100644
>> --- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
>> +++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
>> @@ -11,6 +11,7 @@
>>  #include <linux/bcma/bcma.h>
>>  #include <linux/brcmphy.h>
>>  #include <linux/etherdevice.h>
>> +#include <linux/of_net.h>
>>  #include "bgmac.h"
>>
>>  static inline bool bgmac_is_bcm4707_family(struct bcma_device *core)
>> @@ -114,7 +115,7 @@ static int bgmac_probe(struct bcma_device *core)
>>       struct ssb_sprom *sprom = &core->bus->sprom;
>>       struct mii_bus *mii_bus;
>>       struct bgmac *bgmac;
>> -     u8 *mac;
>> +     const u8 *mac = NULL;
>>       int err;
>>
>>       bgmac = bgmac_alloc(&core->dev);
>> @@ -127,21 +128,27 @@ static int bgmac_probe(struct bcma_device *core)
>>
>>       bcma_set_drvdata(core, bgmac);
>>
>> -     switch (core->core_unit) {
>> -     case 0:
>> -             mac = sprom->et0mac;
>> -             break;
>> -     case 1:
>> -             mac = sprom->et1mac;
>> -             break;
>> -     case 2:
>> -             mac = sprom->et2mac;
>> -             break;
>> -     default:
>> -             dev_err(bgmac->dev, "Unsupported core_unit %d\n",
>> -                     core->core_unit);
>> -             err = -ENOTSUPP;
>> -             goto err;
>> +     if (bgmac->dev->of_node)
>> +             mac = of_get_mac_address(bgmac->dev->of_node);
>> +
>> +     /* If no MAC address assigned via device tree, check SPROM */
>> +     if (!mac) {
>> +             switch (core->core_unit) {
>> +             case 0:
>> +                     mac = sprom->et0mac;
>> +                     break;
>> +             case 1:
>> +                     mac = sprom->et1mac;
>> +                     break;
>> +             case 2:
>> +                     mac = sprom->et2mac;
>> +                     break;
>> +             default:
>> +                     dev_err(bgmac->dev, "Unsupported core_unit %d\n",
>> +                             core->core_unit);
>> +                     err = -ENOTSUPP;
>> +                     goto err;
>> +             }
>>       }
>>
>>       ether_addr_copy(bgmac->net_dev->dev_addr, mac);
>>
>
>
> --
> Florian

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

* Re: [PATCH] net: ethernet: bgmac: Allow MAC address to be specified in DTB
  2017-03-16 15:48 [PATCH] net: ethernet: bgmac: Allow MAC address to be specified in DTB Steve Lin
  2017-03-16 16:39 ` Florian Fainelli
@ 2017-03-16 18:58 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2017-03-16 18:58 UTC (permalink / raw)
  To: steven.lin1
  Cc: rafal, jon.mason, f.fainelli, tklauser, netdev, linux-kernel,
	bcm-kernel-feedback-list

From: Steve Lin <steven.lin1@broadcom.com>
Date: Thu, 16 Mar 2017 11:48:58 -0400

> Allows the BCMA version of the bgmac driver to obtain MAC address
> from the device tree.  If no MAC address is specified there, then
> the previous behavior (obtaining MAC address from SPROM) is
> used.
> 
> Signed-off-by: Steve Lin <steven.lin1@broadcom.com>

Applied to net-next, thanks.

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

end of thread, other threads:[~2017-03-16 18:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-16 15:48 [PATCH] net: ethernet: bgmac: Allow MAC address to be specified in DTB Steve Lin
2017-03-16 16:39 ` Florian Fainelli
2017-03-16 17:13   ` Jon Mason
2017-03-16 18:58 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.