All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] dm: ppc: Fixup cpu.c warning in mpc8xx
@ 2012-07-27 20:00 Marek Vasut
  2012-07-27 20:56 ` Wolfgang Denk
  2012-07-27 22:57 ` [U-Boot] [PATCH V2] " Marek Vasut
  0 siblings, 2 replies; 8+ messages in thread
From: Marek Vasut @ 2012-07-27 20:00 UTC (permalink / raw)
  To: u-boot

cpu.c: In function ?check_CPU?:
cpu.c:256:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
---
 arch/powerpc/cpu/mpc8xx/cpu.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/cpu/mpc8xx/cpu.c b/arch/powerpc/cpu/mpc8xx/cpu.c
index 5cbf9a6..e453245 100644
--- a/arch/powerpc/cpu/mpc8xx/cpu.c
+++ b/arch/powerpc/cpu/mpc8xx/cpu.c
@@ -41,6 +41,7 @@
 #include <netdev.h>
 #include <asm/cache.h>
 #include <linux/compiler.h>
+#include <asm/io.h>
 
 #if defined(CONFIG_OF_LIBFDT)
 #include <libfdt.h>
@@ -253,7 +254,7 @@ static int check_CPU (long clock, uint pvr, uint immr)
 	if ((pvr >> 16) != 0x0050)
 		return -1;
 
-	k = (immr << 16) | *((ushort *) & immap->im_cpm.cp_dparam[0xB0]);
+	k = (immr << 16) | readw(&immap->im_cpm.cp_dparam[0xB0]);
 	m = 0;
 
 	switch (k) {
-- 
1.7.10.4

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

* [U-Boot] [PATCH] dm: ppc: Fixup cpu.c warning in mpc8xx
  2012-07-27 20:00 [U-Boot] [PATCH] dm: ppc: Fixup cpu.c warning in mpc8xx Marek Vasut
@ 2012-07-27 20:56 ` Wolfgang Denk
  2012-07-27 21:26   ` Marek Vasut
  2012-07-27 22:57 ` [U-Boot] [PATCH V2] " Marek Vasut
  1 sibling, 1 reply; 8+ messages in thread
From: Wolfgang Denk @ 2012-07-27 20:56 UTC (permalink / raw)
  To: u-boot

Dear Marek Vasut,

In message <1343419212-18716-1-git-send-email-marex@denx.de> you wrote:
> cpu.c: In function ?check_CPU?:
> cpu.c:256:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Wolfgang Denk <wd@denx.de>
> ---
>  arch/powerpc/cpu/mpc8xx/cpu.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
...
> -	k = (immr << 16) | *((ushort *) & immap->im_cpm.cp_dparam[0xB0]);
> +	k = (immr << 16) | readw(&immap->im_cpm.cp_dparam[0xB0]);

I think this is wrong.  readw() is a little endian I/O accessor, but
PPC is all big-endian.

Guess this was untested?

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
"The good Christian should beware of mathematicians and all those who
make empty prophecies. The danger already exists that  mathematicians
have  made a covenant with the devil to darken the spirit and confine
man in the bonds of Hell."                          - Saint Augustine

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

* [U-Boot] [PATCH] dm: ppc: Fixup cpu.c warning in mpc8xx
  2012-07-27 20:56 ` Wolfgang Denk
@ 2012-07-27 21:26   ` Marek Vasut
  2012-07-27 22:14     ` Wolfgang Denk
  0 siblings, 1 reply; 8+ messages in thread
From: Marek Vasut @ 2012-07-27 21:26 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang Denk,

> Dear Marek Vasut,
> 
> In message <1343419212-18716-1-git-send-email-marex@denx.de> you wrote:
> > cpu.c: In function ?check_CPU?:
> > cpu.c:256:2: warning: dereferencing type-punned pointer will break
> > strict-aliasing rules [-Wstrict-aliasing]
> > 
> > Signed-off-by: Marek Vasut <marex@denx.de>
> > Cc: Wolfgang Denk <wd@denx.de>
> > ---
> > 
> >  arch/powerpc/cpu/mpc8xx/cpu.c |    3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> ...
> 
> > -	k = (immr << 16) | *((ushort *) & immap->im_cpm.cp_dparam[0xB0]);
> > +	k = (immr << 16) | readw(&immap->im_cpm.cp_dparam[0xB0]);
> 
> I think this is wrong.  readw() is a little endian I/O accessor, but
> PPC is all big-endian.

So in_be32 it is, I guess?

> Guess this was untested?

Of course it was not. Had trouble even sending this via the crappy cellular 
connection on a train ;-)

