diff mbox series

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

Message ID 20230616090156.2347850-1-arnd@kernel.org (mailing list archive)
State Accepted
Commit 0c340ba05fda0fbf5a54207452728911c6388330
Headers show
Series [1/4] ASoC: max98388: fix unused function warnings | expand

Commit Message

Arnd Bergmann June 16, 2023, 9 a.m. UTC
From: Arnd Bergmann <arnd@arndb.de>

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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 sound/soc/codecs/max98388.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Mark Brown June 16, 2023, 1:33 p.m. UTC | #1
On Fri, 16 Jun 2023 11:00:37 +0200, Arnd Bergmann wrote:
> 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
Randy Dunlap June 17, 2023, 4:10 a.m. UTC | #2
On 6/16/23 02:00, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> 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.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org> # build-tested

Thanks.

> ---
>  sound/soc/codecs/max98388.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/soc/codecs/max98388.c b/sound/soc/codecs/max98388.c
> index 8062a71150074..3d03c4bac6c55 100644
> --- a/sound/soc/codecs/max98388.c
> +++ b/sound/soc/codecs/max98388.c
> @@ -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,
diff mbox series

Patch

diff --git a/sound/soc/codecs/max98388.c b/sound/soc/codecs/max98388.c
index 8062a71150074..3d03c4bac6c55 100644
--- a/sound/soc/codecs/max98388.c
+++ b/sound/soc/codecs/max98388.c
@@ -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,