[lkml]   [2017]   [Feb]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
SubjectRe: [PATCH] [net-next] ARM: orion: fix PHYLIB dependency
On Friday, February 10, 2017 9:42:21 AM CET Florian Fainelli wrote:
> On 02/10/2017 12:20 AM, Arnd Bergmann wrote:
> > On Thu, Feb 9, 2017 at 7:22 PM, Florian Fainelli <> wrote:
> >> On 02/09/2017 07:08 AM, Arnd Bergmann wrote:
> >> I disabled CONFIG_NETDEVICES to force CONFIG_PHY not to be set here, and
> >> I was not able to reproduce this, what am I missing?
> >
> > In the ARMv5 allmodconfig build, this fails because CONFIG_PHY=m, and
> > we can't call into it. You could use IS_BUILTIN instead of IS_ENABLED in
> > the header as a oneline workaround, but I think that would be more confusing
> > to real users that try to use CONFIG_PHY=m without realizing why they lose
> > access to their switch.
> I see, this patch should also help fixing this:

I think you still have the same problem, as you can still have the
boardinfo registration in a loadable module.

I have come up with a patch too now and done some randconfig testing
on it (it took me several tries as well), please see below. It does
some of the same things as yours and some others.

The main trick is to have a separate 'MDIO_BOARDINFO' Kconfig symbol
that can be selected regardless of all the other symbols, and that
will lead to the registration being either built-in when it's needed
or not built at all when either no board calls it, or PHYLIB is

From f35e89cacfabdf7b822772013389132605941def Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <>
Date: Wed, 27 Apr 2016 11:51:18 +0200
Subject: [PATCH] [RFC] move ethernet PHY config into drivers/phy/Kconfig

Calling mdiobus_register_board_info from builtin code with CONFIG_PHYLIB=m
currently results in a link error:

arch/arm/plat-orion/common.o: In function `orion_ge00_switch_init':
common.c:(.init.text+0x6a4): undefined reference to `mdiobus_register_board_info'

As the long-term strategy is to separate mdio from phylib, and to get generic-phy
and (networking-only) phylib closer together, this performs a first step in that
direction: The Kconfig file for phylib gets logically pulled under the PHY
driver configuration and becomes independent from networking. This lets us
select the new CONFIG_MDIO_BOARDINFO from platforms that need it, and provide
the functions exactly when we need them.

In the same step, we can also split out the MDIO driver configuration from
phylib. This is based on an older experimental patch I had, but it still
requires some code changes in phylib itself to let users actually rely on
MDIO without all of PHYLIB.

Signed-off-by: Arnd Bergmann <>

diff --git a/arch/arm/mach-orion5x/Kconfig b/arch/arm/mach-orion5x/Kconfig
index 468b8cb7fd5f..e1126e1aa3d2 100644
--- a/arch/arm/mach-orion5x/Kconfig
+++ b/arch/arm/mach-orion5x/Kconfig
@@ -4,6 +4,7 @@ menuconfig ARCH_ORION5X
select GPIOLIB
select PCI
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index a993cbeb9e0c..9eb15b7518bd 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -378,8 +378,6 @@ config NET_SB1000

If you don't have this card, of course say N.

-source "drivers/net/phy/Kconfig"
source "drivers/net/plip/Kconfig"

source "drivers/net/ppp/Kconfig"
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 7336cbd3ef5d..3ab87e9f9442 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -17,7 +17,7 @@ obj-$(CONFIG_MII) += mii.o
obj-$(CONFIG_MDIO) += mdio.o
obj-$(CONFIG_NET) += Space.o loopback.o
obj-$(CONFIG_NETCONSOLE) += netconsole.o
-obj-$(CONFIG_PHYLIB) += phy/
+obj-y+= phy/
obj-$(CONFIG_RIONET) += rionet.o
obj-$(CONFIG_NET_TEAM) += team/
obj-$(CONFIG_TUN) += tun.o
diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig
index 8c08f9deef92..9c4652ae2750 100644
--- a/drivers/net/ethernet/Kconfig
+++ b/drivers/net/ethernet/Kconfig
@@ -11,9 +11,6 @@ menuconfig ETHERNET


