Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EAC5C433EF for ; Sat, 13 Nov 2021 02:23:24 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF08460E75 for ; Sat, 13 Nov 2021 02:23:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DF08460E75 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7A84E830A6; Sat, 13 Nov 2021 03:23:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1636770200; bh=6HyRFMnSMJVCryjom09DbvybMTJN6jmYvDpJ9E7Tkic=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=CFo+IrJjrY9Zi6odODKNBu4c+SvtcmW8dz6wJHKK/8LBQgq3WmBCL86Oy0rV+JSgt B3ly0DyU6Sp5Bva5OE1o5COQgQTAL4GfoIah+QPM2lYro71ZMQN3OVLp4tAp01d4pM 4/13uEQhsx0+84kuc2WCGWBxsNGgttkz8l0OVu+egzGBWUziVg8BUTAnIdc5wbVF+U G7Akz90KxwWb6DVOwSqoDdwXG9kRbcew9lTmkv4wiKaD6FT1AYN4SDzoAiAi4/1O9Q Ll9IKtcPdBIhgyVk98H1zLzk2/ZA3joU/q4GA6niYDHiqYNw1/g3nQYGFVjkJk1CRG xf4Gy6XKFYOvg== Received: from tr.lan (ip-89-176-112-137.net.upcbroadband.cz [89.176.112.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 01ABD830A4; Sat, 13 Nov 2021 03:23:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1636770198; bh=6HyRFMnSMJVCryjom09DbvybMTJN6jmYvDpJ9E7Tkic=; h=From:To:Cc:Subject:Date:From; b=XvI80nxW9R9oiYgEIy3blpPkjIxczj5LZKdXJqg4mZ/FvukSoF+9WOOonZGeqi8Ev X2Zo5T49tM6QJW5tsyIHQemo9QX9T25nlYUVdJ3PvxzZqSCq+R9JoeiWm8TpfndbWp LwvcJ+4/1WGqXTLoMkdDfNosUIRtMIx4987jb69PWfB/OCd18YrWkl5NqdU7BBwQrR 1iZimJ0sHNYKxrxtHhmiL/vRQIoUwoYK7NtJPaPWLGqKLBNRTahQIrMLRNYp8Zoz9N nVnNphz1XHmve6qd33Zj0QS7twSZq5iGXSpeJs5nhvVSIu/ZxP2RSr6ZMNfTC5ae9t qbejOI284Z9+Q== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Ramon Fried Subject: [PATCH] net: eth-phy: Handle gpio_request_by_name() return value Date: Sat, 13 Nov 2021 03:23:11 +0100 Message-Id: <20211113022311.231744-1-marex@denx.de> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.35 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean 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 Cc: Ramon Fried --- drivers/net/eth-phy-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/eth-phy-uclass.c b/drivers/net/eth-phy-uclass.c index c04bab944d6..a9b358ee234 100644 --- a/drivers/net/eth-phy-uclass.c +++ b/drivers/net/eth-phy-uclass.c @@ -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); -- 2.33.0