]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
clk: bcm: iproc-asiu: convert from round_rate() to determine_rate()
authorBrian Masney <bmasney@redhat.com>
Mon, 11 Aug 2025 15:19:10 +0000 (11:19 -0400)
committerBrian Masney <bmasney@redhat.com>
Mon, 8 Sep 2025 13:41:30 +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/bcm/clk-iproc-asiu.c

index dcacf55c55ae06bc45fd5585265084075353b379..83ec13da9b2e1de9438ee4fb23b8e2e1852d59f2 100644 (file)
@@ -98,22 +98,27 @@ static unsigned long iproc_asiu_clk_recalc_rate(struct clk_hw *hw,
        return clk->rate;
 }
 
-static long iproc_asiu_clk_round_rate(struct clk_hw *hw, unsigned long rate,
-                                     unsigned long *parent_rate)
+static int iproc_asiu_clk_determine_rate(struct clk_hw *hw,
+                                        struct clk_rate_request *req)
 {
        unsigned int div;
 
-       if (rate == 0 || *parent_rate == 0)
+       if (req->rate == 0 || req->best_parent_rate == 0)
                return -EINVAL;
 
-       if (rate == *parent_rate)
-               return *parent_rate;
+       if (req->rate == req->best_parent_rate)
+               return 0;
 
-       div = DIV_ROUND_CLOSEST(*parent_rate, rate);
-       if (div < 2)
-               return *parent_rate;
+       div = DIV_ROUND_CLOSEST(req->best_parent_rate, req->rate);
+       if (div < 2) {
+               req->rate = req->best_parent_rate;
 
-       return *parent_rate / div;
+               return 0;
+       }
+
+       req->rate = req->best_parent_rate / div;
+
+       return 0;
 }
 
 static int iproc_asiu_clk_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -168,7 +173,7 @@ static const struct clk_ops iproc_asiu_ops = {
        .enable = iproc_asiu_clk_enable,
        .disable = iproc_asiu_clk_disable,
        .recalc_rate = iproc_asiu_clk_recalc_rate,
-       .round_rate = iproc_asiu_clk_round_rate,
+       .determine_rate = iproc_asiu_clk_determine_rate,
        .set_rate = iproc_asiu_clk_set_rate,
 };