summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-09-22 14:17:15 -0400
committerChanho Park <chanho61.park@samsung.com>2014-11-18 11:52:07 +0900
commitf686291040f05ed23d74cc71910223426888d81b (patch)
tree8b3b2edfceb3b75637d6cd29d32c853082fddf27 /sound
parentf0ecf5e5d0c47607a01a43e7dd7ffb649e3e5ec4 (diff)
downloadlinux-3.10-f686291040f05ed23d74cc71910223426888d81b.tar.gz
linux-3.10-f686291040f05ed23d74cc71910223426888d81b.tar.bz2
linux-3.10-f686291040f05ed23d74cc71910223426888d81b.zip
upstream: consolidate the reassignments of ->f_op in ->open() instances
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'sound')
-rw-r--r--sound/core/sound.c22
-rw-r--r--sound/sound_core.c17
2 files changed, 9 insertions, 30 deletions
diff --git a/sound/core/sound.c b/sound/core/sound.c
index f002bd911da..437c25ea640 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -153,7 +153,7 @@ static int snd_open(struct inode *inode, struct file *file)
{
unsigned int minor = iminor(inode);
struct snd_minor *mptr = NULL;
- const struct file_operations *old_fops;
+ const struct file_operations *new_fops;
int err = 0;
if (minor >= ARRAY_SIZE(snd_minors))
@@ -167,24 +167,14 @@ static int snd_open(struct inode *inode, struct file *file)
return -ENODEV;
}
}
- old_fops = file->f_op;
- file->f_op = fops_get(mptr->f_ops);
- if (file->f_op == NULL) {
- file->f_op = old_fops;
- err = -ENODEV;
- }
+ new_fops = fops_get(mptr->f_ops);
mutex_unlock(&sound_mutex);
- if (err < 0)
- return err;
+ if (!new_fops)
+ return -ENODEV;
+ replace_fops(file, new_fops);
- if (file->f_op->open) {
+ 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;
}
diff --git a/sound/sound_core.c b/sound/sound_core.c
index 359753fc24e..3870a0cfbdd 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;
}