Skip to contentSkip to conversation

AT91: factor out ROUND() macro

PATCH New Wolfgang Denk 2 participants 5 messages Jul 17, 2009 – Jul 26, 2009 Arm/Microchip (AT91) SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 AT91: factor out ROUND() macro

A large number of boards (all AT91 based) duplicated the ROUND() macro in their board specific config files. Add the definition to include/common.h and clean up the board config files.

---
 include/common.h                   |    1 +
 include/configs/afeb9260.h         |    1 -
 include/configs/at91cap9adk.h      |    1 -
 include/configs/at91rm9200ek.h     |    1 -
 include/configs/at91sam9260ek.h    |    1 -
 include/configs/at91sam9261ek.h    |    1 -
 include/configs/at91sam9263ek.h    |    1 -
 include/configs/at91sam9m10g45ek.h |    1 -
 include/configs/at91sam9rlek.h     |    1 -
 include/configs/pm9261.h           |    1 -
 include/configs/pm9263.h           |    1 -
 11 files changed, 1 insertions(+), 10 deletions(-)
include/common.h +1 -0
index a6c7c07..6e689b2 100644
@@ -697,6 +697,7 @@ void show_boot_progress(int val);
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
+#define ROUND(a,b)		(((a) + (b)) & ~((b) - 1))
 #define DIV_ROUND(n,d)		(((n) + ((d)/2)) / (d))
 #define DIV_ROUND_UP(n,d)	(((n) + (d) - 1) / (d))
 #define roundup(x, y)		((((x) + ((y) - 1)) / (y)) * (y))
include/configs/afeb9260.h +0 -1
index c5134a2..22099c8 100644
@@ -159,7 +159,6 @@
 #define CONFIG_SYS_LONGHELP		1
 #define CONFIG_CMDLINE_EDITING	1
 
-#define ROUND(A, B)		(((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
include/configs/at91cap9adk.h +0 -1
index 526cd60..f977527 100644
@@ -201,7 +201,6 @@
 #define CONFIG_SYS_LONGHELP		1
 #define CONFIG_CMDLINE_EDITING	1
 
