public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] olpc: fix endian bug in openfirmware workaround
@ 2008-09-23 22:20 Harvey Harrison
  2008-09-24  7:53 ` Ingo Molnar
  2009-02-14  1:56 ` [PATCH] olpc: fix model detection without OFW Chris Ball
  0 siblings, 2 replies; 8+ messages in thread
From: Harvey Harrison @ 2008-09-23 22:20 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Ingo Molnar, LKML, H. Peter Anvin, Thomas Gleixner

Boardrev is always treated as a u32 everywhere else, no reason to
byteswap the 0xc2 value.  The only use is to print out if it is
a prerelease board, the test being:

(olpc_platform_info.boardrev & 0xf) < 8

Which is currently always true as be32_to_cpu(0xc2) & 0xf = 0
but I doubt that was the intention here.  The consequences of the bug
are pretty minor though (incorrect boardrev displayed in dmesg when
ofw support not configured)

Also annotate the temporary used to read the boardrev in the ofw
case.

The confusion was noticed by sparse:
arch/x86/kernel/olpc.c:206:32: warning: cast to restricted __be32

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
 arch/x86/kernel/olpc.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/olpc.c b/arch/x86/kernel/olpc.c
index 3e66722..7a13fac 100644
--- a/arch/x86/kernel/olpc.c
+++ b/arch/x86/kernel/olpc.c
@@ -190,12 +190,12 @@ EXPORT_SYMBOL_GPL(olpc_ec_cmd);
 static void __init platform_detect(void)
 {
 	size_t propsize;
-	u32 rev;
+	__be32 rev;
 
 	if (ofw("getprop", 4, 1, NULL, "board-revision-int", &rev, 4,
 			&propsize) || propsize != 4) {
 		printk(KERN_ERR "ofw: getprop call failed!\n");
-		rev = 0;
+		rev = cpu_to_be32(0);
 	}
 	olpc_platform_info.boardrev = be32_to_cpu(rev);
 }
@@ -203,7 +203,7 @@ static void __init platform_detect(void)
 static void __init platform_detect(void)
 {
 	/* stopgap until OFW support is added to the kernel */
-	olpc_platform_info.boardrev = be32_to_cpu(0xc2);
+	olpc_platform_info.boardrev = 0xc2;
 }
 #endif
 
-- 
1.6.0.2.471.g47a76




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

end of thread, other threads:[~2009-02-14 22:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-23 22:20 [PATCH] olpc: fix endian bug in openfirmware workaround Harvey Harrison
2008-09-24  7:53 ` Ingo Molnar
2009-02-14  1:56 ` [PATCH] olpc: fix model detection without OFW Chris Ball
2009-02-14  4:19   ` Andres Salomon
2009-02-14 21:43     ` Ingo Molnar
2009-02-14 21:53       ` Andres Salomon
2009-02-14 22:14         ` Ingo Molnar
2009-02-14 22:32           ` Andres Salomon

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