summaryrefslogtreecommitdiff
path: root/sound/core/sound_oss.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2005-11-20 14:06:59 +0100
committerJaroslav Kysela <perex@suse.cz>2006-01-03 12:29:17 +0100
commitf87135f56cb266e031f5ec081dfbde7e43f55e80 (patch)
treec048abae6bb04df53f5d8d7dcffbf2c28bc638ff /sound/core/sound_oss.c
parent6983b7240cd229787c3ee00e663ea94ea649d96a (diff)
downloadlinux-rt-f87135f56cb266e031f5ec081dfbde7e43f55e80.tar.gz
[ALSA] dynamic minors (3/6): store device-specific object pointers dynamically
Instead of storing the pointers to the device-specific structures in an array, put them into the struct snd_minor, and look them up dynamically. This makes the device type modules independent of the minor number encoding. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound/core/sound_oss.c')
-rw-r--r--sound/core/sound_oss.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c
index afbfd8df1298..b9e89cac4c5d 100644
--- a/sound/core/sound_oss.c
+++ b/sound/core/sound_oss.c
@@ -38,9 +38,25 @@
#define SNDRV_OSS_MINORS 128
static struct snd_minor *snd_oss_minors[SNDRV_OSS_MINORS];
-
static DECLARE_MUTEX(sound_oss_mutex);
+void *snd_lookup_oss_minor_data(unsigned int minor, int type)
+{
+ struct snd_minor *mreg;
+ void *private_data;
+
+ if (minor > ARRAY_SIZE(snd_oss_minors))
+ return NULL;
+ down(&sound_oss_mutex);
+ mreg = snd_oss_minors[minor];
+ if (mreg && mreg->type == type)
+ private_data = mreg->private_data;
+ else
+ private_data = NULL;
+ up(&sound_oss_mutex);
+ return private_data;
+}
+
static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev)
{
int minor;
@@ -78,7 +94,8 @@ static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev)
}
int snd_register_oss_device(int type, struct snd_card *card, int dev,
- struct file_operations *f_ops, const char *name)
+ struct file_operations *f_ops, void *private_data,
+ const char *name)
{
int minor = snd_oss_kernel_minor(type, card, dev);
int minor_unit;
@@ -97,6 +114,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
preg->card = card ? card->number : -1;
preg->device = dev;
preg->f_ops = f_ops;
+ preg->private_data = private_data;
down(&sound_oss_mutex);
snd_oss_minors[minor] = preg;
minor_unit = SNDRV_MINOR_OSS_DEVICE(minor);
@@ -121,6 +139,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
carddev);
if (register2 != track2)
goto __end;
+ snd_oss_minors[track2] = preg;
}
up(&sound_oss_mutex);
return 0;
@@ -163,8 +182,10 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev)
track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI1);
break;
}
- if (track2 >= 0)
+ if (track2 >= 0) {
unregister_sound_special(track2);
+ snd_oss_minors[track2] = NULL;
+ }
snd_oss_minors[minor] = NULL;
up(&sound_oss_mutex);
kfree(mptr);