[U-Boot] [PATCH 2/5] x86: Forward declare gd_t

Simon Glass sjg at chromium.org
Wed Nov 28 02:38:35 CET 2012


From: Graeme Russ <graeme.russ at gmail.com>

So it can be used as a type in struct global_data and remove an ugly typecast

Signed-off-by: Graeme Russ <graeme.russ at gmail.com>
Signed-off-by: Simon Glass <sjg at chromium.org>
Acked-by: Marek Vasut <marex at denx.de>
---
 arch/x86/cpu/cpu.c                 |    2 +-
 arch/x86/include/asm/global_data.h |    4 +++-
 arch/x86/lib/init_helpers.c        |    2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c
index e9bb0d7..67de6bc 100644
--- a/arch/x86/cpu/cpu.c
+++ b/arch/x86/cpu/cpu.c
@@ -92,7 +92,7 @@ static void load_gdt(const u64 *boot_gdt, u16 num_entries)
 
 void init_gd(gd_t *id, u64 *gdt_addr)
 {
-	id->gd_addr = (ulong)id;
+	id->gd_addr = id;
 	setup_gdt(id, gdt_addr);
 }
 
diff --git a/arch/x86/include/asm/global_data.h b/arch/x86/include/asm/global_data.h
index bce999f..d471367 100644
--- a/arch/x86/include/asm/global_data.h
+++ b/arch/x86/include/asm/global_data.h
@@ -33,9 +33,11 @@
 
 #ifndef __ASSEMBLY__
 
+typedef struct global_data gd_t;
+
 typedef	struct global_data {
 	/* NOTE: gd_addr MUST be first member of struct global_data! */
-	unsigned long	gd_addr;	/* Location of Global Data */
+	gd_t *gd_addr;	/* Location of Global Data */
 	bd_t		*bd;
 	unsigned long	flags;
 	unsigned int	baudrate;
diff --git a/arch/x86/lib/init_helpers.c b/arch/x86/lib/init_helpers.c
index 9ec34ff..2f718d7 100644
--- a/arch/x86/lib/init_helpers.c
+++ b/arch/x86/lib/init_helpers.c
@@ -126,7 +126,7 @@ int copy_gd_to_ram_f_r(void)
 	 * in-RAM copy of Global Data (calculate_relocation_address()
 	 * has already calculated the in-RAM location of the GDT)
 	 */
-	ram_gd->gd_addr = (ulong)ram_gd;
+	ram_gd->gd_addr = ram_gd;
 	init_gd(ram_gd, (u64 *)gd->gdt_addr);
 
 	return 0;
-- 
1.7.7.3



More information about the U-Boot mailing list