aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2005-11-20 08:03:48 -0500
committerJaroslav Kysela <perex@suse.cz>2006-01-03 06:29:14 -0500
commit2af677fc884fc6dc79e65c99050ea607ac8bab9b (patch)
tree4291d36c2f116d5887b88da5f0213b68933a1201
parenta106cd3d9e88c8761bd0eac2ce402cc82bd11fea (diff)
[ALSA] dynamic minors (1/6): store device type in struct snd_minor
Instead of a comment string, store the device type in the snd_minor structure. This makes snd_minor more flexible, and has the nice side effect that we don't need anymore to create a separate snd_minor template for registering a device but can pass the file_operations directly to snd_register_device(). Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
-rw-r--r--include/sound/core.h8
-rw-r--r--include/sound/pcm.h3
-rw-r--r--sound/core/control.c11
-rw-r--r--sound/core/hwdep.c11
-rw-r--r--sound/core/oss/mixer_oss.c8
-rw-r--r--sound/core/oss/pcm_oss.c8
-rw-r--r--sound/core/pcm.c6
-rw-r--r--sound/core/pcm_native.c53
-rw-r--r--sound/core/rawmidi.c14
-rw-r--r--sound/core/seq/oss/seq_oss.c9
-rw-r--r--sound/core/seq/seq_clientmgr.c10
-rw-r--r--sound/core/sound.c38
-rw-r--r--sound/core/sound_oss.c35
-rw-r--r--sound/core/timer.c8
14 files changed, 108 insertions, 114 deletions
diff --git a/include/sound/core.h b/include/sound/core.h
index f00b9c9b567f..f557c8ac450e 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -185,8 +185,8 @@ static inline int snd_power_wait(struct snd_card *card, unsigned int state, stru
185struct snd_minor { 185struct snd_minor {
186 struct list_head list; /* list of all minors per card */ 186 struct list_head list; /* list of all minors per card */
187 int number; /* minor number */ 187 int number; /* minor number */
188 int type; /* SNDRV_DEVICE_TYPE_XXX */
188 int device; /* device number */ 189 int device; /* device number */
189 const char *comment; /* for /proc/asound/devices */
190 struct file_operations *f_ops; /* file operations */ 190 struct file_operations *f_ops; /* file operations */
191 char name[0]; /* device name (keep at the end of 191 char name[0]; /* device name (keep at the end of
192 structure) */ 192 structure) */
@@ -199,11 +199,13 @@ extern int snd_ecards_limit;
199 199
200void snd_request_card(int card); 200void snd_request_card(int card);
201 201
202int snd_register_device(int type, struct snd_card *card, int dev, struct snd_minor *reg, const char *name); 202int snd_register_device(int type, struct snd_card *card, int dev,
203 struct file_operations *f_ops, const char *name);
203int snd_unregister_device(int type, struct snd_card *card, int dev); 204int snd_unregister_device(int type, struct snd_card *card, int dev);
204 205
205#ifdef CONFIG_SND_OSSEMUL 206#ifdef CONFIG_SND_OSSEMUL
206int snd_register_oss_device(int type, struct snd_card *card, int dev, struct snd_minor *reg, const char *name); 207int snd_register_oss_device(int type, struct snd_card *card, int dev,
208 struct file_operations *f_ops, const char *name);
207int snd_unregister_oss_device(int type, struct snd_card *card, int dev); 209int snd_unregister_oss_device(int type, struct snd_card *card, int dev);
208#endif 210#endif
209 211
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 7e77c0add80a..5e29b0e0f214 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -402,7 +402,6 @@ struct snd_pcm_str {
402 struct snd_pcm_oss_stream oss; 402 struct snd_pcm_oss_stream oss;
403#endif 403#endif
404 struct snd_pcm_file *files; 404 struct snd_pcm_file *files;
405 struct snd_minor *reg;
406 struct snd_info_entry *proc_root; 405 struct snd_info_entry *proc_root;
407 struct snd_info_entry *proc_info_entry; 406 struct snd_info_entry *proc_info_entry;
408#ifdef CONFIG_SND_DEBUG 407#ifdef CONFIG_SND_DEBUG
@@ -441,7 +440,7 @@ struct snd_pcm_notify {
441 */ 440 */
442 441
443extern struct snd_pcm *snd_pcm_devices[]; 442extern struct snd_pcm *snd_pcm_devices[];
444extern struct snd_minor snd_pcm_reg[2]; 443extern struct file_operations snd_pcm_f_ops[2];
445 444
446int snd_pcm_new(struct snd_card *card, char *id, int device, 445int snd_pcm_new(struct snd_card *card, char *id, int device,
447 int playback_count, int capture_count, 446 int playback_count, int capture_count,
diff --git a/sound/core/control.c b/sound/core/control.c
index f8f98cc52417..23561e74712b 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -1264,12 +1264,6 @@ static struct file_operations snd_ctl_f_ops =
1264 .fasync = snd_ctl_fasync, 1264 .fasync = snd_ctl_fasync,
1265}; 1265};
1266 1266
1267static struct snd_minor snd_ctl_reg =
1268{
1269 .comment = "ctl",
1270 .f_ops = &snd_ctl_f_ops,
1271};
1272
1273/* 1267/*
1274 * registration of the control device 1268 * registration of the control device
1275 */ 1269 */
@@ -1284,7 +1278,7 @@ static int snd_ctl_dev_register(struct snd_device *device)
1284 snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); 1278 snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO);
1285 sprintf(name, "controlC%i", cardnum); 1279 sprintf(name, "controlC%i", cardnum);
1286 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, 1280 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL,
1287 card, 0, &snd_ctl_reg, name)) < 0) 1281 card, -1, &snd_ctl_f_ops, name)) < 0)
1288 return err; 1282 return err;
1289 return 0; 1283 return 0;
1290} 1284}
@@ -1336,7 +1330,8 @@ static int snd_ctl_dev_unregister(struct snd_device *device)
1336 snd_assert(card != NULL, return -ENXIO); 1330 snd_assert(card != NULL, return -ENXIO);
1337 cardnum = card->number; 1331 cardnum = card->number;
1338 snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); 1332 snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO);
1339 if ((err = snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL, card, 0)) < 0) 1333 if ((err = snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL,
1334 card, -1)) < 0)
1340 return err; 1335 return err;
1341 return snd_ctl_dev_free(device); 1336 return snd_ctl_dev_free(device);
1342} 1337}
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c
index 444e266e7c48..27d5bf7266f0 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -330,12 +330,6 @@ static struct file_operations snd_hwdep_f_ops =
330 .mmap = snd_hwdep_mmap, 330 .mmap = snd_hwdep_mmap,
331}; 331};
332 332
333static struct snd_minor snd_hwdep_reg =
334{
335 .comment = "hardware dependent",
336 .f_ops = &snd_hwdep_f_ops,
337};
338
339/** 333/**
340 * snd_hwdep_new - create a new hwdep instance 334 * snd_hwdep_new - create a new hwdep instance
341 * @card: the card instance 335 * @card: the card instance
@@ -416,7 +410,7 @@ static int snd_hwdep_dev_register(struct snd_device *device)
416 sprintf(name, "hwC%iD%i", hwdep->card->number, hwdep->device); 410 sprintf(name, "hwC%iD%i", hwdep->card->number, hwdep->device);
417 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP, 411 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP,
418 hwdep->card, hwdep->device, 412 hwdep->card, hwdep->device,
419 &snd_hwdep_reg, name)) < 0) { 413 &snd_hwdep_f_ops, name)) < 0) {
420 snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n", 414 snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n",
421 hwdep->card->number, hwdep->device); 415 hwdep->card->number, hwdep->device);
422 snd_hwdep_devices[idx] = NULL; 416 snd_hwdep_devices[idx] = NULL;
@@ -431,7 +425,8 @@ static int snd_hwdep_dev_register(struct snd_device *device)
431 } else { 425 } else {
432 if (snd_register_oss_device(hwdep->oss_type, 426 if (snd_register_oss_device(hwdep->oss_type,
433 hwdep->card, hwdep->device, 427 hwdep->card, hwdep->device,
434 &snd_hwdep_reg, hwdep->oss_dev) < 0) { 428 &snd_hwdep_f_ops,
429 hwdep->oss_dev) < 0) {
435 snd_printk(KERN_ERR "unable to register OSS compatibility device %i:%i\n", 430 snd_printk(KERN_ERR "unable to register OSS compatibility device %i:%i\n",
436 hwdep->card->number, hwdep->device); 431 hwdep->card->number, hwdep->device);
437 } else 432 } else
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index e448002ca7b9..2dd6bf9b49ed 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -398,12 +398,6 @@ static struct file_operations snd_mixer_oss_f_ops =
398 .compat_ioctl = snd_mixer_oss_ioctl_compat, 398 .compat_ioctl = snd_mixer_oss_ioctl_compat,
399}; 399};
400 400
401static struct snd_minor snd_mixer_oss_reg =
402{
403 .comment = "mixer",
404 .f_ops = &snd_mixer_oss_f_ops,
405};
406
407/* 401/*
408 * utilities 402 * utilities
409 */ 403 */
@@ -1292,7 +1286,7 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd)
1292 sprintf(name, "mixer%i%i", card->number, 0); 1286 sprintf(name, "mixer%i%i", card->number, 0);
1293 if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER, 1287 if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER,
1294 card, 0, 1288 card, 0,
1295 &snd_mixer_oss_reg, 1289 &snd_mixer_oss_f_ops,
1296 name)) < 0) { 1290 name)) < 0) {
1297 snd_printk(KERN_ERR "unable to register OSS mixer device %i:%i\n", 1291 snd_printk(KERN_ERR "unable to register OSS mixer device %i:%i\n",
1298 card->number, 0); 1292 card->number, 0);
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index ffc13b9194b7..947bf08df42a 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -2444,18 +2444,12 @@ static struct file_operations snd_pcm_oss_f_reg =
2444 .mmap = snd_pcm_oss_mmap, 2444 .mmap = snd_pcm_oss_mmap,
2445}; 2445};
2446 2446
2447static struct snd_minor snd_pcm_oss_reg =
2448{
2449 .comment = "digital audio",
2450 .f_ops = &snd_pcm_oss_f_reg,
2451};
2452
2453static void register_oss_dsp(struct snd_pcm *pcm, int index) 2447static void register_oss_dsp(struct snd_pcm *pcm, int index)
2454{ 2448{
2455 char name[128]; 2449 char name[128];
2456 sprintf(name, "dsp%i%i", pcm->card->number, pcm->device); 2450 sprintf(name, "dsp%i%i", pcm->card->number, pcm->device);
2457 if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_PCM, 2451 if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_PCM,
2458 pcm->card, index, &snd_pcm_oss_reg, 2452 pcm->card, index, &snd_pcm_oss_f_reg,
2459 name) < 0) { 2453 name) < 0) {
2460 snd_printk(KERN_ERR "unable to register OSS PCM device %i:%i\n", 2454 snd_printk(KERN_ERR "unable to register OSS PCM device %i:%i\n",
2461 pcm->card->number, pcm->device); 2455 pcm->card->number, pcm->device);
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 9305ac357a3e..2bc5f69ec2a8 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -597,7 +597,6 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
597 pstr->stream = stream; 597 pstr->stream = stream;
598 pstr->pcm = pcm; 598 pstr->pcm = pcm;
599 pstr->substream_count = substream_count; 599 pstr->substream_count = substream_count;
600 pstr->reg = &snd_pcm_reg[stream];
601 if (substream_count > 0) { 600 if (substream_count > 0) {
602 err = snd_pcm_stream_proc_init(pstr); 601 err = snd_pcm_stream_proc_init(pstr);
603 if (err < 0) { 602 if (err < 0) {
@@ -897,7 +896,10 @@ static int snd_pcm_dev_register(struct snd_device *device)
897 devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE; 896 devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE;
898 break; 897 break;
899 } 898 }
900 if ((err = snd_register_device(devtype, pcm->card, pcm->device, pcm->streams[cidx].reg, str)) < 0) { 899 if ((err = snd_register_device(devtype, pcm->card,
900 pcm->device,
901 &snd_pcm_f_ops[cidx], str)) < 0)
902 {
901 snd_pcm_devices[idx] = NULL; 903 snd_pcm_devices[idx] = NULL;
902 up(&register_mutex); 904 up(&register_mutex);
903 return err; 905 return err;
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 7bac1cbe38da..bb40c016135e 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3370,40 +3370,29 @@ out:
3370 * Register section 3370 * Register section
3371 */ 3371 */
3372 3372
3373static struct file_operations snd_pcm_f_ops_playback = { 3373struct file_operations snd_pcm_f_ops[2] = {
3374 .owner = THIS_MODULE,
3375 .write = snd_pcm_write,
3376 .writev = snd_pcm_writev,
3377 .open = snd_pcm_open,
3378 .release = snd_pcm_release,
3379 .poll = snd_pcm_playback_poll,
3380 .unlocked_ioctl = snd_pcm_playback_ioctl,
3381 .compat_ioctl = snd_pcm_ioctl_compat,
3382 .mmap = snd_pcm_mmap,
3383 .fasync = snd_pcm_fasync,
3384};
3385
3386static struct file_operations snd_pcm_f_ops_capture = {
3387 .owner = THIS_MODULE,
3388 .read = snd_pcm_read,
3389 .readv = snd_pcm_readv,
3390 .open = snd_pcm_open,
3391 .release = snd_pcm_release,
3392 .poll = snd_pcm_capture_poll,
3393 .unlocked_ioctl = snd_pcm_capture_ioctl,
3394 .compat_ioctl = snd_pcm_ioctl_compat,
3395 .mmap = snd_pcm_mmap,
3396 .fasync = snd_pcm_fasync,
3397};
3398
3399struct snd_minor snd_pcm_reg[2] =
3400{
3401 { 3374 {
3402 .comment = "digital audio playback", 3375 .owner = THIS_MODULE,
3403 .f_ops = &snd_pcm_f_ops_playback, 3376 .write = snd_pcm_write,
3377 .writev = snd_pcm_writev,
3378 .open = snd_pcm_open,
3379 .release = snd_pcm_release,
3380 .poll = snd_pcm_playback_poll,
3381 .unlocked_ioctl = snd_pcm_playback_ioctl,
3382 .compat_ioctl = snd_pcm_ioctl_compat,
3383 .mmap = snd_pcm_mmap,
3384 .fasync = snd_pcm_fasync,
3404 }, 3385 },
3405 { 3386 {
3406 .comment = "digital audio capture", 3387 .owner = THIS_MODULE,
3407 .f_ops = &snd_pcm_f_ops_capture, 3388 .read = snd_pcm_read,
3389 .readv = snd_pcm_readv,
3390 .open = snd_pcm_open,
3391 .release = snd_pcm_release,
3392 .poll = snd_pcm_capture_poll,
3393 .unlocked_ioctl = snd_pcm_capture_ioctl,
3394 .compat_ioctl = snd_pcm_ioctl_compat,
3395 .mmap = snd_pcm_mmap,
3396 .fasync = snd_pcm_fasync,
3408 } 3397 }
3409}; 3398};
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index d703545cae8a..7ac77e5ddcb1 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -1367,12 +1367,6 @@ static struct file_operations snd_rawmidi_f_ops =
1367 .compat_ioctl = snd_rawmidi_ioctl_compat, 1367 .compat_ioctl = snd_rawmidi_ioctl_compat,
1368}; 1368};
1369 1369
1370static struct snd_minor snd_rawmidi_reg =
1371{
1372 .comment = "raw midi",
1373 .f_ops = &snd_rawmidi_f_ops,
1374};
1375
1376static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi, 1370static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi,
1377 struct snd_rawmidi_str *stream, 1371 struct snd_rawmidi_str *stream,
1378 int direction, 1372 int direction,
@@ -1516,7 +1510,7 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
1516 sprintf(name, "midiC%iD%i", rmidi->card->number, rmidi->device); 1510 sprintf(name, "midiC%iD%i", rmidi->card->number, rmidi->device);
1517 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI, 1511 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI,
1518 rmidi->card, rmidi->device, 1512 rmidi->card, rmidi->device,
1519 &snd_rawmidi_reg, name)) < 0) { 1513 &snd_rawmidi_f_ops, name)) < 0) {
1520 snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device); 1514 snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device);
1521 snd_rawmidi_devices[idx] = NULL; 1515 snd_rawmidi_devices[idx] = NULL;
1522 up(&register_mutex); 1516 up(&register_mutex);
@@ -1533,7 +1527,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
1533 rmidi->ossreg = 0; 1527 rmidi->ossreg = 0;
1534 if ((int)rmidi->device == midi_map[rmidi->card->number]) { 1528 if ((int)rmidi->device == midi_map[rmidi->card->number]) {
1535 if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, 1529 if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI,
1536 rmidi->card, 0, &snd_rawmidi_reg, name) < 0) { 1530 rmidi->card, 0,
1531 &snd_rawmidi_f_ops, name) < 0) {
1537 snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 0); 1532 snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 0);
1538 } else { 1533 } else {
1539 rmidi->ossreg++; 1534 rmidi->ossreg++;
@@ -1544,7 +1539,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
1544 } 1539 }
1545 if ((int)rmidi->device == amidi_map[rmidi->card->number]) { 1540 if ((int)rmidi->device == amidi_map[rmidi->card->number]) {
1546 if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, 1541 if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI,
1547 rmidi->card, 1, &snd_rawmidi_reg, name) < 0) { 1542 rmidi->card, 1,
1543 &snd_rawmidi_f_ops, name) < 0) {
1548 snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 1); 1544 snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 1);
1549 } else { 1545 } else {
1550 rmidi->ossreg++; 1546 rmidi->ossreg++;
diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c
index 2371e41b13ef..61c0a41376fd 100644
--- a/sound/core/seq/oss/seq_oss.c
+++ b/sound/core/seq/oss/seq_oss.c
@@ -217,11 +217,6 @@ static struct file_operations seq_oss_f_ops =
217 .compat_ioctl = odev_ioctl_compat, 217 .compat_ioctl = odev_ioctl_compat,
218}; 218};
219 219
220static struct snd_minor seq_oss_reg = {
221 .comment = "sequencer",
222 .f_ops = &seq_oss_f_ops,
223};
224
225static int __init 220static int __init
226register_device(void) 221register_device(void)
227{ 222{
@@ -230,7 +225,7 @@ register_device(void)
230 down(&register_mutex); 225 down(&register_mutex);
231 if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, 226 if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER,
232 NULL, 0, 227 NULL, 0,
233 &seq_oss_reg, 228 &seq_oss_f_ops,
234 SNDRV_SEQ_OSS_DEVNAME)) < 0) { 229 SNDRV_SEQ_OSS_DEVNAME)) < 0) {
235 snd_printk(KERN_ERR "can't register device seq\n"); 230 snd_printk(KERN_ERR "can't register device seq\n");
236 up(&register_mutex); 231 up(&register_mutex);
@@ -238,7 +233,7 @@ register_device(void)
238 } 233 }
239 if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC, 234 if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC,
240 NULL, 0, 235 NULL, 0,
241 &seq_oss_reg, 236 &seq_oss_f_ops,
242 SNDRV_SEQ_OSS_DEVNAME)) < 0) { 237 SNDRV_SEQ_OSS_DEVNAME)) < 0) {
243 snd_printk(KERN_ERR "can't register device music\n"); 238 snd_printk(KERN_ERR "can't register device music\n");
244 snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0); 239 snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0);
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 5eab4201c640..087fdf32732b 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -2520,13 +2520,6 @@ static struct file_operations snd_seq_f_ops =
2520 .compat_ioctl = snd_seq_ioctl_compat, 2520 .compat_ioctl = snd_seq_ioctl_compat,
2521}; 2521};
2522 2522
2523static struct snd_minor snd_seq_reg =
2524{
2525 .comment = "sequencer",
2526 .f_ops = &snd_seq_f_ops,
2527};
2528
2529
2530/* 2523/*
2531 * register sequencer device 2524 * register sequencer device
2532 */ 2525 */
@@ -2537,7 +2530,8 @@ int __init snd_sequencer_device_init(void)
2537 if (down_interruptible(&register_mutex)) 2530 if (down_interruptible(&register_mutex))
2538 return -ERESTARTSYS; 2531 return -ERESTARTSYS;
2539 2532
2540 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0, &snd_seq_reg, "seq")) < 0) { 2533 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0,
2534 &snd_seq_f_ops, "seq")) < 0) {
2541 up(&register_mutex); 2535 up(&register_mutex);
2542 return err; 2536 return err;
2543 } 2537 }
diff --git a/sound/core/sound.c b/sound/core/sound.c
index fb236a6b9c34..798c24c2de20 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -195,7 +195,7 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev)
195 * @type: the device type, SNDRV_DEVICE_TYPE_XXX 195 * @type: the device type, SNDRV_DEVICE_TYPE_XXX
196 * @card: the card instance 196 * @card: the card instance
197 * @dev: the device index 197 * @dev: the device index
198 * @reg: the struct snd_minor record 198 * @f_ops: the file operations
199 * @name: the device file name 199 * @name: the device file name
200 * 200 *
201 * Registers an ALSA device file for the given card. 201 * Registers an ALSA device file for the given card.
@@ -203,7 +203,8 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev)
203 * 203 *
204 * Retrurns zero if successful, or a negative error code on failure. 204 * Retrurns zero if successful, or a negative error code on failure.
205 */ 205 */
206int snd_register_device(int type, struct snd_card *card, int dev, struct snd_minor * reg, const char *name) 206int snd_register_device(int type, struct snd_card *card, int dev,
207 struct file_operations *f_ops, const char *name)
207{ 208{
208 int minor = snd_kernel_minor(type, card, dev); 209 int minor = snd_kernel_minor(type, card, dev);
209 struct snd_minor *preg; 210 struct snd_minor *preg;
@@ -212,12 +213,13 @@ int snd_register_device(int type, struct snd_card *card, int dev, struct snd_min
212 if (minor < 0) 213 if (minor < 0)
213 return minor; 214 return minor;
214 snd_assert(name, return -EINVAL); 215 snd_assert(name, return -EINVAL);
215 preg = kmalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL); 216 preg = kzalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL);
216 if (preg == NULL) 217 if (preg == NULL)
217 return -ENOMEM; 218 return -ENOMEM;
218 *preg = *reg;
219 preg->number = minor; 219 preg->number = minor;
220 preg->type = type;
220 preg->device = dev; 221 preg->device = dev;
222 preg->f_ops = f_ops;
221 strcpy(preg->name, name); 223 strcpy(preg->name, name);
222 down(&sound_mutex); 224 down(&sound_mutex);
223 if (snd_minor_search(minor)) { 225 if (snd_minor_search(minor)) {
@@ -276,6 +278,28 @@ int snd_unregister_device(int type, struct snd_card *card, int dev)
276 278
277static struct snd_info_entry *snd_minor_info_entry = NULL; 279static struct snd_info_entry *snd_minor_info_entry = NULL;
278 280
281static const char *snd_device_type_name(int type)
282{
283 switch (type) {
284 case SNDRV_DEVICE_TYPE_CONTROL:
285 return "control";
286 case SNDRV_DEVICE_TYPE_HWDEP:
287 return "hardware dependent";
288 case SNDRV_DEVICE_TYPE_RAWMIDI:
289 return "raw midi";
290 case SNDRV_DEVICE_TYPE_PCM_PLAYBACK:
291 return "digital audio playback";
292 case SNDRV_DEVICE_TYPE_PCM_CAPTURE:
293 return "digital audio capture";
294 case SNDRV_DEVICE_TYPE_SEQUENCER:
295 return "sequencer";
296 case SNDRV_DEVICE_TYPE_TIMER:
297 return "timer";
298 default:
299 return "?";
300 }
301}
302
279static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) 303static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
280{ 304{
281 int card, device; 305 int card, device;
@@ -288,11 +312,11 @@ static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_bu
288 mptr = list_entry(list, struct snd_minor, list); 312 mptr = list_entry(list, struct snd_minor, list);
289 if (SNDRV_MINOR_DEVICE(mptr->number) != SNDRV_MINOR_GLOBAL) { 313 if (SNDRV_MINOR_DEVICE(mptr->number) != SNDRV_MINOR_GLOBAL) {
290 if ((device = mptr->device) >= 0) 314 if ((device = mptr->device) >= 0)
291 snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, device, mptr->comment); 315 snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, device, snd_device_type_name(mptr->type));
292 else 316 else
293 snd_iprintf(buffer, "%3i: [%i] : %s\n", mptr->number, card, mptr->comment); 317 snd_iprintf(buffer, "%3i: [%i] : %s\n", mptr->number, card, snd_device_type_name(mptr->type));
294 } else { 318 } else {
295 snd_iprintf(buffer, "%3i: : %s\n", mptr->number, mptr->comment); 319 snd_iprintf(buffer, "%3i: : %s\n", mptr->number, snd_device_type_name(mptr->type));
296 } 320 }
297 } 321 }
298 } 322 }
diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c
index ec37604ffb68..4d189ffaa764 100644
--- a/sound/core/sound_oss.c
+++ b/sound/core/sound_oss.c
@@ -91,7 +91,7 @@ static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev)
91} 91}
92 92
93int snd_register_oss_device(int type, struct snd_card *card, int dev, 93int snd_register_oss_device(int type, struct snd_card *card, int dev,
94 struct snd_minor * reg, const char *name) 94 struct file_operations *f_ops, const char *name)
95{ 95{
96 int minor = snd_oss_kernel_minor(type, card, dev); 96 int minor = snd_oss_kernel_minor(type, card, dev);
97 int minor_unit; 97 int minor_unit;
@@ -103,12 +103,13 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
103 103
104 if (minor < 0) 104 if (minor < 0)
105 return minor; 105 return minor;
106 preg = (struct snd_minor *)kmalloc(sizeof(struct snd_minor), GFP_KERNEL); 106 preg = kzalloc(sizeof(struct snd_minor), GFP_KERNEL);
107 if (preg == NULL) 107 if (preg == NULL)
108 return -ENOMEM; 108 return -ENOMEM;
109 *preg = *reg;
110 preg->number = minor; 109 preg->number = minor;
110 preg->type = type;
111 preg->device = dev; 111 preg->device = dev;
112 preg->f_ops = f_ops;
112 down(&sound_oss_mutex); 113 down(&sound_oss_mutex);
113 list_add_tail(&preg->list, &snd_oss_minors_hash[cidx]); 114 list_add_tail(&preg->list, &snd_oss_minors_hash[cidx]);
114 minor_unit = SNDRV_MINOR_OSS_DEVICE(minor); 115 minor_unit = SNDRV_MINOR_OSS_DEVICE(minor);
@@ -125,11 +126,12 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
125 } 126 }
126 if (card) 127 if (card)
127 carddev = card->dev; 128 carddev = card->dev;
128 register1 = register_sound_special_device(reg->f_ops, minor, carddev); 129 register1 = register_sound_special_device(f_ops, minor, carddev);
129 if (register1 != minor) 130 if (register1 != minor)
130 goto __end; 131 goto __end;
131 if (track2 >= 0) { 132 if (track2 >= 0) {
132 register2 = register_sound_special_device(reg->f_ops, track2, carddev); 133 register2 = register_sound_special_device(f_ops, track2,
134 carddev);
133 if (register2 != track2) 135 if (register2 != track2)
134 goto __end; 136 goto __end;
135 } 137 }
@@ -190,6 +192,25 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev)
190 192
191static struct snd_info_entry *snd_minor_info_oss_entry = NULL; 193static struct snd_info_entry *snd_minor_info_oss_entry = NULL;
192 194
195static const char *snd_oss_device_type_name(int type)
196{
197 switch (type) {
198 case SNDRV_OSS_DEVICE_TYPE_MIXER:
199 return "mixer";
200 case SNDRV_OSS_DEVICE_TYPE_SEQUENCER:
201 case SNDRV_OSS_DEVICE_TYPE_MUSIC:
202 return "sequencer";
203 case SNDRV_OSS_DEVICE_TYPE_PCM:
204 return "digital audio";
205 case SNDRV_OSS_DEVICE_TYPE_MIDI:
206 return "raw midi";
207 case SNDRV_OSS_DEVICE_TYPE_DMFM:
208 return "hardware dependent";
209 default:
210 return "?";
211 }
212}
213
193static void snd_minor_info_oss_read(struct snd_info_entry *entry, 214static void snd_minor_info_oss_read(struct snd_info_entry *entry,
194 struct snd_info_buffer *buffer) 215 struct snd_info_buffer *buffer)
195{ 216{
@@ -205,9 +226,9 @@ static void snd_minor_info_oss_read(struct snd_info_entry *entry,
205 if (dev != SNDRV_MINOR_OSS_SNDSTAT && 226 if (dev != SNDRV_MINOR_OSS_SNDSTAT &&
206 dev != SNDRV_MINOR_OSS_SEQUENCER && 227 dev != SNDRV_MINOR_OSS_SEQUENCER &&
207 dev != SNDRV_MINOR_OSS_MUSIC) 228 dev != SNDRV_MINOR_OSS_MUSIC)
208 snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, dev, mptr->comment); 229 snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, dev, snd_oss_device_type_name(mptr->type));
209 else 230 else
210 snd_iprintf(buffer, "%3i: : %s\n", mptr->number, mptr->comment); 231 snd_iprintf(buffer, "%3i: : %s\n", mptr->number, snd_oss_device_type_name(mptr->type));
211 } 232 }
212 } 233 }
213 up(&sound_oss_mutex); 234 up(&sound_oss_mutex);
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 6aad411dd7b8..a7bcb04263cb 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -1924,12 +1924,6 @@ static struct file_operations snd_timer_f_ops =
1924 .fasync = snd_timer_user_fasync, 1924 .fasync = snd_timer_user_fasync,
1925}; 1925};
1926 1926
1927static struct snd_minor snd_timer_reg =
1928{
1929 .comment = "timer",
1930 .f_ops = &snd_timer_f_ops,
1931};
1932
1933/* 1927/*
1934 * ENTRY functions 1928 * ENTRY functions
1935 */ 1929 */
@@ -1959,7 +1953,7 @@ static int __init alsa_timer_init(void)
1959 snd_printk(KERN_ERR "unable to register system timer (%i)\n", 1953 snd_printk(KERN_ERR "unable to register system timer (%i)\n",
1960 err); 1954 err);
1961 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, 1955 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER,
1962 NULL, 0, &snd_timer_reg, "timer"))<0) 1956 NULL, 0, &snd_timer_f_ops, "timer")) < 0)
1963 snd_printk(KERN_ERR "unable to register timer device (%i)\n", 1957 snd_printk(KERN_ERR "unable to register timer device (%i)\n",
1964 err); 1958 err);
1965 return 0; 1959 return 0;