Commit 848669da3a92fa6ab815e0517af3294afb3ea928
1 parent
a2800300f2
Exists in
master
and in
20 other branches
sound: Use sound_register_*() for additional OSS minor devices
Since OSS driver creates the device entries for /dev/audio* and /dev/dspW* by itself without coping with sound_core, it leads to conflicts with others and let sysfs spewing warnings. This patch rewrites the registration part of OSS driver to use the standard method also for additional minor devices. Reported-by: Steven Rostedt <rostedt@goodmis.org> (with ktest.pl) Tested-by: Steven Rostedt <rostedt@goodmis.org> (with ktest.pl) Signed-off-by: Takashi Iwai <tiwai@suse.de>
Showing 2 changed files with 23 additions and 36 deletions Side-by-side Diff
sound/oss/soundcard.c
... | ... | @@ -526,31 +526,21 @@ |
526 | 526 | } |
527 | 527 | |
528 | 528 | |
529 | -/* These device names follow the official Linux device list, | |
530 | - * Documentation/devices.txt. Let us know if there are other | |
531 | - * common names we should support for compatibility. | |
532 | - * Only those devices not created by the generic code in sound_core.c are | |
533 | - * registered here. | |
534 | - */ | |
535 | -static const struct { | |
536 | - unsigned short minor; | |
537 | - char *name; | |
538 | - umode_t mode; | |
539 | - int *num; | |
540 | -} dev_list[] = { /* list of minor devices */ | |
541 | -/* seems to be some confusion here -- this device is not in the device list */ | |
542 | - {SND_DEV_DSP16, "dspW", S_IWUGO | S_IRUSR | S_IRGRP, | |
543 | - &num_audiodevs}, | |
544 | - {SND_DEV_AUDIO, "audio", S_IWUGO | S_IRUSR | S_IRGRP, | |
545 | - &num_audiodevs}, | |
546 | -}; | |
547 | - | |
548 | 529 | static int dmabuf; |
549 | 530 | static int dmabug; |
550 | 531 | |
551 | 532 | module_param(dmabuf, int, 0444); |
552 | 533 | module_param(dmabug, int, 0444); |
553 | 534 | |
535 | +/* additional minors for compatibility */ | |
536 | +struct oss_minor_dev { | |
537 | + unsigned short minor; | |
538 | + unsigned int enabled; | |
539 | +} dev_list[] = { | |
540 | + { SND_DEV_DSP16 }, | |
541 | + { SND_DEV_AUDIO }, | |
542 | +}; | |
543 | + | |
554 | 544 | static int __init oss_init(void) |
555 | 545 | { |
556 | 546 | int err; |
... | ... | @@ -571,18 +561,12 @@ |
571 | 561 | sound_dmap_flag = (dmabuf > 0 ? 1 : 0); |
572 | 562 | |
573 | 563 | for (i = 0; i < ARRAY_SIZE(dev_list); i++) { |
574 | - device_create(sound_class, NULL, | |
575 | - MKDEV(SOUND_MAJOR, dev_list[i].minor), NULL, | |
576 | - "%s", dev_list[i].name); | |
577 | - | |
578 | - if (!dev_list[i].num) | |
579 | - continue; | |
580 | - | |
581 | - for (j = 1; j < *dev_list[i].num; j++) | |
582 | - device_create(sound_class, NULL, | |
583 | - MKDEV(SOUND_MAJOR, | |
584 | - dev_list[i].minor + (j*0x10)), | |
585 | - NULL, "%s%d", dev_list[i].name, j); | |
564 | + j = 0; | |
565 | + do { | |
566 | + unsigned short minor = dev_list[i].minor + j * 0x10; | |
567 | + if (!register_sound_special(&oss_sound_fops, minor)) | |
568 | + dev_list[i].enabled = (1 << j); | |
569 | + } while (++j < num_audiodevs); | |
586 | 570 | } |
587 | 571 | |
588 | 572 | if (sound_nblocks >= MAX_MEM_BLOCKS - 1) |
... | ... | @@ -596,11 +580,11 @@ |
596 | 580 | int i, j; |
597 | 581 | |
598 | 582 | for (i = 0; i < ARRAY_SIZE(dev_list); i++) { |
599 | - device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor)); | |
600 | - if (!dev_list[i].num) | |
601 | - continue; | |
602 | - for (j = 1; j < *dev_list[i].num; j++) | |
603 | - device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10))); | |
583 | + j = 0; | |
584 | + do { | |
585 | + if (dev_list[i].enabled & (1 << j)) | |
586 | + unregister_sound_special(dev_list[i].minor); | |
587 | + } while (++j < num_audiodevs); | |
604 | 588 | } |
605 | 589 | |
606 | 590 | unregister_sound_special(1); |