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

index b0696a928aa98d6fd75c3f2e1911aa9b6d1827e6..e906928cfbf05143a1fa4fc69cd7004a30824b6b 100644 (file)
@@ -319,8 +319,8 @@ static unsigned long at91rm9200_clk_usb_recalc_rate(struct clk_hw *hw,
        return 0;
 }
 
-static long at91rm9200_clk_usb_round_rate(struct clk_hw *hw, unsigned long rate,
-                                         unsigned long *parent_rate)
+static int at91rm9200_clk_usb_determine_rate(struct clk_hw *hw,
+                                            struct clk_rate_request *req)
 {
        struct at91rm9200_clk_usb *usb = to_at91rm9200_clk_usb(hw);
        struct clk_hw *parent = clk_hw_get_parent(hw);
@@ -336,25 +336,27 @@ static long at91rm9200_clk_usb_round_rate(struct clk_hw *hw, unsigned long rate,
                if (!usb->divisors[i])
                        continue;
 
-               tmp_parent_rate = rate * usb->divisors[i];
+               tmp_parent_rate = req->rate * usb->divisors[i];
                tmp_parent_rate = clk_hw_round_rate(parent, tmp_parent_rate);
                tmprate = DIV_ROUND_CLOSEST(tmp_parent_rate, usb->divisors[i]);
-               if (tmprate < rate)
-                       tmpdiff = rate - tmprate;
+               if (tmprate < req->rate)
+                       tmpdiff = req->rate - tmprate;
                else
-                       tmpdiff = tmprate - rate;
+                       tmpdiff = tmprate - req->rate;
 
                if (bestdiff < 0 || bestdiff > tmpdiff) {
                        bestrate = tmprate;
                        bestdiff = tmpdiff;
-                       *parent_rate = tmp_parent_rate;
+                       req->best_parent_rate = tmp_parent_rate;
                }
 
                if (!bestdiff)
                        break;
        }
 
-       return bestrate;
+       req->rate = bestrate;
+
+       return 0;
 }
 
 static int at91rm9200_clk_usb_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -384,7 +386,7 @@ static int at91rm9200_clk_usb_set_rate(struct clk_hw *hw, unsigned long rate,
 
 static const struct clk_ops at91rm9200_usb_ops = {
        .recalc_rate = at91rm9200_clk_usb_recalc_rate,
-       .round_rate = at91rm9200_clk_usb_round_rate,
+       .determine_rate = at91rm9200_clk_usb_determine_rate,
        .set_rate = at91rm9200_clk_usb_set_rate,
 };