* [PATCH] phylib delayed scan
@ 2012-10-30 16:32 Sascha Hauer
2012-10-30 16:32 ` [PATCH 1/2] mdiobus: return existing phydev in mdiobus_scan Sascha Hauer
2012-10-30 16:32 ` [PATCH 2/2] mdiobus: do not scan the bus at registration time Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2012-10-30 16:32 UTC (permalink / raw)
To: barebox
As mentioned scanning the mdiobus for devices can take some time which
unnecessarily delays the boot when no network is needed, so scan the bus
when somebody is interested in the devices.
Sascha
----------------------------------------------------------------
Sascha Hauer (2):
mdiobus: return existing phydev in mdiobus_scan
mdiobus: do not scan the bus at registration time
drivers/net/phy/mdio_bus.c | 26 ++++----------------------
drivers/net/phy/phy.c | 4 ++--
2 files changed, 6 insertions(+), 24 deletions(-)
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] mdiobus: return existing phydev in mdiobus_scan
2012-10-30 16:32 [PATCH] phylib delayed scan Sascha Hauer
@ 2012-10-30 16:32 ` Sascha Hauer
2012-10-30 16:32 ` [PATCH 2/2] mdiobus: do not scan the bus at registration time Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2012-10-30 16:32 UTC (permalink / raw)
To: barebox
Test if we already found a phy device on an address earlier and return
it if it exists. This makes it possible to call mdiobus_scan multiple
times.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/phy/mdio_bus.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index b49f714..5025e3f 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -101,6 +101,9 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
{
struct phy_device *phydev;
+ if (bus->phy_map[addr])
+ return bus->phy_map[addr];
+
phydev = get_phy_device(bus, addr);
if (IS_ERR(phydev) || phydev == NULL)
return phydev;
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] mdiobus: do not scan the bus at registration time
2012-10-30 16:32 [PATCH] phylib delayed scan Sascha Hauer
2012-10-30 16:32 ` [PATCH 1/2] mdiobus: return existing phydev in mdiobus_scan Sascha Hauer
@ 2012-10-30 16:32 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2012-10-30 16:32 UTC (permalink / raw)
To: barebox
Scanning the bus can take some time. If we do not need the ethernet
device, this is unnecessary, so delay the scan until the phy device
iactually is needed.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/phy/mdio_bus.c | 23 +----------------------
drivers/net/phy/phy.c | 4 ++--
2 files changed, 3 insertions(+), 24 deletions(-)
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 5025e3f..35319b4 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -36,7 +36,7 @@
*/
int mdiobus_register(struct mii_bus *bus)
{
- int i, err;
+ int err;
if (NULL == bus ||
NULL == bus->read ||
@@ -59,29 +59,8 @@ int mdiobus_register(struct mii_bus *bus)
if (bus->reset)
bus->reset(bus);
- for (i = 0; i < PHY_MAX_ADDR; i++) {
- if ((bus->phy_mask & (1 << i)) == 0) {
- struct phy_device *phydev;
-
- phydev = mdiobus_scan(bus, i);
- if (IS_ERR(phydev)) {
- err = PTR_ERR(phydev);
- goto error;
- }
- }
- }
-
pr_info("%s: probed\n", dev_name(&bus->dev));
return 0;
-
-error:
- while (--i >= 0) {
- if (bus->phy_map[i]) {
- kfree(bus->phy_map[i]);
- bus->phy_map[i] = NULL;
- }
- }
- return err;
}
EXPORT_SYMBOL(mdiobus_register);
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 88c3ff7..8d36300 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -154,7 +154,7 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
if (!edev->phydev) {
if (addr >= 0) {
- dev = bus->phy_map[addr];
+ dev = mdiobus_scan(bus, addr);
if (!dev) {
ret = -EIO;
goto fail;
@@ -169,7 +169,7 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
goto fail;
} else {
for (i = 0; i < PHY_MAX_ADDR && !edev->phydev; i++) {
- dev = bus->phy_map[i];
+ dev = mdiobus_scan(bus, addr);
if (!dev || dev->attached_dev)
continue;
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-10-30 16:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-30 16:32 [PATCH] phylib delayed scan Sascha Hauer
2012-10-30 16:32 ` [PATCH 1/2] mdiobus: return existing phydev in mdiobus_scan Sascha Hauer
2012-10-30 16:32 ` [PATCH 2/2] mdiobus: do not scan the bus at registration time Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox