public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] PPC4xx: Simplified post_word_{load,store}
@ 2008-05-21 18:24 Grant Erickson
  2008-05-21 19:29 ` [U-Boot-Users] [PATCH] PPC4xx: Simplified post_word_{load, store} Wolfgang Denk
  2008-05-21 19:43 ` [U-Boot-Users] [PATCH v2] " Grant Erickson
  0 siblings, 2 replies; 8+ messages in thread
From: Grant Erickson @ 2008-05-21 18:24 UTC (permalink / raw)
  To: u-boot

This patch simplifies post_word_{load,store} by using the preprocessor 
to eliminate redundant, copy-and-pasted code.

Signed-off-by: Grant Erickson <gerickson@nuovations.com>
---
 cpu/ppc4xx/commproc.c |   26 +++++++++++---------------
 1 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/cpu/ppc4xx/commproc.c b/cpu/ppc4xx/commproc.c
index 22156dd..7d5ef46 100644
--- a/cpu/ppc4xx/commproc.c
+++ b/cpu/ppc4xx/commproc.c
@@ -30,29 +30,25 @@
 
 #if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER)
 
-#if defined(CFG_POST_ALT_WORD_ADDR)
-void post_word_store (ulong a)
-{
-	out_be32((void *)CFG_POST_ALT_WORD_ADDR, a);
-}
+#if defined(CFG_POST_WORD_ADDR)
+# define _POST_ADDR	CFG_OCM_DATA_ADDR + CFG_POST_WORD_ADDR
+#elif defined(CFG_POST_ALT_WORD_ADDR)
+# define _POST_ADDR	CFG_POST_ALT_WORD_ADDR
+#endif
 
-ulong post_word_load (void)
-{
-	return in_be32((void *)CFG_POST_ALT_WORD_ADDR);
-}
-#else /* CFG_POST_ALT_WORD_ADDR */
 void post_word_store (ulong a)
 {
-	volatile void *save_addr = (volatile void *)(CFG_OCM_DATA_ADDR + CFG_POST_WORD_ADDR);
-	*(volatile ulong *) save_addr = a;
+	volatile void *save_addr = (volatile void *)(_POST_ADDR);
+
+	out_be32(save_addr, a);
 }
 
 ulong post_word_load (void)
 {
-	volatile void *save_addr = (volatile void *)(CFG_OCM_DATA_ADDR + CFG_POST_WORD_ADDR);
-	return *(volatile ulong *) save_addr;
+	volatile void *save_addr = (volatile void *)(_POST_ADDR);
+
+	return in_be32(save_addr);
 }
-#endif /* CFG_POST_ALT_WORD_ADDR */
 
 #endif	/* CONFIG_POST || CONFIG_LOGBUFFER*/
 
-- 
1.5.4.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot-Users] [PATCH] PPC4xx: Simplified post_word_{load, store}
  2008-05-21 18:24 [U-Boot-Users] [PATCH] PPC4xx: Simplified post_word_{load,store} Grant Erickson
@ 2008-05-21 19:29 ` Wolfgang Denk
  2008-05-21 19:43 ` [U-Boot-Users] [PATCH v2] " Grant Erickson
  1 sibling, 0 replies; 8+ messages in thread
From: Wolfgang Denk @ 2008-05-21 19:29 UTC (permalink / raw)
  To: u-boot

In message <1211394262-26658-1-git-send-email-gerickson@nuovations.com> you wrote:
> This patch simplifies post_word_{load,store} by using the preprocessor 
> to eliminate redundant, copy-and-pasted code.
...
> +#if defined(CFG_POST_WORD_ADDR)
> +# define _POST_ADDR	CFG_OCM_DATA_ADDR + CFG_POST_WORD_ADDR

Please make this

# define _POST_ADDR ((CFG_OCM_DATA_ADDR) + (CFG_POST_WORD_ADDR))

> +#elif defined(CFG_POST_ALT_WORD_ADDR)
> +# define _POST_ADDR	CFG_POST_ALT_WORD_ADDR

