public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Hiroshi Doyu <hdoyu@nvidia.com>
Cc: "balbi@ti.com" <balbi@ti.com>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
	"swarren@wwwdotorg.org" <swarren@wwwdotorg.org>,
	"linux@arm.linux.org.uk" <linux@arm.linux.org.uk>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/4] ARM: tegra: Unify tegra{20,30,114}_init_early()
Date: Sat, 9 Feb 2013 12:18:41 +0000	[thread overview]
Message-ID: <201302091218.41699.arnd@arndb.de> (raw)
In-Reply-To: <20130208.100942.592982910310763762.hdoyu@nvidia.com>

On Friday 08 February 2013, Hiroshi Doyu wrote:
> > > +#if defined(CONFIG_ARCH_TEGRA_3x_SOC)
> >
> > how about using:
> >
> > #if IS_BUILTIN(CONFIG_ARCH_TEGRA_3x_SOC)
> >
> > instead ?
> 
> Why is IS_BUILTIN() prefered?
> 

Inside of a function, if(IS_ENABLED(CONFIG_FOO)) or the respective IS_BUILTIN is
preferred over #ifdef because it provides better compile coverage and better
readability. Also, IS_ENABLED() is nice when you want to check if something
is builtin or module, without having to write a complex expression.

If you just replace the #ifdef with #if IS_BUILTIN as Felipe suggested, I see
no real benefit, but it would be nice to write this as


void __init tegra_hotplug_init(void)
{
	if (!IS_ENABLED(CONFIG_HOTPLUG_CPU))
		return;
	
	if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC)) && tegra_chip_id == TEGRA20)
		tegra_hotplug_shutdown = tegra20_hotplug_shutdown;
	if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC)) && tegra_chip_id == TEGRA30)
		tegra_hotplug_shutdown = tegra30_hotplug_shutdown;
}

which completely avoids all preprocessor conditionals and replaces them
with compile-time choices based on constant expressions to eliminate the
code paths for disabled platforms.

	Arnd

  reply	other threads:[~2013-02-09 12:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1360308574-19658-1-git-send-email-hdoyu@nvidia.com>
2013-02-08  7:29 ` [PATCH 1/4] ARM: tegra: Unify tegra{20,30,114}_init_early() Hiroshi Doyu
2013-02-08  7:47   ` Felipe Balbi
2013-02-08  8:09     ` Hiroshi Doyu
2013-02-09 12:18       ` Arnd Bergmann [this message]
2013-02-08 12:29   ` Marc Dietrich
2013-02-08 17:09     ` Stephen Warren
2013-02-10 17:28       ` Marc Dietrich
2013-02-10 20:20         ` Stephen Warren
2013-02-10 21:16           ` Marc Dietrich
2013-02-11  4:18             ` Hiroshi Doyu
2013-02-08  7:29 ` [PATCH 2/4] ARM: tegra: Unify board-dt-tegra{30,114}.c Hiroshi Doyu
2013-02-08  7:29 ` [PATCH 3/4] ARM: tegra: Unify board-dt-tegra{20,30}.c to tegra.c Hiroshi Doyu
2013-02-08  7:29 ` [PATCH 4/4] ARM: tegra: Restore USB/PCIE info in new DT board file Hiroshi Doyu
2013-02-08 17:58   ` Stephen Warren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201302091218.41699.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=balbi@ti.com \
    --cc=hdoyu@nvidia.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=swarren@wwwdotorg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox