* [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs
@ 2025-07-10 15:20 Brian Masney
2025-07-10 15:20 ` [PATCH 01/15] rtc: ds1307: fix incorrect maximum clock rate handling Brian Masney
` (15 more replies)
0 siblings, 16 replies; 17+ messages in thread
From: Brian Masney @ 2025-07-10 15:20 UTC (permalink / raw)
To: Alexandre Belloni, Akinobu Mita, Michael Turquette,
Heiko Stuebner, Andrew Morton, Avi Fishman, Tomer Maimon,
Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair, Mia Lin,
Michael McCormick, Heiko Schocher, Parthiban Nallathambi,
Antoniu Miclaus, Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-rtc, linux-kernel, openbmc, Brian Masney
The round_rate() clk ops is deprecated in the clk framework in favor
of the determine_rate() clk ops, so let's go ahead and convert the
drivers in the rtc subsystem using the Coccinelle semantic patch
posted below. I did a few minor cosmetic cleanups of the code in a
few cases.
I also noticed that in some of the drivers that if round_rate() is
called with a requested rate higher than the highest supported rate,
then the clock is disabled. According to the clk API, round_rate()
should instead return the highest supported rate. This series also
updates the functions to return the maximum supported rate.
Coccinelle semantic patch:
virtual patch
// Look up the current name of the round_rate function
@ has_round_rate @
identifier round_rate_name =~ ".*_round_rate";
identifier hw_param, rate_param, parent_rate_param;
@@
long round_rate_name(struct clk_hw *hw_param, unsigned long rate_param,
unsigned long *parent_rate_param)
{
...
}
// Rename the route_rate function name to determine_rate()
@ script:python generate_name depends on has_round_rate @
round_rate_name << has_round_rate.round_rate_name;
new_name;
@@
coccinelle.new_name = round_rate_name.replace("_round_rate", "_determine_rate")
// Change rate to req->rate; also change occurrences of 'return XXX'.
@ chg_rate depends on generate_name @
identifier has_round_rate.round_rate_name;
identifier has_round_rate.hw_param;
identifier has_round_rate.rate_param;
identifier has_round_rate.parent_rate_param;
identifier ERR =~ "E.*";
expression E;
@@
long round_rate_name(struct clk_hw *hw_param, unsigned long rate_param,
unsigned long *parent_rate_param)
{
<...
(
-return -ERR;
+return -ERR;
|
- return rate_param;
+ return 0;
|
- return E;
+ req->rate = E;
+
+ return 0;
|
- rate_param
+ req->rate
)
...>
}
// Coccinelle only transforms the first occurrence of the rate parameter
// Run a second time. FIXME: Is there a better way to do this?
@ chg_rate2 depends on generate_name @
identifier has_round_rate.round_rate_name;
identifier has_round_rate.hw_param;
identifier has_round_rate.rate_param;
identifier has_round_rate.parent_rate_param;
@@
long round_rate_name(struct clk_hw *hw_param, unsigned long rate_param,
unsigned long *parent_rate_param)
{
<...
- rate_param
+ req->rate
...>
}
// Change parent_rate to req->best_parent_rate
@ chg_parent_rate depends on generate_name @
identifier has_round_rate.round_rate_name;
identifier has_round_rate.hw_param;
identifier has_round_rate.rate_param;
identifier has_round_rate.parent_rate_param;
@@
long round_rate_name(struct clk_hw *hw_param, unsigned long rate_param,
unsigned long *parent_rate_param)
{
<...
(
- *parent_rate_param
+ req->best_parent_rate
|
- parent_rate_param
+ &req->best_parent_rate
)
...>
}
// Convert the function definition from round_rate() to determine_rate()
@ func_definition depends on chg_rate @
identifier has_round_rate.round_rate_name;
identifier has_round_rate.hw_param;
identifier has_round_rate.rate_param;
identifier has_round_rate.parent_rate_param;
identifier generate_name.new_name;
@@
- long round_rate_name(struct clk_hw *hw_param, unsigned long rate_param,
- unsigned long *parent_rate_param)
+ int new_name(struct clk_hw *hw, struct clk_rate_request *req)
{
...
}
// Update the ops from round_rate() to determine_rate()
@ ops depends on func_definition @
identifier has_round_rate.round_rate_name;
identifier generate_name.new_name;
@@
{
...,
- .round_rate = round_rate_name,
+ .determine_rate = new_name,
...,
}
Note that I used coccinelle 1.2 instead of 1.3 since the newer version
adds unnecessary braces as described in this post.
https://lore.kernel.org/cocci/67642477-5f3e-4b2a-914d-579a54f48cbd@intel.com/
Signed-off-by: Brian Masney <bmasney@redhat.com>
---
Brian Masney (15):
rtc: ds1307: fix incorrect maximum clock rate handling
rtc: hym8563: fix incorrect maximum clock rate handling
rtc: nct3018y: fix incorrect maximum clock rate handling
rtc: pcf85063: fix incorrect maximum clock rate handling
rtc: pcf8563: fix incorrect maximum clock rate handling
rtc: rv3028: fix incorrect maximum clock rate handling
rtc: ds1307: convert from round_rate() to determine_rate()
rtc: hym8563: convert from round_rate() to determine_rate()
rtc: m41t80: convert from round_rate() to determine_rate()
rtc: max31335: convert from round_rate() to determine_rate()
rtc: nct3018y: convert from round_rate() to determine_rate()
rtc: pcf85063: convert from round_rate() to determine_rate()
rtc: pcf8563: convert from round_rate() to determine_rate()
rtc: rv3028: convert from round_rate() to determine_rate()
rtc: rv3032: convert from round_rate() to determine_rate()
drivers/rtc/rtc-ds1307.c | 15 ++++++++++-----
drivers/rtc/rtc-hym8563.c | 15 ++++++++++-----
drivers/rtc/rtc-m41t80.c | 21 +++++++++++----------
drivers/rtc/rtc-max31335.c | 12 +++++++-----
drivers/rtc/rtc-nct3018y.c | 15 ++++++++++-----
drivers/rtc/rtc-pcf85063.c | 15 ++++++++++-----
drivers/rtc/rtc-pcf8563.c | 15 ++++++++++-----
drivers/rtc/rtc-rv3028.c | 15 ++++++++++-----
drivers/rtc/rtc-rv3032.c | 21 +++++++++++++--------
9 files changed, 91 insertions(+), 53 deletions(-)
---
base-commit: b551c4e2a98a177a06148cf16505643cd2108386
change-id: 20250710-rtc-clk-round-rate-1093066d1a5c
Best regards,
--
Brian Masney <bmasney@redhat.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 01/15] rtc: ds1307: fix incorrect maximum clock rate handling
2025-07-10 15:20 [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Brian Masney
@ 2025-07-10 15:20 ` Brian Masney
2025-07-10 15:20 ` [PATCH 02/15] rtc: hym8563: " Brian Masney
` (14 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Brian Masney @ 2025-07-10 15:20 UTC (permalink / raw)
To: Alexandre Belloni, Akinobu Mita, Michael Turquette,
Heiko Stuebner, Andrew Morton, Avi Fishman, Tomer Maimon,
Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair, Mia Lin,
Michael McCormick, Heiko Schocher, Parthiban Nallathambi,
Antoniu Miclaus, Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-rtc, linux-kernel, openbmc, Brian Masney
When ds3231_clk_sqw_round_rate() is called with a requested rate higher
than the highest supported rate, it currently returns 0, which disables
the clock. According to the clk API, round_rate() should instead return
the highest supported rate. Update the function to return the maximum
supported rate in this case.
Fixes: 6c6ff145b3346 ("rtc: ds1307: add clock provider support for DS3231")
Signed-off-by: Brian Masney <bmasney@redhat.com>
---
drivers/rtc/rtc-ds1307.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 5efbe69bf5ca8cbc2a325cf2797afcd14f3760bf..c8a666de9cbe9163ab7e112b01b99d97c94970d3 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -1466,7 +1466,7 @@ static long ds3231_clk_sqw_round_rate(struct clk_hw *hw, unsigned long rate,
return ds3231_clk_sqw_rates[i];
}
- return 0;
+ return ds3231_clk_sqw_rates[ARRAY_SIZE(ds3231_clk_sqw_rates) - 1];
}
static int ds3231_clk_sqw_set_rate(struct clk_hw *hw, unsigned long rate,
--
2.50.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 02/15] rtc: hym8563: fix incorrect maximum clock rate handling
2025-07-10 15:20 [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Brian Masney
2025-07-10 15:20 ` [PATCH 01/15] rtc: ds1307: fix incorrect maximum clock rate handling Brian Masney
@ 2025-07-10 15:20 ` Brian Masney
2025-07-10 15:20 ` [PATCH 03/15] rtc: nct3018y: " Brian Masney
` (13 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Brian Masney @ 2025-07-10 15:20 UTC (permalink / raw)
To: Alexandre Belloni, Akinobu Mita, Michael Turquette,
Heiko Stuebner, Andrew Morton, Avi Fishman, Tomer Maimon,
Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair, Mia Lin,
Michael McCormick, Heiko Schocher, Parthiban Nallathambi,
Antoniu Miclaus, Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-rtc, linux-kernel, openbmc, Brian Masney
When hym8563_clkout_round_rate() is called with a requested rate higher
than the highest supported rate, it currently returns 0, which disables
the clock. According to the clk API, round_rate() should instead return
the highest supported rate. Update the function to return the maximum
supported rate in this case.
Fixes: dcaf038493525 ("rtc: add hym8563 rtc-driver")
Signed-off-by: Brian Masney <bmasney@redhat.com>
---
drivers/rtc/rtc-hym8563.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-hym8563.c b/drivers/rtc/rtc-hym8563.c
index 63f11ea3589d6439ac0ee7f6ee4ab70e2a52bff4..759dc2ad6e3b2ad57072b35a2642ec5bb78cd98c 100644
--- a/drivers/rtc/rtc-hym8563.c
+++ b/drivers/rtc/rtc-hym8563.c
@@ -294,7 +294,7 @@ static long hym8563_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
if (clkout_rates[i] <= rate)
return clkout_rates[i];
- return 0;
+ return clkout_rates[0];
}
static int hym8563_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
--
2.50.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 03/15] rtc: nct3018y: fix incorrect maximum clock rate handling
2025-07-10 15:20 [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Brian Masney
2025-07-10 15:20 ` [PATCH 01/15] rtc: ds1307: fix incorrect maximum clock rate handling Brian Masney
2025-07-10 15:20 ` [PATCH 02/15] rtc: hym8563: " Brian Masney
@ 2025-07-10 15:20 ` Brian Masney
2025-07-10 15:20 ` [PATCH 04/15] rtc: pcf85063: " Brian Masney
` (12 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Brian Masney @ 2025-07-10 15:20 UTC (permalink / raw)
To: Alexandre Belloni, Akinobu Mita, Michael Turquette,
Heiko Stuebner, Andrew Morton, Avi Fishman, Tomer Maimon,
Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair, Mia Lin,
Michael McCormick, Heiko Schocher, Parthiban Nallathambi,
Antoniu Miclaus, Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-rtc, linux-kernel, openbmc, Brian Masney
When nct3018y_clkout_round_rate() is called with a requested rate higher
than the highest supported rate, it currently returns 0, which disables
the clock. According to the clk API, round_rate() should instead return
the highest supported rate. Update the function to return the maximum
supported rate in this case.
Fixes: 5adbaed16cc63 ("rtc: Add NCT3018Y real time clock driver")
Signed-off-by: Brian Masney <bmasney@redhat.com>
---
drivers/rtc/rtc-nct3018y.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-nct3018y.c b/drivers/rtc/rtc-nct3018y.c
index 76c5f464b2daeb59fa8367bff3ad261ed75dd937..cea05fca0bccddc6384c462cf1ebdc59b377a24d 100644
--- a/drivers/rtc/rtc-nct3018y.c
+++ b/drivers/rtc/rtc-nct3018y.c
@@ -376,7 +376,7 @@ static long nct3018y_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
if (clkout_rates[i] <= rate)
return clkout_rates[i];
- return 0;
+ return clkout_rates[0];
}
static int nct3018y_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
--
2.50.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 04/15] rtc: pcf85063: fix incorrect maximum clock rate handling
2025-07-10 15:20 [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Brian Masney
` (2 preceding siblings ...)
2025-07-10 15:20 ` [PATCH 03/15] rtc: nct3018y: " Brian Masney
@ 2025-07-10 15:20 ` Brian Masney
2025-07-10 15:20 ` [PATCH 05/15] rtc: pcf8563: " Brian Masney
` (11 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Brian Masney @ 2025-07-10 15:20 UTC (permalink / raw)
To: Alexandre Belloni, Akinobu Mita, Michael Turquette,
Heiko Stuebner, Andrew Morton, Avi Fishman, Tomer Maimon,
Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair, Mia Lin,
Michael McCormick, Heiko Schocher, Parthiban Nallathambi,
Antoniu Miclaus, Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-rtc, linux-kernel, openbmc, Brian Masney
When pcf85063_clkout_round_rate() is called with a requested rate higher
than the highest supported rate, it currently returns 0, which disables
the clock. According to the clk API, round_rate() should instead return
the highest supported rate. Update the function to return the maximum
supported rate in this case.
Fixes: 8c229ab6048b7 ("rtc: pcf85063: Add pcf85063 clkout control to common clock framework")
Signed-off-by: Brian Masney <bmasney@redhat.com>
---
drivers/rtc/rtc-pcf85063.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
index 4fa5c4ecdd5a340e6048b0d7d1d9590cff41e8fb..b26c9bfad5d9296ca8d2be3b5ecb04c19ac97191 100644
--- a/drivers/rtc/rtc-pcf85063.c
+++ b/drivers/rtc/rtc-pcf85063.c
@@ -410,7 +410,7 @@ static long pcf85063_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
if (clkout_rates[i] <= rate)
return clkout_rates[i];
- return 0;
+ return clkout_rates[0];
}
static int pcf85063_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
--
2.50.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 05/15] rtc: pcf8563: fix incorrect maximum clock rate handling
2025-07-10 15:20 [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Brian Masney
` (3 preceding siblings ...)
2025-07-10 15:20 ` [PATCH 04/15] rtc: pcf85063: " Brian Masney
@ 2025-07-10 15:20 ` Brian Masney
2025-07-10 15:20 ` [PATCH 06/15] rtc: rv3028: " Brian Masney
` (10 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Brian Masney @ 2025-07-10 15:20 UTC (permalink / raw)
To: Alexandre Belloni, Akinobu Mita, Michael Turquette,
Heiko Stuebner, Andrew Morton, Avi Fishman, Tomer Maimon,
Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair, Mia Lin,
Michael McCormick, Heiko Schocher, Parthiban Nallathambi,
Antoniu Miclaus, Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-rtc, linux-kernel, openbmc, Brian Masney
When pcf8563_clkout_round_rate() is called with a requested rate higher
than the highest supported rate, it currently returns 0, which disables
the clock. According to the clk API, round_rate() should instead return
the highest supported rate. Update the function to return the maximum
supported rate in this case.
Fixes: a39a6405d5f94 ("rtc: pcf8563: add CLKOUT to common clock framework")
Signed-off-by: Brian Masney <bmasney@redhat.com>
---
drivers/rtc/rtc-pcf8563.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index b2611697fa5e3adc61f687e39385d10736dec677..a2a2067b28a127bafec66328cd75f50aa4277986 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -339,7 +339,7 @@ static long pcf8563_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
if (clkout_rates[i] <= rate)
return clkout_rates[i];
- return 0;
+ return clkout_rates[0];
}
static int pcf8563_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
--
2.50.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 06/15] rtc: rv3028: fix incorrect maximum clock rate handling
2025-07-10 15:20 [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Brian Masney
` (4 preceding siblings ...)
2025-07-10 15:20 ` [PATCH 05/15] rtc: pcf8563: " Brian Masney
@ 2025-07-10 15:20 ` Brian Masney
2025-07-10 15:20 ` [PATCH 07/15] rtc: ds1307: convert from round_rate() to determine_rate() Brian Masney
` (9 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Brian Masney @ 2025-07-10 15:20 UTC (permalink / raw)
To: Alexandre Belloni, Akinobu Mita, Michael Turquette,
Heiko Stuebner, Andrew Morton, Avi Fishman, Tomer Maimon,
Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair, Mia Lin,
Michael McCormick, Heiko Schocher, Parthiban Nallathambi,
Antoniu Miclaus, Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-rtc, linux-kernel, openbmc, Brian Masney
When rv3028_clkout_round_rate() is called with a requested rate higher
than the highest supported rate, it currently returns 0, which disables
the clock. According to the clk API, round_rate() should instead return
the highest supported rate. Update the function to return the maximum
supported rate in this case.
Fixes: f583c341a515f ("rtc: rv3028: add clkout support")
Signed-off-by: Brian Masney <bmasney@redhat.com>
---
drivers/rtc/rtc-rv3028.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-rv3028.c b/drivers/rtc/rtc-rv3028.c
index 868d1b1eb0f42e8cdf2895033c24f0d2690587ca..278841c2e47edfefd339f04bf5193f6970ba0c65 100644
--- a/drivers/rtc/rtc-rv3028.c
+++ b/drivers/rtc/rtc-rv3028.c
@@ -740,7 +740,7 @@ static long rv3028_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
if (clkout_rates[i] <= rate)
return clkout_rates[i];
- return 0;
+ return clkout_rates[0];
}
static int rv3028_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
--
2.50.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 07/15] rtc: ds1307: convert from round_rate() to determine_rate()
2025-07-10 15:20 [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Brian Masney
` (5 preceding siblings ...)
2025-07-10 15:20 ` [PATCH 06/15] rtc: rv3028: " Brian Masney
@ 2025-07-10 15:20 ` Brian Masney
2025-07-10 15:20 ` [PATCH 08/15] rtc: hym8563: " Brian Masney
` (8 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Brian Masney @ 2025-07-10 15:20 UTC (permalink / raw)
To: Alexandre Belloni, Akinobu Mita, Michael Turquette,
Heiko Stuebner, Andrew Morton, Avi Fishman, Tomer Maimon,
Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair, Mia Lin,
Michael McCormick, Heiko Schocher, Parthiban Nallathambi,
Antoniu Miclaus, Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-rtc, linux-kernel, openbmc, Brian Masney
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/rtc/rtc-ds1307.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index c8a666de9cbe9163ab7e112b01b99d97c94970d3..d9d0e482b5ea9300ec9d7e77e4c3ec531b9df867 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -1456,17 +1456,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,
@@ -1525,7 +1530,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,
};
--
2.50.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 08/15] rtc: hym8563: convert from round_rate() to determine_rate()
2025-07-10 15:20 [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Brian Masney
` (6 preceding siblings ...)
2025-07-10 15:20 ` [PATCH 07/15] rtc: ds1307: convert from round_rate() to determine_rate() Brian Masney
@ 2025-07-10 15:20 ` Brian Masney
2025-07-10 15:20 ` [PATCH 09/15] rtc: m41t80: " Brian Masney
` (7 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Brian Masney @ 2025-07-10 15:20 UTC (permalink / raw)
To: Alexandre Belloni, Akinobu Mita, Michael Turquette,
Heiko Stuebner, Andrew Morton, Avi Fishman, Tomer Maimon,
Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair, Mia Lin,
Michael McCormick, Heiko Schocher, Parthiban Nallathambi,
Antoniu Miclaus, Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-rtc, linux-kernel, openbmc, Brian Masney
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/rtc/rtc-hym8563.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/rtc/rtc-hym8563.c b/drivers/rtc/rtc-hym8563.c
index 759dc2ad6e3b2ad57072b35a2642ec5bb78cd98c..7a170c0f97109f9a2bc08946845cb8bb5a377bd7 100644
--- a/drivers/rtc/rtc-hym8563.c
+++ b/drivers/rtc/rtc-hym8563.c
@@ -285,16 +285,21 @@ static unsigned long hym8563_clkout_recalc_rate(struct clk_hw *hw,
return clkout_rates[ret];
}
-static long hym8563_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *prate)
+static int hym8563_clkout_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
int i;
for (i = 0; i < ARRAY_SIZE(clkout_rates); i++)
- if (clkout_rates[i] <= rate)
- return clkout_rates[i];
+ if (clkout_rates[i] <= req->rate) {
+ req->rate = clkout_rates[i];
- return clkout_rates[0];
+ return 0;
+ }
+
+ req->rate = clkout_rates[0];
+
+ return 0;
}
static int hym8563_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -363,7 +368,7 @@ static const struct clk_ops hym8563_clkout_ops = {
.unprepare = hym8563_clkout_unprepare,
.is_prepared = hym8563_clkout_is_prepared,
.recalc_rate = hym8563_clkout_recalc_rate,
- .round_rate = hym8563_clkout_round_rate,
+ .determine_rate = hym8563_clkout_determine_rate,
.set_rate = hym8563_clkout_set_rate,
};
--
2.50.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 09/15] rtc: m41t80: convert from round_rate() to determine_rate()
2025-07-10 15:20 [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Brian Masney
` (7 preceding siblings ...)
2025-07-10 15:20 ` [PATCH 08/15] rtc: hym8563: " Brian Masney
@ 2025-07-10 15:20 ` Brian Masney
2025-07-10 15:20 ` [PATCH 10/15] rtc: max31335: " Brian Masney
` (6 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Brian Masney @ 2025-07-10 15:20 UTC (permalink / raw)
To: Alexandre Belloni, Akinobu Mita, Michael Turquette,
Heiko Stuebner, Andrew Morton, Avi Fishman, Tomer Maimon,
Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair, Mia Lin,
Michael McCormick, Heiko Schocher, Parthiban Nallathambi,
Antoniu Miclaus, Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-rtc, linux-kernel, openbmc, Brian Masney
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/rtc/rtc-m41t80.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index c568639d2151702440d726030e9f08a0eb514da8..719afb9de9a831a4f335f505e3a0eae5293ad6c8 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -484,16 +484,17 @@ static unsigned long m41t80_sqw_recalc_rate(struct clk_hw *hw,
return sqw_to_m41t80_data(hw)->freq;
}
-static long m41t80_sqw_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *prate)
+static int m41t80_sqw_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
- if (rate >= M41T80_SQW_MAX_FREQ)
- return M41T80_SQW_MAX_FREQ;
- if (rate >= M41T80_SQW_MAX_FREQ / 4)
- return M41T80_SQW_MAX_FREQ / 4;
- if (!rate)
- return 0;
- return 1 << ilog2(rate);
+ if (req->rate >= M41T80_SQW_MAX_FREQ)
+ req->rate = M41T80_SQW_MAX_FREQ;
+ else if (req->rate >= M41T80_SQW_MAX_FREQ / 4)
+ req->rate = M41T80_SQW_MAX_FREQ / 4;
+ else if (req->rate)
+ req->rate = 1 << ilog2(req->rate);
+
+ return 0;
}
static int m41t80_sqw_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -564,7 +565,7 @@ static const struct clk_ops m41t80_sqw_ops = {
.unprepare = m41t80_sqw_unprepare,
.is_prepared = m41t80_sqw_is_prepared,
.recalc_rate = m41t80_sqw_recalc_rate,
- .round_rate = m41t80_sqw_round_rate,
+ .determine_rate = m41t80_sqw_determine_rate,
.set_rate = m41t80_sqw_set_rate,
};
--
2.50.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 10/15] rtc: max31335: convert from round_rate() to determine_rate()
2025-07-10 15:20 [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Brian Masney
` (8 preceding siblings ...)
2025-07-10 15:20 ` [PATCH 09/15] rtc: m41t80: " Brian Masney
@ 2025-07-10 15:20 ` Brian Masney
2025-07-10 15:20 ` [PATCH 11/15] rtc: nct3018y: " Brian Masney
` (5 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Brian Masney @ 2025-07-10 15:20 UTC (permalink / raw)
To: Alexandre Belloni, Akinobu Mita, Michael Turquette,
Heiko Stuebner, Andrew Morton, Avi Fishman, Tomer Maimon,
Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair, Mia Lin,
Michael McCormick, Heiko Schocher, Parthiban Nallathambi,
Antoniu Miclaus, Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-rtc, linux-kernel, openbmc, Brian Masney
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/rtc/rtc-max31335.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/rtc/rtc-max31335.c b/drivers/rtc/rtc-max31335.c
index a7bb37aaab9e6e315db70bc6bc0dbaa553fdecfa..dfb5bad3a3691d0968bac78cbc9d54a2ea7662ba 100644
--- a/drivers/rtc/rtc-max31335.c
+++ b/drivers/rtc/rtc-max31335.c
@@ -497,15 +497,17 @@ static unsigned long max31335_clkout_recalc_rate(struct clk_hw *hw,
return max31335_clkout_freq[reg & freq_mask];
}
-static long max31335_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *prate)
+static int max31335_clkout_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
int index;
- index = find_closest(rate, max31335_clkout_freq,
+ index = find_closest(req->rate, max31335_clkout_freq,
ARRAY_SIZE(max31335_clkout_freq));
- return max31335_clkout_freq[index];
+ req->rate = max31335_clkout_freq[index];
+
+ return 0;
}
static int max31335_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -554,7 +556,7 @@ static int max31335_clkout_is_enabled(struct clk_hw *hw)
static const struct clk_ops max31335_clkout_ops = {
.recalc_rate = max31335_clkout_recalc_rate,
- .round_rate = max31335_clkout_round_rate,
+ .determine_rate = max31335_clkout_determine_rate,
.set_rate = max31335_clkout_set_rate,
.enable = max31335_clkout_enable,
.disable = max31335_clkout_disable,
--
2.50.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 11/15] rtc: nct3018y: convert from round_rate() to determine_rate()
2025-07-10 15:20 [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Brian Masney
` (9 preceding siblings ...)
2025-07-10 15:20 ` [PATCH 10/15] rtc: max31335: " Brian Masney
@ 2025-07-10 15:20 ` Brian Masney
2025-07-10 15:20 ` [PATCH 12/15] rtc: pcf85063: " Brian Masney
` (4 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Brian Masney @ 2025-07-10 15:20 UTC (permalink / raw)
To: Alexandre Belloni, Akinobu Mita, Michael Turquette,
Heiko Stuebner, Andrew Morton, Avi Fishman, Tomer Maimon,
Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair, Mia Lin,
Michael McCormick, Heiko Schocher, Parthiban Nallathambi,
Antoniu Miclaus, Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-rtc, linux-kernel, openbmc, Brian Masney
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/rtc/rtc-nct3018y.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/rtc/rtc-nct3018y.c b/drivers/rtc/rtc-nct3018y.c
index cea05fca0bccddc6384c462cf1ebdc59b377a24d..cd4b1db902e9f68781787236bec56c2cae8436ab 100644
--- a/drivers/rtc/rtc-nct3018y.c
+++ b/drivers/rtc/rtc-nct3018y.c
@@ -367,16 +367,21 @@ static unsigned long nct3018y_clkout_recalc_rate(struct clk_hw *hw,
return clkout_rates[flags];
}
-static long nct3018y_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *prate)
+static int nct3018y_clkout_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
int i;
for (i = 0; i < ARRAY_SIZE(clkout_rates); i++)
- if (clkout_rates[i] <= rate)
- return clkout_rates[i];
+ if (clkout_rates[i] <= req->rate) {
+ req->rate = clkout_rates[i];
- return clkout_rates[0];
+ return 0;
+ }
+
+ req->rate = clkout_rates[0];
+
+ return 0;
}
static int nct3018y_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -446,7 +451,7 @@ static const struct clk_ops nct3018y_clkout_ops = {
.unprepare = nct3018y_clkout_unprepare,
.is_prepared = nct3018y_clkout_is_prepared,
.recalc_rate = nct3018y_clkout_recalc_rate,
- .round_rate = nct3018y_clkout_round_rate,
+ .determine_rate = nct3018y_clkout_determine_rate,
.set_rate = nct3018y_clkout_set_rate,
};
--
2.50.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 12/15] rtc: pcf85063: convert from round_rate() to determine_rate()
2025-07-10 15:20 [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Brian Masney
` (10 preceding siblings ...)
2025-07-10 15:20 ` [PATCH 11/15] rtc: nct3018y: " Brian Masney
@ 2025-07-10 15:20 ` Brian Masney
2025-07-10 15:20 ` [PATCH 13/15] rtc: pcf8563: " Brian Masney
` (3 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Brian Masney @ 2025-07-10 15:20 UTC (permalink / raw)
To: Alexandre Belloni, Akinobu Mita, Michael Turquette,
Heiko Stuebner, Andrew Morton, Avi Fishman, Tomer Maimon,
Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair, Mia Lin,
Michael McCormick, Heiko Schocher, Parthiban Nallathambi,
Antoniu Miclaus, Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-rtc, linux-kernel, openbmc, Brian Masney
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/rtc/rtc-pcf85063.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
index b26c9bfad5d9296ca8d2be3b5ecb04c19ac97191..779fd627262bde8429ae48735ca591747f871025 100644
--- a/drivers/rtc/rtc-pcf85063.c
+++ b/drivers/rtc/rtc-pcf85063.c
@@ -401,16 +401,21 @@ static unsigned long pcf85063_clkout_recalc_rate(struct clk_hw *hw,
return clkout_rates[buf];
}
-static long pcf85063_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *prate)
+static int pcf85063_clkout_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
int i;
for (i = 0; i < ARRAY_SIZE(clkout_rates); i++)
- if (clkout_rates[i] <= rate)
- return clkout_rates[i];
+ if (clkout_rates[i] <= req->rate) {
+ req->rate = clkout_rates[i];
- return clkout_rates[0];
+ return 0;
+ }
+
+ req->rate = clkout_rates[0];
+
+ return 0;
}
static int pcf85063_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -482,7 +487,7 @@ static const struct clk_ops pcf85063_clkout_ops = {
.unprepare = pcf85063_clkout_unprepare,
.is_prepared = pcf85063_clkout_is_prepared,
.recalc_rate = pcf85063_clkout_recalc_rate,
- .round_rate = pcf85063_clkout_round_rate,
+ .determine_rate = pcf85063_clkout_determine_rate,
.set_rate = pcf85063_clkout_set_rate,
};
--
2.50.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 13/15] rtc: pcf8563: convert from round_rate() to determine_rate()
2025-07-10 15:20 [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Brian Masney
` (11 preceding siblings ...)
2025-07-10 15:20 ` [PATCH 12/15] rtc: pcf85063: " Brian Masney
@ 2025-07-10 15:20 ` Brian Masney
2025-07-10 15:20 ` [PATCH 14/15] rtc: rv3028: " Brian Masney
` (2 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Brian Masney @ 2025-07-10 15:20 UTC (permalink / raw)
To: Alexandre Belloni, Akinobu Mita, Michael Turquette,
Heiko Stuebner, Andrew Morton, Avi Fishman, Tomer Maimon,
Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair, Mia Lin,
Michael McCormick, Heiko Schocher, Parthiban Nallathambi,
Antoniu Miclaus, Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-rtc, linux-kernel, openbmc, Brian Masney
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/rtc/rtc-pcf8563.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index a2a2067b28a127bafec66328cd75f50aa4277986..4e61011fb7a9672ee356f6328a7691ca413a82bc 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -330,16 +330,21 @@ static unsigned long pcf8563_clkout_recalc_rate(struct clk_hw *hw,
return clkout_rates[buf];
}
-static long pcf8563_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *prate)
+static int pcf8563_clkout_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
int i;
for (i = 0; i < ARRAY_SIZE(clkout_rates); i++)
- if (clkout_rates[i] <= rate)
- return clkout_rates[i];
+ if (clkout_rates[i] <= req->rate) {
+ req->rate = clkout_rates[i];
- return clkout_rates[0];
+ return 0;
+ }
+
+ req->rate = clkout_rates[0];
+
+ return 0;
}
static int pcf8563_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -413,7 +418,7 @@ static const struct clk_ops pcf8563_clkout_ops = {
.unprepare = pcf8563_clkout_unprepare,
.is_prepared = pcf8563_clkout_is_prepared,
.recalc_rate = pcf8563_clkout_recalc_rate,
- .round_rate = pcf8563_clkout_round_rate,
+ .determine_rate = pcf8563_clkout_determine_rate,
.set_rate = pcf8563_clkout_set_rate,
};
--
2.50.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 14/15] rtc: rv3028: convert from round_rate() to determine_rate()
2025-07-10 15:20 [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Brian Masney
` (12 preceding siblings ...)
2025-07-10 15:20 ` [PATCH 13/15] rtc: pcf8563: " Brian Masney
@ 2025-07-10 15:20 ` Brian Masney
2025-07-10 15:20 ` [PATCH 15/15] rtc: rv3032: " Brian Masney
2025-08-03 1:01 ` [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Alexandre Belloni
15 siblings, 0 replies; 17+ messages in thread
From: Brian Masney @ 2025-07-10 15:20 UTC (permalink / raw)
To: Alexandre Belloni, Akinobu Mita, Michael Turquette,
Heiko Stuebner, Andrew Morton, Avi Fishman, Tomer Maimon,
Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair, Mia Lin,
Michael McCormick, Heiko Schocher, Parthiban Nallathambi,
Antoniu Miclaus, Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-rtc, linux-kernel, openbmc, Brian Masney
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/rtc/rtc-rv3028.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/rtc/rtc-rv3028.c b/drivers/rtc/rtc-rv3028.c
index 278841c2e47edfefd339f04bf5193f6970ba0c65..c2a531f0e125be7514fb3ad2b11fdb670fb47a16 100644
--- a/drivers/rtc/rtc-rv3028.c
+++ b/drivers/rtc/rtc-rv3028.c
@@ -731,16 +731,21 @@ static unsigned long rv3028_clkout_recalc_rate(struct clk_hw *hw,
return clkout_rates[clkout];
}
-static long rv3028_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *prate)
+static int rv3028_clkout_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
int i;
for (i = 0; i < ARRAY_SIZE(clkout_rates); i++)
- if (clkout_rates[i] <= rate)
- return clkout_rates[i];
+ if (clkout_rates[i] <= req->rate) {
+ req->rate = clkout_rates[i];
- return clkout_rates[0];
+ return 0;
+ }
+
+ req->rate = clkout_rates[0];
+
+ return 0;
}
static int rv3028_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -802,7 +807,7 @@ static const struct clk_ops rv3028_clkout_ops = {
.unprepare = rv3028_clkout_unprepare,
.is_prepared = rv3028_clkout_is_prepared,
.recalc_rate = rv3028_clkout_recalc_rate,
- .round_rate = rv3028_clkout_round_rate,
+ .determine_rate = rv3028_clkout_determine_rate,
.set_rate = rv3028_clkout_set_rate,
};
--
2.50.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 15/15] rtc: rv3032: convert from round_rate() to determine_rate()
2025-07-10 15:20 [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Brian Masney
` (13 preceding siblings ...)
2025-07-10 15:20 ` [PATCH 14/15] rtc: rv3028: " Brian Masney
@ 2025-07-10 15:20 ` Brian Masney
2025-08-03 1:01 ` [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Alexandre Belloni
15 siblings, 0 replies; 17+ messages in thread
From: Brian Masney @ 2025-07-10 15:20 UTC (permalink / raw)
To: Alexandre Belloni, Akinobu Mita, Michael Turquette,
Heiko Stuebner, Andrew Morton, Avi Fishman, Tomer Maimon,
Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair, Mia Lin,
Michael McCormick, Heiko Schocher, Parthiban Nallathambi,
Antoniu Miclaus, Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-rtc, linux-kernel, openbmc, Brian Masney
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/rtc/rtc-rv3032.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/rtc/rtc-rv3032.c b/drivers/rtc/rtc-rv3032.c
index 2c6a8918acba50e57ed923db0834c7c4620ef2cd..b8376bd1d905be63afbcbc688825c0caff74a3b5 100644
--- a/drivers/rtc/rtc-rv3032.c
+++ b/drivers/rtc/rtc-rv3032.c
@@ -646,19 +646,24 @@ static unsigned long rv3032_clkout_recalc_rate(struct clk_hw *hw,
return clkout_xtal_rates[FIELD_GET(RV3032_CLKOUT2_FD_MSK, clkout)];
}
-static long rv3032_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *prate)
+static int rv3032_clkout_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
int i, hfd;
- if (rate < RV3032_HFD_STEP)
+ if (req->rate < RV3032_HFD_STEP)
for (i = 0; i < ARRAY_SIZE(clkout_xtal_rates); i++)
- if (clkout_xtal_rates[i] <= rate)
- return clkout_xtal_rates[i];
+ if (clkout_xtal_rates[i] <= req->rate) {
+ req->rate = clkout_xtal_rates[i];
- hfd = DIV_ROUND_CLOSEST(rate, RV3032_HFD_STEP);
+ return 0;
+ }
+
+ hfd = DIV_ROUND_CLOSEST(req->rate, RV3032_HFD_STEP);
- return RV3032_HFD_STEP * clamp(hfd, 0, 8192);
+ req->rate = RV3032_HFD_STEP * clamp(hfd, 0, 8192);
+
+ return 0;
}
static int rv3032_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -738,7 +743,7 @@ static const struct clk_ops rv3032_clkout_ops = {
.unprepare = rv3032_clkout_unprepare,
.is_prepared = rv3032_clkout_is_prepared,
.recalc_rate = rv3032_clkout_recalc_rate,
- .round_rate = rv3032_clkout_round_rate,
+ .determine_rate = rv3032_clkout_determine_rate,
.set_rate = rv3032_clkout_set_rate,
};
--
2.50.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs
2025-07-10 15:20 [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Brian Masney
` (14 preceding siblings ...)
2025-07-10 15:20 ` [PATCH 15/15] rtc: rv3032: " Brian Masney
@ 2025-08-03 1:01 ` Alexandre Belloni
15 siblings, 0 replies; 17+ messages in thread
From: Alexandre Belloni @ 2025-08-03 1:01 UTC (permalink / raw)
To: Akinobu Mita, Michael Turquette, Heiko Stuebner, Andrew Morton,
Avi Fishman, Tomer Maimon, Tali Perry, Patrick Venture,
Nancy Yuen, Benjamin Fair, Mia Lin, Michael McCormick,
Heiko Schocher, Parthiban Nallathambi, Antoniu Miclaus,
Maxime Ripard, Stephen Boyd, Brian Masney
Cc: linux-clk, linux-rtc, linux-kernel, openbmc
On Thu, 10 Jul 2025 11:20:20 -0400, Brian Masney wrote:
> The round_rate() clk ops is deprecated in the clk framework in favor
> of the determine_rate() clk ops, so let's go ahead and convert the
> drivers in the rtc subsystem using the Coccinelle semantic patch
> posted below. I did a few minor cosmetic cleanups of the code in a
> few cases.
>
> I also noticed that in some of the drivers that if round_rate() is
> called with a requested rate higher than the highest supported rate,
> then the clock is disabled. According to the clk API, round_rate()
> should instead return the highest supported rate. This series also
> updates the functions to return the maximum supported rate.
>
> [...]
Applied, thanks!
[01/15] rtc: ds1307: fix incorrect maximum clock rate handling
https://git.kernel.org/abelloni/c/cf6eb547a24a
[02/15] rtc: hym8563: fix incorrect maximum clock rate handling
https://git.kernel.org/abelloni/c/d0a518eb0a69
[03/15] rtc: nct3018y: fix incorrect maximum clock rate handling
https://git.kernel.org/abelloni/c/437c59e4b222
[04/15] rtc: pcf85063: fix incorrect maximum clock rate handling
https://git.kernel.org/abelloni/c/186ae1869880
[05/15] rtc: pcf8563: fix incorrect maximum clock rate handling
https://git.kernel.org/abelloni/c/906726a5efee
[06/15] rtc: rv3028: fix incorrect maximum clock rate handling
https://git.kernel.org/abelloni/c/b574acb3cf75
[07/15] rtc: ds1307: convert from round_rate() to determine_rate()
https://git.kernel.org/abelloni/c/31b5fea399d5
[08/15] rtc: hym8563: convert from round_rate() to determine_rate()
https://git.kernel.org/abelloni/c/394a4b920a72
[09/15] rtc: m41t80: convert from round_rate() to determine_rate()
https://git.kernel.org/abelloni/c/e05d81b75efd
[10/15] rtc: max31335: convert from round_rate() to determine_rate()
https://git.kernel.org/abelloni/c/9e0dfc7962b3
[11/15] rtc: nct3018y: convert from round_rate() to determine_rate()
https://git.kernel.org/abelloni/c/1251d043f764
[12/15] rtc: pcf85063: convert from round_rate() to determine_rate()
https://git.kernel.org/abelloni/c/ad853657d791
[13/15] rtc: pcf8563: convert from round_rate() to determine_rate()
https://git.kernel.org/abelloni/c/e6f1af719ea1
[14/15] rtc: rv3028: convert from round_rate() to determine_rate()
https://git.kernel.org/abelloni/c/c4253b091441
[15/15] rtc: rv3032: convert from round_rate() to determine_rate()
https://git.kernel.org/abelloni/c/35d6aae85b36
Best regards,
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2025-08-03 1:01 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-10 15:20 [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Brian Masney
2025-07-10 15:20 ` [PATCH 01/15] rtc: ds1307: fix incorrect maximum clock rate handling Brian Masney
2025-07-10 15:20 ` [PATCH 02/15] rtc: hym8563: " Brian Masney
2025-07-10 15:20 ` [PATCH 03/15] rtc: nct3018y: " Brian Masney
2025-07-10 15:20 ` [PATCH 04/15] rtc: pcf85063: " Brian Masney
2025-07-10 15:20 ` [PATCH 05/15] rtc: pcf8563: " Brian Masney
2025-07-10 15:20 ` [PATCH 06/15] rtc: rv3028: " Brian Masney
2025-07-10 15:20 ` [PATCH 07/15] rtc: ds1307: convert from round_rate() to determine_rate() Brian Masney
2025-07-10 15:20 ` [PATCH 08/15] rtc: hym8563: " Brian Masney
2025-07-10 15:20 ` [PATCH 09/15] rtc: m41t80: " Brian Masney
2025-07-10 15:20 ` [PATCH 10/15] rtc: max31335: " Brian Masney
2025-07-10 15:20 ` [PATCH 11/15] rtc: nct3018y: " Brian Masney
2025-07-10 15:20 ` [PATCH 12/15] rtc: pcf85063: " Brian Masney
2025-07-10 15:20 ` [PATCH 13/15] rtc: pcf8563: " Brian Masney
2025-07-10 15:20 ` [PATCH 14/15] rtc: rv3028: " Brian Masney
2025-07-10 15:20 ` [PATCH 15/15] rtc: rv3032: " Brian Masney
2025-08-03 1:01 ` [PATCH 00/15] rtc: convert from clk round_rate() to determine_rate() and fix a few bugs Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).