Skip to contentSkip to conversation

ASoC: max98388: fix unused function warnings

PATCH In review Arnd Bergmann 3 participants 9 messages Jun 16, 2023 – Jun 17, 2023

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

PATCH 1/4 ASoC: max98388: fix unused function warnings

From: Arnd Bergmann <[email protected]>

The PM functions are never referenced when CONFIG_PM_SLEEP is disabled:

sound/soc/codecs/max98388.c:854:12: error: unused function 'max98388_suspend' [-Werror,-Wunused-function] static int max98388_suspend(struct device *dev)

           ^

sound/soc/codecs/max98388.c:864:12: error: unused function 'max98388_resume' [-Werror,-Wunused-function] static int max98388_resume(struct device *dev)

Fix this by using the modern SYSTEM_SLEEP_PM_OPS() macro in place of the deprecated SET_SYSTEM_SLEEP_PM_OPS() version, and use pm_sleep_ptr() to hide the entire structure as well.

On a related note, the of_match_ptr() and ACPI_PTR() macros have the same problem and would cause the device id table to be unused when the driver is built-in and the respective subsystems are disabled. This does not cause warnings unless -Wunused-const-variable is passed to the compiler, but it's better to just not use the macros at all here.

---
 sound/soc/codecs/max98388.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/max98388.c +4 -4
index 8062a71150074..3d03c4bac6c55 100644
@@ -873,7 +873,7 @@ static int max98388_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops max98388_pm = {
-	SET_SYSTEM_SLEEP_PM_OPS(max98388_suspend, max98388_resume)
+	SYSTEM_SLEEP_PM_OPS(max98388_suspend, max98388_resume)
 };
 
 static const struct regmap_config max98388_regmap = {
@@ -998,9 +998,9 @@ MODULE_DEVICE_TABLE(acpi, max98388_acpi_match);
 static struct i2c_driver max98388_i2c_driver = {
 	.driver = {
 		.name = "max98388",
-		.of_match_table = of_match_ptr(max98388_of_match),
-		.acpi_match_table = ACPI_PTR(max98388_acpi_match),
-		.pm = &max98388_pm,
+		.of_match_table = max98388_of_match,
+		.acpi_match_table = max98388_acpi_match,
+		.pm = pm_sleep_ptr(&max98388_pm),
 	},
 	.probe = max98388_i2c_probe,
 	.id_table = max98388_i2c_id,
Signature · 1 line
2.39.2
#1 lore raw

PATCH 2/4 ASoC: loongson: fix unused PM function warning

From: Arnd Bergmann <[email protected]>

Build testing without CONFIG_PM_SLEEP causes a warning:

sound/soc/loongson/loongson_i2s.c:246:12: error: unused function 'i2s_suspend' [-Werror,-Wunused-function] sound/soc/loongson/loongson_i2s.c:255:12: error: unused function 'i2s_resume' [-Werror,-Wunused-function]

Use the modern SYSTEM_SLEEP_PM_OPS() instead of the old one to avoid this.

Fixes d24028606e764 ("ASoC: loongson: Add Loongson ASoC Sound Card Support")
---
 sound/soc/loongson/loongson_i2s.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/loongson/loongson_i2s.c +1 -1
index 35d34568be79e..f73b6d6f16c23 100644
@@ -265,5 +265,5 @@ static int i2s_resume(struct device *dev)
 }
 
 const struct dev_pm_ops loongson_i2s_pm = {
-	SET_SYSTEM_SLEEP_PM_OPS(i2s_suspend, i2s_resume)
+	SYSTEM_SLEEP_PM_OPS(i2s_suspend, i2s_resume)
 };
Signature · 1 line
2.39.2
Acked-by Tested-by on v1 2/4
#2 lore raw

Re: [PATCH 2/4] ASoC: loongson: fix unused PM function warning

Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Build testing without CONFIG_PM_SLEEP causes a warning:

sound/soc/loongson/loongson_i2s.c:246:12: error: unused function 'i2s_suspend' [-Werror,-Wunused-function] sound/soc/loongson/loongson_i2s.c:255:12: error: unused function 'i2s_resume' [-Werror,-Wunused-function]

Use the modern SYSTEM_SLEEP_PM_OPS() instead of the old one to avoid this.

Fixes d24028606e764 ("ASoC: loongson: Add Loongson ASoC Sound Card Support")

Thanks.

Quoted 15 lines
---
 sound/soc/loongson/loongson_i2s.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/loongson/loongson_i2s.c +1 -1
index 35d34568be79e..f73b6d6f16c23 100644
@@ -265,5 +265,5 @@ static int i2s_resume(struct device *dev)
 }
 
 const struct dev_pm_ops loongson_i2s_pm = {
-	SET_SYSTEM_SLEEP_PM_OPS(i2s_suspend, i2s_resume)
+	SYSTEM_SLEEP_PM_OPS(i2s_suspend, i2s_resume)
 };
