Thread (39 messages) 39 messages, 11 authors, 2013-06-21

[PATCH 15/15] OF: remove #ifdef from linux/of_platform.h

From: arnd@arndb.de (Arnd Bergmann)
Date: 2013-06-04 17:51:09
Also in: lkml

On Tuesday 04 June 2013, Rob Herring wrote:
On Sat, Jun 1, 2013 at 3:57 PM, Arnd Bergmann [off-list ref] wrote:
quoted
On Saturday 01 June 2013, Rob Herring wrote:
quoted
No, we still need empty functions. Here is what of_device.h looks like:

http://tinyurl.com/l2azz5m

BTW, it has your ack.
Could you add a patch on top that only puts the function declarations
inside of #ifdef that don't have an inline wrapper?
I'm confused. You mean that DO have an inline? Like this:

void foo(void);

#ifdef CONFIG_OF
void bar(void);
#else
static inline void bar(void) {}
#endif
Yes, sorry. That's what I meant.
quoted
It's really annoying to have to change the header file every time one
needs to call a function from a driver in the DT-only case.
The functions without inlines are ones that drivers should not call
and should only be called from OF enabled code. That's why we have not
done a complete pass of adding inlines for everything.
The problem is that it's a bad default. The convention in kernel code
is not to hide declarations in #ifdef, for multiple reasons:

* It avoids unnecessary code rebuilds when the symbol changes between 
  two 'make' runs.

* It lets drivers and platform code call the function from dead code
  without causing a build error, thus improving compile coverage.

* It's much nicer to read when can write your code like

void __init exynos_init_io(struct map_desc *mach_desc, int size)
{
        if (IS_ENABLED_(CONFIG_OF) && initial_boot_params)
                of_scan_flat_dt(exynos_fdt_map_chipid, NULL);
        else
                iotable_init(exynos_iodesc, ARRAY_SIZE(exynos_iodesc));
	...
}

instead of

void __init exynos_init_io(struct map_desc *mach_desc, int size)
{
#ifdef CONFIG_OF
        if (initial_boot_params)
                of_scan_flat_dt(exynos_fdt_map_chipid, NULL);
        else
#endif
                iotable_init(exynos_iodesc, ARRAY_SIZE(exynos_iodesc));
	...
}

The first one looks like actual C code, the second is really ugly,
and an inline wrapper wouldn't even do the right thing here.

	Arnd
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help