diff options
Diffstat (limited to 'sound/soc/intel/common/sst-match-acpi.c')
-rw-r--r-- | sound/soc/intel/common/sst-match-acpi.c | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/sound/soc/intel/common/sst-match-acpi.c b/sound/soc/intel/common/sst-match-acpi.c index 3b4539d21492..789843307a49 100644 --- a/sound/soc/intel/common/sst-match-acpi.c +++ b/sound/soc/intel/common/sst-match-acpi.c | |||
@@ -13,17 +13,53 @@ | |||
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
14 | * more details. | 14 | * more details. |
15 | */ | 15 | */ |
16 | #include <linux/acpi.h> | ||
17 | #include <linux/device.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/platform_device.h> | ||
20 | 16 | ||
21 | #include "sst-acpi.h" | 17 | #include "sst-acpi.h" |
22 | 18 | ||
19 | static acpi_status sst_acpi_find_name(acpi_handle handle, u32 level, | ||
20 | void *context, void **ret) | ||
21 | { | ||
22 | struct acpi_device *adev; | ||
23 | const char *name = NULL; | ||
24 | |||
25 | if (acpi_bus_get_device(handle, &adev)) | ||
26 | return AE_OK; | ||
27 | |||
28 | if (adev->status.present && adev->status.functional) { | ||
29 | name = acpi_dev_name(adev); | ||
30 | *(const char **)ret = name; | ||
31 | return AE_CTRL_TERMINATE; | ||
32 | } | ||
33 | |||
34 | return AE_OK; | ||
35 | } | ||
36 | |||
37 | const char *sst_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN]) | ||
38 | { | ||
39 | const char *name = NULL; | ||
40 | acpi_status status; | ||
41 | |||
42 | status = acpi_get_devices(hid, sst_acpi_find_name, NULL, | ||
43 | (void **)&name); | ||
44 | |||
45 | if (ACPI_FAILURE(status) || name[0] == '\0') | ||
46 | return NULL; | ||
47 | |||
48 | return name; | ||
49 | } | ||
50 | EXPORT_SYMBOL_GPL(sst_acpi_find_name_from_hid); | ||
51 | |||
23 | static acpi_status sst_acpi_mach_match(acpi_handle handle, u32 level, | 52 | static acpi_status sst_acpi_mach_match(acpi_handle handle, u32 level, |
24 | void *context, void **ret) | 53 | void *context, void **ret) |
25 | { | 54 | { |
55 | unsigned long long sta; | ||
56 | acpi_status status; | ||
57 | |||
26 | *(bool *)context = true; | 58 | *(bool *)context = true; |
59 | status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); | ||
60 | if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT)) | ||
61 | *(bool *)context = false; | ||
62 | |||
27 | return AE_OK; | 63 | return AE_OK; |
28 | } | 64 | } |
29 | 65 | ||
@@ -37,7 +73,6 @@ struct sst_acpi_mach *sst_acpi_find_machine(struct sst_acpi_mach *machines) | |||
37 | sst_acpi_mach_match, | 73 | sst_acpi_mach_match, |
38 | &found, NULL)) && found) | 74 | &found, NULL)) && found) |
39 | return mach; | 75 | return mach; |
40 | |||
41 | return NULL; | 76 | return NULL; |
42 | } | 77 | } |
43 | EXPORT_SYMBOL_GPL(sst_acpi_find_machine); | 78 | EXPORT_SYMBOL_GPL(sst_acpi_find_machine); |