diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2008-06-27 18:57:01 -0400 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2008-07-16 17:27:06 -0400 |
commit | 57fd51a8be26921b56747ddd09d1d9e01c11c9e0 (patch) | |
tree | 8b34c3d57867a217cfabf09a73a1af19242bdc7b /drivers/pnp/resource.c | |
parent | f61ed7e32d2d6a0a8c3c101da513ccedd542e14d (diff) |
PNP: add pnp_possible_config() -- can a device could be configured this way?
As part of a heuristic to identify modem devices, 8250_pnp.c
checks to see whether a device can be configured at any of the
legacy COM port addresses.
This patch moves the code that traverses the PNP "possible resource
options" from 8250_pnp.c to the PNP subsystem. This encapsulation
is important because a future patch will change the implementation
of those resource options.
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/resource.c')
-rw-r--r-- | drivers/pnp/resource.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c index ff79aa6168cf..786fd356916d 100644 --- a/drivers/pnp/resource.c +++ b/drivers/pnp/resource.c | |||
@@ -624,6 +624,68 @@ struct pnp_resource *pnp_add_mem_resource(struct pnp_dev *dev, | |||
624 | return pnp_res; | 624 | return pnp_res; |
625 | } | 625 | } |
626 | 626 | ||
627 | static int pnp_possible_option(struct pnp_option *option, int type, | ||
628 | resource_size_t start, resource_size_t size) | ||
629 | { | ||
630 | struct pnp_option *tmp; | ||
631 | struct pnp_port *port; | ||
632 | struct pnp_mem *mem; | ||
633 | struct pnp_irq *irq; | ||
634 | struct pnp_dma *dma; | ||
635 | |||
636 | if (!option) | ||
637 | return 0; | ||
638 | |||
639 | for (tmp = option; tmp; tmp = tmp->next) { | ||
640 | switch (type) { | ||
641 | case IORESOURCE_IO: | ||
642 | for (port = tmp->port; port; port = port->next) { | ||
643 | if (port->min == start && port->size == size) | ||
644 | return 1; | ||
645 | } | ||
646 | break; | ||
647 | case IORESOURCE_MEM: | ||
648 | for (mem = tmp->mem; mem; mem = mem->next) { | ||
649 | if (mem->min == start && mem->size == size) | ||
650 | return 1; | ||
651 | } | ||
652 | break; | ||
653 | case IORESOURCE_IRQ: | ||
654 | for (irq = tmp->irq; irq; irq = irq->next) { | ||
655 | if (start < PNP_IRQ_NR && | ||
656 | test_bit(start, irq->map)) | ||
657 | return 1; | ||
658 | } | ||
659 | break; | ||
660 | case IORESOURCE_DMA: | ||
661 | for (dma = tmp->dma; dma; dma = dma->next) { | ||
662 | if (dma->map & (1 << start)) | ||
663 | return 1; | ||
664 | } | ||
665 | break; | ||
666 | } | ||
667 | } | ||
668 | |||
669 | return 0; | ||
670 | } | ||
671 | |||
672 | /* | ||
673 | * Determine whether the specified resource is a possible configuration | ||
674 | * for this device. | ||
675 | */ | ||
676 | int pnp_possible_config(struct pnp_dev *dev, int type, resource_size_t start, | ||
677 | resource_size_t size) | ||
678 | { | ||
679 | if (pnp_possible_option(dev->independent, type, start, size)) | ||
680 | return 1; | ||
681 | |||
682 | if (pnp_possible_option(dev->dependent, type, start, size)) | ||
683 | return 1; | ||
684 | |||
685 | return 0; | ||
686 | } | ||
687 | EXPORT_SYMBOL(pnp_possible_config); | ||
688 | |||
627 | /* format is: pnp_reserve_irq=irq1[,irq2] .... */ | 689 | /* format is: pnp_reserve_irq=irq1[,irq2] .... */ |
628 | static int __init pnp_setup_reserve_irq(char *str) | 690 | static int __init pnp_setup_reserve_irq(char *str) |
629 | { | 691 | { |