Thread (14 messages) 14 messages, 4 authors, 2013-06-05

[PATCHv2 1/3] net: phy: prevent linking breakage

From: arnd@arndb.de (Arnd Bergmann)
Date: 2013-06-04 15:07:59
Also in: lkml, netdev

On Thursday 30 May 2013 02:42:01 David Miller wrote:
From: Alexandre Belloni <redacted>
quoted
On 28/05/2013 22:09, David Miller wrote:
But that is making it impossible to compile a kernel without any network
stack for those platforms or we are going back to either enclosing the
calls to phy_register_fixup{,_for_uid,_for_id} with #ifdef CONFIG_PHYLIB
or if(IS_BUILTIN(CONFIG_PHYLIB)). And as you can see, it is quite error
prone and is done only done for 2 platforms on a total of 6. I believe
fixing that in phy.h is more foolproof.
Or you properly segregate the networking bits of the platform code so
that it can be built only when the necessary networking portions are
enabled.

Sometimes having dummy stubs makes sense, but not in this situation.
Currently most users of this function are doing something like

static int foo_phy_fixup(struct phy_device *phydev)
{
	...
}

static int __init boo_board_init(void)
{
	 if (IS_BUILTIN(CONFIG_PHYLIB))
		phy_register_fixup_for_uid(phy_id, foo_phy_fixup);
}

which is practically the same as having a dummy stub. It leads to
the foo_phy_fixup() function always getting compiled and then discarded
by gcc when CONFIG_PHYLIB is disabled.

The method is currently broken when network drivers are enabled as
modules, because we are missing the fixup then.

I think we should use IS_ENABLED() here to force a build error
in that case, and have something like

config ARCH_FOO
	bool "support for the foo platform"
	select PHYLIB if NET

in the platform Kconfig file, to ensure PHYLIB is always built-in.

I still think the inline alternatives would be helpful, but using
if (IS_ENABLED(CONFIG_PHYLIB)) in the platform code would also
work.

	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