From patchwork Thu Jan 26 21:05:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 48896 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp486620wrn; Thu, 26 Jan 2023 13:08:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXtYuSwCwgOPlEh1dZCzc8mPwXbhkuXmc5i0nYuha+QbvvNmSQoi4+KfJyNZSka9CA7+m2qq X-Received: by 2002:a17:906:5214:b0:7c0:f2c5:ac3d with SMTP id g20-20020a170906521400b007c0f2c5ac3dmr35967654ejm.15.1674767323290; Thu, 26 Jan 2023 13:08:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674767323; cv=none; d=google.com; s=arc-20160816; b=XgqEt6dV8NAxPVkZzoqhKFMhm5e/CRYhUd/3lcIQ3qZHjCaSqvzkvnqnwndyNdPQ52 666ywzMxz6USlZ9mZHk+O+y7q3f+E4I6JFY2374nyWqP8kXfj73vEWXkUbdAWOu/vjDM ha6smb63rWRqrY1SK2laf6cq7KDz+6m6RyvuBx+0hug8y8UF+03iV+tuvseM+eOGq/RN j36RsJRMYP22y76ghWqgt7aYD1p4SrKVK5q1WQzaVBrOwdaNC3+BQeaT3s6lSHP2l8WK d8PVifL3eXe4y53go9F+U8X32xpsu/K7sAx2SCI/4M23P4lng1nqpJBqxHC4UnE60Yb3 XUSA== 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=3zflOZGYj+uCTUhJfy2dCG7winKBqOuVr258zzF4LcE=; b=bwbUSfkxiF8cJe7We8KEDLkDyr08jHRRS0WIyLVy5DC0wNfbNs4DdF5KCexOO7QsLs S9Tlw+mz4Kk+TTfR8PRmFz4ATNCVeyc9RI2LHvEcjGSkpZF9j9T/oktluHxGqirCUZ3z ZVwL23/VyTDx80u4PfCbRpeCCvP3BdwGUzgByAqAuNHY1qPTw2uIYMfskgxkoCDVdP4L 4YxS739Yz52E3dOetXqXFDODXygfFhzBKgDxYbMD8WJI7QXQkfeIyGvqTAv8bqm890E8 qx65aM1hzx+8hQYx7+LMn5qfzHI972dlLfE3Yknuny9U/Gj8mWw8rmm1Dop1VIeDjMTG +LEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cxWwJRgc; 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 n5-20020a1709061d0500b0084d14322868si2519192ejh.179.2023.01.26.13.08.18; Thu, 26 Jan 2023 13:08:43 -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=cxWwJRgc; 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 S232732AbjAZVHE (ORCPT + 99 others); Thu, 26 Jan 2023 16:07:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232700AbjAZVHB (ORCPT ); Thu, 26 Jan 2023 16:07:01 -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 DE7455CE67; Thu, 26 Jan 2023 13:06:56 -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 A41ECB81E0A; Thu, 26 Jan 2023 21:06:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1796C433EF; Thu, 26 Jan 2023 21:06:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674767214; bh=9IWrwcLrstDZeuCYJT6dIx+OTz0TyqUya6nH3N9zhhM=; h=From:To:Cc:Subject:Date:From; b=cxWwJRgckrVll7tIC18ukU2A830AWnC0Cc34gLc30EZVjEC56fMYCk6fIcBEXvq2+ GdLEU/yBG0RxC8wlKNsqLGGlVjc89HDDn2YTqa6BnUraPjAZzwFQuhJ2wsk0utqGfZ YPpNt58BVIg+mnpJqSYqNHdGCOUd4sMGAx4lbkrST+k4q3YMOSgjaqPLqWCnmNTaAB +8ZEKMWjZZYvm/esIaTmSdat6EnFr5SNva+ASuBVeWs3LMGQFdMgJI2UHKjH7T2cV+ fbC1lHLe1e78JhS+y77/MBySUyAuXCcOTM2xS4AHAvi5Dr1QvLE1kDMj2RxJqsoY4c LrCzVaS1qcCow== From: Arnd Bergmann To: Wei Fang , Jakub Kicinski Cc: Arnd Bergmann , Shenwei Wang , Clark Wang , NXP Linux Team , "David S. Miller" , Eric Dumazet , Paolo Abeni , Andrew Lunn , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] fec: convert to gpio descriptor Date: Thu, 26 Jan 2023 22:05:59 +0100 Message-Id: <20230126210648.1668178-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?1756120820932520494?= X-GMAIL-MSGID: =?utf-8?q?1756120820932520494?= 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 Reviewed-by: Andrew Lunn --- v2 changes, suggested by Andrew Lunn: - reorder header inclusions, - use dev_err_probe() --- drivers/net/ethernet/freescale/fec_main.c | 25 ++++++++--------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 5ff45b1a74a5..2716898e0b9b 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -56,12 +56,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include #include @@ -4035,10 +4035,11 @@ 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; + 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; if (!np) return 0; @@ -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,20 +4056,18 @@ 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); - return err; - } + phy_reset = devm_gpiod_get(&pdev->dev, "phy-reset", + active_high ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW); + if (IS_ERR(phy_reset)) + return dev_err_probe(&pdev->dev, PTR_ERR(phy_reset), + "failed to get phy-reset-gpios\n"); if (msec > 20) msleep(msec); 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;