From f686291040f05ed23d74cc71910223426888d81b Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 22 Sep 2013 14:17:15 -0400 Subject: upstream: consolidate the reassignments of ->f_op in ->open() instances Signed-off-by: Al Viro --- drivers/usb/core/file.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index e5387a47ef6..89f90f61247 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; -- cgit v1.2.3