diff mbox

[U-Boot,v2,1/3] net: eth: Clear MAC address in eth_pre_remove()

Message ID 1441877360-21315-1-git-send-email-bmeng.cn@gmail.com
State Superseded
Delegated to: Joe Hershberger
Headers show

Commit Message

Bin Meng Sept. 10, 2015, 9:29 a.m. UTC
When removing an Ethernet device, the MAC address saved in the dev's
platdata should be cleared.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

---

Changes in v2:
- New patch to clear MAC address in eth_pre_remove()

 net/eth.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Joe Hershberger Sept. 10, 2015, 10:32 p.m. UTC | #1
Hi Bin,

On Thu, Sep 10, 2015 at 4:29 AM, Bin Meng <bmeng.cn@gmail.com> wrote:
> When removing an Ethernet device, the MAC address saved in the dev's
> platdata should be cleared.

Why is this important to do?  Test case?

> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>
> ---
>
> Changes in v2:
> - New patch to clear MAC address in eth_pre_remove()
>
>  net/eth.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/net/eth.c b/net/eth.c
> index 26520d3..35f9641 100644
> --- a/net/eth.c
> +++ b/net/eth.c
> @@ -564,8 +564,13 @@ static int eth_post_probe(struct udevice *dev)
>
>  static int eth_pre_remove(struct udevice *dev)
>  {
> +       struct eth_pdata *pdata = dev->platdata;
> +
>         eth_get_ops(dev)->stop(dev);
>
> +       /* clear the MAC address */
> +       memset(pdata->enetaddr, 0, 6);
> +
>         return 0;
>  }
>
> --
> 1.8.2.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Bin Meng Sept. 11, 2015, 12:49 a.m. UTC | #2
Hi Joe,

On Fri, Sep 11, 2015 at 6:32 AM, Joe Hershberger
<joe.hershberger@gmail.com> wrote:
> Hi Bin,
>
> On Thu, Sep 10, 2015 at 4:29 AM, Bin Meng <bmeng.cn@gmail.com> wrote:
>> When removing an Ethernet device, the MAC address saved in the dev's
>> platdata should be cleared.
>
> Why is this important to do?  Test case?

platdata->enetaddr was assigned to a value in last dev_probe(). If we
don't clear it, for dev_probe() the second time, dm eth will end up
treating it as a MAC address from ROM no matter where it came from
originally (maybe env, ROM, or even random)

I don't think we need a test case to test this, but I can update
commit message to include the reason above.

>
>> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>>
>> ---
>>
>> Changes in v2:
>> - New patch to clear MAC address in eth_pre_remove()
>>
>>  net/eth.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/net/eth.c b/net/eth.c
>> index 26520d3..35f9641 100644
>> --- a/net/eth.c
>> +++ b/net/eth.c
>> @@ -564,8 +564,13 @@ static int eth_post_probe(struct udevice *dev)
>>
>>  static int eth_pre_remove(struct udevice *dev)
>>  {
>> +       struct eth_pdata *pdata = dev->platdata;
>> +
>>         eth_get_ops(dev)->stop(dev);
>>
>> +       /* clear the MAC address */
>> +       memset(pdata->enetaddr, 0, 6);
>> +
>>         return 0;
>>  }
>>

Regards,
Bin
Joe Hershberger Sept. 11, 2015, 12:52 a.m. UTC | #3
Hi Bin,

On Thu, Sep 10, 2015 at 7:49 PM, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Joe,
>
> On Fri, Sep 11, 2015 at 6:32 AM, Joe Hershberger
> <joe.hershberger@gmail.com> wrote:
>> Hi Bin,
>>
>> On Thu, Sep 10, 2015 at 4:29 AM, Bin Meng <bmeng.cn@gmail.com> wrote:
>>> When removing an Ethernet device, the MAC address saved in the dev's
>>> platdata should be cleared.
>>
>> Why is this important to do?  Test case?
>
> platdata->enetaddr was assigned to a value in last dev_probe(). If we
> don't clear it, for dev_probe() the second time, dm eth will end up
> treating it as a MAC address from ROM no matter where it came from
> originally (maybe env, ROM, or even random)
>
> I don't think we need a test case to test this, but I can update
> commit message to include the reason above.

OK. Sounds fine.

Thanks,
-Joe
diff mbox

Patch

diff --git a/net/eth.c b/net/eth.c
index 26520d3..35f9641 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -564,8 +564,13 @@  static int eth_post_probe(struct udevice *dev)
 
 static int eth_pre_remove(struct udevice *dev)
 {
+	struct eth_pdata *pdata = dev->platdata;
+
 	eth_get_ops(dev)->stop(dev);
 
+	/* clear the MAC address */
+	memset(pdata->enetaddr, 0, 6);
+
 	return 0;
 }