Re: [PATCH 2/2] net, thunder, bgx: Add support for ACPI binding.
From: Arnd Bergmann
Date: Sat Aug 08 2015 - 07:27:37 EST
On Friday 07 August 2015 12:43:20 Robert Richter wrote:
> I would not pollute bgx_probe() with acpi and dt specifics, and instead
> keep bgx_init_phy(). The typical design pattern for this is:
> static int bgx_init_phy(struct bgx *bgx)
> #ifdef CONFIG_ACPI
> if (!acpi_disabled)
> return bgx_init_acpi_phy(bgx);
> return bgx_init_of_phy(bgx);
> This adds acpi runtime detection (acpi=no), does not call dt code in
> case of acpi, and saves the #else for bgx_init_acpi_phy().
What you should really do is to use the same function for both,
using the generic device properties API. If that is not possible,
explain in a comment why not.
Aside from that, if you do have to use compile-time conditionals,
use 'if (IS_ENABLED(CONFIG_ACPI) && !acpi_disabled)' instead of
#ifdef, for readability. The compiler will produce the same binary,
but also give helpful warnings about incorrect code that you don't
get with #ifdef.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/