aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
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 /sound/core
parent7b00ed6fe6321547b9d51f5bfb30e7b5932e6889 (diff)
consolidate the reassignments of ->f_op in ->open() instances
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/sound.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/sound/core/sound.c b/sound/core/sound.c
index f002bd911dae..437c25ea6403 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)
153{ 153{
154 unsigned int minor = iminor(inode); 154 unsigned int minor = iminor(inode);
155 struct snd_minor *mptr = NULL; 155 struct snd_minor *mptr = NULL;
156 const struct file_operations *old_fops; 156 const struct file_operations *new_fops;
157 int err = 0; 157 int err = 0;
158 158
159 if (minor >= ARRAY_SIZE(snd_minors)) 159 if (minor >= ARRAY_SIZE(snd_minors))
@@ -167,24 +167,14 @@ static int snd_open(struct inode *inode, struct file *file)
167 return -ENODEV; 167 return -ENODEV;
168 } 168 }
169 } 169 }
170 old_fops = file->f_op; 170 new_fops = fops_get(mptr->f_ops);
171 file->f_op = fops_get(mptr->f_ops);
172 if (file->f_op == NULL) {
173 file->f_op = old_fops;
174 err = -ENODEV;
175 }
176 mutex_unlock(&sound_mutex); 171 mutex_unlock(&sound_mutex);
177 if (err < 0) 172 if (!new_fops)
178 return err; 173 return -ENODEV;
174 replace_fops(file, new_fops);
179 175
180 if (file->f_op->open) { 176 if (file->f_op->open)
181 err = file->f_op->open(inode, file); 177 err = file->f_op->open(inode, file);
182 if (err) {
183 fops_put(file->f_op);
184 file->f_op = fops_get(old_fops);
185 }
186 }
187 fops_put(old_fops);
188 return err; 178 return err;
189} 179}
190 180