ALSA: maestro3: Simplify with DEFINE_SIMPLE_DEV_PM_OPS()
authorTakashi Iwai <tiwai@suse.de>
Wed, 7 Feb 2024 15:51:35 +0000 (16:51 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 12 Feb 2024 10:50:26 +0000 (11:50 +0100)
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: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20240207155140.18238-25-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/maestro3.c

index 305cbd24a3918eaddb7c9ff552fa5754d41d3c34..f4d211970d7ec98bb626f1187edc8842c44c13ae 100644 (file)
@@ -769,9 +769,7 @@ struct snd_m3 {
 
        unsigned int in_suspend;
 
-#ifdef CONFIG_PM_SLEEP
        u16 *suspend_mem;
-#endif
 
        const struct firmware *assp_kernel_image;
        const struct firmware *assp_minisrc_image;
@@ -2354,9 +2352,7 @@ static void snd_m3_free(struct snd_card *card)
                outw(0, chip->iobase + HOST_INT_CTRL); /* disable ints */
        }
 
-#ifdef CONFIG_PM_SLEEP
        vfree(chip->suspend_mem);
-#endif
        release_firmware(chip->assp_kernel_image);
        release_firmware(chip->assp_minisrc_image);
 }
@@ -2365,7 +2361,6 @@ static void snd_m3_free(struct snd_card *card)
 /*
  * APM support
  */
-#ifdef CONFIG_PM_SLEEP
 static int m3_suspend(struct device *dev)
 {
        struct snd_card *card = dev_get_drvdata(dev);
@@ -2439,11 +2434,7 @@ static int m3_resume(struct device *dev)
        return 0;
 }
 
-static 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 */
+static DEFINE_SIMPLE_DEV_PM_OPS(m3_pm, m3_suspend, m3_resume);
 
 #ifdef CONFIG_SND_MAESTRO3_INPUT
 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,
        chip->irq = pci->irq;
        card->sync_irq = chip->irq;
 
-#ifdef CONFIG_PM_SLEEP
-       chip->suspend_mem =
-               vmalloc(array_size(sizeof(u16),
-                                  REV_B_CODE_MEMORY_LENGTH +
-                                       REV_B_DATA_MEMORY_LENGTH));
-       if (chip->suspend_mem == NULL)
-               dev_warn(card->dev, "can't allocate apm buffer\n");
-#endif
+       if (IS_ENABLED(CONFIG_PM_SLEEP)) {
+               chip->suspend_mem =
+                       vmalloc(array_size(sizeof(u16),
+                                          REV_B_CODE_MEMORY_LENGTH +
+                                          REV_B_DATA_MEMORY_LENGTH));
+               if (!chip->suspend_mem)
+                       dev_warn(card->dev, "can't allocate apm buffer\n");
+       }
 
        err = snd_m3_mixer(chip);
        if (err < 0)
@@ -2706,7 +2697,7 @@ static struct pci_driver m3_driver = {
        .id_table = snd_m3_ids,
        .probe = snd_m3_probe,
        .driver = {
-               .pm = M3_PM_OPS,
+               .pm = &m3_pm,
        },
 };