ASoC: xilinx: formatter_pcm: use more devm in probe
Subsystems (4)
PATCH v4 1/1 ASoC: xilinx: formatter_pcm: use more devm in probe
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().
---
v4: use dev_err_probe
v3: rebase.
v2: add signed-off-by. Further clean up some stuff.
sound/soc/xilinx/xlnx_formatter_pcm.c | 79 ++++++++------------------- 1 file changed, 22 insertions(+), 57 deletions(-)
sound/soc/xilinx/xlnx_formatter_pcm.c +22 -57
@@ -81,7 +81,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; };
@@ -595,100 +594,68 @@ 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 ) { aud_drv_data->mm2s_presence = true; ret =xlnx_formatter_pcm_reset (aud_drv_data->mmio +XLNX_MM2S_OFFSET ); -if (ret) { -dev_err (dev,"audio formatter reset failed\n" ); - goto clk_err; - } +if (ret) +return dev_err_probe (dev, ret,"audio formatter reset failed\n" );xlnx_formatter_disable_irqs (aud_drv_data->mmio +XLNX_MM2S_OFFSET ,SNDRV_PCM_STREAM_PLAYBACK ); 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; - } +if (ret) +return ret; }if (val &AUD_CFG_S2MM_MASK ) { aud_drv_data->s2mm_presence = true; ret =xlnx_formatter_pcm_reset (aud_drv_data->mmio +XLNX_S2MM_OFFSET ); -if (ret) { -dev_err (dev,"audio formatter reset failed\n" ); - goto clk_err; - } +if (ret) +return dev_err_probe (dev,"audio formatter reset failed\n" );xlnx_formatter_disable_irqs (aud_drv_data->mmio +XLNX_S2MM_OFFSET ,SNDRV_PCM_STREAM_CAPTURE ); 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; - } +if (ret) +return ret; }dev_set_drvdata (dev, aud_drv_data); - ret =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; +return devm_snd_soc_register_component (dev, &xlnx_asoc_component,NULL ,0 ); }static void xlnx_formatter_pcm_remove (struct platform_device *pdev)
@@ -705,8 +672,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[] = {
Signature · 1 line
2.55.0
Mark Brown
maintainerQuoted 4 lines · Rosen Penev
Use
devm_clk_get_enabled()to let the clock be enabled automatically and cleaned up on unbind, dropping the manualclk_prepare_enable()andclk_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.
This doesn't apply against current code, please check and resend.
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Rosen,
kernel test robot noticed the following build errors:
[auto build test ERROR on v7.2]
[also build test ERROR on linus/master next-20260821] [cannot apply to xilinx-xlnx/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/ASoC-xilinx-formatter_pcm-use-more-devm-in-probe/20260822-220012 base: v7.2 patch link: https://lore.kernel.org/r/20260823050012.17067-1-rosenp%40gmail.com patch subject: [PATCHv4] ASoC: xilinx: formatter_pcm: use more devm in probe config: csky-allmodconfig (https://download.01.org/0day-ci/archive/20260825/[email protected]/config) compiler: csky-linux-gcc (GCC) 16.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260825/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
sound/soc/xilinx/xlnx_formatter_pcm.c: In function 'xlnx_formatter_pcm_probe':
>> sound/soc/xilinx/xlnx_formatter_pcm.c:632:51: error: passing argument 2 of 'dev_err_probe' makes integer from pointer without a cast [-Wint-conversion]
632 | return dev_err_probe(dev, "audio formatter reset failed\n");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| char *
In file included from include/linux/device.h:15,
from include/sound/soc.h:15,
from sound/soc/xilinx/xlnx_formatter_pcm.c:17:
include/linux/dev_printk.h:278:64: note: expected 'int' but argument is of type 'char *'
278 | __printf(3, 4) int dev_err_probe(const struct device *dev, int err, const char *fmt, ...);
| ~~~~^~~
>> sound/soc/xilinx/xlnx_formatter_pcm.c:632:32: error: too few arguments to function 'dev_err_probe'; expected at least 3, have 2
632 | return dev_err_probe(dev, "audio formatter reset failed\n");
| ^~~~~~~~~~~~~
include/linux/dev_printk.h:278:20: note: declared here
278 | __printf(3, 4) int dev_err_probe(const struct device *dev, int err, const char *fmt, ...);
| ^~~~~~~~~~~~~vim +/dev_err_probe +632 sound/soc/xilinx/xlnx_formatter_pcm.c
584
585 static int xlnx_formatter_pcm_probe(struct platform_device *pdev)
586 {
587 int ret;
588 u32 val;
589 struct xlnx_pcm_drv_data *aud_drv_data;
590 struct device *dev = &pdev->dev;
591 struct clk *axi_clk;
592
593 axi_clk = devm_clk_get_enabled(dev, "s_axi_lite_aclk");
594 if (IS_ERR(axi_clk))
595 return dev_err_probe(dev, PTR_ERR(axi_clk), "failed to get s_axi_lite_aclk");
596
597 aud_drv_data = devm_kzalloc(dev, sizeof(*aud_drv_data), GFP_KERNEL);
598 if (!aud_drv_data)
599 return -ENOMEM;
600
601 aud_drv_data->mmio = devm_platform_ioremap_resource(pdev, 0);
602 if (IS_ERR(aud_drv_data->mmio))
603 return PTR_ERR(aud_drv_data->mmio);
604
605 val = readl(aud_drv_data->mmio + XLNX_AUD_CORE_CONFIG);
606 if (val & AUD_CFG_MM2S_MASK) {
607 aud_drv_data->mm2s_presence = true;
608 ret = xlnx_formatter_pcm_reset(aud_drv_data->mmio +
609 XLNX_MM2S_OFFSET);
610 if (ret)
611 return dev_err_probe(dev, ret, "audio formatter reset failed\n");
612 xlnx_formatter_disable_irqs(aud_drv_data->mmio +
613 XLNX_MM2S_OFFSET,
614 SNDRV_PCM_STREAM_PLAYBACK);
615
616 aud_drv_data->mm2s_irq = platform_get_irq_byname(pdev,
617 "irq_mm2s");
618 if (aud_drv_data->mm2s_irq < 0)
619 return aud_drv_data->mm2s_irq;
620
621 ret = devm_request_irq(dev, aud_drv_data->mm2s_irq,
622 xlnx_mm2s_irq_handler, 0,
623 "xlnx_formatter_pcm_mm2s_irq", aud_drv_data);
624 if (ret)
625 return ret;
626 }
627 if (val & AUD_CFG_S2MM_MASK) {
628 aud_drv_data->s2mm_presence = true;
629 ret = xlnx_formatter_pcm_reset(aud_drv_data->mmio +
630 XLNX_S2MM_OFFSET);
631 if (ret)
> 632 return dev_err_probe(dev, "audio formatter reset failed\n"); 633 xlnx_formatter_disable_irqs(aud_drv_data->mmio + 634 XLNX_S2MM_OFFSET, 635 SNDRV_PCM_STREAM_CAPTURE); 636 637 aud_drv_data->s2mm_irq = platform_get_irq_byname(pdev, 638 "irq_s2mm"); 639 if (aud_drv_data->s2mm_irq < 0) 640 return aud_drv_data->s2mm_irq; 641 642 ret = devm_request_irq(dev, aud_drv_data->s2mm_irq, 643 xlnx_s2mm_irq_handler, 0, 644 "xlnx_formatter_pcm_s2mm_irq", 645 aud_drv_data);
646 if (ret)
647 return ret;
648 }
649
650 dev_set_drvdata(dev, aud_drv_data);
651
652 return devm_snd_soc_register_component(dev, &xlnx_asoc_component, NULL, 0);
653 }
654
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Quoted 8 lines · Mark Brown
Quoted 4 lines · Rosen Penev
Use
devm_clk_get_enabled()to let the clock be enabled automatically and cleaned up on unbind, dropping the manualclk_prepare_enable()andclk_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.This doesn't apply against current code, please check and resend.
I resent a version that I checked against master as well as linux-next.
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Rosen,
kernel test robot noticed the following build errors:
[auto build test ERROR on v7.2]
[also build test ERROR on linus/master next-20260821] [cannot apply to xilinx-xlnx/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/ASoC-xilinx-formatter_pcm-use-more-devm-in-probe/20260822-220012 base: v7.2 patch link: https://lore.kernel.org/r/20260823050012.17067-1-rosenp%40gmail.com patch subject: [PATCHv4] ASoC: xilinx: formatter_pcm: use more devm in probe config: arm64-randconfig-002-20260825 (https://download.01.org/0day-ci/archive/20260825/[email protected]/config) compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 935bfc708590c60147a79c7df145bb6e68b1d388) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260825/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> sound/soc/xilinx/xlnx_formatter_pcm.c:632:62: error: too few arguments to function call, expected at least 3, have 2
632 | return dev_err_probe(dev, "audio formatter reset failed\n");
| ~~~~~~~~~~~~~ ^
include/linux/dev_printk.h:278:20: note: 'dev_err_probe' declared here
278 | __printf(3, 4) int dev_err_probe(const struct device *dev, int err, const char *fmt, ...);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1 error generated.
vim +632 sound/soc/xilinx/xlnx_formatter_pcm.c
584
585 static int xlnx_formatter_pcm_probe(struct platform_device *pdev)
586 {
587 int ret;
588 u32 val;
589 struct xlnx_pcm_drv_data *aud_drv_data;
590 struct device *dev = &pdev->dev;
591 struct clk *axi_clk;
592
593 axi_clk = devm_clk_get_enabled(dev, "s_axi_lite_aclk");
594 if (IS_ERR(axi_clk))
595 return dev_err_probe(dev, PTR_ERR(axi_clk), "failed to get s_axi_lite_aclk");
596
597 aud_drv_data = devm_kzalloc(dev, sizeof(*aud_drv_data), GFP_KERNEL);
598 if (!aud_drv_data)
599 return -ENOMEM;
600
601 aud_drv_data->mmio = devm_platform_ioremap_resource(pdev, 0);
602 if (IS_ERR(aud_drv_data->mmio))
603 return PTR_ERR(aud_drv_data->mmio);
604
605 val = readl(aud_drv_data->mmio + XLNX_AUD_CORE_CONFIG);
606 if (val & AUD_CFG_MM2S_MASK) {
607 aud_drv_data->mm2s_presence = true;
608 ret = xlnx_formatter_pcm_reset(aud_drv_data->mmio +
609 XLNX_MM2S_OFFSET);
610 if (ret)
611 return dev_err_probe(dev, ret, "audio formatter reset failed\n");
612 xlnx_formatter_disable_irqs(aud_drv_data->mmio +
613 XLNX_MM2S_OFFSET,
614 SNDRV_PCM_STREAM_PLAYBACK);
615
616 aud_drv_data->mm2s_irq = platform_get_irq_byname(pdev,
617 "irq_mm2s");
618 if (aud_drv_data->mm2s_irq < 0)
619 return aud_drv_data->mm2s_irq;
620
621 ret = devm_request_irq(dev, aud_drv_data->mm2s_irq,
622 xlnx_mm2s_irq_handler, 0,
623 "xlnx_formatter_pcm_mm2s_irq", aud_drv_data);
624 if (ret)
625 return ret;
626 }
627 if (val & AUD_CFG_S2MM_MASK) {
628 aud_drv_data->s2mm_presence = true;
629 ret = xlnx_formatter_pcm_reset(aud_drv_data->mmio +
630 XLNX_S2MM_OFFSET);
631 if (ret)
> 632 return dev_err_probe(dev, "audio formatter reset failed\n"); 633 xlnx_formatter_disable_irqs(aud_drv_data->mmio + 634 XLNX_S2MM_OFFSET, 635 SNDRV_PCM_STREAM_CAPTURE); 636 637 aud_drv_data->s2mm_irq = platform_get_irq_byname(pdev, 638 "irq_s2mm"); 639 if (aud_drv_data->s2mm_irq < 0) 640 return aud_drv_data->s2mm_irq; 641 642 ret = devm_request_irq(dev, aud_drv_data->s2mm_irq, 643 xlnx_s2mm_irq_handler, 0, 644 "xlnx_formatter_pcm_s2mm_irq", 645 aud_drv_data);
646 if (ret)
647 return ret;
648 }
649
650 dev_set_drvdata(dev, aud_drv_data);
651
652 return devm_snd_soc_register_component(dev, &xlnx_asoc_component, NULL, 0);
653 }
654
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki