lkml.org 
[lkml]   [2011]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/1] memstick: fix the bit shift problem for JMicron 38x controllers in ARM platform
Date
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@jmicron.com>
---
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--;
}



\
 
 \ /
  Last update: 2011-05-16 07:33    [W:0.036 / U:15.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site