# define _POST_ADDR	(CFG_POST_ALT_WORD_ADDR)


Best regards,

Wolfgang Denk

-- 
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
If I don't document something, it's usually either for a good reason,
or a bad reason.  In this case it's a good reason.  :-)
                 - Larry Wall in <1992Jan17.005405.16806@netlabs.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot-Users] [PATCH v2] PPC4xx: Simplified post_word_{load, store}
  2008-05-21 18:24 [U-Boot-Users] [PATCH] PPC4xx: Simplified post_word_{load,store} Grant Erickson
  2008-05-21 19:29 ` [U-Boot-Users] [PATCH] PPC4xx: Simplified post_word_{load, store} Wolfgang Denk
@ 2008-05-21 19:43 ` Grant Erickson
  2008-05-21 20:17   ` Wolfgang Denk
  2008-05-21 20:28   ` [U-Boot-Users] [PATCH v3] " Grant Erickson
  1 sibling, 2 replies; 8+ messages in thread
From: Grant Erickson @ 2008-05-21 19:43 UTC (permalink / raw)
  To: u-boot

This patch simplifies post_word_{load,store} by using the preprocessor 
to eliminate redundant, copy-and-pasted code.

Signed-off-by: Grant Erickson <gerickson@nuovations.com>
---
 cpu/ppc4xx/commproc.c |   26 +++++++++++---------------
 1 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/cpu/ppc4xx/commproc.c b/cpu/ppc4xx/commproc.c
index 22156dd..a6940e2 100644
--- a/cpu/ppc4xx/commproc.c
+++ b/cpu/ppc4xx/commproc.c
@@ -30,29 +30,25 @@
 
 #if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER)
 
-#if defined(CFG_POST_ALT_WORD_ADDR)
-void post_word_store (ulong a)
-{
-	out_be32((void *)CFG_POST_ALT_WORD_ADDR, a);
-}
+#if defined(CFG_POST_WORD_ADDR)
+# define _POST_ADDR	(CFG_OCM_DATA_ADDR + CFG_POST_WORD_ADDR)
+#elif defined(CFG_POST_ALT_WORD_ADDR)
+# define _POST_ADDR	(CFG_POST_ALT_WORD_ADDR)
+#endif
 
-ulong post_word_load (void)
-{
-	return in_be32((void *)CFG_POST_ALT_WORD_ADDR);
-}
-#else /* CFG_POST_ALT_WORD_ADDR */
 void post_word_store (ulong a)
 {
-	volatile void *save_addr = (volatile void *)(CFG_OCM_DATA_ADDR + CFG_POST_WORD_ADDR);
-	*(volatile ulong *) save_addr = a;
+	volatile void *save_addr = (volatile void *)(_POST_ADDR);
+
+	out_be32(save_addr, a);
 }
 
 ulong post_word_load (void)
 {
-	volatile void *save_addr = (volatile void *)(CFG_OCM_DATA_ADDR + CFG_POST_WORD_ADDR);
-	return *(volatile ulong *) save_addr;
+	volatile void *save_addr = (volatile void *)(_POST_ADDR);
+
+	return in_be32(save_addr);
 }
-#endif /* CFG_POST_ALT_WORD_ADDR */
 
 #endif	/* CONFIG_POST || CONFIG_LOGBUFFER*/
 
--
1.5.4.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot-Users] [PATCH v2] PPC4xx: Simplified post_word_{load, store}
  2008-05-21 19:43 ` [U-Boot-Users] [PATCH v2] " Grant Erickson
@ 2008-05-21 20:17   ` Wolfgang Denk
  2008-05-21 20:25     ` Grant Erickson
  2008-05-21 20:28   ` [U-Boot-Users] [PATCH v3] " Grant Erickson
  1 sibling, 1 reply; 8+ messages in thread
From: Wolfgang Denk @ 2008-05-21 20:17 UTC (permalink / raw)
  To: u-boot

