efi/fdt: Simplify the get_fdt() flow
authorJulien Thierry <julien.thierry@arm.com>
Thu, 29 Nov 2018 17:12:22 +0000 (18:12 +0100)
committerIngo Molnar <mingo@kernel.org>
Fri, 30 Nov 2018 08:10:30 +0000 (09:10 +0100)
Reorganize the get_fdt() lookup loop, clearly showing that:

- Nothing is done for table entries that do not have fdt_guid
- Once an entry with fdt_guid is found, break out of the loop

No functional changes.

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Julien Thierry <julien.thierry@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arend van Spriel <arend.vanspriel@broadcom.com>
Cc: Bhupesh Sharma <bhsharma@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Eric Snowberg <eric.snowberg@oracle.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Jon Hunter <jonathanh@nvidia.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Nathan Chancellor <natechancellor@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Cc: Sedat Dilek <sedat.dilek@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: YiFei Zhu <zhuyifei1999@gmail.com>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20181129171230.18699-4-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
drivers/firmware/efi/libstub/fdt.c

index a3614f9..0dc7b49 100644 (file)
@@ -370,23 +370,24 @@ void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size)
 {
        efi_guid_t fdt_guid = DEVICE_TREE_GUID;
        efi_config_table_t *tables;
-       void *fdt;
        int i;
 
-       tables = (efi_config_table_t *) sys_table->tables;
-       fdt = NULL;
+       tables = (efi_config_table_t *)sys_table->tables;
 
        for (i = 0; i < sys_table->nr_tables; i++) {
-               if (efi_guidcmp(tables[i].guid, fdt_guid) == 0) {
-                       fdt = (void *) tables[i].table;
-                       if (fdt_check_header(fdt) != 0) {
-                               pr_efi_err(sys_table, "Invalid header detected on UEFI supplied FDT, ignoring ...\n");
-                               return NULL;
-                       }
-                       *fdt_size = fdt_totalsize(fdt);
-                       break;
+               void *fdt;
+
+               if (efi_guidcmp(tables[i].guid, fdt_guid) != 0)
+                       continue;
+
+               fdt = (void *)tables[i].table;
+               if (fdt_check_header(fdt) != 0) {
+                       pr_efi_err(sys_table, "Invalid header detected on UEFI supplied FDT, ignoring ...\n");
+                       return NULL;
                }
+               *fdt_size = fdt_totalsize(fdt);
+               return fdt;
        }
 
-       return fdt;
+       return NULL;
 }