Re: [PATCH V2] ASoC: soc-core: Prevent warning if no DMI table is present

From: Pierre-Louis Bossart
Date: Wed Mar 10 2021 - 13:37:55 EST



Build time dependencies aren't going to help anything, arm64 (and to my
understanding some future x86 systems, LynxPoint IIRC) supports both DT
and ACPI and so you have kernels built with support for both.

well, that's what I suggested initially:
if (is_of_node(card->dev->fwnode))

I used the of_node test as a proxy for 'no DMI' since I am not aware of any
means to detect if DMI is enabled at run-time.

Can we not fix the DMI code so it lets us check dmi_available either
directly or with an accessor? I don't understand why all the proposals
are dancing around local bodges here.

something like this then (compile-tested only)?

diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index d51ca0428bb8..f191a1f901ac 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -166,6 +166,7 @@ static int __init dmi_checksum(const u8 *buf, u8 len)
static const char *dmi_ident[DMI_STRING_MAX];
static LIST_HEAD(dmi_devices);
int dmi_available;
+EXPORT_SYMBOL_GPL(dmi_available);

/*
* Save a DMI string
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 16ba54eb8164..c7e4600b2dd4 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1574,7 +1574,7 @@ int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour)
if (card->long_name)
return 0; /* long name already set by driver or from DMI */

- if (!is_acpi_device_node(card->dev->fwnode))
+ if (!dmi_available)
return 0;

/* make up dmi long name as: vendor-product-version-board */