summaryrefslogtreecommitdiffstats
path: root/Kbuild
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2021-07-15 09:58:24 +0200
committerTakashi Iwai <tiwai@suse.de>2021-07-19 16:16:33 +0200
commite8ad415b7a55cb9a9fbfc04696518d5ea0b609b3 (patch)
tree6a79d585bb0a62656db6e7e48d86abc6731ff1d8 /Kbuild
parent427ae2689db0fb6377e39e63fae2991223cdd9e7 (diff)
downloadlinux-e8ad415b7a55cb9a9fbfc04696518d5ea0b609b3.tar.bz2
ALSA: core: Add managed card creation
As a second step for preliminary to widen the devres usages among sound drivers, this patch adds a new ALSA core API function, snd_devm_card_new(), to create a snd_card object via devres. When a card object is created by this new function, snd_card_free() is called automatically and the card object resource gets released at the device unbinding time. However, the story isn't that simple. A caveat is that we have to call snd_card_free() at the very first of the whole resource release procedure, in order to assure that the all exposed devices on user-space are deleted and sync with processes accessing those devices before releasing resources. For achieving it, snd_card_register() adds a new devres action to trigger snd_card_free() automatically when the given card object is a "managed" one. Since usually snd_card_register() is the last step of the initialization, this should work in most cases. With all these tricks, some drivers can get rid of the whole driver remove callback code. About a bit of implementation details: the patch adds two new flags to snd_card object: managed and releasing. The former indicates that the object was created via snd_devm_card_new(), and the latter is used for avoiding the double-free of snd_card_free() calls. Both flags are fairly internal and likely uninteresting to normal users. Link: https://lore.kernel.org/r/20210715075941.23332-3-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'Kbuild')
0 files changed, 0 insertions, 0 deletions