Commit ca8cc756 authored by Jaroslav Kysela's avatar Jaroslav Kysela

ALSA CVS update

D:2003/09/04 19:45:26
C:HWDEP Midlevel
A:Jaroslav Kysela <perex@suse.cz>
F:core/hwdep.c:1.19->1.20 
L:Use try_module_get() and module_put() to block the toplevel module
L:Fixed returned error code in the release() callback
parent 4d616b15
......@@ -97,14 +97,19 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
cardnum %= SNDRV_CARDS;
device %= SNDRV_MINOR_HWDEPS;
hw = snd_hwdep_devices[(cardnum * SNDRV_MINOR_HWDEPS) + device];
if (hw == NULL)
return -ENODEV;
snd_assert(hw != NULL, return -ENODEV);
if (!hw->ops.open)
return -ENXIO;
#ifdef CONFIG_SND_OSSEMUL
if (major == SOUND_MAJOR && hw->oss_type < 0)
return -ENXIO;
#endif
if (!try_module_get(hw->card->module))
return -EFAULT;
init_waitqueue_entry(&wait, current);
add_wait_queue(&hw->open_wait, &wait);
down(&hw->open_mutex);
......@@ -137,9 +142,14 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
if (err >= 0) {
file->private_data = hw;
hw->used++;
} else {
if (hw->ops.release)
hw->ops.release(hw, file);
}
}
up(&hw->open_mutex);
if (err < 0)
module_put(hw->card->module);
return err;
}
......@@ -156,7 +166,8 @@ static int snd_hwdep_release(struct inode *inode, struct file * file)
hw->used--;
snd_card_file_remove(hw->card, file);
up(&hw->open_mutex);
return -ENXIO;
module_put(hw->card->module);
return err;
}
static unsigned int snd_hwdep_poll(struct file * file, poll_table * wait)
......
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