提交 0e3e7999 编写于 作者: C Charles Keepax 提交者: David S. Miller

net: macb: Only call GPIO functions if there is a valid GPIO

GPIOlib will print warning messages if we call GPIO functions without a
valid GPIO. Change the code to avoid doing so.
Signed-off-by: NCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 9832ce4c
...@@ -2996,9 +2996,10 @@ static int macb_probe(struct platform_device *pdev) ...@@ -2996,9 +2996,10 @@ static int macb_probe(struct platform_device *pdev)
phy_node = of_get_next_available_child(np, NULL); phy_node = of_get_next_available_child(np, NULL);
if (phy_node) { if (phy_node) {
int gpio = of_get_named_gpio(phy_node, "reset-gpios", 0); int gpio = of_get_named_gpio(phy_node, "reset-gpios", 0);
if (gpio_is_valid(gpio)) if (gpio_is_valid(gpio)) {
bp->reset_gpio = gpio_to_desc(gpio); bp->reset_gpio = gpio_to_desc(gpio);
gpiod_direction_output(bp->reset_gpio, 1); gpiod_direction_output(bp->reset_gpio, 1);
}
} }
of_node_put(phy_node); of_node_put(phy_node);
...@@ -3068,7 +3069,8 @@ static int macb_remove(struct platform_device *pdev) ...@@ -3068,7 +3069,8 @@ static int macb_remove(struct platform_device *pdev)
mdiobus_free(bp->mii_bus); mdiobus_free(bp->mii_bus);
/* Shutdown the PHY if there is a GPIO reset */ /* Shutdown the PHY if there is a GPIO reset */
gpiod_set_value(bp->reset_gpio, 0); if (bp->reset_gpio)
gpiod_set_value(bp->reset_gpio, 0);
unregister_netdev(dev); unregister_netdev(dev);
clk_disable_unprepare(bp->tx_clk); clk_disable_unprepare(bp->tx_clk);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册