From: Dirk Eibach <eibach@gdsys.de>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] char/moxa.c: fix endianess and multiple-card issues
Date: Fri, 18 Aug 2006 13:39:10 +0200 [thread overview]
Message-ID: <44E5A6DE.7090402@gdsys.de> (raw)
From: Dirk Eibach <eibach@gdsys.de>
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.
This patch applies to kernel 2.6.16.
Signed-off-by: Dirk Eibach <eibach@gdsys.de>
---
--- linux-2.6.16/drivers/char/moxa.c 2006-03-20 06:53:29.000000000 +0100
+++ linux-2.6.16-chameleon/drivers/char/moxa.c 2006-08-18
13:21:59.000000000 +0200
@@ -143,6 +143,7 @@ typedef struct _moxa_board_conf {
static moxa_board_conf moxa_boards[MAX_BOARDS];
static void __iomem *moxaBaseAddr[MAX_BOARDS];
+static int loadstat[MAX_BOARDS]={0,0,0,0};
struct moxa_str {
int type;
@@ -1690,6 +1691,8 @@ int MoxaDriverPoll(void)
if (moxaCard == 0)
return (-1);
for (card = 0; card < MAX_BOARDS; card++) {
+ if(loadstat[card]==0)
+ continue;
if ((ports = moxa_boards[card].numPorts) == 0)
continue;
if (readb(moxaIntPend[card]) == 0xff) {
@@ -2905,6 +2908,7 @@ static int moxaloadcode(int cardno, unsi
}
break;
}
+ loadstat[cardno] = 1;
return (0);
}
@@ -2922,7 +2926,7 @@ static int moxaloadc218(int cardno, void
len1 = len >> 1;
ptr = (ushort *) moxaBuff;
for (i = 0; i < len1; i++)
- usum += *(ptr + i);
+ usum += le16_to_cpu(*(ptr + i));
retry = 0;
do {
len1 = len >> 1;
@@ -2994,7 +2998,7 @@ static int moxaloadc320(int cardno, void
wlen = len >> 1;
uptr = (ushort *) moxaBuff;
for (i = 0; i < wlen; i++)
- usum += uptr[i];
+ usum += le16_to_cpu(uptr[i]);
retry = 0;
j = 0;
do {
next reply other threads:[~2006-08-18 11:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-18 11:39 Dirk Eibach [this message]
2006-08-18 13:35 ` Alexey Dobriyan
2006-08-20 18:28 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44E5A6DE.7090402@gdsys.de \
--to=eibach@gdsys.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®