Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Bard Liao <yung-chuan.liao@linux.intel.com>,
	Chen-Yu Tsai <wenst@chromium.org>,
	Daniel Baluta <daniel.baluta@nxp.com>,
	Jaroslav Kysela <perex@perex.cz>,
	Kai Vehmanen <kai.vehmanen@linux.intel.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>,
	Takashi Iwai <tiwai@suse.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-sound@vger.kernel.org
Subject: Re: [PATCH v2] ASoC: soc-card: add snd_soc_card_set_topology_name()
Date: Thu, 28 May 2026 10:19:00 +0300	[thread overview]
Message-ID: <5f584713-10fa-4e23-b5ce-a64d9f808665@linux.intel.com> (raw)
In-Reply-To: <878q942wce.wl-kuninori.morimoto.gx@renesas.com>



On 28/05/2026 03:48, Kuninori Morimoto wrote:
> Some drivers want to use topology name, but currently each drivers are
> setting it by own method.
> This patch adds new snd_soc_card_set_topology_name() and do it by
> same method.
> 
> Almost all driver doesn't set topology name, let's remove fixed name
> array, and use devm_kasprintf() instead.

Reviewed-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> v1 -> v2
> 	- snd_soc_card_set_topology_name() checks prefix, too
> 
>  include/sound/soc-card.h                        |  2 ++
>  include/sound/soc.h                             |  3 +--
>  .../soc/mediatek/common/mtk-soundcard-driver.c  |  7 ++-----
>  sound/soc/soc-card.c                            | 13 +++++++++++++
>  sound/soc/soc-core.c                            | 17 +----------------
>  sound/soc/sof/nocodec.c                         |  4 ++--
>  6 files changed, 21 insertions(+), 25 deletions(-)
> 
> diff --git a/include/sound/soc-card.h b/include/sound/soc-card.h
> index ecc02e955279f..1f1e7d45f5533 100644
> --- a/include/sound/soc-card.h
> +++ b/include/sound/soc-card.h
> @@ -47,6 +47,8 @@ int snd_soc_card_late_probe(struct snd_soc_card *card);
>  void snd_soc_card_fixup_controls(struct snd_soc_card *card);
>  int snd_soc_card_remove(struct snd_soc_card *card);
>  
> +void snd_soc_card_set_topology_name(struct snd_soc_card *card, const char *preifx);
> +
>  int snd_soc_card_set_bias_level(struct snd_soc_card *card,
>  				struct snd_soc_dapm_context *dapm,
>  				enum snd_soc_bias_level level);
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index 8681dd3f4252f..10ad80f930c2e 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -987,7 +987,7 @@ struct snd_soc_card {
>  	bool pci_subsystem_set;
>  #endif /* CONFIG_PCI */
>  
> -	char topology_shortname[32];
> +	char *topology_shortname;
>  
>  	struct device *dev;
>  	struct snd_card *snd_card;
> @@ -1084,7 +1084,6 @@ struct snd_soc_card {
>  #endif
>  	/* bit field */
>  	unsigned int instantiated:1;
> -	unsigned int topology_shortname_created:1;
>  	unsigned int fully_routed:1;
>  	unsigned int probed:1;
>  	unsigned int component_chaining:1;
> diff --git a/sound/soc/mediatek/common/mtk-soundcard-driver.c b/sound/soc/mediatek/common/mtk-soundcard-driver.c
> index a2a30a87a359f..cdff7322426a9 100644
> --- a/sound/soc/mediatek/common/mtk-soundcard-driver.c
> +++ b/sound/soc/mediatek/common/mtk-soundcard-driver.c
> @@ -289,11 +289,8 @@ int mtk_soundcard_common_probe(struct platform_device *pdev)
>  		soc_card_data->sof_priv = pdata->sof_priv;
>  		card->probe = mtk_sof_card_probe;
>  		card->late_probe = mtk_sof_card_late_probe;
> -		if (!card->topology_shortname_created) {
> -			snprintf(card->topology_shortname, 32, "sof-%s", card->name);
> -			card->topology_shortname_created = true;
> -		}
> -		card->name = card->topology_shortname;
> +
> +		snd_soc_card_set_topology_name(card, "sof");
>  	}
>  
>  	/*
> diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
> index 235427d690617..282d666dae9ec 100644
> --- a/sound/soc/soc-card.c
> +++ b/sound/soc/soc-card.c
> @@ -246,3 +246,16 @@ void snd_soc_card_remove_dai_link(struct snd_soc_card *card,
>  		card->remove_dai_link(card, dai_link);
>  }
>  EXPORT_SYMBOL_GPL(snd_soc_card_remove_dai_link);
> +
> +void snd_soc_card_set_topology_name(struct snd_soc_card *card, const char *prefix)
> +{
> +	if (!prefix || !card->name)
> +		return;
> +
> +	if (!card->topology_shortname)
> +		card->topology_shortname = devm_kasprintf(card->dev, GFP_KERNEL,
> +							  "%s-%s", prefix, card->name);
> +
> +	card->name = card->topology_shortname;
> +}
> +EXPORT_SYMBOL_GPL(snd_soc_card_set_topology_name);
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 55130eea04544..e96dd4a3f46c7 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -1990,7 +1990,6 @@ static inline int snd_soc_set_dmi_name(struct snd_soc_card *card)
>  static void soc_check_tplg_fes(struct snd_soc_card *card)
>  {
>  	struct snd_soc_component *component;
> -	const struct snd_soc_component_driver *comp_drv;
>  	struct snd_soc_dai_link *dai_link;
>  	int i;
>  
> @@ -2051,21 +2050,7 @@ static void soc_check_tplg_fes(struct snd_soc_card *card)
>  		}
>  
>  		/* Inform userspace we are using alternate topology */
> -		if (component->driver->topology_name_prefix) {
> -
> -			/* topology shortname created? */
> -			if (!card->topology_shortname_created) {
> -				comp_drv = component->driver;
> -
> -				snprintf(card->topology_shortname, 32, "%s-%s",
> -					 comp_drv->topology_name_prefix,
> -					 card->name);
> -				card->topology_shortname_created = true;
> -			}
> -
> -			/* use topology shortname */
> -			card->name = card->topology_shortname;
> -		}
> +		snd_soc_card_set_topology_name(card, component->driver->topology_name_prefix);
>  	}
>  }
>  
> diff --git a/sound/soc/sof/nocodec.c b/sound/soc/sof/nocodec.c
> index c0c906a78ebae..11a95dba3c9cf 100644
> --- a/sound/soc/sof/nocodec.c
> +++ b/sound/soc/sof/nocodec.c
> @@ -15,7 +15,6 @@
>  
>  static struct snd_soc_card sof_nocodec_card = {
>  	.name = "nocodec", /* the sof- prefix is added by the core */
> -	.topology_shortname = "sof-nocodec",
>  	.owner = THIS_MODULE
>  };
>  
> @@ -89,9 +88,10 @@ static int sof_nocodec_probe(struct platform_device *pdev)
>  	int ret;
>  
>  	card->dev = &pdev->dev;
> -	card->topology_shortname_created = true;
>  	mach = pdev->dev.platform_data;
>  
> +	snd_soc_card_set_topology_name(card, "sof");
> +
>  	ret = sof_nocodec_setup(card->dev, mach->mach_params.num_dai_drivers,
>  				mach->mach_params.dai_drivers);
>  	if (ret < 0)

-- 
Péter



      reply	other threads:[~2026-05-28  7:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-28  0:48 [PATCH v2] ASoC: soc-card: add snd_soc_card_set_topology_name() Kuninori Morimoto
2026-05-28  7:19 ` Péter Ujfalusi [this message]

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=5f584713-10fa-4e23-b5ce-a64d9f808665@linux.intel.com \
    --to=peter.ujfalusi@linux.intel.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=tiwai@suse.com \
    --cc=wenst@chromium.org \
    --cc=yung-chuan.liao@linux.intel.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