Thanks for catching it, glad you reviewed this.

> Best regards,
> 
> Wolfgang Denk

Best regards,
Marek Vasut

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

* [U-Boot] [PATCH] dm: ppc: Fixup cpu.c warning in mpc8xx
  2012-07-27 21:26   ` Marek Vasut
@ 2012-07-27 22:14     ` Wolfgang Denk
  2012-07-27 22:29       ` Marek Vasut
  0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Denk @ 2012-07-27 22:14 UTC (permalink / raw)
  To: u-boot

Dear Marek,

In message <201207272326.26896.marex@denx.de> you wrote:
>
> > > -	k = (immr << 16) | *((ushort *) & immap->im_cpm.cp_dparam[0xB0]);
> > > +	k = (immr << 16) | readw(&immap->im_cpm.cp_dparam[0xB0]);
> > 
> > I think this is wrong.  readw() is a little endian I/O accessor, but
> > PPC is all big-endian.
>
> So in_be32 it is, I guess?

Wrong again. Looks more like in_be16 to me...

> > Guess this was untested?
>
> Of course it was not. Had trouble even sending this via the crappy cellular>  
> connection on a train ;-)

You tested it? And it worked?  I'm surprised. ...  Really??

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
Worlds are conquered, galaxies destroyed -- but a woman is  always  a
woman.
	-- Kirk, "Conscience of the King", stardate unknown

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

* [U-Boot] [PATCH] dm: ppc: Fixup cpu.c warning in mpc8xx
  2012-07-27 22:14     ` Wolfgang Denk
@ 2012-07-27 22:29       ` Marek Vasut
  0 siblings, 0 replies; 8+ messages in thread
From: Marek Vasut @ 2012-07-27 22:29 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang Denk,

> Dear Marek,
> 
> In message <201207272326.26896.marex@denx.de> you wrote:
> > > > -	k = (immr << 16) | *((ushort *) & immap-
>im_cpm.cp_dparam[0xB0]);
> > > > +	k = (immr << 16) | readw(&immap->im_cpm.cp_dparam[0xB0]);
> > > 
> > > I think this is wrong.  readw() is a little endian I/O accessor, but
> > > PPC is all big-endian.
> > 
> > So in_be32 it is, I guess?
> 
> Wrong again. Looks more like in_be16 to me...

Ok, lemme try V2.

> > > Guess this was untested?
> > 
> > Of course it was not. Had trouble even sending this via the crappy
> > cellular> connection on a train ;-)
> 
> You tested it? And it worked?  I'm surprised. ...  Really??

No, I did not test it. The train control unit is MPC5200 too ... so I really had 
no hardware to test it on in close proximity ;-)

> Best regards,
> 
> Wolfgang Denk

Best regards,
Marek Vasut

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

* [U-Boot] [PATCH V2] dm: ppc: Fixup cpu.c warning in mpc8xx
  2012-07-27 20:00 [U-Boot] [PATCH] dm: ppc: Fixup cpu.c warning in mpc8xx Marek Vasut
  2012-07-27 20:56 ` Wolfgang Denk
