]> Pileus Git - ~andy/linux/blobdiff - fs/char_dev.c
sit: rename rtnl functions for consistency
[~andy/linux] / fs / char_dev.c
index dca9e5e0f73b2500b1ce4e0d1b722a2d5de999ee..afc2bb6917806e85ee916d8b2c25cb2183890055 100644 (file)
@@ -272,7 +272,7 @@ int __register_chrdev(unsigned int major, unsigned int baseminor,
        cd = __register_chrdev_region(major, baseminor, count, name);
        if (IS_ERR(cd))
                return PTR_ERR(cd);
-       
+
        cdev = cdev_alloc();
        if (!cdev)
                goto out2;
@@ -280,7 +280,7 @@ int __register_chrdev(unsigned int major, unsigned int baseminor,
        cdev->owner = fops->owner;
        cdev->ops = fops;
        kobject_set_name(&cdev->kobj, "%s", name);
-               
+
        err = cdev_add(cdev, MKDEV(cd->major, baseminor), count);
        if (err)
                goto out;
@@ -405,7 +405,7 @@ static int chrdev_open(struct inode *inode, struct file *filp)
                goto out_cdev_put;
 
        if (filp->f_op->open) {
-               ret = filp->f_op->open(inode,filp);
+               ret = filp->f_op->open(inode, filp);
                if (ret)
                        goto out_cdev_put;
        }
@@ -471,9 +471,19 @@ static int exact_lock(dev_t dev, void *data)
  */
 int cdev_add(struct cdev *p, dev_t dev, unsigned count)
 {
+       int error;
+
        p->dev = dev;
        p->count = count;
-       return kobj_map(cdev_map, dev, count, NULL, exact_match, exact_lock, p);
+
+       error = kobj_map(cdev_map, dev, count, NULL,
+                        exact_match, exact_lock, p);
+       if (error)
+               return error;
+
+       kobject_get(p->kobj.parent);
+
+       return 0;
 }
 
 static void cdev_unmap(dev_t dev, unsigned count)
@@ -498,14 +508,20 @@ void cdev_del(struct cdev *p)
 static void cdev_default_release(struct kobject *kobj)
 {
        struct cdev *p = container_of(kobj, struct cdev, kobj);
+       struct kobject *parent = kobj->parent;
+
        cdev_purge(p);
+       kobject_put(parent);
 }
 
 static void cdev_dynamic_release(struct kobject *kobj)
 {
        struct cdev *p = container_of(kobj, struct cdev, kobj);
+       struct kobject *parent = kobj->parent;
+
        cdev_purge(p);
        kfree(p);
+       kobject_put(parent);
 }
 
 static struct kobj_type ktype_cdev_default = {