Skip to content

Commit e51a1ac

Browse files
hharrisonIngo Molnar
authored andcommitted
x86, olpc: fix endian bug in openfirmware workaround
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 <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent fb478da commit e51a1ac

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/x86/kernel/olpc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,20 +190,20 @@ EXPORT_SYMBOL_GPL(olpc_ec_cmd);
190190
static void __init platform_detect(void)
191191
{
192192
size_t propsize;
193-
u32 rev;
193+
__be32 rev;
194194

195195
if (ofw("getprop", 4, 1, NULL, "board-revision-int", &rev, 4,
196196
&propsize) || propsize != 4) {
197197
printk(KERN_ERR "ofw: getprop call failed!\n");
198-
rev = 0;
198+
rev = cpu_to_be32(0);
199199
}
200200
olpc_platform_info.boardrev = be32_to_cpu(rev);
201201
}
202202
#else
203203
static void __init platform_detect(void)
204204
{
205205
/* stopgap until OFW support is added to the kernel */
206-
olpc_platform_info.boardrev = be32_to_cpu(0xc2);
206+
olpc_platform_info.boardrev = 0xc2;
207207
}
208208
#endif
209209

0 commit comments

Comments
 (0)