mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 7/9] net: phy: Track mii buses on a list
Date: Wed, 11 Dec 2013 12:41:15 +0100	[thread overview]
Message-ID: <1386762077-23205-8-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1386762077-23205-1-git-send-email-s.hauer@pengutronix.de>

To be able to iterate over registered mii buses

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

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 84c05ad..56cb9b2 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>
 
+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,6 +75,8 @@ 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);
 
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 19e4d20..5f3b33f 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -85,6 +85,8 @@ 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)
 
@@ -92,6 +94,11 @@ int mdiobus_register(struct mii_bus *bus);
 void mdiobus_unregister(struct mii_bus *bus);
 struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
 
+extern struct list_head mii_bus_list;
+
+#define for_each_mii_bus(mii) \
+	list_for_each_entry(mii, &mii_bus_list, list)
+
 /**
  * mdiobus_read - Convenience function for reading a given MII mgmt register
  * @bus: the mii_bus struct
-- 
1.8.5.1


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

  parent reply	other threads:[~2013-12-11 11:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-11 11:41 mii patches Sascha Hauer
2013-12-11 11:41 ` [PATCH 1/9] net: phy: cleanup attached device handling Sascha Hauer
2013-12-11 11:41 ` [PATCH 2/9] net: phy: bail out early in phy_device_connect Sascha Hauer
2013-12-11 11:41 ` [PATCH 3/9] net: phy: move duplicated code out of if/else Sascha Hauer
2013-12-11 11:41 ` [PATCH 4/9] net: phy: check if a phy already has an ethernet device Sascha Hauer
2013-12-11 11:41 ` [PATCH 5/9] net: phy: track registered state of a phy device Sascha Hauer
2013-12-11 11:41 ` [PATCH 6/9] net: phy: move phy_init_hw to phy_device_connect Sascha Hauer
2013-12-11 11:41 ` Sascha Hauer [this message]
2013-12-11 11:41 ` [PATCH 8/9] net: phy: implement detect callback for miibus devices Sascha Hauer
2013-12-11 11:41 ` [PATCH 9/9] miitool: Add option to scan mii buses Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1386762077-23205-8-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox