patch-2.4.0-test2 linux/drivers/char/misc.c
Next file: linux/drivers/char/mixcomwd.c
Previous file: linux/drivers/char/mem.c
Back to the patch index
Back to the overall index
- Lines: 46
- Date:
Wed Jun 21 22:31:01 2000
- Orig file:
v2.4.0-test1/linux/drivers/char/misc.c
- Orig date:
Thu May 11 15:30:06 2000
diff -u --recursive --new-file v2.4.0-test1/linux/drivers/char/misc.c linux/drivers/char/misc.c
@@ -111,8 +111,7 @@
int minor = MINOR(inode->i_rdev);
struct miscdevice *c;
int err = -ENODEV;
-
- file->f_op = NULL;
+ struct file_operations *old_fops;
down(&misc_sem);
@@ -133,14 +132,22 @@
goto fail;
}
- if ((file->f_op = c->fops) && file->f_op->open)
+ old_fops = file->f_op;
+ file->f_op = fops_get(c->fops);
+ if (file->f_op && 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:
up(&misc_sem);
return err;
}
static struct file_operations misc_fops = {
+ owner: THIS_MODULE,
open: misc_open,
};
@@ -185,9 +192,9 @@
if (!devfs_handle)
devfs_handle = devfs_mk_dir (NULL, "misc", 4, NULL);
misc->devfs_handle =
- devfs_register (devfs_handle, misc->name, 0, DEVFS_FL_NONE,
+ devfs_register (devfs_handle, misc->name, DEVFS_FL_NONE,
MISC_MAJOR, misc->minor,
- S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, 0, 0,
+ S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP,
misc->fops, NULL);
/*
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)