diff options
author | Johan Hovold <johan@kernel.org> | 2014-11-19 11:59:16 (GMT) |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-11-21 19:08:56 (GMT) |
commit | e7a792e945f9bc5eb3032db8db11c762e8ea9ab0 (patch) | |
tree | 3220cc82221c397e23687a188ed93b56ac435473 | |
parent | e6a423a81da0eb3da755428f4d2df5a9ba13030f (diff) | |
download | linux-e7a792e945f9bc5eb3032db8db11c762e8ea9ab0.tar.xz |
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>
-rw-r--r-- | drivers/net/phy/micrel.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 1b52813..6a81aac 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -79,6 +79,7 @@ struct kszphy_type { struct kszphy_priv { const struct kszphy_type *type; + int led_mode; }; static const struct kszphy_type ksz8021_type = { @@ -186,24 +187,9 @@ static int ks8737_config_intr(struct phy_device *phydev) return rc < 0 ? rc : 0; } -static int kszphy_setup_led(struct phy_device *phydev, u32 reg) +static int kszphy_setup_led(struct phy_device *phydev, u32 reg, int val) { - - struct device *dev = &phydev->dev; - struct device_node *of_node = dev->of_node; int rc, temp, shift; - u32 val; - - if (!of_node && dev->parent->of_node) - of_node = dev->parent->of_node; - - if (of_property_read_u32(of_node, "micrel,led-mode", &val)) - return 0; - - if (val > 3) { - dev_err(&phydev->dev, "invalid led mode: 0x%02x\n", val); - return -EINVAL; - } switch (reg) { case MII_KSZPHY_CTRL_1: @@ -261,8 +247,8 @@ static int kszphy_config_init(struct phy_device *phydev) type = priv->type; - if (type->led_mode_reg) - kszphy_setup_led(phydev, type->led_mode_reg); + if (priv->led_mode >= 0) + kszphy_setup_led(phydev, type->led_mode_reg, priv->led_mode); return 0; } @@ -531,7 +517,9 @@ ksz9021_wr_mmd_phyreg(struct phy_device *phydev, int ptrad, int devnum, static int kszphy_probe(struct phy_device *phydev) { const struct kszphy_type *type = phydev->drv->driver_data; + struct device_node *np = phydev->dev.of_node; struct kszphy_priv *priv; + int ret; priv = devm_kzalloc(&phydev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -541,6 +529,21 @@ static int kszphy_probe(struct phy_device *phydev) priv->type = type; + if (type->led_mode_reg) { + ret = of_property_read_u32(np, "micrel,led-mode", + &priv->led_mode); + if (ret) + priv->led_mode = -1; + + if (priv->led_mode > 3) { + dev_err(&phydev->dev, "invalid led mode: 0x%02x\n", + priv->led_mode); + priv->led_mode = -1; + } + } else { + priv->led_mode = -1; + } + return 0; } |