Skip to contentSkip to conversation

ASoC: rt5640: Omit ACPI match table only if !ACPI

PATCH Applied Thierry Reding 2 participants 4 messages Sep 19, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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
index 0bfb960..641eeeb 100644
@@ -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
maintainer Applied
#1 lore raw
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 #ifdef CONFIG_ACPI.

Applied, thanks. Like I was saying to Olof we really should be able to do better than needing the ifdefs though.

#2 lore raw
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 #ifdef CONFIG_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

maintainer
#3 lore raw
Quoted 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.