Commit b39787a972042ded183343b177d9c595b5704575

Authored by Eric Sesterhenn
Committed by Dmitry Torokhov
1 parent 493a7e0d56

Input: use kzalloc() throughout the code

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

Showing 13 changed files with 22 additions and 40 deletions Side-by-side Diff

drivers/input/evbug.c
... ... @@ -49,9 +49,8 @@
49 49 {
50 50 struct input_handle *handle;
51 51  
52   - if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL)))
  52 + if (!(handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL)))
53 53 return NULL;
54   - memset(handle, 0, sizeof(struct input_handle));
55 54  
56 55 handle->dev = dev;
57 56 handle->handler = handler;
drivers/input/evdev.c
... ... @@ -130,9 +130,8 @@
130 130 if ((accept_err = input_accept_process(&(evdev_table[i]->handle), file)))
131 131 return accept_err;
132 132  
133   - if (!(list = kmalloc(sizeof(struct evdev_list), GFP_KERNEL)))
  133 + if (!(list = kzalloc(sizeof(struct evdev_list), GFP_KERNEL)))
134 134 return -ENOMEM;
135   - memset(list, 0, sizeof(struct evdev_list));
136 135  
137 136 list->evdev = evdev_table[i];
138 137 list_add_tail(&list->node, &evdev_table[i]->list);
139 138  
... ... @@ -609,9 +608,8 @@
609 608 return NULL;
610 609 }
611 610  
612   - if (!(evdev = kmalloc(sizeof(struct evdev), GFP_KERNEL)))
  611 + if (!(evdev = kzalloc(sizeof(struct evdev), GFP_KERNEL)))
613 612 return NULL;
614   - memset(evdev, 0, sizeof(struct evdev));
615 613  
616 614 INIT_LIST_HEAD(&evdev->list);
617 615 init_waitqueue_head(&evdev->wait);
drivers/input/joydev.c
... ... @@ -171,9 +171,8 @@
171 171 if (i >= JOYDEV_MINORS || !joydev_table[i])
172 172 return -ENODEV;
173 173  
174   - if (!(list = kmalloc(sizeof(struct joydev_list), GFP_KERNEL)))
  174 + if (!(list = kzalloc(sizeof(struct joydev_list), GFP_KERNEL)))
175 175 return -ENOMEM;
176   - memset(list, 0, sizeof(struct joydev_list));
177 176  
178 177 list->joydev = joydev_table[i];
179 178 list_add_tail(&list->node, &joydev_table[i]->list);
180 179  
... ... @@ -457,9 +456,8 @@
457 456 return NULL;
458 457 }
459 458  
460   - if (!(joydev = kmalloc(sizeof(struct joydev), GFP_KERNEL)))
  459 + if (!(joydev = kzalloc(sizeof(struct joydev), GFP_KERNEL)))
461 460 return NULL;
462   - memset(joydev, 0, sizeof(struct joydev));
463 461  
464 462 INIT_LIST_HEAD(&joydev->list);
465 463 init_waitqueue_head(&joydev->wait);
drivers/input/keyboard/hil_kbd.c
... ... @@ -251,10 +251,9 @@
251 251 uint8_t did, *idd;
252 252 int i;
253 253  
254   - kbd = kmalloc(sizeof(*kbd), GFP_KERNEL);
  254 + kbd = kzalloc(sizeof(*kbd), GFP_KERNEL);
255 255 if (!kbd)
256 256 return -ENOMEM;
257   - memset(kbd, 0, sizeof(struct hil_kbd));
258 257  
259 258 if (serio_open(serio, drv)) goto bail0;
260 259  
drivers/input/mouse/hil_ptr.c
... ... @@ -245,10 +245,11 @@
245 245 unsigned int i, naxsets, btntype;
246 246 uint8_t did, *idd;
247 247  
248   - if (!(ptr = kmalloc(sizeof(struct hil_ptr), GFP_KERNEL))) return -ENOMEM;
249   - memset(ptr, 0, sizeof(struct hil_ptr));
  248 + if (!(ptr = kzalloc(sizeof(struct hil_ptr), GFP_KERNEL)))
  249 + return -ENOMEM;
