* [PATCH] ASoC: Drop invalid DMI fields when setting card long name from DMI info
@ 2017-06-28 7:01 mengdong.lin
2017-06-28 14:22 ` Takashi Iwai
0 siblings, 1 reply; 4+ messages in thread
From: mengdong.lin @ 2017-06-28 7:01 UTC (permalink / raw)
To: alsa-devel, broonie
Cc: tiwai, liam.r.girdwood, Mengdong Lin, mengdong.lin, pierre-louis.bossart
From: Mengdong Lin <mengdong.lin@linux.intel.com>
Sometimes DMI fields may be invalid and so can't give useful vendor,
product or board info, such as "Type2 - Board Manufacturer" or
"Type1 - TBD by OEM". Including such invalid DMI fileds may create silly
card long name. So this patch creates a black list of invalid strings.
And if a DMI field contains any string in this list, it will be excluded
from the card long name.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index cfa9cf1476f2..419b788fd801 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -69,6 +69,20 @@ static int pmdown_time = 5000;
module_param(pmdown_time, int, 0);
MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)");
+/* If a DMI filed contain strings in this blacklist (e.g.
+ * "Type2 - Board Manufacturer" or "Type1 - TBD by OEM"), it will be taken
+ * as invalid and dropped when setting the card long name from DMI info.
+ */
+static const char * const dmi_blacklist[] = {
+ "To be filled by OEM",
+ "TBD by OEM",
+ "Default String",
+ "Board Manufacturer",
+ "Board Vendor Name",
+ "Board Product Name",
+ NULL, /* terminator */
+};
+
/* returns the minimum number of bytes needed to represent
* a particular given value */
static int min_bytes_needed(unsigned long val)
@@ -1934,6 +1948,22 @@ static void cleanup_dmi_name(char *name)
name[j] = '\0';
}
+/* Check if a DMI field is valid, i.e. not containing any string
+ * in the black list.
+ */
+static int is_dmi_valid(const char *field)
+{
+ int i = 0;
+
+ while (dmi_blacklist[i]) {
+ if (strstr(field, dmi_blacklist[i]))
+ return 0;
+ i++;
+ };
+
+ return 1;
+}
+
/**
* snd_soc_set_dmi_name() - Register DMI names to card
* @card: The card to register DMI names
@@ -1976,17 +2006,18 @@ int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour)
/* make up dmi long name as: vendor.product.version.board */
vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
- if (!vendor) {
+ if (!vendor || !is_dmi_valid(vendor)) {
dev_warn(card->dev, "ASoC: no DMI vendor name!\n");
return 0;
}
+
snprintf(card->dmi_longname, sizeof(card->snd_card->longname),
"%s", vendor);
cleanup_dmi_name(card->dmi_longname);
product = dmi_get_system_info(DMI_PRODUCT_NAME);
- if (product) {
+ if (product && is_dmi_valid(product)) {
len = strlen(card->dmi_longname);
snprintf(card->dmi_longname + len,
longname_buf_size - len,
@@ -2000,7 +2031,7 @@ int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour)
* name in the product version field
*/
product_version = dmi_get_system_info(DMI_PRODUCT_VERSION);
- if (product_version) {
+ if (product_version && is_dmi_valid(product_version)) {
len = strlen(card->dmi_longname);
snprintf(card->dmi_longname + len,
longname_buf_size - len,
@@ -2013,7 +2044,7 @@ int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour)
}
board = dmi_get_system_info(DMI_BOARD_NAME);
- if (board) {
+ if (board && is_dmi_valid(board)) {
len = strlen(card->dmi_longname);
snprintf(card->dmi_longname + len,
longname_buf_size - len,
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: Drop invalid DMI fields when setting card long name from DMI info
2017-06-28 7:01 [PATCH] ASoC: Drop invalid DMI fields when setting card long name from DMI info mengdong.lin
@ 2017-06-28 14:22 ` Takashi Iwai
2017-06-28 17:45 ` Mark Brown
2017-06-29 4:03 ` Mengdong Lin
0 siblings, 2 replies; 4+ messages in thread
From: Takashi Iwai @ 2017-06-28 14:22 UTC (permalink / raw)
To: mengdong.lin
Cc: liam.r.girdwood, mengdong.lin, alsa-devel, broonie, pierre-louis.bossart
On Wed, 28 Jun 2017 09:01:39 +0200,
mengdong.lin@linux.intel.com wrote:
>
> From: Mengdong Lin <mengdong.lin@linux.intel.com>
>
> Sometimes DMI fields may be invalid and so can't give useful vendor,
> product or board info, such as "Type2 - Board Manufacturer" or
> "Type1 - TBD by OEM". Including such invalid DMI fileds may create silly
> card long name. So this patch creates a black list of invalid strings.
> And if a DMI field contains any string in this list, it will be excluded
> from the card long name.
>
> Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
>
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index cfa9cf1476f2..419b788fd801 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -69,6 +69,20 @@ static int pmdown_time = 5000;
> module_param(pmdown_time, int, 0);
> MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)");
>
> +/* If a DMI filed contain strings in this blacklist (e.g.
> + * "Type2 - Board Manufacturer" or "Type1 - TBD by OEM"), it will be taken
> + * as invalid and dropped when setting the card long name from DMI info.
> + */
> +static const char * const dmi_blacklist[] = {
> + "To be filled by OEM",
> + "TBD by OEM",
> + "Default String",
We found also a case with "Default string" (note the case-sensitive).
thanks,
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: Drop invalid DMI fields when setting card long name from DMI info
2017-06-28 14:22 ` Takashi Iwai
@ 2017-06-28 17:45 ` Mark Brown
2017-06-29 4:03 ` Mengdong Lin
1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2017-06-28 17:45 UTC (permalink / raw)
To: Takashi Iwai
Cc: liam.r.girdwood, mengdong.lin, alsa-devel, mengdong.lin,
pierre-louis.bossart
[-- Attachment #1.1: Type: text/plain, Size: 369 bytes --]
On Wed, Jun 28, 2017 at 04:22:10PM +0200, Takashi Iwai wrote:
> mengdong.lin@linux.intel.com wrote:
> > +static const char * const dmi_blacklist[] = {
> > + "To be filled by OEM",
> > + "TBD by OEM",
> > + "Default String",
> We found also a case with "Default string" (note the case-sensitive).
I'll apply Mengdong's current patch, that can be added incrementally.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: Drop invalid DMI fields when setting card long name from DMI info
2017-06-28 14:22 ` Takashi Iwai
2017-06-28 17:45 ` Mark Brown
@ 2017-06-29 4:03 ` Mengdong Lin
1 sibling, 0 replies; 4+ messages in thread
From: Mengdong Lin @ 2017-06-29 4:03 UTC (permalink / raw)
To: Takashi Iwai
Cc: liam.r.girdwood, mengdong.lin, alsa-devel, broonie, pierre-louis.bossart
On 06/28/2017 10:22 PM, Takashi Iwai wrote:
> On Wed, 28 Jun 2017 09:01:39 +0200,
> mengdong.lin@linux.intel.com wrote:
>>
>> From: Mengdong Lin <mengdong.lin@linux.intel.com>
>>
>> Sometimes DMI fields may be invalid and so can't give useful vendor,
>> product or board info, such as "Type2 - Board Manufacturer" or
>> "Type1 - TBD by OEM". Including such invalid DMI fileds may create silly
>> card long name. So this patch creates a black list of invalid strings.
>> And if a DMI field contains any string in this list, it will be excluded
>> from the card long name.
>>
>> Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
>>
>> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
>> index cfa9cf1476f2..419b788fd801 100644
>> --- a/sound/soc/soc-core.c
>> +++ b/sound/soc/soc-core.c
>> @@ -69,6 +69,20 @@ static int pmdown_time = 5000;
>> module_param(pmdown_time, int, 0);
>> MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)");
>>
>> +/* If a DMI filed contain strings in this blacklist (e.g.
>> + * "Type2 - Board Manufacturer" or "Type1 - TBD by OEM"), it will be taken
>> + * as invalid and dropped when setting the card long name from DMI info.
>> + */
>> +static const char * const dmi_blacklist[] = {
>> + "To be filled by OEM",
>> + "TBD by OEM",
>> + "Default String",
>
> We found also a case with "Default string" (note the case-sensitive).
I added it in the v2 patch. Please review.
It seems we'll add more strings later to handle such case-sensitive cases.
Thanks
Mengdong
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-06-29 11:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-28 7:01 [PATCH] ASoC: Drop invalid DMI fields when setting card long name from DMI info mengdong.lin
2017-06-28 14:22 ` Takashi Iwai
2017-06-28 17:45 ` Mark Brown
2017-06-29 4:03 ` Mengdong Lin
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.