Commit 848669da authored by Takashi Iwai's avatar Takashi Iwai

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: default avatarTakashi Iwai <tiwai@suse.de>
parent a2800300
...@@ -526,31 +526,21 @@ static int create_special_devices(void) ...@@ -526,31 +526,21 @@ static int create_special_devices(void)
} }
/* These device names follow the official Linux device list,
* Documentation/devices.txt. Let us know if there are other
* common names we should support for compatibility.
* Only those devices not created by the generic code in sound_core.c are
* registered here.
*/
static const struct {
unsigned short minor;
char *name;
umode_t mode;
int *num;
} dev_list[] = { /* list of minor devices */
/* seems to be some confusion here -- this device is not in the device list */
{SND_DEV_DSP16, "dspW", S_IWUGO | S_IRUSR | S_IRGRP,
&num_audiodevs},
{SND_DEV_AUDIO, "audio", S_IWUGO | S_IRUSR | S_IRGRP,
&num_audiodevs},
};
static int dmabuf; static int dmabuf;
static int dmabug; static int dmabug;
module_param(dmabuf, int, 0444); module_param(dmabuf, int, 0444);
module_param(dmabug, int, 0444); module_param(dmabug, int, 0444);
/* additional minors for compatibility */
struct oss_minor_dev {
unsigned short minor;
unsigned int enabled;
} dev_list[] = {
{ SND_DEV_DSP16 },
{ SND_DEV_AUDIO },
};
static int __init oss_init(void) static int __init oss_init(void)
{ {
int err; int err;
...@@ -571,18 +561,12 @@ static int __init oss_init(void) ...@@ -571,18 +561,12 @@ static int __init oss_init(void)
sound_dmap_flag = (dmabuf > 0 ? 1 : 0); sound_dmap_flag = (dmabuf > 0 ? 1 : 0);
for (i = 0; i < ARRAY_SIZE(dev_list); i++) { for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
device_create(sound_class, NULL, j = 0;
MKDEV(SOUND_MAJOR, dev_list[i].minor), NULL, do {
"%s", dev_list[i].name); unsigned short minor = dev_list[i].minor + j * 0x10;
if (!register_sound_special(&oss_sound_fops, minor))
if (!dev_list[i].num) dev_list[i].enabled = (1 << j);
continue; } while (++j < num_audiodevs);
for (j = 1; j < *dev_list[i].num; j++)
device_create(sound_class, NULL,
MKDEV(SOUND_MAJOR,
dev_list[i].minor + (j*0x10)),
NULL, "%s%d", dev_list[i].name, j);
} }
if (sound_nblocks >= MAX_MEM_BLOCKS - 1) if (sound_nblocks >= MAX_MEM_BLOCKS - 1)
...@@ -596,11 +580,11 @@ static void __exit oss_cleanup(void) ...@@ -596,11 +580,11 @@ static void __exit oss_cleanup(void)
int i, j; int i, j;
for (i = 0; i < ARRAY_SIZE(dev_list); i++) { for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor)); j = 0;
if (!dev_list[i].num) do {
continue; if (dev_list[i].enabled & (1 << j))
for (j = 1; j < *dev_list[i].num; j++) unregister_sound_special(dev_list[i].minor);
device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10))); } while (++j < num_audiodevs);
} }
unregister_sound_special(1); unregister_sound_special(1);
......
...@@ -384,6 +384,9 @@ int register_sound_special_device(const struct file_operations *fops, int unit, ...@@ -384,6 +384,9 @@ int register_sound_special_device(const struct file_operations *fops, int unit,
case 4: case 4:
name = "audio"; name = "audio";
break; break;
case 5:
name = "dspW";
break;
case 8: case 8:
name = "sequencer2"; name = "sequencer2";
if (unit >= SOUND_STEP) if (unit >= SOUND_STEP)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment