ASoC: Ensure we generate a driver name
PATCH 1/1 ASoC: Ensure we generate a driver name
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.
--- sound/soc/soc-core.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-)
sound/soc/soc-core.c +15 -3
@@ -30,6 +30,7 @@#include <linux/bitops.h> #include <linux/debugfs.h> #include <linux/platform_device.h> +#include <linux/ctype.h> #include <linux/slab.h> #include <sound/ac97_codec.h> #include <sound/core.h>
@@ -1432,9 +1433,20 @@ 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++) { +switch (card->snd_card->driver[i]) { +case '_' : +case '-' : +case '\0' : +break ; +default : +if (!isalnum (card->snd_card->driver[i])) + card->snd_card->driver[i] ='_' ; +break ; + } + }if (card->late_probe) { ret = card->late_probe (card);
Signature · 1 line
1.7.6.3
2011/9/20 Mark Brown <[email protected]>:
Quoted 37 lines
Commit 873bd4c (ASoC: Don't set invalid name string to
snd_card->driverfield) 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 <[email protected]>---
sound/soc/soc-core.c | 18 +++++++++++++++---1 files changed, 15 insertions(+), 3 deletions(-)sound/soc/soc-core.c +9
-3@@ -30,6 +30,7 @@ #include <linux/bitops.h> #include <linux/debugfs.h> #include <linux/platform_device.h> +#include <linux/ctype.h> #include <linux/slab.h> #include <sound/ac97_codec.h> #include <sound/core.h>@@ -1432,9 +1433,20 @@ 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++) { + switch (card->snd_card->driver[i]) { + case '_': + case '-': + case '\0': + break;
sound/soc/soc-core.c static void snd_soc_instantiate_card(struct snd_soc_card *card)
Quoted 10 lines
sound/soc/soc-core.c +6
-1+ default: + if (!isalnum(card->snd_card->driver[i])) + card->snd_card->driver[i] = '_'; + break; + } + } if (card->late_probe) { ret = card->late_probe(card); --
If '\0', we should break out of loop?
Quoted 15 lines · Scott Jiang
2011/9/20 Mark Brown <[email protected]>:
Quoted 4 lines
+ for (i = 0; i <
ARRAY_SIZE(card->snd_card->driver); i++) {
+ switch (card->snd_card->driver[i]) {
+ case '_':
+ case '-':Quoted 8 lines
+ case '\0':
+ break;
+ default:
+ if (!isalnum(card->snd_card->driver[i]))
+ card->snd_card->driver[i] = '_';
+ break;
+ }
+ }
Quoted 1 line
If '\0', we should break out of loop?
It's really not worth the code complexity, we only run this once during probe and the array is fixed size and small.