devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Maso Huang (黃加竹)" <Maso.Huang@mediatek.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"Trevor Wu (吳文良)" <Trevor.Wu@mediatek.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"Allen-KH Cheng (程冠勳)" <Allen-KH.Cheng@mediatek.com>,
	"broonie@kernel.org" <broonie@kernel.org>,
	"renzhijie2@huawei.com" <renzhijie2@huawei.com>,
	"conor+dt@kernel.org" <conor+dt@kernel.org>,
	"tiwai@suse.com" <tiwai@suse.com>,
	"Claudiu.Beznea@microchip.com" <Claudiu.Beznea@microchip.com>,
	"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"krzysztof.kozlowski+dt@linaro.org"
	<krzysztof.kozlowski+dt@linaro.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"perex@perex.cz" <perex@perex.cz>,
	"Jiaxin Yu (俞家鑫)" <Jiaxin.Yu@mediatek.com>,
	"angelogioacchino.delregno@collabora.com"
	<angelogioacchino.delregno@collabora.com>,
	"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>
Subject: Re: [PATCH v2 4/7] ASoC: mediatek: mt7986: add platform driver
Date: Tue, 27 Jun 2023 06:25:01 +0000	[thread overview]
Message-ID: <eca820ecc0966f884e997bc26fbf3039f7db5b1f.camel@mediatek.com> (raw)
In-Reply-To: <fb1aa025-5314-b4c4-25ed-1efbbacbdc3b@microchip.com>

