Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e3e7999 authored by Charles Keepax's avatar Charles Keepax Committed by David S. Miller
Browse files

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: default avatarCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9832ce4c
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -2996,10 +2996,11 @@ 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);
		}
	}
	of_node_put(phy_node);

	err = of_get_phy_mode(np);
@@ -3068,6 +3069,7 @@ static int macb_remove(struct platform_device *pdev)
		mdiobus_free(bp->mii_bus);

		/* Shutdown the PHY if there is a GPIO reset */
		if (bp->reset_gpio)
			gpiod_set_value(bp->reset_gpio, 0);

		unregister_netdev(dev);