diff mbox series

[Xen-devel,7/8] xen/arm: efi: Rework acpi_create_efi_mmap_table to avoid memory_map[offset]

Message ID 1486149538-20432-14-git-send-email-julien.grall@arm.com
State Superseded
Headers show
Series None | expand

Commit Message

Julien Grall Feb. 3, 2017, 7:18 p.m. UTC
The code contains a lot of memory_map[offset]. This could be simplified
by incrementing the descriptor pointer every time.

Signed-off-by: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/efi/efi-dom0.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

Comments

Stefano Stabellini Feb. 16, 2017, 1:57 a.m. UTC | #1
On Fri, 3 Feb 2017, Julien Grall wrote:
> The code contains a lot of memory_map[offset]. This could be simplified
> by incrementing the descriptor pointer every time.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

> ---
>  xen/arch/arm/efi/efi-dom0.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/xen/arch/arm/efi/efi-dom0.c b/xen/arch/arm/efi/efi-dom0.c
> index f307f26..f0ceaa6 100644
> --- a/xen/arch/arm/efi/efi-dom0.c
> +++ b/xen/arch/arm/efi/efi-dom0.c
> @@ -112,25 +112,24 @@ void __init acpi_create_efi_mmap_table(struct domain *d,
>                                         const struct meminfo *mem,
>                                         struct membank tbl_add[])
>  {
> -    EFI_MEMORY_DESCRIPTOR *memory_map;
> -    unsigned int i, offset;
> +    EFI_MEMORY_DESCRIPTOR *desc;
> +    unsigned int i;
>      u8 *base_ptr;
>  
>      base_ptr = d->arch.efi_acpi_table
>                 + acpi_get_table_offset(tbl_add, TBL_MMAP);
> -    memory_map = (EFI_MEMORY_DESCRIPTOR *)base_ptr;
> +    desc = (EFI_MEMORY_DESCRIPTOR *)base_ptr;
>  
> -    offset = 0;
> -    for( i = 0; i < mem->nr_banks; i++, offset++ )
> -        fill_efi_memory_descriptor(&memory_map[offset], EfiConventionalMemory,
> +    for ( i = 0; i < mem->nr_banks; i++, desc++ )
> +        fill_efi_memory_descriptor(desc, EfiConventionalMemory,
>                                     mem->bank[i].start, mem->bank[i].size);
>  
> -    for( i = 0; i < acpi_mem.nr_banks; i++, offset++ )
> -        fill_efi_memory_descriptor(&memory_map[offset], EfiACPIReclaimMemory,
> +    for ( i = 0; i < acpi_mem.nr_banks; i++, desc++ )
> +        fill_efi_memory_descriptor(desc, EfiACPIReclaimMemory,
>                                     acpi_mem.bank[i].start,
>                                     acpi_mem.bank[i].size);
>  
> -    fill_efi_memory_descriptor(&memory_map[offset], EfiACPIReclaimMemory,
> +    fill_efi_memory_descriptor(desc, EfiACPIReclaimMemory,
>                                 d->arch.efi_acpi_gpa, d->arch.efi_acpi_len);
>  
>      tbl_add[TBL_MMAP].start = d->arch.efi_acpi_gpa
> -- 
> 1.9.1
>
diff mbox series

Patch

diff --git a/xen/arch/arm/efi/efi-dom0.c b/xen/arch/arm/efi/efi-dom0.c
index f307f26..f0ceaa6 100644
--- a/xen/arch/arm/efi/efi-dom0.c
+++ b/xen/arch/arm/efi/efi-dom0.c
@@ -112,25 +112,24 @@  void __init acpi_create_efi_mmap_table(struct domain *d,
                                        const struct meminfo *mem,
                                        struct membank tbl_add[])
 {
-    EFI_MEMORY_DESCRIPTOR *memory_map;
-    unsigned int i, offset;
+    EFI_MEMORY_DESCRIPTOR *desc;
+    unsigned int i;
     u8 *base_ptr;
 
     base_ptr = d->arch.efi_acpi_table
                + acpi_get_table_offset(tbl_add, TBL_MMAP);
-    memory_map = (EFI_MEMORY_DESCRIPTOR *)base_ptr;
+    desc = (EFI_MEMORY_DESCRIPTOR *)base_ptr;
 
-    offset = 0;
-    for( i = 0; i < mem->nr_banks; i++, offset++ )
-        fill_efi_memory_descriptor(&memory_map[offset], EfiConventionalMemory,
+    for ( i = 0; i < mem->nr_banks; i++, desc++ )
+        fill_efi_memory_descriptor(desc, EfiConventionalMemory,
                                    mem->bank[i].start, mem->bank[i].size);
 
-    for( i = 0; i < acpi_mem.nr_banks; i++, offset++ )
-        fill_efi_memory_descriptor(&memory_map[offset], EfiACPIReclaimMemory,
+    for ( i = 0; i < acpi_mem.nr_banks; i++, desc++ )
+        fill_efi_memory_descriptor(desc, EfiACPIReclaimMemory,
                                    acpi_mem.bank[i].start,
                                    acpi_mem.bank[i].size);
 
-    fill_efi_memory_descriptor(&memory_map[offset], EfiACPIReclaimMemory,
+    fill_efi_memory_descriptor(desc, EfiACPIReclaimMemory,
                                d->arch.efi_acpi_gpa, d->arch.efi_acpi_len);
 
     tbl_add[TBL_MMAP].start = d->arch.efi_acpi_gpa