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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id EB641C433EF for ; Tue, 30 Nov 2021 20:23:30 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 44D2D8306E; Tue, 30 Nov 2021 21:23:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="oDh4A47W"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D58F883060; Tue, 30 Nov 2021 21:23:25 +0100 (CET) Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0970D83081 for ; Tue, 30 Nov 2021 21:23:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=tomm.merciai@gmail.com Received: by mail-ed1-x531.google.com with SMTP id y13so91822579edd.13 for ; Tue, 30 Nov 2021 12:23:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=3YqWMOyojIwKVAIS87CAG72iflbsH4ukHKtKYAMYLfg=; b=oDh4A47WL9EAPmGMnrE4ceRk2i0LITITITpkyrUXeXh/v4oRpckm+eHvgiign6vw7+ MG+uOa4SGwxAnC/ssgxUeRfOTutt501FEYrdeUnv47wcz6LXAPyQnrRLQvj9nuda/atx UfF2/KujsHz16NaDGvyq9Hahdnp/mzd/U1uv75cafpPC8BlwxjP7uzxK99D1X1OaicHJ /ML4C66lod0tpqtRcyce7sMIqiXHoDS0C8vzMWlhwVnBZPDzKF4Ei3b2PZm4tuvhguWP GOGkyjSg8kMZt1W5gyLR7t23Z74Mdk/cf1O37K5Jx1ilOkcKwT/1CJbDMc/1alnW3uRC 27zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=3YqWMOyojIwKVAIS87CAG72iflbsH4ukHKtKYAMYLfg=; b=UxoUMMdo06A+im6bpbCX3st5hOv462pCU0mxtO9txPKd1Zfv5d63pXQEbK8uas8RAu oSjJLuiX+4mtZgKqs1YY+jyrSon5UVJQhKhCxnH9eNwczmJtYPTN/CUnaKJy9D2k+n8Z ohv/fKQvMsEzOSG3Pch9veAoaHJRl7EchliF70Kk3CKWTY2mW1RhwxB7rypvF4CtTQX5 /MnvNF9W4N9376KK8cttq/uY3PWYijxyYzwhfuiERGJhxbOkMZDVVqK5tqYavMTLeEpD WK/jFHX9X1fkCOj6wAEnIYNKwuTJ/0PJCXiN+tHr5PxGrfH2MYArwg96CzXyloJVrUNf 7zUA== X-Gm-Message-State: AOAM531tKvcsKPsrOBMZhWbHHs4Uqit3G6/yz7iO3dFgBdi663tmMwYi YKd2L5Fl/KI6eJJpyWQhudI= X-Google-Smtp-Source: ABdhPJzIlkbsr8/Nr4XJ2wOsFC3ZQPimN/iQ73qGJlap/8TGAiqrZ5w3kqdS4t+Boez5rfaoguTdhw== X-Received: by 2002:aa7:c5c4:: with SMTP id h4mr1757658eds.386.1638303801564; Tue, 30 Nov 2021 12:23:21 -0800 (PST) Received: from tom-desktop (net-2-39-74-150.cust.vodafonedsl.it. [2.39.74.150]) by smtp.gmail.com with ESMTPSA id z25sm9302988ejd.80.2021.11.30.12.23.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 12:23:20 -0800 (PST) Date: Tue, 30 Nov 2021 21:23:18 +0100 From: Tommaso Merciai To: Marek =?iso-8859-1?Q?Beh=FAn?= Cc: michael@amarulasolutions.com, andrey.zhizhikin@leica-geosystems.com, Stefano Babic , Fabio Estevam , "NXP i.MX U-Boot Team" , Peng Fan , Ye Li , Marek Vasut , Simon Glass , Frieder Schrempf , Harald Seiler , "Ying-Chun Liu (PaulLiu)" , u-boot@lists.denx.de Subject: Re: [RFC PATCH 3/3] imx: imx8mp_evk: override env_get_location Message-ID: <20211130202318.GA2813@tom-desktop> References: <20211126174331.5928-1-tomm.merciai@gmail.com> <20211126174331.5928-4-tomm.merciai@gmail.com> <20211126190021.7d8428af@thinkpad> <20211128174711.GA4938@tom-desktop> <20211129131744.28234486@thinkpad> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20211129131744.28234486@thinkpad> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 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 Mon, Nov 29, 2021 at 01:17:44PM +0100, Marek Behún wrote: > On Sun, 28 Nov 2021 18:47:11 +0100 > Tommaso Merciai wrote: > > > On Fri, Nov 26, 2021 at 07:00:21PM +0100, Marek Behún wrote: > > > On Fri, 26 Nov 2021 18:43:31 +0100 > > > Tommaso Merciai wrote: > > > > > > > Override env_get_location function at board level, previously dropped > > > > down from soc.c > > > > > > > > References: > > > > - commit f1575f23df1ef704051f218d5bc4aeeb20c2c542 > > > > > > > > Signed-off-by: Tommaso Merciai > > > > --- > > > > Changes since v1: > > > > - Remove wrong env_get_offset function from commit > > > > > > > > board/freescale/imx8mp_evk/imx8mp_evk.c | 41 +++++++++++++++++++++++++ > > > > 1 file changed, 41 insertions(+) > > > > > > > > diff --git a/board/freescale/imx8mp_evk/imx8mp_evk.c b/board/freescale/imx8mp_evk/imx8mp_evk.c > > > > index 62096c24fb..6b2eeaf152 100644 > > > > --- a/board/freescale/imx8mp_evk/imx8mp_evk.c > > > > +++ b/board/freescale/imx8mp_evk/imx8mp_evk.c > > > > @@ -5,6 +5,7 @@ > > > > > > > > #include > > > > #include > > > > +#include > > > > #include > > > > #include > > > > #include > > > > @@ -17,6 +18,7 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > > > > > DECLARE_GLOBAL_DATA_PTR; > > > > > > > > @@ -32,6 +34,45 @@ static iomux_v3_cfg_t const wdog_pads[] = { > > > > MX8MP_PAD_GPIO1_IO02__WDOG1_WDOG_B | MUX_PAD_CTRL(WDOG_PAD_CTRL), > > > > }; > > > > > > > > +enum env_location env_get_location(enum env_operation op, int prio) > > > > +{ > > > > + enum boot_device dev = get_boot_device(); > > > > + enum env_location env_loc = ENVL_UNKNOWN; > > > > + > > > > + if (prio) > > > > + return env_loc; > > > > + > > > > + switch (dev) { > > > > +#ifdef CONFIG_ENV_IS_IN_SPI_FLASH > > > > + case QSPI_BOOT: > > > > + env_loc = ENVL_SPI_FLASH; > > > > + break; > > > > +#endif > > > > +#ifdef CONFIG_ENV_IS_IN_NAND > > > > + case NAND_BOOT: > > > > + env_loc = ENVL_NAND; > > > > + break; > > > > +#endif > > > > +#ifdef CONFIG_ENV_IS_IN_MMC > > > > + case SD1_BOOT: > > > > + case SD2_BOOT: > > > > + case SD3_BOOT: > > > > + case MMC1_BOOT: > > > > + case MMC2_BOOT: > > > > + case MMC3_BOOT: > > > > + env_loc = ENVL_MMC; > > > > + break; > > > > +#endif > > > > + default: > > > > +#if defined(CONFIG_ENV_IS_NOWHERE) > > > > + env_loc = ENVL_NOWHERE; > > > > +#endif > > > > > > Using > > > if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE)) > > > instead of #ifdefs is preferred because the compiler then warns about > > > bugs even in the disabled codepaths (that's why checkpatch complains > > > about #ifdefs). > > > > > > I know that this cannot be combined with switch() in a simple way, > > > though. > > > > > > Do you need to use switch? Can't you rewrite it to use if()s and use > > > IS_ENABLED()? > > > > > > Marek > > > > Hi Marek, > > Thanks for your review. What do you think about this solution? > > > > enum env_location env_get_location(enum env_operation op, int prio) > > { > > enum boot_device dev = get_boot_device(); > > enum env_location env_loc = ENVL_UNKNOWN; > > > > if (prio) > > return env_loc; > > > > if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH) && dev == QSPI_BOOT) { > > env_loc = ENVL_SPI_FLASH; > > } > > else if (IS_ENABLED(CONFIG_ENV_IS_IN_NAND) && dev == NAND_BOOT) { > > env_loc = ENVL_NAND; > > } > > else if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC)) { > > switch (dev) { > > case SD1_BOOT: > > case SD2_BOOT: > > case SD3_BOOT: > > case MMC1_BOOT: > > case MMC2_BOOT: > > case MMC3_BOOT: > > env_loc = ENVL_MMC; > > break; > > default: > > break; > > } > > } > > else if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE)) { > > env_loc = ENVL_MMC; > > } > > > > return env_loc; > > } > > Thanks, this looks ok, just run it through checkpatch to correct the > indentation of 'case' statements and put 'else if' on the same line as > '}': > > if () { > } else if () { > } ... > > Marek Thanks Marek for your review. Sent v2. Let me know, Tommaso