From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19278C433EF for ; Thu, 21 Oct 2021 05:33:38 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8766560FED for ; Thu, 21 Oct 2021 05:33:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8766560FED Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B88A3834CF; Thu, 21 Oct 2021 07:33:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1634794416; bh=qul581HzYO7VHWPbcnLBZBizwL677h7V/AZEMlVRoDQ=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=xnsyIWUMz7jD4djek1A74oKqccXlGO+b1CH9/8f7s9bJfkTIn68bQHAgnLAj3+2QA VrTL8GasyvqAl/jQNl+0Q1PFu/hWflTeYzFji3kDZsJSE5At8PIwzsRWsp87Aeq3pc sAVZtBwubrMd3tpzqdzNhJFd3V3pLFBG5DjqLoDTbHQ+94Bjc5TU6HX0WnEQ+SPZZX U+WZaZy8fm3iMTLL202Vw27NpWOBYL53++LZYJvLFiOD8uuQWk3ST08c0x6OMQp1Dv kJGjLGA2tEl+PWCPzzAP/Wwdb5RwqZ8CsrawOVSG4bVgHg87er0NmfWBcJ6GY+qhtQ JToCG8FX8Joww== Received: by phobos.denx.de (Postfix, from userid 109) id BAA77834B5; Thu, 21 Oct 2021 07:33:28 +0200 (CEST) Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [IPv6:2001:67c:2050:1::465:107]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D65D783426 for ; Thu, 21 Oct 2021 07:33:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp102.mailbox.org (smtp102.mailbox.org [80.241.60.233]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4HZbjw5yGCzQkLv; Thu, 21 Oct 2021 07:33:24 +0200 (CEST) Subject: Re: [PATCH u-boot-marvell 08/12] arm: mvebu: turris_mox: Better check for valid ethernet addresses in env To: =?UTF-8?Q?Marek_Beh=c3=ban?= Cc: u-boot@lists.denx.de, pali@kernel.org, =?UTF-8?Q?Marek_Beh=c3=ban?= References: <20211009173346.7859-1-kabel@kernel.org> <20211009173346.7859-9-kabel@kernel.org> From: Stefan Roese Message-ID: Date: Thu, 21 Oct 2021 07:33:21 +0200 MIME-Version: 1.0 In-Reply-To: <20211009173346.7859-9-kabel@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C34A511FD X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 09.10.21 19:33, Marek Behún wrote: > From: Marek Behún > > Currently we overwrite ethaddr and eth1addr only if these variables > don't exist. > > Better overwrite them even if the env variable exists, but is invalid - > eth_env_get_enetaddr_by_index() checks for validity. > > Refactor the code to use a for cycle. > > Signed-off-by: Marek Behún Reviewed-by: Stefan Roese Thanks, Stefan > --- > board/CZ.NIC/turris_mox/turris_mox.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) > > diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c > index 7c5acfd1d9..2202eb8cfb 100644 > --- a/board/CZ.NIC/turris_mox/turris_mox.c > +++ b/board/CZ.NIC/turris_mox/turris_mox.c > @@ -359,20 +359,22 @@ static int get_reset_gpio(struct gpio_desc *reset_gpio) > > int misc_init_r(void) > { > - int ret; > - u8 mac1[6], mac2[6]; > + u8 mac[2][6]; > + int i, ret; > > - ret = mbox_sp_get_board_info(NULL, mac1, mac2, NULL, NULL); > + ret = mbox_sp_get_board_info(NULL, mac[0], mac[1], NULL, NULL); > if (ret < 0) { > printf("Cannot read data from OTP!\n"); > return 0; > } > > - if (is_valid_ethaddr(mac1) && !env_get("ethaddr")) > - eth_env_set_enetaddr("ethaddr", mac1); > + for (i = 0; i < 2; ++i) { > + u8 oldmac[6]; > > - if (is_valid_ethaddr(mac2) && !env_get("eth1addr")) > - eth_env_set_enetaddr("eth1addr", mac2); > + if (is_valid_ethaddr(mac[i]) && > + !eth_env_get_enetaddr_by_index("eth", i, oldmac)) > + eth_env_set_enetaddr_by_index("eth", i, mac[i]); > + } > > return 0; > } > Viele Grüße, Stefan -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de