mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: AngeloGioacchino Del Regno  <angelogioacchino.delregno@collabora.com>
To: Maso Huang <maso.huang@mediatek.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Trevor Wu <trevor.wu@mediatek.com>, Arnd Bergmann <arnd@arndb.de>,
	Mars Chen <chenxiangrui@huaqin.corp-partner.google.com>,
	Allen-KH Cheng <allen-kh.cheng@mediatek.com>,
	alsa-devel@alsa-project.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH v3 4/6] ASoC: mediatek: mt7986: add machine driver with wm8960
Date: Fri, 28 Jul 2023 11:49:36 +0200	[thread overview]
Message-ID: <bab11add-b56f-59d3-f4fc-ad248ebe9b99@collabora.com> (raw)
In-Reply-To: <20230728090819.18038-5-maso.huang@mediatek.com>

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? ;-)

> +static const struct of_device_id mt7986_wm8960_machine_dt_match[] = {
> +	{.compatible = "mediatek,mt7986-wm8960-machine",},

please...

{ .compatible = "mediatek,mt7986-wm8960-machine" },

> +	{ /* 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

  reply	other threads:[~2023-07-28  9:49 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 [this message]
2023-07-28  9:52     ` AngeloGioacchino Del Regno
2023-07-31  6:50       ` Maso Huang (黃加竹)
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=bab11add-b56f-59d3-f4fc-ad248ebe9b99@collabora.com \
    --to=angelogioacchino.delregno@collabora.com \
    --cc=allen-kh.cheng@mediatek.com \
    --cc=alsa-devel@alsa-project.org \
    --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=maso.huang@mediatek.com \
    --cc=matthias.bgg@gmail.com \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=tiwai@suse.com \
    --cc=trevor.wu@mediatek.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

all inboxes | Powered by JetHome®