diff options
author | David S. Miller <davem@davemloft.net> | 2017-06-13 12:56:43 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-06-13 12:56:43 -0400 |
commit | d980b8d1fc3c6a37f1123995d3939c6b0eeff1c5 (patch) | |
tree | 60dbcae8697b5c2fc821c8bc2e12b93a64f5db3a /drivers/net | |
parent | 61d3e1d9bc2a1910d773cbf4ed6f587a7a6166b5 (diff) | |
parent | fe0e4052fb11d5c713961ab7e136520be40052a3 (diff) | |
download | linux-stable-d980b8d1fc3c6a37f1123995d3939c6b0eeff1c5.tar.gz linux-stable-d980b8d1fc3c6a37f1123995d3939c6b0eeff1c5.tar.bz2 linux-stable-d980b8d1fc3c6a37f1123995d3939c6b0eeff1c5.zip |
Merge branch 'MDIO-bus-reset-GPIO-cleanups'
Sergei Shtylyov says:
====================
MDIO bus reset GPIO cleanups
Commit 4c5e7a2c0501 ("dt-bindings: mdio: Clarify binding document")
declared that a MDIO reset GPIO property should have only a single GPIO
reference/specifier, however the supporting code was left intact...
Here's a couple of the obvious cleanups to that code:
[1/2] mdio_bus: handle only single PHY reset GPIO
[2/2] mdio_bus: use devm_gpiod_get_optional()
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/phy/mdio_bus.c | 51 |
1 files changed, 16 insertions, 35 deletions
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 4c169dbf9138..2df7b62c1a36 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -353,33 +353,18 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) mutex_init(&bus->mdio_lock); - /* de-assert bus level PHY GPIO resets */ - if (bus->num_reset_gpios > 0) { - bus->reset_gpiod = devm_kcalloc(&bus->dev, - bus->num_reset_gpios, - sizeof(struct gpio_desc *), - GFP_KERNEL); - if (!bus->reset_gpiod) - return -ENOMEM; - } - - for (i = 0; i < bus->num_reset_gpios; i++) { - gpiod = devm_gpiod_get_index(&bus->dev, "reset", i, - GPIOD_OUT_LOW); - if (IS_ERR(gpiod)) { - err = PTR_ERR(gpiod); - if (err != -ENOENT) { - dev_err(&bus->dev, - "mii_bus %s couldn't get reset GPIO\n", - bus->id); - return err; - } - } else { - bus->reset_gpiod[i] = gpiod; - gpiod_set_value_cansleep(gpiod, 1); - udelay(bus->reset_delay_us); - gpiod_set_value_cansleep(gpiod, 0); - } + /* de-assert bus level PHY GPIO reset */ + gpiod = devm_gpiod_get_optional(&bus->dev, "reset", GPIOD_OUT_LOW); + if (IS_ERR(gpiod)) { + dev_err(&bus->dev, "mii_bus %s couldn't get reset GPIO\n", + bus->id); + return PTR_ERR(gpiod); + } else if (gpiod) { + bus->reset_gpiod = gpiod; + + gpiod_set_value_cansleep(gpiod, 1); + udelay(bus->reset_delay_us); + gpiod_set_value_cansleep(gpiod, 0); } if (bus->reset) @@ -414,10 +399,8 @@ error: } /* Put PHYs in RESET to save power */ - for (i = 0; i < bus->num_reset_gpios; i++) { - if (bus->reset_gpiod[i]) - gpiod_set_value_cansleep(bus->reset_gpiod[i], 1); - } + if (bus->reset_gpiod) + gpiod_set_value_cansleep(bus->reset_gpiod, 1); device_del(&bus->dev); return err; @@ -442,10 +425,8 @@ void mdiobus_unregister(struct mii_bus *bus) } /* Put PHYs in RESET to save power */ - for (i = 0; i < bus->num_reset_gpios; i++) { - if (bus->reset_gpiod[i]) - gpiod_set_value_cansleep(bus->reset_gpiod[i], 1); - } + if (bus->reset_gpiod) + gpiod_set_value_cansleep(bus->reset_gpiod, 1); device_del(&bus->dev); } |