Commit f8f137a7 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: echoaudio: 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.

This ends up with the allocation of firmware caches if it's not really
used without CONFIG_PM, but the code simplification should justify the
cost.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20240207155140.18238-21-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent cbdcefbd
...@@ -34,7 +34,6 @@ static int get_firmware(const struct firmware **fw_entry, ...@@ -34,7 +34,6 @@ static int get_firmware(const struct firmware **fw_entry,
int err; int err;
char name[30]; char name[30];
#ifdef CONFIG_PM_SLEEP
if (chip->fw_cache[fw_index]) { if (chip->fw_cache[fw_index]) {
dev_dbg(chip->card->dev, dev_dbg(chip->card->dev,
"firmware requested: %s is cached\n", "firmware requested: %s is cached\n",
...@@ -42,7 +41,6 @@ static int get_firmware(const struct firmware **fw_entry, ...@@ -42,7 +41,6 @@ static int get_firmware(const struct firmware **fw_entry,
*fw_entry = chip->fw_cache[fw_index]; *fw_entry = chip->fw_cache[fw_index];
return 0; return 0;
} }
#endif
dev_dbg(chip->card->dev, dev_dbg(chip->card->dev,
"firmware requested: %s\n", card_fw[fw_index].data); "firmware requested: %s\n", card_fw[fw_index].data);
...@@ -51,10 +49,8 @@ static int get_firmware(const struct firmware **fw_entry, ...@@ -51,10 +49,8 @@ static int get_firmware(const struct firmware **fw_entry,
if (err < 0) if (err < 0)
dev_err(chip->card->dev, dev_err(chip->card->dev,
"get_firmware(): Firmware not available (%d)\n", err); "get_firmware(): Firmware not available (%d)\n", err);
#ifdef CONFIG_PM_SLEEP
else else
chip->fw_cache[fw_index] = *fw_entry; chip->fw_cache[fw_index] = *fw_entry;
#endif
return err; return err;
} }
...@@ -63,18 +59,13 @@ static int get_firmware(const struct firmware **fw_entry, ...@@ -63,18 +59,13 @@ static int get_firmware(const struct firmware **fw_entry,
static void free_firmware(const struct firmware *fw_entry, static void free_firmware(const struct firmware *fw_entry,
struct echoaudio *chip) struct echoaudio *chip)
{ {
#ifdef CONFIG_PM_SLEEP
dev_dbg(chip->card->dev, "firmware not released (kept in cache)\n"); dev_dbg(chip->card->dev, "firmware not released (kept in cache)\n");
#else
release_firmware(fw_entry);
#endif
} }
static void free_firmware_cache(struct echoaudio *chip) static void free_firmware_cache(struct echoaudio *chip)
{ {
#ifdef CONFIG_PM_SLEEP
int i; int i;
for (i = 0; i < 8 ; i++) for (i = 0; i < 8 ; i++)
...@@ -82,8 +73,6 @@ static void free_firmware_cache(struct echoaudio *chip) ...@@ -82,8 +73,6 @@ static void free_firmware_cache(struct echoaudio *chip)
release_firmware(chip->fw_cache[i]); release_firmware(chip->fw_cache[i]);
dev_dbg(chip->card->dev, "release_firmware(%d)\n", i); dev_dbg(chip->card->dev, "release_firmware(%d)\n", i);
} }
#endif
} }
...@@ -2146,8 +2135,6 @@ static int snd_echo_probe(struct pci_dev *pci, ...@@ -2146,8 +2135,6 @@ static int snd_echo_probe(struct pci_dev *pci,
} }
#if defined(CONFIG_PM_SLEEP)
static int snd_echo_suspend(struct device *dev) static int snd_echo_suspend(struct device *dev)
{ {
struct echoaudio *chip = dev_get_drvdata(dev); struct echoaudio *chip = dev_get_drvdata(dev);
...@@ -2237,11 +2224,7 @@ static int snd_echo_resume(struct device *dev) ...@@ -2237,11 +2224,7 @@ static int snd_echo_resume(struct device *dev)
return 0; return 0;
} }
static SIMPLE_DEV_PM_OPS(snd_echo_pm, snd_echo_suspend, snd_echo_resume); static DEFINE_SIMPLE_DEV_PM_OPS(snd_echo_pm, snd_echo_suspend, snd_echo_resume);
#define SND_ECHO_PM_OPS &snd_echo_pm
#else
#define SND_ECHO_PM_OPS NULL
#endif /* CONFIG_PM_SLEEP */
/****************************************************************************** /******************************************************************************
Everything starts and ends here Everything starts and ends here
...@@ -2253,7 +2236,7 @@ static struct pci_driver echo_driver = { ...@@ -2253,7 +2236,7 @@ static struct pci_driver echo_driver = {
.id_table = snd_echo_ids, .id_table = snd_echo_ids,
.probe = snd_echo_probe, .probe = snd_echo_probe,
.driver = { .driver = {
.pm = SND_ECHO_PM_OPS, .pm = &snd_echo_pm,
}, },
}; };
......
...@@ -422,9 +422,7 @@ struct echoaudio { ...@@ -422,9 +422,7 @@ struct echoaudio {
u32 __iomem *dsp_registers; /* DSP's register base */ u32 __iomem *dsp_registers; /* DSP's register base */
u32 active_mask; /* Chs. active mask or u32 active_mask; /* Chs. active mask or
* punks out */ * punks out */
#ifdef CONFIG_PM_SLEEP
const struct firmware *fw_cache[8]; /* Cached firmwares */ const struct firmware *fw_cache[8]; /* Cached firmwares */
#endif
#ifdef ECHOCARD_HAS_MIDI #ifdef ECHOCARD_HAS_MIDI
u16 mtc_state; /* State for MIDI input parsing state machine */ u16 mtc_state; /* State for MIDI input parsing state machine */
......
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