-#define ROUND(A, B)		(((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
include/configs/at91rm9200ek.h +0 -1
index c898c73..58ec94a 100644
@@ -311,7 +311,6 @@ struct bd_info_ext {
  */
 #define CONFIG_SYS_HZ_CLOCK (AT91C_MASTER_CLOCK / 2)
 
-#define ROUND(A, B)		(((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
include/configs/at91sam9260ek.h +0 -1
index 1828c63..dd886d8 100644
@@ -205,7 +205,6 @@
 #define CONFIG_SYS_LONGHELP		1
 #define CONFIG_CMDLINE_EDITING	1
 
-#define ROUND(A, B)		(((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
include/configs/at91sam9261ek.h +0 -1
index 6d24023..cb0384a 100644
@@ -223,7 +223,6 @@
 #define CONFIG_SYS_LONGHELP		1
 #define CONFIG_CMDLINE_EDITING	1
 
-#define ROUND(A, B)		(((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
include/configs/at91sam9263ek.h +0 -1
index 00f3114..2bd2915 100644
@@ -333,7 +333,6 @@
 #define CONFIG_SYS_HUSH_PARSER
 #define CONFIG_SYS_PROMPT_HUSH_PS2	"> "
 
-#define ROUND(A, B)		(((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
include/configs/at91sam9m10g45ek.h +0 -1
index 572c45b..8f86839 100644
@@ -209,7 +209,6 @@
 #define CONFIG_SYS_HUSH_PARSER
 #define CONFIG_SYS_PROMPT_HUSH_PS2	"> "
 
-#define ROUND(A, B)		(((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
include/configs/at91sam9rlek.h +0 -1
index c466823..64a9951 100644
@@ -168,7 +168,6 @@
 #define CONFIG_SYS_LONGHELP		1
 #define CONFIG_CMDLINE_EDITING	1
 
-#define ROUND(A, B)		(((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
include/configs/pm9261.h +0 -1
index 4784c40..3307a94 100644
@@ -366,7 +366,6 @@
 #define CONFIG_SYS_LONGHELP		1
 #define CONFIG_CMDLINE_EDITING	1
 
-#define ROUND(A, B)		(((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
include/configs/pm9263.h +0 -1
index 94e1eb9..a197061 100644
@@ -395,7 +395,6 @@
 #define CONFIG_SYS_LONGHELP		1
 #define CONFIG_CMDLINE_EDITING		1
 
-#define ROUND(A, B)			(((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
Signature · 1 line
1.6.0.6
#1 lore raw

PATCH 1/1 AT91: factor out ROUND() macro

Quoted 5 lines · Wolfgang Denk

A large number of boards (all AT91 based) duplicated the ROUND() macro in their board specific config files. Add the definition to include/common.h and clean up the board config files.

build failled
as we do not include common.h but config.h it in the cpu/arm926ejs/start.S

Best Regards,
J.

#2 lore raw

PATCH 1/1 AT91: factor out ROUND() macro

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 5 lines · Wolfgang Denk

A large number of boards (all AT91 based) duplicated the ROUND() macro in their board specific config files. Add the definition to include/common.h and clean up the board config files.

build failled
as we do not include common.h but config.h it in the cpu/arm926ejs/start.S

Yeah, this escaped my testing. But it's already in mainline, so we need a fix for it.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
All these theories, diverse as they are, have two things  in  common:
they explain the observed facts, and they are completeley and utterly
wrong.                       - Terry Pratchett, _The Light Fantastic_
#3 lore raw

PATCH 1/1 Make include/common.h usable by assembler code

Commit 70ebf316 factored out the ROUND() macro into include/common.h, not realizing that the primary use of this macro on AT91 systems was in start.S where common.h was not included, and could not be included because it contains a lot of C code which the assembler doesn't understand.

This patch wraps such code in common.h in a "#ifndef __ASSEMBLY__" construct, and then adds an include to cpu/arm926ejs/start.S thus solving the problem.

---
 cpu/arm926ejs/start.S |    1 +
 include/common.h      |   37 ++++++++++++++++++++-----------------
 2 files changed, 21 insertions(+), 17 deletions(-)
cpu/arm926ejs/start.S +1 -0
index 0275b66..8043322 100644
@@ -32,6 +32,7 @@
 
 
 #include <config.h>
+#include <common.h>
 #include <version.h>
 
 #if defined(CONFIG_OMAP1610)
include/common.h +20 -17
index 6e689b2..ee174bb 100644
@@ -27,6 +27,8 @@
 #undef	_LINUX_CONFIG_H
 #define _LINUX_CONFIG_H 1	/* avoid reading Linux autoconf.h file	*/
 
+#ifndef __ASSEMBLY__		/* put C only stuff in this section */
+
 typedef unsigned char		uchar;
 typedef volatile unsigned long	vu_long;
 typedef volatile unsigned short vu_short;
@@ -105,6 +107,9 @@ typedef volatile unsigned char	vu_char;
 #ifdef CONFIG_BLACKFIN
 #include <asm/blackfin.h>
 #endif
+#ifdef CONFIG_STATUS_LED
+#include <status_led.h>
+#endif
 
 #include <part.h>
 #include <flash.h>
@@ -636,11 +641,9 @@ int	disable_ctrlc (int);	/* 1 to disable, 0 to enable Control-C detect */
 /*
  * STDIO based functions (can always be used)
  */
-
 /* serial stuff */
 void	serial_printf (const char *fmt, ...)
 		__attribute__ ((format (__printf__, 1, 2)));
-
 /* stdin */
 int	getc(void);
 int	tstc(void);
@@ -660,7 +663,6 @@ void	vprintf(const char *fmt, va_list args);
 /*
  * FILE based functions (can only be used AFTER relocation!)
  */
-
 #define stdin		0
 #define stdout		1
 #define stderr		2
@@ -682,14 +684,26 @@ int	fgetc(int file);
 
 int	pcmcia_init (void);
 
-#ifdef CONFIG_STATUS_LED
-# include <status_led.h>
-#endif
 /*
  * Board-specific Platform code can reimplement show_boot_progress () if needed
  */
 void show_boot_progress(int val);
 
+/* Multicore arch functions */
+#ifdef CONFIG_MP
+int cpu_status(int nr);
+int cpu_reset(int nr);
+int cpu_release(int nr, int argc, char *argv[]);
+#endif
+
+#endif /* __ASSEMBLY__ */
+
+/* Put only stuff here that the assembler can digest */
+
+#ifdef CONFIG_POST
+#define CONFIG_HAS_POST
+#endif
+
 #ifdef CONFIG_INIT_CRITICAL
 #error CONFIG_INIT_CRITICAL is deprecated!
 #error Read section CONFIG_SKIP_LOWLEVEL_INIT in README.
@@ -705,15 +719,4 @@ void show_boot_progress(int val);
 #define ALIGN(x,a)		__ALIGN_MASK((x),(typeof(x))(a)-1)
 #define __ALIGN_MASK(x,mask)	(((x)+(mask))&~(mask))
 
-/* Multicore arch functions */
-#ifdef CONFIG_MP
-int cpu_status(int nr);
-int cpu_reset(int nr);
-int cpu_release(int nr, int argc, char *argv[]);
-#endif
-
-#ifdef CONFIG_POST
-#define CONFIG_HAS_POST
-#endif
-
 #endif	/* __COMMON_H_ */
Signature · 1 line
1.6.0.6
author Applied
#4 lore raw

PATCH 1/1 Make include/common.h usable by assembler code

Quoted 10 lines · In message <[email protected]> you wrote:

Commit 70ebf316 factored out the ROUND() macro into include/common.h, not realizing that the primary use of this macro on AT91 systems was in start.S where common.h was not included, and could not be included because it contains a lot of C code which the assembler doesn't understand.

This patch wraps such code in common.h in a "#ifndef __ASSEMBLY__" construct, and then adds an include to cpu/arm926ejs/start.S thus solving the problem.

Quoted 5 lines
---
 cpu/arm926ejs/start.S |    1 +
 include/common.h      |   37 ++++++++++++++++++++-----------------
 2 files changed, 21 insertions(+), 17 deletions(-)

Applied.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Einstein argued that there must be simplified explanations of nature,
because God is not capricious or arbitrary. No  such  faith  comforts
the software engineer.                             - Fred Brooks, Jr.