aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2005-09-09 16:03:21 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-09 16:57:46 -0400
commit76fa82fb7156aa7191dfd1fdede1fc0da51d45dd (patch)
tree40278b8ff4816d46e66261f8b5ac02b42123c6ca /drivers
parent4da006c63fb4758ee2d688aa65a461337b3ed065 (diff)
[PATCH] pcmcia: reduce ds.c stack footprint
This patch reduces the stack footprint of pcmcia_device_query() from 416 bytes to 36 bytes. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pcmcia/ds.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 43da2e92d50f..398146e3823e 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -424,9 +424,13 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev)
424{ 424{
425 cistpl_manfid_t manf_id; 425 cistpl_manfid_t manf_id;
426 cistpl_funcid_t func_id; 426 cistpl_funcid_t func_id;
427 cistpl_vers_1_t vers1; 427 cistpl_vers_1_t *vers1;
428 unsigned int i; 428 unsigned int i;
429 429
430 vers1 = kmalloc(sizeof(*vers1), GFP_KERNEL);
431 if (!vers1)
432 return -ENOMEM;
433
430 if (!pccard_read_tuple(p_dev->socket, p_dev->func, 434 if (!pccard_read_tuple(p_dev->socket, p_dev->func,
431 CISTPL_MANFID, &manf_id)) { 435 CISTPL_MANFID, &manf_id)) {
432 p_dev->manf_id = manf_id.manf; 436 p_dev->manf_id = manf_id.manf;
@@ -443,23 +447,30 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev)
443 /* rule of thumb: cards with no FUNCID, but with 447 /* rule of thumb: cards with no FUNCID, but with
444 * common memory device geometry information, are 448 * common memory device geometry information, are
445 * probably memory cards (from pcmcia-cs) */ 449 * probably memory cards (from pcmcia-cs) */
446 cistpl_device_geo_t devgeo; 450 cistpl_device_geo_t *devgeo;
451
452 devgeo = kmalloc(sizeof(*devgeo), GFP_KERNEL);
453 if (!devgeo) {
454 kfree(vers1);
455 return -ENOMEM;
456 }
447 if (!pccard_read_tuple(p_dev->socket, p_dev->func, 457 if (!pccard_read_tuple(p_dev->socket, p_dev->func,
448 CISTPL_DEVICE_GEO, &devgeo)) { 458 CISTPL_DEVICE_GEO, devgeo)) {
449 ds_dbg(0, "mem device geometry probably means " 459 ds_dbg(0, "mem device geometry probably means "
450 "FUNCID_MEMORY\n"); 460 "FUNCID_MEMORY\n");
451 p_dev->func_id = CISTPL_FUNCID_MEMORY; 461 p_dev->func_id = CISTPL_FUNCID_MEMORY;
452 p_dev->has_func_id = 1; 462 p_dev->has_func_id = 1;
453 } 463 }
464 kfree(devgeo);
454 } 465 }
455 466
456 if (!pccard_read_tuple(p_dev->socket, p_dev->func, CISTPL_VERS_1, 467 if (!pccard_read_tuple(p_dev->socket, p_dev->func, CISTPL_VERS_1,
457 &vers1)) { 468 vers1)) {
458 for (i=0; i < vers1.ns; i++) { 469 for (i=0; i < vers1->ns; i++) {
459 char *tmp; 470 char *tmp;
460 unsigned int length; 471 unsigned int length;
461 472
462 tmp = vers1.str + vers1.ofs[i]; 473 tmp = vers1->str + vers1->ofs[i];
463 474
464 length = strlen(tmp) + 1; 475 length = strlen(tmp) + 1;
465 if ((length < 3) || (length > 255)) 476 if ((length < 3) || (length > 255))
@@ -475,6 +486,7 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev)
475 } 486 }
476 } 487 }
477 488
489 kfree(vers1);
478 return 0; 490 return 0;
479} 491}
480 492