phy: Add API for {un}registering an mdio device to a bus.

Rather than have drivers directly manipulate the mii_bus structure,
provide and API for registering and unregistering devices on an MDIO
bus, and performing lookups.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/include/linux/mdio.h b/include/linux/mdio.h
index 94f9f14..8cd9579 100644
--- a/include/linux/mdio.h
+++ b/include/linux/mdio.h
@@ -19,9 +19,12 @@
 	struct mii_bus *bus;
 	/* Bus address of the MDIO device (0-31) */
 	int addr;
+	int flags;
 };
 #define to_mdio_device(d) container_of(d, struct mdio_device, dev)
 
+#define MDIO_DEVICE_FLAG_PHY		1
+
 static inline bool mdio_phy_id_is_c45(int phy_id)
 {
 	return (phy_id & MDIO_PHY_ID_C45) && !(phy_id & ~MDIO_PHY_ID_C45_MASK);
@@ -188,4 +191,9 @@
 int mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val);
 int mdiobus_write_nested(struct mii_bus *bus, int addr, u32 regnum, u16 val);
 
+int mdiobus_register_device(struct mdio_device *mdiodev);
+int mdiobus_unregister_device(struct mdio_device *mdiodev);
+bool mdiobus_is_registered_device(struct mii_bus *bus, int addr);
+struct phy_device *mdiobus_get_phy(struct mii_bus *bus, int addr);
+
 #endif /* __LINUX_MDIO_H__ */
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 239a0c2..2d7beef 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -180,7 +180,7 @@
 	struct device dev;
 
 	/* list of all PHYs on bus */
-	struct phy_device *phy_map[PHY_MAX_ADDR];
+	struct mdio_device *mdio_map[PHY_MAX_ADDR];
 
 	/* PHY addresses to be ignored when probing */
 	u32 phy_mask;