diff options
Diffstat (limited to 'drivers/acpi/resource.c')
-rw-r--r-- | drivers/acpi/resource.c | 82 |
1 files changed, 63 insertions, 19 deletions
diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c index cd4c4271dc4c..d85e010ee2cc 100644 --- a/drivers/acpi/resource.c +++ b/drivers/acpi/resource.c | |||
@@ -573,6 +573,35 @@ static acpi_status acpi_dev_process_resource(struct acpi_resource *ares, | |||
573 | return AE_OK; | 573 | return AE_OK; |
574 | } | 574 | } |
575 | 575 | ||
576 | static int __acpi_dev_get_resources(struct acpi_device *adev, | ||
577 | struct list_head *list, | ||
578 | int (*preproc)(struct acpi_resource *, void *), | ||
579 | void *preproc_data, char *method) | ||
580 | { | ||
581 | struct res_proc_context c; | ||
582 | acpi_status status; | ||
583 | |||
584 | if (!adev || !adev->handle || !list_empty(list)) | ||
585 | return -EINVAL; | ||
586 | |||
587 | if (!acpi_has_method(adev->handle, method)) | ||
588 | return 0; | ||
589 | |||
590 | c.list = list; | ||
591 | c.preproc = preproc; | ||
592 | c.preproc_data = preproc_data; | ||
593 | c.count = 0; | ||
594 | c.error = 0; | ||
595 | status = acpi_walk_resources(adev->handle, method, | ||
596 | acpi_dev_process_resource, &c); | ||
597 | if (ACPI_FAILURE(status)) { | ||
598 | acpi_dev_free_resource_list(list); | ||
599 | return c.error ? c.error : -EIO; | ||
600 | } | ||
601 | |||
602 | return c.count; | ||
603 | } | ||
604 | |||
576 | /** | 605 | /** |
577 | * acpi_dev_get_resources - Get current resources of a device. | 606 | * acpi_dev_get_resources - Get current resources of a device. |
578 | * @adev: ACPI device node to get the resources for. | 607 | * @adev: ACPI device node to get the resources for. |
@@ -601,30 +630,45 @@ int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list, | |||
601 | int (*preproc)(struct acpi_resource *, void *), | 630 | int (*preproc)(struct acpi_resource *, void *), |
602 | void *preproc_data) | 631 | void *preproc_data) |
603 | { | 632 | { |
604 | struct res_proc_context c; | 633 | return __acpi_dev_get_resources(adev, list, preproc, preproc_data, |
605 | acpi_status status; | 634 | METHOD_NAME__CRS); |
635 | } | ||
636 | EXPORT_SYMBOL_GPL(acpi_dev_get_resources); | ||
606 | 637 | ||
607 | if (!adev || !adev->handle || !list_empty(list)) | 638 | static int is_memory(struct acpi_resource *ares, void *not_used) |
608 | return -EINVAL; | 639 | { |
640 | struct resource_win win; | ||
641 | struct resource *res = &win.res; | ||
609 | 642 | ||
610 | if (!acpi_has_method(adev->handle, METHOD_NAME__CRS)) | 643 | memset(&win, 0, sizeof(win)); |
611 | return 0; | ||
612 | 644 | ||
613 | c.list = list; | 645 | return !(acpi_dev_resource_memory(ares, res) |
614 | c.preproc = preproc; | 646 | || acpi_dev_resource_address_space(ares, &win) |
615 | c.preproc_data = preproc_data; | 647 | || acpi_dev_resource_ext_address_space(ares, &win)); |
616 | c.count = 0; | 648 | } |
617 | c.error = 0; | ||
618 | status = acpi_walk_resources(adev->handle, METHOD_NAME__CRS, | ||
619 | acpi_dev_process_resource, &c); | ||
620 | if (ACPI_FAILURE(status)) { | ||
621 | acpi_dev_free_resource_list(list); | ||
622 | return c.error ? c.error : -EIO; | ||
623 | } | ||
624 | 649 | ||
625 | return c.count; | 650 | /** |
651 | * acpi_dev_get_dma_resources - Get current DMA resources of a device. | ||
652 | * @adev: ACPI device node to get the resources for. | ||
653 | * @list: Head of the resultant list of resources (must be empty). | ||
654 | * | ||
655 | * Evaluate the _DMA method for the given device node and process its | ||
656 | * output. | ||
657 | * | ||
658 | * The resultant struct resource objects are put on the list pointed to | ||
659 | * by @list, that must be empty initially, as members of struct | ||
660 | * resource_entry objects. Callers of this routine should use | ||
661 | * %acpi_dev_free_resource_list() to free that list. | ||
662 | * | ||
663 | * The number of resources in the output list is returned on success, | ||
664 | * an error code reflecting the error condition is returned otherwise. | ||
665 | */ | ||
666 | int acpi_dev_get_dma_resources(struct acpi_device *adev, struct list_head *list) | ||
667 | { | ||
668 | return __acpi_dev_get_resources(adev, list, is_memory, NULL, | ||
669 | METHOD_NAME__DMA); | ||
626 | } | 670 | } |
627 | EXPORT_SYMBOL_GPL(acpi_dev_get_resources); | 671 | EXPORT_SYMBOL_GPL(acpi_dev_get_dma_resources); |
628 | 672 | ||
629 | /** | 673 | /** |
630 | * acpi_dev_filter_resource_type - Filter ACPI resource according to resource | 674 | * acpi_dev_filter_resource_type - Filter ACPI resource according to resource |