[PATCH v5 4/4] ASoC: airoha: Add AFE and machine driver for Airoha AN7581
Mark Brown
broonie at kernel.org
Fri Aug 7 15:52:58 PDT 2026
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20260807/654a104c/attachment.sig>
More information about the linux-arm-kernel
mailing list