250 250  
251   - if (serio_open(serio, driver)) goto bail0;
  251 + if (serio_open(serio, driver))
  252 + goto bail0;
252 253  
253 254 serio_set_drvdata(serio, ptr);
254 255 ptr->serio = serio;
drivers/input/mouse/synaptics.c
... ... @@ -247,14 +247,12 @@
247 247 {
248 248 struct serio *serio;
249 249  
250   - serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
  250 + serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
251 251 if (!serio) {
252 252 printk(KERN_ERR "synaptics: not enough memory to allocate pass-through port\n");
253 253 return;
254 254 }
255 255  
256   - memset(serio, 0, sizeof(struct serio));
257   -
258 256 serio->id.type = SERIO_PS_PSTHRU;
259 257 strlcpy(serio->name, "Synaptics pass-through", sizeof(serio->name));
260 258 strlcpy(serio->phys, "synaptics-pt/serio0", sizeof(serio->name));
261 259  
... ... @@ -623,10 +621,9 @@
623 621 {
624 622 struct synaptics_data *priv;
625 623  
626   - psmouse->private = priv = kmalloc(sizeof(struct synaptics_data), GFP_KERNEL);
  624 + psmouse->private = priv = kzalloc(sizeof(struct synaptics_data), GFP_KERNEL);
627 625 if (!priv)
628 626 return -1;
629   - memset(priv, 0, sizeof(struct synaptics_data));
630 627  
631 628 if (synaptics_query_hardware(psmouse)) {
632 629 printk(KERN_ERR "Unable to query Synaptics hardware.\n");
drivers/input/mousedev.c
... ... @@ -412,9 +412,8 @@
412 412 if (i >= MOUSEDEV_MINORS || !mousedev_table[i])
413 413 return -ENODEV;
414 414  
415   - if (!(list = kmalloc(sizeof(struct mousedev_list), GFP_KERNEL)))
  415 + if (!(list = kzalloc(sizeof(struct mousedev_list), GFP_KERNEL)))
416 416 return -ENOMEM;
417   - memset(list, 0, sizeof(struct mousedev_list));
418 417  
419 418 spin_lock_init(&list->packet_lock);
420 419 list->pos_x = xres / 2;
421 420  
... ... @@ -626,9 +625,8 @@
626 625 return NULL;
627 626 }
628 627  
629   - if (!(mousedev = kmalloc(sizeof(struct mousedev), GFP_KERNEL)))
  628 + if (!(mousedev = kzalloc(sizeof(struct mousedev), GFP_KERNEL)))
630 629 return NULL;
631   - memset(mousedev, 0, sizeof(struct mousedev));
632 630  
633 631 INIT_LIST_HEAD(&mousedev->list);
634 632 init_waitqueue_head(&mousedev->wait);
drivers/input/power.c
... ... @@ -103,9 +103,8 @@
103 103 {
104 104 struct input_handle *handle;
105 105  
106   - if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL)))
  106 + if (!(handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL)))
