Skip to contentSkip to conversation

ASoC: rt5682: Fix build error without CONFIG_I2C

PATCH Superseded YueHaibing 2 participants 4 messages Apr 1, 2020

Subsystems (3)
lore
Share & tools
lore

YueHaibing

author
#0 lore raw

PATCH 1/1 ASoC: rt5682: Fix build error without CONFIG_I2C

If I2C is n but SoundWire is m, building fails:

sound/soc/codecs/rt5682.c:3716:1: warning: data definition has no type or storage class
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

Guard this use #ifdef CONFIG_I2C.

Fixes 5549ea647997 ("ASoC: rt5682: fix unmet dependencies")
---
 sound/soc/codecs/rt5682.c | 110 +++++++++++++++++++-------------------
 1 file changed, 56 insertions(+), 54 deletions(-)
sound/soc/codecs/rt5682.c +56 -54
index c9268a230daa..ff3efad874a4 100644
@@ -33,12 +33,6 @@
 #include "rt5682.h"
 #include "rt5682-sdw.h"
 
-static const char *rt5682_supply_names[RT5682_NUM_SUPPLIES] = {
-	"AVDD",
-	"MICVDD",
-	"VBAT",
-};
-
 static const struct rt5682_platform_data i2s_default_platform_data = {
 	.dmic1_data_pin = RT5682_DMIC1_DATA_GPIO2,
 	.dmic1_clk_pin = RT5682_DMIC1_CLK_GPIO3,
@@ -984,25 +978,6 @@ static irqreturn_t rt5682_irq(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static void rt5682_jd_check_handler(struct work_struct *work)
-{
-	struct rt5682_priv *rt5682 = container_of(work, struct rt5682_priv,
-		jd_check_work.work);
-
-	if (snd_soc_component_read32(rt5682->component, RT5682_AJD1_CTRL)
-		& RT5682_JDH_RS_MASK) {
-		/* jack out */
-		rt5682->jack_type = rt5682_headset_detect(rt5682->component, 0);
-
-		snd_soc_jack_report(rt5682->hs_jack, rt5682->jack_type,
-				SND_JACK_HEADSET |
-				SND_JACK_BTN_0 | SND_JACK_BTN_1 |
-				SND_JACK_BTN_2 | SND_JACK_BTN_3);
-	} else {
-		schedule_delayed_work(&rt5682->jd_check_work, 500);
-	}
-}
-
 static int rt5682_set_jack_detect(struct snd_soc_component *component,
 	struct snd_soc_jack *hs_jack, void *data)
 {
@@ -3230,35 +3205,6 @@ static const struct i2c_device_id rt5682_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, rt5682_i2c_id);
 
-static int rt5682_parse_dt(struct rt5682_priv *rt5682, struct device *dev)
-{
-
-	device_property_read_u32(dev, "realtek,dmic1-data-pin",
-		&rt5682->pdata.dmic1_data_pin);
-	device_property_read_u32(dev, "realtek,dmic1-clk-pin",
-		&rt5682->pdata.dmic1_clk_pin);
-	device_property_read_u32(dev, "realtek,jd-src",
-		&rt5682->pdata.jd_src);
-	device_property_read_u32(dev, "realtek,btndet-delay",
-		&rt5682->pdata.btndet_delay);
-	device_property_read_u32(dev, "realtek,dmic-clk-rate-hz",
-		&rt5682->pdata.dmic_clk_rate);
-	device_property_read_u32(dev, "realtek,dmic-delay-ms",
-		&rt5682->pdata.dmic_delay);
-
-	rt5682->pdata.ldo1_en = of_get_named_gpio(dev->of_node,
-		"realtek,ldo1-en-gpios", 0);
-
-	if (device_property_read_string_array(dev, "clock-output-names",
-					      rt5682->pdata.dai_clk_names,
-					      RT5682_DAI_NUM_CLKS) < 0)
-		dev_warn(dev, "Using default DAI clk names: %s, %s\n",
-			 rt5682->pdata.dai_clk_names[RT5682_DAI_WCLK_IDX],
-			 rt5682->pdata.dai_clk_names[RT5682_DAI_BCLK_IDX]);
-
-	return 0;
-}
-
 static void rt5682_calibrate(struct rt5682_priv *rt5682)
 {
 	int value, count;
@@ -3526,6 +3472,61 @@ int rt5682_io_init(struct device *dev, struct sdw_slave *slave)
 EXPORT_SYMBOL_GPL(rt5682_io_init);
 #endif
 
+#ifdef CONFIG_I2C
+static const char *rt5682_supply_names[RT5682_NUM_SUPPLIES] = {
+	"AVDD",
+	"MICVDD",
+	"VBAT",
+};
+
+static void rt5682_jd_check_handler(struct work_struct *work)
+{
+	struct rt5682_priv *rt5682 = container_of(work, struct rt5682_priv,
+		jd_check_work.work);
+
+	if (snd_soc_component_read32(rt5682->component, RT5682_AJD1_CTRL)
+		& RT5682_JDH_RS_MASK) {
+		/* jack out */
+		rt5682->jack_type = rt5682_headset_detect(rt5682->component, 0);
+
+		snd_soc_jack_report(rt5682->hs_jack, rt5682->jack_type,
+				SND_JACK_HEADSET |
+				SND_JACK_BTN_0 | SND_JACK_BTN_1 |
+				SND_JACK_BTN_2 | SND_JACK_BTN_3);
+	} else {
+		schedule_delayed_work(&rt5682->jd_check_work, 500);
+	}
+}
+
+static int rt5682_parse_dt(struct rt5682_priv *rt5682, struct device *dev)
+{
+
+	device_property_read_u32(dev, "realtek,dmic1-data-pin",
+		&rt5682->pdata.dmic1_data_pin);
+	device_property_read_u32(dev, "realtek,dmic1-clk-pin",
+		&rt5682->pdata.dmic1_clk_pin);
+	device_property_read_u32(dev, "realtek,jd-src",
+		&rt5682->pdata.jd_src);
+	device_property_read_u32(dev, "realtek,btndet-delay",
+		&rt5682->pdata.btndet_delay);
+	device_property_read_u32(dev, "realtek,dmic-clk-rate-hz",
+		&rt5682->pdata.dmic_clk_rate);
+	device_property_read_u32(dev, "realtek,dmic-delay-ms",
+		&rt5682->pdata.dmic_delay);
+
+	rt5682->pdata.ldo1_en = of_get_named_gpio(dev->of_node,
+		"realtek,ldo1-en-gpios", 0);
+
+	if (device_property_read_string_array(dev, "clock-output-names",
+					      rt5682->pdata.dai_clk_names,
+					      RT5682_DAI_NUM_CLKS) < 0)
+		dev_warn(dev, "Using default DAI clk names: %s, %s\n",
+			 rt5682->pdata.dai_clk_names[RT5682_DAI_WCLK_IDX],
+			 rt5682->pdata.dai_clk_names[RT5682_DAI_BCLK_IDX]);
+
+	return 0;
+}
+
 static int rt5682_i2c_probe(struct i2c_client *i2c,
 		    const struct i2c_device_id *id)
 {
@@ -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 <[email protected]>");
Signature · 1 line
2.17.1
maintainer
#1 lore raw

sound/soc/codecs/rt5682.c line 41

Quoted 6 lines · YueHaibing
sound/soc/codecs/rt5682.c +0 -6
-static const char *rt5682_supply_names[RT5682_NUM_SUPPLIES] = {
-	"AVDD",
-	"MICVDD",
-	"VBAT",
-};
-

I imagine that the device is going to need power even when use with slimbus, even if the regulator support isn't wired up at the minute. For things like this __maybey_unused annotations tend to be better, this stops warnings about things not being used but doesn't need ifdefs or big code moves.

author
#2 lore raw

PATCH v2 1/1 ASoC: rt5682: Fix build error without CONFIG_I2C

In reply to YueHaibing

If I2C is n but SoundWire is m, building fails:

sound/soc/codecs/rt5682.c:3716:1: warning: data definition has no type or storage class
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

Guard this use #ifdef CONFIG_I2C.

Fixes 5549ea647997 ("ASoC: rt5682: fix unmet dependencies")

---
v2: use __maybe_unused

---
 sound/soc/codecs/rt5682.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/codecs/rt5682.c +4 -1
index c9268a230daa..d36f560ad7a8 100644
@@ -3703,7 +3703,7 @@ static const struct acpi_device_id rt5682_acpi_match[] = {
 MODULE_DEVICE_TABLE(acpi, rt5682_acpi_match);
 #endif
 
-static struct i2c_driver rt5682_i2c_driver = {
+static struct i2c_driver __maybe_unused rt5682_i2c_driver = {
 	.driver = {
 		.name = "rt5682",
 		.of_match_table = of_match_ptr(rt5682_of_match),
@@ -3713,7 +3713,10 @@ static struct i2c_driver rt5682_i2c_driver = {
 	.shutdown = rt5682_i2c_shutdown,
 	.id_table = rt5682_i2c_id,
 };
+
+#ifdef CONFIG_I2C
 module_i2c_driver(rt5682_i2c_driver);
+#endif
 
 MODULE_DESCRIPTION("ASoC RT5682 driver");
 MODULE_AUTHOR("Bard Liao <[email protected]>");
Signature · 1 line
2.17.1
maintainer
#3 lore raw

Applied "ASoC: rt5682: Fix build error without CONFIG_I2C" to the asoc tree

The patch

ASoC: rt5682: Fix build error without CONFIG_I2C

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 59564e117356d5bb6df6876c03d7d650361781c9 Mon Sep 17 00:00:00 2001
From: YueHaibing <[email protected]>
Date: Wed, 1 Apr 2020 17:10:55 +0800
Subject: [PATCH] ASoC: rt5682: Fix build error without CONFIG_I2C

If I2C is n but SoundWire is m, building fails:

sound/soc/codecs/rt5682.c:3716:1: warning: data definition has no type or storage class
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

Guard this use #ifdef CONFIG_I2C.

Fixes 5549ea647997 ("ASoC: rt5682: fix unmet dependencies")
---
 sound/soc/codecs/rt5682.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/codecs/rt5682.c +4 -1
index c9268a230daa..d36f560ad7a8 100644
@@ -3703,7 +3703,7 @@ static const struct acpi_device_id rt5682_acpi_match[] = {
 MODULE_DEVICE_TABLE(acpi, rt5682_acpi_match);
 #endif
 
-static struct i2c_driver rt5682_i2c_driver = {
+static struct i2c_driver __maybe_unused rt5682_i2c_driver = {
 	.driver = {
 		.name = "rt5682",
 		.of_match_table = of_match_ptr(rt5682_of_match),
@@ -3713,7 +3713,10 @@ static struct i2c_driver rt5682_i2c_driver = {
 	.shutdown = rt5682_i2c_shutdown,
 	.id_table = rt5682_i2c_id,
 };
+
+#ifdef CONFIG_I2C
 module_i2c_driver(rt5682_i2c_driver);
+#endif
 
 MODULE_DESCRIPTION("ASoC RT5682 driver");
 MODULE_AUTHOR("Bard Liao <[email protected]>");
Signature · 1 line
2.20.1