]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
clk: scmi: Use new determine_rate clock operation
authorCristian Marussi <cristian.marussi@arm.com>
Fri, 8 May 2026 15:32:48 +0000 (16:32 +0100)
committerSudeep Holla <sudeep.holla@kernel.org>
Tue, 12 May 2026 14:29:10 +0000 (15:29 +0100)
Use the Clock protocol layer determine_rate logic to calculate the closest
rate that can be supported by a specific clock.

No functional change.

Cc: Brian Masney <bmasney@redhat.com>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Tested-by: Florian Fainelli <florian.fainelli@broadcom.com>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://patch.msgid.link/20260508153300.2224715-4-cristian.marussi@arm.com
Reviewed-by: Brian Masney <bmasney@redhat.com>
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
drivers/clk/clk-scmi.c

index b6a12f3bc123c92f4bfce24babdc4e2fcb329dae..c223e4ef1dd17acef27e247bf8785250a1f16b5e 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/of.h>
-#include <linux/math64.h>
 #include <linux/module.h>
 #include <linux/scmi_protocol.h>
 
@@ -57,35 +56,17 @@ static unsigned long scmi_clk_recalc_rate(struct clk_hw *hw,
 static int scmi_clk_determine_rate(struct clk_hw *hw,
                                   struct clk_rate_request *req)
 {
-       u64 fmin, fmax, ftmp;
+       int ret;
        struct scmi_clk *clk = to_scmi_clk(hw);
 
        /*
-        * We can't figure out what rate it will be, so just return the
-        * rate back to the caller. scmi_clk_recalc_rate() will be called
-        * after the rate is set and we'll know what rate the clock is
+        * If we could not get a better rate scmi_clk_recalc_rate() will be
+        * called after the rate is set and we'll know what rate the clock is
         * running at then.
         */
-       if (clk->info->rate_discrete)
-               return 0;
-
-       fmin = clk->info->range.min_rate;
-       fmax = clk->info->range.max_rate;
-       if (req->rate <= fmin) {
-               req->rate = fmin;
-
-               return 0;
-       } else if (req->rate >= fmax) {
-               req->rate = fmax;
-
-               return 0;
-       }
-
-       ftmp = req->rate - fmin;
-       ftmp += clk->info->range.step_size - 1; /* to round up */
-       ftmp = div64_ul(ftmp, clk->info->range.step_size);
-
-       req->rate = ftmp * clk->info->range.step_size + fmin;
+       ret = scmi_proto_clk_ops->determine_rate(clk->ph, clk->id, &req->rate);
+       if (ret)
+               return ret;
 
        return 0;
 }