[PATCH 1/1] memstick: fix the bit shift problem for JMicron 38x controllers in ARM platform

From: Aries Lee
Date: Mon May 16 2011 - 01:33:26 EST


If x86 architecture, an unsigned variable shift more than 31 times means a
rotation.
But in some architecture, shift 32 bit or more will give a zero value.
For example,
An unsigned int variable of 0x11223344 runs the operation "<< 32",
In x86 architecture, its value is still 0x11223344
But its value will change as 0x00000000 in ARM.

This patch try to fix those architecture-specific code, and made it both
work in x86 and the other architecture.

Signed-off-by: Aries Lee <arieslee@xxxxxxxxxxx>
---
diff --git a/drivers/memstick/host/jmb38x_ms.c
b/drivers/memstick/host/jmb38x_ms.c
index d89d925..272e89c 100644
--- a/drivers/memstick/host/jmb38x_ms.c
+++ b/drivers/memstick/host/jmb38x_ms.c
@@ -287,8 +287,8 @@ static unsigned int jmb38x_ms_write_reg_data(struct
jmb38x_ms_host *host,
return off;

while (host->io_pos < 8 && length) {
- host->io_word[1] &= ~(0xff << (host->io_pos * 8));
- host->io_word[1] |= buf[off++] << (host->io_pos * 8);
+ host->io_word[1] &= ~(0xff << ((host->io_pos-4) * 8));
+ host->io_word[1] |= buf[off++] << ((host->io_pos-4) * 8);
host->io_pos++;
length--;
}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/