diff options
Diffstat (limited to 'drivers/usb/core/file.c')
-rw-r--r-- | drivers/usb/core/file.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index 3bdfbf88a0ae..ea337a718cc1 100644 --- a/drivers/usb/core/file.c +++ b/drivers/usb/core/file.c | |||
@@ -29,27 +29,19 @@ static DECLARE_RWSEM(minor_rwsem); | |||
29 | 29 | ||
30 | static int usb_open(struct inode *inode, struct file *file) | 30 | static int usb_open(struct inode *inode, struct file *file) |
31 | { | 31 | { |
32 | int minor = iminor(inode); | ||
33 | const struct file_operations *c; | ||
34 | int err = -ENODEV; | 32 | int err = -ENODEV; |
35 | const struct file_operations *old_fops, *new_fops = NULL; | 33 | const struct file_operations *new_fops; |
36 | 34 | ||
37 | down_read(&minor_rwsem); | 35 | down_read(&minor_rwsem); |
38 | c = usb_minors[minor]; | 36 | new_fops = fops_get(usb_minors[iminor(inode)]); |
39 | 37 | ||
40 | if (!c || !(new_fops = fops_get(c))) | 38 | if (!new_fops) |
41 | goto done; | 39 | goto done; |
42 | 40 | ||
43 | old_fops = file->f_op; | 41 | replace_fops(file, new_fops); |
44 | file->f_op = new_fops; | ||
45 | /* Curiouser and curiouser... NULL ->open() as "no device" ? */ | 42 | /* Curiouser and curiouser... NULL ->open() as "no device" ? */ |
46 | if (file->f_op->open) | 43 | if (file->f_op->open) |
47 | err = file->f_op->open(inode, file); | 44 | err = file->f_op->open(inode, file); |
48 | if (err) { | ||
49 | fops_put(file->f_op); | ||
50 | file->f_op = fops_get(old_fops); | ||
51 | } | ||
52 | fops_put(old_fops); | ||
53 | done: | 45 | done: |
54 | up_read(&minor_rwsem); | 46 | up_read(&minor_rwsem); |
55 | return err; | 47 | return err; |