diff options
Diffstat (limited to 'drivers/acpi/utils.c')
-rw-r--r-- | drivers/acpi/utils.c | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 9d49a1acebe3..78db97687f26 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c | |||
@@ -737,16 +737,17 @@ bool acpi_dev_found(const char *hid) | |||
737 | } | 737 | } |
738 | EXPORT_SYMBOL(acpi_dev_found); | 738 | EXPORT_SYMBOL(acpi_dev_found); |
739 | 739 | ||
740 | struct acpi_dev_present_info { | 740 | struct acpi_dev_match_info { |
741 | const char *dev_name; | ||
741 | struct acpi_device_id hid[2]; | 742 | struct acpi_device_id hid[2]; |
742 | const char *uid; | 743 | const char *uid; |
743 | s64 hrv; | 744 | s64 hrv; |
744 | }; | 745 | }; |
745 | 746 | ||
746 | static int acpi_dev_present_cb(struct device *dev, void *data) | 747 | static int acpi_dev_match_cb(struct device *dev, void *data) |
747 | { | 748 | { |
748 | struct acpi_device *adev = to_acpi_device(dev); | 749 | struct acpi_device *adev = to_acpi_device(dev); |
749 | struct acpi_dev_present_info *match = data; | 750 | struct acpi_dev_match_info *match = data; |
750 | unsigned long long hrv; | 751 | unsigned long long hrv; |
751 | acpi_status status; | 752 | acpi_status status; |
752 | 753 | ||
@@ -757,6 +758,8 @@ static int acpi_dev_present_cb(struct device *dev, void *data) | |||
757 | strcmp(adev->pnp.unique_id, match->uid))) | 758 | strcmp(adev->pnp.unique_id, match->uid))) |
758 | return 0; | 759 | return 0; |
759 | 760 | ||
761 | match->dev_name = acpi_dev_name(adev); | ||
762 | |||
760 | if (match->hrv == -1) | 763 | if (match->hrv == -1) |
761 | return 1; | 764 | return 1; |
762 | 765 | ||
@@ -789,20 +792,44 @@ static int acpi_dev_present_cb(struct device *dev, void *data) | |||
789 | */ | 792 | */ |
790 | bool acpi_dev_present(const char *hid, const char *uid, s64 hrv) | 793 | bool acpi_dev_present(const char *hid, const char *uid, s64 hrv) |
791 | { | 794 | { |
792 | struct acpi_dev_present_info match = {}; | 795 | struct acpi_dev_match_info match = {}; |
793 | struct device *dev; | 796 | struct device *dev; |
794 | 797 | ||
795 | strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id)); | 798 | strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id)); |
796 | match.uid = uid; | 799 | match.uid = uid; |
797 | match.hrv = hrv; | 800 | match.hrv = hrv; |
798 | 801 | ||
799 | dev = bus_find_device(&acpi_bus_type, NULL, &match, | 802 | dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb); |
800 | acpi_dev_present_cb); | ||
801 | |||
802 | return !!dev; | 803 | return !!dev; |
803 | } | 804 | } |
804 | EXPORT_SYMBOL(acpi_dev_present); | 805 | EXPORT_SYMBOL(acpi_dev_present); |
805 | 806 | ||
807 | /** | ||
808 | * acpi_dev_get_first_match_name - Return name of first match of ACPI device | ||
809 | * @hid: Hardware ID of the device. | ||
810 | * @uid: Unique ID of the device, pass NULL to not check _UID | ||
811 | * @hrv: Hardware Revision of the device, pass -1 to not check _HRV | ||
812 | * | ||
813 | * Return device name if a matching device was present | ||
814 | * at the moment of invocation, or NULL otherwise. | ||
815 | * | ||
816 | * See additional information in acpi_dev_present() as well. | ||
817 | */ | ||
818 | const char * | ||
819 | acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv) | ||
820 | { | ||
821 | struct acpi_dev_match_info match = {}; | ||
822 | struct device *dev; | ||
823 | |||
824 | strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id)); | ||
825 | match.uid = uid; | ||
826 | match.hrv = hrv; | ||
827 | |||
828 | dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb); | ||
829 | return dev ? match.dev_name : NULL; | ||
830 | } | ||
831 | EXPORT_SYMBOL(acpi_dev_get_first_match_name); | ||
832 | |||
806 | /* | 833 | /* |
807 | * acpi_backlight= handling, this is done here rather then in video_detect.c | 834 | * acpi_backlight= handling, this is done here rather then in video_detect.c |
808 | * because __setup cannot be used in modules. | 835 | * because __setup cannot be used in modules. |