diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/of/of_mdio.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/of/of_mdio.c')
-rw-r--r-- | drivers/of/of_mdio.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index 1fce00eb421b..d35e300b0ad1 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c | |||
@@ -52,27 +52,35 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) | |||
52 | 52 | ||
53 | /* Loop over the child nodes and register a phy_device for each one */ | 53 | /* Loop over the child nodes and register a phy_device for each one */ |
54 | for_each_child_of_node(np, child) { | 54 | for_each_child_of_node(np, child) { |
55 | const __be32 *addr; | 55 | const __be32 *paddr; |
56 | u32 addr; | ||
56 | int len; | 57 | int len; |
57 | 58 | ||
58 | /* A PHY must have a reg property in the range [0-31] */ | 59 | /* A PHY must have a reg property in the range [0-31] */ |
59 | addr = of_get_property(child, "reg", &len); | 60 | paddr = of_get_property(child, "reg", &len); |
60 | if (!addr || len < sizeof(*addr) || *addr >= 32 || *addr < 0) { | 61 | if (!paddr || len < sizeof(*paddr)) { |
61 | dev_err(&mdio->dev, "%s has invalid PHY address\n", | 62 | dev_err(&mdio->dev, "%s has invalid PHY address\n", |
62 | child->full_name); | 63 | child->full_name); |
63 | continue; | 64 | continue; |
64 | } | 65 | } |
65 | 66 | ||
67 | addr = be32_to_cpup(paddr); | ||
68 | if (addr >= 32) { | ||
69 | dev_err(&mdio->dev, "%s PHY address %i is too large\n", | ||
70 | child->full_name, addr); | ||
71 | continue; | ||
72 | } | ||
73 | |||
66 | if (mdio->irq) { | 74 | if (mdio->irq) { |
67 | mdio->irq[*addr] = irq_of_parse_and_map(child, 0); | 75 | mdio->irq[addr] = irq_of_parse_and_map(child, 0); |
68 | if (!mdio->irq[*addr]) | 76 | if (!mdio->irq[addr]) |
69 | mdio->irq[*addr] = PHY_POLL; | 77 | mdio->irq[addr] = PHY_POLL; |
70 | } | 78 | } |
71 | 79 | ||
72 | phy = get_phy_device(mdio, be32_to_cpup(addr)); | 80 | phy = get_phy_device(mdio, addr); |
73 | if (!phy || IS_ERR(phy)) { | 81 | if (!phy || IS_ERR(phy)) { |
74 | dev_err(&mdio->dev, "error probing PHY at address %i\n", | 82 | dev_err(&mdio->dev, "error probing PHY at address %i\n", |
75 | *addr); | 83 | addr); |
76 | continue; | 84 | continue; |
77 | } | 85 | } |
78 | phy_scan_fixups(phy); | 86 | phy_scan_fixups(phy); |
@@ -91,7 +99,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) | |||
91 | } | 99 | } |
92 | 100 | ||
93 | dev_dbg(&mdio->dev, "registered phy %s at address %i\n", | 101 | dev_dbg(&mdio->dev, "registered phy %s at address %i\n", |
94 | child->name, *addr); | 102 | child->name, addr); |
95 | } | 103 | } |
96 | 104 | ||
97 | return 0; | 105 | return 0; |
@@ -128,7 +136,7 @@ EXPORT_SYMBOL(of_phy_find_device); | |||
128 | * @hndlr: Link state callback for the network device | 136 | * @hndlr: Link state callback for the network device |
129 | * @iface: PHY data interface type | 137 | * @iface: PHY data interface type |
130 | * | 138 | * |
131 | * Returns a pointer to the phy_device if successfull. NULL otherwise | 139 | * Returns a pointer to the phy_device if successful. NULL otherwise |
132 | */ | 140 | */ |
133 | struct phy_device *of_phy_connect(struct net_device *dev, | 141 | struct phy_device *of_phy_connect(struct net_device *dev, |
134 | struct device_node *phy_np, | 142 | struct device_node *phy_np, |