* [PATCH 1/1] net: korina: fix value check in korina_probe()
@ 2023-07-26 13:29 Yuanjun Gong
2023-07-28 23:26 ` Jakub Kicinski
0 siblings, 1 reply; 4+ messages in thread
From: Yuanjun Gong @ 2023-07-26 13:29 UTC (permalink / raw)
To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev
Cc: Yuanjun Gong
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(-)
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 */
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] net: korina: fix value check in korina_probe()
2023-07-26 13:29 [PATCH 1/1] net: korina: fix value check in korina_probe() Yuanjun Gong
@ 2023-07-28 23:26 ` Jakub Kicinski
2023-07-31 9:05 ` [PATCH v2 1/1] net: korina: handle clk prepare error " Yuanjun Gong
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2023-07-28 23:26 UTC (permalink / raw)
To: Yuanjun Gong; +Cc: David S . Miller, Eric Dumazet, Paolo Abeni, netdev
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;
--
pw-bot: cr
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/1] net: korina: handle clk prepare error in korina_probe()
2023-07-28 23:26 ` Jakub Kicinski
@ 2023-07-31 9:05 ` Yuanjun Gong
2023-08-01 22:00 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 4+ messages in thread
From: Yuanjun Gong @ 2023-07-31 9:05 UTC (permalink / raw)
To: kuba; +Cc: davem, edumazet, netdev, pabeni, Yuanjun Gong
in korina_probe(), the return value of clk_prepare_enable()
should be checked since it might fail. we can use
devm_clk_get_optional_enabled() instead of devm_clk_get_optional()
and clk_prepare_enable() to automatically handle the error.
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 | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c
index 2b9335cb4bb3..8537578e1cf1 100644
--- a/drivers/net/ethernet/korina.c
+++ b/drivers/net/ethernet/korina.c
@@ -1302,11 +1302,10 @@ static int korina_probe(struct platform_device *pdev)
else if (of_get_ethdev_address(pdev->dev.of_node, dev) < 0)
eth_hw_addr_random(dev);
- clk = devm_clk_get_optional(&pdev->dev, "mdioclk");
+ clk = devm_clk_get_optional_enabled(&pdev->dev, "mdioclk");
if (IS_ERR(clk))
return PTR_ERR(clk);
if (clk) {
- clk_prepare_enable(clk);
lp->mii_clock_freq = clk_get_rate(clk);
} else {
lp->mii_clock_freq = 200000000; /* max possible input clk */
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/1] net: korina: handle clk prepare error in korina_probe()
2023-07-31 9:05 ` [PATCH v2 1/1] net: korina: handle clk prepare error " Yuanjun Gong
@ 2023-08-01 22:00 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-08-01 22:00 UTC (permalink / raw)
To: Yuanjun Gong; +Cc: kuba, davem, edumazet, netdev, pabeni
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 31 Jul 2023 17:05:35 +0800 you wrote:
> in korina_probe(), the return value of clk_prepare_enable()
> should be checked since it might fail. we can use
> devm_clk_get_optional_enabled() instead of devm_clk_get_optional()
> and clk_prepare_enable() to automatically handle the error.
>
> Fixes: e4cd854ec487 ("net: korina: Get mdio input clock via common clock framework")
> Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
>
> [...]
Here is the summary with links:
- [v2,1/1] net: korina: handle clk prepare error in korina_probe()
https://git.kernel.org/netdev/net/c/0b6291ad1940
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-01 22:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-26 13:29 [PATCH 1/1] net: korina: fix value check in korina_probe() Yuanjun Gong
2023-07-28 23:26 ` Jakub Kicinski
2023-07-31 9:05 ` [PATCH v2 1/1] net: korina: handle clk prepare error " Yuanjun Gong
2023-08-01 22:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).