Re: [PATCH v2 03/21] i.MX: ocotp: Simplify MAC address storing logic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 12, 2016 at 10:02:50AM -0800, Andrey Smirnov wrote:
> Store MAC addresses as 8 byte buffer to avoid the need to have extra
> code to deal with "6 into 8" conversions and the need to have various
> magic numbers.
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
> ---
>  arch/arm/mach-imx/ocotp.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/ocotp.c b/arch/arm/mach-imx/ocotp.c
> index 7f625d8..f549c94 100644
> --- a/arch/arm/mach-imx/ocotp.c
> +++ b/arch/arm/mach-imx/ocotp.c
> @@ -84,7 +84,7 @@ struct ocotp_priv {
>  	struct device_d dev;
>  	int permanent_write_enable;
>  	int sense_enable;
> -	char ethaddr[6];
> +	char ethaddr[MAC_BYTES];
>  	struct regmap_config map_config;
>  	const struct imx_ocotp_data *data;
>  };
> @@ -409,25 +409,24 @@ static void memreverse(void *dest, const void *src, size_t n)
>  static int imx_ocotp_get_mac(struct param_d *param, void *priv)
>  {
>  	struct ocotp_priv *ocotp_priv = priv;
> -	char buf[8];
> +	char buf[MAC_BYTES];
>  	int ret;
>  
>  	ret = regmap_bulk_read(ocotp_priv->map, MAC_OFFSET, buf, MAC_BYTES);
>  	if (ret < 0)
>  		return ret;
>  
> -	memreverse(ocotp_priv->ethaddr, buf, 6);
> +	memreverse(ocotp_priv->ethaddr, buf, MAC_BYTES);
>  	return 0;
>  }
>  
>  static int imx_ocotp_set_mac(struct param_d *param, void *priv)
>  {
>  	struct ocotp_priv *ocotp_priv = priv;
> -	char buf[8];
> +	char buf[MAC_BYTES];
>  	int ret;
>  
> -	memreverse(buf, ocotp_priv->ethaddr, 6);
> -	buf[6] = 0; buf[7] = 0;
> +	memreverse(buf, ocotp_priv->ethaddr, MAC_BYTES);

Unless I have knots in my mind this does not work. dev_add_param_mac()
expects the MAC address in the given buffer. We pass priv->ethaddr, but
now with this change the MAC address is in priv->ethaddr + 2. Anything I
don't see here?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux