Revert "mdio_bus: Remove unneeded gpiod NULL check"
authorFlorian Fainelli <f.fainelli@gmail.com>
Fri, 8 Sep 2017 22:38:07 +0000 (15:38 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 9 Sep 2017 04:12:40 +0000 (21:12 -0700)
This reverts commit 95b80bf3db03c2bf572a357cf74b9a6aefef0a4a ("mdio_bus:
Remove unneeded gpiod NULL check"), this commit assumed that GPIOLIB
checks for NULL descriptors, so it's safe to drop them, but it is not
when CONFIG_GPIOLIB is disabled in the kernel. If we do call
gpiod_set_value_cansleep() on a GPIO descriptor we will issue warnings
coming from the inline stubs declared in include/linux/gpio/consumer.h.

Fixes: 95b80bf3db03 ("mdio_bus: Remove unneeded gpiod NULL check")
Reported-by: Woojung Huh <Woojung.Huh@microchip.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/mdio_bus.c

index b6f9fa67016831745c5ad43dfe466605182daf71..2df7b62c1a36811e97087ae641a89d06641cef4e 100644 (file)
@@ -399,7 +399,8 @@ error:
        }
 
        /* Put PHYs in RESET to save power */
-       gpiod_set_value_cansleep(bus->reset_gpiod, 1);
+       if (bus->reset_gpiod)
+               gpiod_set_value_cansleep(bus->reset_gpiod, 1);
 
        device_del(&bus->dev);
        return err;
@@ -424,7 +425,8 @@ void mdiobus_unregister(struct mii_bus *bus)
        }
 
        /* Put PHYs in RESET to save power */
-       gpiod_set_value_cansleep(bus->reset_gpiod, 1);
+       if (bus->reset_gpiod)
+               gpiod_set_value_cansleep(bus->reset_gpiod, 1);
 
        device_del(&bus->dev);
 }