@ 2012-07-27 22:57 ` Marek Vasut
  2012-07-30  7:45   ` Wolfgang Denk
  2012-07-30  8:02   ` Wolfgang Denk
  1 sibling, 2 replies; 8+ messages in thread
From: Marek Vasut @ 2012-07-27 22:57 UTC (permalink / raw)
  To: u-boot

cpu.c: In function ?check_CPU?:
cpu.c:256:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
---
 arch/powerpc/cpu/mpc8xx/cpu.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

NOTE: This patch is likely to break something, it is only compile tested.
NOTE2: Something is seriously wrong with my damned locale again :-/

diff --git a/arch/powerpc/cpu/mpc8xx/cpu.c b/arch/powerpc/cpu/mpc8xx/cpu.c
index 5cbf9a6..b3fcfe5 100644
--- a/arch/powerpc/cpu/mpc8xx/cpu.c
+++ b/arch/powerpc/cpu/mpc8xx/cpu.c
@@ -41,6 +41,7 @@
 #include <netdev.h>
 #include <asm/cache.h>
 #include <linux/compiler.h>
+#include <asm/io.h>
 
 #if defined(CONFIG_OF_LIBFDT)
 #include <libfdt.h>
@@ -253,7 +254,7 @@ static int check_CPU (long clock, uint pvr, uint immr)
 	if ((pvr >> 16) != 0x0050)
 		return -1;
 
-	k = (immr << 16) | *((ushort *) & immap->im_cpm.cp_dparam[0xB0]);
+	k = (immr << 16) | in_be16((ushort *)&immap->im_cpm.cp_dparam[0xB0]);
 	m = 0;
 
 	switch (k) {
-- 
1.7.10.4

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

* [U-Boot] [PATCH V2] dm: ppc: Fixup cpu.c warning in mpc8xx
  2012-07-27 22:57 ` [U-Boot] [PATCH V2] " Marek Vasut
@ 2012-07-30  7:45   ` Wolfgang Denk
  2012-07-30  8:02   ` Wolfgang Denk
  1 sibling, 0 replies; 8+ messages in thread
From: Wolfgang Denk @ 2012-07-30  7:45 UTC (permalink / raw)
  To: u-boot

Dear Marek Vasut,

In message <1343429832-24194-1-git-send-email-marex@denx.de> you wrote:
> cpu.c: In function ?check_CPU?:
> cpu.c:256:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Wolfgang Denk <wd@denx.de>
> ---
>  arch/powerpc/cpu/mpc8xx/cpu.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> NOTE: This patch is likely to break something, it is only compile tested.
> NOTE2: Something is seriously wrong with my damned locale again :-/

Tested on TQM855MDCBAB7-T66.102 (MPC855T at 66 MHz) and
TQM860LDB0A3-T50.202 (MPC860T at 50MHz).

Tested-by: Wolfgang Denk <wd@denx.de>
Acked-by: Wolfgang Denk <wd@denx.de>


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
"Wish not to seem, but to be, the best."                  - Aeschylus

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

* [U-Boot] [PATCH V2] dm: ppc: Fixup cpu.c warning in mpc8xx
  2012-07-27 22:57 ` [U-Boot] [PATCH V2] " Marek Vasut
  2012-07-30  7:45   ` Wolfgang Denk
@ 2012-07-30  8:02   ` Wolfgang Denk
  1 sibling, 0 replies; 8+ messages in thread
From: Wolfgang Denk @ 2012-07-30  8:02 UTC (permalink / raw)
  To: u-boot

Dear Marek Vasut,

In message <1343429832-24194-1-git-send-email-marex@denx.de> you wrote:
> cpu.c: In function ?check_CPU?:
> cpu.c:256:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Wolfgang Denk <wd@denx.de>
> ---
>  arch/powerpc/cpu/mpc8xx/cpu.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Applied to "next" branch, 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
Old programmers never die, they just branch to a new address.

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

end of thread, other threads:[~2012-07-30  8:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-27 20:00 [U-Boot] [PATCH] dm: ppc: Fixup cpu.c warning in mpc8xx Marek Vasut
2012-07-27 20:56 ` Wolfgang Denk
2012-07-27 21:26   ` Marek Vasut
2012-07-27 22:14     ` Wolfgang Denk
2012-07-27 22:29       ` Marek Vasut
2012-07-27 22:57 ` [U-Boot] [PATCH V2] " Marek Vasut
2012-07-30  7:45   ` Wolfgang Denk
2012-07-30  8:02   ` Wolfgang Denk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.