aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/resource.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/resource.c')
-rw-r--r--drivers/acpi/resource.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
index 1c3abae6f2fa..3ea0d17eb951 100644
--- a/drivers/acpi/resource.c
+++ b/drivers/acpi/resource.c
@@ -569,3 +569,58 @@ int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,
569 return c.count; 569 return c.count;
570} 570}
571EXPORT_SYMBOL_GPL(acpi_dev_get_resources); 571EXPORT_SYMBOL_GPL(acpi_dev_get_resources);
572
573/**
574 * acpi_dev_filter_resource_type - Filter ACPI resource according to resource
575 * types
576 * @ares: Input ACPI resource object.
577 * @types: Valid resource types of IORESOURCE_XXX
578 *
579 * This is a hepler function to support acpi_dev_get_resources(), which filters
580 * ACPI resource objects according to resource types.
581 */
582int acpi_dev_filter_resource_type(struct acpi_resource *ares,
583 unsigned long types)
584{
585 unsigned long type = 0;
586
587 switch (ares->type) {
588 case ACPI_RESOURCE_TYPE_MEMORY24:
589 case ACPI_RESOURCE_TYPE_MEMORY32:
590 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
591 type = IORESOURCE_MEM;
592 break;
593 case ACPI_RESOURCE_TYPE_IO:
594 case ACPI_RESOURCE_TYPE_FIXED_IO:
595 type = IORESOURCE_IO;
596 break;
597 case ACPI_RESOURCE_TYPE_IRQ:
598 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
599 type = IORESOURCE_IRQ;
600 break;
601 case ACPI_RESOURCE_TYPE_DMA:
602 case ACPI_RESOURCE_TYPE_FIXED_DMA:
603 type = IORESOURCE_DMA;
604 break;
605 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
606 type = IORESOURCE_REG;
607 break;
608 case ACPI_RESOURCE_TYPE_ADDRESS16:
609 case ACPI_RESOURCE_TYPE_ADDRESS32:
610 case ACPI_RESOURCE_TYPE_ADDRESS64:
611 case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
612 if (ares->data.address.resource_type == ACPI_MEMORY_RANGE)
613 type = IORESOURCE_MEM;
614 else if (ares->data.address.resource_type == ACPI_IO_RANGE)
615 type = IORESOURCE_IO;
616 else if (ares->data.address.resource_type ==
617 ACPI_BUS_NUMBER_RANGE)
618 type = IORESOURCE_BUS;
619 break;
620 default:
621 break;
622 }
623
624 return (type & types) ? 0 : 1;
625}
626EXPORT_SYMBOL_GPL(acpi_dev_filter_resource_type);