mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:24:47 +01:00
ALSA: hda: Introduce auto cleanup macros for PM
The temporary power up/down of the codec via snd_hda_power_up() and _down() (or snd_hda_power_up_pm() and _down_pm()) is seen in various places. This patch introduces simple auto-cleanup macros for those call patterns, so that the drivers don't have to call the corresponding power-down calls explicitly. Namely, err = snd_hda_power_up(codec); if (err < 0) return err; .... snd_power_down(codec); can drop the *_down() call by replacing with CLASS(snd_hda_power, pm)(codec); if (pm.err < 0) return pm.err; Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20250827072916.31933-2-tiwai@suse.de
This commit is contained in:
parent
4ef353d546
commit
5d8c9c987f
1 changed files with 30 additions and 0 deletions
|
|
@ -503,6 +503,36 @@ static inline bool hda_codec_need_resume(struct hda_codec *codec)
|
|||
return !codec->relaxed_resume && codec->jacktbl.used;
|
||||
}
|
||||
|
||||
/*
|
||||
* PM with auto-cleanup: call like CLASS(snd_hda_power, pm)(codec)
|
||||
* If the error handling is needed, refer pm.err.
|
||||
*/
|
||||
struct __hda_power_obj {
|
||||
struct hda_codec *codec;
|
||||
int err;
|
||||
};
|
||||
|
||||
static inline struct __hda_power_obj __snd_hda_power_up(struct hda_codec *codec)
|
||||
{
|
||||
struct __hda_power_obj T = { .codec = codec };
|
||||
T.err = snd_hda_power_up(codec);
|
||||
return T;
|
||||
}
|
||||
|
||||
static inline struct __hda_power_obj __snd_hda_power_up_pm(struct hda_codec *codec)
|
||||
{
|
||||
struct __hda_power_obj T = { .codec = codec };
|
||||
T.err = snd_hda_power_up_pm(codec);
|
||||
return T;
|
||||
}
|
||||
|
||||
DEFINE_CLASS(snd_hda_power, struct __hda_power_obj,
|
||||
snd_hda_power_down((_T).codec), __snd_hda_power_up(codec),
|
||||
struct hda_codec *codec)
|
||||
DEFINE_CLASS(snd_hda_power_pm, struct __hda_power_obj,
|
||||
snd_hda_power_down_pm((_T).codec), __snd_hda_power_up_pm(codec),
|
||||
struct hda_codec *codec)
|
||||
|
||||
#ifdef CONFIG_SND_HDA_PATCH_LOADER
|
||||
/*
|
||||
* patch firmware
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue