From 8b0fa66882783bba9adcfeda58066f7ef5bb66be Mon Sep 17 00:00:00 2001 From: Tim Harvey Date: Mon, 28 Feb 2022 14:53:21 -0800 Subject: [PATCH] phy: nop-phy: Fix phy reset if no reset-gpio defined Ensure there is a valid reset-gpio defined before using it. Fixes: 668d0273f889 ("phy: nop-phy: Fix enabling reset") Cc: Adam Ford Signed-off-by: Tim Harvey --- drivers/phy/nop-phy.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/phy/nop-phy.c b/drivers/phy/nop-phy.c index e2ee6e9206..d0904f4f07 100644 --- a/drivers/phy/nop-phy.c +++ b/drivers/phy/nop-phy.c @@ -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; -- 2.39.5