summaryrefslogtreecommitdiffstats
path: root/sound/sound_core.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-09-22 20:17:15 +0200
committerAl Viro <viro@zeniv.linux.org.uk>2013-10-25 05:34:53 +0200
commite84f9e57b90ca89664d733a7cef19aa7ccd832f3 (patch)
tree2766cbae82e38a4356b161a7f48abfd9e4db56ce /sound/sound_core.c
parentput_mnt_ns(): use drop_collected_mounts() (diff)
downloadlinux-e84f9e57b90ca89664d733a7cef19aa7ccd832f3.tar.xz
linux-e84f9e57b90ca89664d733a7cef19aa7ccd832f3.zip
consolidate the reassignments of ->f_op in ->open() instances
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'sound/sound_core.c')
-rw-r--r--sound/sound_core.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/sound/sound_core.c b/sound/sound_core.c
index 45759f4cca75..11e953a1fa45 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -626,31 +626,20 @@ static int soundcore_open(struct inode *inode, struct file *file)
if (s)
new_fops = fops_get(s->unit_fops);
}
+ spin_unlock(&sound_loader_lock);
if (new_fops) {
/*
* We rely upon the fact that we can't be unloaded while the
- * subdriver is there, so if ->open() is successful we can
- * safely drop the reference counter and if it is not we can
- * revert to old ->f_op. Ugly, indeed, but that's the cost of
- * switching ->f_op in the first place.
+ * subdriver is there.
*/
int err = 0;
- const struct file_operations *old_fops = file->f_op;
- file->f_op = new_fops;
- spin_unlock(&sound_loader_lock);
+ replace_fops(file, new_fops);
if (file->f_op->open)
err = file->f_op->open(inode,file);
- if (err) {
- fops_put(file->f_op);
- file->f_op = fops_get(old_fops);
- }
-
- fops_put(old_fops);
return err;
}
- spin_unlock(&sound_loader_lock);
return -ENODEV;
}