Re: [PATCH v2] OF: of_address: clean up OF stub & extern functions

From: Randy Dunlap
Date: Wed May 26 2021 - 21:53:47 EST


On 5/26/21 12:06 PM, Rob Herring wrote:
> On Mon, May 24, 2021 at 2:09 PM Randy Dunlap <rdunlap@xxxxxxxxxxxxx> wrote:
>>
>> Adjust <linux/of_address.h> so that stubs are present when
>> CONFIG_OF is not set *or* OF is set but OF_ADDRESS is not set.
>>
>> This eliminates 2 build errors on arch/s390/ when HAS_IOMEM
>> is not set (so OF_ADDRESS is not set).
>> I.e., it provides a stub for of_iomap() when one was previously
>> not provided as well as removing some duplicate externs.
>
> Personally, I think we should get rid of HAS_IOMEM or at least most of
> its usage in kconfig. It has little purpose beyond hiding drivers in
> kconfig and mainly for UML though I think UML no longer needs that
> IIRC. (I'm not wild about 'depends on OF' either).

There are only over 800 of the latter.

>
>> s390-linux-ld: drivers/irqchip/irq-al-fic.o: in function `al_fic_init_dt':
>> irq-al-fic.c:(.init.text+0x7a): undefined reference to `of_iomap'
>> s390-linux-ld: drivers/clocksource/timer-of.o: in function `timer_of_init':
>> timer-of.c:(.init.text+0xa4): undefined reference to `of_iomap'
>>
>> Tested with many randconfig builds, but there could still be some
>> hidden problem here.
>>
>> Fixes: 4acf4b9cd453 ("of: move of_address_to_resource and of_iomap declarations from sparc")
>> Signed-off-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
>> Cc: Rob Herring <robh+dt@xxxxxxxxxx>
>> Cc: Frank Rowand <frowand.list@xxxxxxxxx>
>> Cc: devicetree@xxxxxxxxxxxxxxx
>> Cc: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
>> Reported-by: kernel test robot <lkp@xxxxxxxxx>
>> ---
>> v2: handle SPARC as a special case since it provides its own versions of
>> of_address_to_resource() and of_iomap();
>> fix build errors reported by lkp/ktr and address comments from Laurent;
>> do more randconfig build testing;
>>
>> include/linux/of_address.h | 11 +++++++----
>> 1 file changed, 7 insertions(+), 4 deletions(-)
>>
>> --- linux-next-20210524.orig/include/linux/of_address.h
>> +++ linux-next-20210524/include/linux/of_address.h
>> @@ -106,11 +106,12 @@ static inline bool of_dma_is_coherent(st
>> }
>> #endif /* CONFIG_OF_ADDRESS */
>>
>> -#ifdef CONFIG_OF
>> +#ifdef CONFIG_SPARC /* SPARC has its own versions of these */
>
> The whole point of CONFIG_OF_ADDRESS is really just for SPARC. So I
> don't really like the mixture of the ifdefs here and in kconfig. It
> looks only more fragile.
>
> Can we drop the HAS_IOMEM dependency from CONFIG_OF_ADDRESS and then
> fix the fallout from that? That would also remove all the other build
> time dependencies on HAS_IOMEM.

so change
config OF_ADDRESS
def_bool y
depends on !SPARC && (HAS_IOMEM || UML)

to
config OF_ADDRESS
def_bool y
depends on !SPARC


I'll run some builds and see what all breaks.

thanks.
--
~Randy