All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yuanjun Gong <ruc_gongyuanjun@163.com>
To: kuba@kernel.org
Cc: davem@davemloft.net, edumazet@google.com, netdev@vger.kernel.org,
	pabeni@redhat.com, Yuanjun Gong <ruc_gongyuanjun@163.com>
Subject: [PATCH v2 1/1] net: korina: handle clk prepare error in korina_probe()
Date: Mon, 31 Jul 2023 17:05:35 +0800	[thread overview]
Message-ID: <20230731090535.21416-1-ruc_gongyuanjun@163.com> (raw)
In-Reply-To: <20230728162639.1c08f645@kernel.org>

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


  reply	other threads:[~2023-07-31  9:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Yuanjun Gong [this message]
2023-08-01 22:00     ` [PATCH v2 1/1] net: korina: handle clk prepare error " patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230731090535.21416-1-ruc_gongyuanjun@163.com \
    --to=ruc_gongyuanjun@163.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.