Message ID | 20220521083425.787204-1-u.kleine-koenig@pengutronix.de (mailing list archive) |
---|---|
State | Accepted |
Commit | 43252ed15f46658cec64edecfe610e40f6a12d85 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [v2] net: fec: Do proper error checking for optional clks | expand |
On Sat, May 21, 2022 at 10:34:25AM +0200, Uwe Kleine-König wrote: > An error code returned by devm_clk_get() might have other meanings than > "This clock doesn't exist". So use devm_clk_get_optional() and handle > all remaining errors as fatal. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Andrew
Hello: This patch was applied to netdev/net.git (master) by David S. Miller <davem@davemloft.net>: On Sat, 21 May 2022 10:34:25 +0200 you wrote: > An error code returned by devm_clk_get() might have other meanings than > "This clock doesn't exist". So use devm_clk_get_optional() and handle > all remaining errors as fatal. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > --- > Hello, > > [...] Here is the summary with links: - [v2] net: fec: Do proper error checking for optional clks https://git.kernel.org/netdev/net/c/43252ed15f46 You are awesome, thank you!
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 11227f51404c..907b379d2c83 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3866,17 +3866,21 @@ fec_probe(struct platform_device *pdev) fep->itr_clk_rate = clk_get_rate(fep->clk_ahb); /* enet_out is optional, depends on board */ - fep->clk_enet_out = devm_clk_get(&pdev->dev, "enet_out"); - if (IS_ERR(fep->clk_enet_out)) - fep->clk_enet_out = NULL; + fep->clk_enet_out = devm_clk_get_optional(&pdev->dev, "enet_out"); + if (IS_ERR(fep->clk_enet_out)) { + ret = PTR_ERR(fep->clk_enet_out); + goto failed_clk; + } fep->ptp_clk_on = false; mutex_init(&fep->ptp_clk_mutex); /* clk_ref is optional, depends on board */ - fep->clk_ref = devm_clk_get(&pdev->dev, "enet_clk_ref"); - if (IS_ERR(fep->clk_ref)) - fep->clk_ref = NULL; + fep->clk_ref = devm_clk_get_optional(&pdev->dev, "enet_clk_ref"); + if (IS_ERR(fep->clk_ref)) { + ret = PTR_ERR(fep->clk_ref); + goto failed_clk; + } fep->clk_ref_rate = clk_get_rate(fep->clk_ref); /* clk_2x_txclk is optional, depends on board */
An error code returned by devm_clk_get() might have other meanings than "This clock doesn't exist". So use devm_clk_get_optional() and handle all remaining errors as fatal. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- Hello, as Andrew pointed out, there are two clocks that can benefit from better error handling during probe. So compared to (implicit) v1 this also cares for "enet_clk_ref". Best regards Uwe drivers/net/ethernet/freescale/fec_main.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) base-commit: 3123109284176b1532874591f7c81f3837bbdc17