* [PATCH v2 0/2] Cleanup in rockchip_sai.c
@ 2025-06-06 9:18 Pei Xiao
2025-06-06 9:18 ` [PATCH v2 1/2] ASOC: rockchip: fix capture stream handling in rockchip_sai_xfer_stop Pei Xiao
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Pei Xiao @ 2025-06-06 9:18 UTC (permalink / raw)
To: nicolas.frattaroli, lgirdwood, broonie, perex, tiwai, heiko,
linux-rockchip, linux-sound, linux-arm-kernel, linux-kernel
Cc: Pei Xiao
1.Simplify the condition logic in
2.Use helper function devm_clk_get_enabled()
---
changlog in v2:
1.fix capture flag in rockchip_sai_xfer_stop
2.remove err_disable_hclk
---
Pei Xiao (2):
ASOC: rockchip: fix capture stream handling in rockchip_sai_xfer_stop
ASOC: rockchip: Use helper function devm_clk_get_enabled()
sound/soc/rockchip/rockchip_sai.c | 51 ++++++++-----------------------
1 file changed, 13 insertions(+), 38 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] ASOC: rockchip: fix capture stream handling in rockchip_sai_xfer_stop
2025-06-06 9:18 [PATCH v2 0/2] Cleanup in rockchip_sai.c Pei Xiao
@ 2025-06-06 9:18 ` Pei Xiao
2025-06-06 9:48 ` Nicolas Frattaroli
2025-06-06 9:18 ` [PATCH v2 2/2] ASOC: rockchip: Use helper function devm_clk_get_enabled() Pei Xiao
2025-06-09 21:00 ` [PATCH v2 0/2] Cleanup in rockchip_sai.c Mark Brown
2 siblings, 1 reply; 6+ messages in thread
From: Pei Xiao @ 2025-06-06 9:18 UTC (permalink / raw)
To: nicolas.frattaroli, lgirdwood, broonie, perex, tiwai, heiko,
linux-rockchip, linux-sound, linux-arm-kernel, linux-kernel
Cc: Pei Xiao
Correcting the capture stream handling which was incorrectly setting
playback=true for capture streams.
The original code mistakenly set playback=true for capture streams,
causing incorrect behavior.
Fixes: cc78d1eaabad ("ASoC: rockchip: add Serial Audio Interface (SAI) driver")
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
sound/soc/rockchip/rockchip_sai.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/sound/soc/rockchip/rockchip_sai.c b/sound/soc/rockchip/rockchip_sai.c
index 602f1ddfad00..916af63f1c2c 100644
--- a/sound/soc/rockchip/rockchip_sai.c
+++ b/sound/soc/rockchip/rockchip_sai.c
@@ -378,19 +378,9 @@ static void rockchip_sai_xfer_start(struct rk_sai_dev *sai, int stream)
static void rockchip_sai_xfer_stop(struct rk_sai_dev *sai, int stream)
{
unsigned int msk = 0, val = 0, clr = 0;
- bool playback;
- bool capture;
-
- if (stream < 0) {
- playback = true;
- capture = true;
- } else if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
- playback = true;
- capture = false;
- } else {
- playback = true;
- capture = false;
- }
+ bool capture = stream == SNDRV_PCM_STREAM_CAPTURE || stream < 0;
+ bool playback = stream == SNDRV_PCM_STREAM_PLAYBACK || stream < 0;
+ /* could be <= 0 but we don't want to depend on enum values */
if (playback) {
msk |= SAI_XFER_TXS_MASK;
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] ASOC: rockchip: Use helper function devm_clk_get_enabled()
2025-06-06 9:18 [PATCH v2 0/2] Cleanup in rockchip_sai.c Pei Xiao
2025-06-06 9:18 ` [PATCH v2 1/2] ASOC: rockchip: fix capture stream handling in rockchip_sai_xfer_stop Pei Xiao
@ 2025-06-06 9:18 ` Pei Xiao
2025-06-06 9:51 ` Nicolas Frattaroli
2025-06-09 21:00 ` [PATCH v2 0/2] Cleanup in rockchip_sai.c Mark Brown
2 siblings, 1 reply; 6+ messages in thread
From: Pei Xiao @ 2025-06-06 9:18 UTC (permalink / raw)
To: nicolas.frattaroli, lgirdwood, broonie, perex, tiwai, heiko,
linux-rockchip, linux-sound, linux-arm-kernel, linux-kernel
Cc: Pei Xiao
Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared
and enabled clocks"), devm_clk_get() and clk_prepare_enable() can now be
replaced by devm_clk_get_enabled() when driver enables the clocks for the
whole lifetime of the device. Moreover, it is no longer necessary to
unprepare and disable the clocks explicitly.
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
sound/soc/rockchip/rockchip_sai.c | 35 +++++++++----------------------
1 file changed, 10 insertions(+), 25 deletions(-)
diff --git a/sound/soc/rockchip/rockchip_sai.c b/sound/soc/rockchip/rockchip_sai.c
index 916af63f1c2c..0b9f54102d69 100644
--- a/sound/soc/rockchip/rockchip_sai.c
+++ b/sound/soc/rockchip/rockchip_sai.c
@@ -1427,43 +1427,32 @@ static int rockchip_sai_probe(struct platform_device *pdev)
if (irq > 0) {
ret = devm_request_irq(&pdev->dev, irq, rockchip_sai_isr,
IRQF_SHARED, node->name, sai);
- if (ret) {
+ if (ret)
return dev_err_probe(&pdev->dev, ret,
"Failed to request irq %d\n", irq);
- }
} else {
dev_dbg(&pdev->dev, "Asked for an IRQ but got %d\n", irq);
}
sai->mclk = devm_clk_get(&pdev->dev, "mclk");
- if (IS_ERR(sai->mclk)) {
+ if (IS_ERR(sai->mclk))
return dev_err_probe(&pdev->dev, PTR_ERR(sai->mclk),
"Failed to get mclk\n");
- }
- sai->hclk = devm_clk_get(&pdev->dev, "hclk");
- if (IS_ERR(sai->hclk)) {
+ sai->hclk = devm_clk_get_enabled(&pdev->dev, "hclk");
+ if (IS_ERR(sai->hclk))
return dev_err_probe(&pdev->dev, PTR_ERR(sai->hclk),
"Failed to get hclk\n");
- }
-
- ret = clk_prepare_enable(sai->hclk);
- if (ret)
- return dev_err_probe(&pdev->dev, ret, "Failed to enable hclk\n");
regmap_read(sai->regmap, SAI_VERSION, &sai->version);
ret = rockchip_sai_init_dai(sai, res, &dai);
- if (ret) {
- dev_err(&pdev->dev, "Failed to initialize DAI: %d\n", ret);
- goto err_disable_hclk;
- }
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret, "Failed to initialize DAI\n");
ret = rockchip_sai_parse_paths(sai, node);
- if (ret) {
- dev_err(&pdev->dev, "Failed to parse paths: %d\n", ret);
- goto err_disable_hclk;
- }
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret, "Failed to parse paths\n");
/*
* From here on, all register accesses need to be wrapped in
@@ -1474,10 +1463,8 @@ static int rockchip_sai_probe(struct platform_device *pdev)
devm_pm_runtime_enable(&pdev->dev);
pm_runtime_get_noresume(&pdev->dev);
ret = rockchip_sai_runtime_resume(&pdev->dev);
- if (ret) {
- dev_err(&pdev->dev, "Failed to resume device: %pe\n", ERR_PTR(ret));
- goto err_disable_hclk;
- }
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret, "Failed to resume device\n");
ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
if (ret) {
@@ -1504,8 +1491,6 @@ static int rockchip_sai_probe(struct platform_device *pdev)
/* If we're !CONFIG_PM, we get -ENOSYS and disable manually */
if (pm_runtime_put(&pdev->dev))
rockchip_sai_runtime_suspend(&pdev->dev);
-err_disable_hclk:
- clk_disable_unprepare(sai->hclk);
return ret;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] ASOC: rockchip: fix capture stream handling in rockchip_sai_xfer_stop
2025-06-06 9:18 ` [PATCH v2 1/2] ASOC: rockchip: fix capture stream handling in rockchip_sai_xfer_stop Pei Xiao
@ 2025-06-06 9:48 ` Nicolas Frattaroli
0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Frattaroli @ 2025-06-06 9:48 UTC (permalink / raw)
To: lgirdwood, broonie, perex, tiwai, heiko, linux-rockchip,
linux-sound, linux-arm-kernel, linux-kernel, Pei Xiao
Cc: Pei Xiao
On Friday, 6 June 2025 11:18:21 Central European Summer Time Pei Xiao wrote:
> Correcting the capture stream handling which was incorrectly setting
> playback=true for capture streams.
>
> The original code mistakenly set playback=true for capture streams,
> causing incorrect behavior.
>
> Fixes: cc78d1eaabad ("ASoC: rockchip: add Serial Audio Interface (SAI) driver")
> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
> ---
> sound/soc/rockchip/rockchip_sai.c | 16 +++-------------
> 1 file changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/sound/soc/rockchip/rockchip_sai.c b/sound/soc/rockchip/rockchip_sai.c
> index 602f1ddfad00..916af63f1c2c 100644
> --- a/sound/soc/rockchip/rockchip_sai.c
> +++ b/sound/soc/rockchip/rockchip_sai.c
> @@ -378,19 +378,9 @@ static void rockchip_sai_xfer_start(struct rk_sai_dev *sai, int stream)
> static void rockchip_sai_xfer_stop(struct rk_sai_dev *sai, int stream)
> {
> unsigned int msk = 0, val = 0, clr = 0;
> - bool playback;
> - bool capture;
> -
> - if (stream < 0) {
> - playback = true;
> - capture = true;
> - } else if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
> - playback = true;
> - capture = false;
> - } else {
> - playback = true;
> - capture = false;
> - }
> + bool capture = stream == SNDRV_PCM_STREAM_CAPTURE || stream < 0;
> + bool playback = stream == SNDRV_PCM_STREAM_PLAYBACK || stream < 0;
> + /* could be <= 0 but we don't want to depend on enum values */
>
> if (playback) {
> msk |= SAI_XFER_TXS_MASK;
>
Tested-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Acked-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Thank you!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] ASOC: rockchip: Use helper function devm_clk_get_enabled()
2025-06-06 9:18 ` [PATCH v2 2/2] ASOC: rockchip: Use helper function devm_clk_get_enabled() Pei Xiao
@ 2025-06-06 9:51 ` Nicolas Frattaroli
0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Frattaroli @ 2025-06-06 9:51 UTC (permalink / raw)
To: lgirdwood, broonie, perex, tiwai, heiko, linux-rockchip,
linux-sound, linux-arm-kernel, linux-kernel, Pei Xiao
Cc: Pei Xiao
On Friday, 6 June 2025 11:18:22 Central European Summer Time Pei Xiao wrote:
> Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared
> and enabled clocks"), devm_clk_get() and clk_prepare_enable() can now be
> replaced by devm_clk_get_enabled() when driver enables the clocks for the
> whole lifetime of the device. Moreover, it is no longer necessary to
> unprepare and disable the clocks explicitly.
>
> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
> ---
> sound/soc/rockchip/rockchip_sai.c | 35 +++++++++----------------------
> 1 file changed, 10 insertions(+), 25 deletions(-)
>
> diff --git a/sound/soc/rockchip/rockchip_sai.c b/sound/soc/rockchip/rockchip_sai.c
> index 916af63f1c2c..0b9f54102d69 100644
> --- a/sound/soc/rockchip/rockchip_sai.c
> +++ b/sound/soc/rockchip/rockchip_sai.c
> @@ -1427,43 +1427,32 @@ static int rockchip_sai_probe(struct platform_device *pdev)
> if (irq > 0) {
> ret = devm_request_irq(&pdev->dev, irq, rockchip_sai_isr,
> IRQF_SHARED, node->name, sai);
> - if (ret) {
> + if (ret)
> return dev_err_probe(&pdev->dev, ret,
> "Failed to request irq %d\n", irq);
> - }
> } else {
> dev_dbg(&pdev->dev, "Asked for an IRQ but got %d\n", irq);
> }
>
> sai->mclk = devm_clk_get(&pdev->dev, "mclk");
> - if (IS_ERR(sai->mclk)) {
> + if (IS_ERR(sai->mclk))
> return dev_err_probe(&pdev->dev, PTR_ERR(sai->mclk),
> "Failed to get mclk\n");
> - }
>
> - sai->hclk = devm_clk_get(&pdev->dev, "hclk");
> - if (IS_ERR(sai->hclk)) {
> + sai->hclk = devm_clk_get_enabled(&pdev->dev, "hclk");
> + if (IS_ERR(sai->hclk))
> return dev_err_probe(&pdev->dev, PTR_ERR(sai->hclk),
> "Failed to get hclk\n");
> - }
> -
> - ret = clk_prepare_enable(sai->hclk);
> - if (ret)
> - return dev_err_probe(&pdev->dev, ret, "Failed to enable hclk\n");
>
> regmap_read(sai->regmap, SAI_VERSION, &sai->version);
>
> ret = rockchip_sai_init_dai(sai, res, &dai);
> - if (ret) {
> - dev_err(&pdev->dev, "Failed to initialize DAI: %d\n", ret);
> - goto err_disable_hclk;
> - }
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret, "Failed to initialize DAI\n");
>
> ret = rockchip_sai_parse_paths(sai, node);
> - if (ret) {
> - dev_err(&pdev->dev, "Failed to parse paths: %d\n", ret);
> - goto err_disable_hclk;
> - }
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret, "Failed to parse paths\n");
>
> /*
> * From here on, all register accesses need to be wrapped in
> @@ -1474,10 +1463,8 @@ static int rockchip_sai_probe(struct platform_device *pdev)
> devm_pm_runtime_enable(&pdev->dev);
> pm_runtime_get_noresume(&pdev->dev);
> ret = rockchip_sai_runtime_resume(&pdev->dev);
> - if (ret) {
> - dev_err(&pdev->dev, "Failed to resume device: %pe\n", ERR_PTR(ret));
> - goto err_disable_hclk;
> - }
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret, "Failed to resume device\n");
>
> ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
> if (ret) {
> @@ -1504,8 +1491,6 @@ static int rockchip_sai_probe(struct platform_device *pdev)
> /* If we're !CONFIG_PM, we get -ENOSYS and disable manually */
> if (pm_runtime_put(&pdev->dev))
> rockchip_sai_runtime_suspend(&pdev->dev);
> -err_disable_hclk:
> - clk_disable_unprepare(sai->hclk);
>
> return ret;
> }
>
Acked-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Tested-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Thank you!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/2] Cleanup in rockchip_sai.c
2025-06-06 9:18 [PATCH v2 0/2] Cleanup in rockchip_sai.c Pei Xiao
2025-06-06 9:18 ` [PATCH v2 1/2] ASOC: rockchip: fix capture stream handling in rockchip_sai_xfer_stop Pei Xiao
2025-06-06 9:18 ` [PATCH v2 2/2] ASOC: rockchip: Use helper function devm_clk_get_enabled() Pei Xiao
@ 2025-06-09 21:00 ` Mark Brown
2 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2025-06-09 21:00 UTC (permalink / raw)
To: nicolas.frattaroli, lgirdwood, perex, tiwai, heiko,
linux-rockchip, linux-sound, linux-arm-kernel, linux-kernel,
Pei Xiao
On Fri, 06 Jun 2025 17:18:20 +0800, Pei Xiao wrote:
> 1.Simplify the condition logic in
> 2.Use helper function devm_clk_get_enabled()
>
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/2] ASOC: rockchip: fix capture stream handling in rockchip_sai_xfer_stop
commit: 5dc302d00807b8916992dd25a7a22b78d07dcd03
[2/2] ASOC: rockchip: Use helper function devm_clk_get_enabled()
commit: 03b778d1994827ea5cc971dbdfbb457bbb7bfa5d
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] 6+ messages in thread
end of thread, other threads:[~2025-06-09 21:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-06 9:18 [PATCH v2 0/2] Cleanup in rockchip_sai.c Pei Xiao
2025-06-06 9:18 ` [PATCH v2 1/2] ASOC: rockchip: fix capture stream handling in rockchip_sai_xfer_stop Pei Xiao
2025-06-06 9:48 ` Nicolas Frattaroli
2025-06-06 9:18 ` [PATCH v2 2/2] ASOC: rockchip: Use helper function devm_clk_get_enabled() Pei Xiao
2025-06-06 9:51 ` Nicolas Frattaroli
2025-06-09 21:00 ` [PATCH v2 0/2] Cleanup in rockchip_sai.c 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).