[PATCH 3/5] net: phy: Add missing phy_unregister_device

Sascha Hauer s.hauer at pengutronix.de
Tue Apr 28 04:05:35 PDT 2015


The counterpart of phy_register_device is missing. Add it.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/net/phy/phy.c | 11 +++++++++++
 include/linux/phy.h   |  1 +
 2 files changed, 12 insertions(+)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index f3dffca..edf5d03 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -272,6 +272,17 @@ int phy_register_device(struct phy_device *phydev)
 	return ret;
 }
 
+void phy_unregister_device(struct phy_device *phydev)
+{
+	if (!phydev->registered)
+		return;
+
+	phydev->bus->phy_map[phydev->addr] = NULL;
+
+	unregister_device(&phydev->dev);
+	phydev->registered = 0;
+}
+
 static struct phy_device *of_mdio_find_phy(struct eth_device *edev)
 {
 	struct device_d *dev;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index c0fd4ff..9a451a6 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -266,6 +266,7 @@ int phy_init(void);
 int phy_init_hw(struct phy_device *phydev);
 
 int phy_register_device(struct phy_device* dev);
+void phy_unregister_device(struct phy_device *phydev);
 
 /**
  * phy_read - Convenience function for reading a given PHY register
-- 
2.1.4




More information about the barebox mailing list