From patchwork Wed Feb 1 03:23:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 51146 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp57916wrn; Tue, 31 Jan 2023 19:27:47 -0800 (PST) X-Google-Smtp-Source: AK7set+qGBCdqvmCpODxPalx9kf5FXnAY5VE79S/Rq+mDqsRLMT6LM5JaijWvpcTwFnqNi6teWrv X-Received: by 2002:a17:906:4b57:b0:87b:d41b:67dc with SMTP id j23-20020a1709064b5700b0087bd41b67dcmr597555ejv.74.1675222067780; Tue, 31 Jan 2023 19:27:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675222067; cv=none; d=google.com; s=arc-20160816; b=QNa8LfWA1rfqVArXAKe8Eyrx6l/V5UIJNzpsORaEravjMDfw2f669g6kVGoa0d49MA fyRfNdzGa2QbqecvOc9Tc9Zvp6SQW8SysIBVDjXir7DxEUzGYQYkYX4AX+goixYNJSM2 Umtn/ccyubpv8ztsrxzGLmY3vxxHaEArOl/2pOTKTjqCcdQ1q66cXJ/6rPiSGwyTNHiV +KOmMY7QL4NYLSz/2gBPink+vxYXDvJ+LFCxJWrESBGjhYQtBl4oquD9udJMzug1rdkb LEOuwxOmeTm4o3JXHzFtp8e7ltEh9zqiUr6OaQr/4qAEga1sjUV9USSZ+cNxMUIFivXR 4t/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=eF3+uQ/iC9ZPJbEUP+TfPygGgCu0+3aq1witfpsSE/w=; b=AB4LHY84CuCaKex1AJszOW9EELg03R4SDSqrLq4Q/2WQlYbcXcI4n1ZQbAzsrug1PT 4iwU0IMJDc3ZybpnXeg8fdoyrlXOkZ66GzdRj+zMqn9mJY8zOtJboqY+CRvGpMAZ2Uk5 /kiy8bxB0huTOtrwMcbNsJKzbBQux8wWqWPCztHz027momSS58vhtTJowycDKpux71Nk UHyLYSrM8stcgvb0CUM9vL2Oy9Qm59d/J21uOjSOxRejwzLbotwGf8lNvpUMtxzXeajA 1Kj1S3XmY1qHtLpwLbpNRLpqUIdPCktFW3bznxn+I55zuRkmxAfI/1FWNQeuvuSu6Xrk x2ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cjNHxxni; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a22-20020aa7cf16000000b0049defeaec6dsi19617478edy.530.2023.01.31.19.27.00; Tue, 31 Jan 2023 19:27:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cjNHxxni; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230523AbjBADXX (ORCPT + 99 others); Tue, 31 Jan 2023 22:23:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230225AbjBADXV (ORCPT ); Tue, 31 Jan 2023 22:23:21 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B16D043478; Tue, 31 Jan 2023 19:23:20 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id be8so17142758plb.7; Tue, 31 Jan 2023 19:23:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=eF3+uQ/iC9ZPJbEUP+TfPygGgCu0+3aq1witfpsSE/w=; b=cjNHxxniZRvMUNs2AQL67d/8eW/wU+Pr4VE80JtdnqufgZIgaRQLPYqSFr0hYtAVPa IiwHcFtu12W1KcbyDWGiLdbVCz8oFVt8ly3m7yd4dngtDvb6OkYJ6FeOjPa2YHylQHSI cRu9SLTgml6f+iBf16+exqkUOyo9z7cCSroQjJMrJ8YgNF/XMvk3CyAvd6Xknbz0HkK/ 94KGdxlD/uRDWY0MbedInZLRhLRttnpuqK/5X5SWBHcKA68Wv2OPrIY60lAAL+jLwDGV ed5jMdk2uEyJqzmtr9w6lHbIpEBqqdBKS5lEPjEWRwfpCudbY5VqDd888ijEsY87Ah8/ YLqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eF3+uQ/iC9ZPJbEUP+TfPygGgCu0+3aq1witfpsSE/w=; b=BoiRbW4iF+PVaV/0iHNwI9KaiAQdBe/qB0qjXdWn+OPpKsD7lNhMNCtvQKzrW3B36U K4swxYm+NIar7aIZRUY9v7oneB2AbyO6TE+LRkxkSeT5BalOwv8d+OUh51STShFznH+6 Em6opgbLmGdFga9uSv8yDJ1gZUpW5fmAk2qOW01gACG/fmKIQY3cz8FqagP7CrixWjYN zizTI0nnv+s55NN24IppFy9Dy8AxDJau3XdAnLW5odtw1OtD2p9IhSWVdpfg29IM0qpa W8XMhcUGHAtFaslegIxLY8LGqAtPEb1dfmtg4xX+Keb7gkjDcPquWUsQKtQwND4GHWh/ 2j+A== X-Gm-Message-State: AO0yUKVzLSiYSRwVHyLWgW5RHCErfAkrBh0V2rbn7GnucPCjrlTd10qd ioTCNiP0VLNj9UwyFycEb6c= X-Received: by 2002:a17:902:e751:b0:198:999e:4e5 with SMTP id p17-20020a170902e75100b00198999e04e5mr566185plf.62.1675221800055; Tue, 31 Jan 2023 19:23:20 -0800 (PST) Received: from google.com ([2620:15c:9d:2:ce3a:44de:62b3:7a4b]) by smtp.gmail.com with ESMTPSA id 5-20020a170902c24500b0019335832ee9sm10434985plg.179.2023.01.31.19.23.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:23:19 -0800 (PST) Date: Tue, 31 Jan 2023 19:23:16 -0800 From: Dmitry Torokhov To: Wei Fang , Jakub Kicinski , Andrew Lunn Cc: Arnd Bergmann , Shenwei Wang , Clark Wang , NXP Linux Team , "David S. Miller" , Eric Dumazet , Paolo Abeni , Marc Kleine-Budde , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] net: fec: fix conversion to gpiod API Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756580404454593558?= X-GMAIL-MSGID: =?utf-8?q?1756597654905247228?= The reset line is optional, so we should be using devm_gpiod_get_optional() and not abort probing if it is not available. Also, there is a quirk in gpiolib (introduced in b02c85c9458cdd15e2c43413d7d2541a468cde57) that transparently handles "phy-reset-active-high" property. Remove handling from the driver to avoid ending up with the double inversion/flipped logic. Fixes: 468ba54bd616 ("fec: convert to gpio descriptor") Signed-off-by: Dmitry Torokhov Reported-by: Marc Kleine-Budde Tested-by: Marc Kleine-Budde --- v2: dropped conversion to generic device properties from the patch. drivers/net/ethernet/freescale/fec_main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 2716898e0b9b..1a8f1e6296f2 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -4036,7 +4037,6 @@ static int fec_enet_init(struct net_device *ndev) static int fec_reset_phy(struct platform_device *pdev) { struct gpio_desc *phy_reset; - bool active_high = false; int msec = 1, phy_post_delay = 0; struct device_node *np = pdev->dev.of_node; int err; @@ -4054,20 +4054,21 @@ static int fec_reset_phy(struct platform_device *pdev) if (!err && phy_post_delay > 1000) return -EINVAL; - active_high = of_property_read_bool(np, "phy-reset-active-high"); - - phy_reset = devm_gpiod_get(&pdev->dev, "phy-reset", - active_high ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW); + phy_reset = devm_gpiod_get_optional(&pdev->dev, "phy-reset", + GPIOD_OUT_HIGH); if (IS_ERR(phy_reset)) return dev_err_probe(&pdev->dev, PTR_ERR(phy_reset), "failed to get phy-reset-gpios\n"); + if (!phy_reset) + return 0; + if (msec > 20) msleep(msec); else usleep_range(msec * 1000, msec * 1000 + 1000); - gpiod_set_value_cansleep(phy_reset, !active_high); + gpiod_set_value_cansleep(phy_reset, 0); if (!phy_post_delay) return 0;