aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/sound_oss.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2005-11-20 08:06:59 -0500
committerJaroslav Kysela <perex@suse.cz>2006-01-03 06:29:17 -0500
commitf87135f56cb266e031f5ec081dfbde7e43f55e80 (patch)
treec048abae6bb04df53f5d8d7dcffbf2c28bc638ff /sound/core/sound_oss.c
parent6983b7240cd229787c3ee00e663ea94ea649d96a (diff)
[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 afbfd8df129..b9e89cac4c5 100644
--- a/sound/core/sound_oss.c
+++ b/sound/core/sound_oss.c
@@ -38,9 +38,25 @@
38#define SNDRV_OSS_MINORS 128 38#define SNDRV_OSS_MINORS 128
39 39
40static struct snd_minor *snd_oss_minors[SNDRV_OSS_MINORS]; 40static struct snd_minor *snd_oss_minors[SNDRV_OSS_MINORS];
41
42static DECLARE_MUTEX(sound_oss_mutex); 41static DECLARE_MUTEX(sound_oss_mutex);
43 42
43void *snd_lookup_oss_minor_data(unsigned int minor, int type)
44{
45 struct snd_minor *mreg;
46 void *private_data;
47
48 if (minor > ARRAY_SIZE(snd_oss_minors))
49 return NULL;
50 down(&sound_oss_mutex);
51 mreg = snd_oss_minors[minor];
52 if (mreg && mreg->type == type)
53 private_data = mreg->private_data;
54 else
55 private_data = NULL;
56 up(&sound_oss_mutex);
57 return private_data;
58}
59
44static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev) 60static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev)
45{ 61{
46 int minor; 62 int minor;
@@ -78,7 +94,8 @@ static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev)
78} 94}
79 95
80int snd_register_oss_device(int type, struct snd_card *card, int dev, 96int snd_register_oss_device(int type, struct snd_card *card, int dev,
81 struct file_operations *f_ops, const char *name) 97 struct file_operations *f_ops, void *private_data,
98 const char *name)
82{ 99{
83 int minor = snd_oss_kernel_minor(type, card, dev); 100 int minor = snd_oss_kernel_minor(type, card, dev);
84 int minor_unit; 101 int minor_unit;
@@ -97,6 +114,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
97 preg->card = card ? card->number : -1; 114 preg->card = card ? card->number : -1;
98 preg->device = dev; 115 preg->device = dev;
99 preg->f_ops = f_ops; 116 preg->f_ops = f_ops;
117 preg->private_data = private_data;
100 down(&sound_oss_mutex); 118 down(&sound_oss_mutex);
101 snd_oss_minors[minor] = preg; 119 snd_oss_minors[minor] = preg;
102 minor_unit = SNDRV_MINOR_OSS_DEVICE(minor); 120 minor_unit = SNDRV_MINOR_OSS_DEVICE(minor);
@@ -121,6 +139,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
121 carddev); 139 carddev);
122 if (register2 != track2) 140 if (register2 != track2)
123 goto __end; 141 goto __end;
142 snd_oss_minors[track2] = preg;
124 } 143 }
125 up(&sound_oss_mutex); 144 up(&sound_oss_mutex);
126 return 0; 145 return 0;
@@ -163,8 +182,10 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev)
163 track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI1); 182 track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI1);
164 break; 183 break;
165 } 184 }
166 if (track2 >= 0) 185 if (track2 >= 0) {
167 unregister_sound_special(track2); 186 unregister_sound_special(track2);
187 snd_oss_minors[track2] = NULL;
188 }
168 snd_oss_minors[minor] = NULL; 189 snd_oss_minors[minor] = NULL;
169 up(&sound_oss_mutex); 190 up(&sound_oss_mutex);
170 kfree(mptr); 191 kfree(mptr);