]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
libphy: add phy_find_first function
authorJiri Pirko <jpirko@redhat.com>
Thu, 4 Feb 2010 18:23:02 +0000 (10:23 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 4 Feb 2010 18:23:02 +0000 (10:23 -0800)
Many drivers do this in them manually. Now they can use this function.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy_device.c
include/linux/phy.h

index adbc0fded1305ecad1e44c22cd0fbb6f037d99b6..db1794546c5651e827db0941f6f9b659e48e3d50 100644 (file)
@@ -276,6 +276,22 @@ int phy_device_register(struct phy_device *phydev)
 }
 EXPORT_SYMBOL(phy_device_register);
 
+/**
+ * phy_find_first - finds the first PHY device on the bus
+ * @bus: the target MII bus
+ */
+struct phy_device *phy_find_first(struct mii_bus *bus)
+{
+       int addr;
+
+       for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
+               if (bus->phy_map[addr])
+                       return bus->phy_map[addr];
+       }
+       return NULL;
+}
+EXPORT_SYMBOL(phy_find_first);
+
 /**
  * phy_prepare_link - prepares the PHY layer to monitor link status
  * @phydev: target phy_device struct
index 6a7eb402165d0f6c4dfb8d647f3b2afe725ab4e7..14d7fdf6a90ae229af04e755cd4e25f73f209f1b 100644 (file)
@@ -452,6 +452,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
                u32 flags, phy_interface_t interface);
 struct phy_device * phy_attach(struct net_device *dev,
                const char *bus_id, u32 flags, phy_interface_t interface);
+struct phy_device *phy_find_first(struct mii_bus *bus);
 int phy_connect_direct(struct net_device *dev, struct phy_device *phydev,
                void (*handler)(struct net_device *), u32 flags,
                phy_interface_t interface);