ALSA: via82xx: Simplify with DEFINE_SIMPLE_DEV_PM_OPS()
authorTakashi Iwai <tiwai@suse.de>
Wed, 7 Feb 2024 15:51:39 +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.

This ends up with the allocation of a few additional bytes for the
state dumps even if it's not really used, but the code simplification
should justify the cost.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20240207155140.18238-29-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/via82xx.c
sound/pci/via82xx_modem.c

index d8666ff7bdfae02e8278f7e698fb7927d479c3b7..89838b4fb118a30f51924eca79568fbd4e1d61eb 100644 (file)
@@ -347,13 +347,11 @@ struct via82xx {
 
        unsigned char old_legacy;
        unsigned char old_legacy_cfg;
-#ifdef CONFIG_PM_SLEEP
        unsigned char legacy_saved;
        unsigned char legacy_cfg_saved;
        unsigned char spdif_ctrl_saved;
        unsigned char capture_src_saved[2];
        unsigned int mpu_port_saved;
-#endif
 
        unsigned char playback_volume[4][2]; /* for VIA8233/C/8235; default = 0 */
        unsigned char playback_volume_c[2]; /* for VIA8233/C/8235; default = 0 */
@@ -2031,9 +2029,7 @@ static int snd_via686_init_misc(struct via82xx *chip)
                if (mpu_port >= 0x200) {        /* force MIDI */
                        mpu_port &= 0xfffc;
                        pci_write_config_dword(chip->pci, 0x18, mpu_port | 0x01);
-#ifdef CONFIG_PM_SLEEP
                        chip->mpu_port_saved = mpu_port;
-#endif
                } else {
                        mpu_port = pci_resource_start(chip->pci, 2);
                }
@@ -2085,10 +2081,8 @@ static int snd_via686_init_misc(struct via82xx *chip)
 
        snd_via686_create_gameport(chip, &legacy);
 
-#ifdef CONFIG_PM_SLEEP
        chip->legacy_saved = legacy;
        chip->legacy_cfg_saved = legacy_cfg;
-#endif
 
        return 0;
 }
@@ -2234,7 +2228,6 @@ static int snd_via82xx_chip_init(struct via82xx *chip)
        return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 /*
  * power management
  */
@@ -2287,11 +2280,7 @@ static int snd_via82xx_resume(struct device *dev)
        return 0;
 }
 
-static SIMPLE_DEV_PM_OPS(snd_via82xx_pm, snd_via82xx_suspend, snd_via82xx_resume);
-#define SND_VIA82XX_PM_OPS     &snd_via82xx_pm
-#else
-#define SND_VIA82XX_PM_OPS     NULL
-#endif /* CONFIG_PM_SLEEP */
+static DEFINE_SIMPLE_DEV_PM_OPS(snd_via82xx_pm, snd_via82xx_suspend, snd_via82xx_resume);
 
 static void snd_via82xx_free(struct snd_card *card)
 {
@@ -2576,7 +2565,7 @@ static struct pci_driver via82xx_driver = {
        .id_table = snd_via82xx_ids,
        .probe = snd_via82xx_probe,
        .driver = {
-               .pm = SND_VIA82XX_PM_OPS,
+               .pm = &snd_via82xx_pm,
        },
 };
 
index ca7f024bf8ec6efe5387d205512120cdbc8872aa..a0a49b8d151160482fef70a21e1b32e37575116b 100644 (file)
@@ -1008,7 +1008,6 @@ static int snd_via82xx_chip_init(struct via82xx_modem *chip)
        return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 /*
  * power management
  */
@@ -1042,11 +1041,7 @@ static int snd_via82xx_resume(struct device *dev)
        return 0;
 }
 
-static SIMPLE_DEV_PM_OPS(snd_via82xx_pm, snd_via82xx_suspend, snd_via82xx_resume);
-#define SND_VIA82XX_PM_OPS     &snd_via82xx_pm
-#else
-#define SND_VIA82XX_PM_OPS     NULL
-#endif /* CONFIG_PM_SLEEP */
+static DEFINE_SIMPLE_DEV_PM_OPS(snd_via82xx_pm, snd_via82xx_suspend, snd_via82xx_resume);
 
 static void snd_via82xx_free(struct snd_card *card)
 {
@@ -1168,7 +1163,7 @@ static struct pci_driver via82xx_modem_driver = {
        .id_table = snd_via82xx_modem_ids,
        .probe = snd_via82xx_probe,
        .driver = {
-               .pm = SND_VIA82XX_PM_OPS,
+               .pm = &snd_via82xx_pm,
        },
 };