]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
clk: at91: h32mx: convert from round_rate() to determine_rate()
authorBrian Masney <bmasney@redhat.com>
Mon, 11 Aug 2025 15:17:57 +0000 (11:17 -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/at91/clk-h32mx.c

index 1e6c12eeda10c4abb51c2046ea27b238db2560cb..a9aa93b5a870988677ad4609a210ed9570295228 100644 (file)
@@ -40,21 +40,32 @@ static unsigned long clk_sama5d4_h32mx_recalc_rate(struct clk_hw *hw,
        return parent_rate;
 }
 
-static long clk_sama5d4_h32mx_round_rate(struct clk_hw *hw, unsigned long rate,
-                                      unsigned long *parent_rate)
+static int clk_sama5d4_h32mx_determine_rate(struct clk_hw *hw,
+                                           struct clk_rate_request *req)
 {
        unsigned long div;
 
-       if (rate > *parent_rate)
-               return *parent_rate;
-       div = *parent_rate / 2;
-       if (rate < div)
-               return div;
+       if (req->rate > req->best_parent_rate) {
+               req->rate = req->best_parent_rate;
 
-       if (rate - div < *parent_rate - rate)
-               return div;
+               return 0;
+       }
+       div = req->best_parent_rate / 2;
+       if (req->rate < div) {
+               req->rate = div;
+
+               return 0;
+       }
+
+       if (req->rate - div < req->best_parent_rate - req->rate) {
+               req->rate = div;
 
-       return *parent_rate;
+               return 0;
+       }
+
+       req->rate = req->best_parent_rate;
+
+       return 0;
 }
 
 static int clk_sama5d4_h32mx_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -77,7 +88,7 @@ static int clk_sama5d4_h32mx_set_rate(struct clk_hw *hw, unsigned long rate,
 
 static const struct clk_ops h32mx_ops = {
        .recalc_rate = clk_sama5d4_h32mx_recalc_rate,
-       .round_rate = clk_sama5d4_h32mx_round_rate,
+       .determine_rate = clk_sama5d4_h32mx_determine_rate,
        .set_rate = clk_sama5d4_h32mx_set_rate,
 };