From 589d8b2048037c880d17437651336d1e0b7178b3 Mon Sep 17 00:00:00 2001 From: David Daney Date: Wed, 27 Oct 2010 18:03:47 -0700 Subject: [PATCH] --- yaml --- r: 227711 b: refs/heads/master c: 194588604765ac803f98fb9d19a36f6b835f4620 h: refs/heads/master i: 227709: 2a150bd0fd27f12d003e4c3b2aee69f4dfd7a9da 227707: e0347646a4f518c78b5467850d2c5af0e249b80b 227703: 1d58775d99010490e8a8ef9480c384fa2037aa1c 227695: b89f0072e4bf1e7168ec85babe18f4dc752d8e59 227679: dc5d5bdd963e8941a1b96aa93a1f4b555acf89ae 227647: 0ad273217df7a4b763f01d14028ea402859b8044 227583: c9211b4ecbb072ea6a69ad29d29559f31e7da8fd v: v3 --- [refs] | 2 +- trunk/drivers/of/of_mdio.c | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/[refs] b/[refs] index ff4a81cf4197..850cf19340ae 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 0131d8973c8b9bd9d40fee8fae24eab24821efdb +refs/heads/master: 194588604765ac803f98fb9d19a36f6b835f4620 diff --git a/trunk/drivers/of/of_mdio.c b/trunk/drivers/of/of_mdio.c index 1fce00eb421b..dcd7857784f2 100644 --- a/trunk/drivers/of/of_mdio.c +++ b/trunk/drivers/of/of_mdio.c @@ -52,27 +52,35 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) /* Loop over the child nodes and register a phy_device for each one */ for_each_child_of_node(np, child) { - const __be32 *addr; + const __be32 *paddr; + u32 addr; int len; /* A PHY must have a reg property in the range [0-31] */ - addr = of_get_property(child, "reg", &len); - if (!addr || len < sizeof(*addr) || *addr >= 32 || *addr < 0) { + paddr = of_get_property(child, "reg", &len); + if (!paddr || len < sizeof(*paddr)) { dev_err(&mdio->dev, "%s has invalid PHY address\n", child->full_name); continue; } + addr = be32_to_cpup(paddr); + if (addr >= 32) { + dev_err(&mdio->dev, "%s PHY address %i is too large\n", + child->full_name, addr); + continue; + } + if (mdio->irq) { - mdio->irq[*addr] = irq_of_parse_and_map(child, 0); - if (!mdio->irq[*addr]) - mdio->irq[*addr] = PHY_POLL; + mdio->irq[addr] = irq_of_parse_and_map(child, 0); + if (!mdio->irq[addr]) + mdio->irq[addr] = PHY_POLL; } - phy = get_phy_device(mdio, be32_to_cpup(addr)); + phy = get_phy_device(mdio, addr); if (!phy || IS_ERR(phy)) { dev_err(&mdio->dev, "error probing PHY at address %i\n", - *addr); + addr); continue; } phy_scan_fixups(phy); @@ -91,7 +99,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) } dev_dbg(&mdio->dev, "registered phy %s at address %i\n", - child->name, *addr); + child->name, addr); } return 0;