* [PATCH 0/4] media: convert from clk round_rate() to determine_rate()
@ 2025-07-10 17:29 Brian Masney
2025-07-10 17:29 ` [PATCH 1/4] media: i2c: ds90ub953: convert from " Brian Masney
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Brian Masney @ 2025-07-10 17:29 UTC (permalink / raw)
To: Tomi Valkeinen, Mauro Carvalho Chehab, Julien Massot,
Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-media, 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 media 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 (4):
media: i2c: ds90ub953: convert from round_rate() to determine_rate()
media: i2c: max96717: convert from round_rate() to determine_rate()
media: i2c: tc358746: convert from round_rate() to determine_rate()
media: platform: ti: omap3isp: isp: convert from round_rate() to determine_rate()
drivers/media/i2c/ds90ub953.c | 12 +++++++-----
drivers/media/i2c/max96717.c | 16 +++++++++-------
drivers/media/i2c/tc358746.c | 12 +++++++-----
drivers/media/platform/ti/omap3isp/isp.c | 10 +++++-----
4 files changed, 28 insertions(+), 22 deletions(-)
---
base-commit: b551c4e2a98a177a06148cf16505643cd2108386
change-id: 20250710-media-clk-round-rate-50fa3894747b
Best regards,
--
Brian Masney <bmasney@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] media: i2c: ds90ub953: convert from round_rate() to determine_rate()
2025-07-10 17:29 [PATCH 0/4] media: convert from clk round_rate() to determine_rate() Brian Masney
@ 2025-07-10 17:29 ` Brian Masney
2025-07-10 17:29 ` [PATCH 2/4] media: i2c: max96717: " Brian Masney
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Brian Masney @ 2025-07-10 17:29 UTC (permalink / raw)
To: Tomi Valkeinen, Mauro Carvalho Chehab, Julien Massot,
Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-media, 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>
---
drivers/media/i2c/ds90ub953.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c
index a865bfc895006464da0a0bedc90b1c26c4ec8d49..f57130bc6ba274ae8c7f69320791a52a8aaf0404 100644
--- a/drivers/media/i2c/ds90ub953.c
+++ b/drivers/media/i2c/ds90ub953.c
@@ -1023,15 +1023,17 @@ static unsigned long ub953_clkout_recalc_rate(struct clk_hw *hw,
return rate;
}
-static long ub953_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *parent_rate)
+static int ub953_clkout_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
struct ub953_data *priv = container_of(hw, struct ub953_data, clkout_clk_hw);
struct ub953_clkout_data clkout_data;
- ub953_calc_clkout_params(priv, rate, &clkout_data);
+ ub953_calc_clkout_params(priv, req->rate, &clkout_data);
+
+ req->rate = clkout_data.rate;
- return clkout_data.rate;
+ return 0;
}
static int ub953_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -1050,7 +1052,7 @@ static int ub953_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
static const struct clk_ops ub953_clkout_ops = {
.recalc_rate = ub953_clkout_recalc_rate,
- .round_rate = ub953_clkout_round_rate,
+ .determine_rate = ub953_clkout_determine_rate,
.set_rate = ub953_clkout_set_rate,
};
--
2.50.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] media: i2c: max96717: convert from round_rate() to determine_rate()
2025-07-10 17:29 [PATCH 0/4] media: convert from clk round_rate() to determine_rate() Brian Masney
2025-07-10 17:29 ` [PATCH 1/4] media: i2c: ds90ub953: convert from " Brian Masney
@ 2025-07-10 17:29 ` Brian Masney
2025-07-10 17:29 ` [PATCH 3/4] media: i2c: tc358746: " Brian Masney
2025-07-10 17:29 ` [PATCH 4/4] media: platform: ti: omap3isp: isp: " Brian Masney
3 siblings, 0 replies; 5+ messages in thread
From: Brian Masney @ 2025-07-10 17:29 UTC (permalink / raw)
To: Tomi Valkeinen, Mauro Carvalho Chehab, Julien Massot,
Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-media, 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>
---
drivers/media/i2c/max96717.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/media/i2c/max96717.c b/drivers/media/i2c/max96717.c
index 015e42fbe24629cc0268825ec640532a145e563b..17625fa72367bcce59b2178b8ca4fba795187d11 100644
--- a/drivers/media/i2c/max96717.c
+++ b/drivers/media/i2c/max96717.c
@@ -782,21 +782,23 @@ static unsigned int max96717_clk_find_best_index(struct max96717_priv *priv,
return idx;
}
-static long max96717_clk_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *parent_rate)
+static int max96717_clk_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
struct max96717_priv *priv = clk_hw_to_max96717(hw);
struct device *dev = &priv->client->dev;
unsigned int idx;
- idx = max96717_clk_find_best_index(priv, rate);
+ idx = max96717_clk_find_best_index(priv, req->rate);
- if (rate != max96717_predef_freqs[idx].freq) {
+ if (req->rate != max96717_predef_freqs[idx].freq) {
dev_warn(dev, "Request CLK freq:%lu, found CLK freq:%lu\n",
- rate, max96717_predef_freqs[idx].freq);
+ req->rate, max96717_predef_freqs[idx].freq);
}
- return max96717_predef_freqs[idx].freq;
+ req->rate = max96717_predef_freqs[idx].freq;
+
+ return 0;
}
static int max96717_clk_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -847,7 +849,7 @@ static const struct clk_ops max96717_clk_ops = {
.unprepare = max96717_clk_unprepare,
.set_rate = max96717_clk_set_rate,
.recalc_rate = max96717_clk_recalc_rate,
- .round_rate = max96717_clk_round_rate,
+ .determine_rate = max96717_clk_determine_rate,
};
static int max96717_register_clkout(struct max96717_priv *priv)
--
2.50.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] media: i2c: tc358746: convert from round_rate() to determine_rate()
2025-07-10 17:29 [PATCH 0/4] media: convert from clk round_rate() to determine_rate() Brian Masney
2025-07-10 17:29 ` [PATCH 1/4] media: i2c: ds90ub953: convert from " Brian Masney
2025-07-10 17:29 ` [PATCH 2/4] media: i2c: max96717: " Brian Masney
@ 2025-07-10 17:29 ` Brian Masney
2025-07-10 17:29 ` [PATCH 4/4] media: platform: ti: omap3isp: isp: " Brian Masney
3 siblings, 0 replies; 5+ messages in thread
From: Brian Masney @ 2025-07-10 17:29 UTC (permalink / raw)
To: Tomi Valkeinen, Mauro Carvalho Chehab, Julien Massot,
Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-media, 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>
---
drivers/media/i2c/tc358746.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/media/i2c/tc358746.c b/drivers/media/i2c/tc358746.c
index 143aa1359aba51c2a36e8800e7c1149698268ca1..952470767b1e4b4c6e919fc5fec1ab5338c52409 100644
--- a/drivers/media/i2c/tc358746.c
+++ b/drivers/media/i2c/tc358746.c
@@ -1226,14 +1226,16 @@ tc358746_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
return tc358746->pll_rate / (prediv * postdiv);
}
-static long tc358746_mclk_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *parent_rate)
+static int tc358746_mclk_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
struct tc358746 *tc358746 = clk_hw_to_tc358746(hw);
- *parent_rate = tc358746->pll_rate;
+ req->best_parent_rate = tc358746->pll_rate;
- return tc358746_find_mclk_settings(tc358746, rate);
+ req->rate = tc358746_find_mclk_settings(tc358746, req->rate);
+
+ return 0;
}
static int tc358746_mclk_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -1250,7 +1252,7 @@ static const struct clk_ops tc358746_mclk_ops = {
.enable = tc358746_mclk_enable,
.disable = tc358746_mclk_disable,
.recalc_rate = tc358746_recalc_rate,
- .round_rate = tc358746_mclk_round_rate,
+ .determine_rate = tc358746_mclk_determine_rate,
.set_rate = tc358746_mclk_set_rate,
};
--
2.50.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] media: platform: ti: omap3isp: isp: convert from round_rate() to determine_rate()
2025-07-10 17:29 [PATCH 0/4] media: convert from clk round_rate() to determine_rate() Brian Masney
` (2 preceding siblings ...)
2025-07-10 17:29 ` [PATCH 3/4] media: i2c: tc358746: " Brian Masney
@ 2025-07-10 17:29 ` Brian Masney
3 siblings, 0 replies; 5+ messages in thread
From: Brian Masney @ 2025-07-10 17:29 UTC (permalink / raw)
To: Tomi Valkeinen, Mauro Carvalho Chehab, Julien Massot,
Maxime Ripard, Stephen Boyd
Cc: linux-clk, linux-media, 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>
---
drivers/media/platform/ti/omap3isp/isp.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/media/platform/ti/omap3isp/isp.c b/drivers/media/platform/ti/omap3isp/isp.c
index f51cf6119e978a3a33939bd83c2e676a43ca2c6d..8ac2bdcdf87b1fa0ad1b064cbeb7f1e7519973fd 100644
--- a/drivers/media/platform/ti/omap3isp/isp.c
+++ b/drivers/media/platform/ti/omap3isp/isp.c
@@ -240,11 +240,11 @@ static u32 isp_xclk_calc_divider(unsigned long *rate, unsigned long parent_rate)
return divider;
}
-static long isp_xclk_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *parent_rate)
+static int isp_xclk_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
- isp_xclk_calc_divider(&rate, *parent_rate);
- return rate;
+ isp_xclk_calc_divider(&req->rate, req->best_parent_rate);
+ return 0;
}
static int isp_xclk_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -275,7 +275,7 @@ static const struct clk_ops isp_xclk_ops = {
.enable = isp_xclk_enable,
.disable = isp_xclk_disable,
.recalc_rate = isp_xclk_recalc_rate,
- .round_rate = isp_xclk_round_rate,
+ .determine_rate = isp_xclk_determine_rate,
.set_rate = isp_xclk_set_rate,
};
--
2.50.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-10 17:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-10 17:29 [PATCH 0/4] media: convert from clk round_rate() to determine_rate() Brian Masney
2025-07-10 17:29 ` [PATCH 1/4] media: i2c: ds90ub953: convert from " Brian Masney
2025-07-10 17:29 ` [PATCH 2/4] media: i2c: max96717: " Brian Masney
2025-07-10 17:29 ` [PATCH 3/4] media: i2c: tc358746: " Brian Masney
2025-07-10 17:29 ` [PATCH 4/4] media: platform: ti: omap3isp: isp: " Brian Masney
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).