diff options
author | Jiang Liu <jiang.liu@linux.intel.com> | 2015-02-01 21:43:01 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-02-03 16:27:23 -0500 |
commit | 62d1141ff34e35de496ba06491c8e854b23b3f3e (patch) | |
tree | 597c240e33d2b97579fa60f7141a29e727f66b48 /drivers/acpi | |
parent | 93286f4798590e711aa395503401f8632fb74f9a (diff) |
ACPI: Introduce helper function acpi_dev_filter_resource_type()
Introduce helper function acpi_dev_filter_resource_type(), which may
be used by acpi_dev_get_resources() to filer out resource based on
resource type.
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/resource.c | 55 |
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 | } |
571 | EXPORT_SYMBOL_GPL(acpi_dev_get_resources); | 571 | EXPORT_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 | */ | ||
582 | int 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 | } | ||
626 | EXPORT_SYMBOL_GPL(acpi_dev_filter_resource_type); | ||