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 67D04C433EF for ; Thu, 21 Oct 2021 05:33:58 +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 E2955610D0 for ; Thu, 21 Oct 2021 05:33:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E2955610D0 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 5CD6083426; Thu, 21 Oct 2021 07:33:56 +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=1634794436; bh=pGkhkT2SJCMCcmLcKDu8ZKp/jcrOKXh8qyxNngNQUnk=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=BA0+XGCmuEPATS+acNC+21ZEBfjAJbjy3BL1k8axfgtAATOHTEZBTZQ+fSGZVMGwt ZX7/c4B9AL0z8BrySrhe1Zpw3Jv18u33XlAXBpvf1izVZfmzd6Xzt3LsOyzMwrjCP/ LX1wkMfMq4ztuGqqIJLyXn8CKpDu0UZHeJ8eIVlwi5Sj2gIpM7/JQJ+StRISI6G5kj KfQuc5afdAyBipHrwBJhf24kT7tHpwL5EsKezTrC4wFH03j7JZRCQpo8sF+MIJmX1q Fn6XYmtCVi5b66si5S09l6y8ruVN5yLBFRVPaaQECmj/ZW0pyJ98UqDNuMDPE7tqID 0cU0Ctg48PRkg== Received: by phobos.denx.de (Postfix, from userid 109) id 2296E83483; Thu, 21 Oct 2021 07:33:54 +0200 (CEST) Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [91.198.250.252]) (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 CB7E283410 for ; Thu, 21 Oct 2021 07:33:50 +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 [IPv6:2001:67c:2050:105:465:1:3:0]) (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 4HZbkQ5M2jzQkLv; Thu, 21 Oct 2021 07:33:50 +0200 (CEST) Subject: Re: [PATCH u-boot-marvell 09/12] arm: mvebu: turris_omnia: Overwrite ethaddr only if invalid 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-10-kabel@kernel.org> From: Stefan Roese Message-ID: <816b3475-0fda-b74e-7329-8a9deb45f82b@denx.de> Date: Thu, 21 Oct 2021 07:33:47 +0200 MIME-Version: 1.0 In-Reply-To: <20211009173346.7859-10-kabel@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 0C6EE5AF 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 always overwrite ethaddrs with those from EEPROM. > > In order to allow user to use a cloned MAC address in U-Boot, change the > code so that it sets ethaddr variables only if they aren't set or are > invalid. > > Signed-off-by: Marek Behún Reviewed-by: Stefan Roese Thanks, Stefan > --- > board/CZ.NIC/turris_omnia/turris_omnia.c | 22 ++++++++++++---------- > 1 file changed, 12 insertions(+), 10 deletions(-) > > diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c > index a48e1f5c30..7a86111890 100644 > --- a/board/CZ.NIC/turris_omnia/turris_omnia.c > +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c > @@ -518,6 +518,15 @@ static void increment_mac(u8 *mac) > } > } > > +static void set_mac_if_invalid(int i, u8 *mac) > +{ > + u8 oldmac[6]; > + > + if (is_valid_ethaddr(mac) && > + !eth_env_get_enetaddr_by_index("eth", i, oldmac)) > + eth_env_set_enetaddr_by_index("eth", i, mac); > +} > + > int misc_init_r(void) > { > int err; > @@ -550,18 +559,11 @@ int misc_init_r(void) > mac[4] = mac1[2]; > mac[5] = mac1[3]; > > - if (is_valid_ethaddr(mac)) > - eth_env_set_enetaddr("eth1addr", mac); > - > + set_mac_if_invalid(1, mac); > increment_mac(mac); > - > - if (is_valid_ethaddr(mac)) > - eth_env_set_enetaddr("eth2addr", mac); > - > + set_mac_if_invalid(2, mac); > increment_mac(mac); > - > - if (is_valid_ethaddr(mac)) > - eth_env_set_enetaddr("ethaddr", mac); > + set_mac_if_invalid(0, mac); > > out: > 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