Skip to content

Commit 971d38b

Browse files
Julien ThierryArd Biesheuvel
authored andcommitted
efi/fdt: Simplify get_fdt flow
Reorganize 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>
1 parent d2a586f commit 971d38b

File tree

1 file changed

+13
-12
lines changed
  • drivers/firmware/efi/libstub

1 file changed

+13
-12
lines changed

drivers/firmware/efi/libstub/fdt.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -370,23 +370,24 @@ void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size)
370370
{
371371
efi_guid_t fdt_guid = DEVICE_TREE_GUID;
372372
efi_config_table_t *tables;
373-
void *fdt;
374373
int i;
375374

376-
tables = (efi_config_table_t *) sys_table->tables;
377-
fdt = NULL;
375+
tables = (efi_config_table_t *)sys_table->tables;
378376

379377
for (i = 0; i < sys_table->nr_tables; i++) {
380-
if (efi_guidcmp(tables[i].guid, fdt_guid) == 0) {
381-
fdt = (void *) tables[i].table;
382-
if (fdt_check_header(fdt) != 0) {
383-
pr_efi_err(sys_table, "Invalid header detected on UEFI supplied FDT, ignoring ...\n");
384-
return NULL;
385-
}
386-
*fdt_size = fdt_totalsize(fdt);
387-
break;
378+
void *fdt;
379+
380+
if (efi_guidcmp(tables[i].guid, fdt_guid) != 0)
381+
continue;
382+
383+
fdt = (void *)tables[i].table;
384+
if (fdt_check_header(fdt) != 0) {
385+
pr_efi_err(sys_table, "Invalid header detected on UEFI supplied FDT, ignoring ...\n");
386+
return NULL;
388387
}
388+
*fdt_size = fdt_totalsize(fdt);
389+
return fdt;
389390
}
390391

391-
return fdt;
392+
return NULL;
392393
}

0 commit comments

Comments
 (0)