diff mbox series

ASoC: rt5682: fix building without I2C

Message ID 20200408185527.308213-1-arnd@arndb.de (mailing list archive)
State New, archived
Headers show
Series ASoC: rt5682: fix building without I2C | expand

Commit Message

Arnd Bergmann April 8, 2020, 6:55 p.m. UTC
When I2C is disabled, building rt5682 produces a compile-time error:

sound/soc/codecs/rt5682.c:3716:1: warning: data definition has no type or storage class
 3716 | module_i2c_driver(rt5682_i2c_driver);
      | ^~~~~~~~~~~~~~~~~
sound/soc/codecs/rt5682.c:3716:1: error: type defaults to 'int' in declaration of 'module_i2c_driver' [-Werror=implicit-int]
sound/soc/codecs/rt5682.c:3716:1: warning: parameter names (without types) in function declaration
sound/soc/codecs/rt5682.c:3706:26: error: 'rt5682_i2c_driver' defined but not used [-Werror=unused-variable]
 3706 | static struct i2c_driver rt5682_i2c_driver = {
      |                          ^~~~~~~~~~~~~~~~~

Move the i2c specific entry points into an #ifdef section so
it can actually be built standalone.

Fixes: 5549ea647997 ("ASoC: rt5682: fix unmet dependencies")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 sound/soc/codecs/rt5682.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

Comments

Pierre-Louis Bossart April 8, 2020, 7:12 p.m. UTC | #1
On 4/8/20 1:55 PM, Arnd Bergmann wrote:
> When I2C is disabled, building rt5682 produces a compile-time error:
> 
> sound/soc/codecs/rt5682.c:3716:1: warning: data definition has no type or storage class
>   3716 | module_i2c_driver(rt5682_i2c_driver);
>        | ^~~~~~~~~~~~~~~~~
> sound/soc/codecs/rt5682.c:3716:1: error: type defaults to 'int' in declaration of 'module_i2c_driver' [-Werror=implicit-int]
> sound/soc/codecs/rt5682.c:3716:1: warning: parameter names (without types) in function declaration
> sound/soc/codecs/rt5682.c:3706:26: error: 'rt5682_i2c_driver' defined but not used [-Werror=unused-variable]
>   3706 | static struct i2c_driver rt5682_i2c_driver = {
>        |                          ^~~~~~~~~~~~~~~~~
> 
> Move the i2c specific entry points into an #ifdef section so
> it can actually be built standalone.
> 
> Fixes: 5549ea647997 ("ASoC: rt5682: fix unmet dependencies")

it's already fixed by [PATCH -next] ASoC: rt5682: Fix build error 
without CONFIG_I2C
diff mbox series

Patch

diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index c9268a230daa..a6548f870807 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -3224,12 +3224,6 @@  static const struct regmap_config rt5682_regmap = {
 	.use_single_write = true,
 };
 
-static const struct i2c_device_id rt5682_i2c_id[] = {
-	{"rt5682", 0},
-	{}
-};
-MODULE_DEVICE_TABLE(i2c, rt5682_i2c_id);
-
 static int rt5682_parse_dt(struct rt5682_priv *rt5682, struct device *dev)
 {
 
@@ -3526,7 +3520,7 @@  int rt5682_io_init(struct device *dev, struct sdw_slave *slave)
 EXPORT_SYMBOL_GPL(rt5682_io_init);
 #endif
 
-static int rt5682_i2c_probe(struct i2c_client *i2c,
+static int __maybe_unused rt5682_i2c_probe(struct i2c_client *i2c,
 		    const struct i2c_device_id *id)
 {
 	struct rt5682_platform_data *pdata = dev_get_platdata(&i2c->dev);
@@ -3680,13 +3674,14 @@  static int rt5682_i2c_probe(struct i2c_client *i2c,
 					rt5682_dai, ARRAY_SIZE(rt5682_dai));
 }
 
-static void rt5682_i2c_shutdown(struct i2c_client *client)
+static void __maybe_unused rt5682_i2c_shutdown(struct i2c_client *client)
 {
 	struct rt5682_priv *rt5682 = i2c_get_clientdata(client);
 
 	rt5682_reset(rt5682);
 }
 
+#ifdef CONFIG_I2C
 #ifdef CONFIG_OF
 static const struct of_device_id rt5682_of_match[] = {
 	{.compatible = "realtek,rt5682i"},
@@ -3703,6 +3698,12 @@  static const struct acpi_device_id rt5682_acpi_match[] = {
 MODULE_DEVICE_TABLE(acpi, rt5682_acpi_match);
 #endif
 
+static const struct i2c_device_id rt5682_i2c_id[] = {
+	{"rt5682", 0},
+	{}
+};
+MODULE_DEVICE_TABLE(i2c, rt5682_i2c_id);
+
 static struct i2c_driver rt5682_i2c_driver = {
 	.driver = {
 		.name = "rt5682",
@@ -3714,6 +3715,7 @@  static struct i2c_driver rt5682_i2c_driver = {
 	.id_table = rt5682_i2c_id,
 };
 module_i2c_driver(rt5682_i2c_driver);
+#endif
 
 MODULE_DESCRIPTION("ASoC RT5682 driver");
 MODULE_AUTHOR("Bard Liao <bardliao@realtek.com>");