From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
To: Rosen Penev <rosenp@gmail.com>
Cc: linux-sound@vger.kernel.org,
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: Re: [PATCHv3] ASoC: xilinx: formatter_pcm: use more devm in probe
Date: Tue, 18 Aug 2026 15:03:05 -0700 [thread overview]
Message-ID: <20260818150305.00000a2d@oss.qualcomm.com> (raw)
In-Reply-To: <20260814204428.37786-1-rosenp@gmail.com>
On Fri, 14 Aug 2026 13:44:28 -0700
Rosen Penev <rosenp@gmail.com> wrote:
> 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. As a result, move the
> clk struct member into probe, which is the only place it's used.
>
> Simplify the probe error paths by returning directly instead of
> jumping to clk_err, and use devm_snd_soc_register_component() return
> value directly. Also remove error message from ioremap as it throws one
> itself. Same with devm_request_irq().
>
> Assisted-by: opencode:deepseek-v4-flash-free
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> Reviewed-by: Michal Simek <michal.simek@amd.com>
> Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
> v3: rebase.
> v2: add signed-off-by. Further clean up some stuff.
> sound/soc/xilinx/xlnx_formatter_pcm.c | 71 ++++++++-------------------
> 1 file changed, 20 insertions(+), 51 deletions(-)
>
> diff --git a/sound/soc/xilinx/xlnx_formatter_pcm.c b/sound/soc/xilinx/xlnx_formatter_pcm.c
> index 3d6f1e4046d8..5f63fb28ea5f 100644
> --- a/sound/soc/xilinx/xlnx_formatter_pcm.c
> +++ b/sound/soc/xilinx/xlnx_formatter_pcm.c
> @@ -82,7 +82,6 @@ struct xlnx_pcm_drv_data {
> int mm2s_irq;
> struct snd_pcm_substream *play_stream;
> struct snd_pcm_substream *capture_stream;
> - struct clk *axi_clk;
> unsigned int sysclk;
> };
>
> @@ -596,30 +595,19 @@ static int xlnx_formatter_pcm_probe(struct platform_device *pdev)
> u32 val;
> struct xlnx_pcm_drv_data *aud_drv_data;
> struct device *dev = &pdev->dev;
> + struct clk *axi_clk;
> +
> + axi_clk = devm_clk_get_enabled(dev, "s_axi_lite_aclk");
> + if (IS_ERR(axi_clk))
> + return dev_err_probe(dev, PTR_ERR(axi_clk), "failed to get s_axi_lite_aclk");
>
> aud_drv_data = devm_kzalloc(dev, sizeof(*aud_drv_data), GFP_KERNEL);
> if (!aud_drv_data)
> return -ENOMEM;
>
> - aud_drv_data->axi_clk = devm_clk_get(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;
> - }
> + if (IS_ERR(aud_drv_data->mmio))
> + return PTR_ERR(aud_drv_data->mmio);
>
> val = readl(aud_drv_data->mmio + XLNX_AUD_CORE_CONFIG);
> if (val & AUD_CFG_MM2S_MASK) {
> @@ -628,7 +616,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;
Why not dev_err_probe() for this one? Even though maybe deferred handling
isn't useful here (I haven't checked) it still gives more compact code.
> }
> xlnx_formatter_disable_irqs(aud_drv_data->mmio +
> XLNX_MM2S_OFFSET,
..
> if (val & AUD_CFG_S2MM_MASK) {
> aud_drv_data->s2mm_presence = true;
> @@ -654,7 +639,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;
As above, I'd go return dev_err_probe() everywhere you now return due to
the other cleanups.
> }
> xlnx_formatter_disable_irqs(aud_drv_data->mmio +
prev parent reply other threads:[~2026-08-18 22:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 20:44 [PATCHv3] ASoC: xilinx: formatter_pcm: use more devm in probe Rosen Penev
2026-08-18 22:03 ` Jonathan Cameron [this message]
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=20260818150305.00000a2d@oss.qualcomm.com \
--to=jonathan.cameron@oss.qualcomm.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=rosenp@gmail.com \
--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