Patchwork sh_eth: use random MAC address if no valid one supplied

login
register
mail settings
Submitter Sergei Shtylyov
Date April 27, 2013, 10:48 p.m.
Message ID <201304280248.11893.sergei.shtylyov@cogentembedded.com>
Download mbox | patch
Permalink /patch/240210/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Sergei Shtylyov - April 27, 2013, 10:48 p.m.
On Renesas R-Car based development boards, although a MAC address is printed on
all the Ethernet port labels, U-Boot  doesn't write a valid MAC address  to the
Ether MAHR/MALR registers (there's no storage provided for the Ether MAC address
either), so we have to resort to using a random MAC address...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
This patch is against the 'net-next.git' repository.

 drivers/net/ethernet/renesas/sh_eth.c |    5 +++++
 1 file changed, 5 insertions(+)

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Laurent Pinchart - April 28, 2013, 8:29 p.m.
Hi Sergei,

Thank you for the patch.

On Sunday 28 April 2013 02:48:11 Sergei Shtylyov wrote:
> On Renesas R-Car based development boards, although a MAC address is printed
> on all the Ethernet port labels, U-Boot  doesn't write a valid MAC address 
> to the Ether MAHR/MALR registers (there's no storage provided for the Ether
> MAC address either), so we have to resort to using a random MAC address...
> 
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
> 
> ---
> This patch is against the 'net-next.git' repository.
> 
>  drivers/net/ethernet/renesas/sh_eth.c |    5 +++++
>  1 file changed, 5 insertions(+)
> 
> Index: net-next/drivers/net/ethernet/renesas/sh_eth.c
> ===================================================================
> --- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c
> +++ net-next/drivers/net/ethernet/renesas/sh_eth.c
> @@ -2735,6 +2735,11 @@ static int sh_eth_drv_probe(struct platf
> 
>  	/* read and set MAC address */
>  	read_mac_address(ndev, pd->mac_addr);
> +	if (!is_valid_ether_addr(ndev->dev_addr)) {
> +		dev_warn(&pdev->dev, "no valid MAC address supplied, using "
> +			 "a random one.\n");

Breaking log messages in the middle of a line is frowned upon, more than 
exceeding the 80 characters per line (soft) limit. I think

        dev_warn(&pdev->dev,
                 "no valid MAC address supplied, using a random one.\n");

would be better.

> +		eth_hw_addr_random(ndev);
> +	}
> 
>  	/* ioremap the TSU registers */
>  	if (mdp->cd->tsu) {
Sergei Shtylyov - April 29, 2013, 11:43 a.m.
Hello.

On 29-04-2013 0:29, Laurent Pinchart wrote:

>> On Renesas R-Car based development boards, although a MAC address is printed
>> on all the Ethernet port labels, U-Boot  doesn't write a valid MAC address
>> to the Ether MAHR/MALR registers (there's no storage provided for the Ether
>> MAC address either), so we have to resort to using a random MAC address...

>> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

>> ---
>> This patch is against the 'net-next.git' repository.

>>   drivers/net/ethernet/renesas/sh_eth.c |    5 +++++
>>   1 file changed, 5 insertions(+)

>> Index: net-next/drivers/net/ethernet/renesas/sh_eth.c
>> ===================================================================
>> --- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c
>> +++ net-next/drivers/net/ethernet/renesas/sh_eth.c
>> @@ -2735,6 +2735,11 @@ static int sh_eth_drv_probe(struct platf
>>
>>   	/* read and set MAC address */
>>   	read_mac_address(ndev, pd->mac_addr);
>> +	if (!is_valid_ether_addr(ndev->dev_addr)) {
>> +		dev_warn(&pdev->dev, "no valid MAC address supplied, using "
>> +			 "a random one.\n");

> Breaking log messages in the middle of a line is frowned upon, more than
> exceeding the 80 characters per line (soft) limit. I think

>          dev_warn(&pdev->dev,
>                   "no valid MAC address supplied, using a random one.\n");

> would be better.

    Thanks, totally forgot about that when doing a patch, only remembered 
after sending out.

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

Index: net-next/drivers/net/ethernet/renesas/sh_eth.c
===================================================================
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c
+++ net-next/drivers/net/ethernet/renesas/sh_eth.c
@@ -2735,6 +2735,11 @@  static int sh_eth_drv_probe(struct platf
 
 	/* read and set MAC address */
 	read_mac_address(ndev, pd->mac_addr);
+	if (!is_valid_ether_addr(ndev->dev_addr)) {
+		dev_warn(&pdev->dev, "no valid MAC address supplied, using "
+			 "a random one.\n");
+		eth_hw_addr_random(ndev);
+	}
 
 	/* ioremap the TSU registers */
 	if (mdp->cd->tsu) {