* [PATCH 0/6] sound: convert from clk round_rate() to determine_rate()
@ 2025-07-10 15:51 Brian Masney
2025-07-10 15:51 ` [PATCH 1/6] sound: soc: codecs: da7219: convert from " Brian Masney
` (7 more replies)
0 siblings, 8 replies; 12+ messages in thread
From: Brian Masney @ 2025-07-10 15:51 UTC (permalink / raw)
To: Support Opensource, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Oder Chiou, Srinivas Kandagatla, Olivier Moysan,
Arnaud Pouliquen, Maxime Coquelin, Alexandre Torgue,
Maxime Ripard, Stephen Boyd
Cc: linux-sound, linux-kernel, linux-arm-msm, linux-stm32,
linux-arm-kernel, linux-clk, 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.
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 (6):
sound: soc: codecs: da7219: convert from round_rate() to determine_rate()
sound: soc: codecs: rt5682: convert from round_rate() to determine_rate()
sound: soc: codecs: rt5682s: convert from round_rate() to determine_rate()
sound: soc: qcom: qdsp6: q6dsp-lpass-clocks: convert from round_rate() to determine_rate()
sound: soc: stm: stm32_i2s: convert from round_rate() to determine_rate()
sound: soc: stm: stm32_sai_sub: convert from round_rate() to determine_rate()
sound/soc/codecs/da7219.c | 64 ++++++++++++++++---------------
sound/soc/codecs/rt5682.c | 26 +++++++------
sound/soc/codecs/rt5682s.c | 26 +++++++------
sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c | 8 ++--
sound/soc/stm/stm32_i2s.c | 21 ++++++----
sound/soc/stm/stm32_sai_sub.c | 14 ++++---
6 files changed, 87 insertions(+), 72 deletions(-)
---
base-commit: b551c4e2a98a177a06148cf16505643cd2108386
change-id: 20250710-sound-clk-round-rate-adb1a71bd867
Best regards,
--
Brian Masney <bmasney@redhat.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/6] sound: soc: codecs: da7219: convert from round_rate() to determine_rate()
2025-07-10 15:51 [PATCH 0/6] sound: convert from clk round_rate() to determine_rate() Brian Masney
@ 2025-07-10 15:51 ` Brian Masney
2025-07-10 15:51 ` [PATCH 2/6] sound: soc: codecs: rt5682: " Brian Masney
` (6 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Brian Masney @ 2025-07-10 15:51 UTC (permalink / raw)
To: Support Opensource, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Oder Chiou, Srinivas Kandagatla, Olivier Moysan,
Arnaud Pouliquen, Maxime Coquelin, Alexandre Torgue,
Maxime Ripard, Stephen Boyd
Cc: linux-sound, linux-kernel, linux-arm-msm, linux-stm32,
linux-arm-kernel, linux-clk, 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>
---
sound/soc/codecs/da7219.c | 64 +++++++++++++++++++++++++----------------------
1 file changed, 34 insertions(+), 30 deletions(-)
diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c
index 221577574525a5fd60180a4441331d7db88f50e2..1742f91c788c62a34f35aae44fcfd1d7fbea007c 100644
--- a/sound/soc/codecs/da7219.c
+++ b/sound/soc/codecs/da7219.c
@@ -1982,8 +1982,8 @@ static unsigned long da7219_wclk_recalc_rate(struct clk_hw *hw,
}
}
-static long da7219_wclk_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *parent_rate)
+static int da7219_wclk_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
struct da7219_priv *da7219 =
container_of(hw, struct da7219_priv,
@@ -1992,28 +1992,30 @@ static long da7219_wclk_round_rate(struct clk_hw *hw, unsigned long rate,
if (!da7219->master)
return -EINVAL;
- if (rate < 11025)
- return 8000;
- else if (rate < 12000)
- return 11025;
- else if (rate < 16000)
- return 12000;
- else if (rate < 22050)
- return 16000;
- else if (rate < 24000)
- return 22050;
- else if (rate < 32000)
- return 24000;
- else if (rate < 44100)
- return 32000;
- else if (rate < 48000)
- return 44100;
- else if (rate < 88200)
- return 48000;
- else if (rate < 96000)
- return 88200;
+ if (req->rate < 11025)
+ req->rate = 8000;
+ else if (req->rate < 12000)
+ req->rate = 11025;
+ else if (req->rate < 16000)
+ req->rate = 12000;
+ else if (req->rate < 22050)
+ req->rate = 16000;
+ else if (req->rate < 24000)
+ req->rate = 22050;
+ else if (req->rate < 32000)
+ req->rate = 24000;
+ else if (req->rate < 44100)
+ req->rate = 32000;
+ else if (req->rate < 48000)
+ req->rate = 44100;
+ else if (req->rate < 88200)
+ req->rate = 48000;
+ else if (req->rate < 96000)
+ req->rate = 88200;
else
- return 96000;
+ req->rate = 96000;
+
+ return 0;
}
static int da7219_wclk_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -2070,15 +2072,15 @@ static unsigned long da7219_bclk_get_factor(unsigned long rate,
return 256;
}
-static long da7219_bclk_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *parent_rate)
+static int da7219_bclk_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
struct da7219_priv *da7219 =
container_of(hw, struct da7219_priv,
dai_clks_hw[DA7219_DAI_BCLK_IDX]);
unsigned long factor;
- if (!*parent_rate || !da7219->master)
+ if (!req->best_parent_rate || !da7219->master)
return -EINVAL;
/*
@@ -2088,9 +2090,11 @@ static long da7219_bclk_round_rate(struct clk_hw *hw, unsigned long rate,
* parent WCLK rate set and find the appropriate multiplier of BCLK to
* get the rounded down BCLK value.
*/
- factor = da7219_bclk_get_factor(rate, *parent_rate);
+ factor = da7219_bclk_get_factor(req->rate, req->best_parent_rate);
+
+ req->rate = req->best_parent_rate * factor;
- return *parent_rate * factor;
+ return 0;
}
static int da7219_bclk_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -2116,12 +2120,12 @@ static const struct clk_ops da7219_dai_clk_ops[DA7219_DAI_NUM_CLKS] = {
.unprepare = da7219_wclk_unprepare,
.is_prepared = da7219_wclk_is_prepared,
.recalc_rate = da7219_wclk_recalc_rate,
- .round_rate = da7219_wclk_round_rate,
+ .determine_rate = da7219_wclk_determine_rate,
.set_rate = da7219_wclk_set_rate,
},
[DA7219_DAI_BCLK_IDX] = {
.recalc_rate = da7219_bclk_recalc_rate,
- .round_rate = da7219_bclk_round_rate,
+ .determine_rate = da7219_bclk_determine_rate,
.set_rate = da7219_bclk_set_rate,
},
};
--
2.50.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/6] sound: soc: codecs: rt5682: convert from round_rate() to determine_rate()
2025-07-10 15:51 [PATCH 0/6] sound: convert from clk round_rate() to determine_rate() Brian Masney
2025-07-10 15:51 ` [PATCH 1/6] sound: soc: codecs: da7219: convert from " Brian Masney
@ 2025-07-10 15:51 ` Brian Masney
2025-07-10 15:51 ` [PATCH 3/6] sound: soc: codecs: rt5682s: " Brian Masney
` (5 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Brian Masney @ 2025-07-10 15:51 UTC (permalink / raw)
To: Support Opensource, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Oder Chiou, Srinivas Kandagatla, Olivier Moysan,
Arnaud Pouliquen, Maxime Coquelin, Alexandre Torgue,
Maxime Ripard, Stephen Boyd
Cc: linux-sound, linux-kernel, linux-arm-msm, linux-stm32,
linux-arm-kernel, linux-clk, 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>
---
sound/soc/codecs/rt5682.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index 7c88370e2dee6a4c2332f1e3db885c980f5e8079..a0abd2ce0c1e1f6cf59fecdd426db16136befe66 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -2675,8 +2675,8 @@ static unsigned long rt5682_wclk_recalc_rate(struct clk_hw *hw,
return rt5682->lrck[RT5682_AIF1];
}
-static long rt5682_wclk_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *parent_rate)
+static int rt5682_wclk_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
struct rt5682_priv *rt5682 =
container_of(hw, struct rt5682_priv,
@@ -2689,13 +2689,13 @@ static long rt5682_wclk_round_rate(struct clk_hw *hw, unsigned long rate,
* Only accept to set wclk rate to 44.1k or 48kHz.
* It will force to 48kHz if not both.
*/
- if (rate != CLK_48 && rate != CLK_44) {
+ if (req->rate != CLK_48 && req->rate != CLK_44) {
dev_warn(rt5682->i2c_dev, "%s: clk %s only support %d or %d Hz output\n",
__func__, clk_name, CLK_44, CLK_48);
- rate = CLK_48;
+ req->rate = CLK_48;
}
- return rate;
+ return 0;
}
static int rt5682_wclk_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -2795,15 +2795,15 @@ static unsigned long rt5682_bclk_get_factor(unsigned long rate,
return 256;
}
-static long rt5682_bclk_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *parent_rate)
+static int rt5682_bclk_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
struct rt5682_priv *rt5682 =
container_of(hw, struct rt5682_priv,
dai_clks_hw[RT5682_DAI_BCLK_IDX]);
unsigned long factor;
- if (!*parent_rate || !rt5682_clk_check(rt5682))
+ if (!req->best_parent_rate || !rt5682_clk_check(rt5682))
return -EINVAL;
/*
@@ -2813,9 +2813,11 @@ static long rt5682_bclk_round_rate(struct clk_hw *hw, unsigned long rate,
* and find the appropriate multiplier of BCLK to
* get the rounded down BCLK value.
*/
- factor = rt5682_bclk_get_factor(rate, *parent_rate);
+ factor = rt5682_bclk_get_factor(req->rate, req->best_parent_rate);
+
+ req->rate = req->best_parent_rate * factor;
- return *parent_rate * factor;
+ return 0;
}
static int rt5682_bclk_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -2849,12 +2851,12 @@ static const struct clk_ops rt5682_dai_clk_ops[RT5682_DAI_NUM_CLKS] = {
.prepare = rt5682_wclk_prepare,
.unprepare = rt5682_wclk_unprepare,
.recalc_rate = rt5682_wclk_recalc_rate,
- .round_rate = rt5682_wclk_round_rate,
+ .determine_rate = rt5682_wclk_determine_rate,
.set_rate = rt5682_wclk_set_rate,
},
[RT5682_DAI_BCLK_IDX] = {
.recalc_rate = rt5682_bclk_recalc_rate,
- .round_rate = rt5682_bclk_round_rate,
+ .determine_rate = rt5682_bclk_determine_rate,
.set_rate = rt5682_bclk_set_rate,
},
};
--
2.50.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/6] sound: soc: codecs: rt5682s: convert from round_rate() to determine_rate()
2025-07-10 15:51 [PATCH 0/6] sound: convert from clk round_rate() to determine_rate() Brian Masney
2025-07-10 15:51 ` [PATCH 1/6] sound: soc: codecs: da7219: convert from " Brian Masney
2025-07-10 15:51 ` [PATCH 2/6] sound: soc: codecs: rt5682: " Brian Masney
@ 2025-07-10 15:51 ` Brian Masney
2025-07-10 15:51 ` [PATCH 4/6] sound: soc: qcom: qdsp6: q6dsp-lpass-clocks: " Brian Masney
` (4 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Brian Masney @ 2025-07-10 15:51 UTC (permalink / raw)
To: Support Opensource, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Oder Chiou, Srinivas Kandagatla, Olivier Moysan,
Arnaud Pouliquen, Maxime Coquelin, Alexandre Torgue,
Maxime Ripard, Stephen Boyd
Cc: linux-sound, linux-kernel, linux-arm-msm, linux-stm32,
linux-arm-kernel, linux-clk, 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>
---
sound/soc/codecs/rt5682s.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/sound/soc/codecs/rt5682s.c b/sound/soc/codecs/rt5682s.c
index 73c4b3c31f8c45703d965e6fd1b70aa1817e2926..80b921695e7d1c0506766bd47421c07e5fa7a6d3 100644
--- a/sound/soc/codecs/rt5682s.c
+++ b/sound/soc/codecs/rt5682s.c
@@ -2610,8 +2610,8 @@ static unsigned long rt5682s_wclk_recalc_rate(struct clk_hw *hw,
return rt5682s->lrck[RT5682S_AIF1];
}
-static long rt5682s_wclk_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *parent_rate)
+static int rt5682s_wclk_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
struct rt5682s_priv *rt5682s =
container_of(hw, struct rt5682s_priv, dai_clks_hw[RT5682S_DAI_WCLK_IDX]);
@@ -2624,13 +2624,13 @@ static long rt5682s_wclk_round_rate(struct clk_hw *hw, unsigned long rate,
* Only accept to set wclk rate to 44.1k or 48kHz.
* It will force to 48kHz if not both.
*/
- if (rate != CLK_48 && rate != CLK_44) {
+ if (req->rate != CLK_48 && req->rate != CLK_44) {
dev_warn(component->dev, "%s: clk %s only support %d or %d Hz output\n",
__func__, clk_name, CLK_44, CLK_48);
- rate = CLK_48;
+ req->rate = CLK_48;
}
- return rate;
+ return 0;
}
static int rt5682s_wclk_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -2719,14 +2719,14 @@ static unsigned long rt5682s_bclk_get_factor(unsigned long rate,
return 256;
}
-static long rt5682s_bclk_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *parent_rate)
+static int rt5682s_bclk_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
struct rt5682s_priv *rt5682s =
container_of(hw, struct rt5682s_priv, dai_clks_hw[RT5682S_DAI_BCLK_IDX]);
unsigned long factor;
- if (!*parent_rate || !rt5682s_clk_check(rt5682s))
+ if (!req->best_parent_rate || !rt5682s_clk_check(rt5682s))
return -EINVAL;
/*
@@ -2736,9 +2736,11 @@ static long rt5682s_bclk_round_rate(struct clk_hw *hw, unsigned long rate,
* and find the appropriate multiplier of BCLK to
* get the rounded down BCLK value.
*/
- factor = rt5682s_bclk_get_factor(rate, *parent_rate);
+ factor = rt5682s_bclk_get_factor(req->rate, req->best_parent_rate);
+
+ req->rate = req->best_parent_rate * factor;
- return *parent_rate * factor;
+ return 0;
}
static int rt5682s_bclk_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -2769,12 +2771,12 @@ static const struct clk_ops rt5682s_dai_clk_ops[RT5682S_DAI_NUM_CLKS] = {
.prepare = rt5682s_wclk_prepare,
.unprepare = rt5682s_wclk_unprepare,
.recalc_rate = rt5682s_wclk_recalc_rate,
- .round_rate = rt5682s_wclk_round_rate,
+ .determine_rate = rt5682s_wclk_determine_rate,
.set_rate = rt5682s_wclk_set_rate,
},
[RT5682S_DAI_BCLK_IDX] = {
.recalc_rate = rt5682s_bclk_recalc_rate,
- .round_rate = rt5682s_bclk_round_rate,
+ .determine_rate = rt5682s_bclk_determine_rate,
.set_rate = rt5682s_bclk_set_rate,
},
};
--
2.50.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/6] sound: soc: qcom: qdsp6: q6dsp-lpass-clocks: convert from round_rate() to determine_rate()
2025-07-10 15:51 [PATCH 0/6] sound: convert from clk round_rate() to determine_rate() Brian Masney
` (2 preceding siblings ...)
2025-07-10 15:51 ` [PATCH 3/6] sound: soc: codecs: rt5682s: " Brian Masney
@ 2025-07-10 15:51 ` Brian Masney
2025-07-10 16:09 ` Konrad Dybcio
2025-07-10 15:51 ` [PATCH 5/6] sound: soc: stm: stm32_i2s: " Brian Masney
` (3 subsequent siblings)
7 siblings, 1 reply; 12+ messages in thread
From: Brian Masney @ 2025-07-10 15:51 UTC (permalink / raw)
To: Support Opensource, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Oder Chiou, Srinivas Kandagatla, Olivier Moysan,
Arnaud Pouliquen, Maxime Coquelin, Alexandre Torgue,
Maxime Ripard, Stephen Boyd
Cc: linux-sound, linux-kernel, linux-arm-msm, linux-stm32,
linux-arm-kernel, linux-clk, 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>
---
sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c b/sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c
index e758411603be5157e468e8c076620d7c18661bf3..03838582aeade389d9a2d90cf9f03fad835f0733 100644
--- a/sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c
+++ b/sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c
@@ -69,17 +69,17 @@ static unsigned long clk_q6dsp_recalc_rate(struct clk_hw *hw,
return clk->rate;
}
-static long clk_q6dsp_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *parent_rate)
+static int clk_q6dsp_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
- return rate;
+ return 0;
}
static const struct clk_ops clk_q6dsp_ops = {
.prepare = clk_q6dsp_prepare,
.unprepare = clk_q6dsp_unprepare,
.set_rate = clk_q6dsp_set_rate,
- .round_rate = clk_q6dsp_round_rate,
+ .determine_rate = clk_q6dsp_determine_rate,
.recalc_rate = clk_q6dsp_recalc_rate,
};
--
2.50.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 5/6] sound: soc: stm: stm32_i2s: convert from round_rate() to determine_rate()
2025-07-10 15:51 [PATCH 0/6] sound: convert from clk round_rate() to determine_rate() Brian Masney
` (3 preceding siblings ...)
2025-07-10 15:51 ` [PATCH 4/6] sound: soc: qcom: qdsp6: q6dsp-lpass-clocks: " Brian Masney
@ 2025-07-10 15:51 ` Brian Masney
2025-07-10 15:51 ` [PATCH 6/6] sound: soc: stm: stm32_sai_sub: " Brian Masney
` (2 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Brian Masney @ 2025-07-10 15:51 UTC (permalink / raw)
To: Support Opensource, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Oder Chiou, Srinivas Kandagatla, Olivier Moysan,
Arnaud Pouliquen, Maxime Coquelin, Alexandre Torgue,
Maxime Ripard, Stephen Boyd
Cc: linux-sound, linux-kernel, linux-arm-msm, linux-stm32,
linux-arm-kernel, linux-clk, 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>
---
sound/soc/stm/stm32_i2s.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/sound/soc/stm/stm32_i2s.c b/sound/soc/stm/stm32_i2s.c
index 6037b7a9c97bf25621fccb1feb59c4caee3250ca..0e489097d9c1086efcd9e3d1013acffeb0a46d4a 100644
--- a/sound/soc/stm/stm32_i2s.c
+++ b/sound/soc/stm/stm32_i2s.c
@@ -461,20 +461,25 @@ static int stm32_i2s_set_parent_rate(struct stm32_i2s_data *i2s,
return -EINVAL;
}
-static long stm32_i2smclk_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *prate)
+static int stm32_i2smclk_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
struct stm32_i2smclk_data *mclk = to_mclk_data(hw);
struct stm32_i2s_data *i2s = mclk->i2s_data;
int ret;
- ret = stm32_i2s_calc_clk_div(i2s, *prate, rate);
- if (ret)
- return ret;
+ ret = stm32_i2s_calc_clk_div(i2s, req->best_parent_rate, req->rate);
+ if (ret) {
+ req->rate = ret;
- mclk->freq = *prate / i2s->divider;
+ return 0;
+ }
- return mclk->freq;
+ mclk->freq = req->best_parent_rate / i2s->divider;
+
+ req->rate = mclk->freq;
+
+ return 0;
}
static unsigned long stm32_i2smclk_recalc_rate(struct clk_hw *hw,
@@ -530,7 +535,7 @@ static const struct clk_ops mclk_ops = {
.enable = stm32_i2smclk_enable,
.disable = stm32_i2smclk_disable,
.recalc_rate = stm32_i2smclk_recalc_rate,
- .round_rate = stm32_i2smclk_round_rate,
+ .determine_rate = stm32_i2smclk_determine_rate,
.set_rate = stm32_i2smclk_set_rate,
};
--
2.50.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 6/6] sound: soc: stm: stm32_sai_sub: convert from round_rate() to determine_rate()
2025-07-10 15:51 [PATCH 0/6] sound: convert from clk round_rate() to determine_rate() Brian Masney
` (4 preceding siblings ...)
2025-07-10 15:51 ` [PATCH 5/6] sound: soc: stm: stm32_i2s: " Brian Masney
@ 2025-07-10 15:51 ` Brian Masney
2025-07-11 8:37 ` [PATCH 0/6] sound: convert from clk " Mark Brown
2025-07-16 10:14 ` Mark Brown
7 siblings, 0 replies; 12+ messages in thread
From: Brian Masney @ 2025-07-10 15:51 UTC (permalink / raw)
To: Support Opensource, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Oder Chiou, Srinivas Kandagatla, Olivier Moysan,
Arnaud Pouliquen, Maxime Coquelin, Alexandre Torgue,
Maxime Ripard, Stephen Boyd
Cc: linux-sound, linux-kernel, linux-arm-msm, linux-stm32,
linux-arm-kernel, linux-clk, 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>
---
sound/soc/stm/stm32_sai_sub.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
index bf5299ba11c3c95ad89dfb00612ade7ed42b9d0d..463a2b7d023b9cae802f88041c23a9bcc3219a6a 100644
--- a/sound/soc/stm/stm32_sai_sub.c
+++ b/sound/soc/stm/stm32_sai_sub.c
@@ -489,20 +489,22 @@ static int stm32_sai_set_parent_rate(struct stm32_sai_sub_data *sai,
return -EINVAL;
}
-static long stm32_sai_mclk_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *prate)
+static int stm32_sai_mclk_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
struct stm32_sai_mclk_data *mclk = to_mclk_data(hw);
struct stm32_sai_sub_data *sai = mclk->sai_data;
int div;
- div = stm32_sai_get_clk_div(sai, *prate, rate);
+ div = stm32_sai_get_clk_div(sai, req->best_parent_rate, req->rate);
if (div <= 0)
return -EINVAL;
- mclk->freq = *prate / div;
+ mclk->freq = req->best_parent_rate / div;
- return mclk->freq;
+ req->rate = mclk->freq;
+
+ return 0;
}
static unsigned long stm32_sai_mclk_recalc_rate(struct clk_hw *hw,
@@ -558,7 +560,7 @@ static const struct clk_ops mclk_ops = {
.enable = stm32_sai_mclk_enable,
.disable = stm32_sai_mclk_disable,
.recalc_rate = stm32_sai_mclk_recalc_rate,
- .round_rate = stm32_sai_mclk_round_rate,
+ .determine_rate = stm32_sai_mclk_determine_rate,
.set_rate = stm32_sai_mclk_set_rate,
};
--
2.50.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 4/6] sound: soc: qcom: qdsp6: q6dsp-lpass-clocks: convert from round_rate() to determine_rate()
2025-07-10 15:51 ` [PATCH 4/6] sound: soc: qcom: qdsp6: q6dsp-lpass-clocks: " Brian Masney
@ 2025-07-10 16:09 ` Konrad Dybcio
2025-07-14 20:39 ` Brian Masney
0 siblings, 1 reply; 12+ messages in thread
From: Konrad Dybcio @ 2025-07-10 16:09 UTC (permalink / raw)
To: Brian Masney, Support Opensource, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Oder Chiou, Srinivas Kandagatla,
Olivier Moysan, Arnaud Pouliquen, Maxime Coquelin,
Alexandre Torgue, Maxime Ripard, Stephen Boyd
Cc: linux-sound, linux-kernel, linux-arm-msm, linux-stm32,
linux-arm-kernel, linux-clk
On 7/10/25 5:51 PM, 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>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
come to think of it, there are a lot of drivers that can not
do any rate rounding - perhaps we could introduce a NOP implementation
in the clk core that we could reference, instead of copypasting
int foo(...) { "return 0" }?
Konrad
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/6] sound: convert from clk round_rate() to determine_rate()
2025-07-10 15:51 [PATCH 0/6] sound: convert from clk round_rate() to determine_rate() Brian Masney
` (5 preceding siblings ...)
2025-07-10 15:51 ` [PATCH 6/6] sound: soc: stm: stm32_sai_sub: " Brian Masney
@ 2025-07-11 8:37 ` Mark Brown
2025-07-16 10:14 ` Mark Brown
7 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2025-07-11 8:37 UTC (permalink / raw)
To: Brian Masney
Cc: Support Opensource, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Oder Chiou, Srinivas Kandagatla, Olivier Moysan, Arnaud Pouliquen,
Maxime Coquelin, Alexandre Torgue, Maxime Ripard, Stephen Boyd,
linux-sound, linux-kernel, linux-arm-msm, linux-stm32,
linux-arm-kernel, linux-clk
[-- Attachment #1: Type: text/plain, Size: 682 bytes --]
On Thu, Jul 10, 2025 at 11:51:06AM -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.
Please submit patches using subject lines reflecting the style for the
subsystem, this makes it easier for people to identify relevant patches.
Look at what existing commits in the area you're changing are doing and
make sure your subject lines visually resemble what they're doing.
There's no need to resubmit to fix this alone.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/6] sound: soc: qcom: qdsp6: q6dsp-lpass-clocks: convert from round_rate() to determine_rate()
2025-07-10 16:09 ` Konrad Dybcio
@ 2025-07-14 20:39 ` Brian Masney
2025-07-14 23:41 ` Konrad Dybcio
0 siblings, 1 reply; 12+ messages in thread
From: Brian Masney @ 2025-07-14 20:39 UTC (permalink / raw)
To: Konrad Dybcio
Cc: Support Opensource, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Oder Chiou, Srinivas Kandagatla, Olivier Moysan,
Arnaud Pouliquen, Maxime Coquelin, Alexandre Torgue,
Maxime Ripard, Stephen Boyd, linux-sound, linux-kernel,
linux-arm-msm, linux-stm32, linux-arm-kernel, linux-clk
Hi Konrad,
On Thu, Jul 10, 2025 at 12:09 PM Konrad Dybcio
<konrad.dybcio@oss.qualcomm.com> wrote:
> On 7/10/25 5:51 PM, 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>
> > ---
>
> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
>
> come to think of it, there are a lot of drivers that can not
> do any rate rounding - perhaps we could introduce a NOP implementation
> in the clk core that we could reference, instead of copypasting
> int foo(...) { "return 0" }?
I'll look at that for a second round of cleanup once all of the
round_rates have been removed from the tree. From what I recall about
the ~200 or so round_rate implementations in the kernel tree, there
were maybe only 5 or so that cover this noop case. QC seemed to have
the most from what I recall.
It wouldn't be hard to make a Coccinelle script to look for the noop
determine_rate() implementations.
Brian
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/6] sound: soc: qcom: qdsp6: q6dsp-lpass-clocks: convert from round_rate() to determine_rate()
2025-07-14 20:39 ` Brian Masney
@ 2025-07-14 23:41 ` Konrad Dybcio
0 siblings, 0 replies; 12+ messages in thread
From: Konrad Dybcio @ 2025-07-14 23:41 UTC (permalink / raw)
To: Brian Masney
Cc: Support Opensource, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Oder Chiou, Srinivas Kandagatla, Olivier Moysan,
Arnaud Pouliquen, Maxime Coquelin, Alexandre Torgue,
Maxime Ripard, Stephen Boyd, linux-sound, linux-kernel,
linux-arm-msm, linux-stm32, linux-arm-kernel, linux-clk
On 7/14/25 10:39 PM, Brian Masney wrote:
> Hi Konrad,
>
> On Thu, Jul 10, 2025 at 12:09 PM Konrad Dybcio
> <konrad.dybcio@oss.qualcomm.com> wrote:
>> On 7/10/25 5:51 PM, 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>
>>> ---
>>
>> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
>>
>> come to think of it, there are a lot of drivers that can not
>> do any rate rounding - perhaps we could introduce a NOP implementation
>> in the clk core that we could reference, instead of copypasting
>> int foo(...) { "return 0" }?
>
> I'll look at that for a second round of cleanup once all of the
> round_rates have been removed from the tree. From what I recall about
> the ~200 or so round_rate implementations in the kernel tree, there
> were maybe only 5 or so that cover this noop case. QC seemed to have
> the most from what I recall.
>
> It wouldn't be hard to make a Coccinelle script to look for the noop
> determine_rate() implementations.
Thanks!
Konrad
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/6] sound: convert from clk round_rate() to determine_rate()
2025-07-10 15:51 [PATCH 0/6] sound: convert from clk round_rate() to determine_rate() Brian Masney
` (6 preceding siblings ...)
2025-07-11 8:37 ` [PATCH 0/6] sound: convert from clk " Mark Brown
@ 2025-07-16 10:14 ` Mark Brown
7 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2025-07-16 10:14 UTC (permalink / raw)
To: Support Opensource, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Oder Chiou, Srinivas Kandagatla, Olivier Moysan, Arnaud Pouliquen,
Maxime Coquelin, Alexandre Torgue, Maxime Ripard, Stephen Boyd,
Brian Masney
Cc: linux-sound, linux-kernel, linux-arm-msm, linux-stm32,
linux-arm-kernel, linux-clk
On Thu, 10 Jul 2025 11:51:06 -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.
>
> Coccinelle semantic patch:
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/6] sound: soc: codecs: da7219: convert from round_rate() to determine_rate()
commit: 8a4d73121d6bd9a70895e65d6d1014ed6b0a6c8e
[2/6] sound: soc: codecs: rt5682: convert from round_rate() to determine_rate()
commit: 4e15a10f6fb254e33d73a6da3c4d00e3e64d2eb8
[3/6] sound: soc: codecs: rt5682s: convert from round_rate() to determine_rate()
commit: a37d9c8aef1c78876eff0bc8980a889c083de89d
[4/6] sound: soc: qcom: qdsp6: q6dsp-lpass-clocks: convert from round_rate() to determine_rate()
commit: fc62ed665eb2e8fb0f1e12ab9cdb578666704a76
[5/6] sound: soc: stm: stm32_i2s: convert from round_rate() to determine_rate()
commit: afd529d740028a41fa750d4491b106cecbccba3e
[6/6] sound: soc: stm: stm32_sai_sub: convert from round_rate() to determine_rate()
commit: d5f317fd5cd9dfdf5bbe11384001817760c12b75
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-07-16 10:14 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-10 15:51 [PATCH 0/6] sound: convert from clk round_rate() to determine_rate() Brian Masney
2025-07-10 15:51 ` [PATCH 1/6] sound: soc: codecs: da7219: convert from " Brian Masney
2025-07-10 15:51 ` [PATCH 2/6] sound: soc: codecs: rt5682: " Brian Masney
2025-07-10 15:51 ` [PATCH 3/6] sound: soc: codecs: rt5682s: " Brian Masney
2025-07-10 15:51 ` [PATCH 4/6] sound: soc: qcom: qdsp6: q6dsp-lpass-clocks: " Brian Masney
2025-07-10 16:09 ` Konrad Dybcio
2025-07-14 20:39 ` Brian Masney
2025-07-14 23:41 ` Konrad Dybcio
2025-07-10 15:51 ` [PATCH 5/6] sound: soc: stm: stm32_i2s: " Brian Masney
2025-07-10 15:51 ` [PATCH 6/6] sound: soc: stm: stm32_sai_sub: " Brian Masney
2025-07-11 8:37 ` [PATCH 0/6] sound: convert from clk " Mark Brown
2025-07-16 10:14 ` Mark Brown
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).