]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
clk: xilinx: xlnx-clock-wizard: convert from round_rate() to determine_rate()
authorBrian Masney <bmasney@redhat.com>
Mon, 11 Aug 2025 15:18:58 +0000 (11:18 -0400)
committerBrian Masney <bmasney@redhat.com>
Mon, 8 Sep 2025 13:41:29 +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/xilinx/clk-xlnx-clock-wizard.c

index 0295a13a811cf8e00fd49879eefc5bcf4fb89228..3ee14770212a9f241d49123b25cee7abca350194 100644 (file)
@@ -322,8 +322,8 @@ err_reconfig:
        return err;
 }
 
-static long clk_wzrd_round_rate(struct clk_hw *hw, unsigned long rate,
-                               unsigned long *prate)
+static int clk_wzrd_determine_rate(struct clk_hw *hw,
+                                  struct clk_rate_request *req)
 {
        u8 div;
 
@@ -331,9 +331,11 @@ static long clk_wzrd_round_rate(struct clk_hw *hw, unsigned long rate,
         * since we don't change parent rate we just round rate to closest
         * achievable
         */
-       div = DIV_ROUND_CLOSEST(*prate, rate);
+       div = DIV_ROUND_CLOSEST(req->best_parent_rate, req->rate);
 
-       return *prate / div;
+       req->rate = req->best_parent_rate / div;
+
+       return 0;
 }
 
 static int clk_wzrd_get_divisors_ver(struct clk_hw *hw, unsigned long rate,
@@ -642,14 +644,14 @@ static unsigned long clk_wzrd_recalc_rate_all_ver(struct clk_hw *hw,
                        divider->flags, divider->width);
 }
 
-static long clk_wzrd_round_rate_all(struct clk_hw *hw, unsigned long rate,
-                                   unsigned long *prate)
+static int clk_wzrd_determine_rate_all(struct clk_hw *hw,
+                                      struct clk_rate_request *req)
 {
        struct clk_wzrd_divider *divider = to_clk_wzrd_divider(hw);
        u32 m, d, o;
        int err;
 
-       err = clk_wzrd_get_divisors(hw, rate, *prate);
+       err = clk_wzrd_get_divisors(hw, req->rate, req->best_parent_rate);
        if (err)
                return err;
 
@@ -657,19 +659,20 @@ static long clk_wzrd_round_rate_all(struct clk_hw *hw, unsigned long rate,
        d = divider->d;
        o = divider->o;
 
-       rate = div_u64(*prate * (m * 1000 + divider->m_frac), d * (o * 1000 + divider->o_frac));
-       return rate;
+       req->rate = div_u64(req->best_parent_rate * (m * 1000 + divider->m_frac),
+                           d * (o * 1000 + divider->o_frac));
+       return 0;
 }
 
-static long clk_wzrd_ver_round_rate_all(struct clk_hw *hw, unsigned long rate,
-                                       unsigned long *prate)
+static int clk_wzrd_ver_determine_rate_all(struct clk_hw *hw,
+                                          struct clk_rate_request *req)
 {
        struct clk_wzrd_divider *divider = to_clk_wzrd_divider(hw);
        unsigned long int_freq;
        u32 m, d, o, div, f;
        int err;
 
-       err = clk_wzrd_get_divisors_ver(hw, rate, *prate);
+       err = clk_wzrd_get_divisors_ver(hw, req->rate, req->best_parent_rate);
        if (err)
                return err;
 
@@ -678,36 +681,38 @@ static long clk_wzrd_ver_round_rate_all(struct clk_hw *hw, unsigned long rate,
        o = divider->o;
 
        div = d * o;
-       int_freq =  divider_recalc_rate(hw, *prate * m, div, divider->table,
+       int_freq =  divider_recalc_rate(hw, req->best_parent_rate * m, div,
+                                       divider->table,
                                        divider->flags, divider->width);
 
-       if (rate > int_freq) {
-               f = DIV_ROUND_CLOSEST_ULL(rate * WZRD_FRAC_POINTS, int_freq);
-               rate = DIV_ROUND_CLOSEST(int_freq * f, WZRD_FRAC_POINTS);
+       if (req->rate > int_freq) {
+               f = DIV_ROUND_CLOSEST_ULL(req->rate * WZRD_FRAC_POINTS,
+                                         int_freq);
+               req->rate = DIV_ROUND_CLOSEST(int_freq * f, WZRD_FRAC_POINTS);
        }
-       return rate;
+       return 0;
 }
 
 static const struct clk_ops clk_wzrd_ver_divider_ops = {
-       .round_rate = clk_wzrd_round_rate,
+       .determine_rate = clk_wzrd_determine_rate,
        .set_rate = clk_wzrd_ver_dynamic_reconfig,
        .recalc_rate = clk_wzrd_recalc_rate_ver,
 };
 
 static const struct clk_ops clk_wzrd_ver_div_all_ops = {
-       .round_rate = clk_wzrd_ver_round_rate_all,
+       .determine_rate = clk_wzrd_ver_determine_rate_all,
        .set_rate = clk_wzrd_dynamic_all_ver,
        .recalc_rate = clk_wzrd_recalc_rate_all_ver,
 };
 
 static const struct clk_ops clk_wzrd_clk_divider_ops = {
-       .round_rate = clk_wzrd_round_rate,
+       .determine_rate = clk_wzrd_determine_rate,
        .set_rate = clk_wzrd_dynamic_reconfig,
        .recalc_rate = clk_wzrd_recalc_rate,
 };
 
 static const struct clk_ops clk_wzrd_clk_div_all_ops = {
-       .round_rate = clk_wzrd_round_rate_all,
+       .determine_rate = clk_wzrd_determine_rate_all,
        .set_rate = clk_wzrd_dynamic_all,
        .recalc_rate = clk_wzrd_recalc_rate_all,
 };
@@ -769,14 +774,14 @@ static int clk_wzrd_dynamic_reconfig_f(struct clk_hw *hw, unsigned long rate,
                                WZRD_USEC_POLL, WZRD_TIMEOUT_POLL);
 }
 
-static long clk_wzrd_round_rate_f(struct clk_hw *hw, unsigned long rate,
-                                 unsigned long *prate)
+static int clk_wzrd_determine_rate_f(struct clk_hw *hw,
+                                    struct clk_rate_request *req)
 {
-       return rate;
+       return 0;
 }
 
 static const struct clk_ops clk_wzrd_clk_divider_ops_f = {
-       .round_rate = clk_wzrd_round_rate_f,
+       .determine_rate = clk_wzrd_determine_rate_f,
        .set_rate = clk_wzrd_dynamic_reconfig_f,
        .recalc_rate = clk_wzrd_recalc_ratef,
 };