]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] drivers/base/*: use kzalloc instead of kmalloc+memset
authorJiri Slaby <jirislaby@gmail.com>
Tue, 13 Sep 2005 08:25:01 +0000 (01:25 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Tue, 13 Sep 2005 15:22:27 +0000 (08:22 -0700)
Fixes a bunch of memset bugs too.

Signed-off-by: Lion Vollnhals <webmaster@schiggl.de>
Signed-off-by: Jiri Slaby <xslaby@fi.muni.cz>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/base/attribute_container.c
drivers/base/class.c
drivers/base/firmware_class.c
drivers/base/map.c
drivers/base/platform.c

index 373e7b728fa70746bb13907e07114ee0293fd4f6..6b2eb6f39b4dea6ec809acb715cf1c2ab1fc0b45 100644 (file)
@@ -152,12 +152,13 @@ attribute_container_add_device(struct device *dev,
 
                if (!cont->match(cont, dev))
                        continue;
-               ic = kmalloc(sizeof(struct internal_container), GFP_KERNEL);
+
+               ic = kzalloc(sizeof(*ic), GFP_KERNEL);
                if (!ic) {
                        dev_printk(KERN_ERR, dev, "failed to allocate class container\n");
                        continue;
                }
-               memset(ic, 0, sizeof(struct internal_container));
+
                ic->cont = cont;
                class_device_initialize(&ic->classdev);
                ic->classdev.dev = get_device(dev);
index d164c32a97ad4e90426a4f1e8a244b8d5f7d93d3..3b112e3542f897e81bf881b762f3a317ecaefae4 100644 (file)
@@ -189,12 +189,11 @@ struct class *class_create(struct module *owner, char *name)
        struct class *cls;
        int retval;
 
-       cls = kmalloc(sizeof(struct class), GFP_KERNEL);
+       cls = kzalloc(sizeof(*cls), GFP_KERNEL);
        if (!cls) {
                retval = -ENOMEM;
                goto error;
        }
-       memset(cls, 0x00, sizeof(struct class));
 
        cls->name = name;
        cls->owner = owner;
@@ -500,13 +499,13 @@ int class_device_add(struct class_device *class_dev)
        /* add the needed attributes to this device */
        if (MAJOR(class_dev->devt)) {
                struct class_device_attribute *attr;
-               attr = kmalloc(sizeof(*attr), GFP_KERNEL);
+               attr = kzalloc(sizeof(*attr), GFP_KERNEL);
                if (!attr) {
                        error = -ENOMEM;
                        kobject_del(&class_dev->kobj);
                        goto register_done;
                }
-               memset(attr, sizeof(*attr), 0x00);
+
                attr->attr.name = "dev";
                attr->attr.mode = S_IRUGO;
                attr->attr.owner = parent->owner;
@@ -577,12 +576,11 @@ struct class_device *class_device_create(struct class *cls, dev_t devt,
        if (cls == NULL || IS_ERR(cls))
                goto error;
 
-       class_dev = kmalloc(sizeof(struct class_device), GFP_KERNEL);
+       class_dev = kzalloc(sizeof(*class_dev), GFP_KERNEL);
        if (!class_dev) {
                retval = -ENOMEM;
                goto error;
        }
-       memset(class_dev, 0x00, sizeof(struct class_device));
 
        class_dev->devt = devt;
        class_dev->dev = device;
index 5bfa2e9a7c2678efade79213aa5bd203054613b8..4acb2c5733c3b46710d6321b886d16b8704f1d1c 100644 (file)
@@ -301,9 +301,9 @@ fw_register_class_device(struct class_device **class_dev_p,
                         const char *fw_name, struct device *device)
 {
        int retval;
-       struct firmware_priv *fw_priv = kmalloc(sizeof (struct firmware_priv),
+       struct firmware_priv *fw_priv = kzalloc(sizeof(*fw_priv),
                                                GFP_KERNEL);
-       struct class_device *class_dev = kmalloc(sizeof (struct class_device),
+       struct class_device *class_dev = kzalloc(sizeof(*class_dev),
                                                 GFP_KERNEL);
 
        *class_dev_p = NULL;
@@ -313,8 +313,6 @@ fw_register_class_device(struct class_device **class_dev_p,
                retval = -ENOMEM;
                goto error_kfree;
        }
-       memset(fw_priv, 0, sizeof (*fw_priv));
-       memset(class_dev, 0, sizeof (*class_dev));
 
        init_completion(&fw_priv->completion);
        fw_priv->attr_data = firmware_attr_data_tmpl;
@@ -402,14 +400,13 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
        if (!firmware_p)
                return -EINVAL;
 
-       *firmware_p = firmware = kmalloc(sizeof (struct firmware), GFP_KERNEL);
+       *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL);
        if (!firmware) {
                printk(KERN_ERR "%s: kmalloc(struct firmware) failed\n",
                       __FUNCTION__);
                retval = -ENOMEM;
                goto out;
        }
-       memset(firmware, 0, sizeof (*firmware));
 
        retval = fw_setup_class_device(firmware, &class_dev, name, device,
                hotplug);
index 2f455d86793c8bde34098fae2deb80a17e54238d..b449dae6f0d30fcb8385ce68c1f9bdfd34f6ff64 100644 (file)
@@ -135,7 +135,7 @@ retry:
 struct kobj_map *kobj_map_init(kobj_probe_t *base_probe, struct semaphore *sem)
 {
        struct kobj_map *p = kmalloc(sizeof(struct kobj_map), GFP_KERNEL);
-       struct probe *base = kmalloc(sizeof(struct probe), GFP_KERNEL);
+       struct probe *base = kzalloc(sizeof(*base), GFP_KERNEL);
        int i;
 
        if ((p == NULL) || (base == NULL)) {
@@ -144,7 +144,6 @@ struct kobj_map *kobj_map_init(kobj_probe_t *base_probe, struct semaphore *sem)
                return NULL;
        }
 
-       memset(base, 0, sizeof(struct probe));
        base->dev = 1;
        base->range = ~0;
        base->get = base_probe;
index 3a5f4c991797a02eb0de0ecaac726076d88281f9..361e204209ebb3c8324599aecf0716766d1b20c1 100644 (file)
@@ -225,13 +225,12 @@ struct platform_device *platform_device_register_simple(char *name, unsigned int
        struct platform_object *pobj;
        int retval;
 
-       pobj = kmalloc(sizeof(struct platform_object) + sizeof(struct resource) * num, GFP_KERNEL);
+       pobj = kzalloc(sizeof(*pobj) + sizeof(struct resource) * num, GFP_KERNEL);
        if (!pobj) {
                retval = -ENOMEM;
                goto error;
        }
 
-       memset(pobj, 0, sizeof(*pobj));
        pobj->pdev.name = name;
        pobj->pdev.id = id;
        pobj->pdev.dev.release = platform_device_release_simple;