Re: [U-Boot] [PATCH] x86: Simplify the fsp hob access functions

2014-12-31 Thread Simon Glass
On 31 December 2014 at 01:22, Bin Meng  wrote:
> Hi Simon,
>
> On Wed, Dec 31, 2014 at 7:02 AM, Simon Glass  wrote:
>> Hi Bin,
>>
>> On 30 December 2014 at 01:02, Bin Meng  wrote:
>>> Remove the troublesome union hob_pointers so that some annoying casts
>>> are no longer needed in those hob access routines. This also improves
>>> the readability.
>>>
>>> Signed-off-by: Bin Meng 
>>> ---
>>>
>>>  arch/x86/cpu/queensbay/fsp_support.c   | 95 
>>> --
>>>  arch/x86/cpu/queensbay/tnc_dram.c  | 39 +
>>>  arch/x86/include/asm/arch-queensbay/fsp/fsp_hob.h  | 46 ---
>>>  .../include/asm/arch-queensbay/fsp/fsp_support.h   |  5 +-
>>>  arch/x86/lib/cmd_hob.c | 16 ++--
>>>  5 files changed, 101 insertions(+), 100 deletions(-)
>>>
>>
>> Yes a big improvement - see a few additional ideas for a follow-on patch 
>> below.
>>
>> Acked-by: Simon Glass 

Applied to u-boot-x86/next, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] x86: Simplify the fsp hob access functions

2014-12-31 Thread Bin Meng
Hi Simon,