107 107 return NULL;
108   - memset(handle, 0, sizeof(struct input_handle));
109 108  
110 109 handle->dev = dev;
111 110 handle->handler = handler;
drivers/input/serio/hil_mlc.c
... ... @@ -872,9 +872,8 @@
872 872 for (i = 0; i < HIL_MLC_DEVMEM; i++) {
873 873 struct serio *mlc_serio;
874 874 hil_mlc_copy_di_scratch(mlc, i);
875   - mlc_serio = kmalloc(sizeof(*mlc_serio), GFP_KERNEL);
  875 + mlc_serio = kzalloc(sizeof(*mlc_serio), GFP_KERNEL);
876 876 mlc->serio[i] = mlc_serio;
877   - memset(mlc_serio, 0, sizeof(*mlc_serio));
878 877 mlc_serio->id = hil_mlc_serio_id;
879 878 mlc_serio->write = hil_mlc_serio_write;
880 879 mlc_serio->open = hil_mlc_serio_open;
drivers/input/serio/parkbd.c
... ... @@ -171,9 +171,8 @@
171 171 {
172 172 struct serio *serio;
173 173  
174   - serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
  174 + serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
175 175 if (serio) {
176   - memset(serio, 0, sizeof(struct serio));
177 176 serio->id.type = parkbd_mode;
178 177 serio->write = parkbd_write,
179 178 strlcpy(serio->name, "PARKBD AT/XT keyboard adapter", sizeof(serio->name));
drivers/input/serio/rpckbd.c
... ... @@ -111,11 +111,10 @@
111 111 {
112 112 struct serio *serio;
113 113  
114   - serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
  114 + serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
115 115 if (!serio)
116 116 return -ENOMEM;
117 117  
118   - memset(serio, 0, sizeof(struct serio));
119 118 serio->id.type = SERIO_8042;
120 119 serio->write = rpckbd_write;
121 120 serio->open = rpckbd_open;
drivers/input/serio/serio_raw.c
... ... @@ -96,12 +96,11 @@
96 96 goto out;
97 97 }
98 98  
99   - if (!(list = kmalloc(sizeof(struct serio_raw_list), GFP_KERNEL))) {
  99 + if (!(list = kzalloc(sizeof(struct serio_raw_list), GFP_KERNEL))) {
100 100 retval = -ENOMEM;
101 101 goto out;
102 102 }
103 103  
104   - memset(list, 0, sizeof(struct serio_raw_list));
105 104 list->serio_raw = serio_raw;
106 105 file->private_data = list;
107 106  
108 107  
... ... @@ -276,14 +275,13 @@
276 275 struct serio_raw *serio_raw;
277 276 int err;
278 277  
279   - if (!(serio_raw = kmalloc(sizeof(struct serio_raw), GFP_KERNEL))) {
  278 + if (!(serio_raw = kzalloc(sizeof(struct serio_raw), GFP_KERNEL))) {
280 279 printk(KERN_ERR "serio_raw.c: can't allocate memory for a device\n");
281 280 return -ENOMEM;
282 281 }
283 282  
284 283 mutex_lock(&serio_raw_mutex);
285 284  
286   - memset(serio_raw, 0, sizeof(struct serio_raw));
287 285 snprintf(serio_raw->name, sizeof(serio_raw->name), "serio_raw%d", serio_raw_no++);
288 286 serio_raw->refcnt = 1;
289 287 serio_raw->serio = serio;
drivers/input/tsdev.c
... ... @@ -157,9 +157,8 @@
157 157 if (i >= TSDEV_MINORS || !tsdev_table[i & TSDEV_MINOR_MASK])
158 158 return -ENODEV;
159 159  
160   - if (!(list = kmalloc(sizeof(struct tsdev_list), GFP_KERNEL)))
  160 + if (!(list = kzalloc(sizeof(struct tsdev_list), GFP_KERNEL)))
161 161 return -ENOMEM;
162   - memset(list, 0, sizeof(struct tsdev_list));
163 162  
164 163 list->raw = (i >= TSDEV_MINORS/2) ? 1 : 0;
165 164  
166 165  
... ... @@ -379,9 +378,8 @@
379 378 return NULL;
380 379 }
381 380  
382   - if (!(tsdev = kmalloc(sizeof(struct tsdev), GFP_KERNEL)))
  381 + if (!(tsdev = kzalloc(sizeof(struct tsdev), GFP_KERNEL)))
383 382 return NULL;
384   - memset(tsdev, 0, sizeof(struct tsdev));
385 383  
386 384 INIT_LIST_HEAD(&tsdev->list);
387 385 init_waitqueue_head(&tsdev->wait);