In message <1211398998-30954-1-git-send-email-gerickson@nuovations.com> you wrote:
> This patch simplifies post_word_{load,store} by using the preprocessor 
> to eliminate redundant, copy-and-pasted code.
...

> +#if defined(CFG_POST_WORD_ADDR)
> +# define _POST_ADDR	(CFG_OCM_DATA_ADDR + CFG_POST_WORD_ADDR)

Please make this

# define _POST_ADDR ((CFG_OCM_DATA_ADDR) + (CFG_POST_WORD_ADDR))

This *is* important. Assume 

	#define	CFG_OCM_DATA_ADDR	8 | 1
	#define CFG_POST_WORD_ADDR	16 | 3

Then ((CFG_OCM_DATA_ADDR) + (CFG_POST_WORD_ADDR)) gives 28 as
intended, but (CFG_OCM_DATA_ADDR + CFG_POST_WORD_ADDR) gives 27.

Best regards,

Wolfgang Denk

-- 
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
I express preference for a chronological  sequence  of  events  which
precludes a violence.   - Terry Pratchett, _The Dark Side of the Sun_

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot-Users] [PATCH v2] PPC4xx: Simplified post_word_{load, store}
  2008-05-21 20:17   ` Wolfgang Denk
@ 2008-05-21 20:25     ` Grant Erickson
  0 siblings, 0 replies; 8+ messages in thread
From: Grant Erickson @ 2008-05-21 20:25 UTC (permalink / raw)
  To: u-boot

On 5/21/08 1:17 PM, Wolfgang Denk wrote:

> In message <1211398998-30954-1-git-send-email-gerickson@nuovations.com> you
> wrote:
>> This patch simplifies post_word_{load,store} by using the preprocessor
>> to eliminate redundant, copy-and-pasted code.
> ...
> 
>> +#if defined(CFG_POST_WORD_ADDR)
>> +# define _POST_ADDR (CFG_OCM_DATA_ADDR + CFG_POST_WORD_ADDR)
> 
> Please make this
> 
> # define _POST_ADDR ((CFG_OCM_DATA_ADDR) + (CFG_POST_WORD_ADDR))
> 
> This *is* important. Assume
> 
> #define CFG_OCM_DATA_ADDR 8 | 1
> #define CFG_POST_WORD_ADDR 16 | 3
> 
> Then ((CFG_OCM_DATA_ADDR) + (CFG_POST_WORD_ADDR)) gives 28 as
> intended, but (CFG_OCM_DATA_ADDR + CFG_POST_WORD_ADDR) gives 27.

Agreed and I will make the change; however, were that the case, I would tend
to favor the approach that the responsibility is on the definer of '8 | 1'
and '16 | 3' to wrap those in parens. Thankfully, parens are a free
resource.

Regards,

Grant

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot-Users] [PATCH v3] PPC4xx: Simplified post_word_{load, store}
  2008-05-21 19:43 ` [U-Boot-Users] [PATCH v2] " Grant Erickson
  2008-05-21 20:17   ` Wolfgang Denk
