aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorOliver Neukum <oliver@neukum.org>2006-01-06 14:54:29 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-20 17:49:52 -0500
commitbbdb7dafb5b5a3c0197cbabd5055d8e9c093e3ea (patch)
tree9ac23c97ef6a983e4e7a98e19f9307b8d3aad1f4 /drivers/usb
parent887c2560b6ceb5fe7ac24704e85af507c6d960e5 (diff)
[PATCH] USB: kzalloc for hid
this uses kzalloc in hid. Signed-off-by: Oliver Neukum <oliver@neukum.name> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/input/hid-core.c18
-rw-r--r--drivers/usb/input/hid-lgff.c6
-rw-r--r--drivers/usb/input/hid-tmff.c3
-rw-r--r--drivers/usb/input/hiddev.c6
4 files changed, 10 insertions, 23 deletions
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 07a012f88772..f187a719f17e 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -66,9 +66,8 @@ static struct hid_report *hid_register_report(struct hid_device *device, unsigne
66 if (report_enum->report_id_hash[id]) 66 if (report_enum->report_id_hash[id])
67 return report_enum->report_id_hash[id]; 67 return report_enum->report_id_hash[id];
68 68
69 if (!(report = kmalloc(sizeof(struct hid_report), GFP_KERNEL))) 69 if (!(report = kzalloc(sizeof(struct hid_report), GFP_KERNEL)))
70 return NULL; 70 return NULL;
71 memset(report, 0, sizeof(struct hid_report));
72 71
73 if (id != 0) 72 if (id != 0)
74 report_enum->numbered = 1; 73 report_enum->numbered = 1;
@@ -97,12 +96,9 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned
97 return NULL; 96 return NULL;
98 } 97 }
99 98
100 if (!(field = kmalloc(sizeof(struct hid_field) + usages * sizeof(struct hid_usage) 99 if (!(field = kzalloc(sizeof(struct hid_field) + usages * sizeof(struct hid_usage)
101 + values * sizeof(unsigned), GFP_KERNEL))) return NULL; 100 + values * sizeof(unsigned), GFP_KERNEL))) return NULL;
102 101
103 memset(field, 0, sizeof(struct hid_field) + usages * sizeof(struct hid_usage)
104 + values * sizeof(unsigned));
105
106 field->index = report->maxfield++; 102 field->index = report->maxfield++;
107 report->field[field->index] = field; 103 report->field[field->index] = field;
108 field->usage = (struct hid_usage *)(field + 1); 104 field->usage = (struct hid_usage *)(field + 1);
@@ -651,17 +647,14 @@ static struct hid_device *hid_parse_report(__u8 *start, unsigned size)
651 hid_parser_reserved 647 hid_parser_reserved
652 }; 648 };
653 649
654 if (!(device = kmalloc(sizeof(struct hid_device), GFP_KERNEL))) 650 if (!(device = kzalloc(sizeof(struct hid_device), GFP_KERNEL)))
655 return NULL; 651 return NULL;
656 memset(device, 0, sizeof(struct hid_device));
657 652
658 if (!(device->collection = kmalloc(sizeof(struct hid_collection) * 653 if (!(device->collection = kzalloc(sizeof(struct hid_collection) *
659 HID_DEFAULT_NUM_COLLECTIONS, GFP_KERNEL))) { 654 HID_DEFAULT_NUM_COLLECTIONS, GFP_KERNEL))) {
660 kfree(device); 655 kfree(device);
661 return NULL; 656 return NULL;
662 } 657 }
663 memset(device->collection, 0, sizeof(struct hid_collection) *
664 HID_DEFAULT_NUM_COLLECTIONS);
665 device->collection_size = HID_DEFAULT_NUM_COLLECTIONS; 658 device->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
666 659
667 for (i = 0; i < HID_REPORT_TYPES; i++) 660 for (i = 0; i < HID_REPORT_TYPES; i++)
@@ -675,13 +668,12 @@ static struct hid_device *hid_parse_report(__u8 *start, unsigned size)
675 memcpy(device->rdesc, start, size); 668 memcpy(device->rdesc, start, size);
676 device->rsize = size; 669 device->rsize = size;
677 670
678 if (!(parser = kmalloc(sizeof(struct hid_parser), GFP_KERNEL))) { 671 if (!(parser = kzalloc(sizeof(struct hid_parser), GFP_KERNEL))) {
679 kfree(device->rdesc); 672 kfree(device->rdesc);
680 kfree(device->collection); 673 kfree(device->collection);
681 kfree(device); 674 kfree(device);
682 return NULL; 675 return NULL;
683 } 676 }
684 memset(parser, 0, sizeof(struct hid_parser));
685 parser->device = device; 677 parser->device = device;
686 678
687 end = start + size; 679 end = start + size;
diff --git a/drivers/usb/input/hid-lgff.c b/drivers/usb/input/hid-lgff.c
index f82c9c9e5d51..f07d44357ff1 100644
--- a/drivers/usb/input/hid-lgff.c
+++ b/drivers/usb/input/hid-lgff.c
@@ -154,10 +154,9 @@ int hid_lgff_init(struct hid_device* hid)
154 return -1; 154 return -1;
155 } 155 }
156 156
157 private = kmalloc(sizeof(struct lgff_device), GFP_KERNEL); 157 private = kzalloc(sizeof(struct lgff_device), GFP_KERNEL);
158 if (!private) 158 if (!private)
159 return -1; 159 return -1;
160 memset(private, 0, sizeof(struct lgff_device));
161 hid->ff_private = private; 160 hid->ff_private = private;
162 161
163 /* Input init */ 162 /* Input init */
@@ -228,13 +227,12 @@ static struct hid_report* hid_lgff_duplicate_report(struct hid_report* report)
228 } 227 }
229 *ret->field[0] = *report->field[0]; 228 *ret->field[0] = *report->field[0];
230 229
231 ret->field[0]->value = kmalloc(sizeof(s32[8]), GFP_KERNEL); 230 ret->field[0]->value = kzalloc(sizeof(s32[8]), GFP_KERNEL);
232 if (!ret->field[0]->value) { 231 if (!ret->field[0]->value) {
233 kfree(ret->field[0]); 232 kfree(ret->field[0]);
234 kfree(ret); 233 kfree(ret);
235 return NULL; 234 return NULL;
236 } 235 }
237 memset(ret->field[0]->value, 0, sizeof(s32[8]));
238 236
239 return ret; 237 return ret;
240} 238}
diff --git a/drivers/usb/input/hid-tmff.c b/drivers/usb/input/hid-tmff.c
index 023fd5ac31c8..534425c69c0a 100644
--- a/drivers/usb/input/hid-tmff.c
+++ b/drivers/usb/input/hid-tmff.c
@@ -113,11 +113,10 @@ int hid_tmff_init(struct hid_device *hid)
113 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); 113 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
114 struct input_dev *input_dev = hidinput->input; 114 struct input_dev *input_dev = hidinput->input;
115 115
116 private = kmalloc(sizeof(struct tmff_device), GFP_KERNEL); 116 private = kzalloc(sizeof(struct tmff_device), GFP_KERNEL);
117 if (!private) 117 if (!private)
118 return -ENOMEM; 118 return -ENOMEM;
119 119
120 memset(private, 0, sizeof(struct tmff_device));
121 hid->ff_private = private; 120 hid->ff_private = private;
122 121
123 /* Find the report to use */ 122 /* Find the report to use */
diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c
index 925f5aba06f5..6dd666696178 100644
--- a/drivers/usb/input/hiddev.c
+++ b/drivers/usb/input/hiddev.c
@@ -257,9 +257,8 @@ static int hiddev_open(struct inode * inode, struct file * file) {
257 if (i >= HIDDEV_MINORS || !hiddev_table[i]) 257 if (i >= HIDDEV_MINORS || !hiddev_table[i])
258 return -ENODEV; 258 return -ENODEV;
259 259
260 if (!(list = kmalloc(sizeof(struct hiddev_list), GFP_KERNEL))) 260 if (!(list = kzalloc(sizeof(struct hiddev_list), GFP_KERNEL)))
261 return -ENOMEM; 261 return -ENOMEM;
262 memset(list, 0, sizeof(struct hiddev_list));
263 262
264 list->hiddev = hiddev_table[i]; 263 list->hiddev = hiddev_table[i];
265 list->next = hiddev_table[i]->list; 264 list->next = hiddev_table[i]->list;
@@ -754,9 +753,8 @@ int hiddev_connect(struct hid_device *hid)
754 if (i == hid->maxcollection && (hid->quirks & HID_QUIRK_HIDDEV) == 0) 753 if (i == hid->maxcollection && (hid->quirks & HID_QUIRK_HIDDEV) == 0)
755 return -1; 754 return -1;
756 755
757 if (!(hiddev = kmalloc(sizeof(struct hiddev), GFP_KERNEL))) 756 if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL)))
758 return -1; 757 return -1;
759 memset(hiddev, 0, sizeof(struct hiddev));
760 758
761 retval = usb_register_dev(hid->intf, &hiddev_class); 759 retval = usb_register_dev(hid->intf, &hiddev_class);
762 if (retval) { 760 if (retval) {