diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2005-09-06 18:16:51 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-07 19:57:21 -0400 |
commit | a2822e7f00cdccbff8e507b5ebbddce1aa95eb5d (patch) | |
tree | 07ac5760bb7771744daa59b759c34190fb39f3ae /drivers | |
parent | ea2f1590aaffbd02f1850c19c3895ff4d092c6e0 (diff) |
[PATCH] pnp: consolidate kmalloc wrappers
ISAPNP, PNPBIOS, and PNPACPI all had their own kmalloc wrappers that
reimplemented kcalloc(). Remove the wrappers and just use kcalloc()
directly.
Note that this also removes the PNPBIOS error message when the kmalloc
fails.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pnp/isapnp/core.c | 33 | ||||
-rw-r--r-- | drivers/pnp/pnpacpi/core.c | 15 | ||||
-rw-r--r-- | drivers/pnp/pnpacpi/pnpacpi.h | 1 | ||||
-rw-r--r-- | drivers/pnp/pnpacpi/rsparser.c | 18 | ||||
-rw-r--r-- | drivers/pnp/pnpbios/core.c | 26 | ||||
-rw-r--r-- | drivers/pnp/pnpbios/pnpbios.h | 1 | ||||
-rw-r--r-- | drivers/pnp/pnpbios/proc.c | 8 | ||||
-rw-r--r-- | drivers/pnp/pnpbios/rsparser.c | 16 |
8 files changed, 43 insertions, 75 deletions
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 82c5edd5b9ee..beedd86800f4 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c | |||
@@ -142,17 +142,6 @@ static void isapnp_write_word(unsigned char idx, unsigned short val) | |||
142 | isapnp_write_byte(idx+1, val); | 142 | isapnp_write_byte(idx+1, val); |
143 | } | 143 | } |
144 | 144 | ||
145 | static void *isapnp_alloc(long size) | ||
146 | { | ||
147 | void *result; | ||
148 | |||
149 | result = kmalloc(size, GFP_KERNEL); | ||
150 | if (!result) | ||
151 | return NULL; | ||
152 | memset(result, 0, size); | ||
153 | return result; | ||
154 | } | ||
155 | |||
156 | static void isapnp_key(void) | 145 | static void isapnp_key(void) |
157 | { | 146 | { |
158 | unsigned char code = 0x6a, msb; | 147 | unsigned char code = 0x6a, msb; |
@@ -406,7 +395,7 @@ static void isapnp_parse_id(struct pnp_dev * dev, unsigned short vendor, unsigne | |||
406 | struct pnp_id * id; | 395 | struct pnp_id * id; |
407 | if (!dev) | 396 | if (!dev) |
408 | return; | 397 | return; |
409 | id = isapnp_alloc(sizeof(struct pnp_id)); | 398 | id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); |
410 | if (!id) | 399 | if (!id) |
411 | return; | 400 | return; |
412 | sprintf(id->id, "%c%c%c%x%x%x%x", | 401 | sprintf(id->id, "%c%c%c%x%x%x%x", |
@@ -430,7 +419,7 @@ static struct pnp_dev * __init isapnp_parse_device(struct pnp_card *card, int si | |||
430 | struct pnp_dev *dev; | 419 | struct pnp_dev *dev; |
431 | 420 | ||
432 | isapnp_peek(tmp, size); | 421 | isapnp_peek(tmp, size); |
433 | dev = isapnp_alloc(sizeof(struct pnp_dev)); | 422 | dev = kcalloc(1, sizeof(struct pnp_dev), GFP_KERNEL); |
434 | if (!dev) | 423 | if (!dev) |
435 | return NULL; | 424 | return NULL; |
436 | dev->number = number; | 425 | dev->number = number; |
@@ -461,7 +450,7 @@ static void __init isapnp_parse_irq_resource(struct pnp_option *option, | |||
461 | unsigned long bits; | 450 | unsigned long bits; |
462 | 451 | ||
463 | isapnp_peek(tmp, size); | 452 | isapnp_peek(tmp, size); |
464 | irq = isapnp_alloc(sizeof(struct pnp_irq)); | 453 | irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); |
465 | if (!irq) | 454 | if (!irq) |
466 | return; | 455 | return; |
467 | bits = (tmp[1] << 8) | tmp[0]; | 456 | bits = (tmp[1] << 8) | tmp[0]; |
@@ -485,7 +474,7 @@ static void __init isapnp_parse_dma_resource(struct pnp_option *option, | |||
485 | struct pnp_dma *dma; | 474 | struct pnp_dma *dma; |
486 | 475 | ||
487 | isapnp_peek(tmp, size); | 476 | isapnp_peek(tmp, size); |
488 | dma = isapnp_alloc(sizeof(struct pnp_dma)); | 477 | dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); |
489 | if (!dma) | 478 | if (!dma) |
490 | return; | 479 | return; |
491 | dma->map = tmp[0]; | 480 | dma->map = tmp[0]; |
@@ -505,7 +494,7 @@ static void __init isapnp_parse_port_resource(struct pnp_option *option, | |||
505 | struct pnp_port *port; | 494 | struct pnp_port *port; |
506 | 495 | ||
507 | isapnp_peek(tmp, size); | 496 | isapnp_peek(tmp, size); |
508 | port = isapnp_alloc(sizeof(struct pnp_port)); | 497 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); |
509 | if (!port) | 498 | if (!port) |
510 | return; | 499 | return; |
511 | port->min = (tmp[2] << 8) | tmp[1]; | 500 | port->min = (tmp[2] << 8) | tmp[1]; |
@@ -528,7 +517,7 @@ static void __init isapnp_parse_fixed_port_resource(struct pnp_option *option, | |||
528 | struct pnp_port *port; | 517 | struct pnp_port *port; |
529 | 518 | ||
530 | isapnp_peek(tmp, size); | 519 | isapnp_peek(tmp, size); |
531 | port = isapnp_alloc(sizeof(struct pnp_port)); | 520 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); |
532 | if (!port) | 521 | if (!port) |
533 | return; | 522 | return; |
534 | port->min = port->max = (tmp[1] << 8) | tmp[0]; | 523 | port->min = port->max = (tmp[1] << 8) | tmp[0]; |
@@ -550,7 +539,7 @@ static void __init isapnp_parse_mem_resource(struct pnp_option *option, | |||
550 | struct pnp_mem *mem; | 539 | struct pnp_mem *mem; |
551 | 540 | ||
552 | isapnp_peek(tmp, size); | 541 | isapnp_peek(tmp, size); |
553 | mem = isapnp_alloc(sizeof(struct pnp_mem)); | 542 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); |
554 | if (!mem) | 543 | if (!mem) |
555 | return; | 544 | return; |
556 | mem->min = ((tmp[2] << 8) | tmp[1]) << 8; | 545 | mem->min = ((tmp[2] << 8) | tmp[1]) << 8; |
@@ -573,7 +562,7 @@ static void __init isapnp_parse_mem32_resource(struct pnp_option *option, | |||
573 | struct pnp_mem *mem; | 562 | struct pnp_mem *mem; |
574 | 563 | ||
575 | isapnp_peek(tmp, size); | 564 | isapnp_peek(tmp, size); |
576 | mem = isapnp_alloc(sizeof(struct pnp_mem)); | 565 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); |
577 | if (!mem) | 566 | if (!mem) |
578 | return; | 567 | return; |
579 | mem->min = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; | 568 | mem->min = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; |
@@ -595,7 +584,7 @@ static void __init isapnp_parse_fixed_mem32_resource(struct pnp_option *option, | |||
595 | struct pnp_mem *mem; | 584 | struct pnp_mem *mem; |
596 | 585 | ||
597 | isapnp_peek(tmp, size); | 586 | isapnp_peek(tmp, size); |
598 | mem = isapnp_alloc(sizeof(struct pnp_mem)); | 587 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); |
599 | if (!mem) | 588 | if (!mem) |
600 | return; | 589 | return; |
601 | mem->min = mem->max = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; | 590 | mem->min = mem->max = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; |
@@ -838,7 +827,7 @@ static unsigned char __init isapnp_checksum(unsigned char *data) | |||
838 | 827 | ||
839 | static void isapnp_parse_card_id(struct pnp_card * card, unsigned short vendor, unsigned short device) | 828 | static void isapnp_parse_card_id(struct pnp_card * card, unsigned short vendor, unsigned short device) |
840 | { | 829 | { |
841 | struct pnp_id * id = isapnp_alloc(sizeof(struct pnp_id)); | 830 | struct pnp_id * id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); |
842 | if (!id) | 831 | if (!id) |
843 | return; | 832 | return; |
844 | sprintf(id->id, "%c%c%c%x%x%x%x", | 833 | sprintf(id->id, "%c%c%c%x%x%x%x", |
@@ -874,7 +863,7 @@ static int __init isapnp_build_device_list(void) | |||
874 | header[4], header[5], header[6], header[7], header[8]); | 863 | header[4], header[5], header[6], header[7], header[8]); |
875 | printk(KERN_DEBUG "checksum = 0x%x\n", checksum); | 864 | printk(KERN_DEBUG "checksum = 0x%x\n", checksum); |
876 | #endif | 865 | #endif |
877 | if ((card = isapnp_alloc(sizeof(struct pnp_card))) == NULL) | 866 | if ((card = kcalloc(1, sizeof(struct pnp_card), GFP_KERNEL)) == NULL) |
878 | continue; | 867 | continue; |
879 | 868 | ||
880 | card->number = csn; | 869 | card->number = csn; |
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 8655dd2e5b83..d3d292ea5876 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c | |||
@@ -41,14 +41,6 @@ static inline int is_exclusive_device(struct acpi_device *dev) | |||
41 | return (!acpi_match_ids(dev, excluded_id_list)); | 41 | return (!acpi_match_ids(dev, excluded_id_list)); |
42 | } | 42 | } |
43 | 43 | ||
44 | void *pnpacpi_kmalloc(size_t size, int f) | ||
45 | { | ||
46 | void *p = kmalloc(size, f); | ||
47 | if (p) | ||
48 | memset(p, 0, size); | ||
49 | return p; | ||
50 | } | ||
51 | |||
52 | /* | 44 | /* |
53 | * Compatible Device IDs | 45 | * Compatible Device IDs |
54 | */ | 46 | */ |
@@ -143,7 +135,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) | |||
143 | return 0; | 135 | return 0; |
144 | 136 | ||
145 | pnp_dbg("ACPI device : hid %s", acpi_device_hid(device)); | 137 | pnp_dbg("ACPI device : hid %s", acpi_device_hid(device)); |
146 | dev = pnpacpi_kmalloc(sizeof(struct pnp_dev), GFP_KERNEL); | 138 | dev = kcalloc(1, sizeof(struct pnp_dev), GFP_KERNEL); |
147 | if (!dev) { | 139 | if (!dev) { |
148 | pnp_err("Out of memory"); | 140 | pnp_err("Out of memory"); |
149 | return -ENOMEM; | 141 | return -ENOMEM; |
@@ -173,7 +165,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) | |||
173 | dev->number = num; | 165 | dev->number = num; |
174 | 166 | ||
175 | /* set the initial values for the PnP device */ | 167 | /* set the initial values for the PnP device */ |
176 | dev_id = pnpacpi_kmalloc(sizeof(struct pnp_id), GFP_KERNEL); | 168 | dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); |
177 | if (!dev_id) | 169 | if (!dev_id) |
178 | goto err; | 170 | goto err; |
179 | pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id); | 171 | pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id); |
@@ -205,8 +197,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) | |||
205 | for (i = 0; i < cid_list->count; i++) { | 197 | for (i = 0; i < cid_list->count; i++) { |
206 | if (!ispnpidacpi(cid_list->id[i].value)) | 198 | if (!ispnpidacpi(cid_list->id[i].value)) |
207 | continue; | 199 | continue; |
208 | dev_id = pnpacpi_kmalloc(sizeof(struct pnp_id), | 200 | dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); |
209 | GFP_KERNEL); | ||
210 | if (!dev_id) | 201 | if (!dev_id) |
211 | continue; | 202 | continue; |
212 | 203 | ||
diff --git a/drivers/pnp/pnpacpi/pnpacpi.h b/drivers/pnp/pnpacpi/pnpacpi.h index 76f907e09ee6..f28e2ed66fa3 100644 --- a/drivers/pnp/pnpacpi/pnpacpi.h +++ b/drivers/pnp/pnpacpi/pnpacpi.h | |||
@@ -5,7 +5,6 @@ | |||
5 | #include <linux/acpi.h> | 5 | #include <linux/acpi.h> |
6 | #include <linux/pnp.h> | 6 | #include <linux/pnp.h> |
7 | 7 | ||
8 | void *pnpacpi_kmalloc(size_t size, int f); | ||
9 | acpi_status pnpacpi_parse_allocated_resource(acpi_handle, struct pnp_resource_table*); | 8 | acpi_status pnpacpi_parse_allocated_resource(acpi_handle, struct pnp_resource_table*); |
10 | acpi_status pnpacpi_parse_resource_option_data(acpi_handle, struct pnp_dev*); | 9 | acpi_status pnpacpi_parse_resource_option_data(acpi_handle, struct pnp_dev*); |
11 | int pnpacpi_encode_resources(struct pnp_resource_table *, struct acpi_buffer *); | 10 | int pnpacpi_encode_resources(struct pnp_resource_table *, struct acpi_buffer *); |
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 75575f6c349c..675b76a42403 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c | |||
@@ -244,7 +244,7 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso | |||
244 | 244 | ||
245 | if (p->number_of_channels == 0) | 245 | if (p->number_of_channels == 0) |
246 | return; | 246 | return; |
247 | dma = pnpacpi_kmalloc(sizeof(struct pnp_dma), GFP_KERNEL); | 247 | dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); |
248 | if (!dma) | 248 | if (!dma) |
249 | return; | 249 | return; |
250 | 250 | ||
@@ -300,7 +300,7 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option, | |||
300 | 300 | ||
301 | if (p->number_of_interrupts == 0) | 301 | if (p->number_of_interrupts == 0) |
302 | return; | 302 | return; |
303 | irq = pnpacpi_kmalloc(sizeof(struct pnp_irq), GFP_KERNEL); | 303 | irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); |
304 | if (!irq) | 304 | if (!irq) |
305 | return; | 305 | return; |
306 | 306 | ||
@@ -321,7 +321,7 @@ static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, | |||
321 | 321 | ||
322 | if (p->number_of_interrupts == 0) | 322 | if (p->number_of_interrupts == 0) |
323 | return; | 323 | return; |
324 | irq = pnpacpi_kmalloc(sizeof(struct pnp_irq), GFP_KERNEL); | 324 | irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); |
325 | if (!irq) | 325 | if (!irq) |
326 | return; | 326 | return; |
327 | 327 | ||
@@ -342,7 +342,7 @@ pnpacpi_parse_port_option(struct pnp_option *option, | |||
342 | 342 | ||
343 | if (io->range_length == 0) | 343 | if (io->range_length == 0) |
344 | return; | 344 | return; |
345 | port = pnpacpi_kmalloc(sizeof(struct pnp_port), GFP_KERNEL); | 345 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); |
346 | if (!port) | 346 | if (!port) |
347 | return; | 347 | return; |
348 | port->min = io->min_base_address; | 348 | port->min = io->min_base_address; |
@@ -363,7 +363,7 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option, | |||
363 | 363 | ||
364 | if (io->range_length == 0) | 364 | if (io->range_length == 0) |
365 | return; | 365 | return; |
366 | port = pnpacpi_kmalloc(sizeof(struct pnp_port), GFP_KERNEL); | 366 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); |
367 | if (!port) | 367 | if (!port) |
368 | return; | 368 | return; |
369 | port->min = port->max = io->base_address; | 369 | port->min = port->max = io->base_address; |
@@ -382,7 +382,7 @@ pnpacpi_parse_mem24_option(struct pnp_option *option, | |||
382 | 382 | ||
383 | if (p->range_length == 0) | 383 | if (p->range_length == 0) |
384 | return; | 384 | return; |
385 | mem = pnpacpi_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL); | 385 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); |
386 | if (!mem) | 386 | if (!mem) |
387 | return; | 387 | return; |
388 | mem->min = p->min_base_address; | 388 | mem->min = p->min_base_address; |
@@ -405,7 +405,7 @@ pnpacpi_parse_mem32_option(struct pnp_option *option, | |||
405 | 405 | ||
406 | if (p->range_length == 0) | 406 | if (p->range_length == 0) |
407 | return; | 407 | return; |
408 | mem = pnpacpi_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL); | 408 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); |
409 | if (!mem) | 409 | if (!mem) |
410 | return; | 410 | return; |
411 | mem->min = p->min_base_address; | 411 | mem->min = p->min_base_address; |
@@ -428,7 +428,7 @@ pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, | |||
428 | 428 | ||
429 | if (p->range_length == 0) | 429 | if (p->range_length == 0) |
430 | return; | 430 | return; |
431 | mem = pnpacpi_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL); | 431 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); |
432 | if (!mem) | 432 | if (!mem) |
433 | return; | 433 | return; |
434 | mem->min = mem->max = p->range_base_address; | 434 | mem->min = mem->max = p->range_base_address; |
@@ -612,7 +612,7 @@ int pnpacpi_build_resource_template(acpi_handle handle, | |||
612 | if (!res_cnt) | 612 | if (!res_cnt) |
613 | return -EINVAL; | 613 | return -EINVAL; |
614 | buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1; | 614 | buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1; |
615 | buffer->pointer = pnpacpi_kmalloc(buffer->length - 1, GFP_KERNEL); | 615 | buffer->pointer = kcalloc(1, buffer->length - 1, GFP_KERNEL); |
616 | if (!buffer->pointer) | 616 | if (!buffer->pointer) |
617 | return -ENOMEM; | 617 | return -ENOMEM; |
618 | pnp_dbg("Res cnt %d", res_cnt); | 618 | pnp_dbg("Res cnt %d", res_cnt); |
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c index 778a324028f4..f49674f07949 100644 --- a/drivers/pnp/pnpbios/core.c +++ b/drivers/pnp/pnpbios/core.c | |||
@@ -86,16 +86,6 @@ int pnp_bios_present(void) | |||
86 | 86 | ||
87 | struct pnp_dev_node_info node_info; | 87 | struct pnp_dev_node_info node_info; |
88 | 88 | ||
89 | void *pnpbios_kmalloc(size_t size, int f) | ||
90 | { | ||
91 | void *p = kmalloc( size, f ); | ||
92 | if ( p == NULL ) | ||
93 | printk(KERN_ERR "PnPBIOS: kmalloc() failed\n"); | ||
94 | else | ||
95 | memset(p, 0, size); | ||
96 | return p; | ||
97 | } | ||
98 | |||
99 | /* | 89 | /* |
100 | * | 90 | * |
101 | * DOCKING FUNCTIONS | 91 | * DOCKING FUNCTIONS |
@@ -121,10 +111,10 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info) | |||
121 | if (!current->fs->root) { | 111 | if (!current->fs->root) { |
122 | return -EAGAIN; | 112 | return -EAGAIN; |
123 | } | 113 | } |
124 | if (!(envp = (char **) pnpbios_kmalloc (20 * sizeof (char *), GFP_KERNEL))) { | 114 | if (!(envp = (char **) kcalloc (20, sizeof (char *), GFP_KERNEL))) { |
125 | return -ENOMEM; | 115 | return -ENOMEM; |
126 | } | 116 | } |
127 | if (!(buf = pnpbios_kmalloc (256, GFP_KERNEL))) { | 117 | if (!(buf = kcalloc (1, 256, GFP_KERNEL))) { |
128 | kfree (envp); | 118 | kfree (envp); |
129 | return -ENOMEM; | 119 | return -ENOMEM; |
130 | } | 120 | } |
@@ -231,7 +221,7 @@ static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table | |||
231 | if(!pnpbios_is_dynamic(dev)) | 221 | if(!pnpbios_is_dynamic(dev)) |
232 | return -EPERM; | 222 | return -EPERM; |
233 | 223 | ||
234 | node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); | 224 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); |
235 | if (!node) | 225 | if (!node) |
236 | return -1; | 226 | return -1; |
237 | if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { | 227 | if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { |
@@ -254,7 +244,7 @@ static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table | |||
254 | if (!pnpbios_is_dynamic(dev)) | 244 | if (!pnpbios_is_dynamic(dev)) |
255 | return -EPERM; | 245 | return -EPERM; |
256 | 246 | ||
257 | node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); | 247 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); |
258 | if (!node) | 248 | if (!node) |
259 | return -1; | 249 | return -1; |
260 | if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { | 250 | if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { |
@@ -305,7 +295,7 @@ static int pnpbios_disable_resources(struct pnp_dev *dev) | |||
305 | if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev)) | 295 | if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev)) |
306 | return -EPERM; | 296 | return -EPERM; |
307 | 297 | ||
308 | node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); | 298 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); |
309 | if (!node) | 299 | if (!node) |
310 | return -ENOMEM; | 300 | return -ENOMEM; |
311 | 301 | ||
@@ -347,7 +337,7 @@ static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node) | |||
347 | } | 337 | } |
348 | 338 | ||
349 | /* set the initial values for the PnP device */ | 339 | /* set the initial values for the PnP device */ |
350 | dev_id = pnpbios_kmalloc(sizeof(struct pnp_id), GFP_KERNEL); | 340 | dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); |
351 | if (!dev_id) | 341 | if (!dev_id) |
352 | return -1; | 342 | return -1; |
353 | pnpid32_to_pnpid(node->eisa_id,id); | 343 | pnpid32_to_pnpid(node->eisa_id,id); |
@@ -385,7 +375,7 @@ static void __init build_devlist(void) | |||
385 | struct pnp_bios_node *node; | 375 | struct pnp_bios_node *node; |
386 | struct pnp_dev *dev; | 376 | struct pnp_dev *dev; |
387 | 377 | ||
388 | node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); | 378 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); |
389 | if (!node) | 379 | if (!node) |
390 | return; | 380 | return; |
391 | 381 | ||
@@ -402,7 +392,7 @@ static void __init build_devlist(void) | |||
402 | break; | 392 | break; |
403 | } | 393 | } |
404 | nodes_got++; | 394 | nodes_got++; |
405 | dev = pnpbios_kmalloc(sizeof (struct pnp_dev), GFP_KERNEL); | 395 | dev = kcalloc(1, sizeof (struct pnp_dev), GFP_KERNEL); |
406 | if (!dev) | 396 | if (!dev) |
407 | break; | 397 | break; |
408 | if(insert_device(dev,node)<0) | 398 | if(insert_device(dev,node)<0) |
diff --git a/drivers/pnp/pnpbios/pnpbios.h b/drivers/pnp/pnpbios/pnpbios.h index 01896e705ed4..d8cb2fd1f127 100644 --- a/drivers/pnp/pnpbios/pnpbios.h +++ b/drivers/pnp/pnpbios/pnpbios.h | |||
@@ -26,7 +26,6 @@ union pnp_bios_install_struct { | |||
26 | 26 | ||
27 | extern int pnp_bios_present(void); | 27 | extern int pnp_bios_present(void); |
28 | extern int pnpbios_dont_use_current_config; | 28 | extern int pnpbios_dont_use_current_config; |
29 | extern void *pnpbios_kmalloc(size_t size, int f); | ||
30 | 29 | ||
31 | extern int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node); | 30 | extern int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node); |
32 | extern int pnpbios_read_resources_from_node(struct pnp_resource_table *res, struct pnp_bios_node * node); | 31 | extern int pnpbios_read_resources_from_node(struct pnp_resource_table *res, struct pnp_bios_node * node); |
diff --git a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c index 6bb8e1973fd4..5a3dfc97f5e9 100644 --- a/drivers/pnp/pnpbios/proc.c +++ b/drivers/pnp/pnpbios/proc.c | |||
@@ -87,7 +87,7 @@ static int proc_read_escd(char *buf, char **start, off_t pos, | |||
87 | return -EFBIG; | 87 | return -EFBIG; |
88 | } | 88 | } |
89 | 89 | ||
90 | tmpbuf = pnpbios_kmalloc(escd.escd_size, GFP_KERNEL); | 90 | tmpbuf = kcalloc(1, escd.escd_size, GFP_KERNEL); |
91 | if (!tmpbuf) return -ENOMEM; | 91 | if (!tmpbuf) return -ENOMEM; |
92 | 92 | ||
93 | if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) { | 93 | if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) { |
@@ -133,7 +133,7 @@ static int proc_read_devices(char *buf, char **start, off_t pos, | |||
133 | if (pos >= 0xff) | 133 | if (pos >= 0xff) |
134 | return 0; | 134 | return 0; |
135 | 135 | ||
136 | node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); | 136 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); |
137 | if (!node) return -ENOMEM; | 137 | if (!node) return -ENOMEM; |
138 | 138 | ||
139 | for (nodenum=pos; nodenum<0xff; ) { | 139 | for (nodenum=pos; nodenum<0xff; ) { |
@@ -168,7 +168,7 @@ static int proc_read_node(char *buf, char **start, off_t pos, | |||
168 | u8 nodenum = (long)data; | 168 | u8 nodenum = (long)data; |
169 | int len; | 169 | int len; |
170 | 170 | ||
171 | node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); | 171 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); |
172 | if (!node) return -ENOMEM; | 172 | if (!node) return -ENOMEM; |
173 | if (pnp_bios_get_dev_node(&nodenum, boot, node)) { | 173 | if (pnp_bios_get_dev_node(&nodenum, boot, node)) { |
174 | kfree(node); | 174 | kfree(node); |
@@ -188,7 +188,7 @@ static int proc_write_node(struct file *file, const char __user *buf, | |||
188 | u8 nodenum = (long)data; | 188 | u8 nodenum = (long)data; |
189 | int ret = count; | 189 | int ret = count; |
190 | 190 | ||
191 | node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); | 191 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); |
192 | if (!node) | 192 | if (!node) |
193 | return -ENOMEM; | 193 | return -ENOMEM; |
194 | if (pnp_bios_get_dev_node(&nodenum, boot, node)) { | 194 | if (pnp_bios_get_dev_node(&nodenum, boot, node)) { |
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index e305bb132c24..b0ca65b68645 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c | |||
@@ -247,7 +247,7 @@ static void | |||
247 | pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option) | 247 | pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option) |
248 | { | 248 | { |
249 | struct pnp_mem * mem; | 249 | struct pnp_mem * mem; |
250 | mem = pnpbios_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL); | 250 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); |
251 | if (!mem) | 251 | if (!mem) |
252 | return; | 252 | return; |
253 | mem->min = ((p[5] << 8) | p[4]) << 8; | 253 | mem->min = ((p[5] << 8) | p[4]) << 8; |
@@ -263,7 +263,7 @@ static void | |||
263 | pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option) | 263 | pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option) |
264 | { | 264 | { |
265 | struct pnp_mem * mem; | 265 | struct pnp_mem * mem; |
266 | mem = pnpbios_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL); | 266 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); |
267 | if (!mem) | 267 | if (!mem) |
268 | return; | 268 | return; |
269 | mem->min = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; | 269 | mem->min = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; |
@@ -279,7 +279,7 @@ static void | |||
279 | pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *option) | 279 | pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *option) |
280 | { | 280 | { |
281 | struct pnp_mem * mem; | 281 | struct pnp_mem * mem; |
282 | mem = pnpbios_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL); | 282 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); |
283 | if (!mem) | 283 | if (!mem) |
284 | return; | 284 | return; |
285 | mem->min = mem->max = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; | 285 | mem->min = mem->max = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; |
@@ -296,7 +296,7 @@ pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option) | |||
296 | struct pnp_irq * irq; | 296 | struct pnp_irq * irq; |
297 | unsigned long bits; | 297 | unsigned long bits; |
298 | 298 | ||
299 | irq = pnpbios_kmalloc(sizeof(struct pnp_irq), GFP_KERNEL); | 299 | irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); |
300 | if (!irq) | 300 | if (!irq) |
301 | return; | 301 | return; |
302 | bits = (p[2] << 8) | p[1]; | 302 | bits = (p[2] << 8) | p[1]; |
@@ -313,7 +313,7 @@ static void | |||
313 | pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option) | 313 | pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option) |
314 | { | 314 | { |
315 | struct pnp_dma * dma; | 315 | struct pnp_dma * dma; |
316 | dma = pnpbios_kmalloc(sizeof(struct pnp_dma), GFP_KERNEL); | 316 | dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); |
317 | if (!dma) | 317 | if (!dma) |
318 | return; | 318 | return; |
319 | dma->map = p[1]; | 319 | dma->map = p[1]; |
@@ -326,7 +326,7 @@ static void | |||
326 | pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option) | 326 | pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option) |
327 | { | 327 | { |
328 | struct pnp_port * port; | 328 | struct pnp_port * port; |
329 | port = pnpbios_kmalloc(sizeof(struct pnp_port), GFP_KERNEL); | 329 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); |
330 | if (!port) | 330 | if (!port) |
331 | return; | 331 | return; |
332 | port->min = (p[3] << 8) | p[2]; | 332 | port->min = (p[3] << 8) | p[2]; |
@@ -342,7 +342,7 @@ static void | |||
342 | pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *option) | 342 | pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *option) |
343 | { | 343 | { |
344 | struct pnp_port * port; | 344 | struct pnp_port * port; |
345 | port = pnpbios_kmalloc(sizeof(struct pnp_port), GFP_KERNEL); | 345 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); |
346 | if (!port) | 346 | if (!port) |
347 | return; | 347 | return; |
348 | port->min = port->max = (p[2] << 8) | p[1]; | 348 | port->min = port->max = (p[2] << 8) | p[1]; |
@@ -530,7 +530,7 @@ pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_de | |||
530 | case SMALL_TAG_COMPATDEVID: /* compatible ID */ | 530 | case SMALL_TAG_COMPATDEVID: /* compatible ID */ |
531 | if (len != 4) | 531 | if (len != 4) |
532 | goto len_err; | 532 | goto len_err; |
533 | dev_id = pnpbios_kmalloc(sizeof (struct pnp_id), GFP_KERNEL); | 533 | dev_id = kcalloc(1, sizeof (struct pnp_id), GFP_KERNEL); |
534 | if (!dev_id) | 534 | if (!dev_id) |
535 | return NULL; | 535 | return NULL; |
536 | memset(dev_id, 0, sizeof(struct pnp_id)); | 536 | memset(dev_id, 0, sizeof(struct pnp_id)); |