aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/sound.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core/sound.c')
-rw-r--r--sound/core/sound.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 1003ae375d47..44a69bb8d4f0 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -34,8 +34,6 @@
34#include <linux/kmod.h> 34#include <linux/kmod.h>
35#include <linux/mutex.h> 35#include <linux/mutex.h>
36 36
37#define SNDRV_OS_MINORS 256
38
39static int major = CONFIG_SND_MAJOR; 37static int major = CONFIG_SND_MAJOR;
40int snd_major; 38int snd_major;
41EXPORT_SYMBOL(snd_major); 39EXPORT_SYMBOL(snd_major);
@@ -208,20 +206,23 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev)
208 minor = type; 206 minor = type;
209 break; 207 break;
210 case SNDRV_DEVICE_TYPE_CONTROL: 208 case SNDRV_DEVICE_TYPE_CONTROL:
211 snd_assert(card != NULL, return -EINVAL); 209 if (snd_BUG_ON(!card))
210 return -EINVAL;
212 minor = SNDRV_MINOR(card->number, type); 211 minor = SNDRV_MINOR(card->number, type);
213 break; 212 break;
214 case SNDRV_DEVICE_TYPE_HWDEP: 213 case SNDRV_DEVICE_TYPE_HWDEP:
215 case SNDRV_DEVICE_TYPE_RAWMIDI: 214 case SNDRV_DEVICE_TYPE_RAWMIDI:
216 case SNDRV_DEVICE_TYPE_PCM_PLAYBACK: 215 case SNDRV_DEVICE_TYPE_PCM_PLAYBACK:
217 case SNDRV_DEVICE_TYPE_PCM_CAPTURE: 216 case SNDRV_DEVICE_TYPE_PCM_CAPTURE:
218 snd_assert(card != NULL, return -EINVAL); 217 if (snd_BUG_ON(!card))
218 return -EINVAL;
219 minor = SNDRV_MINOR(card->number, type + dev); 219 minor = SNDRV_MINOR(card->number, type + dev);
220 break; 220 break;
221 default: 221 default:
222 return -EINVAL; 222 return -EINVAL;
223 } 223 }
224 snd_assert(minor >= 0 && minor < SNDRV_OS_MINORS, return -EINVAL); 224 if (snd_BUG_ON(minor < 0 || minor >= SNDRV_OS_MINORS))
225 return -EINVAL;
225 return minor; 226 return minor;
226} 227}
227#endif 228#endif
@@ -249,7 +250,8 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev,
249 int minor; 250 int minor;
250 struct snd_minor *preg; 251 struct snd_minor *preg;
251 252
252 snd_assert(name, return -EINVAL); 253 if (snd_BUG_ON(!name))
254 return -EINVAL;
253 preg = kmalloc(sizeof *preg, GFP_KERNEL); 255 preg = kmalloc(sizeof *preg, GFP_KERNEL);
254 if (preg == NULL) 256 if (preg == NULL)
255 return -ENOMEM; 257 return -ENOMEM;
@@ -272,9 +274,8 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev,
272 return minor; 274 return minor;
273 } 275 }
274 snd_minors[minor] = preg; 276 snd_minors[minor] = preg;
275 preg->dev = device_create_drvdata(sound_class, device, 277 preg->dev = device_create(sound_class, device, MKDEV(major, minor),
276 MKDEV(major, minor), 278 private_data, "%s", name);
277 private_data, "%s", name);
278 if (IS_ERR(preg->dev)) { 279 if (IS_ERR(preg->dev)) {
279 snd_minors[minor] = NULL; 280 snd_minors[minor] = NULL;
280 mutex_unlock(&sound_mutex); 281 mutex_unlock(&sound_mutex);