Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux...
[linux/fpc-iii.git] / sound / soc / intel / common / sst-match-acpi.c
blob789843307a4950ad503d3cabda82300489d8e8d0
1 /*
2 * sst_match_apci.c - SST (LPE) match for ACPI enumeration.
4 * Copyright (c) 2013-15, Intel Corporation.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
17 #include "sst-acpi.h"
19 static acpi_status sst_acpi_find_name(acpi_handle handle, u32 level,
20 void *context, void **ret)
22 struct acpi_device *adev;
23 const char *name = NULL;
25 if (acpi_bus_get_device(handle, &adev))
26 return AE_OK;
28 if (adev->status.present && adev->status.functional) {
29 name = acpi_dev_name(adev);
30 *(const char **)ret = name;
31 return AE_CTRL_TERMINATE;
34 return AE_OK;
37 const char *sst_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN])
39 const char *name = NULL;
40 acpi_status status;
42 status = acpi_get_devices(hid, sst_acpi_find_name, NULL,
43 (void **)&name);
45 if (ACPI_FAILURE(status) || name[0] == '\0')
46 return NULL;
48 return name;
50 EXPORT_SYMBOL_GPL(sst_acpi_find_name_from_hid);
52 static acpi_status sst_acpi_mach_match(acpi_handle handle, u32 level,
53 void *context, void **ret)
55 unsigned long long sta;
56 acpi_status status;
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;
63 return AE_OK;
66 struct sst_acpi_mach *sst_acpi_find_machine(struct sst_acpi_mach *machines)
68 struct sst_acpi_mach *mach;
69 bool found = false;
71 for (mach = machines; mach->id[0]; mach++)
72 if (ACPI_SUCCESS(acpi_get_devices(mach->id,
73 sst_acpi_mach_match,
74 &found, NULL)) && found)
75 return mach;
76 return NULL;
78 EXPORT_SYMBOL_GPL(sst_acpi_find_machine);
80 MODULE_LICENSE("GPL v2");
81 MODULE_DESCRIPTION("Intel Common ACPI Match module");