Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp3346043rdb; Tue, 29 Aug 2023 12:22:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGLQM31xtYL2dpZWR/QcuD43rIolHalN9m+Sqbt7t3R75vU6PJHmHTsGOJr+5q/gHfR2p4X X-Received: by 2002:a17:902:dac1:b0:1b5:674d:2aa5 with SMTP id q1-20020a170902dac100b001b5674d2aa5mr312739plx.13.1693336933408; Tue, 29 Aug 2023 12:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693336933; cv=none; d=google.com; s=arc-20160816; b=fHKQjJoYFliDfgZrGsbq4um/CpjJkv4JqkQVyOzQjUe26ajy6g/P5nQa3IOYFmgQ1M qDCyaRgS5S8cXvoiApXK114qbtqQmSuTq7N+nSZ2g9iiyaX2saFFP/xkPp3DfAjx3X8n 9kLU1jsV+5B0YCeGgnRiABNvr/nUcfX3M8F4niUtmfFZydHYj2J0pFAZyxAqikJrlbAn kmmFSceTo6dU9pbmwtym2JjU4YtFPmDR/QlJDg5iAlaCarSXGsCjf4I82upjZU8TnYFP EV8ZdfT9VLFCnegX4xK2g4d9XJYIkdx8x5je6yhBoAUb0FH6ra0/Z+lAGlKwmD8w51py IU1A== 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=vCt/jPuVskrFpdgPGOBO4Cqq+OLtK9HA44FFfUUmuQg=; fh=r/VVG12KmrF+nQv7lC2x2sQ0qQnFs7bJUsMqdUzXKDU=; b=d7mZi5G89DQMUacd/1ViAMslxA9KjWIw/00gsUESgU+3f1E7xPU/PcXOQgzeMnreIf NMkAPbh4mPj8YlZPtWLKmE4JdfNxqjBcVg+koddqeJ2MLN4YXe0bPvduFAPqKxCH2n73 53Tc21HfTSZ5f2aQRdb4NXztMm5M8WyhjtIUUpQNCc0/zZdQM12GLwxSj1QPFp+kXNzi rYCTJZl5W603RbGbmfWKo0584LqrK3Ni42pLknWH3rPKzH2kC6lDbWNIh52NVYlpWR8M cYRvDoebwYHz04Rz/+2pJjtluCo41CLHnVNEhGWq2vWhXrCtHPn3iQxTBM08DJSU26PI NzOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uhoBUQV2; 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 ko4-20020a17090307c400b001bdd35033f4si9124261plb.387.2023.08.29.12.21.57; Tue, 29 Aug 2023 12:22:13 -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=uhoBUQV2; 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 S235206AbjH2Kya (ORCPT + 99 others); Tue, 29 Aug 2023 06:54:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235313AbjH2KyV (ORCPT ); Tue, 29 Aug 2023 06:54:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97A4CCF4 for ; Tue, 29 Aug 2023 03:53:51 -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 0F6176545D for ; Tue, 29 Aug 2023 10:53:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 732C2C433CA; Tue, 29 Aug 2023 10:53:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1693306429; bh=isFMv5J3rpOHLVDhhNbIoTnhkQjoG9ObXVsYmwnSTWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uhoBUQV2UlvEvXTJ6FesBJUWqQ8Fgm4vPFQR3HIO5bXsCvSSxhZFddMPEm0stx9ef lMRynaqBRCIVrvXglDzIgWvfuNXWJvNeMTNUO7MEx5bQMfUlG7YWN9DC40vnXhy2KA V5X06L2jau4ArXqR+Gt+rvakJx4Bmdoj7hYswq7SUCBC/nBTtRHqd1xNsgwOq6nMLb gDz7uN2o7DVL0uUpAuDv9Z0ZN1Ud+XK3jAiOUvfy5IjbvkK9P2RkafPzmqFpWUFHdD kiH9G4Cw9hG/3cIw2SuRlgzlWaS+bQb+NBToTsk7Nx/rNTImuQsh9u/B3Pz95GYWzC H19/PmdaPlrZg== 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 12/22] net: stmmac: dwmac-meson8b: use devm_stmmac_probe_config_dt() Date: Tue, 29 Aug 2023 18:40:23 +0800 Message-Id: <20230829104033.955-13-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 --- .../ethernet/stmicro/stmmac/dwmac-meson8b.c | 55 ++++++------------- 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c index 0b159dc0d5f6..37f249980929 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c @@ -400,33 +400,27 @@ static int meson8b_dwmac_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); dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); - if (!dwmac) { - ret = -ENOMEM; - goto err_remove_config_dt; - } + if (!dwmac) + return -ENOMEM; dwmac->data = (const struct meson8b_dwmac_data *) of_device_get_match_data(&pdev->dev); - if (!dwmac->data) { - ret = -EINVAL; - goto err_remove_config_dt; - } + if (!dwmac->data) + return -EINVAL; dwmac->regs = devm_platform_ioremap_resource(pdev, 1); - if (IS_ERR(dwmac->regs)) { - ret = PTR_ERR(dwmac->regs); - goto err_remove_config_dt; - } + if (IS_ERR(dwmac->regs)) + return PTR_ERR(dwmac->regs); dwmac->dev = &pdev->dev; ret = of_get_phy_mode(pdev->dev.of_node, &dwmac->phy_mode); if (ret) { dev_err(&pdev->dev, "missing phy-mode property\n"); - goto err_remove_config_dt; + return ret; } /* use 2ns as fallback since this value was previously hardcoded */ @@ -448,53 +442,40 @@ static int meson8b_dwmac_probe(struct platform_device *pdev) if (dwmac->rx_delay_ps > 3000 || dwmac->rx_delay_ps % 200) { dev_err(dwmac->dev, "The RGMII RX delay range is 0..3000ps in 200ps steps"); - ret = -EINVAL; - goto err_remove_config_dt; + return -EINVAL; } } else { if (dwmac->rx_delay_ps != 0 && dwmac->rx_delay_ps != 2000) { dev_err(dwmac->dev, "The only allowed RGMII RX delays values are: 0ps, 2000ps"); - ret = -EINVAL; - goto err_remove_config_dt; + return -EINVAL; } } dwmac->timing_adj_clk = devm_clk_get_optional(dwmac->dev, "timing-adjustment"); - if (IS_ERR(dwmac->timing_adj_clk)) { - ret = PTR_ERR(dwmac->timing_adj_clk); - goto err_remove_config_dt; - } + if (IS_ERR(dwmac->timing_adj_clk)) + return PTR_ERR(dwmac->timing_adj_clk); ret = meson8b_init_rgmii_delays(dwmac); if (ret) - goto err_remove_config_dt; + return ret; ret = meson8b_init_rgmii_tx_clk(dwmac); if (ret) - goto err_remove_config_dt; + return ret; ret = dwmac->data->set_phy_mode(dwmac); if (ret) - goto err_remove_config_dt; + return ret; ret = meson8b_init_prg_eth(dwmac); if (ret) - goto err_remove_config_dt; + return ret; plat_dat->bsp_priv = dwmac; - ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); - if (ret) - goto err_remove_config_dt; - - return 0; - -err_remove_config_dt: - stmmac_remove_config_dt(pdev, plat_dat); - - return ret; + return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); } static const struct meson8b_dwmac_data meson8b_dwmac_data = { @@ -539,7 +520,7 @@ MODULE_DEVICE_TABLE(of, meson8b_dwmac_match); static struct platform_driver meson8b_dwmac_driver = { .probe = meson8b_dwmac_probe, - .remove_new = stmmac_pltfr_remove, + .remove_new = stmmac_pltfr_remove_no_dt, .driver = { .name = "meson8b-dwmac", .pm = &stmmac_pltfr_pm_ops, -- 2.40.1