-config MDIO
- tristate

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 8dbd59baa34d..37f5552cc5b3 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -3,8 +3,9 @@

menuconfig PHYLIB
- tristate "PHY Device support and infrastructure"
+ tristate "Ethernet PHY Device support and infrastructure"
depends on NETDEVICES
+ select MDIO
Ethernet controllers are usually attached to PHY
devices. This option provides infrastructure for
@@ -248,6 +249,16 @@ config FIXED_PHY
PHYs that are not connected to the real MDIO bus.

Currently tested with mpc866ads and mpc8349e-mitx.
+endif # PHYLIB
+config MDIO
+ tristate
+ help
+ The MDIO bus is typically used ethernet PHYs, but can also be
+ used by other PHY drivers.
+menu "MDIO bus drivers"
+ depends on MDIO

tristate "ICPlus PHYs"
@@ -340,7 +351,10 @@ config XILINX_GMII2RGMII
the Reduced Gigabit Media Independent Interface(RGMII) between
Ethernet physical media devices and the Gigabit Ethernet controller.

-endif # PHYLIB
+endmenu # MDIO
+ bool

config MICREL_KS8995MA
tristate "Micrel KS8995MA 5-ports 10/100 managed Ethernet switch"
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 407b0b601ea8..e60e5d2fae53 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -1,11 +1,13 @@
# Makefile for Linux PHY drivers and MDIO bus drivers

-libphy-y := phy.o phy_device.o mdio_bus.o mdio_device.o \
- mdio-boardinfo.o
+libphy-y := phy.o phy_device.o mdio_bus.o mdio_device.o
libphy-$(CONFIG_SWPHY) += swphy.o
libphy-$(CONFIG_LED_TRIGGER_PHY) += phy_led_triggers.o

obj-$(CONFIG_PHYLIB) += libphy.o
+obj-$(CONFIG_MDIO_BOARDINFO) += mdio-boardinfo.o

obj-$(CONFIG_MDIO_BCM_IPROC) += mdio-bcm-iproc.o
obj-$(CONFIG_MDIO_BCM_UNIMAC) += mdio-bcm-unimac.o
diff --git a/drivers/net/phy/mdio-boardinfo.c b/drivers/net/phy/mdio-boardinfo.c
index 6b988f77da08..f7cf98093344 100644
--- a/drivers/net/phy/mdio-boardinfo.c
+++ b/drivers/net/phy/mdio-boardinfo.c
@@ -55,6 +55,7 @@ void mdiobus_setup_mdiodev_from_board_info(struct mii_bus *bus)

* mdio_register_board_info - register MDIO devices for a given board
diff --git a/drivers/net/phy/mdio-boardinfo.h b/drivers/net/phy/mdio-boardinfo.h
index 00f98163e90e..3a72bd978114 100644
--- a/drivers/net/phy/mdio-boardinfo.h
+++ b/drivers/net/phy/mdio-boardinfo.h
@@ -14,6 +14,12 @@ struct mdio_board_entry {
struct mdio_board_info board_info;

void mdiobus_setup_mdiodev_from_board_info(struct mii_bus *bus);
+static inline void mdiobus_setup_mdiodev_from_board_info(struct mii_bus *bus)

#endif /* __MDIO_BOARD_INFO_H */
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 519241bc8817..87c581f11297 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -2,7 +2,9 @@

-menu "PHY Subsystem"
+menu "PHY drivers"
+menu "Generic PHY subsystem"

bool "PHY Core"
@@ -515,3 +517,7 @@ config PHY_NSP_USB3
Enable this to support the Broadcom Northstar plus USB3 PHY.
If unsure, say N.
+source "drivers/net/phy/Kconfig"
diff --git a/include/linux/phy.h b/include/linux/phy.h
index d9bdf53e0514..2ec82a4c3b8f 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -893,7 +893,7 @@ struct mdio_board_info {
const void *platform_data;

int mdiobus_register_board_info(const struct mdio_board_info *info,
unsigned int n);
 \ /
  Last update: 2017-02-10 21:07    [W:0.070 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site