mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] net phy: Add support for finding a mdio bus by its name
@ 2013-02-07 11:09 Sascha Hauer
  2013-02-07 11:09 ` [PATCH 2/2] miitool: Add support for examing mdio bus Sascha Hauer
  2013-02-07 12:02 ` [PATCH 1/2] net phy: Add support for finding a mdio bus by its name Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 2 replies; 15+ messages in thread
From: Sascha Hauer @ 2013-02-07 11:09 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/phy/mdio_bus.c |   19 +++++++++++++++++++
 include/linux/phy.h        |    3 +++
 2 files changed, 22 insertions(+)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index d1d802b..3c4be1c 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -25,6 +25,8 @@
 #include <linux/phy.h>
 #include <linux/err.h>
 
+static LIST_HEAD(mii_bus_list);
+
 /**
  * mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
  * @bus: target mii_bus
@@ -57,6 +59,8 @@ int mdiobus_register(struct mii_bus *bus)
 	if (bus->reset)
 		bus->reset(bus);
 
+	list_add_tail(&bus->list, &mii_bus_list);
+
 	pr_info("%s: probed\n", dev_name(&bus->dev));
 	return 0;
 }
@@ -71,9 +75,24 @@ void mdiobus_unregister(struct mii_bus *bus)
 			unregister_device(&bus->phy_map[i]->dev);
 		bus->phy_map[i] = NULL;
 	}
+
+	list_del(&bus->list);
 }
 EXPORT_SYMBOL(mdiobus_unregister);
 
+struct mii_bus *mdiobus_find(const char *name)
+{
+	struct mii_bus *bus;
+
+	list_for_each_entry(bus, &mii_bus_list, list) {
+		if (!strcmp(dev_name(&bus->dev), name))
+			return bus;
+	}
+
+	return NULL;
+}
+EXPORT_SYMBOL(mdiobus_find);
+
 struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
 {
 	struct phy_device *phydev;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 6c9cac9..9ab6e06 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -84,11 +84,14 @@ struct mii_bus {
 
 	/* PHY addresses to be ignored when probing */
 	u32 phy_mask;
+
+	struct list_head list;
 };
 #define to_mii_bus(d) container_of(d, struct mii_bus, dev)
 
 int mdiobus_register(struct mii_bus *bus);
 void mdiobus_unregister(struct mii_bus *bus);
+struct mii_bus *mdiobus_find(const char *name);
 struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
 
 /**
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread
* [PATCH v2] add mdio bus support to miitool
@ 2013-02-08  9:24 Sascha Hauer
  2013-02-08  9:24 ` [PATCH 2/2] miitool: Add support for examing mdio bus Sascha Hauer
  0 siblings, 1 reply; 15+ messages in thread
From: Sascha Hauer @ 2013-02-08  9:24 UTC (permalink / raw)
  To: barebox

2nd version. This adds both the mdio buses and the phy devices
to the mdio_bus_type. This is in sync with Linux which also
adds the buses (for example i2c_adapter) and the devices (for example
i2c devices) to the same bus type. Linux uses a struct device_type
pointer in struct device to distinguish between both. As we do
not have this struct, we use the type_data field which has the
same purpose.

----------------------------------------------------------------
Sascha Hauer (2):
      net phy: Add mdio buses to mdio_bus_type
      miitool: Add support for examing mdio bus

 commands/miitool.c         |   94 +++++++++++++++++++++++++++++++++++---------
 drivers/net/phy/mdio_bus.c |   18 +++++++++
 drivers/net/phy/phy.c      |    1 +
 include/linux/phy.h        |    7 ++++
 4 files changed, 101 insertions(+), 19 deletions(-)

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-02-12  7:36 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-07 11:09 [PATCH 1/2] net phy: Add support for finding a mdio bus by its name Sascha Hauer
2013-02-07 11:09 ` [PATCH 2/2] miitool: Add support for examing mdio bus Sascha Hauer
2013-02-07 12:02 ` [PATCH 1/2] net phy: Add support for finding a mdio bus by its name Jean-Christophe PLAGNIOL-VILLARD
2013-02-07 12:20   ` Sascha Hauer
2013-02-07 12:26     ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-07 12:46       ` Sascha Hauer
2013-02-07 16:05         ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-07 17:43           ` Sascha Hauer
2013-02-07 18:23             ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-07 18:29               ` Sascha Hauer
2013-02-08  9:24 [PATCH v2] add mdio bus support to miitool Sascha Hauer
2013-02-08  9:24 ` [PATCH 2/2] miitool: Add support for examing mdio bus Sascha Hauer
2013-02-08 11:02   ` Alexander Aring
2013-02-11 11:40     ` Sascha Hauer
2013-02-11 23:13       ` Alexander Aring
2013-02-12  7:35         ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox