Input: use kzalloc() throughout the code
authorEric Sesterhenn <snakebyte@gmx.de>
Tue, 14 Mar 2006 05:09:16 +0000 (00:09 -0500)
committerDmitry Torokhov <dtor_core@ameritech.net>
Tue, 14 Mar 2006 05:09:16 +0000 (00:09 -0500)
Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
13 files changed:
drivers/input/evbug.c
drivers/input/evdev.c
drivers/input/joydev.c
drivers/input/keyboard/hil_kbd.c
drivers/input/mouse/hil_ptr.c
drivers/input/mouse/synaptics.c
drivers/input/mousedev.c
drivers/input/power.c
drivers/input/serio/hil_mlc.c
drivers/input/serio/parkbd.c
drivers/input/serio/rpckbd.c
drivers/input/serio/serio_raw.c
drivers/input/tsdev.c

index d782893..07358fb 100644 (file)
@@ -49,9 +49,8 @@ static struct input_handle *evbug_connect(struct input_handler *handler, struct
 {
        struct input_handle *handle;
 
-       if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL)))
+       if (!(handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL)))
                return NULL;
-       memset(handle, 0, sizeof(struct input_handle));
 
        handle->dev = dev;
        handle->handler = handler;
index 745979f..a34e3d9 100644 (file)
@@ -130,9 +130,8 @@ static int evdev_open(struct inode * inode, struct file * file)
        if ((accept_err = input_accept_process(&(evdev_table[i]->handle), file)))
                return accept_err;
 
-       if (!(list = kmalloc(sizeof(struct evdev_list), GFP_KERNEL)))
+       if (!(list = kzalloc(sizeof(struct evdev_list), GFP_KERNEL)))
                return -ENOMEM;
-       memset(list, 0, sizeof(struct evdev_list));
 
        list->evdev = evdev_table[i];
        list_add_tail(&list->node, &evdev_table[i]->list);
@@ -609,9 +608,8 @@ static struct input_handle *evdev_connect(struct input_handler *handler, struct
                return NULL;
        }
 
-       if (!(evdev = kmalloc(sizeof(struct evdev), GFP_KERNEL)))
+       if (!(evdev = kzalloc(sizeof(struct evdev), GFP_KERNEL)))
                return NULL;
-       memset(evdev, 0, sizeof(struct evdev));
 
        INIT_LIST_HEAD(&evdev->list);
        init_waitqueue_head(&evdev->wait);
index 20e2972..949bdce 100644 (file)
@@ -171,9 +171,8 @@ static int joydev_open(struct inode *inode, struct file *file)
        if (i >= JOYDEV_MINORS || !joydev_table[i])
                return -ENODEV;
 
-       if (!(list = kmalloc(sizeof(struct joydev_list), GFP_KERNEL)))
+       if (!(list = kzalloc(sizeof(struct joydev_list), GFP_KERNEL)))
                return -ENOMEM;
-       memset(list, 0, sizeof(struct joydev_list));
 
        list->joydev = joydev_table[i];
        list_add_tail(&list->node, &joydev_table[i]->list);
@@ -457,9 +456,8 @@ static struct input_handle *joydev_connect(struct input_handler *handler, struct
                return NULL;
        }
 
-       if (!(joydev = kmalloc(sizeof(struct joydev), GFP_KERNEL)))
+       if (!(joydev = kzalloc(sizeof(struct joydev), GFP_KERNEL)))
                return NULL;
-       memset(joydev, 0, sizeof(struct joydev));
 
        INIT_LIST_HEAD(&joydev->list);
        init_waitqueue_head(&joydev->wait);
index 0a90962..ed3271b 100644 (file)
@@ -251,10 +251,9 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
        uint8_t         did, *idd;
        int             i;
        
-       kbd = kmalloc(sizeof(*kbd), GFP_KERNEL);
+       kbd = kzalloc(sizeof(*kbd), GFP_KERNEL);
        if (!kbd)
                return -ENOMEM;
