Merge tag 'pm+acpi-4.4-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[firefly-linux-kernel-4.4.55.git] / drivers / acpi / scan.c
index ed3d76fadccf40ff8057ff48c4ee1134b8eed5c9..78d5f02a073bb1c9e84beaeaf2f38b6f54125333 100644 (file)
@@ -1164,7 +1164,7 @@ static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id)
        if (!id)
                return;
 
-       id->id = kstrdup(dev_id, GFP_KERNEL);
+       id->id = kstrdup_const(dev_id, GFP_KERNEL);
        if (!id->id) {
                kfree(id);
                return;
@@ -1302,7 +1302,7 @@ void acpi_free_pnp_ids(struct acpi_device_pnp *pnp)
        struct acpi_hardware_id *id, *tmp;
 
        list_for_each_entry_safe(id, tmp, &pnp->ids, list) {
-               kfree(id->id);
+               kfree_const(id->id);
                kfree(id);
        }
        kfree(pnp->unique_id);
@@ -1494,7 +1494,7 @@ bool acpi_device_is_present(struct acpi_device *adev)
 }
 
 static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler,
-                                      char *idstr,
+                                      const char *idstr,
                                       const struct acpi_device_id **matchid)
 {
        const struct acpi_device_id *devid;
@@ -1513,7 +1513,7 @@ static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler,
        return false;
 }
 
-static struct acpi_scan_handler *acpi_scan_match_handler(char *idstr,
+static struct acpi_scan_handler *acpi_scan_match_handler(const char *idstr,
                                        const struct acpi_device_id **matchid)
 {
        struct acpi_scan_handler *handler;
@@ -1955,3 +1955,42 @@ int __init acpi_scan_init(void)
        mutex_unlock(&acpi_scan_lock);
        return result;
 }
+
+static struct acpi_probe_entry *ape;
+static int acpi_probe_count;
+static DEFINE_SPINLOCK(acpi_probe_lock);
+
+static int __init acpi_match_madt(struct acpi_subtable_header *header,
+                                 const unsigned long end)
+{
+       if (!ape->subtable_valid || ape->subtable_valid(header, ape))
+               if (!ape->probe_subtbl(header, end))
+                       acpi_probe_count++;
+
+       return 0;
+}
+
+int __init __acpi_probe_device_table(struct acpi_probe_entry *ap_head, int nr)
+{
+       int count = 0;
+
+       if (acpi_disabled)
+               return 0;
+
+       spin_lock(&acpi_probe_lock);
+       for (ape = ap_head; nr; ape++, nr--) {
+               if (ACPI_COMPARE_NAME(ACPI_SIG_MADT, ape->id)) {
+                       acpi_probe_count = 0;
+                       acpi_table_parse_madt(ape->type, acpi_match_madt, 0);
+                       count += acpi_probe_count;
+               } else {
+                       int res;
+                       res = acpi_table_parse(ape->id, ape->probe_table);
+                       if (!res)
+                               count++;
+               }
+       }
+       spin_unlock(&acpi_probe_lock);
+
+       return count;
+}