X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=sound%2Fcore%2Fsound_oss.c;h=ec86009141d0ba1bc43c366107c52b43cbf80ce1;hb=refs%2Fheads%2Fpandora-3.2-.57-wip;hp=0c164e5e43222b1787463fbb265084b4142d4953;hpb=da7806f9b0579a1150f01ade3b562e543ddcbf2c;p=pandora-kernel.git diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c index 0c164e5e4322..ec86009141d0 100644 --- a/sound/core/sound_oss.c +++ b/sound/core/sound_oss.c @@ -26,6 +26,7 @@ #endif #include +#include #include #include #include @@ -39,6 +40,9 @@ static struct snd_minor *snd_oss_minors[SNDRV_OSS_MINORS]; static DEFINE_MUTEX(sound_oss_mutex); +/* NOTE: This function increments the refcount of the associated card like + * snd_lookup_minor_data(); the caller must call snd_card_unref() appropriately + */ void *snd_lookup_oss_minor_data(unsigned int minor, int type) { struct snd_minor *mreg; @@ -48,9 +52,11 @@ void *snd_lookup_oss_minor_data(unsigned int minor, int type) return NULL; mutex_lock(&sound_oss_mutex); mreg = snd_oss_minors[minor]; - if (mreg && mreg->type == type) + if (mreg && mreg->type == type) { private_data = mreg->private_data; - else + if (private_data && mreg->card_ptr) + atomic_inc(&mreg->card_ptr->refcount); + } else private_data = NULL; mutex_unlock(&sound_oss_mutex); return private_data; @@ -122,6 +128,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, preg->device = dev; preg->f_ops = f_ops; preg->private_data = private_data; + preg->card_ptr = card; mutex_lock(&sound_oss_mutex); snd_oss_minors[minor] = preg; minor_unit = SNDRV_MINOR_OSS_DEVICE(minor);