From: Julien Thierry <julien.thierry@arm.com>
To: linux-efi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, ard.biesheuvel@linaro.org,
joe@perches.com, Julien Thierry <julien.thierry@arm.com>
Subject: [PATCH v2 2/2] efi/fdt: Simplify get_fdt flow
Date: Mon, 29 Oct 2018 10:15:42 +0000 [thread overview]
Message-ID: <1540808142-33208-3-git-send-email-julien.thierry@arm.com> (raw)
In-Reply-To: <1540808142-33208-1-git-send-email-julien.thierry@arm.com>
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.
Signed-off-by: Julien Thierry <julien.thierry@arm.com>
Suggested-by: Joe Perches <joe@perches.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
drivers/firmware/efi/libstub/fdt.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c
index 8b6696e..5b7e2b3 100644
--- a/drivers/firmware/efi/libstub/fdt.c
+++ b/drivers/firmware/efi/libstub/fdt.c
@@ -366,23 +366,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;
}
--
1.9.1
next prev parent reply other threads:[~2018-10-29 10:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-29 10:15 [PATCH v2 0/2] efi/fdt: get_fdt cleanups Julien Thierry
2018-10-29 10:15 ` [PATCH v2 1/2] efi/fdt: Indentation fix Julien Thierry
2018-11-05 12:37 ` Ard Biesheuvel
2018-10-29 10:15 ` Julien Thierry [this message]
2018-11-05 12:41 ` [PATCH v2 2/2] efi/fdt: Simplify get_fdt flow Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1540808142-33208-3-git-send-email-julien.thierry@arm.com \
--to=julien.thierry@arm.com \
--cc=ard.biesheuvel@linaro.org \
--cc=joe@perches.com \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).