diff options
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 | { |