]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rtc: ds1307: convert from round_rate() to determine_rate()
authorBrian Masney <bmasney@redhat.com>
Thu, 10 Jul 2025 15:20:27 +0000 (11:20 -0400)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Sun, 3 Aug 2025 00:57:05 +0000 (02:57 +0200)
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>
Link: https://lore.kernel.org/r/20250710-rtc-clk-round-rate-v1-7-33140bb2278e@redhat.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-ds1307.c

index 1960d1bd851cb09e13db3dda53628e2136f8773b..7205c59ff7294ef7779d445369f16f7db824e3cb 100644 (file)
@@ -1467,17 +1467,22 @@ static unsigned long ds3231_clk_sqw_recalc_rate(struct clk_hw *hw,
        return ds3231_clk_sqw_rates[rate_sel];
 }
 
-static long ds3231_clk_sqw_round_rate(struct clk_hw *hw, unsigned long rate,
-                                     unsigned long *prate)
+static int ds3231_clk_sqw_determine_rate(struct clk_hw *hw,
+                                        struct clk_rate_request *req)
 {
        int i;
 
        for (i = ARRAY_SIZE(ds3231_clk_sqw_rates) - 1; i >= 0; i--) {
-               if (ds3231_clk_sqw_rates[i] <= rate)
-                       return ds3231_clk_sqw_rates[i];
+               if (ds3231_clk_sqw_rates[i] <= req->rate) {
+                       req->rate = ds3231_clk_sqw_rates[i];
+
+                       return 0;
+               }
        }
 
-       return ds3231_clk_sqw_rates[ARRAY_SIZE(ds3231_clk_sqw_rates) - 1];
+       req->rate = ds3231_clk_sqw_rates[ARRAY_SIZE(ds3231_clk_sqw_rates) - 1];
+
+       return 0;
 }
 
 static int ds3231_clk_sqw_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -1536,7 +1541,7 @@ static const struct clk_ops ds3231_clk_sqw_ops = {
        .unprepare = ds3231_clk_sqw_unprepare,
        .is_prepared = ds3231_clk_sqw_is_prepared,
        .recalc_rate = ds3231_clk_sqw_recalc_rate,
-       .round_rate = ds3231_clk_sqw_round_rate,
+       .determine_rate = ds3231_clk_sqw_determine_rate,
        .set_rate = ds3231_clk_sqw_set_rate,
 };