net: mdio: switch to using gpiod_get_optional()
Subsystems (3)
PATCH v3 1/1 net: mdio: switch to using gpiod_get_optional()
The MDIO device reset line is optional and now that gpiod_get_optional() returns proper value when GPIO support is compiled out, there is no reason to use fwnode_get_named_gpiod() that I plan to hide away.
Let's switch to using more standard gpiod_get_optional() and gpiod_set_consumer_name() to keep the nice "PHY reset" label.
---
v2 -> v3:
- no longer check for NULL before calling gpiod_set_consumer_name() as it handles NULL descriptors
- added Andy S's reviewed-by
- did NOT add Andrew's reviewed-by as I am unsure if he's OK with the latest iteration.
drivers/net/phy/mdio_bus.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
drivers/net/phy/mdio_bus.c +7 -13
@@ -42,22 +42,16 @@static int mdiobus_register_gpiod (struct mdio_device *mdiodev) { -struct gpio_desc *gpiod =NULL ; +int error;/* Deassert the optional reset signal */ -if (mdiodev->dev.of_node) - gpiod =fwnode_get_named_gpiod (&mdiodev->dev.of_node->fwnode, -"reset-gpios" ,0 ,GPIOD_OUT_LOW , -"PHY reset" ); -if (IS_ERR (gpiod)) { -if (PTR_ERR (gpiod) == -ENOENT ||PTR_ERR (gpiod) == -ENOSYS ) - gpiod =NULL ; -else -return PTR_ERR (gpiod); - } - - mdiodev->reset_gpio = gpiod; + mdiodev->reset_gpio =gpiod_get_optional (&mdiodev->dev, +"reset" ,GPIOD_OUT_LOW ); + error =PTR_ERR_OR_ZERO (mdiodev->reset_gpio); +if (error) +return error; +gpiod_set_consumer_name (mdiodev->reset_gpio,"PHY reset" );return 0 ; }
Signature · 5 lines
2.23.0.237.gc6a4ce50a0-goog -- Dmitry
Quoted 9 lines · Dmitry Torokhov
The MDIO device reset line is optional and now that
gpiod_get_optional()returns proper value when GPIO support is compiled out, there is no reason to usefwnode_get_named_gpiod()that I plan to hide away.Let's switch to using more standard
gpiod_get_optional()andgpiod_set_consumer_name()to keep the nice "PHY reset" label.Reviewed-by Andy Shevchenko <[email protected]>Signed-off-by Dmitry Torokhov <[email protected]>
Hi Dmitry
What path into mainline do you expect this to take? Via DaveM? net-next is closed now, so i guess you will need to repost in two weeks time.
Andrew