]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
clk: fractional-divider: convert from round_rate() to determine_rate()
authorBrian Masney <bmasney@redhat.com>
Mon, 11 Aug 2025 15:18:07 +0000 (11:18 -0400)
committerBrian Masney <bmasney@redhat.com>
Mon, 8 Sep 2025 13:41:26 +0000 (09:41 -0400)
The round_rate() clk ops is deprecated, so migrate this driver from
round_rate() to determine_rate() using the Coccinelle semantic patch
on the cover letter of this series.

Signed-off-by: Brian Masney <bmasney@redhat.com>
drivers/clk/clk-fractional-divider.c

index da057172cc90f145743a4f7dfd71870bd63b564b..cd36a6e27f251f88c5fdf06e7de4bd8cbe332c24 100644 (file)
@@ -151,25 +151,32 @@ void clk_fractional_divider_general_approximation(struct clk_hw *hw,
 }
 EXPORT_SYMBOL_GPL(clk_fractional_divider_general_approximation);
 
-static long clk_fd_round_rate(struct clk_hw *hw, unsigned long rate,
-                             unsigned long *parent_rate)
+static int clk_fd_determine_rate(struct clk_hw *hw,
+                                struct clk_rate_request *req)
 {
        struct clk_fractional_divider *fd = to_clk_fd(hw);
        unsigned long m, n;
        u64 ret;
 
-       if (!rate || (!clk_hw_can_set_rate_parent(hw) && rate >= *parent_rate))
-               return *parent_rate;
+       if (!req->rate || (!clk_hw_can_set_rate_parent(hw) && req->rate >= req->best_parent_rate)) {
+               req->rate = req->best_parent_rate;
+
+               return 0;
+       }
 
        if (fd->approximation)
-               fd->approximation(hw, rate, parent_rate, &m, &n);
+               fd->approximation(hw, req->rate, &req->best_parent_rate, &m, &n);
        else
-               clk_fractional_divider_general_approximation(hw, rate, parent_rate, &m, &n);
+               clk_fractional_divider_general_approximation(hw, req->rate,
+                                                            &req->best_parent_rate,
+                                                            &m, &n);
 
-       ret = (u64)*parent_rate * m;
+       ret = (u64)req->best_parent_rate * m;
        do_div(ret, n);
 
-       return ret;
+       req->rate = ret;
+
+       return 0;
 }
 
 static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -250,7 +257,7 @@ static void clk_fd_debug_init(struct clk_hw *hw, struct dentry *dentry)
 
 const struct clk_ops clk_fractional_divider_ops = {
        .recalc_rate = clk_fd_recalc_rate,
-       .round_rate = clk_fd_round_rate,
+       .determine_rate = clk_fd_determine_rate,
        .set_rate = clk_fd_set_rate,
 #ifdef CONFIG_DEBUG_FS
        .debug_init = clk_fd_debug_init,