All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: Ensure we generate a card name
@ 2011-09-20 10:42 Mark Brown
  2011-09-20 10:58 ` Takashi Iwai
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Brown @ 2011-09-20 10:42 UTC (permalink / raw)
  To: Liam Girdwood, Takashi Iwai; +Cc: alsa-devel, patches, Mark Brown

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@opensource.wolfsonmicro.com>
---
 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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] ASoC: Ensure we generate a card name
  2011-09-20 10:42 [PATCH] ASoC: Ensure we generate a card name Mark Brown
@ 2011-09-20 10:58 ` Takashi Iwai
  2011-09-20 11:03   ` Mark Brown
  0 siblings, 1 reply; 10+ messages in thread
From: Takashi Iwai @ 2011-09-20 10:58 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, patches, Liam Girdwood

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@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
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] ASoC: Ensure we generate a card name
  2011-09-20 10:58 ` Takashi Iwai
@ 2011-09-20 11:03   ` Mark Brown
  2011-09-20 12:12     ` Takashi Iwai
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Brown @ 2011-09-20 11:03 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, patches, Liam Girdwood

On Tue, Sep 20, 2011 at 12:58:11PM +0200, Takashi Iwai wrote:

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

What *are* the rules?  The documentation says "driver name" which isn't
verbose...

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] ASoC: Ensure we generate a card name
  2011-09-20 11:03   ` Mark Brown
@ 2011-09-20 12:12     ` Takashi Iwai
  2011-09-20 12:19       ` Mark Brown
  0 siblings, 1 reply; 10+ messages in thread
From: Takashi Iwai @ 2011-09-20 12:12 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, patches, Liam Girdwood

At Tue, 20 Sep 2011 12:03:56 +0100,
Mark Brown wrote:
> 
> On Tue, Sep 20, 2011 at 12:58:11PM +0200, Takashi Iwai wrote:
> 
> > Better to replace any letter except [a-zA-Z0-9_] with '_' or drop
> > them.  Use isalnum(), for example.
> 
> What *are* the rules?  The documentation says "driver name" which isn't
> verbose...

It's used as an id string, so you can guess.
Practically, it should be a single word, contain no dangerous letters
that may screw up the parser.


Takashi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] ASoC: Ensure we generate a card name
  2011-09-20 12:12     ` Takashi Iwai
@ 2011-09-20 12:19       ` Mark Brown
  2011-09-20 12:51         ` Takashi Iwai
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Brown @ 2011-09-20 12:19 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, patches, Liam Girdwood

On Tue, Sep 20, 2011 at 02:12:15PM +0200, Takashi Iwai wrote:
> Mark Brown wrote:

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

> > What *are* the rules?  The documentation says "driver name" which isn't
> > verbose...

> It's used as an id string, so you can guess.
> Practically, it should be a single word, contain no dangerous letters
> that may screw up the parser.

I'm inclined to just stick with the original patch then, I'd expect that
anything that's problematic for the driver name is also going to be an
issue in the main name field and it's a lot simpler to implement (we
don't have isalnum() in kernel right now and you still need to handle _
and possibly -).

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] ASoC: Ensure we generate a card name
  2011-09-20 12:19       ` Mark Brown
@ 2011-09-20 12:51         ` Takashi Iwai
  2011-09-20 12:56           ` Mark Brown
  0 siblings, 1 reply; 10+ messages in thread
From: Takashi Iwai @ 2011-09-20 12:51 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, patches, Liam Girdwood

At Tue, 20 Sep 2011 13:19:14 +0100,
Mark Brown wrote:
> 
> On Tue, Sep 20, 2011 at 02:12:15PM +0200, Takashi Iwai wrote:
> > Mark Brown wrote:
> 
> > > > Better to replace any letter except [a-zA-Z0-9_] with '_' or drop
> > > > them.  Use isalnum(), for example.
> 
> > > What *are* the rules?  The documentation says "driver name" which isn't
> > > verbose...
> 
> > It's used as an id string, so you can guess.
> > Practically, it should be a single word, contain no dangerous letters
> > that may screw up the parser.
> 
> I'm inclined to just stick with the original patch then, I'd expect that
> anything that's problematic for the driver name is also going to be an
> issue in the main name field and it's a lot simpler to implement (we
> don't have isalnum() in kernel right now and you still need to handle _
> and possibly -).

The main name field isn't used by the parser.  So it may contain
special letters like parentheses or such.

And we have isalnum() in kernel, see include/linux/ctype.h.


Takashi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] ASoC: Ensure we generate a card name
  2011-09-20 12:51         ` Takashi Iwai
