aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/pnpacpi
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2008-06-27 18:57:11 -0400
committerAndi Kleen <andi@basil.nowhere.org>2008-07-16 17:27:07 -0400
commitc227536b4cc2600fc9d22ba0067f699165f6621f (patch)
treeeacf9e90f89f9f71304033e4da1492450c8c644a /drivers/pnp/pnpacpi
parentb08395e5038e3337bb85c7246a635a3be6d5a29c (diff)
PNP: centralize resource option allocations
This patch moves all the option allocations (pnp_mem, pnp_port, etc) into the pnp_register_{mem,port,irq,dma}_resource() functions. This will make it easier to rework the option data structures. The non-trivial part of this patch is the IRQ handling. The backends have to allocate a local pnp_irq_mask_t bitmap, populate it, and pass a pointer to pnp_register_irq_resource(). Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: Rene Herman <rene.herman@gmail.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/pnp/pnpacpi')
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c149
1 files changed, 49 insertions, 100 deletions
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 {