]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/char_dev.c
[PATCH] autofs4: change AUTOFS_TYP_* AUTOFS_TYPE_*
[linux-2.6-omap-h63xx.git] / fs / char_dev.c
index 21195c481637658ad4e676ba35c204da83d53d57..8c6eb04d31e2ab9033a067fc42393d5fa8c38a60 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/kobject.h>
 #include <linux/kobj_map.h>
 #include <linux/cdev.h>
+#include <linux/mutex.h>
 
 #ifdef CONFIG_KMOD
 #include <linux/kmod.h>
@@ -28,7 +29,7 @@ static struct kobj_map *cdev_map;
 
 #define MAX_PROBE_HASH 255     /* random */
 
-static DECLARE_MUTEX(chrdevs_lock);
+static DEFINE_MUTEX(chrdevs_lock);
 
 static struct char_device_struct {
        struct char_device_struct *next;
@@ -88,13 +89,13 @@ out:
 
 void *acquire_chrdev_list(void)
 {
-       down(&chrdevs_lock);
+       mutex_lock(&chrdevs_lock);
        return get_next_chrdev(NULL);
 }
 
 void release_chrdev_list(void *dev)
 {
-       up(&chrdevs_lock);
+       mutex_unlock(&chrdevs_lock);
        kfree(dev);
 }
 
@@ -145,13 +146,11 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor,
        int ret = 0;
        int i;
 
-       cd = kmalloc(sizeof(struct char_device_struct), GFP_KERNEL);
+       cd = kzalloc(sizeof(struct char_device_struct), GFP_KERNEL);
        if (cd == NULL)
                return ERR_PTR(-ENOMEM);
 
-       memset(cd, 0, sizeof(struct char_device_struct));
-
-       down(&chrdevs_lock);
+       mutex_lock(&chrdevs_lock);
 
        /* temporary */
        if (major == 0) {
@@ -186,10 +185,10 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor,
        }
        cd->next = *cp;
        *cp = cd;
-       up(&chrdevs_lock);
+       mutex_unlock(&chrdevs_lock);
        return cd;
 out:
-       up(&chrdevs_lock);
+       mutex_unlock(&chrdevs_lock);
        kfree(cd);
        return ERR_PTR(ret);
 }
@@ -200,7 +199,7 @@ __unregister_chrdev_region(unsigned major, unsigned baseminor, int minorct)
        struct char_device_struct *cd = NULL, **cp;
        int i = major_to_index(major);
 
-       down(&chrdevs_lock);
+       mutex_lock(&chrdevs_lock);
        for (cp = &chrdevs[i]; *cp; cp = &(*cp)->next)
                if ((*cp)->major == major &&
                    (*cp)->baseminor == baseminor &&
@@ -210,7 +209,7 @@ __unregister_chrdev_region(unsigned major, unsigned baseminor, int minorct)
                cd = *cp;
                *cp = cd->next;
        }
-       up(&chrdevs_lock);
+       mutex_unlock(&chrdevs_lock);
        return cd;
 }
 
@@ -465,9 +464,8 @@ static struct kobj_type ktype_cdev_dynamic = {
 
 struct cdev *cdev_alloc(void)
 {
-       struct cdev *p = kmalloc(sizeof(struct cdev), GFP_KERNEL);
+       struct cdev *p = kzalloc(sizeof(struct cdev), GFP_KERNEL);
        if (p) {
-               memset(p, 0, sizeof(struct cdev));
                p->kobj.ktype = &ktype_cdev_dynamic;
                INIT_LIST_HEAD(&p->list);
                kobject_init(&p->kobj);