diff mbox series

net: smc911x: Automatically Update ethaddr with MAC

Message ID 20200816121737.2666944-1-aford173@gmail.com
State Changes Requested
Delegated to: Tom Rini
Headers show
Series net: smc911x: Automatically Update ethaddr with MAC | expand

Commit Message

Adam Ford Aug. 16, 2020, 12:17 p.m. UTC
The ethernet controller can read the MAC from EEPROM and display it,
but if ethaddr is not set, the ethernet is still unavailable.

This patch checks will automatically set the MAC address if it has
not already been set.

Signed-off-by: Adam Ford <aford173@gmail.com>

Comments

Tom Rini Aug. 17, 2020, 2:41 p.m. UTC | #1
On Sun, Aug 16, 2020 at 07:17:37AM -0500, Adam Ford wrote:

> The ethernet controller can read the MAC from EEPROM and display it,
> but if ethaddr is not set, the ethernet is still unavailable.
> 
> This patch checks will automatically set the MAC address if it has
> not already been set.
> 
> Signed-off-by: Adam Ford <aford173@gmail.com>
> 
> diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
> index 9c5dc46483..f028bfba18 100644
> --- a/drivers/net/smc911x.c
> +++ b/drivers/net/smc911x.c
> @@ -6,6 +6,7 @@
>   */
>  
>  #include <common.h>
> +#include <env.h>
>  #include <command.h>
>  #include <malloc.h>
>  #include <net.h>
> @@ -185,6 +186,8 @@ static void smc911x_handle_mac_address(struct smc911x_priv *priv)
>  	smc911x_set_mac_csr(priv, ADDRH, addrh);
>  
>  	printf(DRIVERNAME ": MAC %pM\n", m);
> +	if (!env_get("ethaddr"))
> +		env_set("fdt_file", (const char *)m);

Um, clearly a thinko here and you meant ethaddr and not fdt_file? :)
Adam Ford Aug. 17, 2020, 2:51 p.m. UTC | #2
On Mon, Aug 17, 2020 at 9:41 AM Tom Rini <trini@konsulko.com> wrote:
>
> On Sun, Aug 16, 2020 at 07:17:37AM -0500, Adam Ford wrote:
>
> > The ethernet controller can read the MAC from EEPROM and display it,
> > but if ethaddr is not set, the ethernet is still unavailable.
> >
> > This patch checks will automatically set the MAC address if it has
> > not already been set.
> >
> > Signed-off-by: Adam Ford <aford173@gmail.com>
> >
> > diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
> > index 9c5dc46483..f028bfba18 100644
> > --- a/drivers/net/smc911x.c
> > +++ b/drivers/net/smc911x.c
> > @@ -6,6 +6,7 @@
> >   */
> >
> >  #include <common.h>
> > +#include <env.h>
> >  #include <command.h>
> >  #include <malloc.h>
> >  #include <net.h>
> > @@ -185,6 +186,8 @@ static void smc911x_handle_mac_address(struct smc911x_priv *priv)
> >       smc911x_set_mac_csr(priv, ADDRH, addrh);
> >
> >       printf(DRIVERNAME ": MAC %pM\n", m);
> > +     if (!env_get("ethaddr"))
> > +             env_set("fdt_file", (const char *)m);
>
> Um, clearly a thinko here and you meant ethaddr and not fdt_file? :)

You are right.  (facepalm, egg on my face)

I'll submit a V2 later today.

adam
>
> --
> Tom
diff mbox series

Patch

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 9c5dc46483..f028bfba18 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -6,6 +6,7 @@ 
  */
 
 #include <common.h>
+#include <env.h>
 #include <command.h>
 #include <malloc.h>
 #include <net.h>
@@ -185,6 +186,8 @@  static void smc911x_handle_mac_address(struct smc911x_priv *priv)
 	smc911x_set_mac_csr(priv, ADDRH, addrh);
 
 	printf(DRIVERNAME ": MAC %pM\n", m);
+	if (!env_get("ethaddr"))
+		env_set("fdt_file", (const char *)m);
 }
 
 static bool smc911x_read_mac_address(struct smc911x_priv *priv)