Message ID | 20240822084733.1599295-3-frank.li@vivo.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | net: convert to devm_clk_get_enabled() and devm_clk_get_optional_enabled() | expand |
Hi, On Thu, 22 Aug 2024 02:47:26 -0600 Yangtao Li <frank.li@vivo.com> wrote: > Use devm_clk_get_enabled() and devm_clk_get_optional_enabled() > to simplify code. > > Signed-off-by: Yangtao Li <frank.li@vivo.com> Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Thanks, Maxime
On Thu, Aug 22, 2024 at 02:47:26AM -0600, Yangtao Li wrote: > Use devm_clk_get_enabled() and devm_clk_get_optional_enabled() > to simplify code. > > Signed-off-by: Yangtao Li <frank.li@vivo.com> Hi Yangtao Li, I feel that I am missing something obvious here, but this patch fails to build when applied to net-next. clang-18 for an x86_64 allmodconfig W=1 build says: drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:625:10: error: incompatible pointer types returning 'struct clk *' from a function with result type 'struct plat_stmmacenet_data *' [-Werror,-Wincompatible-pointer-types] 625 | return plat->pclk; | ^~~~~~~~~~ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:641:10: error: incompatible pointer types returning 'struct reset_control *' from a function with result type 'struct plat_stmmacenet_data *' [-Werror,-Wincompatible-pointer-types] 641 | return plat->stmmac_rst; | ^~~~~~~~~~~~~~~~ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:646:10: error: incompatible pointer types returning 'struct reset_control *' from a function with result type 'struct plat_stmmacenet_data *' [-Werror,-Wincompatible-pointer-types] 646 | return plat->stmmac_ahb_rst; | ^~~~~~~~~~~~~~~~~~~~ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:437:8: warning: unused variable 'ret' [-Wunused-variable] 437 | void *ret; | ^~~
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index ad868e8d195d..9aba6318ee77 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -415,8 +415,6 @@ static int stmmac_of_get_mac_mode(struct device_node *np) static void stmmac_remove_config_dt(struct platform_device *pdev, struct plat_stmmacenet_data *plat) { - clk_disable_unprepare(plat->stmmac_clk); - clk_disable_unprepare(plat->pclk); of_node_put(plat->phy_node); of_node_put(plat->mdio_node); } @@ -615,21 +613,16 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) /* clock setup */ if (!of_device_is_compatible(np, "snps,dwc-qos-ethernet-4.10")) { - plat->stmmac_clk = devm_clk_get(&pdev->dev, - STMMAC_RESOURCE_NAME); + plat->stmmac_clk = devm_clk_get_enabled(&pdev->dev, STMMAC_RESOURCE_NAME); if (IS_ERR(plat->stmmac_clk)) { dev_warn(&pdev->dev, "Cannot get CSR clock\n"); plat->stmmac_clk = NULL; } - clk_prepare_enable(plat->stmmac_clk); } - plat->pclk = devm_clk_get_optional(&pdev->dev, "pclk"); - if (IS_ERR(plat->pclk)) { - ret = plat->pclk; - goto error_pclk_get; - } - clk_prepare_enable(plat->pclk); + plat->pclk = devm_clk_get_optional_enabled(&pdev->dev, "pclk"); + if (IS_ERR(plat->pclk)) + return plat->pclk; /* Fall-back to main clock in case of no PTP ref is passed */ plat->clk_ptp_ref = devm_clk_get(&pdev->dev, "ptp_ref"); @@ -644,26 +637,15 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) plat->stmmac_rst = devm_reset_control_get_optional(&pdev->dev, STMMAC_RESOURCE_NAME); - if (IS_ERR(plat->stmmac_rst)) { - ret = plat->stmmac_rst; - goto error_hw_init; - } + if (IS_ERR(plat->stmmac_rst)) + return plat->stmmac_rst; plat->stmmac_ahb_rst = devm_reset_control_get_optional_shared( &pdev->dev, "ahb"); - if (IS_ERR(plat->stmmac_ahb_rst)) { - ret = plat->stmmac_ahb_rst; - goto error_hw_init; - } + if (IS_ERR(plat->stmmac_ahb_rst)) + return plat->stmmac_ahb_rst; return plat; - -error_hw_init: - clk_disable_unprepare(plat->pclk); -error_pclk_get: - clk_disable_unprepare(plat->stmmac_clk); - - return ret; } static void devm_stmmac_remove_config_dt(void *data)
Use devm_clk_get_enabled() and devm_clk_get_optional_enabled() to simplify code. Signed-off-by: Yangtao Li <frank.li@vivo.com> --- .../ethernet/stmicro/stmmac/stmmac_platform.c | 34 +++++-------------- 1 file changed, 8 insertions(+), 26 deletions(-)