@ 2011-09-20 12:56           ` Mark Brown
  2011-09-20 13:02             ` Takashi Iwai
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Brown @ 2011-09-20 12:56 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, patches, Liam Girdwood

On Tue, Sep 20, 2011 at 02:51:12PM +0200, Takashi Iwai wrote:

> The main name field isn't used by the parser.  So it may contain
> special letters like parentheses or such.

It might not be used by ALSA but it's used by some userspaces to
identify the card they're running on.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] ASoC: Ensure we generate a card name
  2011-09-20 12:56           ` Mark Brown
@ 2011-09-20 13:02             ` Takashi Iwai
  2011-09-20 13:20               ` Mark Brown
  0 siblings, 1 reply; 10+ messages in thread
From: Takashi Iwai @ 2011-09-20 13:02 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, patches, Liam Girdwood

At Tue, 20 Sep 2011 13:56:46 +0100,
Mark Brown wrote:
> 
> On Tue, Sep 20, 2011 at 02:51:12PM +0200, Takashi Iwai wrote:
> 
> > The main name field isn't used by the parser.  So it may contain
> > special letters like parentheses or such.
> 
> It might not be used by ALSA but it's used by some userspaces to
> identify the card they're running on.

The card->name can contain special letters.  This has been so for over
a decade, and won't be changed.  Why now need to change this?


Takashi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] ASoC: Ensure we generate a card name
  2011-09-20 13:02             ` Takashi Iwai
@ 2011-09-20 13:20               ` Mark Brown
  2011-09-20 13:30                 ` Takashi Iwai
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Brown @ 2011-09-20 13:20 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, patches, Liam Girdwood

On Tue, Sep 20, 2011 at 03:02:22PM +0200, Takashi Iwai wrote:
> Mark Brown wrote:

> > It might not be used by ALSA but it's used by some userspaces to
> > identify the card they're running on.

> The card->name can contain special letters.  This has been so for over
> a decade, and won't be changed.  Why now need to change this?

I'm not suggesting that it should?  To be honest I'm quite surprised
that the alsa-lib code isn't able to cope with spaces in the driver
name in the first places, I'd rather just fix the specific characters it
doesn't like.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] ASoC: Ensure we generate a card name
  2011-09-20 13:20               ` Mark Brown
@ 2011-09-20 13:30                 ` Takashi Iwai
  0 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2011-09-20 13:30 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, patches, Liam Girdwood

At Tue, 20 Sep 2011 14:20:02 +0100,
Mark Brown wrote:
> 
> On Tue, Sep 20, 2011 at 03:02:22PM +0200, Takashi Iwai wrote:
> > Mark Brown wrote:
> 
> > > It might not be used by ALSA but it's used by some userspaces to
> > > identify the card they're running on.
> 
> > The card->name can contain special letters.  This has been so for over
> > a decade, and won't be changed.  Why now need to change this?
> 
> I'm not suggesting that it should?

OK, then I misunderstood the context.  It wasn't clear to me.

>  To be honest I'm quite surprised
> that the alsa-lib code isn't able to cope with spaces in the driver
> name in the first places, I'd rather just fix the specific characters it
> doesn't like.

Spaces may be handled actually, but it'll become tricky by quoting.
It's just like a shell script programming - spaces make harder to
handle in the end.  So, it should be avoided if possible.


Takashi

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-09-20 13:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-20 10:42 [PATCH] ASoC: Ensure we generate a card name Mark Brown
2011-09-20 10:58 ` Takashi Iwai
2011-09-20 11:03   ` Mark Brown
2011-09-20 12:12     ` Takashi Iwai
2011-09-20 12:19       ` Mark Brown
2011-09-20 12:51         ` Takashi Iwai
2011-09-20 12:56           ` Mark Brown
2011-09-20 13:02             ` Takashi Iwai
2011-09-20 13:20               ` Mark Brown
2011-09-20 13:30                 ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.