-       memset(kbd, 0, sizeof(struct hil_kbd));
 
        if (serio_open(serio, drv)) goto bail0;
 
index c2bf2ed..798f4a3 100644 (file)
@@ -245,10 +245,11 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
        unsigned int    i, naxsets, btntype;
        uint8_t         did, *idd;
 
-       if (!(ptr = kmalloc(sizeof(struct hil_ptr), GFP_KERNEL))) return -ENOMEM;
-       memset(ptr, 0, sizeof(struct hil_ptr));
+       if (!(ptr = kzalloc(sizeof(struct hil_ptr), GFP_KERNEL)))
+               return -ENOMEM;
 
-       if (serio_open(serio, driver)) goto bail0;
+       if (serio_open(serio, driver))
+               goto bail0;
 
        serio_set_drvdata(serio, ptr);
        ptr->serio = serio;
index 2051bec..d27d52c 100644 (file)
@@ -247,14 +247,12 @@ static void synaptics_pt_create(struct psmouse *psmouse)
 {
        struct serio *serio;
 
-       serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
+       serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
        if (!serio) {
                printk(KERN_ERR "synaptics: not enough memory to allocate pass-through port\n");
                return;
        }
 
-       memset(serio, 0, sizeof(struct serio));
-
        serio->id.type = SERIO_PS_PSTHRU;
        strlcpy(serio->name, "Synaptics pass-through", sizeof(serio->name));
        strlcpy(serio->phys, "synaptics-pt/serio0", sizeof(serio->name));
@@ -623,10 +621,9 @@ int synaptics_init(struct psmouse *psmouse)
 {
        struct synaptics_data *priv;
 
-       psmouse->private = priv = kmalloc(sizeof(struct synaptics_data), GFP_KERNEL);
+       psmouse->private = priv = kzalloc(sizeof(struct synaptics_data), GFP_KERNEL);
        if (!priv)
                return -1;
-       memset(priv, 0, sizeof(struct synaptics_data));
 
        if (synaptics_query_hardware(psmouse)) {
                printk(KERN_ERR "Unable to query Synaptics hardware.\n");
index 9abed18..b685a50 100644 (file)
@@ -412,9 +412,8 @@ static int mousedev_open(struct inode * inode, struct file * file)
        if (i >= MOUSEDEV_MINORS || !mousedev_table[i])
                return -ENODEV;
 
-       if (!(list = kmalloc(sizeof(struct mousedev_list), GFP_KERNEL)))
+       if (!(list = kzalloc(sizeof(struct mousedev_list), GFP_KERNEL)))
                return -ENOMEM;
-       memset(list, 0, sizeof(struct mousedev_list));
 
        spin_lock_init(&list->packet_lock);
        list->pos_x = xres / 2;
@@ -626,9 +625,8 @@ static struct input_handle *mousedev_connect(struct input_handler *handler, stru
                return NULL;
        }
 
-       if (!(mousedev = kmalloc(sizeof(struct mousedev), GFP_KERNEL)))
+       if (!(mousedev = kzalloc(sizeof(struct mousedev), GFP_KERNEL)))
                return NULL;
-       memset(mousedev, 0, sizeof(struct mousedev));
 
        INIT_LIST_HEAD(&mousedev->list);
        init_waitqueue_head(&mousedev->wait);
index bfc5c63..526e607 100644 (file)
@@ -103,9 +103,8 @@ static struct input_handle *power_connect(struct input_handler *handler,
 {
        struct input_handle *handle;
 
-       if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL)))
+       if (!(handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL)))
                return NULL;
-       memset(handle, 0, sizeof(struct input_handle));
 
        handle->dev = dev;
        handle->handler = handler;
index 5704204..73aa8df 100644 (file)
@@ -872,9 +872,8 @@ int hil_mlc_register(hil_mlc *mlc) {
        for (i = 0; i < HIL_MLC_DEVMEM; i++) {
                struct serio *mlc_serio;
                hil_mlc_copy_di_scratch(mlc, i);
-               mlc_serio = kmalloc(sizeof(*mlc_serio), GFP_KERNEL);
+               mlc_serio = kzalloc(sizeof(*mlc_serio), GFP_KERNEL);
                mlc->serio[i] = mlc_serio;
-               memset(mlc_serio, 0, sizeof(*mlc_serio));
                mlc_serio->id                   = hil_mlc_serio_id;
                mlc_serio->write                = hil_mlc_serio_write;
                mlc_serio->open                 = hil_mlc_serio_open;
index 1d15c28..a5c1fb3 100644 (file)
@@ -171,9 +171,8 @@ static struct serio * __init parkbd_allocate_serio(void)
 {
        struct serio *serio;
 
-       serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
+       serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
        if (serio) {
-               memset(serio, 0, sizeof(struct serio));
                serio->id.type = parkbd_mode;
                serio->write = parkbd_write,
                strlcpy(serio->name, "PARKBD AT/XT keyboard adapter", sizeof(serio->name));
index a3bd115..513d37f 100644 (file)
@@ -111,11 +111,10 @@ static int __devinit rpckbd_probe(struct platform_device *dev)
 {
        struct serio *serio;
 
-       serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
+       serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
        if (!serio)
                return -ENOMEM;
 
-       memset(serio, 0, sizeof(struct serio));
        serio->id.type          = SERIO_8042;
        serio->write            = rpckbd_write;
        serio->open             = rpckbd_open;
index 8734e7f..5a2703b 100644 (file)
@@ -96,12 +96,11 @@ static int serio_raw_open(struct inode *inode, struct file *file)
                goto out;
        }
 
-       if (!(list = kmalloc(sizeof(struct serio_raw_list), GFP_KERNEL))) {
+       if (!(list = kzalloc(sizeof(struct serio_raw_list), GFP_KERNEL))) {
                retval = -ENOMEM;
                goto out;
        }
 
-       memset(list, 0, sizeof(struct serio_raw_list));
        list->serio_raw = serio_raw;
        file->private_data = list;
 
@@ -276,14 +275,13 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
        struct serio_raw *serio_raw;
        int err;
 
-       if (!(serio_raw = kmalloc(sizeof(struct serio_raw), GFP_KERNEL))) {
+       if (!(serio_raw = kzalloc(sizeof(struct serio_raw), GFP_KERNEL))) {
                printk(KERN_ERR "serio_raw.c: can't allocate memory for a device\n");
                return -ENOMEM;
        }
 
        mutex_lock(&serio_raw_mutex);
 
-       memset(serio_raw, 0, sizeof(struct serio_raw));
        snprintf(serio_raw->name, sizeof(serio_raw->name), "serio_raw%d", serio_raw_no++);
        serio_raw->refcnt = 1;
        serio_raw->serio = serio;
index ca15479..d678d14 100644 (file)
@@ -157,9 +157,8 @@ static int tsdev_open(struct inode *inode, struct file *file)
        if (i >= TSDEV_MINORS || !tsdev_table[i & TSDEV_MINOR_MASK])
                return -ENODEV;
 
-       if (!(list = kmalloc(sizeof(struct tsdev_list), GFP_KERNEL)))
+       if (!(list = kzalloc(sizeof(struct tsdev_list), GFP_KERNEL)))
                return -ENOMEM;
-       memset(list, 0, sizeof(struct tsdev_list));
 
        list->raw = (i >= TSDEV_MINORS/2) ? 1 : 0;
 
@@ -379,9 +378,8 @@ static struct input_handle *tsdev_connect(struct input_handler *handler,
                return NULL;
        }
 
-       if (!(tsdev = kmalloc(sizeof(struct tsdev), GFP_KERNEL)))
+       if (!(tsdev = kzalloc(sizeof(struct tsdev), GFP_KERNEL)))
                return NULL;
-       memset(tsdev, 0, sizeof(struct tsdev));
 
        INIT_LIST_HEAD(&tsdev->list);
        init_waitqueue_head(&tsdev->wait);