Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp3111883rdb; Tue, 29 Aug 2023 05:59:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE6Zw+aMdvrcGS+i+XMz5CxIqVUGel/jgh5iBx4VoLyd2NiVeBSd3rlQ8xBYDMItsIOLjHb X-Received: by 2002:a9d:7a9a:0:b0:6b9:8ea3:2ce0 with SMTP id l26-20020a9d7a9a000000b006b98ea32ce0mr14273127otn.33.1693313954234; Tue, 29 Aug 2023 05:59:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693313954; cv=none; d=google.com; s=arc-20160816; b=Bk7Ah8Qn/j2KO7nJctpQKJmfD7mde4muMr3IZ7gyqPYZ/3A8cRhiAnmAp9eyavdcbC 5LTHA3HZaj+hghLpaDgh8G5T/wXfkheQjsBKr28UUQ7lrU0zLI2l4kQ5Rb9vlpGfsZtw Hqh/Bt1Y8DMqM2m5S6KXljkid0rO6ocJdXrlnJNK7Vd/ZVuwfGWscfOyiKLaT0mCBv/n K1NZq1/UQR2UGVIt6cFLVg+lrkbpFxVTw434+7iekZIdM8kkPN9n4ll2IGUv7YwQxelh O3JFX3RKKly9jD/GO6K7NjIGV2smGqTaBO245mA1gb/e2+JWDhL10v8A4z1v6pgluxS2 bSdA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6/xUoyIFASPIfXzO7DjHxdTqcD1CDAyUsRNRIBCEazE=; fh=r/VVG12KmrF+nQv7lC2x2sQ0qQnFs7bJUsMqdUzXKDU=; b=SFyso6jXsI0JglC6fWBPQsxBqmXKN8fZayawWlP/tE77987h1EcAjQ2sA8eYwe1OSz 1DavOBzqjYetX+ZH6Lc127uI/p533p3C0Zej8J59FwFvLKj10QpEPcxsFn0Jif/BzteK iy8Iu1oBajgY8+2Ete+Bvu9wH1j0yls4bVGwRHXJWHm3Y34jMHrjE4BuQ/g2Zmg2eudd UK16KudjAe3VhqDLpFbQ+KT+ZVZorUN1FN+YnZ6abdCfbjC1REZsa/Mw/3Qn/UH2BntS pDiKuW8qu3utY+eoj/h31TcY3ByOd9qeZH+3Y6CXwDFy/Alnz5cpjgzlJjv7vEUJJveU L8+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kpGlg8go; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v135-20020a63618d000000b00565e940690csi9297757pgb.709.2023.08.29.05.58.55; Tue, 29 Aug 2023 05:59:14 -0700 (PDT) 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=kpGlg8go; 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 S234455AbjH2K4I (ORCPT + 99 others); Tue, 29 Aug 2023 06:56:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235486AbjH2K4A (ORCPT ); Tue, 29 Aug 2023 06:56:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60671CF2 for ; Tue, 29 Aug 2023 03:55:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7AC7E6547C for ; Tue, 29 Aug 2023 10:54:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D2CEC433CB; Tue, 29 Aug 2023 10:54:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1693306478; bh=YIjtmUbVrg/RXcc1/xGF0odjZwPY+o3yQzwT12xvMT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kpGlg8goH2fAwB0KtHFx0u7iYJh4nD3j5g7QPH2L4u6HRlUygRl6b/C1MG7cjEyjb IC2R+66bEhVHHNB9qmp5eMtTBx5heJ6eHO9V157tTqah6E5SettWXei2mcweRCbSTH O5RwW2ZxMunS199TpsHVJBLJq+yKX4h58TpuF4xFcI1VxOo+r0sVxLql+XkcP/YM4/ AIAfT6kxiOESS1vh9HmKMMlUcJjmwdGhvgRRZfHgptT7pz2YcKjeaeqsx2zF3rVCOH NmTj1OSnX7VpGGulAy8sLcGz/5CGkL1Wz3I8H3D7GT+s2Ixs6FECRLf8oZM7yd5FWc 98F1DruYetwgA== From: Jisheng Zhang To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Vladimir Zapolskiy , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Emil Renner Berthing , Samin Guo , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Thierry Reding , Jonathan Hunter , Nobuhiro Iwamatsu , Russell King , Matthias Brugger , AngeloGioacchino Del Regno , Bartosz Golaszewski Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 19/22] net: stmmac: dwmac-sunxi: use devm_stmmac_probe_config_dt() Date: Tue, 29 Aug 2023 18:40:30 +0800 Message-Id: <20230829104033.955-20-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230829104033.955-1-jszhang@kernel.org> References: <20230829104033.955-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Simplify the driver's probe() function by using the devres variant of stmmac_probe_config_dt(). The remove_new() callback now needs to be switched to stmmac_pltfr_remove_no_dt(). Signed-off-by: Jisheng Zhang --- .../net/ethernet/stmicro/stmmac/dwmac-sunxi.c | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c index beceeae579bf..b857235f5b1f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c @@ -108,36 +108,31 @@ static int sun7i_gmac_probe(struct platform_device *pdev) if (ret) return ret; - plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac); + plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac); if (IS_ERR(plat_dat)) return PTR_ERR(plat_dat); gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL); - if (!gmac) { - ret = -ENOMEM; - goto err_remove_config_dt; - } + if (!gmac) + return -ENOMEM; ret = of_get_phy_mode(dev->of_node, &gmac->interface); if (ret && ret != -ENODEV) { dev_err(dev, "Can't get phy-mode\n"); - goto err_remove_config_dt; + return ret; } gmac->tx_clk = devm_clk_get(dev, "allwinner_gmac_tx"); if (IS_ERR(gmac->tx_clk)) { dev_err(dev, "could not get tx clock\n"); - ret = PTR_ERR(gmac->tx_clk); - goto err_remove_config_dt; + return PTR_ERR(gmac->tx_clk); } /* Optional regulator for PHY */ gmac->regulator = devm_regulator_get_optional(dev, "phy"); if (IS_ERR(gmac->regulator)) { - if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER) { - ret = -EPROBE_DEFER; - goto err_remove_config_dt; - } + if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER) + return -EPROBE_DEFER; dev_info(dev, "no regulator found\n"); gmac->regulator = NULL; } @@ -155,7 +150,7 @@ static int sun7i_gmac_probe(struct platform_device *pdev) ret = sun7i_gmac_init(pdev, plat_dat->bsp_priv); if (ret) - goto err_remove_config_dt; + return ret; ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); if (ret) @@ -165,8 +160,6 @@ static int sun7i_gmac_probe(struct platform_device *pdev) err_gmac_exit: sun7i_gmac_exit(pdev, plat_dat->bsp_priv); -err_remove_config_dt: - stmmac_remove_config_dt(pdev, plat_dat); return ret; } @@ -179,7 +172,7 @@ MODULE_DEVICE_TABLE(of, sun7i_dwmac_match); static struct platform_driver sun7i_dwmac_driver = { .probe = sun7i_gmac_probe, - .remove_new = stmmac_pltfr_remove, + .remove_new = stmmac_pltfr_remove_no_dt, .driver = { .name = "sun7i-dwmac", .pm = &stmmac_pltfr_pm_ops, -- 2.40.1