Signature · 1 line
~Randy
#3 lore raw

PATCH 3/4 ASoC: loongson: add PCI dependency

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The new driver fails to build when PCI is disabled:

WARNING: unmet direct dependencies detected for SND_SOC_LOONGSON_I2S_PCI
Depends on [n]: SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && (LOONGARCH || COMPILE_TEST [=y]) && PCI [=n]
Selected by [y]:
- SND_SOC_LOONGSON_CARD [=y] && SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && (LOONGARCH || COMPILE_TEST [=y])
sound/soc/loongson/loongson_i2s_pci.c:167:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int] module_pci_driver(loongson_i2s_driver);

Add the appropriate Kconfig dependency.

Fixes d24028606e764 ("ASoC: loongson: Add Loongson ASoC Sound Card Support")
---
 sound/soc/loongson/Kconfig | 1 +
 1 file changed, 1 insertion(+)
sound/soc/loongson/Kconfig +1 -0
index c175f9de19a85..b8d7e2bade246 100644
@@ -16,6 +16,7 @@ config SND_SOC_LOONGSON_I2S_PCI
 config SND_SOC_LOONGSON_CARD
 	tristate "Loongson Sound Card Driver"
 	select SND_SOC_LOONGSON_I2S_PCI
+	depends on PCI
 	help
 	  Say Y or M if you want to add support for SoC audio using
 	  loongson I2S controller.
Signature · 1 line
2.39.2
Acked-by Tested-by on v1 3/4
#4 lore raw

Re: [PATCH 3/4] ASoC: loongson: add PCI dependency

Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The new driver fails to build when PCI is disabled:

WARNING: unmet direct dependencies detected for SND_SOC_LOONGSON_I2S_PCI
Depends on [n]: SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && (LOONGARCH || COMPILE_TEST [=y]) && PCI [=n]
Selected by [y]:
- SND_SOC_LOONGSON_CARD [=y] && SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && (LOONGARCH || COMPILE_TEST [=y])
sound/soc/loongson/loongson_i2s_pci.c:167:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int] module_pci_driver(loongson_i2s_driver);

Quoted 4 lines

Add the appropriate Kconfig dependency.

Fixes d24028606e764 ("ASoC: loongson: Add Loongson ASoC Sound Card Support")

Thanks.

Quoted 16 lines
---
 sound/soc/loongson/Kconfig | 1 +
 1 file changed, 1 insertion(+)
sound/soc/loongson/Kconfig +1 -0
index c175f9de19a85..b8d7e2bade246 100644
@@ -16,6 +16,7 @@ config SND_SOC_LOONGSON_I2S_PCI
 config SND_SOC_LOONGSON_CARD
 	tristate "Loongson Sound Card Driver"
 	select SND_SOC_LOONGSON_I2S_PCI
+	depends on PCI
 	help
 	  Say Y or M if you want to add support for SoC audio using
 	  loongson I2S controller.
Signature · 1 line
~Randy
#5 lore raw

PATCH 4/4 ASoC: loongson: fix compile testing on 32-bit

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

DIV_ROUND_CLOSEST() does not work on 64-bit variables when building for a 32-bit target:

ld.lld: error: undefined symbol: __udivdi3

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by loongson_i2s.c
sound/soc/loongson/loongson_i2s.o:(loongson_i2s_hw_params) in archive vmlinux.a

Use DIV_ROUND_CLOSEST_ULL() instead.

Fixes d24028606e764 ("ASoC: loongson: Add Loongson ASoC Sound Card Support")
---
 sound/soc/loongson/loongson_i2s.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/loongson/loongson_i2s.c +1 -1
