Commit a2280df4 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: maestro3: Simplify with DEFINE_SIMPLE_DEV_PM_OPS()

Use the new DEFINE_SIMPLE_DEV_PM_OPS() instead of SIMPLE_DEV_PM_OPS()
for code-simplification.  We need no longer CONFIG_PM_SLEEP ifdefs.

The area for register dump is conditionally allocated instead of
ifdef now.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20240207155140.18238-25-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent e6c2f5ec
...@@ -769,9 +769,7 @@ struct snd_m3 { ...@@ -769,9 +769,7 @@ struct snd_m3 {
unsigned int in_suspend; unsigned int in_suspend;
#ifdef CONFIG_PM_SLEEP
u16 *suspend_mem; u16 *suspend_mem;
#endif
const struct firmware *assp_kernel_image; const struct firmware *assp_kernel_image;
const struct firmware *assp_minisrc_image; const struct firmware *assp_minisrc_image;
...@@ -2354,9 +2352,7 @@ static void snd_m3_free(struct snd_card *card) ...@@ -2354,9 +2352,7 @@ static void snd_m3_free(struct snd_card *card)
outw(0, chip->iobase + HOST_INT_CTRL); /* disable ints */ outw(0, chip->iobase + HOST_INT_CTRL); /* disable ints */
} }
#ifdef CONFIG_PM_SLEEP
vfree(chip->suspend_mem); vfree(chip->suspend_mem);
#endif
release_firmware(chip->assp_kernel_image); release_firmware(chip->assp_kernel_image);
release_firmware(chip->assp_minisrc_image); release_firmware(chip->assp_minisrc_image);
} }
...@@ -2365,7 +2361,6 @@ static void snd_m3_free(struct snd_card *card) ...@@ -2365,7 +2361,6 @@ static void snd_m3_free(struct snd_card *card)
/* /*
* APM support * APM support
*/ */
#ifdef CONFIG_PM_SLEEP
static int m3_suspend(struct device *dev) static int m3_suspend(struct device *dev)
{ {
struct snd_card *card = dev_get_drvdata(dev); struct snd_card *card = dev_get_drvdata(dev);
...@@ -2439,11 +2434,7 @@ static int m3_resume(struct device *dev) ...@@ -2439,11 +2434,7 @@ static int m3_resume(struct device *dev)
return 0; return 0;
} }
static SIMPLE_DEV_PM_OPS(m3_pm, m3_suspend, m3_resume); static DEFINE_SIMPLE_DEV_PM_OPS(m3_pm, m3_suspend, m3_resume);
#define M3_PM_OPS &m3_pm
#else
#define M3_PM_OPS NULL
#endif /* CONFIG_PM_SLEEP */
#ifdef CONFIG_SND_MAESTRO3_INPUT #ifdef CONFIG_SND_MAESTRO3_INPUT
static int snd_m3_input_register(struct snd_m3 *chip) static int snd_m3_input_register(struct snd_m3 *chip)
...@@ -2587,14 +2578,14 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci, ...@@ -2587,14 +2578,14 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
chip->irq = pci->irq; chip->irq = pci->irq;
card->sync_irq = chip->irq; card->sync_irq = chip->irq;
#ifdef CONFIG_PM_SLEEP if (IS_ENABLED(CONFIG_PM_SLEEP)) {
chip->suspend_mem = chip->suspend_mem =
vmalloc(array_size(sizeof(u16), vmalloc(array_size(sizeof(u16),
REV_B_CODE_MEMORY_LENGTH + REV_B_CODE_MEMORY_LENGTH +
REV_B_DATA_MEMORY_LENGTH)); REV_B_DATA_MEMORY_LENGTH));
if (chip->suspend_mem == NULL) if (!chip->suspend_mem)
dev_warn(card->dev, "can't allocate apm buffer\n"); dev_warn(card->dev, "can't allocate apm buffer\n");
#endif }
err = snd_m3_mixer(chip); err = snd_m3_mixer(chip);
if (err < 0) if (err < 0)
...@@ -2706,7 +2697,7 @@ static struct pci_driver m3_driver = { ...@@ -2706,7 +2697,7 @@ static struct pci_driver m3_driver = {
.id_table = snd_m3_ids, .id_table = snd_m3_ids,
.probe = snd_m3_probe, .probe = snd_m3_probe,
.driver = { .driver = {
.pm = M3_PM_OPS, .pm = &m3_pm,
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment