Re: [PATCH] net: davinci: fix building davinci mdio code without CONFIG_OF

From: Arnd Bergmann
Date: Tue May 29 2018 - 10:31:34 EST


On Tue, May 29, 2018 at 3:25 PM, Sekhar Nori <nsekhar@xxxxxx> wrote:

>> @@ -374,7 +372,7 @@ static int davinci_mdio_probe(struct platform_device *pdev)
>> return -ENOMEM;
>> }
>>
>> - if (dev->of_node) {
>> + if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
>> const struct of_device_id *of_id;
>>
>> ret = davinci_mdio_probe_dt(&data->pdata, pdev);
>
> I was expecting this one change to fix the issue since the if() block
> should be compiled away removing references to davinci_mdio_probe_dt().
>
> The code does get compiled out and there are no references to
> davinci_mdio_probe_dt() in the final object when !CONFIG_OF.
>
> But the compile error remains if the #ifdefs you removed above are
> installed back. Not sure why.

The way that "if (IS_ENABLED())" works, everything gets compiled at
first, but then the compiler uses dead code elimination to remove it
from the output after verifying that everything builds.

Arnd