patch-2.4.0-test5 linux/drivers/char/misc.c
Next file: linux/drivers/char/msp3400.c
Previous file: linux/drivers/char/lp.c
Back to the patch index
Back to the overall index
- Lines: 50
- Date:
Mon Jul 24 17:04:12 2000
- Orig file:
v2.4.0-test4/linux/drivers/char/misc.c
- Orig date:
Mon Jul 10 16:47:22 2000
diff -u --recursive --new-file v2.4.0-test4/linux/drivers/char/misc.c linux/drivers/char/misc.c
@@ -112,7 +112,7 @@
int minor = MINOR(inode->i_rdev);
struct miscdevice *c;
int err = -ENODEV;
- struct file_operations *old_fops;
+ struct file_operations *old_fops, *new_fops = NULL;
down(&misc_sem);
@@ -120,7 +120,9 @@
while ((c != &misc_list) && (c->minor != minor))
c = c->next;
- if (c == &misc_list) {
+ if (c != &misc_list)
+ new_fops = fops_get(c->fops);
+ if (!new_fops) {
char modname[20];
up(&misc_sem);
sprintf(modname, "char-major-%d-%d", MISC_MAJOR, minor);
@@ -129,20 +131,19 @@
c = misc_list.next;
while ((c != &misc_list) && (c->minor != minor))
c = c->next;
- if (c == &misc_list)
+ if (c == &misc_list || (new_fops = fops_get(c->fops)) == NULL)
goto fail;
}
+ err = 0;
old_fops = file->f_op;
- file->f_op = fops_get(c->fops);
- if (file->f_op) {
- err = 0;
- 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);
+ file->f_op = 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);
fail:
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)