All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Aaro Koskinen <aaro.koskinen@iki.fi>,
	Ralf Baechle <ralf@linux-mips.org>,
	David Daney <ddaney.cavm@gmail.com>,
	linux-mips@linux-mips.org
Subject: Re: [PATCH 2/3] MIPS: OCTEON: device_tree_init: don't fill mac if already set
Date: Mon, 22 Feb 2016 15:10:07 -0800	[thread overview]
Message-ID: <56CB954F.1070504@gmail.com> (raw)
In-Reply-To: <1456180788-6803-3-git-send-email-aaro.koskinen@iki.fi>

On 22/02/16 14:39, Aaro Koskinen wrote:
> Don't fill MAC address if it's already set. This allows DTB to
> override the bootinfo.
> 
> Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
> ---
>  arch/mips/cavium-octeon/octeon-platform.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
> index a7d9f07..c5de792 100644
> --- a/arch/mips/cavium-octeon/octeon-platform.c
> +++ b/arch/mips/cavium-octeon/octeon-platform.c
> @@ -525,10 +525,19 @@ static void __init octeon_fdt_set_phy(int eth, int phy_addr)
>  
>  static void __init octeon_fdt_set_mac_addr(int n, u64 *pmac)
>  {
> +	const u8 *old_mac;
> +	int old_len;
>  	u8 new_mac[6];
>  	u64 mac = *pmac;
>  	int r;
>  
> +	old_mac = fdt_getprop(initial_boot_params, n, "local-mac-address",
> +			      &old_len);
> +	if (!old_mac || old_len != 6 || old_mac[0] || old_mac[1] ||
> +					old_mac[2] || old_mac[3] ||
> +					old_mac[4] || old_mac[5])

There is nothing that tells you that these are valid MAC addresses
though, although unlikely, the FW could be handing you bad addresses,
might be better to use is_valid_ether_addr() here?
-- 
Florian

  reply	other threads:[~2016-02-22 23:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-22 22:39 [PATCH 0/3] MIPS: OCTEON: fill mac addresses with appended DTB Aaro Koskinen
2016-02-22 22:39 ` [PATCH 1/3] MIPS: OCTEON: device_tree_init: use separate pass to fill mac addresses Aaro Koskinen
2016-02-22 22:39 ` [PATCH 2/3] MIPS: OCTEON: device_tree_init: don't fill mac if already set Aaro Koskinen
2016-02-22 23:10   ` Florian Fainelli [this message]
2016-02-22 22:39 ` [PATCH 3/3] MIPS: OCTEON: device_tree_init: fill mac addresses when using appended dtb Aaro Koskinen
2016-02-23  2:03 ` [PATCH 0/3] MIPS: OCTEON: fill mac addresses with appended DTB David Daney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56CB954F.1070504@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=aaro.koskinen@iki.fi \
    --cc=ddaney.cavm@gmail.com \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.