aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/sound_oss.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core/sound_oss.c')
-rw-r--r--sound/core/sound_oss.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c
index e9528333e36d..e1d79ee35906 100644
--- a/sound/core/sound_oss.c
+++ b/sound/core/sound_oss.c
@@ -40,6 +40,9 @@
40static struct snd_minor *snd_oss_minors[SNDRV_OSS_MINORS]; 40static struct snd_minor *snd_oss_minors[SNDRV_OSS_MINORS];
41static DEFINE_MUTEX(sound_oss_mutex); 41static DEFINE_MUTEX(sound_oss_mutex);
42 42
43/* NOTE: This function increments the refcount of the associated card like
44 * snd_lookup_minor_data(); the caller must call snd_card_unref() appropriately
45 */
43void *snd_lookup_oss_minor_data(unsigned int minor, int type) 46void *snd_lookup_oss_minor_data(unsigned int minor, int type)
44{ 47{
45 struct snd_minor *mreg; 48 struct snd_minor *mreg;
@@ -49,9 +52,11 @@ void *snd_lookup_oss_minor_data(unsigned int minor, int type)
49 return NULL; 52 return NULL;
50 mutex_lock(&sound_oss_mutex); 53 mutex_lock(&sound_oss_mutex);
51 mreg = snd_oss_minors[minor]; 54 mreg = snd_oss_minors[minor];
52 if (mreg && mreg->type == type) 55 if (mreg && mreg->type == type) {
53 private_data = mreg->private_data; 56 private_data = mreg->private_data;
54 else 57 if (mreg->card_ptr)
58 atomic_inc(&mreg->card_ptr->refcount);
59 } else
55 private_data = NULL; 60 private_data = NULL;
56 mutex_unlock(&sound_oss_mutex); 61 mutex_unlock(&sound_oss_mutex);
57 return private_data; 62 return private_data;
@@ -123,6 +128,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
123 preg->device = dev; 128 preg->device = dev;
124 preg->f_ops = f_ops; 129 preg->f_ops = f_ops;
125 preg->private_data = private_data; 130 preg->private_data = private_data;
131 preg->card_ptr = card;
126 mutex_lock(&sound_oss_mutex); 132 mutex_lock(&sound_oss_mutex);
127 snd_oss_minors[minor] = preg; 133 snd_oss_minors[minor] = preg;
128 minor_unit = SNDRV_MINOR_OSS_DEVICE(minor); 134 minor_unit = SNDRV_MINOR_OSS_DEVICE(minor);