ASoC: rt5640: Omit ACPI match table only if !ACPI
Subsystems (3)
PATCH 1/1 ASoC: rt5640: Omit ACPI match table only if !ACPI
The ACPI_PTR() macro evaluates to NULL if ACPI is disabled and hence the ACPI match table won't be used, causing the compiler to complain. Avoid this by protecting the table using an #ifdef CONFIG_ACPI.
--- sound/soc/codecs/rt5640.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/codecs/rt5640.c +2 -0
@@ -2082,11 +2082,13 @@ static const struct i2c_device_id rt5640_i2c_id[] = { };MODULE_DEVICE_TABLE (i2c, rt5640_i2c_id); +#ifdef CONFIG_ACPI static struct acpi_device_id rt5640_acpi_match[] = { {"INT33CA" ,0 }, { }, };MODULE_DEVICE_TABLE (acpi, rt5640_acpi_match); +#endif static int rt5640_parse_dt (struct rt5640_priv *rt5640,struct device_node *np) {
Signature · 1 line
1.8.4
Quoted 3 lines · Thierry Reding
The
ACPI_PTR()macro evaluates to NULL if ACPI is disabled and hence the ACPI match table won't be used, causing the compiler to complain. Avoid this by protecting the table using an #ifdefCONFIG_ACPI.
Applied, thanks. Like I was saying to Olof we really should be able to do better than needing the ifdefs though.
Quoted 7 lines · Mark Brown
Quoted 3 lines · Thierry Reding
The
ACPI_PTR()macro evaluates to NULL if ACPI is disabled and hence the ACPI match table won't be used, causing the compiler to complain. Avoid this by protecting the table using an #ifdefCONFIG_ACPI.Applied, thanks. Like I was saying to Olof we really should be able to do better than needing the ifdefs though.
The struct device_driver's .acpi_match_table field is unconditionally declared and the ACPI table with one entry and the sentinel weighs in at 26 bytes, so perhaps doing away with the conditionals would be an equally good option.
Or perhaps we can annotate the table so that the compiler will stop complaining but remove the table nonetheless if it isn't used. Similarly to what we can do with
if (IS_ENABLED(CONFIG_FOO)) {
...
}constructs. I can't really think of a way to do that, though. Perhaps gcc will throw away the table anyway, so we'll just need a way to make it shut up?
Thierry
Mark Brown
maintainerQuoted 11 lines · Thierry Reding
Or perhaps we can annotate the table so that the compiler will stop complaining but remove the table nonetheless if it isn't used. Similarly to what we can do with
if (IS_ENABLED(CONFIG_FOO)) { ... }constructs. I can't really think of a way to do that, though. Perhaps gcc will throw away the table anyway, so we'll just need a way to make it shut up?
There's an annotation which can stop the unreferenced variable warning and then modern compilers are able to eliminate unreferenced static symbols. Not sure if it's actually worth the effort of doing all this though, but it is nice to be able to avoid needing multiple builds.