diff mbox series

[2/2] eth phy: add mdio bus char device interface

Message ID 1529292733-13243-2-git-send-email-liwei1412@163.com
State Changes Requested, archived
Delegated to: David Miller
Headers show
Series [1/2] eth phy: add mdio bus char device interface | expand

Commit Message

Wei Li June 18, 2018, 3:32 a.m. UTC
Add the notifier for the change of mdio bus, since i wanna that a char device
represents a mii_bus not a mdio_device.

Signed-off-by: Wei Li <liwei1412@163.com>
---
 drivers/net/phy/mdio_bus.c | 21 ++++++++++++++++++++-
 include/linux/mdio.h       |  1 +
 include/linux/phy.h        |  2 ++
 3 files changed, 23 insertions(+), 1 deletion(-)

Comments

kernel test robot June 18, 2018, 6:52 a.m. UTC | #1
Hi Wei,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Wei-Li/eth-phy-add-mdio-bus-char-device-interface/20180618-115206
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 8.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=8.1.0 make.cross ARCH=ia64 

All errors (new ones prefixed by >>):

   ERROR: "ia64_delay_loop" [drivers/spi/spi-thunderx.ko] undefined!
   ERROR: "__sw_hweight8" [drivers/net/wireless/mediatek/mt76/mt76.ko] undefined!
>> ERROR: "mdiobus_unregister_notifier" [drivers/net/phy/mdio-dev.ko] undefined!
>> ERROR: "mdiobus_register_notifier" [drivers/net/phy/mdio-dev.ko] undefined!
   ERROR: "ia64_delay_loop" [drivers/net/phy/mdio-cavium.ko] undefined!

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 24b5511..3821dc8 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -240,10 +240,25 @@  static void mdiobus_release(struct device *d)
 	kfree(bus);
 }
 
-static struct class mdio_bus_class = {
+struct class mdio_bus_class = {
 	.name		= "mdio_bus",
 	.dev_release	= mdiobus_release,
 };
+EXPORT_SYMBOL_GPL(mdio_bus_class);
+
+static BLOCKING_NOTIFIER_HEAD(mdio_bus_notifier_list);
+
+int mdiobus_register_notifier(struct notifier_block *nb)
+{
+    return blocking_notifier_chain_register(
+				&mdio_bus_notifier_list, nb);
+}
+
+int mdiobus_unregister_notifier(struct notifier_block *nb)
+{
+    return blocking_notifier_chain_unregister(
+				&mdio_bus_notifier_list, nb);
+}
 
 #if IS_ENABLED(CONFIG_OF_MDIO)
 /* Helper function for of_mdio_find_bus */
@@ -418,6 +433,8 @@  int __mdiobus_register(struct mii_bus *bus, struct module *owner)
 	mdiobus_setup_mdiodev_from_board_info(bus, mdiobus_create_device);
 
 	bus->state = MDIOBUS_REGISTERED;
+	blocking_notifier_call_chain(&mdio_bus_notifier_list,
+					BUS_NOTIFY_ADD_DEVICE, &bus->dev);
 	pr_info("%s: probed\n", bus->name);
 	return 0;
 
@@ -446,6 +463,8 @@  void mdiobus_unregister(struct mii_bus *bus)
 	int i;
 
 	BUG_ON(bus->state != MDIOBUS_REGISTERED);
+	blocking_notifier_call_chain(&mdio_bus_notifier_list,
+					BUS_NOTIFY_DEL_DEVICE, &bus->dev);
 	bus->state = MDIOBUS_UNREGISTERED;
 
 	for (i = 0; i < PHY_MAX_ADDR; i++) {
diff --git a/include/linux/mdio.h b/include/linux/mdio.h
index 2cfffe5..29ab455 100644
--- a/include/linux/mdio.h
+++ b/include/linux/mdio.h
@@ -79,6 +79,7 @@  void mdio_device_reset(struct mdio_device *mdiodev, int value);
 int mdio_driver_register(struct mdio_driver *drv);
 void mdio_driver_unregister(struct mdio_driver *drv);
 int mdio_device_bus_match(struct device *dev, struct device_driver *drv);
+extern struct class mdio_bus_class;
 
 static inline bool mdio_phy_id_is_c45(int phy_id)
 {
diff --git a/include/linux/phy.h b/include/linux/phy.h
index f0b5870..39f2609 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -246,6 +246,8 @@  int __mdiobus_register(struct mii_bus *bus, struct module *owner);
 #define mdiobus_register(bus) __mdiobus_register(bus, THIS_MODULE)
 void mdiobus_unregister(struct mii_bus *bus);
 void mdiobus_free(struct mii_bus *bus);
+int mdiobus_register_notifier(struct notifier_block *nb);
+int mdiobus_unregister_notifier(struct notifier_block *nb);
 struct mii_bus *devm_mdiobus_alloc_size(struct device *dev, int sizeof_priv);
 static inline struct mii_bus *devm_mdiobus_alloc(struct device *dev)
 {