[alsa-devel] [PATCH] ASoC: Ensure we generate a card name

Takashi Iwai tiwai at suse.de
Tue Sep 20 12:58:11 CEST 2011


At Tue, 20 Sep 2011 11:42:21 +0100,
Mark Brown wrote:
> 
> Commit 873bd4c (ASoC: Don't set invalid name string to snd_card->driver
> field) broke generation of a driver name for all ASoC cards relying on the
> automatic generation of one. Fix this by using the old default with spaces
> replaced by underscores.
> 
> Signed-off-by: Mark Brown <broonie at opensource.wolfsonmicro.com>

Better to replace any letter except [a-zA-Z0-9_] with '_' or drop
them.  Use isalnum(), for example.


thanks,

Takashi

> ---
>  sound/soc/soc-core.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 10e5cde..7e30c08 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -1432,9 +1432,11 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
>  		 "%s", card->name);
>  	snprintf(card->snd_card->longname, sizeof(card->snd_card->longname),
>  		 "%s", card->long_name ? card->long_name : card->name);
> -	if (card->driver_name)
> -		strlcpy(card->snd_card->driver, card->driver_name,
> -			sizeof(card->snd_card->driver));
> +	snprintf(card->snd_card->driver, sizeof(card->snd_card->driver),
> +		 "%s", card->driver_name ? card->driver_name : card->name);
> +	for (i = 0; i < ARRAY_SIZE(card->snd_card->driver); i++)
> +		if (card->snd_card->driver[i] == ' ')
> +			card->snd_card->driver[i] = '_';
>  
>  	if (card->late_probe) {
>  		ret = card->late_probe(card);
> -- 
> 1.7.6.3
> 


More information about the Alsa-devel mailing list