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>,
"chenxiangrui@huaqin.corp-partner.google.com"
<chenxiangrui@huaqin.corp-partner.google.com>,
"Trevor Wu (吳文良)" <Trevor.Wu@mediatek.com>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"Allen-KH Cheng (程冠勲)" <Allen-KH.Cheng@mediatek.com>,
"broonie@kernel.org" <broonie@kernel.org>,
"conor+dt@kernel.org" <conor+dt@kernel.org>,
"tiwai@suse.com" <tiwai@suse.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>,
"arnd@arndb.de" <arnd@arndb.de>,
"angelogioacchino.delregno@collabora.com"
<angelogioacchino.delregno@collabora.com>,
"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>
Subject: Re: [PATCH v3 4/6] ASoC: mediatek: mt7986: add machine driver with wm8960
Date: Mon, 31 Jul 2023 06:50:37 +0000 [thread overview]
Message-ID: <fe11acb200695cb6049371899d00de37c18772c3.camel@mediatek.com> (raw)
In-Reply-To: <3cd43731-a49e-e751-2839-84708333a0e2@collabora.com>
On Fri, 2023-07-28 at 11:52 +0200, AngeloGioacchino Del Regno wrote:
> Il 28/07/23 11:49, AngeloGioacchino Del Regno ha scritto:
> > Il 28/07/23 11:08, Maso Huang ha scritto:
> > > Add support for mt7986 board with wm8960.
> > >
> > > Signed-off-by: Maso Huang <maso.huang@mediatek.com>
> > > ---
> > > sound/soc/mediatek/Kconfig | 10 ++
> > > sound/soc/mediatek/mt7986/Makefile | 1 +
> > > sound/soc/mediatek/mt7986/mt7986-wm8960.c | 184
> > > ++++++++++++++++++++++
> > > 3 files changed, 195 insertions(+)
> > > create mode 100644 sound/soc/mediatek/mt7986/mt7986-wm8960.c
> > >
> > > diff --git a/sound/soc/mediatek/Kconfig
> > > b/sound/soc/mediatek/Kconfig
> > > index 558827755a8d..8d1bc8814486 100644
> > > --- a/sound/soc/mediatek/Kconfig
> > > +++ b/sound/soc/mediatek/Kconfig
> > > @@ -64,6 +64,16 @@ config SND_SOC_MT7986
> > > Select Y if you have such device.
> > > If unsure select "N".
> > > +config SND_SOC_MT7986_WM8960
> > > + tristate "ASoc Audio driver for MT7986 with WM8960 codec"
> > > + depends on SND_SOC_MT7986 && I2C
> > > + select SND_SOC_WM8960
> > > + help
> > > + This adds support for ASoC machine driver for MediaTek
> > > MT7986
> > > + boards with the WM8960 codecs.
> > > + Select Y if you have such device.
> > > + If unsure select "N".
> > > +
> > > config SND_SOC_MT8173
> > > tristate "ASoC support for Mediatek MT8173 chip"
> > > depends on ARCH_MEDIATEK
> > > diff --git a/sound/soc/mediatek/mt7986/Makefile
> > > b/sound/soc/mediatek/mt7986/Makefile
> > > index de0742a67cae..fc4c82559b29 100644
> > > --- a/sound/soc/mediatek/mt7986/Makefile
> > > +++ b/sound/soc/mediatek/mt7986/Makefile
> > > @@ -6,3 +6,4 @@ snd-soc-mt7986-afe-objs := \
> > > mt7986-dai-etdm.o
> > > obj-$(CONFIG_SND_SOC_MT7986) += snd-soc-mt7986-afe.o
> > > +obj-$(CONFIG_SND_SOC_MT7986_WM8960) += mt7986-wm8960.o
> > > diff --git a/sound/soc/mediatek/mt7986/mt7986-wm8960.c
> > > b/sound/soc/mediatek/mt7986/mt7986-wm8960.c
> > > new file mode 100644
> > > index 000000000000..a880fcb8662e
> > > --- /dev/null
> > > +++ b/sound/soc/mediatek/mt7986/mt7986-wm8960.c
> >
> > ..snip..
> >
> > > +static int mt7986_wm8960_machine_probe(struct platform_device
> > > *pdev)
> > > +{
> > > + struct snd_soc_card *card = &mt7986_wm8960_card;
> > > + struct snd_soc_dai_link *dai_link;
> > > + struct mt7986_wm8960_priv *priv;
> > > + int ret, i;
> > > +
> > > + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> > > + if (!priv)
> > > + return -ENOMEM;
> > > +
> > > + priv->platform_node = of_parse_phandle(pdev->dev.of_node,
> > > + "mediatek,platform", 0);
> > > + if (!priv->platform_node) {
> > > + dev_err(&pdev->dev, "Property 'platform' missing or
> > > invalid\n");
> > > + return -EINVAL;
> > > + }
> > > +
> > > + for_each_card_prelinks(card, i, dai_link) {
> > > + if (dai_link->platforms->name)
> > > + continue;
> > > + dai_link->platforms->of_node = priv->platform_node;
> > > + }
> > > +
> > > + card->dev = &pdev->dev;
> > > +
> > > + priv->codec_node = of_parse_phandle(pdev->dev.of_node,
> > > + "mediatek,audio-codec", 0);
> > > + if (!priv->codec_node) {
> > > + dev_err(&pdev->dev,
> > > + "Property 'audio-codec' missing or invalid\n");
> > > + of_node_put(priv->platform_node);
> > > + return -EINVAL;
> > > + }
> > > +
> > > + for_each_card_prelinks(card, i, dai_link) {
> > > + if (dai_link->codecs->name)
> > > + continue;
> > > + dai_link->codecs->of_node = priv->codec_node;
> > > + }
> > > +
> > > + ret = snd_soc_of_parse_audio_routing(card, "audio-routing");
> > > + if (ret) {
> > > + dev_err(&pdev->dev, "failed to parse audio-routing:
> > > %d\n", ret);
> > > + goto err_of_node_put;
> > > + }
> > > +
> > > + ret = devm_snd_soc_register_card(&pdev->dev, card);
> > > + if (ret) {
> > > + dev_err(&pdev->dev, "%s snd_soc_register_card fail
> > > %d\n",
> > > + __func__, ret);
> > > + goto err_of_node_put;
> > > + }
> > > +
> > > +err_of_node_put:
> > > + of_node_put(priv->codec_node);
> > > + of_node_put(priv->platform_node);
> > > + return ret;
> > > +}
> > > +
> > > +static void mt7986_wm8960_machine_remove(struct platform_device
> > > *pdev)
> > > +{
> > > + struct snd_soc_card *card = platform_get_drvdata(pdev);
> > > + struct mt7986_wm8960_priv *priv =
> > > snd_soc_card_get_drvdata(card);
> > > +
> > > + of_node_put(priv->codec_node);
> > > + of_node_put(priv->platform_node);
> > > +}
> > > +
> > > +#ifdef CONFIG_OF
> >
> > Your probe function *relies on* devicetree, and you're adding an
> > ifdef for
> > CONFIG_OF? That wouldn't make sense, would it? ;-)
> >
Hi Angelo,
Thanks for your review.
It seems we don't need CONFIG_OF here, so I'll remove it in v4 patch.
> > > +static const struct of_device_id
> > > mt7986_wm8960_machine_dt_match[] = {
> > > + {.compatible = "mediatek,mt7986-wm8960-machine",},
> >
> > please...
> >
> > { .compatible = "mediatek,mt7986-wm8960-machine" },
>
> Actually, I noticed that just after sending the review.
>
> Can you also please change the compatible, as "machine" doesn't
> really
> mean "sound"? :-)
>
> .compatible = "mediatek,mt7986-wm8960-sound"
>
> Thanks!
>
For compatible suffix, I'll discuss with you in PATCH v3[5/6] mail, and
will refine this with [5/6] mail conclusion :)
> >
> > > + { /* sentinel */ }
> > > +};
> > > +MODULE_DEVICE_TABLE(of, mt7986_wm8960_machine_dt_match);
> > > +#endif
> > > +
> > > +static struct platform_driver mt7986_wm8960_machine = {
> > > + .driver = {
> > > + .name = "mt7986-wm8960",
> > > +#ifdef CONFIG_OF
> >
> > Check `struct device_driver`: const struct of_device_id
> > *of_match_table is
> > always present, there's no ifdef.... and that's done in order to
> > avoid seeing
> > a bunch of ifdefs in drivers...
> >
> > ...so, why is this callback enclosed in an ifdef?
> >
> > Please drop all those ifdefs.
> >
> >
> > After addressing those last comments, you can get my
> >
> > Reviewed-by: AngeloGioacchino Del Regno <
> > angelogioacchino.delregno@collabora.com>
> >
> > Regards,
> > Angelo
>
>
No more needed for the ifdef, so I'll drop them in v4 patch :)
Best regards,
Maso
next prev parent reply other threads:[~2023-07-31 6:50 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-28 9:08 [PATCH v3 0/6] ASoC: mediatek: Add support for MT7986 SoC Maso Huang
2023-07-28 9:08 ` [PATCH v3 1/6] ASoC: mediatek: mt7986: add common header Maso Huang
2023-08-04 9:15 ` Alexandre Mergnat
2023-08-04 10:24 ` Maso Huang (黃加竹)
2023-07-28 9:08 ` [PATCH v3 2/6] ASoC: mediatek: mt7986: support etdm in platform driver Maso Huang
2023-08-04 9:57 ` Alexandre Mergnat
2023-08-08 7:49 ` Maso Huang (黃加竹)
2023-07-28 9:08 ` [PATCH v3 3/6] ASoC: mediatek: mt7986: add " Maso Huang
2023-07-28 9:38 ` AngeloGioacchino Del Regno
2023-07-28 10:13 ` Maso Huang (黃加竹)
2023-07-28 9:08 ` [PATCH v3 4/6] ASoC: mediatek: mt7986: add machine driver with wm8960 Maso Huang
2023-07-28 9:49 ` AngeloGioacchino Del Regno
2023-07-28 9:52 ` AngeloGioacchino Del Regno
2023-07-31 6:50 ` Maso Huang (黃加竹) [this message]
2023-07-28 9:08 ` [PATCH v3 5/6] ASoC: dt-bindings: mediatek,mt7986-wm8960: add mt7986-wm8960 document Maso Huang
2023-07-28 9:55 ` AngeloGioacchino Del Regno
2023-07-28 10:16 ` Maso Huang (黃加竹)
2023-07-31 6:42 ` Maso Huang (黃加竹)
2023-07-31 10:44 ` AngeloGioacchino Del Regno
2023-07-31 12:38 ` Maso Huang (黃加竹)
2023-07-28 12:49 ` Krzysztof Kozlowski
2023-07-31 7:31 ` Maso Huang (黃加竹)
2023-07-31 8:14 ` Krzysztof Kozlowski
2023-07-31 14:56 ` Krzysztof Kozlowski
2023-08-04 7:08 ` Maso Huang (黃加竹)
2023-07-28 9:08 ` [PATCH v3 6/6] ASoC: dt-bindings: mediatek,mt7986-afe: add audio afe document Maso Huang
2023-07-28 10:00 ` AngeloGioacchino Del Regno
2023-07-28 10:19 ` Maso Huang (黃加竹)
2023-07-28 12:51 ` Krzysztof Kozlowski
2023-07-28 13:26 ` Mark Brown
2023-08-01 8:25 ` Maso Huang (黃加竹)
2023-08-04 9:45 ` Krzysztof Kozlowski
2023-08-04 10:29 ` Maso Huang (黃加竹)
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=fe11acb200695cb6049371899d00de37c18772c3.camel@mediatek.com \
--to=maso.huang@mediatek.com \
--cc=Allen-KH.Cheng@mediatek.com \
--cc=Trevor.Wu@mediatek.com \
--cc=alsa-devel@alsa-project.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=chenxiangrui@huaqin.corp-partner.google.com \
--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=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