]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: eth-phy: Handle gpio_request_by_name() return value
authorMarek Vasut <marex@denx.de>
Sat, 13 Nov 2021 02:23:11 +0000 (03:23 +0100)
committerRamon Fried <rfried.dev@gmail.com>
Thu, 2 Dec 2021 06:35:37 +0000 (08:35 +0200)
The gpio_request_by_name() returns zero in case of success, however the
conditional return value check in gpio_request_by_name() checks only for
(ret != -ENOENT) and if the condition is true, returns ret outright.

This leads to a situation where successful gpio_request_by_name() return
leads to immediate successful eth_phy_of_to_plat() return as well, and
to skipped parsing of "reset-assert-us" and "reset-deassert-us", so the
PHY driver operates with valid reset GPIO, but with assert/deassert times
set to default, which is 0, instead of the values from DT. This breaks
PHY reset.

Fix this by checking if return value is non-zero and then for this one
single allowed non-zero return value, -ENOENT.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
drivers/net/eth-phy-uclass.c

index c04bab944d6ec50e7a88e8219f200f2f1b8ab469..a9b358ee2342b9b2ea050ee3fdf8a2d5ab936b61 100644 (file)
@@ -138,7 +138,7 @@ static int eth_phy_of_to_plat(struct udevice *dev)
        ret = gpio_request_by_name(dev, "reset-gpios", 0,
                                   &uc_priv->reset_gpio,
                                   GPIOD_IS_OUT);
-       if (ret != -ENOENT)
+       if (ret && ret != -ENOENT)
                return ret;
 
        uc_priv->reset_assert_delay = dev_read_u32_default(dev, "reset-assert-us", 0);