Re: [PATCH v5 4/4] ASoC: airoha: Add AFE and machine driver for Airoha AN7581
Mark Brown <[email protected]> Fri, 7 Aug 2026 23:52:58 +0100
| Newsgroups | org.infradead.lists.linux-mediatek,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel,org.kernel.vger.linux-sound |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Aug 07, 2026 at 10:09:34PM +0200, Christian Marangi wrote:
> Add support for the Sound system present on Airoha AN7581 SoC. This is
> based on the mediatek AFE drivers.
> Also add the machine driver to create an actual sound card for the AFE.
This should be more patches, the machine driver should be a separate
patch at a minimum. Possibly PCM and ETDM drivers too.
> +static int an7581_afe_pcm_dev_probe(struct platform_device *pdev)
> +{
> + struct an7581_afe_private *afe_priv;
> + struct reset_control *reset;
> + struct mtk_base_afe *afe;
> + struct device *dev;
> + int i, irq_id, ret;
> + void *base;
> +
> + afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL);
> + if (!afe)
> + return -ENOMEM;
We allocate afe here with devm_kzalloc() so everything is zero...
> + afe->irqs = devm_kcalloc(dev, afe->irqs_size, sizeof(*afe->irqs),
> + GFP_KERNEL);
> + if (!afe->irqs)
> + return -ENOMEM;
...then we allocate an array using a size read from the struct which must
therefore have zero elements. We also didn't assign dev, either we
should assign it and use it consistently or we should drop it and use
&pdev->dev like the first allocation.
> + /* register component */
> + ret = devm_snd_soc_register_component(&pdev->dev,
> + &mtk_afe_pcm_platform,
> + NULL, 0);
> + if (ret)
> + return dev_err_probe(dev, ret, "Cannot register AFE component\n");
> +
> + ret = devm_snd_soc_register_component(afe->dev,
> + &an7581_afe_pcm_dai_component,
> + afe->dai_drivers,
> + afe->num_dai_drivers);
> + if (ret)
> + return dev_err_probe(dev, ret, "Cannot register PCM DAI component\n");
> +
> + platform_set_drvdata(pdev, afe);
The component registration might result in a card being instantiated so
we need the driver data initialized before we try to register.
signature.asc
(application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmp2YcoACgkQJNaLcl1U h9ARiwf+LpDqvrfwUmAxX0QX50R8ii4KPIXyv5I0qvKJZcQ4j3ofe+outq7w/7zh nJsC2gzVvtmzP7LOx3TdiR4pj1w2uRSI9ymg2rKoU05VzD3CEIjNtm/YIqPbd8cR T4WQlImD5NQ9K7U0NgP1N+y7uX8r0QMikrRUMiw6k/D8CzaSsmZ6fCL8RQq0ge6O oUJqMGcsdRn5x4ppuwy4y8FIn/Z73xEoAHWTQrf6jtLPBM8f++3t66ULaDKhwf+L +uflmWRcVPBtXHGwQaqYImTilXTk6wYVmMqj7OBEuLnKiHyYN5bA4Lm53gbqUBE4 9Utlm+txNJsPR3uhLbGfxdFrZ3+lQw== =/wv4 -----END PGP SIGNATURE-----