[PATCH v2 03/14] clocksource: sp804: append CONFIG_OF

Haojian Zhuang haojian.zhuang at linaro.org
Tue Mar 12 23:25:57 EDT 2013


On 13 March 2013 03:17, Arnd Bergmann <arnd at arndb.de> wrote:
> (resending this email as I got a few rejects from mailing lists when
> I accidentally had an invalid email address for Mike)
>
> On Tuesday 12 March 2013, Haojian Zhuang wrote:
>> of_find_matching_node() & of_device_is_available() are depend on CONFIG_OF
>> macro. If CONFIG_OF isn't defined for non-DT mode, the build error
>> occurs.
>>
>> So add CONFIG_OF for those DT functions.
>
> I don't like this patch too much:
>
> We should be able to do this without the #ifdef. The problem is really that the
> declarations are also hidden behind an #ifdef. I think we should change the
> linux/of.h header file to either provide alternative empty inline functions
> or at least leave the declarations visible so we can compile the code as
> long as the call gets discarded.
>
>>
>> +#ifdef CONFIG_OF
>>  static struct device_node *from = NULL;
>>
>>  static struct of_device_id sp804_timer_match[] __initdata = {
>> @@ -294,3 +295,4 @@ err:
>>       iounmap(base);
>>  }
>>  CLOCKSOURCE_OF_DECLARE(sp804, "arm,sp804", sp804_dt_init);
>> +#endif
>
> There is actually an empty definition for CLOCKSOURCE_OF_DECLARE(),
> but I think it would be better to still define it the same way as
> with CONFIG_OF enabled but attribute((__unused__)), like:
>
> #ifdef CONFIG_CLKSRC_OF
> extern void clocksource_of_init(void);
> #define CLOCKSOURCE_OF_DECLARE(name, compat, fn)                        \
>         static const struct of_device_id __clksrc_of_table_##name       \
>                 __used __section(__clksrc_of_table)                     \
>                  = { .compatible = compat, .data = fn };
> #else
> static inline void clocksource_of_init(void) {}
> #define CLOCKSOURCE_OF_DECLARE(name, compat, fn)                        \
>         static const struct of_device_id __clksrc_of_table_##name       \
>                 __unused = { .compatible = compat, .data = fn };
> #endif
>
> This way, all the code still gets built, but since there is nothing
> pointing to __clksrc_of_table_##name and it is marked __unused, it
> gets dropped along with all other symbols that are only referenced
> from it.
>
>         Arnd
>

If CONFIG_CLKSRC_OF is depend on CONFIG_USEOF, I think that
we can resolve all these issue. We don't need to define
CLOCKSOURCE_OF_DECLARE() for non-DT mode, and we also
don't need to define of_device_is_available(), ... in non-DT mode.

We only need to add "depends on USE_OF" for CLKSRC_OF
configuration. It's simpler. What's your opinion?

Regards
Haojian



More information about the linux-arm-kernel mailing list