X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fchar%2Fmisc.c;fp=drivers%2Fchar%2Fmisc.c;h=7e975f606924e04b6d24eef36707cbc97723cebc;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=3e4c0414a01a2177d3a1d40638a5dc6b34aa5437;hpb=76828883507a47dae78837ab5dec5a5b4513c667;p=linux-2.6.git diff --git a/drivers/char/misc.c b/drivers/char/misc.c index 3e4c0414a..7e975f606 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c @@ -34,7 +34,6 @@ */ #include -#include #include #include @@ -44,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -115,7 +113,7 @@ static int misc_seq_open(struct inode *inode, struct file *file) return seq_open(file, &misc_seq_ops); } -static struct file_operations misc_proc_fops = { +static const struct file_operations misc_proc_fops = { .owner = THIS_MODULE, .open = misc_seq_open, .read = seq_read, @@ -129,7 +127,7 @@ static int misc_open(struct inode * inode, struct file * file) int minor = iminor(inode); struct miscdevice *c; int err = -ENODEV; - struct file_operations *old_fops, *new_fops = NULL; + const struct file_operations *old_fops, *new_fops = NULL; down(&misc_sem); @@ -171,14 +169,9 @@ fail: return err; } -/* - * TODO for 2.7: - * - add a struct kref to struct miscdevice and make all usages of - * them dynamic. - */ static struct class *misc_class; -static struct file_operations misc_fops = { +static const struct file_operations misc_fops = { .owner = THIS_MODULE, .open = misc_open, }; @@ -204,7 +197,9 @@ int misc_register(struct miscdevice * misc) { struct miscdevice *c; dev_t dev; - int err; + int err = 0; + + INIT_LIST_HEAD(&misc->list); down(&misc_sem); list_for_each_entry(c, &misc_list, list) { @@ -228,23 +223,12 @@ int misc_register(struct miscdevice * misc) if (misc->minor < DYNAMIC_MINORS) misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7); - if (misc->devfs_name[0] == '\0') { - snprintf(misc->devfs_name, sizeof(misc->devfs_name), - "misc/%s", misc->name); - } dev = MKDEV(MISC_MAJOR, misc->minor); - misc->class = class_device_create(misc_class, NULL, dev, misc->dev, + misc->this_device = device_create(misc_class, misc->parent, dev, "%s", misc->name); - if (IS_ERR(misc->class)) { - err = PTR_ERR(misc->class); - goto out; - } - - err = devfs_mk_cdev(dev, S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP, - misc->devfs_name); - if (err) { - class_device_destroy(misc_class, dev); + if (IS_ERR(misc->this_device)) { + err = PTR_ERR(misc->this_device); goto out; } @@ -277,8 +261,7 @@ int misc_deregister(struct miscdevice * misc) down(&misc_sem); list_del(&misc->list); - class_device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor)); - devfs_remove(misc->devfs_name); + device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor)); if (i < DYNAMIC_MINORS && i>0) { misc_minors[i>>3] &= ~(1 << (misc->minor & 7)); }