Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Also there is no reason to only try to fetch the reset GPIO when we have
OF node, gpiolib can fetch GPIO data from firmwares as well.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Dmitry Torokhov and committed by
David S. Miller
40ba6a12 28f2c362

+8 -12
+8 -12
drivers/net/phy/mdio_bus.c
··· 42 42 43 43 static int mdiobus_register_gpiod(struct mdio_device *mdiodev) 44 44 { 45 - struct gpio_desc *gpiod = NULL; 45 + int error; 46 46 47 47 /* Deassert the optional reset signal */ 48 - if (mdiodev->dev.of_node) 49 - gpiod = fwnode_get_named_gpiod(&mdiodev->dev.of_node->fwnode, 50 - "reset-gpios", 0, GPIOD_OUT_LOW, 51 - "PHY reset"); 52 - if (IS_ERR(gpiod)) { 53 - if (PTR_ERR(gpiod) == -ENOENT || PTR_ERR(gpiod) == -ENOSYS) 54 - gpiod = NULL; 55 - else 56 - return PTR_ERR(gpiod); 57 - } 48 + mdiodev->reset_gpio = gpiod_get_optional(&mdiodev->dev, 49 + "reset", GPIOD_OUT_LOW); 50 + error = PTR_ERR_OR_ZERO(mdiodev->reset_gpio); 51 + if (error) 52 + return error; 58 53 59 - mdiodev->reset_gpio = gpiod; 54 + if (mdiodev->reset_gpio) 55 + gpiod_set_consumer_name(mdiodev->reset_gpio, "PHY reset"); 60 56 61 57 return 0; 62 58 }