[PATCH] ALSA: hda_acpi: eliminate defined but not used warnings

Randy Dunlap posted 1 patch 6 months, 3 weeks ago
sound/pci/hda/hda_acpi.c |    2 ++
1 file changed, 2 insertions(+)
[PATCH] ALSA: hda_acpi: eliminate defined but not used warnings
Posted by Randy Dunlap 6 months, 3 weeks ago
When CONFIG_PM_SLEEP is not set, the hda_acpi_suspend() and
hda_acpi_resume() functions are not used and cause build warnings:

sound/pci/hda/hda_acpi.c:282:12: warning: 'hda_acpi_resume' defined but not used [-Wunused-function]
  282 | static int hda_acpi_resume(struct device *dev)
sound/pci/hda/hda_acpi.c:269:12: warning: 'hda_acpi_suspend' defined but not used [-Wunused-function]
  269 | static int hda_acpi_suspend(struct device *dev)

Enclose these functions inside an ifdef CONFIG_PM_SLEEP block to
prevent the warnings.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Daniel Dadap <ddadap@nvidia.com>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: linux-sound@vger.kernel.org
---
 sound/pci/hda/hda_acpi.c |    2 ++
 1 file changed, 2 insertions(+)

--- linux-next-20250522.orig/sound/pci/hda/hda_acpi.c
+++ linux-next-20250522/sound/pci/hda/hda_acpi.c
@@ -266,6 +266,7 @@ static void hda_acpi_shutdown(struct pla
 		azx_stop_chip(chip);
 }
 
+#ifdef CONFIG_PM_SLEEP
 static int hda_acpi_suspend(struct device *dev)
 {
 	struct snd_card *card = dev_get_drvdata(dev);
@@ -291,6 +292,7 @@ static int hda_acpi_resume(struct device
 
 	return 0;
 }
+#endif /* CONFIG_PM_SLEEP */
 
 static const struct dev_pm_ops hda_acpi_pm = {
 	SET_SYSTEM_SLEEP_PM_OPS(hda_acpi_suspend, hda_acpi_resume)
Re: [PATCH] ALSA: hda_acpi: eliminate defined but not used warnings
Posted by Takashi Iwai 6 months, 3 weeks ago
On Thu, 22 May 2025 22:30:20 +0200,
Randy Dunlap wrote:
> 
> When CONFIG_PM_SLEEP is not set, the hda_acpi_suspend() and
> hda_acpi_resume() functions are not used and cause build warnings:
> 
> sound/pci/hda/hda_acpi.c:282:12: warning: 'hda_acpi_resume' defined but not used [-Wunused-function]
>   282 | static int hda_acpi_resume(struct device *dev)
> sound/pci/hda/hda_acpi.c:269:12: warning: 'hda_acpi_suspend' defined but not used [-Wunused-function]
>   269 | static int hda_acpi_suspend(struct device *dev)
> 
> Enclose these functions inside an ifdef CONFIG_PM_SLEEP block to
> prevent the warnings.
> 
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Cc: Daniel Dadap <ddadap@nvidia.com>
> Cc: Takashi Iwai <tiwai@suse.de>
> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: linux-sound@vger.kernel.org

Err, it just an incorrect use of SET_SYSTEM_SLEEP_PM_OPS() instead of
SYSTEM_SLEEP_OPS().  It seems that v5 patch went back to a wrong
macro, likely mistakenly.

A fix patch will follow.


thanks,

Takashi
Re: [PATCH] ALSA: hda_acpi: eliminate defined but not used warnings
Posted by Daniel Dadap 6 months, 3 weeks ago
On Thu, May 22, 2025 at 10:42:17PM +0200, Takashi Iwai wrote:
> On Thu, 22 May 2025 22:30:20 +0200,
> Randy Dunlap wrote:
> > 
> > When CONFIG_PM_SLEEP is not set, the hda_acpi_suspend() and
> > hda_acpi_resume() functions are not used and cause build warnings:
> > 
> > sound/pci/hda/hda_acpi.c:282:12: warning: 'hda_acpi_resume' defined but not used [-Wunused-function]
> >   282 | static int hda_acpi_resume(struct device *dev)
> > sound/pci/hda/hda_acpi.c:269:12: warning: 'hda_acpi_suspend' defined but not used [-Wunused-function]
> >   269 | static int hda_acpi_suspend(struct device *dev)
> > 
> > Enclose these functions inside an ifdef CONFIG_PM_SLEEP block to
> > prevent the warnings.
> > 
> > Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> > Cc: Daniel Dadap <ddadap@nvidia.com>
> > Cc: Takashi Iwai <tiwai@suse.de>
> > Cc: Jaroslav Kysela <perex@perex.cz>
> > Cc: linux-sound@vger.kernel.org
> 
> Err, it just an incorrect use of SET_SYSTEM_SLEEP_PM_OPS() instead of
> SYSTEM_SLEEP_OPS().  It seems that v5 patch went back to a wrong
> macro, likely mistakenly.
> 

Sorry about that, I'm not sure how that change got lost between v3 and v5.
(I also introduced a typo in the commit message of v5 that wasn't in the
original patch, oops.)

> A fix patch will follow.
> 
> 
> thanks,
> 
> Takashi