aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2014-11-19 06:59:16 -0500
committerDavid S. Miller <davem@davemloft.net>2014-11-21 14:08:56 -0500
commite7a792e945f9bc5eb3032db8db11c762e8ea9ab0 (patch)
tree3220cc82221c397e23687a188ed93b56ac435473 /drivers/net/phy
parente6a423a81da0eb3da755428f4d2df5a9ba13030f (diff)
net: phy: micrel: parse of nodes at probe
Parse the "micrel,led-mode" property at probe, rather than at config_init time in the led-setup helper itself. Note that the bogus parent->of_node bit is removed. Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy')
-rw-r--r--drivers/net/phy/micrel.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 1b528137afd9..6a81aaca5b1c 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -79,6 +79,7 @@ struct kszphy_type {
79 79
80struct kszphy_priv { 80struct kszphy_priv {
81 const struct kszphy_type *type; 81 const struct kszphy_type *type;
82 int led_mode;
82}; 83};
83 84
84static const struct kszphy_type ksz8021_type = { 85static const struct kszphy_type ksz8021_type = {
@@ -186,24 +187,9 @@ static int ks8737_config_intr(struct phy_device *phydev)
186 return rc < 0 ? rc : 0; 187 return rc < 0 ? rc : 0;
187} 188}
188 189
189static int kszphy_setup_led(struct phy_device *phydev, u32 reg) 190static int kszphy_setup_led(struct phy_device *phydev, u32 reg, int val)
190{ 191{
191
192 struct device *dev = &phydev->dev;
193 struct device_node *of_node = dev->of_node;
194 int rc, temp, shift; 192 int rc, temp, shift;
195 u32 val;
196
197 if (!of_node && dev->parent->of_node)
198 of_node = dev->parent->of_node;
199
200 if (of_property_read_u32(of_node, "micrel,led-mode", &val))
201 return 0;
202
203 if (val > 3) {
204 dev_err(&phydev->dev, "invalid led mode: 0x%02x\n", val);
205 return -EINVAL;
206 }
207 193
208 switch (reg) { 194 switch (reg) {
209 case MII_KSZPHY_CTRL_1: 195 case MII_KSZPHY_CTRL_1:
@@ -261,8 +247,8 @@ static int kszphy_config_init(struct phy_device *phydev)
261 247
262 type = priv->type; 248 type = priv->type;
263 249
264 if (type->led_mode_reg) 250 if (priv->led_mode >= 0)
265 kszphy_setup_led(phydev, type->led_mode_reg); 251 kszphy_setup_led(phydev, type->led_mode_reg, priv->led_mode);
266 252
267 return 0; 253 return 0;
268} 254}
@@ -531,7 +517,9 @@ ksz9021_wr_mmd_phyreg(struct phy_device *phydev, int ptrad, int devnum,
531static int kszphy_probe(struct phy_device *phydev) 517static int kszphy_probe(struct phy_device *phydev)
532{ 518{
533 const struct kszphy_type *type = phydev->drv->driver_data; 519 const struct kszphy_type *type = phydev->drv->driver_data;
520 struct device_node *np = phydev->dev.of_node;
534 struct kszphy_priv *priv; 521 struct kszphy_priv *priv;
522 int ret;
535 523
536 priv = devm_kzalloc(&phydev->dev, sizeof(*priv), GFP_KERNEL); 524 priv = devm_kzalloc(&phydev->dev, sizeof(*priv), GFP_KERNEL);
537 if (!priv) 525 if (!priv)
@@ -541,6 +529,21 @@ static int kszphy_probe(struct phy_device *phydev)
541 529
542 priv->type = type; 530 priv->type = type;
543 531
532 if (type->led_mode_reg) {
533 ret = of_property_read_u32(np, "micrel,led-mode",
534 &priv->led_mode);
535 if (ret)
536 priv->led_mode = -1;
537
538 if (priv->led_mode > 3) {
539 dev_err(&phydev->dev, "invalid led mode: 0x%02x\n",
540 priv->led_mode);
541 priv->led_mode = -1;
542 }
543 } else {
544 priv->led_mode = -1;
545 }
546
544 return 0; 547 return 0;
545} 548}
546 549