diff mbox series

[01/14] sandbox: net: Remove fake-host-hwaddr

Message ID 20220207234212.685316-2-sean.anderson@seco.com
State Changes Requested
Delegated to: Simon Glass
Headers show
Series Add support for NVMEM API | expand

Commit Message

Sean Anderson Feb. 7, 2022, 11:41 p.m. UTC
Instead of reading a pseudo-rom mac address from the device tree, just use
whatever we get from write_hwaddr. This has the effect of using the mac
address from the environment (or from the device tree, if it is
specified).

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

 arch/sandbox/dts/sandbox.dts   |  1 -
 arch/sandbox/dts/sandbox64.dts |  1 -
 arch/sandbox/dts/test.dts      |  5 -----
 drivers/net/sandbox.c          | 10 ++--------
 4 files changed, 2 insertions(+), 15 deletions(-)

Comments

Simon Glass Feb. 19, 2022, 12:21 a.m. UTC | #1
On Mon, 7 Feb 2022 at 16:42, Sean Anderson <sean.anderson@seco.com> wrote:
>
> Instead of reading a pseudo-rom mac address from the device tree, just use
> whatever we get from write_hwaddr. This has the effect of using the mac
> address from the environment (or from the device tree, if it is
> specified).
>
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
>
>  arch/sandbox/dts/sandbox.dts   |  1 -
>  arch/sandbox/dts/sandbox64.dts |  1 -
>  arch/sandbox/dts/test.dts      |  5 -----
>  drivers/net/sandbox.c          | 10 ++--------
>  4 files changed, 2 insertions(+), 15 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
Ramon Fried Feb. 19, 2022, 7:33 p.m. UTC | #2
On Sat, Feb 19, 2022 at 2:21 AM Simon Glass <sjg@chromium.org> wrote:
>
> On Mon, 7 Feb 2022 at 16:42, Sean Anderson <sean.anderson@seco.com> wrote:
> >
> > Instead of reading a pseudo-rom mac address from the device tree, just use
> > whatever we get from write_hwaddr. This has the effect of using the mac
> > address from the environment (or from the device tree, if it is
> > specified).
> >
> > Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> > ---
> >
> >  arch/sandbox/dts/sandbox.dts   |  1 -
> >  arch/sandbox/dts/sandbox64.dts |  1 -
> >  arch/sandbox/dts/test.dts      |  5 -----
> >  drivers/net/sandbox.c          | 10 ++--------
> >  4 files changed, 2 insertions(+), 15 deletions(-)
> >
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Ramon Fried <rfried.dev@gmail.com>
diff mbox series

Patch

diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index 127f168f02..840b8b503f 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -63,7 +63,6 @@ 
 	eth@10002000 {
 		compatible = "sandbox,eth";
 		reg = <0x10002000 0x1000>;
-		fake-host-hwaddr = [00 00 66 44 22 00];
 	};
 
 	i2c_0: i2c@0 {
diff --git a/arch/sandbox/dts/sandbox64.dts b/arch/sandbox/dts/sandbox64.dts
index ec53106af9..3eb0457089 100644
--- a/arch/sandbox/dts/sandbox64.dts
+++ b/arch/sandbox/dts/sandbox64.dts
@@ -58,7 +58,6 @@ 
 	eth@10002000 {
 		compatible = "sandbox,eth";
 		reg = <0x0 0x10002000 0x0 0x1000>;
-		fake-host-hwaddr = [00 00 66 44 22 00];
 	};
 
 	i2c_0: i2c@0 {
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 48ca3e1e47..5f3332a417 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -506,31 +506,26 @@ 
 	eth@10002000 {
 		compatible = "sandbox,eth";
 		reg = <0x10002000 0x1000>;
-		fake-host-hwaddr = [00 00 66 44 22 00];
 	};
 
 	eth_5: eth@10003000 {
 		compatible = "sandbox,eth";
 		reg = <0x10003000 0x1000>;
-		fake-host-hwaddr = [00 00 66 44 22 11];
 	};
 
 	eth_3: sbe5 {
 		compatible = "sandbox,eth";
 		reg = <0x10005000 0x1000>;
-		fake-host-hwaddr = [00 00 66 44 22 33];
 	};
 
 	eth@10004000 {
 		compatible = "sandbox,eth";
 		reg = <0x10004000 0x1000>;
-		fake-host-hwaddr = [00 00 66 44 22 22];
 	};
 
 	dsa_eth0: dsa-test-eth {
 		compatible = "sandbox,eth";
 		reg = <0x10006000 0x1000>;
-		fake-host-hwaddr = [00 00 66 44 22 66];
 	};
 
 	dsa-test {
diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c
index 37459dfa0a..13022addb6 100644
--- a/drivers/net/sandbox.c
+++ b/drivers/net/sandbox.c
@@ -395,9 +395,11 @@  static void sb_eth_stop(struct udevice *dev)
 static int sb_eth_write_hwaddr(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_plat(dev);
+	struct eth_sandbox_priv *priv = dev_get_priv(dev);
 
 	debug("eth_sandbox %s: Write HW ADDR - %pM\n", dev->name,
 	      pdata->enetaddr);
+	memcpy(priv->fake_host_hwaddr, pdata->enetaddr, ARP_HLEN);
 	return 0;
 }
 
@@ -419,16 +421,8 @@  static int sb_eth_of_to_plat(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	struct eth_sandbox_priv *priv = dev_get_priv(dev);
-	const u8 *mac;
 
 	pdata->iobase = dev_read_addr(dev);
-
-	mac = dev_read_u8_array_ptr(dev, "fake-host-hwaddr", ARP_HLEN);
-	if (!mac) {
-		printf("'fake-host-hwaddr' is missing from the DT\n");
-		return -EINVAL;
-	}
-	memcpy(priv->fake_host_hwaddr, mac, ARP_HLEN);
 	priv->disabled = false;
 	priv->tx_handler = sb_default_handler;