Skip to content

Commit

Permalink
net: macb: Only call GPIO functions if there is a valid GPIO
Browse files Browse the repository at this point in the history
GPIOlib will print warning messages if we call GPIO functions without a
valid GPIO. Change the code to avoid doing so.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Charles Keepax authored and David S. Miller committed Mar 28, 2016
1 parent 9832ce4 commit 0e3e799
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/net/ethernet/cadence/macb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2996,9 +2996,10 @@ static int macb_probe(struct platform_device *pdev)
phy_node = of_get_next_available_child(np, NULL);
if (phy_node) {
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);
gpiod_direction_output(bp->reset_gpio, 1);
gpiod_direction_output(bp->reset_gpio, 1);
}
}
of_node_put(phy_node);

Expand Down Expand Up @@ -3068,7 +3069,8 @@ static int macb_remove(struct platform_device *pdev)
mdiobus_free(bp->mii_bus);

/* 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);
clk_disable_unprepare(bp->tx_clk);
Expand Down

0 comments on commit 0e3e799

Please sign in to comment.