From nobody Fri Dec 19 16:00:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7EE1C83F18 for ; Tue, 29 Aug 2023 10:53:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235186AbjH2Kxc (ORCPT ); Tue, 29 Aug 2023 06:53:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232196AbjH2KxN (ORCPT ); Tue, 29 Aug 2023 06:53:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E2F7AB for ; Tue, 29 Aug 2023 03:53:10 -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 9F8426545B for ; Tue, 29 Aug 2023 10:53:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E253C433C9; Tue, 29 Aug 2023 10:53:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1693306389; bh=8DqJfXvXVRDqjgnN3KzU58KERFF7Sd7wLkdDZEnq1nM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LvYuLlXSmmeQx/p8z2LlIFcUnd1Wz1BTu0KVbRnLzCOGSy+uQHFbTcnxL6y5CLgSs eTvMrXGUuCsF/O6tYuz6BQwLnivxtNtHu3ki3LZOE7eVKU7lAzCeCHftBgOpL2gfID ztgBHJxUuTh6N+erP5/cpySQMwKzQ/Ynhb0hKjPqqe/scUWzweTRg7I9SVhD+Z4Ls+ IHg7sljE+n5DZkPLztM10xyvPtO6YR2QOJt3BELwd8tE0JaFrKPePk+McRA16eJyrp 4Uo4N550cUnSc9aC1xQ/WlMdPGj7mMKwFAGWgeMz6h4MDd+H0DTHZ/ZNScT1I68Aiq RgISSV7S3+wgg== 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 06/22] net: stmmac: dwmac-ingenic: use devm_stmmac_probe_config_dt() Date: Tue, 29 Aug 2023 18:40:17 +0800 Message-Id: <20230829104033.955-7-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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-ingenic.c | 35 ++++++------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c b/drivers/= net/ethernet/stmicro/stmmac/dwmac-ingenic.c index e22ef0d6bc73..ddfd7af63492 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c @@ -241,29 +241,25 @@ static int ingenic_mac_probe(struct platform_device *= pdev) if (ret) return ret; =20 - plat_dat =3D stmmac_probe_config_dt(pdev, stmmac_res.mac); + plat_dat =3D devm_stmmac_probe_config_dt(pdev, stmmac_res.mac); if (IS_ERR(plat_dat)) return PTR_ERR(plat_dat); =20 mac =3D devm_kzalloc(&pdev->dev, sizeof(*mac), GFP_KERNEL); - if (!mac) { - ret =3D -ENOMEM; - goto err_remove_config_dt; - } + if (!mac) + return -ENOMEM; =20 data =3D of_device_get_match_data(&pdev->dev); if (!data) { dev_err(&pdev->dev, "No of match data provided\n"); - ret =3D -EINVAL; - goto err_remove_config_dt; + return -EINVAL; } =20 /* Get MAC PHY control register */ mac->regmap =3D syscon_regmap_lookup_by_phandle(pdev->dev.of_node, "mode-= reg"); if (IS_ERR(mac->regmap)) { dev_err(&pdev->dev, "%s: Failed to get syscon regmap\n", __func__); - ret =3D PTR_ERR(mac->regmap); - goto err_remove_config_dt; + return PTR_ERR(mac->regmap); } =20 if (!of_property_read_u32(pdev->dev.of_node, "tx-clk-delay-ps", &tx_delay= _ps)) { @@ -272,8 +268,7 @@ static int ingenic_mac_probe(struct platform_device *pd= ev) mac->tx_delay =3D tx_delay_ps * 1000; } else { dev_err(&pdev->dev, "Invalid TX clock delay: %dps\n", tx_delay_ps); - ret =3D -EINVAL; - goto err_remove_config_dt; + return -EINVAL; } } =20 @@ -283,8 +278,7 @@ static int ingenic_mac_probe(struct platform_device *pd= ev) mac->rx_delay =3D rx_delay_ps * 1000; } else { dev_err(&pdev->dev, "Invalid RX clock delay: %dps\n", rx_delay_ps); - ret =3D -EINVAL; - goto err_remove_config_dt; + return -EINVAL; } } =20 @@ -295,18 +289,9 @@ static int ingenic_mac_probe(struct platform_device *p= dev) =20 ret =3D ingenic_mac_init(plat_dat); if (ret) - goto err_remove_config_dt; - - ret =3D 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; =20 - return ret; + return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); } =20 #ifdef CONFIG_PM_SLEEP @@ -385,7 +370,7 @@ MODULE_DEVICE_TABLE(of, ingenic_mac_of_matches); =20 static struct platform_driver ingenic_mac_driver =3D { .probe =3D ingenic_mac_probe, - .remove_new =3D stmmac_pltfr_remove, + .remove_new =3D stmmac_pltfr_remove_no_dt, .driver =3D { .name =3D "ingenic-mac", .pm =3D pm_ptr(&ingenic_mac_pm_ops), --=20 2.40.1