aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pnp')
-rw-r--r--drivers/pnp/base.h12
-rw-r--r--drivers/pnp/isapnp/core.c112
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c149
-rw-r--r--drivers/pnp/pnpbios/rsparser.c120
-rw-r--r--drivers/pnp/resource.c54
5 files changed, 198 insertions, 249 deletions
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h
index afbeee5b8af6..360c6385686c 100644
--- a/drivers/pnp/base.h
+++ b/drivers/pnp/base.h
@@ -74,13 +74,17 @@ struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev);
74struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev, 74struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
75 int priority); 75 int priority);
76int pnp_register_irq_resource(struct pnp_dev *dev, struct pnp_option *option, 76int pnp_register_irq_resource(struct pnp_dev *dev, struct pnp_option *option,
77 struct pnp_irq *data); 77 pnp_irq_mask_t *map, unsigned char flags);
78int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_option *option, 78int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_option *option,
79 struct pnp_dma *data); 79 unsigned char map, unsigned char flags);
80int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option, 80int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option,
81 struct pnp_port *data); 81 resource_size_t min, resource_size_t max,
82 resource_size_t align, resource_size_t size,
83 unsigned char flags);
82int pnp_register_mem_resource(struct pnp_dev *dev, struct pnp_option *option, 84int pnp_register_mem_resource(struct pnp_dev *dev, struct pnp_option *option,
83 struct pnp_mem *data); 85 resource_size_t min, resource_size_t max,
86 resource_size_t align, resource_size_t size,
87 unsigned char flags);
84void pnp_init_resources(struct pnp_dev *dev); 88void pnp_init_resources(struct pnp_dev *dev);
85 89
86void pnp_fixup_device(struct pnp_dev *dev); 90void pnp_fixup_device(struct pnp_dev *dev);
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index e0caa71b16c0..3f75fdbe6098 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -433,20 +433,20 @@ static void __init isapnp_parse_irq_resource(struct pnp_dev *dev,
433 int size) 433 int size)
434{ 434{
435 unsigned char tmp[3]; 435 unsigned char tmp[3];
436 struct pnp_irq *irq;
437 unsigned long bits; 436 unsigned long bits;
437 pnp_irq_mask_t map;
438 unsigned char flags = IORESOURCE_IRQ_HIGHEDGE;
438 439
439 isapnp_peek(tmp, size); 440 isapnp_peek(tmp, size);
440 irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
441 if (!irq)
442 return;
443 bits = (tmp[1] << 8) | tmp[0]; 441 bits = (tmp[1] << 8) | tmp[0];
444 bitmap_copy(irq->map.bits, &bits, 16); 442
443 bitmap_zero(map.bits, PNP_IRQ_NR);
444 bitmap_copy(map.bits, &bits, 16);
445
445 if (size > 2) 446 if (size > 2)
446 irq->flags = tmp[2]; 447 flags = tmp[2];
447 else 448
448 irq->flags = IORESOURCE_IRQ_HIGHEDGE; 449 pnp_register_irq_resource(dev, option, &map, flags);
449 pnp_register_irq_resource(dev, option, irq);
450} 450}
451 451
452/* 452/*
@@ -457,15 +457,9 @@ static void __init isapnp_parse_dma_resource(struct pnp_dev *dev,
457 int size) 457 int size)
458{ 458{
459 unsigned char tmp[2]; 459 unsigned char tmp[2];
460 struct pnp_dma *dma;
461 460
462 isapnp_peek(tmp, size); 461 isapnp_peek(tmp, size);
463 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL); 462 pnp_register_dma_resource(dev, option, tmp[0], tmp[1]);
464 if (!dma)
465 return;
466 dma->map = tmp[0];
467 dma->flags = tmp[1];
468 pnp_register_dma_resource(dev, option, dma);
469} 463}
470 464
471/* 465/*
@@ -476,18 +470,16 @@ static void __init isapnp_parse_port_resource(struct pnp_dev *dev,
476 int size) 470 int size)
477{ 471{
478 unsigned char tmp[7]; 472 unsigned char tmp[7];
479 struct pnp_port *port; 473 resource_size_t min, max, align, len;
474 unsigned char flags;
480 475
481 isapnp_peek(tmp, size); 476 isapnp_peek(tmp, size);
482 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 477 min = (tmp[2] << 8) | tmp[1];
483 if (!port) 478 max = (tmp[4] << 8) | tmp[3];
484 return; 479 align = tmp[5];
485 port->min = (tmp[2] << 8) | tmp[1]; 480 len = tmp[6];
486 port->max = (tmp[4] << 8) | tmp[3]; 481 flags = tmp[0] ? IORESOURCE_IO_16BIT_ADDR : 0;
487 port->align = tmp[5]; 482 pnp_register_port_resource(dev, option, min, max, align, len, flags);
488 port->size = tmp[6];
489 port->flags = tmp[0] ? IORESOURCE_IO_16BIT_ADDR : 0;
490 pnp_register_port_resource(dev, option, port);
491} 483}
492 484
493/* 485/*
@@ -498,17 +490,13 @@ static void __init isapnp_parse_fixed_port_resource(struct pnp_dev *dev,
498 int size) 490 int size)
499{ 491{
500 unsigned char tmp[3]; 492 unsigned char tmp[3];
501 struct pnp_port *port; 493 resource_size_t base, len;
502 494
503 isapnp_peek(tmp, size); 495 isapnp_peek(tmp, size);
504 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 496 base = (tmp[1] << 8) | tmp[0];
505 if (!port) 497 len = tmp[2];
506 return; 498 pnp_register_port_resource(dev, option, base, base, 0, len,
507 port->min = port->max = (tmp[1] << 8) | tmp[0]; 499 IORESOURCE_IO_FIXED);
508 port->size = tmp[2];
509 port->align = 0;
510 port->flags = IORESOURCE_IO_FIXED;
511 pnp_register_port_resource(dev, option, port);
512} 500}
513 501
514/* 502/*
@@ -519,18 +507,16 @@ static void __init isapnp_parse_mem_resource(struct pnp_dev *dev,
519 int size) 507 int size)
520{ 508{
521 unsigned char tmp[9]; 509 unsigned char tmp[9];
522 struct pnp_mem *mem; 510 resource_size_t min, max, align, len;
511 unsigned char flags;
523 512
524 isapnp_peek(tmp, size); 513 isapnp_peek(tmp, size);
525 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 514 min = ((tmp[2] << 8) | tmp[1]) << 8;
526 if (!mem) 515 max = ((tmp[4] << 8) | tmp[3]) << 8;
527 return; 516 align = (tmp[6] << 8) | tmp[5];
528 mem->min = ((tmp[2] << 8) | tmp[1]) << 8; 517 len = ((tmp[8] << 8) | tmp[7]) << 8;
529 mem->max = ((tmp[4] << 8) | tmp[3]) << 8; 518 flags = tmp[0];
530 mem->align = (tmp[6] << 8) | tmp[5]; 519 pnp_register_mem_resource(dev, option, min, max, align, len, flags);
531 mem->size = ((tmp[8] << 8) | tmp[7]) << 8;
532 mem->flags = tmp[0];
533 pnp_register_mem_resource(dev, option, mem);
534} 520}
535 521
536/* 522/*
@@ -541,20 +527,16 @@ static void __init isapnp_parse_mem32_resource(struct pnp_dev *dev,
541 int size) 527 int size)
542{ 528{
543 unsigned char tmp[17]; 529 unsigned char tmp[17];
544 struct pnp_mem *mem; 530 resource_size_t min, max, align, len;
531 unsigned char flags;
545 532
546 isapnp_peek(tmp, size); 533 isapnp_peek(tmp, size);
547 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 534 min = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1];
548 if (!mem) 535 max = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5];
549 return; 536 align = (tmp[12] << 24) | (tmp[11] << 16) | (tmp[10] << 8) | tmp[9];
550 mem->min = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; 537 len = (tmp[16] << 24) | (tmp[15] << 16) | (tmp[14] << 8) | tmp[13];
551 mem->max = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5]; 538 flags = tmp[0];
552 mem->align = 539 pnp_register_mem_resource(dev, option, min, max, align, len, flags);
553 (tmp[12] << 24) | (tmp[11] << 16) | (tmp[10] << 8) | tmp[9];
554 mem->size =
555 (tmp[16] << 24) | (tmp[15] << 16) | (tmp[14] << 8) | tmp[13];
556 mem->flags = tmp[0];
557 pnp_register_mem_resource(dev, option, mem);
558} 540}
559 541
560/* 542/*
@@ -565,18 +547,14 @@ static void __init isapnp_parse_fixed_mem32_resource(struct pnp_dev *dev,
565 int size) 547 int size)
566{ 548{
567 unsigned char tmp[9]; 549 unsigned char tmp[9];
568 struct pnp_mem *mem; 550 resource_size_t base, len;
551 unsigned char flags;
569 552
570 isapnp_peek(tmp, size); 553 isapnp_peek(tmp, size);
571 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 554 base = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1];
572 if (!mem) 555 len = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5];
573 return; 556 flags = tmp[0];
574 mem->min = mem->max = 557 pnp_register_mem_resource(dev, option, base, base, 0, len, flags);
575 (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1];
576 mem->size = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5];
577 mem->align = 0;
578 mem->flags = tmp[0];
579 pnp_register_mem_resource(dev, option, mem);
580} 558}
581 559
582/* 560/*
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index ae65454a23bb..3aaf406b67b8 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -411,20 +411,16 @@ static __init void pnpacpi_parse_dma_option(struct pnp_dev *dev,
411 struct acpi_resource_dma *p) 411 struct acpi_resource_dma *p)
412{ 412{
413 int i; 413 int i;
414 struct pnp_dma *dma; 414 unsigned char map = 0, flags;
415 415
416 if (p->channel_count == 0) 416 if (p->channel_count == 0)
417 return; 417 return;
418 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL);
419 if (!dma)
420 return;
421 418
422 for (i = 0; i < p->channel_count; i++) 419 for (i = 0; i < p->channel_count; i++)
423 dma->map |= 1 << p->channels[i]; 420 map |= 1 << p->channels[i];
424
425 dma->flags = dma_flags(p->type, p->bus_master, p->transfer);
426 421
427 pnp_register_dma_resource(dev, option, dma); 422 flags = dma_flags(p->type, p->bus_master, p->transfer);
423 pnp_register_dma_resource(dev, option, map, flags);
428} 424}
429 425
430static __init void pnpacpi_parse_irq_option(struct pnp_dev *dev, 426static __init void pnpacpi_parse_irq_option(struct pnp_dev *dev,
@@ -432,20 +428,19 @@ static __init void pnpacpi_parse_irq_option(struct pnp_dev *dev,
432 struct acpi_resource_irq *p) 428 struct acpi_resource_irq *p)
433{ 429{
434 int i; 430 int i;
435 struct pnp_irq *irq; 431 pnp_irq_mask_t map;
432 unsigned char flags;
436 433
437 if (p->interrupt_count == 0) 434 if (p->interrupt_count == 0)
438 return; 435 return;
439 irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
440 if (!irq)
441 return;
442 436
437 bitmap_zero(map.bits, PNP_IRQ_NR);
443 for (i = 0; i < p->interrupt_count; i++) 438 for (i = 0; i < p->interrupt_count; i++)
444 if (p->interrupts[i]) 439 if (p->interrupts[i])
445 __set_bit(p->interrupts[i], irq->map.bits); 440 __set_bit(p->interrupts[i], map.bits);
446 irq->flags = irq_flags(p->triggering, p->polarity, p->sharable);
447 441
448 pnp_register_irq_resource(dev, option, irq); 442 flags = irq_flags(p->triggering, p->polarity, p->sharable);
443 pnp_register_irq_resource(dev, option, &map, flags);
449} 444}
450 445
451static __init void pnpacpi_parse_ext_irq_option(struct pnp_dev *dev, 446static __init void pnpacpi_parse_ext_irq_option(struct pnp_dev *dev,
@@ -453,123 +448,90 @@ static __init void pnpacpi_parse_ext_irq_option(struct pnp_dev *dev,
453 struct acpi_resource_extended_irq *p) 448 struct acpi_resource_extended_irq *p)
454{ 449{
455 int i; 450 int i;
456 struct pnp_irq *irq; 451 pnp_irq_mask_t map;
452 unsigned char flags;
457 453
458 if (p->interrupt_count == 0) 454 if (p->interrupt_count == 0)
459 return; 455 return;
460 irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
461 if (!irq)
462 return;
463 456
457 bitmap_zero(map.bits, PNP_IRQ_NR);
464 for (i = 0; i < p->interrupt_count; i++) 458 for (i = 0; i < p->interrupt_count; i++)
465 if (p->interrupts[i]) 459 if (p->interrupts[i])
466 __set_bit(p->interrupts[i], irq->map.bits); 460 __set_bit(p->interrupts[i], map.bits);
467 irq->flags = irq_flags(p->triggering, p->polarity, p->sharable);
468 461
469 pnp_register_irq_resource(dev, option, irq); 462 flags = irq_flags(p->triggering, p->polarity, p->sharable);
463 pnp_register_irq_resource(dev, option, &map, flags);
470} 464}
471 465
472static __init void pnpacpi_parse_port_option(struct pnp_dev *dev, 466static __init void pnpacpi_parse_port_option(struct pnp_dev *dev,
473 struct pnp_option *option, 467 struct pnp_option *option,
474 struct acpi_resource_io *io) 468 struct acpi_resource_io *io)
475{ 469{
476 struct pnp_port *port; 470 unsigned char flags = 0;
477 471
478 if (io->address_length == 0) 472 if (io->address_length == 0)
479 return; 473 return;
480 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 474
481 if (!port) 475 if (io->io_decode == ACPI_DECODE_16)
482 return; 476 flags = IORESOURCE_IO_16BIT_ADDR;
483 port->min = io->minimum; 477 pnp_register_port_resource(dev, option, io->minimum, io->maximum,
484 port->max = io->maximum; 478 io->alignment, io->address_length, flags);
485 port->align = io->alignment;
486 port->size = io->address_length;
487 port->flags = ACPI_DECODE_16 == io->io_decode ?
488 IORESOURCE_IO_16BIT_ADDR : 0;
489 pnp_register_port_resource(dev, option, port);
490} 479}
491 480
492static __init void pnpacpi_parse_fixed_port_option(struct pnp_dev *dev, 481static __init void pnpacpi_parse_fixed_port_option(struct pnp_dev *dev,
493 struct pnp_option *option, 482 struct pnp_option *option,
494 struct acpi_resource_fixed_io *io) 483 struct acpi_resource_fixed_io *io)
495{ 484{
496 struct pnp_port *port;
497
498 if (io->address_length == 0) 485 if (io->address_length == 0)
499 return; 486 return;
500 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 487
501 if (!port) 488 pnp_register_port_resource(dev, option, io->address, io->address, 0,
502 return; 489 io->address_length, IORESOURCE_IO_FIXED);
503 port->min = port->max = io->address;
504 port->size = io->address_length;
505 port->align = 0;
506 port->flags = IORESOURCE_IO_FIXED;
507 pnp_register_port_resource(dev, option, port);
508} 490}
509 491
510static __init void pnpacpi_parse_mem24_option(struct pnp_dev *dev, 492static __init void pnpacpi_parse_mem24_option(struct pnp_dev *dev,
511 struct pnp_option *option, 493 struct pnp_option *option,
512 struct acpi_resource_memory24 *p) 494 struct acpi_resource_memory24 *p)
513{ 495{
514 struct pnp_mem *mem; 496 unsigned char flags = 0;
515 497
516 if (p->address_length == 0) 498 if (p->address_length == 0)
517 return; 499 return;
518 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
519 if (!mem)
520 return;
521 mem->min = p->minimum;
522 mem->max = p->maximum;
523 mem->align = p->alignment;
524 mem->size = p->address_length;
525 500
526 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? 501 if (p->write_protect == ACPI_READ_WRITE_MEMORY)
527 IORESOURCE_MEM_WRITEABLE : 0; 502 flags = IORESOURCE_MEM_WRITEABLE;
528 503 pnp_register_mem_resource(dev, option, p->minimum, p->maximum,
529 pnp_register_mem_resource(dev, option, mem); 504 p->alignment, p->address_length, flags);
530} 505}
531 506
532static __init void pnpacpi_parse_mem32_option(struct pnp_dev *dev, 507static __init void pnpacpi_parse_mem32_option(struct pnp_dev *dev,
533 struct pnp_option *option, 508 struct pnp_option *option,
534 struct acpi_resource_memory32 *p) 509 struct acpi_resource_memory32 *p)
535{ 510{
536 struct pnp_mem *mem; 511 unsigned char flags = 0;
537 512
538 if (p->address_length == 0) 513 if (p->address_length == 0)
539 return; 514 return;
540 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
541 if (!mem)
542 return;
543 mem->min = p->minimum;
544 mem->max = p->maximum;
545 mem->align = p->alignment;
546 mem->size = p->address_length;
547 515
548 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? 516 if (p->write_protect == ACPI_READ_WRITE_MEMORY)
549 IORESOURCE_MEM_WRITEABLE : 0; 517 flags = IORESOURCE_MEM_WRITEABLE;
550 518 pnp_register_mem_resource(dev, option, p->minimum, p->maximum,
551 pnp_register_mem_resource(dev, option, mem); 519 p->alignment, p->address_length, flags);
552} 520}
553 521
554static __init void pnpacpi_parse_fixed_mem32_option(struct pnp_dev *dev, 522static __init void pnpacpi_parse_fixed_mem32_option(struct pnp_dev *dev,
555 struct pnp_option *option, 523 struct pnp_option *option,
556 struct acpi_resource_fixed_memory32 *p) 524 struct acpi_resource_fixed_memory32 *p)
557{ 525{
558 struct pnp_mem *mem; 526 unsigned char flags = 0;
559 527
560 if (p->address_length == 0) 528 if (p->address_length == 0)
561 return; 529 return;
562 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
563 if (!mem)
564 return;
565 mem->min = mem->max = p->address;
566 mem->size = p->address_length;
567 mem->align = 0;
568 530
569 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? 531 if (p->write_protect == ACPI_READ_WRITE_MEMORY)
570 IORESOURCE_MEM_WRITEABLE : 0; 532 flags = IORESOURCE_MEM_WRITEABLE;
571 533 pnp_register_mem_resource(dev, option, p->address, p->address,
572 pnp_register_mem_resource(dev, option, mem); 534 0, p->address_length, flags);
573} 535}
574 536
575static __init void pnpacpi_parse_address_option(struct pnp_dev *dev, 537static __init void pnpacpi_parse_address_option(struct pnp_dev *dev,
@@ -578,8 +540,7 @@ static __init void pnpacpi_parse_address_option(struct pnp_dev *dev,
578{ 540{
579 struct acpi_resource_address64 addr, *p = &addr; 541 struct acpi_resource_address64 addr, *p = &addr;
580 acpi_status status; 542 acpi_status status;
581 struct pnp_mem *mem; 543 unsigned char flags = 0;
582 struct pnp_port *port;
583 544
584 status = acpi_resource_to_address64(r, p); 545 status = acpi_resource_to_address64(r, p);
585 if (!ACPI_SUCCESS(status)) { 546 if (!ACPI_SUCCESS(status)) {
@@ -592,26 +553,14 @@ static __init void pnpacpi_parse_address_option(struct pnp_dev *dev,
592 return; 553 return;
593 554
594 if (p->resource_type == ACPI_MEMORY_RANGE) { 555 if (p->resource_type == ACPI_MEMORY_RANGE) {
595 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 556 if (p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY)
596 if (!mem) 557 flags = IORESOURCE_MEM_WRITEABLE;
597 return; 558 pnp_register_mem_resource(dev, option, p->minimum, p->minimum,
598 mem->min = mem->max = p->minimum; 559 0, p->address_length, flags);
599 mem->size = p->address_length; 560 } else if (p->resource_type == ACPI_IO_RANGE)
600 mem->align = 0; 561 pnp_register_port_resource(dev, option, p->minimum, p->minimum,
601 mem->flags = (p->info.mem.write_protect == 562 0, p->address_length,
602 ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE 563 IORESOURCE_IO_FIXED);
603 : 0;
604 pnp_register_mem_resource(dev, option, mem);
605 } else if (p->resource_type == ACPI_IO_RANGE) {
606 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
607 if (!port)
608 return;
609 port->min = port->max = p->minimum;
610 port->size = p->address_length;
611 port->align = 0;
612 port->flags = IORESOURCE_IO_FIXED;
613 pnp_register_port_resource(dev, option, port);
614 }
615} 564}
616 565
617struct acpipnp_parse_option_s { 566struct acpipnp_parse_option_s {
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index dd2ea7b03605..26fb04cc12bb 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -218,116 +218,96 @@ static __init void pnpbios_parse_mem_option(struct pnp_dev *dev,
218 unsigned char *p, int size, 218 unsigned char *p, int size,
219 struct pnp_option *option) 219 struct pnp_option *option)
220{ 220{
221 struct pnp_mem *mem; 221 resource_size_t min, max, align, len;
222 222 unsigned char flags;
223 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 223
224 if (!mem) 224 min = ((p[5] << 8) | p[4]) << 8;
225 return; 225 max = ((p[7] << 8) | p[6]) << 8;
226 mem->min = ((p[5] << 8) | p[4]) << 8; 226 align = (p[9] << 8) | p[8];
227 mem->max = ((p[7] << 8) | p[6]) << 8; 227 len = ((p[11] << 8) | p[10]) << 8;
228 mem->align = (p[9] << 8) | p[8]; 228 flags = p[3];
229 mem->size = ((p[11] << 8) | p[10]) << 8; 229 pnp_register_mem_resource(dev, option, min, max, align, len, flags);
230 mem->flags = p[3];
231 pnp_register_mem_resource(dev, option, mem);
232} 230}
233 231
234static __init void pnpbios_parse_mem32_option(struct pnp_dev *dev, 232static __init void pnpbios_parse_mem32_option(struct pnp_dev *dev,
235 unsigned char *p, int size, 233 unsigned char *p, int size,
236 struct pnp_option *option) 234 struct pnp_option *option)
237{ 235{
238 struct pnp_mem *mem; 236 resource_size_t min, max, align, len;
239 237 unsigned char flags;
240 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 238
241 if (!mem) 239 min = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4];
242 return; 240 max = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8];
243 mem->min = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; 241 align = (p[15] << 24) | (p[14] << 16) | (p[13] << 8) | p[12];
244 mem->max = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8]; 242 len = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16];
245 mem->align = (p[15] << 24) | (p[14] << 16) | (p[13] << 8) | p[12]; 243 flags = p[3];
246 mem->size = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16]; 244 pnp_register_mem_resource(dev, option, min, max, align, len, flags);
247 mem->flags = p[3];
248 pnp_register_mem_resource(dev, option, mem);
249} 245}
250 246
251static __init void pnpbios_parse_fixed_mem32_option(struct pnp_dev *dev, 247static __init void pnpbios_parse_fixed_mem32_option(struct pnp_dev *dev,
252 unsigned char *p, int size, 248 unsigned char *p, int size,
253 struct pnp_option *option) 249 struct pnp_option *option)
254{ 250{
255 struct pnp_mem *mem; 251 resource_size_t base, len;
256 252 unsigned char flags;
257 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 253
258 if (!mem) 254 base = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4];
259 return; 255 len = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8];
260 mem->min = mem->max = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; 256 flags = p[3];
261 mem->size = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8]; 257 pnp_register_mem_resource(dev, option, base, base, 0, len, flags);
262 mem->align = 0;
263 mem->flags = p[3];
264 pnp_register_mem_resource(dev, option, mem);
265} 258}
266 259
267static __init void pnpbios_parse_irq_option(struct pnp_dev *dev, 260static __init void pnpbios_parse_irq_option(struct pnp_dev *dev,
268 unsigned char *p, int size, 261 unsigned char *p, int size,
269 struct pnp_option *option) 262 struct pnp_option *option)
270{ 263{
271 struct pnp_irq *irq;
272 unsigned long bits; 264 unsigned long bits;
265 pnp_irq_mask_t map;
266 unsigned char flags = IORESOURCE_IRQ_HIGHEDGE;
273 267
274 irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
275 if (!irq)
276 return;
277 bits = (p[2] << 8) | p[1]; 268 bits = (p[2] << 8) | p[1];
278 bitmap_copy(irq->map.bits, &bits, 16); 269
270 bitmap_zero(map.bits, PNP_IRQ_NR);
271 bitmap_copy(map.bits, &bits, 16);
272
279 if (size > 2) 273 if (size > 2)
280 irq->flags = p[3]; 274 flags = p[3];
281 else 275
282 irq->flags = IORESOURCE_IRQ_HIGHEDGE; 276 pnp_register_irq_resource(dev, option, &map, flags);
283 pnp_register_irq_resource(dev, option, irq);
284} 277}
285 278
286static __init void pnpbios_parse_dma_option(struct pnp_dev *dev, 279static __init void pnpbios_parse_dma_option(struct pnp_dev *dev,
287 unsigned char *p, int size, 280 unsigned char *p, int size,
288 struct pnp_option *option) 281 struct pnp_option *option)
289{ 282{
290 struct pnp_dma *dma; 283 pnp_register_dma_resource(dev, option, p[1], p[2]);
291
292 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL);
293 if (!dma)
294 return;
295 dma->map = p[1];
296 dma->flags = p[2];
297 pnp_register_dma_resource(dev, option, dma);
298} 284}
299 285
300static __init void pnpbios_parse_port_option(struct pnp_dev *dev, 286static __init void pnpbios_parse_port_option(struct pnp_dev *dev,
301 unsigned char *p, int size, 287 unsigned char *p, int size,
302 struct pnp_option *option) 288 struct pnp_option *option)
303{ 289{
304 struct pnp_port *port; 290 resource_size_t min, max, align, len;
305 291 unsigned char flags;
306 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 292
307 if (!port) 293 min = (p[3] << 8) | p[2];
308 return; 294 max = (p[5] << 8) | p[4];
309 port->min = (p[3] << 8) | p[2]; 295 align = p[6];
310 port->max = (p[5] << 8) | p[4]; 296 len = p[7];
311 port->align = p[6]; 297 flags = p[1] ? IORESOURCE_IO_16BIT_ADDR : 0;
312 port->size = p[7]; 298 pnp_register_port_resource(dev, option, min, max, align, len, flags);
313 port->flags = p[1] ? IORESOURCE_IO_16BIT_ADDR : 0;
314 pnp_register_port_resource(dev, option, port);
315} 299}
316 300
317static __init void pnpbios_parse_fixed_port_option(struct pnp_dev *dev, 301static __init void pnpbios_parse_fixed_port_option(struct pnp_dev *dev,
318 unsigned char *p, int size, 302 unsigned char *p, int size,
319 struct pnp_option *option) 303 struct pnp_option *option)
320{ 304{
321 struct pnp_port *port; 305 resource_size_t base, len;
322 306
323 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 307 base = (p[2] << 8) | p[1];
324 if (!port) 308 len = p[3];
325 return; 309 pnp_register_port_resource(dev, option, base, base, 0, len,
326 port->min = port->max = (p[2] << 8) | p[1]; 310 IORESOURCE_IO_FIXED);
327 port->size = p[3];
328 port->align = 0;
329 port->flags = IORESOURCE_IO_FIXED;
330 pnp_register_port_resource(dev, option, port);
331} 311}
332 312
333static __init unsigned char * 313static __init unsigned char *
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index 391828c7f207..61145491f363 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -78,13 +78,20 @@ struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
78} 78}
79 79
80int pnp_register_irq_resource(struct pnp_dev *dev, struct pnp_option *option, 80int pnp_register_irq_resource(struct pnp_dev *dev, struct pnp_option *option,
81 struct pnp_irq *data) 81 pnp_irq_mask_t *map, unsigned char flags)
82{ 82{
83 struct pnp_irq *ptr; 83 struct pnp_irq *data, *ptr;
84#ifdef DEBUG 84#ifdef DEBUG
85 char buf[PNP_IRQ_NR]; /* hex-encoded, so this is overkill but safe */ 85 char buf[PNP_IRQ_NR]; /* hex-encoded, so this is overkill but safe */
86#endif 86#endif
87 87
88 data = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
89 if (!data)
90 return -ENOMEM;
91
92 data->map = *map;
93 data->flags = flags;
94
88 ptr = option->irq; 95 ptr = option->irq;
89 while (ptr && ptr->next) 96 while (ptr && ptr->next)
90 ptr = ptr->next; 97 ptr = ptr->next;
@@ -112,9 +119,16 @@ int pnp_register_irq_resource(struct pnp_dev *dev, struct pnp_option *option,
112} 119}
113 120
114int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_option *option, 121int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_option *option,
115 struct pnp_dma *data) 122 unsigned char map, unsigned char flags)
116{ 123{
117 struct pnp_dma *ptr; 124 struct pnp_dma *data, *ptr;
125
126 data = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL);
127 if (!data)
128 return -ENOMEM;
129
130 data->map = map;
131 data->flags = flags;
118 132
119 ptr = option->dma; 133 ptr = option->dma;
120 while (ptr && ptr->next) 134 while (ptr && ptr->next)
@@ -130,9 +144,21 @@ int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_option *option,
130} 144}
131 145
132int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option, 146int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option,
133 struct pnp_port *data) 147 resource_size_t min, resource_size_t max,
148 resource_size_t align, resource_size_t size,
149 unsigned char flags)
134{ 150{
135 struct pnp_port *ptr; 151 struct pnp_port *data, *ptr;
152
153 data = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
154 if (!data)
155 return -ENOMEM;
156
157 data->min = min;
158 data->max = max;
159 data->align = align;
160 data->size = size;
161 data->flags = flags;
136 162
137 ptr = option->port; 163 ptr = option->port;
138 while (ptr && ptr->next) 164 while (ptr && ptr->next)
@@ -152,9 +178,21 @@ int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option,
152} 178}
153 179
154int pnp_register_mem_resource(struct pnp_dev *dev, struct pnp_option *option, 180int pnp_register_mem_resource(struct pnp_dev *dev, struct pnp_option *option,
155 struct pnp_mem *data) 181 resource_size_t min, resource_size_t max,
182 resource_size_t align, resource_size_t size,
183 unsigned char flags)
156{ 184{
157 struct pnp_mem *ptr; 185 struct pnp_mem *data, *ptr;
186
187 data = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
188 if (!data)
189 return -ENOMEM;
190
191 data->min = min;
192 data->max = max;
193 data->align = align;
194 data->size = size;
195 data->flags = flags;
158 196
159 ptr = option->mem; 197 ptr = option->mem;
160 while (ptr && ptr->next) 198 while (ptr && ptr->next)