* [PATCH v2 0/2] efi/fdt: get_fdt cleanups
@ 2018-10-29 10:15 Julien Thierry
2018-10-29 10:15 ` [PATCH v2 1/2] efi/fdt: Indentation fix Julien Thierry
2018-10-29 10:15 ` [PATCH v2 2/2] efi/fdt: Simplify get_fdt flow Julien Thierry
0 siblings, 2 replies; 5+ messages in thread
From: Julien Thierry @ 2018-10-29 10:15 UTC (permalink / raw)
To: linux-efi; +Cc: linux-kernel, ard.biesheuvel, joe, Julien Thierry
Hi,
Here are just some minor cleanups of get_fdt function.
Changes since v1:
- Add a set of brace for the for loop
- Reorganize code as suggested by Joe
[1] https://lkml.org/lkml/2018/10/1/465
Thanks,
Julien
-->
Julien Thierry (2):
efi/fdt: Indentation fix
efi/fdt: Simplify get_fdt flow
drivers/firmware/efi/libstub/fdt.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] efi/fdt: Indentation fix
2018-10-29 10:15 [PATCH v2 0/2] efi/fdt: get_fdt cleanups Julien Thierry
@ 2018-10-29 10:15 ` Julien Thierry
2018-11-05 12:37 ` Ard Biesheuvel
2018-10-29 10:15 ` [PATCH v2 2/2] efi/fdt: Simplify get_fdt flow Julien Thierry
1 sibling, 1 reply; 5+ messages in thread
From: Julien Thierry @ 2018-10-29 10:15 UTC (permalink / raw)
To: linux-efi; +Cc: linux-kernel, ard.biesheuvel, joe, Julien Thierry
Closing bracket seems to end a for statement when it is actually ending
the contained if. Add some brackets to have clear delimitation of each
scope.
No functional change/fix, just fix the indentation.
Signed-off-by: Julien Thierry <julien.thierry@arm.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
drivers/firmware/efi/libstub/fdt.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c
index 8830fa6..8b6696e 100644
--- a/drivers/firmware/efi/libstub/fdt.c
+++ b/drivers/firmware/efi/libstub/fdt.c
@@ -372,7 +372,7 @@ void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size)
tables = (efi_config_table_t *) sys_table->tables;
fdt = NULL;
- for (i = 0; i < sys_table->nr_tables; i++)
+ 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) {
@@ -381,7 +381,8 @@ void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size)
}
*fdt_size = fdt_totalsize(fdt);
break;
- }
+ }
+ }
return fdt;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] efi/fdt: Simplify get_fdt flow
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-10-29 10:15 ` Julien Thierry
2018-11-05 12:41 ` Ard Biesheuvel
1 sibling, 1 reply; 5+ messages in thread
From: Julien Thierry @ 2018-10-29 10:15 UTC (permalink / raw)
To: linux-efi; +Cc: linux-kernel, ard.biesheuvel, joe, Julien Thierry
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] efi/fdt: Indentation fix
2018-10-29 10:15 ` [PATCH v2 1/2] efi/fdt: Indentation fix Julien Thierry
@ 2018-11-05 12:37 ` Ard Biesheuvel
0 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2018-11-05 12:37 UTC (permalink / raw)
To: Julien Thierry; +Cc: linux-efi, Linux Kernel Mailing List, Joe Perches
On 29 October 2018 at 11:15, Julien Thierry <julien.thierry@arm.com> wrote:
> Closing bracket seems to end a for statement when it is actually ending
> the contained if. Add some brackets to have clear delimitation of each
> scope.
>
> No functional change/fix, just fix the indentation.
>
> Signed-off-by: Julien Thierry <julien.thierry@arm.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> drivers/firmware/efi/libstub/fdt.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c
> index 8830fa6..8b6696e 100644
> --- a/drivers/firmware/efi/libstub/fdt.c
> +++ b/drivers/firmware/efi/libstub/fdt.c
> @@ -372,7 +372,7 @@ void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size)
> tables = (efi_config_table_t *) sys_table->tables;
> fdt = NULL;
>
> - for (i = 0; i < sys_table->nr_tables; i++)
> + 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) {
> @@ -381,7 +381,8 @@ void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size)
> }
> *fdt_size = fdt_totalsize(fdt);
> break;
> - }
> + }
> + }
>
> return fdt;
> }
> --
> 1.9.1
>
Queued in efi/next
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] efi/fdt: Simplify get_fdt flow
2018-10-29 10:15 ` [PATCH v2 2/2] efi/fdt: Simplify get_fdt flow Julien Thierry
@ 2018-11-05 12:41 ` Ard Biesheuvel
0 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2018-11-05 12:41 UTC (permalink / raw)
To: Julien Thierry; +Cc: linux-efi, Linux Kernel Mailing List, Joe Perches
On 29 October 2018 at 11:15, Julien Thierry <julien.thierry@arm.com> wrote:
> 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
>
Queued in efi/next
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-11-05 12:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v2 2/2] efi/fdt: Simplify get_fdt flow Julien Thierry
2018-11-05 12:41 ` Ard Biesheuvel
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).