From: Rosen Penev <rosenp@gmail.com>
To: linux-sound@vger.kernel.org
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
Michal Simek <michal.simek@amd.com>,
linux-arm-kernel@lists.infradead.org (moderated list:ARM/ZYNQ
ARCHITECTURE), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] ASoC: xilinx: formatter_pcm: use devm_clk_get_enabled and simplify probe
Date: Thu, 6 Aug 2026 16:38:12 -0700 [thread overview]
Message-ID: <20260806233812.31851-1-rosenp@gmail.com> (raw)
Use devm_clk_get_enabled() to let the clock be enabled automatically
and cleaned up on unbind, dropping the manual clk_prepare_enable() and
clk_disable_unprepare() calls in probe and remove.
Simplify the probe error paths by returning directly instead of
jumping to clk_err, and use devm_snd_soc_register_component() return
value directly.
Assisted-by: opencode:deepseek-v4-flash-free
---
sound/soc/xilinx/xlnx_formatter_pcm.c | 47 ++++++++-------------------
1 file changed, 13 insertions(+), 34 deletions(-)
diff --git a/sound/soc/xilinx/xlnx_formatter_pcm.c b/sound/soc/xilinx/xlnx_formatter_pcm.c
index b50306b0fc06..948bc604738a 100644
--- a/sound/soc/xilinx/xlnx_formatter_pcm.c
+++ b/sound/soc/xilinx/xlnx_formatter_pcm.c
@@ -593,24 +593,17 @@ static int xlnx_formatter_pcm_probe(struct platform_device *pdev)
if (!aud_drv_data)
return -ENOMEM;
- aud_drv_data->axi_clk = devm_clk_get(dev, "s_axi_lite_aclk");
+ aud_drv_data->axi_clk = devm_clk_get_enabled(dev, "s_axi_lite_aclk");
if (IS_ERR(aud_drv_data->axi_clk)) {
ret = PTR_ERR(aud_drv_data->axi_clk);
dev_err(dev, "failed to get s_axi_lite_aclk(%d)\n", ret);
return ret;
}
- ret = clk_prepare_enable(aud_drv_data->axi_clk);
- if (ret) {
- dev_err(dev,
- "failed to enable s_axi_lite_aclk(%d)\n", ret);
- return ret;
- }
aud_drv_data->mmio = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(aud_drv_data->mmio)) {
dev_err(dev, "audio formatter ioremap failed\n");
- ret = PTR_ERR(aud_drv_data->mmio);
- goto clk_err;
+ return PTR_ERR(aud_drv_data->mmio);
}
val = readl(aud_drv_data->mmio + XLNX_AUD_CORE_CONFIG);
@@ -620,7 +613,7 @@ static int xlnx_formatter_pcm_probe(struct platform_device *pdev)
XLNX_MM2S_OFFSET);
if (ret) {
dev_err(dev, "audio formatter reset failed\n");
- goto clk_err;
+ return ret;
}
xlnx_formatter_disable_irqs(aud_drv_data->mmio +
XLNX_MM2S_OFFSET,
@@ -628,16 +621,15 @@ static int xlnx_formatter_pcm_probe(struct platform_device *pdev)
aud_drv_data->mm2s_irq = platform_get_irq_byname(pdev,
"irq_mm2s");
- if (aud_drv_data->mm2s_irq < 0) {
- ret = aud_drv_data->mm2s_irq;
- goto clk_err;
- }
+ if (aud_drv_data->mm2s_irq < 0)
+ return aud_drv_data->mm2s_irq;
+
ret = devm_request_irq(dev, aud_drv_data->mm2s_irq,
xlnx_mm2s_irq_handler, 0,
"xlnx_formatter_pcm_mm2s_irq", aud_drv_data);
if (ret) {
dev_err(dev, "xlnx audio mm2s irq request failed\n");
- goto clk_err;
+ return ret;
}
}
if (val & AUD_CFG_S2MM_MASK) {
@@ -646,7 +638,7 @@ static int xlnx_formatter_pcm_probe(struct platform_device *pdev)
XLNX_S2MM_OFFSET);
if (ret) {
dev_err(dev, "audio formatter reset failed\n");
- goto clk_err;
+ return ret;
}
xlnx_formatter_disable_irqs(aud_drv_data->mmio +
XLNX_S2MM_OFFSET,
@@ -654,34 +646,23 @@ static int xlnx_formatter_pcm_probe(struct platform_device *pdev)
aud_drv_data->s2mm_irq = platform_get_irq_byname(pdev,
"irq_s2mm");
- if (aud_drv_data->s2mm_irq < 0) {
- ret = aud_drv_data->s2mm_irq;
- goto clk_err;
- }
+ if (aud_drv_data->s2mm_irq < 0)
+ return aud_drv_data->s2mm_irq;
+
ret = devm_request_irq(dev, aud_drv_data->s2mm_irq,
xlnx_s2mm_irq_handler, 0,
"xlnx_formatter_pcm_s2mm_irq",
aud_drv_data);
if (ret) {
dev_err(dev, "xlnx audio s2mm irq request failed\n");
- goto clk_err;
+ return ret;
}
}
dev_set_drvdata(dev, aud_drv_data);
- ret = devm_snd_soc_register_component(dev, &xlnx_asoc_component,
+ return devm_snd_soc_register_component(dev, &xlnx_asoc_component,
NULL, 0);
- if (ret) {
- dev_err(dev, "pcm platform device register failed\n");
- goto clk_err;
- }
-
- return 0;
-
-clk_err:
- clk_disable_unprepare(aud_drv_data->axi_clk);
- return ret;
}
static void xlnx_formatter_pcm_remove(struct platform_device *pdev)
@@ -698,8 +679,6 @@ static void xlnx_formatter_pcm_remove(struct platform_device *pdev)
if (ret)
dev_err(&pdev->dev, "audio formatter reset failed\n");
-
- clk_disable_unprepare(adata->axi_clk);
}
static const struct of_device_id xlnx_formatter_pcm_of_match[] = {
--
2.55.0
next reply other threads:[~2026-08-06 23:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 23:38 Rosen Penev [this message]
2026-08-06 23:43 ` [PATCH] ASoC: xilinx: formatter_pcm: use devm_clk_get_enabled and simplify probe Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260806233812.31851-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=vincenzo.frascino@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox