Message ID | 20230726132943.20318-1-ruc_gongyuanjun@163.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [1/1] net: korina: fix value check in korina_probe() | expand |
On Wed, 26 Jul 2023 21:29:43 +0800 Yuanjun Gong wrote: > clk = devm_clk_get_optional(&pdev->dev, "mdioclk"); Why not switch this to devm_clk_get_optional_enabled() instead? Error already handled, makes the code shorter.. > if (IS_ERR(clk)) > return PTR_ERR(clk); > if (clk) { > - clk_prepare_enable(clk); > + rc = clk_prepare_enable(clk); > + if (rc) > + return rc;
diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c index 2b9335cb4bb3..e18062007ae3 100644 --- a/drivers/net/ethernet/korina.c +++ b/drivers/net/ethernet/korina.c @@ -1306,7 +1306,9 @@ static int korina_probe(struct platform_device *pdev) if (IS_ERR(clk)) return PTR_ERR(clk); if (clk) { - clk_prepare_enable(clk); + rc = clk_prepare_enable(clk); + if (rc) + return rc; lp->mii_clock_freq = clk_get_rate(clk); } else { lp->mii_clock_freq = 200000000; /* max possible input clk */
in korina_probe(), check the return value of clk_prepare_enable() and return the error code if clk_prepare_enable() returns an unexpected value. Fixes: e4cd854ec487 ("net: korina: Get mdio input clock via common clock framework") Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com> --- drivers/net/ethernet/korina.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)