summaryrefslogtreecommitdiff
path: root/drivers/usb/core/file.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-09-22 14:17:15 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-10-24 23:34:53 -0400
commite84f9e57b90ca89664d733a7cef19aa7ccd832f3 (patch)
tree2766cbae82e38a4356b161a7f48abfd9e4db56ce /drivers/usb/core/file.c
parent7b00ed6fe6321547b9d51f5bfb30e7b5932e6889 (diff)
consolidate the reassignments of ->f_op in ->open() instances
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/usb/core/file.c')
-rw-r--r--drivers/usb/core/file.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index 7421888087a3..fe0d8365411a 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -29,27 +29,19 @@ static DECLARE_RWSEM(minor_rwsem);
static int usb_open(struct inode * inode, struct file * file)
{
- int minor = iminor(inode);
- const struct file_operations *c;
int err = -ENODEV;
- const struct file_operations *old_fops, *new_fops = NULL;
+ const struct file_operations *new_fops;
down_read(&minor_rwsem);
- c = usb_minors[minor];
+ new_fops = fops_get(usb_minors[iminor(inode)]);
- if (!c || !(new_fops = fops_get(c)))
+ if (!new_fops)
goto done;
- old_fops = file->f_op;
- file->f_op = new_fops;
+ replace_fops(file, new_fops);
/* Curiouser and curiouser... NULL ->open() as "no device" ? */
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);
done:
up_read(&minor_rwsem);
return err;