On Wed, Dec 31, 2014 at 7:02 AM, Simon Glass  wrote:
> Hi Bin,
>
> On 30 December 2014 at 01:02, Bin Meng  wrote:
>> Remove the troublesome union hob_pointers so that some annoying casts
>> are no longer needed in those hob access routines. This also improves
>> the readability.
>>
>> Signed-off-by: Bin Meng 
>> ---
>>
>>  arch/x86/cpu/queensbay/fsp_support.c   | 95 
>> --
>>  arch/x86/cpu/queensbay/tnc_dram.c  | 39 +
>>  arch/x86/include/asm/arch-queensbay/fsp/fsp_hob.h  | 46 ---
>>  .../include/asm/arch-queensbay/fsp/fsp_support.h   |  5 +-
>>  arch/x86/lib/cmd_hob.c | 16 ++--
>>  5 files changed, 101 insertions(+), 100 deletions(-)
>>
>
> Yes a big improvement - see a few additional ideas for a follow-on patch 
> below.
>
> Acked-by: Simon Glass 
>
>> diff --git a/arch/x86/cpu/queensbay/fsp_support.c 
>> b/arch/x86/cpu/queensbay/fsp_support.c
>> index ef1916b..4764e3c 100644
>> --- a/arch/x86/cpu/queensbay/fsp_support.c
>> +++ b/arch/x86/cpu/queensbay/fsp_support.c
>> @@ -231,26 +231,28 @@ u32 fsp_notify(struct fsp_header *fsp_hdr, u32 phase)
>>
>>  u32 fsp_get_usable_lowmem_top(const void *hob_list)
>>  {
>> -   union hob_pointers hob;
>> +   const struct hob_header *hdr;
>> +   struct hob_res_desc *res_desc;
>> phys_addr_t phys_start;
>> u32 top;
>>
>> /* Get the HOB list for processing */
>> -   hob.raw = (void *)hob_list;
>> +   hdr = hob_list;
>>
>> /* * Collect memory ranges */
>> top = FSP_LOWMEM_BASE;
>> -   while (!end_of_hob(hob)) {
>> -   if (get_hob_type(hob) == HOB_TYPE_RES_DESC) {
>> -   if (hob.res_desc->type == RES_SYS_MEM) {
>> -   phys_start = hob.res_desc->phys_start;
>> +   while (!end_of_hob(hdr)) {
>> +   if (get_hob_type(hdr) == HOB_TYPE_RES_DESC) {
>> +   res_desc = (struct hob_res_desc *)hdr;
>> +   if (res_desc->type == RES_SYS_MEM) {
>> +   phys_start = res_desc->phys_start;
>> /* Need memory above 1MB to be collected 
>> here */
>> if (phys_start >= FSP_LOWMEM_BASE &&
>> phys_start < 
>> (phys_addr_t)FSP_HIGHMEM_BASE)
>> -   top += (u32)(hob.res_desc->len);
>> +   top += (u32)(res_desc->len);
>> }
>> }
>> -   hob.raw = get_next_hob(hob);
>> +   hdr = get_next_hob(hdr);
>> }
>>
>> return top;
>> @@ -258,25 +260,27 @@ u32 fsp_get_usable_lowmem_top(const void *hob_list)
>>
>>  u64 fsp_get_usable_highmem_top(const void *hob_list)
>>  {
>> -   union hob_pointers hob;
>> +   const struct hob_header *hdr;
>> +   struct hob_res_desc *res_desc;
>> phys_addr_t phys_start;
>> u64 top;
>>
>> /* Get the HOB list for processing */
>> -   hob.raw = (void *)hob_list;
>> +   hdr = hob_list;
>>
>> /* Collect memory ranges */
>> top = FSP_HIGHMEM_BASE;
>> -   while (!end_of_hob(hob)) {
>> -   if (get_hob_type(hob) == HOB_TYPE_RES_DESC) {
>> -   if (hob.res_desc->type == RES_SYS_MEM) {
>> -   phys_start = hob.res_desc->phys_start;
>> +   while (!end_of_hob(hdr)) {
>> +   if (get_hob_type(hdr) == HOB_TYPE_RES_DESC) {
>> +   res_desc = (struct hob_res_desc *)hdr;
>> +   if (res_desc->type == RES_SYS_MEM) {
>> +   phys_start = res_desc->phys_start;
>> /* Need memory above 1MB to be collected 
>> here */
>> if (phys_start >= 
>> (phys_addr_t)FSP_HIGHMEM_BASE)
>> -   top += (u32)(hob.res_desc->len);
>> +   top += (u32)(res_desc->len);
>> }
>> }
>> -   hob.raw = get_next_hob(hob);
>> +   hdr = get_next_hob(hdr);
>> }
>>
>> return top;
>> @@ -285,24 +289,26 @@ u64 fsp_get_usable_highmem_top(const void *hob_list)
>>  u64 fsp_get_reserved_mem_from_guid(const void *hob_list, u64 *len,
>>struct efi_guid *guid)
>>  {
>> -   union hob_pointers hob;
>> +   const struct hob_header *hdr;
>> +   struct hob_res_desc *res_desc;
>>
>> /* Get the HOB list for processing */
>> -   hob.raw = (void *)hob_list;
>> +   hdr = hob_list;
>>
>> /* Collect memory ranges */
>> -   while (!end_of_hob(hob)) {
>> -   if (get_hob_type(hob) == HOB_TYPE_RES_DESC) {
>> -   if (hob.res_desc->type == RES_MEM_RESERVED) {
>> -   if (com

Re: [U-Boot] [PATCH] x86: Simplify the fsp hob access functions

2014-12-30 Thread Simon Glass
Hi Bin,

On 30 December 2014 at 01:02, Bin Meng  wrote:
> Remove the troublesome union hob_pointers so that some annoying casts
> are no longer needed in those hob access routines. This also improves
> the readability.
>
> Signed-off-by: Bin Meng 
> ---
>
>  arch/x86/cpu/queensbay/fsp_support.c   | 95 
> --
>  arch/x86/cpu/queensbay/tnc_dram.c  | 39 +
>  arch/x86/include/asm/arch-queensbay/fsp/fsp_hob.h  | 46 ---
>  .../include/asm/arch-queensbay/fsp/fsp_support.h   |  5 +-
>  arch/x86/lib/cmd_hob.c | 16 ++--
>  5 files changed, 101 insertions(+), 100 deletions(-)
>

Yes a big improvement - see a few additional ideas for a follow-on patch below.

Acked-by: Simon Glass 

> diff --git a/arch/x86/cpu/queensbay/fsp_support.c 
> b/arch/x86/cpu/queensbay/fsp_support.c
> index ef1916b..4764e3c 100644
> --- a/arch/x86/cpu/queensbay/fsp_support.c
> +++ b/arch/x86/cpu/queensbay/fsp_support.c
> @@ -231,26 +231,28 @@ u32 fsp_notify(struct fsp_header *fsp_hdr, u32 phase)
>
>  u32 fsp_get_usable_lowmem_top(const void *hob_list)
>  {
> -   union hob_pointers hob;
> +   const struct hob_header *hdr;
> +   struct hob_res_desc *res_desc;
> phys_addr_t phys_start;
> u32 top;
>
> /* Get the HOB list for processing */
> -   hob.raw = (void *)hob_list;
> +   hdr = hob_list;
>
> /* * Collect memory ranges */
> top = FSP_LOWMEM_BASE;
> -   while (!end_of_hob(hob)) {
> -   if (get_hob_type(hob) == HOB_TYPE_RES_DESC) {
> -   if (hob.res_desc->type == RES_SYS_MEM) {
> -   phys_start = hob.res_desc->phys_start;
> +   while (!end_of_hob(hdr)) {
> +   if (get_hob_type(hdr) == HOB_TYPE_RES_DESC) {
> +   res_desc = (struct hob_res_desc *)hdr;
> +   if (res_desc->type == RES_SYS_MEM) {
> +   phys_start = res_desc->phys_start;
> /* Need memory above 1MB to be collected here 
> */
> if (phys_start >= FSP_LOWMEM_BASE &&
> phys_start < 
> (phys_addr_t)FSP_HIGHMEM_BASE)
> -   top += (u32)(hob.res_desc->len);
> +   top += (u32)(res_desc->len);
> }
> }
> -   hob.raw = get_next_hob(hob);
> +   hdr = get_next_hob(hdr);
> }
>
> return top;
> @@ -258,25 +260,27 @@ u32 fsp_get_usable_lowmem_top(const void *hob_list)
>
>  u64 fsp_get_usable_highmem_top(const void *hob_list)
>  {
> -   union hob_pointers hob;
> +   const struct hob_header *hdr;
> +   struct hob_res_desc *res_desc;
> phys_addr_t phys_start;
> u64 top;
>
> /* Get the HOB list for processing */
> -   hob.raw = (void *)hob_list;
> +   hdr = hob_list;
>
> /* Collect memory ranges */
> top = FSP_HIGHMEM_BASE;
> -   while (!end_of_hob(hob)) {
> -   if (get_hob_type(hob) == HOB_TYPE_RES_DESC) {
> -   if (hob.res_desc->type == RES_SYS_MEM) {
> -   phys_start = hob.res_desc->phys_start;
> +   while (!end_of_hob(hdr)) {
> +   if (get_hob_type(hdr) == HOB_TYPE_RES_DESC) {
> +   res_desc = (struct hob_res_desc *)hdr;
> +   if (res_desc->type == RES_SYS_MEM) {
> +   phys_start = res_desc->phys_start;
> /* Need memory above 1MB to be collected here 
> */
> if (phys_start >= 
> (phys_addr_t)FSP_HIGHMEM_BASE)
> -   top += (u32)(hob.res_desc->len);
> +   top += (u32)(res_desc->len);
> }
> }
> -   hob.raw = get_next_hob(hob);
> +   hdr = get_next_hob(hdr);
> }
>
> return top;
> @@ -285,24 +289,26 @@ u64 fsp_get_usable_highmem_top(const void *hob_list)
>  u64 fsp_get_reserved_mem_from_guid(const void *hob_list, u64 *len,
>struct efi_guid *guid)
>  {
> -   union hob_pointers hob;
> +   const struct hob_header *hdr;
> +   struct hob_res_desc *res_desc;
>
> /* Get the HOB list for processing */
> -   hob.raw = (void *)hob_list;
> +   hdr = hob_list;
>
> /* Collect memory ranges */
> -   while (!end_of_hob(hob)) {
> -   if (get_hob_type(hob) == HOB_TYPE_RES_DESC) {
> -   if (hob.res_desc->type == RES_MEM_RESERVED) {
> -   if (compare_guid(&hob.res_desc->owner, guid)) 
> {
> +   while (!end_of_hob(hdr)) {
> +   if (get_hob_type(hdr) == HOB_TYPE_RES_DESC) {
> +   res_desc = (struct hob

[U-Boot] [PATCH] x86: Simplify the fsp hob access functions

2014-12-30 Thread Bin Meng
Remove the troublesome union hob_pointers so that some annoying casts
are no longer needed in those hob access routines. This also improves
the readability.

Signed-off-by: Bin Meng 
---

 arch/x86/cpu/queensbay/fsp_support.c   | 95 --
 arch/x86/cpu/queensbay/tnc_dram.c  | 39 +
 arch/x86/include/asm/arch-queensbay/fsp/fsp_hob.h  | 46 ---
 .../include/asm/arch-queensbay/fsp/fsp_support.h   |  5 +-
 arch/x86/lib/cmd_hob.c | 16 ++--
 5 files changed, 101 insertions(+), 100 deletions(-)

diff --git a/arch/x86/cpu/queensbay/fsp_support.c 
b/arch/x86/cpu/queensbay/fsp_support.c
index ef1916b..4764e3c 100644
--- a/arch/x86/cpu/queensbay/fsp_support.c
+++ b/arch/x86/cpu/queensbay/fsp_support.c
@@ -231,26 +231,28 @@ u32 fsp_notify(struct fsp_header *fsp_hdr, u32 phase)
 
 u32 fsp_get_usable_lowmem_top(const void *hob_list)
 {
-   union hob_pointers hob;
+   const struct hob_header *hdr;
+   struct hob_res_desc *res_desc;
phys_addr_t phys_start;
u32 top;
 
/* Get the HOB list for processing */
-   hob.raw = (void *)hob_list;
+   hdr = hob_list;
 
/* * Collect memory ranges */
top = FSP_LOWMEM_BASE;
-   while (!end_of_hob(hob)) {
-   if (get_hob_type(hob) == HOB_TYPE_RES_DESC) {
-   if (hob.res_desc->type == RES_SYS_MEM) {
-   phys_start = hob.res_desc->phys_start;
+   while (!end_of_hob(hdr)) {
+   if (get_hob_type(hdr) == HOB_TYPE_RES_DESC) {
+   res_desc = (struct hob_res_desc *)hdr;
+   if (res_desc->type == RES_SYS_MEM) {
+   phys_start = res_desc->phys_start;
/* Need memory above 1MB to be collected here */
if (phys_start >= FSP_LOWMEM_BASE &&
phys_start < (phys_addr_t)FSP_HIGHMEM_BASE)
-   top += (u32)(hob.res_desc->len);
+   top += (u32)(res_desc->len);
}
}
-   hob.raw = get_next_hob(hob);
+   hdr = get_next_hob(hdr);
}
 
return top;
@@ -258,25 +260,27 @@ u32 fsp_get_usable_lowmem_top(const void *hob_list)
 
 u64 fsp_get_usable_highmem_top(const void *hob_list)
 {
-   union hob_pointers hob;
+   const struct hob_header *hdr;
+   struct hob_res_desc *res_desc;
phys_addr_t phys_start;
u64 top;
 
/* Get the HOB list for processing */
-   hob.raw = (void *)hob_list;
+   hdr = hob_list;
 
/* Collect memory ranges */
top = FSP_HIGHMEM_BASE;
-   while (!end_of_hob(hob)) {
-   if (get_hob_type(hob) == HOB_TYPE_RES_DESC) {
-   if (hob.res_desc->type == RES_SYS_MEM) {
-   phys_start = hob.res_desc->phys_start;
+   while (!end_of_hob(hdr)) {
+   if (get_hob_type(hdr) == HOB_TYPE_RES_DESC) {
+   res_desc = (struct hob_res_desc *)hdr;
+   if (res_desc->type == RES_SYS_MEM) {
+   phys_start = res_desc->phys_start;
/* Need memory above 1MB to be collected here */
if (phys_start >= (phys_addr_t)FSP_HIGHMEM_BASE)
-   top += (u32)(hob.res_desc->len);
+   top += (u32)(res_desc->len);
}
}
-   hob.raw = get_next_hob(hob);
+   hdr = get_next_hob(hdr);
}
 
return top;
@@ -285,24 +289,26 @@ u64 fsp_get_usable_highmem_top(const void *hob_list)
 u64 fsp_get_reserved_mem_from_guid(const void *hob_list, u64 *len,
   struct efi_guid *guid)
 {
-   union hob_pointers hob;
+   const struct hob_header *hdr;
+   struct hob_res_desc *res_desc;
 
/* Get the HOB list for processing */
-   hob.raw = (void *)hob_list;
+   hdr = hob_list;
 
/* Collect memory ranges */
-   while (!end_of_hob(hob)) {
-   if (get_hob_type(hob) == HOB_TYPE_RES_DESC) {
-   if (hob.res_desc->type == RES_MEM_RESERVED) {
-   if (compare_guid(&hob.res_desc->owner, guid)) {
+   while (!end_of_hob(hdr)) {
+   if (get_hob_type(hdr) == HOB_TYPE_RES_DESC) {
+   res_desc = (struct hob_res_desc *)hdr;
+   if (res_desc->type == RES_MEM_RESERVED) {
+   if (compare_guid(&res_desc->owner, guid)) {
if (len)
-   *len = (u32)(hob.res_desc->len);
+   *len = (u32)(res_desc->len);
 
-