diff mbox series

[net-next,RESEND] net: fec: Do proper error checking for enet_out clk

Message ID 20220520062650.712561-1-u.kleine-koenig@pengutronix.de (mailing list archive)
State Accepted
Commit 5ff851b7be752a6d607c289b489c40f96f9dc489
Delegated to: Netdev Maintainers
Headers show
Series [net-next,RESEND] net: fec: Do proper error checking for enet_out clk | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: pabeni@redhat.com edumazet@google.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 14 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Uwe Kleine-König May 20, 2022, 6:26 a.m. UTC
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,

I sent this back in March and was asked to resend after the merge window
closed. Actually I intended to do this earlier, but it got lost in my
todo list and I found it just now. (And after all it is still after the
merge window and http://vger.kernel.org/~davem/net-next.html claims it's
still time ... :-)

Best regards
Uwe

 drivers/net/ethernet/freescale/fec_main.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)


base-commit: 3123109284176b1532874591f7c81f3837bbdc17

Comments

Andrew Lunn May 20, 2022, 8:20 p.m. UTC | #1
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index 11227f51404c..2512b68d8545 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -3866,9 +3866,11 @@ 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);

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

This is O.K, as far as it goes. But directly after this we have:

	/* 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_rate = clk_get_rate(fep->clk_ref);

It would be good to do the same to this clock as well.

    Andrew
patchwork-bot+netdevbpf@kernel.org May 22, 2022, 9 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Fri, 20 May 2022 08:26:50 +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:
  - [net-next,RESEND] net: fec: Do proper error checking for enet_out clk
    https://git.kernel.org/netdev/net-next/c/5ff851b7be75

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 11227f51404c..2512b68d8545 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -3866,9 +3866,11 @@  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);