]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: es1688: add ISA suspend and resume callbacks
authorCássio Gabriel <cassiogabrielcontato@gmail.com>
Wed, 1 Apr 2026 11:45:37 +0000 (08:45 -0300)
committerTakashi Iwai <tiwai@suse.de>
Wed, 1 Apr 2026 12:46:41 +0000 (14:46 +0200)
The ISA ES1688 driver still carries a disabled suspend/resume block in
its isa_driver definition, while the same file already provides minimal
power-management handling for the PnP ES968 path.

Add ISA-specific PM callbacks and factor the existing ES1688 suspend and
resume sequence into common card-level helpers shared by both probe
paths. Suspend moves the card to D3hot. Resume reinitializes the chip
with snd_es1688_reset() and restores the card to D0, propagating reset
failures to the caller.

This wires up power-management callbacks for the ISA path and keeps the
PM handling consistent between the ISA and PnP probe paths.

Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
Link: https://patch.msgid.link/20260401-alsa-es1688-pm-v1-1-510767628fe6@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/isa/es1688/es1688.c

index 6a95dfb7600a3bc7333fdabaafbcb7d79ed75dac..7255b34f914888bed809fb497bd1fb6ea8f74307 100644 (file)
@@ -184,12 +184,44 @@ static int snd_es1688_isa_probe(struct device *dev, unsigned int n)
        return 0;
 }
 
+#ifdef CONFIG_PM
+static int snd_es1688_card_suspend(struct snd_card *card)
+{
+       snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
+       return 0;
+}
+
+static int snd_es1688_card_resume(struct snd_card *card)
+{
+       struct snd_es1688 *chip = card->private_data;
+       int err;
+
+       err = snd_es1688_reset(chip);
+       if (err < 0)
+               return err;
+
+       snd_power_change_state(card, SNDRV_CTL_POWER_D0);
+       return 0;
+}
+
+static int snd_es1688_isa_suspend(struct device *dev, unsigned int n,
+                                 pm_message_t state)
+{
+       return snd_es1688_card_suspend(dev_get_drvdata(dev));
+}
+
+static int snd_es1688_isa_resume(struct device *dev, unsigned int n)
+{
+       return snd_es1688_card_resume(dev_get_drvdata(dev));
+}
+#endif
+
 static struct isa_driver snd_es1688_driver = {
        .match          = snd_es1688_match,
        .probe          = snd_es1688_isa_probe,
-#if 0  /* FIXME */
-       .suspend        = snd_es1688_suspend,
-       .resume         = snd_es1688_resume,
+#ifdef CONFIG_PM
+       .suspend        = snd_es1688_isa_suspend,
+       .resume         = snd_es1688_isa_resume,
 #endif
        .driver         = {
                .name   = DEV_NAME
@@ -266,20 +298,12 @@ static void snd_es968_pnp_remove(struct pnp_card_link *pcard)
 static int snd_es968_pnp_suspend(struct pnp_card_link *pcard,
                                 pm_message_t state)
 {
-       struct snd_card *card = pnp_get_card_drvdata(pcard);
-
-       snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
-       return 0;
+       return snd_es1688_card_suspend(pnp_get_card_drvdata(pcard));
 }
 
 static int snd_es968_pnp_resume(struct pnp_card_link *pcard)
 {
-       struct snd_card *card = pnp_get_card_drvdata(pcard);
-       struct snd_es1688 *chip = card->private_data;
-
-       snd_es1688_reset(chip);
-       snd_power_change_state(card, SNDRV_CTL_POWER_D0);
-       return 0;
+       return snd_es1688_card_resume(pnp_get_card_drvdata(pcard));
 }
 #endif