Merge tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64...
[pandora-kernel.git] / drivers / firmware / efi / efi.c
index fccb464..3061bb8 100644 (file)
@@ -297,29 +297,15 @@ static __init int match_config_table(efi_guid_t *guid,
        return 0;
 }
 
-int __init efi_config_init(efi_config_table_type_t *arch_tables)
+int __init efi_config_parse_tables(void *config_tables, int count, int sz,
+                                  efi_config_table_type_t *arch_tables)
 {
-       void *config_tables, *tablep;
-       int i, sz;
-
-       if (efi_enabled(EFI_64BIT))
-               sz = sizeof(efi_config_table_64_t);
-       else
-               sz = sizeof(efi_config_table_32_t);
-
-       /*
-        * Let's see what config tables the firmware passed to us.
-        */
-       config_tables = early_memremap(efi.systab->tables,
-                                      efi.systab->nr_tables * sz);
-       if (config_tables == NULL) {
-               pr_err("Could not map Configuration table!\n");
-               return -ENOMEM;
-       }
+       void *tablep;
+       int i;
 
        tablep = config_tables;
        pr_info("");
-       for (i = 0; i < efi.systab->nr_tables; i++) {
+       for (i = 0; i < count; i++) {
                efi_guid_t guid;
                unsigned long table;
 
@@ -332,8 +318,6 @@ int __init efi_config_init(efi_config_table_type_t *arch_tables)
                        if (table64 >> 32) {
                                pr_cont("\n");
                                pr_err("Table located above 4GB, disabling EFI.\n");
-                               early_memunmap(config_tables,
-                                              efi.systab->nr_tables * sz);
                                return -EINVAL;
                        }
 #endif
@@ -348,13 +332,37 @@ int __init efi_config_init(efi_config_table_type_t *arch_tables)
                tablep += sz;
        }
        pr_cont("\n");
-       early_memunmap(config_tables, efi.systab->nr_tables * sz);
-
        set_bit(EFI_CONFIG_TABLES, &efi.flags);
-
        return 0;
 }
 
+int __init efi_config_init(efi_config_table_type_t *arch_tables)
+{
+       void *config_tables;
+       int sz, ret;
+
+       if (efi_enabled(EFI_64BIT))
+               sz = sizeof(efi_config_table_64_t);
+       else
+               sz = sizeof(efi_config_table_32_t);
+
+       /*
+        * Let's see what config tables the firmware passed to us.
+        */
+       config_tables = early_memremap(efi.systab->tables,
+                                      efi.systab->nr_tables * sz);
+       if (config_tables == NULL) {
+               pr_err("Could not map Configuration table!\n");
+               return -ENOMEM;
+       }
+
+       ret = efi_config_parse_tables(config_tables, efi.systab->nr_tables, sz,
+                                     arch_tables);
+
+       early_memunmap(config_tables, efi.systab->nr_tables * sz);
+       return ret;
+}
+
 #ifdef CONFIG_EFI_VARS_MODULE
 static int __init efi_load_efivars(void)
 {