phy: nop-phy: Fix phy reset if no reset-gpio defined
authorTim Harvey <tharvey@gateworks.com>
Mon, 28 Feb 2022 22:53:21 +0000 (14:53 -0800)
committerMarek Vasut <marex@denx.de>
Mon, 28 Feb 2022 23:21:11 +0000 (00:21 +0100)
Ensure there is a valid reset-gpio defined before using it.

Fixes: f9852acdce02 ("phy: nop-phy: Fix enabling reset")
Cc: Adam Ford <aford173@gmail.com>
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
drivers/phy/nop-phy.c

index e2ee6e9..d0904f4 100644 (file)
@@ -45,11 +45,13 @@ static int nop_phy_init(struct phy *phy)
 
 #if CONFIG_IS_ENABLED(DM_GPIO)
        /* Take phy out of reset */
-       ret = dm_gpio_set_value(&priv->reset_gpio, false);
-       if (ret) {
-               if (CONFIG_IS_ENABLED(CLK))
-                       clk_disable_bulk(&priv->bulk);
-               return ret;
+       if (dm_gpio_is_valid(&priv->reset_gpio)) {
+               ret = dm_gpio_set_value(&priv->reset_gpio, false);
+               if (ret) {
+                       if (CONFIG_IS_ENABLED(CLK))
+                               clk_disable_bulk(&priv->bulk);
+                       return ret;
+               }
        }
 #endif
        return 0;