Re: [PATCH] char/moxa.c: fix endianess and multiple-card issues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 18, 2006 at 01:39:10PM +0200, Dirk Eibach wrote:
> From: Dirk Eibach <[email protected]>
> 
> While testing Moxa C218T/PCI on PowerPC 405EP I found that loading 
> firmware using the linux kernel driver fails because calculation of the 
> checksum is not endianess independent in the original code.
> 
> After I fixed this I found that uploading firmware in a system with 
> multiple cards causes a kernel oops. I had a look in the recent moxa 
> sources and found that they do some kind of locking there. Applying this 
> lock fixed the problem.

Patch for endian bug needs sparse endian annotations as well.
--------------------------------------
[PATCH] moxa: fix checksum endianness

From: Dirk Eibach <[email protected]>

While testing Moxa C218T/PCI on PowerPC 405EP I found that loading
firmware using the linux kernel driver fails because calculation of the
checksum is not endianess independent in the original code.

Signed-off-by: Dirk Eibach <[email protected]>
Signed-off-by: Alexey Dobriyan <[email protected]>
---

 drivers/char/moxa.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -2910,7 +2910,8 @@ static int moxaloadc218(int cardno, void
 {
 	char retry;
 	int i, j, len1, len2;
-	ushort usum, *ptr, keycode;
+	ushort usum, keycode;
+	__le16 *ptr;
 
 	if (moxa_boards[cardno].boardType == MOXA_BOARD_CP204J)
 		keycode = CP204J_KeyCode;
@@ -2918,9 +2919,9 @@ static int moxaloadc218(int cardno, void
 		keycode = C218_KeyCode;
 	usum = 0;
 	len1 = len >> 1;
-	ptr = (ushort *) moxaBuff;
+	ptr = (__le16 *) moxaBuff;
 	for (i = 0; i < len1; i++)
-		usum += *(ptr + i);
+		usum += le16_to_cpu(*(ptr + i));
 	retry = 0;
 	do {
 		len1 = len >> 1;
@@ -2986,13 +2987,13 @@ static int moxaloadc320(int cardno, void
 {
 	ushort usum;
 	int i, j, wlen, len2, retry;
-	ushort *uptr;
+	__le16 *uptr;
 
 	usum = 0;
 	wlen = len >> 1;
-	uptr = (ushort *) moxaBuff;
+	uptr = (__le16 *) moxaBuff;
 	for (i = 0; i < wlen; i++)
-		usum += uptr[i];
+		usum += le16_to_cpu(uptr[i]);
 	retry = 0;
 	j = 0;
 	do {

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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux