[alsa-devel] [PATCH v6 6/9] ASoC: simple-card-utils: enable "label" on asoc_simple_card_parse_card_name
Rob Herring
robh+dt at kernel.org
Wed Apr 19 22:31:02 CEST 2017
On Mon, Apr 17, 2017 at 9:44 PM, Kuninori Morimoto
<kuninori.morimoto.gx at renesas.com> wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
>
> Current asoc_simple_card_parse_card_name() detect [prefix]name,
> but in generally, we uses "label" for user visible names.
> This patch enables [prefix]label too.
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
> ---
> v5 -> v6
>
> - used const for names[]
>
> sound/soc/generic/simple-card-utils.c | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
> index 343b291..94ceaca 100644
> --- a/sound/soc/generic/simple-card-utils.c
> +++ b/sound/soc/generic/simple-card-utils.c
> @@ -81,15 +81,25 @@ int asoc_simple_card_set_dailink_name(struct device *dev,
> int asoc_simple_card_parse_card_name(struct snd_soc_card *card,
> char *prefix)
> {
> + char * const names[] = {
> + "label", "name"
> + };
> char prop[128];
> + int i;
> int ret;
>
> - snprintf(prop, sizeof(prop), "%sname", prefix);
> + if (!prefix)
> + prefix = "";
>
> /* Parse the card name from DT */
> - ret = snd_soc_of_parse_card_name(card, prop);
> - if (ret < 0)
> - return ret;
> + for (i = 0; i < ARRAY_SIZE(names); i++) {
> + snprintf(prop, sizeof(prop), "%s%s", prefix, names[i]);
> + ret = snd_soc_of_parse_card_name(card, prop);
> + if (ret < 0)
> + return ret;
> + if (card->name)
> + break;
> + }
This is still wrong as you are allowing "<prefix>label" for property
names. I think you want something like this:
ret = snd_soc_of_parse_card_name(card, "label");
if (ret < 0) {
char prop[128];
snprintf(prop, sizeof(prop), "%sname", prefix);
/* Parse the card name from DT */
ret = snd_soc_of_parse_card_name(card, prop);
if (ret < 0)
return ret;
}
More information about the Alsa-devel
mailing list