[U-Boot] [PATCH] arm: mxs: fix mac address of second interface

Marek Vasut marex at denx.de
Sun Aug 16 00:49:36 CEST 2015


On Sunday, August 16, 2015 at 12:16:21 AM, Michael Heimpold wrote:
> In the rare case that an overflow occurs, propagate it.

Hi!

> Signed-off-by: Michael Heimpold <mhei at heimpold.de>
> Cc: Stefano Babic <sbabic at denx.de>
> Cc: Marek Vasut <marex at denx.de>
> CC: Fabio Estevam <fabio.estevam at freescale.com>
> ---
>  arch/arm/cpu/arm926ejs/mxs/mxs.c |   12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/cpu/arm926ejs/mxs/mxs.c
> b/arch/arm/cpu/arm926ejs/mxs/mxs.c index b1d8721..42057ad 100644
> --- a/arch/arm/cpu/arm926ejs/mxs/mxs.c
> +++ b/arch/arm/cpu/arm926ejs/mxs/mxs.c
> @@ -238,11 +238,19 @@ int cpu_eth_init(bd_t *bis)
> 
>  __weak void mx28_adjust_mac(int dev_id, unsigned char *mac)
>  {
> +	uint32_t data;
> +
>  	mac[0] = 0x00;
>  	mac[1] = 0x04; /* Use FSL vendor MAC address by default */
> 
> -	if (dev_id == 1) /* Let MAC1 be MAC0 + 1 by default */
> -		mac[5] += 1;
> +	if (dev_id == 1) { /* Let MAC1 be MAC0 + 1 by default */
> +		data = (mac[3] << 16) | (mac[4] << 8) | mac[5];
> +		data++;
> +
> +		mac[3] = (data >> 16) & 0xff;
> +		mac[4] = (data >> 8) & 0xff;
> +		mac[5] = data & 0xff;
> +	}

I'm not very fond of the added complexity. If an overflow happens,
the last nibble just becomes 0x00, which should be okayish. In case
you need some sort of special handling of the ethernet address, I'd
suggest to implement your own thing in board file.

Best regards,
Marek Vasut


More information about the U-Boot mailing list