Re: [PATCH v5 4/4] ASoC: airoha: Add AFE and machine driver for Airoha AN7581
From: Christian Marangi
Date: Fri Aug 07 2026 - 18:57:44 EST
On Fri, Aug 07, 2026 at 11:52:58PM +0100, Mark Brown wrote:
> 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.
>
Sooo you are suggesting 3 patch? one for machine, one for basic pcm and one
for etdm?
> > +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.
>
Nono these were just my mistake with moving code... I already fixed them...
sorry for the mistake.
> > + /* 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.
Sorry this was asked to be moved in the previous revision by another
review. I will revert following the pattern done in other AFE driver...
--
Ansuel