mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Alexander Shiyan <eagle.alexander923@gmail.com>
To: barebox@lists.infradead.org
Cc: Alexander Shiyan <eagle.alexander923@gmail.com>
Subject: [PATCH] clk: Fix incorrect rate comparison in clk_set_rate()
Date: Mon, 28 Apr 2025 12:25:06 +0300	[thread overview]
Message-ID: <20250428092506.27200-1-eagle.alexander923@gmail.com> (raw)

The original condition in clk_set_rate() compared the current clock rate
against clk_round_rate(clk, rate). However, when the clock driver doesn't
implement .round_rate(), clk_round_rate() falls back to returning the
current clock rate via clk_get_rate(). This created a situation where:
clk_get_rate(clk) == clk_round_rate(clk, rate)
would always evaluate to true when .round_rate() is unimplemented.

Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 drivers/clk/clk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index bd36878280..8ecfe35094 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -169,7 +169,8 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
-	if (clk_get_rate(clk) == clk_round_rate(clk, rate))
+	if (clk_get_rate(clk) ==
+	    (clk->ops->round_rate ? clk_round_rate(clk, rate) : rate))
 		return 0;
 
 	if (!clk->ops->set_rate)
-- 
2.39.1




                 reply	other threads:[~2025-04-28  9:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20250428092506.27200-1-eagle.alexander923@gmail.com \
    --to=eagle.alexander923@gmail.com \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox