* [PATCH 0/3] ARM: convert from clk round_rate() to determine_rate()
@ 2025-07-10 23:42 Brian Masney
2025-07-10 23:42 ` [PATCH 1/3] ARM: OMAP1: clock: convert from " Brian Masney
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Brian Masney @ 2025-07-10 23:42 UTC (permalink / raw)
To: Paul Walmsley, Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren,
Russell King, Andreas Kemnade, Kevin Hilman, Roger Quadros,
Linus Walleij, Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi,
Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-omap, linux-arm-kernel, linux-kernel,
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 arm32 subsystem using the Coccinelle semantic patch
posted below. I did a few minor cosmetic cleanups of the code in a
few cases.
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 (3):
ARM: OMAP1: clock: convert from round_rate() to determine_rate()
ARM: OMAP2+: clock: convert from round_rate() to determine_rate()
ARM: versatile: clock: convert from round_rate() to determine_rate()
arch/arm/mach-omap1/clock.c | 19 +++++++++++++------
arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c | 12 +++++++-----
arch/arm/mach-versatile/spc.c | 9 +++++----
3 files changed, 25 insertions(+), 15 deletions(-)
---
base-commit: b551c4e2a98a177a06148cf16505643cd2108386
change-id: 20250710-arm32-clk-round-rate-e52d845e682c
Best regards,
--
Brian Masney <bmasney@redhat.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] ARM: OMAP1: clock: convert from round_rate() to determine_rate()
2025-07-10 23:42 [PATCH 0/3] ARM: convert from clk round_rate() to determine_rate() Brian Masney
@ 2025-07-10 23:42 ` Brian Masney
2025-07-13 20:35 ` Janusz Krzysztofik
2025-07-10 23:42 ` [PATCH 2/3] ARM: OMAP2+: " Brian Masney
2025-07-10 23:42 ` [PATCH 3/3] ARM: versatile: " Brian Masney
2 siblings, 1 reply; 7+ messages in thread
From: Brian Masney @ 2025-07-10 23:42 UTC (permalink / raw)
To: Paul Walmsley, Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren,
Russell King, Andreas Kemnade, Kevin Hilman, Roger Quadros,
Linus Walleij, Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi,
Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-omap, linux-arm-kernel, linux-kernel,
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>
---
arch/arm/mach-omap1/clock.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
index 83381e23fab983522ca01b8feffb861b02fee730..afc6404f62d39c4ddbac6f1ee04d889be6c47186 100644
--- a/arch/arm/mach-omap1/clock.c
+++ b/arch/arm/mach-omap1/clock.c
@@ -705,14 +705,21 @@ static unsigned long omap1_clk_recalc_rate(struct clk_hw *hw, unsigned long p_ra
return clk->rate;
}
-static long omap1_clk_round_rate(struct clk_hw *hw, unsigned long rate, unsigned long *p_rate)
+static int omap1_clk_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
struct omap1_clk *clk = to_omap1_clk(hw);
- if (clk->round_rate != NULL)
- return clk->round_rate(clk, rate, p_rate);
+ if (clk->round_rate != NULL) {
+ req->rate = clk->round_rate(clk, req->rate,
+ &req->best_parent_rate);
- return omap1_clk_recalc_rate(hw, *p_rate);
+ return 0;
+ }
+
+ req->rate = omap1_clk_recalc_rate(hw, req->best_parent_rate);
+
+ return 0;
}
static int omap1_clk_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long p_rate)
@@ -771,7 +778,7 @@ const struct clk_ops omap1_clk_gate_ops = {
const struct clk_ops omap1_clk_rate_ops = {
.recalc_rate = omap1_clk_recalc_rate,
- .round_rate = omap1_clk_round_rate,
+ .determine_rate = omap1_clk_determine_rate,
.set_rate = omap1_clk_set_rate,
.init = omap1_clk_init_op,
};
@@ -784,7 +791,7 @@ const struct clk_ops omap1_clk_full_ops = {
.disable_unused = omap1_clk_disable_unused,
#endif
.recalc_rate = omap1_clk_recalc_rate,
- .round_rate = omap1_clk_round_rate,
+ .determine_rate = omap1_clk_determine_rate,
.set_rate = omap1_clk_set_rate,
.init = omap1_clk_init_op,
};
--
2.50.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] ARM: OMAP2+: clock: convert from round_rate() to determine_rate()
2025-07-10 23:42 [PATCH 0/3] ARM: convert from clk round_rate() to determine_rate() Brian Masney
2025-07-10 23:42 ` [PATCH 1/3] ARM: OMAP1: clock: convert from " Brian Masney
@ 2025-07-10 23:42 ` Brian Masney
2025-07-10 23:42 ` [PATCH 3/3] ARM: versatile: " Brian Masney
2 siblings, 0 replies; 7+ messages in thread
From: Brian Masney @ 2025-07-10 23:42 UTC (permalink / raw)
To: Paul Walmsley, Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren,
Russell King, Andreas Kemnade, Kevin Hilman, Roger Quadros,
Linus Walleij, Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi,
Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-omap, linux-arm-kernel, linux-kernel,
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.
The change to virt_prcm_set_ops had to be made manually.
Signed-off-by: Brian Masney <bmasney@redhat.com>
---
arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c b/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c
index 011076a5952f0bfb24eadd13b8991b41b8115bae..96c5cdc718c8b9449a4372e1bb83582eaa91440e 100644
--- a/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c
+++ b/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c
@@ -70,8 +70,8 @@ static unsigned long omap2_table_mpu_recalc(struct clk_hw *clk,
* Some might argue L3-DDR, others ARM, others IVA. This code is simple and
* just uses the ARM rates.
*/
-static long omap2_round_to_table_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *parent_rate)
+static int omap2_determine_rate_to_table(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
const struct prcm_config *ptr;
long highest_rate;
@@ -87,10 +87,12 @@ static long omap2_round_to_table_rate(struct clk_hw *hw, unsigned long rate,
highest_rate = ptr->mpu_speed;
/* Can check only after xtal frequency check */
- if (ptr->mpu_speed <= rate)
+ if (ptr->mpu_speed <= req->rate)
break;
}
- return highest_rate;
+ req->rate = highest_rate;
+
+ return 0;
}
/* Sets basic clocks based on the specified rate */
@@ -215,7 +217,7 @@ static void omap2xxx_clkt_vps_late_init(void)
static const struct clk_ops virt_prcm_set_ops = {
.recalc_rate = &omap2_table_mpu_recalc,
.set_rate = &omap2_select_table_rate,
- .round_rate = &omap2_round_to_table_rate,
+ .determine_rate = &omap2_determine_rate_to_table,
};
/**
--
2.50.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] ARM: versatile: clock: convert from round_rate() to determine_rate()
2025-07-10 23:42 [PATCH 0/3] ARM: convert from clk round_rate() to determine_rate() Brian Masney
2025-07-10 23:42 ` [PATCH 1/3] ARM: OMAP1: clock: convert from " Brian Masney
2025-07-10 23:42 ` [PATCH 2/3] ARM: OMAP2+: " Brian Masney
@ 2025-07-10 23:42 ` Brian Masney
2025-07-11 8:51 ` Sudeep Holla
2025-07-11 17:45 ` Linus Walleij
2 siblings, 2 replies; 7+ messages in thread
From: Brian Masney @ 2025-07-10 23:42 UTC (permalink / raw)
To: Paul Walmsley, Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren,
Russell King, Andreas Kemnade, Kevin Hilman, Roger Quadros,
Linus Walleij, Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi,
Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-omap, linux-arm-kernel, linux-kernel,
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>
---
arch/arm/mach-versatile/spc.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-versatile/spc.c b/arch/arm/mach-versatile/spc.c
index 790092734cf6155daa63c44a1e5af00ecef30737..812db32448fcd415fa1a60f8bb971661369151e1 100644
--- a/arch/arm/mach-versatile/spc.c
+++ b/arch/arm/mach-versatile/spc.c
@@ -497,12 +497,13 @@ static unsigned long spc_recalc_rate(struct clk_hw *hw,
return freq * 1000;
}
-static long spc_round_rate(struct clk_hw *hw, unsigned long drate,
- unsigned long *parent_rate)
+static int spc_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
{
struct clk_spc *spc = to_clk_spc(hw);
- return ve_spc_round_performance(spc->cluster, drate);
+ req->rate = ve_spc_round_performance(spc->cluster, req->rate);
+
+ return 0;
}
static int spc_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -515,7 +516,7 @@ static int spc_set_rate(struct clk_hw *hw, unsigned long rate,
static struct clk_ops clk_spc_ops = {
.recalc_rate = spc_recalc_rate,
- .round_rate = spc_round_rate,
+ .determine_rate = spc_determine_rate,
.set_rate = spc_set_rate,
};
--
2.50.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] ARM: versatile: clock: convert from round_rate() to determine_rate()
2025-07-10 23:42 ` [PATCH 3/3] ARM: versatile: " Brian Masney
@ 2025-07-11 8:51 ` Sudeep Holla
2025-07-11 17:45 ` Linus Walleij
1 sibling, 0 replies; 7+ messages in thread
From: Sudeep Holla @ 2025-07-11 8:51 UTC (permalink / raw)
To: Brian Masney
Cc: Paul Walmsley, Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren,
Russell King, Andreas Kemnade, Kevin Hilman, Roger Quadros,
Linus Walleij, Liviu Dudau, Lorenzo Pieralisi, Maxime Ripard,
Stephen Boyd, linux-clk, linux-omap, linux-arm-kernel,
linux-kernel
On Thu, Jul 10, 2025 at 07:42:18PM -0400, Brian Masney wrote:
> 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.
>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
> Signed-off-by: Brian Masney <bmasney@redhat.com>
> ---
> arch/arm/mach-versatile/spc.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/mach-versatile/spc.c b/arch/arm/mach-versatile/spc.c
> index 790092734cf6155daa63c44a1e5af00ecef30737..812db32448fcd415fa1a60f8bb971661369151e1 100644
> --- a/arch/arm/mach-versatile/spc.c
> +++ b/arch/arm/mach-versatile/spc.c
> @@ -497,12 +497,13 @@ static unsigned long spc_recalc_rate(struct clk_hw *hw,
> return freq * 1000;
> }
>
> -static long spc_round_rate(struct clk_hw *hw, unsigned long drate,
> - unsigned long *parent_rate)
> +static int spc_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
> {
> struct clk_spc *spc = to_clk_spc(hw);
>
> - return ve_spc_round_performance(spc->cluster, drate);
> + req->rate = ve_spc_round_performance(spc->cluster, req->rate);
> +
> + return 0;
> }
>
> static int spc_set_rate(struct clk_hw *hw, unsigned long rate,
> @@ -515,7 +516,7 @@ static int spc_set_rate(struct clk_hw *hw, unsigned long rate,
>
> static struct clk_ops clk_spc_ops = {
> .recalc_rate = spc_recalc_rate,
> - .round_rate = spc_round_rate,
> + .determine_rate = spc_determine_rate,
> .set_rate = spc_set_rate,
> };
>
>
> --
> 2.50.0
>
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] ARM: versatile: clock: convert from round_rate() to determine_rate()
2025-07-10 23:42 ` [PATCH 3/3] ARM: versatile: " Brian Masney
2025-07-11 8:51 ` Sudeep Holla
@ 2025-07-11 17:45 ` Linus Walleij
1 sibling, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2025-07-11 17:45 UTC (permalink / raw)
To: Brian Masney
Cc: Paul Walmsley, Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren,
Russell King, Andreas Kemnade, Kevin Hilman, Roger Quadros,
Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi, Maxime Ripard,
Stephen Boyd, linux-clk, linux-omap, linux-arm-kernel,
linux-kernel
On Fri, Jul 11, 2025 at 1:42 AM Brian Masney <bmasney@redhat.com> wrote:
> 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>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] ARM: OMAP1: clock: convert from round_rate() to determine_rate()
2025-07-10 23:42 ` [PATCH 1/3] ARM: OMAP1: clock: convert from " Brian Masney
@ 2025-07-13 20:35 ` Janusz Krzysztofik
0 siblings, 0 replies; 7+ messages in thread
From: Janusz Krzysztofik @ 2025-07-13 20:35 UTC (permalink / raw)
To: Paul Walmsley, Aaro Koskinen, Tony Lindgren, Russell King,
Andreas Kemnade, Kevin Hilman, Roger Quadros, Linus Walleij,
Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi, Maxime Ripard,
Stephen Boyd, Brian Masney
Cc: linux-clk, linux-omap, linux-arm-kernel, linux-kernel,
Brian Masney
[-- Attachment #1: Type: text/plain, Size: 2213 bytes --]
On Friday, 11 July 2025 01:42:16 CEST Brian Masney wrote:
> 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>
Acked-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
> ---
> arch/arm/mach-omap1/clock.c | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
> index 83381e23fab983522ca01b8feffb861b02fee730..afc6404f62d39c4ddbac6f1ee04d889be6c47186 100644
> --- a/arch/arm/mach-omap1/clock.c
> +++ b/arch/arm/mach-omap1/clock.c
> @@ -705,14 +705,21 @@ static unsigned long omap1_clk_recalc_rate(struct clk_hw *hw, unsigned long p_ra
> return clk->rate;
> }
>
> -static long omap1_clk_round_rate(struct clk_hw *hw, unsigned long rate, unsigned long *p_rate)
> +static int omap1_clk_determine_rate(struct clk_hw *hw,
> + struct clk_rate_request *req)
> {
> struct omap1_clk *clk = to_omap1_clk(hw);
>
> - if (clk->round_rate != NULL)
> - return clk->round_rate(clk, rate, p_rate);
> + if (clk->round_rate != NULL) {
> + req->rate = clk->round_rate(clk, req->rate,
> + &req->best_parent_rate);
>
> - return omap1_clk_recalc_rate(hw, *p_rate);
> + return 0;
> + }
> +
> + req->rate = omap1_clk_recalc_rate(hw, req->best_parent_rate);
> +
> + return 0;
> }
>
> static int omap1_clk_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long p_rate)
> @@ -771,7 +778,7 @@ const struct clk_ops omap1_clk_gate_ops = {
>
> const struct clk_ops omap1_clk_rate_ops = {
> .recalc_rate = omap1_clk_recalc_rate,
> - .round_rate = omap1_clk_round_rate,
> + .determine_rate = omap1_clk_determine_rate,
> .set_rate = omap1_clk_set_rate,
> .init = omap1_clk_init_op,
> };
> @@ -784,7 +791,7 @@ const struct clk_ops omap1_clk_full_ops = {
> .disable_unused = omap1_clk_disable_unused,
> #endif
> .recalc_rate = omap1_clk_recalc_rate,
> - .round_rate = omap1_clk_round_rate,
> + .determine_rate = omap1_clk_determine_rate,
> .set_rate = omap1_clk_set_rate,
> .init = omap1_clk_init_op,
> };
>
>
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-07-13 20:35 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-10 23:42 [PATCH 0/3] ARM: convert from clk round_rate() to determine_rate() Brian Masney
2025-07-10 23:42 ` [PATCH 1/3] ARM: OMAP1: clock: convert from " Brian Masney
2025-07-13 20:35 ` Janusz Krzysztofik
2025-07-10 23:42 ` [PATCH 2/3] ARM: OMAP2+: " Brian Masney
2025-07-10 23:42 ` [PATCH 3/3] ARM: versatile: " Brian Masney
2025-07-11 8:51 ` Sudeep Holla
2025-07-11 17:45 ` Linus Walleij
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).