ALSA: core: Use kref for card usage refcount
So far we've used the device refcount of card->card_dev for triggering
the free. This doesn't work well, however, when the delayed kobj
release is enabled for debugging. Then the release of card_dev is
also delayed, and the whole snd_device_free_all() and co are delayed
as well.
This patch replaces the card's usage refcount with the own kref for
decoupling between the release-trigger and the actual memory release.
Now the release-trigger (which is done in snd_card_do_free()) is
performed via kref_put() of the card's usage count while the
card_dev's release manages only the card memory.
The new helpers snd_card_get() and snd_card_put() are for managing the
card's usage count. The exinst snd_card_unref() becomes an alias of
snd_card_put() after this change.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 files changed