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 87198C433F5 for ; Tue, 14 Dec 2021 12:45:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 292CA810EC; Tue, 14 Dec 2021 13:45:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org 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=kernel.org header.i=@kernel.org header.b="Sm29Ejoj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AA8E6811BB; Tue, 14 Dec 2021 13:45:45 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BC43E810EC for ; Tue, 14 Dec 2021 13:45:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kabel@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 60067B81978; Tue, 14 Dec 2021 12:45:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51BD4C34605; Tue, 14 Dec 2021 12:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639485941; bh=WoWCRsUBce+fqWi1XbVGiiB225jnBgUs86Yh90b7CAU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Sm29EjojwbTxVgu4qd2bnhUiLg9Srqm+ss95hbseoRyriIypqWTghOpErVzDQFTIa cy2tnmsQ+CVYqItsL94pbzdt7p0rZpZM24i+OLe7RtsXKgTrJBtXkvrYNjHu8VPY9Q bpqvOSlIAtbcP70/qLmcUDaqkUAnj+ieYVt5LNhw9OK6ejCstxdiLsr/b3BSieWO6P iTihQKDAdI11sdIfXALmCQrbKbCCZhYwap0JYirZI+aaJi8/ndG+DPpEy5y6P2n6WG mZK5Fx249nn1xA4f4E8q3rxY32tVcwc3GveT7Wjlj9bnRCy7rBj2LGFcfF1iXN4431 srMnzfW08uT4Q== Date: Tue, 14 Dec 2021 13:45:36 +0100 From: Marek =?UTF-8?B?QmVow7pu?= To: Pali =?UTF-8?B?Um9ow6Fy?= Cc: Stefan Roese , u-boot@lists.denx.de, Marek =?UTF-8?B?QmVo?= =?UTF-8?B?w7pu?= Subject: Re: [PATCH u-boot-marvell v2 8/9] arm: mvebu: spl: Use IS_ENABLED() instead of #ifdef where possible Message-ID: <20211214134536.2baeb2a0@thinkpad> In-Reply-To: <20211214111234.ie54zex6veoirfam@pali> References: <20211126143738.23830-1-kabel@kernel.org> <20211126143738.23830-9-kabel@kernel.org> <20211214093600.e2sy5yrtpz7gvfna@pali> <20211214104515.2ae03d0d@thinkpad> <20211214111234.ie54zex6veoirfam@pali> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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 Tue, 14 Dec 2021 12:12:34 +0100 Pali Roh=C3=A1r wrote: > On Tuesday 14 December 2021 10:45:15 Marek Beh=C3=BAn wrote: > > On Tue, 14 Dec 2021 10:36:00 +0100 > > Pali Roh=C3=A1r wrote: > > =20 > > > On Friday 26 November 2021 15:37:37 Marek Beh=C3=BAn wrote: =20 > > > > @@ -340,17 +333,17 @@ void board_init_f(ulong dummy) > > > > timer_init(); > > > > =20 > > > > /* Armada 375 does not support SerDes and DDR3 init yet */ > > > > -#if !defined(CONFIG_ARMADA_375) > > > > - /* First init the serdes PHY's */ > > > > - serdes_phy_config(); > > > > - > > > > - /* Setup DDR */ > > > > - ret =3D ddr3_init(); > > > > - if (ret) { > > > > - debug("ddr3_init() failed: %d\n", ret); > > > > - hang(); > > > > + if (!IS_ENABLED(CONFIG_ARMADA_375)) { > > > > + /* First init the serdes PHY's */ > > > > + serdes_phy_config(); > > > > + > > > > + /* Setup DDR */ > > > > + ret =3D ddr3_init(); > > > > + if (ret) { > > > > + debug("ddr3_init() failed: %d\n", ret); > > > > + hang(); > > > > + } > > > > } > > > > -#endif =20 > > >=20 > > > As written in comment above there is no SerDes and DDR3 support for > > > Armada 375 and therefore there is no serdes_phy_config() or ddr3_init= () > > > function. So this code needs not to be compiled at all and usage of > > > #ifdef is correct here. =20 > >=20 > > #ifdefs are almost never correct in C-files, for the parts of the code > > they guard isn't put through syntactic analysis, and can therefore > > contain bugs which we are not warned about. > >=20 > > Using if (IS_ENABLED()) almost never producess a different binary, > > because the code is optimized away. > >=20 > > Marek =20 >=20 > There is no function serdes_phy_config() for Armada 375, so if you put > it outside of #ifdef you will get compile error. The function is always declared in arch/arm/mach-mvebu/include/mach/cpu.h regardless of architecture. Thus an error will be raised only when linking, and the compliation was done with -O0, which I don't think anyone does. Anyway, if we want to support -O0, this can and should be solved via defining serdes_phy_config() as empty static inline function in the cpu.h header, guarded by #ifdef. In header files #ifdefs are allowed, in this manner: #if X declare function #else define that function as empty static inline #endif So if you think we should support -O0, I can do this. But the #ifdefs should really go away from real C code, that is the way both Linux and U-Boot are trying to go for the last couple of years, if I understand it correctly. Marek