diff --git a/include/sound/core.h b/include/sound/core.h index bc05668..9869087 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -185,6 +185,7 @@ static inline int snd_power_wait(struct snd_card *card, unsigned int state) { re struct snd_minor { int type; /* SNDRV_DEVICE_TYPE_XXX */ int card; /* card number */ + struct snd_card *cardp; int device; /* device number */ const struct file_operations *f_ops; /* file operations */ void *private_data; /* private data for f_ops->open */ @@ -241,6 +242,7 @@ static inline int snd_register_device(int type, struct snd_card *card, int dev, int snd_unregister_device(int type, struct snd_card *card, int dev); void *snd_lookup_minor_data(unsigned int minor, int type); +void *snd_lookup_minor_data2(unsigned int minor, int type, struct file *file); int snd_add_device_sysfs_file(int type, struct snd_card *card, int dev, struct device_attribute *attr); diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 8753c89..c2445c0 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -2114,8 +2114,8 @@ static int snd_pcm_playback_open(struct inode *inode, struct file *file) int err = nonseekable_open(inode, file); if (err < 0) return err; - pcm = snd_lookup_minor_data(iminor(inode), - SNDRV_DEVICE_TYPE_PCM_PLAYBACK); + pcm = snd_lookup_minor_data2(iminor(inode), + SNDRV_DEVICE_TYPE_PCM_PLAYBACK, file); return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_PLAYBACK); } @@ -2125,23 +2125,24 @@ static int snd_pcm_capture_open(struct inode *inode, struct file *file) int err = nonseekable_open(inode, file); if (err < 0) return err; - pcm = snd_lookup_minor_data(iminor(inode), - SNDRV_DEVICE_TYPE_PCM_CAPTURE); + pcm = snd_lookup_minor_data2(iminor(inode), + SNDRV_DEVICE_TYPE_PCM_CAPTURE, file); return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_CAPTURE); } +#include static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream) { int err; wait_queue_t wait; + printk("msleep o2 %p\n", pcm); + mdelay(5000); + printk("msleep o2+\n"); if (pcm == NULL) { err = -ENODEV; goto __error1; } - err = snd_card_file_add(pcm->card, file); - if (err < 0) - goto __error1; if (!try_module_get(pcm->card->module)) { err = -EFAULT; goto __error2; diff --git a/sound/core/sound.c b/sound/core/sound.c index 6439760..5ea8010 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -118,6 +118,35 @@ void *snd_lookup_minor_data(unsigned int minor, int type) EXPORT_SYMBOL(snd_lookup_minor_data); +#include +void *snd_lookup_minor_data2(unsigned int minor, int type, struct file *file) +{ + struct snd_minor *mreg; + void *private_data; + + if (minor >= ARRAY_SIZE(snd_minors)) + return NULL; + mutex_lock(&sound_mutex); + mreg = snd_minors[minor]; + if (mreg && mreg->type == type) + private_data = mreg->private_data; + else + private_data = NULL; + printk("msleep o %p\n", NULL); + mdelay(5000); + printk("msleep o+\n"); + + + if (private_data) { + if (snd_card_file_add(mreg->cardp, file) < 0) + private_data = NULL; + } + mutex_unlock(&sound_mutex); + return private_data; +} + +EXPORT_SYMBOL(snd_lookup_minor_data2); + #ifdef CONFIG_MODULES static struct snd_minor *autoload_device(unsigned int minor) { @@ -272,6 +301,7 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev, return -ENOMEM; preg->type = type; preg->card = card ? card->number : -1; + preg->cardp = card; preg->device = dev; preg->f_ops = f_ops; preg->private_data = private_data;