index f73b6d6f16c23..b919f0fe83615 100644
@@ -89,7 +89,7 @@ static int loongson_i2s_hw_params(struct snd_pcm_substream *substream,
 		bclk_ratio = DIV_ROUND_CLOSEST(sysclk,
 					       (bits * chans * fs * 2)) - 1;
 		mclk_ratio = clk_rate / sysclk;
-		mclk_ratio_frac = DIV_ROUND_CLOSEST(((u64)clk_rate << 16),
+		mclk_ratio_frac = DIV_ROUND_CLOSEST_ULL(((u64)clk_rate << 16),
 						    sysclk) - (mclk_ratio << 16);
 
 		regmap_read(i2s->regmap, LS_I2S_CFG, &val);
Signature · 1 line
2.39.2
Acked-by Tested-by on v1 4/4
#6 lore raw

Re: [PATCH 4/4] ASoC: loongson: fix compile testing on 32-bit

Quoted 5 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

DIV_ROUND_CLOSEST() does not work on 64-bit variables when building for a 32-bit target:

Quoted 8 lines

ld.lld: error: undefined symbol: __udivdi3

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by loongson_i2s.c
sound/soc/loongson/loongson_i2s.o:(loongson_i2s_hw_params) in archive vmlinux.a

Use DIV_ROUND_CLOSEST_ULL() instead.

Fixes d24028606e764 ("ASoC: loongson: Add Loongson ASoC Sound Card Support")

Thanks.

Quoted 17 lines
---
 sound/soc/loongson/loongson_i2s.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/loongson/loongson_i2s.c +1 -1
index f73b6d6f16c23..b919f0fe83615 100644
@@ -89,7 +89,7 @@ static int loongson_i2s_hw_params(struct snd_pcm_substream *substream,
 		bclk_ratio = DIV_ROUND_CLOSEST(sysclk,
 					       (bits * chans * fs * 2)) - 1;
 		mclk_ratio = clk_rate / sysclk;
-		mclk_ratio_frac = DIV_ROUND_CLOSEST(((u64)clk_rate << 16),
+		mclk_ratio_frac = DIV_ROUND_CLOSEST_ULL(((u64)clk_rate << 16),
 						    sysclk) - (mclk_ratio << 16);
 
 		regmap_read(i2s->regmap, LS_I2S_CFG, &val);
Signature · 1 line
~Randy
maintainer
#7 lore raw
In reply to Arnd Bergmann
Quoted 10 lines · Arnd Bergmann

The PM functions are never referenced when CONFIG_PM_SLEEP is disabled:

sound/soc/codecs/max98388.c:854:12: error: unused function 'max98388_suspend' [-Werror,-Wunused-function] static int max98388_suspend(struct device *dev)

           ^

sound/soc/codecs/max98388.c:864:12: error: unused function 'max98388_resume' [-Werror,-Wunused-function] static int max98388_resume(struct device *dev)

[...]

Applied to

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

Thanks!

[1/4] ASoC: max98388: fix unused function warnings

      commit: 0c340ba05fda0fbf5a54207452728911c6388330
[2/4] ASoC: loongson: fix unused PM function warning
      commit: 041c5a1d065e5882299475326655f573e2a2a580
[3/4] ASoC: loongson: add PCI dependency
      commit: 08432e59c7d9a958e69cf6b7a03777ba4f26f10b
[4/4] ASoC: loongson: fix compile testing on 32-bit
      commit: 928314eb06709e3861ce3e2c7e9ef3f83ba8691b

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

Acked-by Tested-by on v1 1/4
#8 lore raw
In reply to Arnd Bergmann
Quoted 15 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The PM functions are never referenced when CONFIG_PM_SLEEP is disabled:

sound/soc/codecs/max98388.c:854:12: error: unused function 'max98388_suspend' [-Werror,-Wunused-function] static int max98388_suspend(struct device *dev)

           ^

sound/soc/codecs/max98388.c:864:12: error: unused function 'max98388_resume' [-Werror,-Wunused-function] static int max98388_resume(struct device *dev)

Fix this by using the modern SYSTEM_SLEEP_PM_OPS() macro in place of the deprecated SET_SYSTEM_SLEEP_PM_OPS() version, and use pm_sleep_ptr() to hide the entire structure as well.

Quoted 7 lines

On a related note, the of_match_ptr() and ACPI_PTR() macros have the same problem and would cause the device id table to be unused when the driver is built-in and the respective subsystems are disabled. This does not cause warnings unless -Wunused-const-variable is passed to the compiler, but it's better to just not use the macros at all here.

Thanks.

Quoted 30 lines
---
 sound/soc/codecs/max98388.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/max98388.c +4 -4
index 8062a71150074..3d03c4bac6c55 100644
@@ -873,7 +873,7 @@ static int max98388_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops max98388_pm = {
-	SET_SYSTEM_SLEEP_PM_OPS(max98388_suspend, max98388_resume)
+	SYSTEM_SLEEP_PM_OPS(max98388_suspend, max98388_resume)
 };
 
 static const struct regmap_config max98388_regmap = {
@@ -998,9 +998,9 @@ MODULE_DEVICE_TABLE(acpi, max98388_acpi_match);
 static struct i2c_driver max98388_i2c_driver = {
 	.driver = {
 		.name = "max98388",
-		.of_match_table = of_match_ptr(max98388_of_match),
-		.acpi_match_table = ACPI_PTR(max98388_acpi_match),
-		.pm = &max98388_pm,
+		.of_match_table = max98388_of_match,
+		.acpi_match_table = max98388_acpi_match,
+		.pm = pm_sleep_ptr(&max98388_pm),
 	},
 	.probe = max98388_i2c_probe,
 	.id_table = max98388_i2c_id,
Signature · 1 line
~Randy