提交 40ba6a12 编写于 作者: D Dmitry Torokhov 提交者: David S. Miller

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: NDmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 28f2c362
...@@ -42,21 +42,17 @@ ...@@ -42,21 +42,17 @@
static int mdiobus_register_gpiod(struct mdio_device *mdiodev) static int mdiobus_register_gpiod(struct mdio_device *mdiodev)
{ {
struct gpio_desc *gpiod = NULL; int error;
/* Deassert the optional reset signal */ /* Deassert the optional reset signal */
if (mdiodev->dev.of_node) mdiodev->reset_gpio = gpiod_get_optional(&mdiodev->dev,
gpiod = fwnode_get_named_gpiod(&mdiodev->dev.of_node->fwnode, "reset", GPIOD_OUT_LOW);
"reset-gpios", 0, GPIOD_OUT_LOW, error = PTR_ERR_OR_ZERO(mdiodev->reset_gpio);
"PHY reset"); if (error)
if (IS_ERR(gpiod)) { return error;
if (PTR_ERR(gpiod) == -ENOENT || PTR_ERR(gpiod) == -ENOSYS)
gpiod = NULL; if (mdiodev->reset_gpio)
else gpiod_set_consumer_name(mdiodev->reset_gpio, "PHY reset");
return PTR_ERR(gpiod);
}
mdiodev->reset_gpio = gpiod;
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册