From patchwork Thu Jan 26 13:52:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 48680 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp284457wrn; Thu, 26 Jan 2023 06:02:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXslvYy88mqquogwC+q50zh/z9tex4d0aCNWVhngSw42HpEkXQ+rEeqcEHbWP1WCfmtfsb2c X-Received: by 2002:a05:6a20:4392:b0:b6:e9:d3d1 with SMTP id i18-20020a056a20439200b000b600e9d3d1mr35037820pzl.11.1674741765834; Thu, 26 Jan 2023 06:02:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674741765; cv=none; d=google.com; s=arc-20160816; b=MfoTD+Zg2riYv3xQ0jxFLR597Z+7Eiadwe2QxiqaPwOb50N0OIXqsljGZ3KrVQpIxR kizhwFz1y97OAkELzQzgVkMgToiflHRAgLINTmBiUPgX3y4hz8cspq2OtOsujbM0XL00 jb0DS6jKYC8NmB8z0cV3UO6hhe+9aNtn9aNhg0VynYKJVmEtab3dEO9ABPdMN1aev/GZ j2jtX0TCxzPTM18eTtjfOnhshkkkYo4NMFHxR8Kgcp+D5QsrTfly98IdnWb5hbBZq5Um l+2/IzYIrMgMJihN6nHA6Jw14cfFZNp8MjnXW7UCV5Ow1Qy3tkX1uMJV7OMRw67Li//L 2Ylw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=HOfynslKr2TOhk4tVwYC3ohYG7B3YkJAmhgLpzRL/E8=; b=U03bWmULIK9+3/57HXJVVbfw2DITEEDuEi8pfiHvvRiNrkjddW3uZlMXgCECIi0TEM 8W3HHwbhqFONyp6y+RTWJAjzdLrNi8rF5iRz9XHorO2dCpICa6EAgeu1FoyHGKt/oK4S jwOsdiHToryoTs4zdCdlVpArakZaam9uz4HGHa4MpcXOVVEx7Tb1tdSmredxAUwtm4gz zzEwmD2eKxgF169SxdUKS/xU8qtIFS0FLhzNoZuLKLgH8vc2V6JqGdeGOVmWZ80e+13g xpZ9uU4hxKXSYzIora5aAuiijg3L970gC+BcR3doNXMib2abr1YstVUy1IYzlA9X0pMN P20Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hGrguENh; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z17-20020a63b911000000b004cff4e7799dsi1250880pge.813.2023.01.26.06.02.31; Thu, 26 Jan 2023 06:02:45 -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=@kernel.org header.s=k20201202 header.b=hGrguENh; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231621AbjAZNyj (ORCPT + 99 others); Thu, 26 Jan 2023 08:54:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231704AbjAZNyV (ORCPT ); Thu, 26 Jan 2023 08:54:21 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BD416226A; Thu, 26 Jan 2023 05:53:52 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AE3A9B81BEA; Thu, 26 Jan 2023 13:53:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98EB3C433EF; Thu, 26 Jan 2023 13:53:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674741225; bh=W1LnY595Ov6jF+hpZHXAZjn52UQrvhyKdsYdkv/rH60=; h=From:To:Cc:Subject:Date:From; b=hGrguENhWyWwHVtsJzGh4GTTlYEFLeB8iopGwjoPBOAqRsokQc/sxzDHaWysNjHsX jyB/ggwIK8dGtAwiEw4lmFZl3/IsiFaa2KBZyOfSNZnNgkbM+3pF7pkmBxddfkMzY2 zy3vaaSFIKVB0bjmwKneIdTWjLjIuq0d1G7cg96KGG1YdukVYLKBTmI1nhd9c30RZo rsERjYQ1rOHAggtqYNLu5C/VDT/4xm3ScmfSPGWWJ3pRuJakMoFrObe2kxdmcdRoNL jbDW2+5pTn2e6HUXw/jPfW7UPnNx7X7A+sJesOxmnXSkskrxuDMvJ3K2o0nirY192A vPxMImCp0iRzg== From: Arnd Bergmann To: Wei Fang Cc: linux-gpio@vger.kernel.org, Arnd Bergmann , Shenwei Wang , Clark Wang , NXP Linux Team , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] fec: convert to gpio descriptor Date: Thu, 26 Jan 2023 14:52:58 +0100 Message-Id: <20230126135339.3488682-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1756094021942899518?= X-GMAIL-MSGID: =?utf-8?q?1756094021942899518?= From: Arnd Bergmann The driver can be trivially converted, as it only triggers the gpio pin briefly to do a reset, and it already only supports DT. Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/freescale/fec_main.c | 25 ++++++++++------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 5ff45b1a74a5..dee2890fd702 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -56,7 +56,7 @@ #include #include #include -#include +#include #include #include #include @@ -4035,7 +4035,8 @@ static int fec_enet_init(struct net_device *ndev) #ifdef CONFIG_OF static int fec_reset_phy(struct platform_device *pdev) { - int err, phy_reset; + int err; + struct gpio_desc *phy_reset; bool active_high = false; int msec = 1, phy_post_delay = 0; struct device_node *np = pdev->dev.of_node; @@ -4048,12 +4049,6 @@ static int fec_reset_phy(struct platform_device *pdev) if (!err && msec > 1000) msec = 1; - phy_reset = of_get_named_gpio(np, "phy-reset-gpios", 0); - if (phy_reset == -EPROBE_DEFER) - return phy_reset; - else if (!gpio_is_valid(phy_reset)) - return 0; - err = of_property_read_u32(np, "phy-reset-post-delay", &phy_post_delay); /* valid reset duration should be less than 1s */ if (!err && phy_post_delay > 1000) @@ -4061,11 +4056,13 @@ static int fec_reset_phy(struct platform_device *pdev) active_high = of_property_read_bool(np, "phy-reset-active-high"); - err = devm_gpio_request_one(&pdev->dev, phy_reset, - active_high ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW, - "phy-reset"); - if (err) { - dev_err(&pdev->dev, "failed to get phy-reset-gpios: %d\n", err); + phy_reset = devm_gpiod_get(&pdev->dev, "phy-reset", + active_high ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW); + if (IS_ERR(phy_reset)) { + err = PTR_ERR(phy_reset); + if (err != -EPROBE_DEFER) + dev_err(&pdev->dev, + "failed to get phy-reset-gpios: %d\n", err); return err; } @@ -4074,7 +4071,7 @@ static int fec_reset_phy(struct platform_device *pdev) else usleep_range(msec * 1000, msec * 1000 + 1000); - gpio_set_value_cansleep(phy_reset, !active_high); + gpiod_set_value_cansleep(phy_reset, !active_high); if (!phy_post_delay) return 0;