On Tue, 2023-06-27 at 04:43 +0000, Claudiu.Beznea@microchip.com wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  On 26.06.2023 05:34, Maso Huang wrote:
> > +static int mt7986_afe_pcm_dev_probe(struct platform_device *pdev)
> > +{
> > +       struct mtk_base_afe *afe;
> > +       struct mt7986_afe_private *afe_priv;
> > +       struct device *dev;
> > +       int i, irq_id, ret;
> > +
> > +       afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL);
> > +       if (!afe)
> > +               return -ENOMEM;
> > +       platform_set_drvdata(pdev, afe);
> > +
> > +       afe->platform_priv = devm_kzalloc(&pdev->dev,
> sizeof(*afe_priv),
> > +                                         GFP_KERNEL);
> > +       if (!afe->platform_priv)
> > +               return -ENOMEM;
> > +
> > +       afe_priv = afe->platform_priv;
> > +       afe->dev = &pdev->dev;
> > +       dev = afe->dev;
> > +
> > +       afe->base_addr = devm_platform_ioremap_resource(pdev, 0);
> > +       if (IS_ERR(afe->base_addr))
> > +               return PTR_ERR(afe->base_addr);
> > +
> > +       /* initial audio related clock */
> > +       ret = mt7986_init_clock(afe);
> > +       if (ret)
> > +               return dev_err_probe(dev, ret, "Cannot initialize
> clocks\n");
> > +
> > +       ret = devm_pm_runtime_enable(dev);
> > +       if (ret)
> > +               return ret;
> > +
> > +       /* enable clock for regcache get default value from hw */
> > +       afe_priv->pm_runtime_bypass_reg_ctl = true;
> > +       pm_runtime_get_sync(&pdev->dev);
> > +
> > +       afe->regmap = devm_regmap_init_mmio(&pdev->dev, afe-
> >base_addr,
> > +                     &mt7986_afe_regmap_config);
> > +       if (IS_ERR(afe->regmap)) {
> > +               ret = PTR_ERR(afe->regmap);
> > +               goto err_pm_disable;
> > +       }
> > +
> > +       pm_runtime_put_sync(&pdev->dev);
> 
> You already did here a put thus (see below)
> 
> > +       afe_priv->pm_runtime_bypass_reg_ctl = false;
> > +
> > +       /* init memif */
> > +       afe->memif_size = MT7986_MEMIF_NUM;
> > +       afe->memif = devm_kcalloc(dev, afe->memif_size,
> sizeof(*afe->memif),
> > +                                 GFP_KERNEL);
> > +       if (!afe->memif)
> > +               goto err_pm_disable;
> > +
> > +       for (i = 0; i < afe->memif_size; i++) {
> > +               afe->memif[i].data = &memif_data[i];
> > +               afe->memif[i].irq_usage = -1;
> > +       }
> > +
> > +       mutex_init(&afe->irq_alloc_lock);
> > +
> > +       /* irq initialize */
> > +       afe->irqs_size = MT7986_IRQ_NUM;
> > +       afe->irqs = devm_kcalloc(dev, afe->irqs_size, sizeof(*afe-
> >irqs),
> > +                                GFP_KERNEL);
> > +       if (!afe->irqs)
> > +               goto err_pm_disable;
> > +
> > +       for (i = 0; i < afe->irqs_size; i++)
> > +               afe->irqs[i].irq_data = &irq_data[i];
> > +
> > +       /* request irq */
> > +       irq_id = platform_get_irq(pdev, 0);
> > +       if (irq_id < 0) {
> > +               dev_err(dev, "%pOFn no irq found\n", dev->of_node);
> > +               ret = irq_id;
> > +               goto err_pm_disable;
> > +       }
> > +       ret = devm_request_irq(dev, irq_id, mt7986_afe_irq_handler,
> > +                              IRQF_TRIGGER_NONE, "asys-isr", (void
> *)afe);
> > +       if (ret) {
> > +               dev_err(dev, "could not request_irq for asys-
> isr\n");
> > +               goto err_pm_disable;
> > +       }
> > +
> > +       /* init sub_dais */
> > +       INIT_LIST_HEAD(&afe->sub_dais);
> > +
> > +       for (i = 0; i < ARRAY_SIZE(dai_register_cbs); i++) {
> > +               ret = dai_register_cbs[i](afe);
> > +               if (ret) {
> > +                       dev_err(afe->dev, "dai register i %d fail,
> ret %d\n",
> > +                                i, ret);
> > +                       goto err_pm_disable;
> > +               }
> > +       }
> > +
> > +       /* init dai_driver and component_driver */
> > +       ret = mtk_afe_combine_sub_dai(afe);
> > +       if (ret) {
> > +               dev_err(afe->dev, "mtk_afe_combine_sub_dai fail,
> ret %d\n",
> > +                        ret);
> > +               goto err_pm_disable;
> > +       }
> > +
> > +       afe->mtk_afe_hardware = &mt7986_afe_hardware;
> > +       afe->memif_fs = mt7986_memif_fs;
> > +       afe->irq_fs = mt7986_irq_fs;
> > +
> > +       afe->runtime_resume = mt7986_afe_runtime_resume;
> > +       afe->runtime_suspend = mt7986_afe_runtime_suspend;
> > +
> > +       /* register component */
> > +       ret = devm_snd_soc_register_component(&pdev->dev,
> >
> +                                             &mt7986_afe_component,
> > +                                             NULL, 0);
> > +       if (ret) {
> > +               dev_warn(dev, "err_platform\n");
> > +               goto err_pm_disable;
> > +       }
> > +
> > +       ret = devm_snd_soc_register_component(afe->dev,
> >
> +                                             &mt7986_afe_pcm_dai_com
> ponent,
> > +                                             afe->dai_drivers,
> > +                                             afe-
> >num_dai_drivers);
> > +       if (ret) {
> > +               dev_warn(dev, "err_dai_component\n");
> > +               goto err_pm_disable;
> > +       }
> > +
> > +       return ret;
> > +
> > +err_pm_disable:
> > +       pm_runtime_put_sync(&pdev->dev);
> 
> these should be no need for this one here.
> 

Hi Claudiu,
Thanks for your review.
This is for (IS_ERR(afe->regmap)) error handling.
May I just remove this one? or any other suggestion?

Thanks,
Maso

> > +       pm_runtime_disable(&pdev->dev);
> 
> This is also covered by devm_pm_runtime_enable().
> 
> > +       return ret;
> > +}
> 
> 

  reply	other threads:[~2023-06-27  6:25 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-26  2:34 [PATCH v2 0/7] ASoC: mediatek: Add support for MT7986 SoC Maso Huang
2023-06-26  2:34 ` [PATCH v2 1/7] ASoC: mediatek: mt7986: add common header Maso Huang
2023-07-04  9:01   ` AngeloGioacchino Del Regno
2023-07-05  7:58     ` Maso Huang (黃加竹)
2023-06-26  2:34 ` [PATCH v2 2/7] ASoC: mediatek: mt7986: support audio clock control Maso Huang
2023-06-27  4:37   ` Claudiu.Beznea
2023-07-04  8:53   ` AngeloGioacchino Del Regno
2023-07-05  7:52     ` Maso Huang (黃加竹)
2023-06-26  2:34 ` [PATCH v2 3/7] ASoC: mediatek: mt7986: support etdm in platform driver Maso Huang
2023-07-04  8:58   ` AngeloGioacchino Del Regno
2023-07-05  7:57     ` Maso Huang (黃加竹)
2023-06-26  2:34 ` [PATCH v2 4/7] ASoC: mediatek: mt7986: add " Maso Huang
2023-06-27  4:43   ` Claudiu.Beznea
2023-06-27  6:25     ` Maso Huang (黃加竹) [this message]
2023-07-04  9:13   ` AngeloGioacchino Del Regno
2023-07-05  8:03     ` Maso Huang (黃加竹)
2023-07-13  7:44       ` Maso Huang (黃加竹)
2023-06-26  2:34 ` [PATCH v2 5/7] ASoC: mediatek: mt7986: add machine driver with wm8960 Maso Huang
2023-06-26  2:35 ` [PATCH v2 6/7] ASoC: dt-bindings: mediatek,mt7986-wm8960: add mt7986-wm8960 document Maso Huang
2023-06-29 14:58   ` Rob Herring
2023-06-30  9:29     ` Maso Huang (黃加竹)
2023-06-26  2:35 ` [PATCH v2 7/7] ASoC: dt-bindings: mediatek,mt7986-afe: add audio afe document Maso Huang
2023-06-29 15:05   ` Rob Herring
2023-06-30  2:26     ` Maso Huang (黃加竹)
2023-07-24  6:17 ` [PATCH v2 0/7] ASoC: mediatek: Add support for MT7986 SoC Maso Huang (黃加竹)
2023-07-24  7:25   ` Krzysztof Kozlowski

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=eca820ecc0966f884e997bc26fbf3039f7db5b1f.camel@mediatek.com \
    --to=maso.huang@mediatek.com \
    --cc=Allen-KH.Cheng@mediatek.com \
    --cc=Claudiu.Beznea@microchip.com \
    --cc=Jiaxin.Yu@mediatek.com \
    --cc=Trevor.Wu@mediatek.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=perex@perex.cz \
    --cc=renzhijie2@huawei.com \
    --cc=robh+dt@kernel.org \
    --cc=tiwai@suse.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;
as well as URLs for NNTP newsgroup(s).