@ 2008-05-21 20:28   ` Grant Erickson
  2008-06-03 18:34     ` Stefan Roese
  2008-06-04 22:06     ` Wolfgang Denk
  1 sibling, 2 replies; 8+ messages in thread
From: Grant Erickson @ 2008-05-21 20:28 UTC (permalink / raw)
  To: u-boot

This patch simplifies post_word_{load,store} by using the preprocessor 
to eliminate redundant, copy-and-pasted code.

Signed-off-by: Grant Erickson <gerickson@nuovations.com>
---
 cpu/ppc4xx/commproc.c |   26 +++++++++++---------------
 1 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/cpu/ppc4xx/commproc.c b/cpu/ppc4xx/commproc.c
index 22156dd..a6940e2 100644
--- a/cpu/ppc4xx/commproc.c
+++ b/cpu/ppc4xx/commproc.c
@@ -30,29 +30,25 @@
 
 #if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER)
 
-#if defined(CFG_POST_ALT_WORD_ADDR)
-void post_word_store (ulong a)
-{
-	out_be32((void *)CFG_POST_ALT_WORD_ADDR, a);
-}
+#if defined(CFG_POST_WORD_ADDR)
+# define _POST_ADDR	((CFG_OCM_DATA_ADDR) + (CFG_POST_WORD_ADDR))
+#elif defined(CFG_POST_ALT_WORD_ADDR)
+# define _POST_ADDR	(CFG_POST_ALT_WORD_ADDR)
+#endif
 
-ulong post_word_load (void)
-{
-	return in_be32((void *)CFG_POST_ALT_WORD_ADDR);
-}
-#else /* CFG_POST_ALT_WORD_ADDR */
 void post_word_store (ulong a)
 {
-	volatile void *save_addr = (volatile void *)(CFG_OCM_DATA_ADDR + CFG_POST_WORD_ADDR);
-	*(volatile ulong *) save_addr = a;
+	volatile void *save_addr = (volatile void *)(_POST_ADDR);
+
+	out_be32(save_addr, a);
 }
 
 ulong post_word_load (void)
 {
-	volatile void *save_addr = (volatile void *)(CFG_OCM_DATA_ADDR + CFG_POST_WORD_ADDR);
-	return *(volatile ulong *) save_addr;
+	volatile void *save_addr = (volatile void *)(_POST_ADDR);
+
+	return in_be32(save_addr);
 }
-#endif /* CFG_POST_ALT_WORD_ADDR */
 
 #endif	/* CONFIG_POST || CONFIG_LOGBUFFER*/
 
--
1.5.4.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot-Users] [PATCH v3] PPC4xx: Simplified post_word_{load, store}
  2008-05-21 20:28   ` [U-Boot-Users] [PATCH v3] " Grant Erickson
@ 2008-06-03 18:34     ` Stefan Roese
  2008-06-04 22:06     ` Wolfgang Denk
  1 sibling, 0 replies; 8+ messages in thread
From: Stefan Roese @ 2008-06-03 18:34 UTC (permalink / raw)
  To: u-boot

On Wednesday 21 May 2008, Grant Erickson wrote:
> This patch simplifies post_word_{load,store} by using the preprocessor
> to eliminate redundant, copy-and-pasted code.

Applied to u-boot-ppc4xx repo. Thanks.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot-Users] [PATCH v3] PPC4xx: Simplified post_word_{load, store}
  2008-05-21 20:28   ` [U-Boot-Users] [PATCH v3] " Grant Erickson
  2008-06-03 18:34     ` Stefan Roese
@ 2008-06-04 22:06     ` Wolfgang Denk
  1 sibling, 0 replies; 8+ messages in thread
From: Wolfgang Denk @ 2008-06-04 22:06 UTC (permalink / raw)
  To: u-boot

In message <1211401710-31902-1-git-send-email-gerickson@nuovations.com> you wrote:
> This patch simplifies post_word_{load,store} by using the preprocessor 
> to eliminate redundant, copy-and-pasted code.
> 
> Signed-off-by: Grant Erickson <gerickson@nuovations.com>
> ---
>  cpu/ppc4xx/commproc.c |   26 +++++++++++---------------
>  1 files changed, 11 insertions(+), 15 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

-- 
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
If you fail to plan, plan to fail.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-06-04 22:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-21 18:24 [U-Boot-Users] [PATCH] PPC4xx: Simplified post_word_{load,store} Grant Erickson
2008-05-21 19:29 ` [U-Boot-Users] [PATCH] PPC4xx: Simplified post_word_{load, store} Wolfgang Denk
2008-05-21 19:43 ` [U-Boot-Users] [PATCH v2] " Grant Erickson
2008-05-21 20:17   ` Wolfgang Denk
2008-05-21 20:25     ` Grant Erickson
2008-05-21 20:28   ` [U-Boot-Users] [PATCH v3] " Grant Erickson
2008-06-03 18:34     ` Stefan Roese
2008-06-04 22:06     ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox