Commit 24c032f1 authored by Jiri Slaby's avatar Jiri Slaby Committed by Linus Torvalds

Char: moxa, eliminate busy waiting

blah, moxa delays 250+ ms in busy waiting, use msleep instead.
Signed-off-by: default avatarJiri Slaby <jirislaby@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 4969b3a4
...@@ -1405,7 +1405,6 @@ static int moxaCard; ...@@ -1405,7 +1405,6 @@ static int moxaCard;
static struct mon_str moxaLog; static struct mon_str moxaLog;
static int moxaFuncTout = HZ / 2; static int moxaFuncTout = HZ / 2;
static void moxadelay(int);
static void moxafunc(void __iomem *, int, ushort); static void moxafunc(void __iomem *, int, ushort);
static void wait_finish(void __iomem *); static void wait_finish(void __iomem *);
static void low_water_check(void __iomem *); static void low_water_check(void __iomem *);
...@@ -2404,10 +2403,10 @@ void MoxaPortSendBreak(int port, int ms100) ...@@ -2404,10 +2403,10 @@ void MoxaPortSendBreak(int port, int ms100)
ofsAddr = moxa_ports[port].tableAddr; ofsAddr = moxa_ports[port].tableAddr;
if (ms100) { if (ms100) {
moxafunc(ofsAddr, FC_SendBreak, Magic_code); moxafunc(ofsAddr, FC_SendBreak, Magic_code);
moxadelay(ms100 * (HZ / 10)); msleep(ms100 * 10);
} else { } else {
moxafunc(ofsAddr, FC_SendBreak, Magic_code); moxafunc(ofsAddr, FC_SendBreak, Magic_code);
moxadelay(HZ / 4); /* 250 ms */ msleep(250);
} }
moxafunc(ofsAddr, FC_StopBreak, Magic_code); moxafunc(ofsAddr, FC_StopBreak, Magic_code);
} }
...@@ -2476,18 +2475,6 @@ static int moxa_set_serial_info(struct moxa_port *info, ...@@ -2476,18 +2475,6 @@ static int moxa_set_serial_info(struct moxa_port *info,
/***************************************************************************** /*****************************************************************************
* Static local functions: * * Static local functions: *
*****************************************************************************/ *****************************************************************************/
/*
* moxadelay - delays a specified number ticks
*/
static void moxadelay(int tick)
{
unsigned long st, et;
st = jiffies;
et = st + tick;
while (time_before(jiffies, et));
}
static void moxafunc(void __iomem *ofsAddr, int cmd, ushort arg) static void moxafunc(void __iomem *ofsAddr, int cmd, ushort arg)
{ {
...@@ -2535,7 +2522,7 @@ static int moxaloadbios(int cardno, unsigned char __user *tmp, int len) ...@@ -2535,7 +2522,7 @@ static int moxaloadbios(int cardno, unsigned char __user *tmp, int len)
return -EFAULT; return -EFAULT;
baseAddr = moxa_boards[cardno].basemem; baseAddr = moxa_boards[cardno].basemem;
writeb(HW_reset, baseAddr + Control_reg); /* reset */ writeb(HW_reset, baseAddr + Control_reg); /* reset */
moxadelay(1); /* delay 10 ms */ msleep(10);
for (i = 0; i < 4096; i++) for (i = 0; i < 4096; i++)
writeb(0, baseAddr + i); /* clear fix page */ writeb(0, baseAddr + i); /* clear fix page */
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
...@@ -2713,7 +2700,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len) ...@@ -2713,7 +2700,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)
for (i = 0; i < 100; i++) { for (i = 0; i < 100; i++) {
if (readw(baseAddr + C218_key) == keycode) if (readw(baseAddr + C218_key) == keycode)
break; break;
moxadelay(1); /* delay 10 ms */ msleep(10);
} }
if (readw(baseAddr + C218_key) != keycode) { if (readw(baseAddr + C218_key) != keycode) {
return (-1); return (-1);
...@@ -2725,7 +2712,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len) ...@@ -2725,7 +2712,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)
for (i = 0; i < 100; i++) { for (i = 0; i < 100; i++) {
if (readw(baseAddr + C218_key) == keycode) if (readw(baseAddr + C218_key) == keycode)
break; break;
moxadelay(1); /* delay 10 ms */ msleep(10);
} }
retry++; retry++;
} while ((readb(baseAddr + C218chksum_ok) != 1) && (retry < 3)); } while ((readb(baseAddr + C218chksum_ok) != 1) && (retry < 3));
...@@ -2736,7 +2723,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len) ...@@ -2736,7 +2723,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)
for (i = 0; i < 100; i++) { for (i = 0; i < 100; i++) {
if (readw(baseAddr + Magic_no) == Magic_code) if (readw(baseAddr + Magic_no) == Magic_code)
break; break;
moxadelay(1); /* delay 10 ms */ msleep(10);
} }
if (readw(baseAddr + Magic_no) != Magic_code) { if (readw(baseAddr + Magic_no) != Magic_code) {
return (-1); return (-1);
...@@ -2746,7 +2733,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len) ...@@ -2746,7 +2733,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)
for (i = 0; i < 100; i++) { for (i = 0; i < 100; i++) {
if (readw(baseAddr + Magic_no) == Magic_code) if (readw(baseAddr + Magic_no) == Magic_code)
break; break;
moxadelay(1); /* delay 10 ms */ msleep(10);
} }
if (readw(baseAddr + Magic_no) != Magic_code) { if (readw(baseAddr + Magic_no) != Magic_code) {
return (-1); return (-1);
...@@ -2788,7 +2775,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor ...@@ -2788,7 +2775,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
if (readw(baseAddr + C320_key) == C320_KeyCode) if (readw(baseAddr + C320_key) == C320_KeyCode)
break; break;
moxadelay(1); msleep(10);
} }
if (readw(baseAddr + C320_key) != C320_KeyCode) if (readw(baseAddr + C320_key) != C320_KeyCode)
return (-1); return (-1);
...@@ -2799,7 +2786,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor ...@@ -2799,7 +2786,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
if (readw(baseAddr + C320_key) == C320_KeyCode) if (readw(baseAddr + C320_key) == C320_KeyCode)
break; break;
moxadelay(1); msleep(10);
} }
retry++; retry++;
} while ((readb(baseAddr + C320chksum_ok) != 1) && (retry < 3)); } while ((readb(baseAddr + C320chksum_ok) != 1) && (retry < 3));
...@@ -2809,7 +2796,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor ...@@ -2809,7 +2796,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor
for (i = 0; i < 600; i++) { for (i = 0; i < 600; i++) {
if (readw(baseAddr + Magic_no) == Magic_code) if (readw(baseAddr + Magic_no) == Magic_code)
break; break;
moxadelay(1); msleep(10);
} }
if (readw(baseAddr + Magic_no) != Magic_code) if (readw(baseAddr + Magic_no) != Magic_code)
return (-100); return (-100);
...@@ -2828,7 +2815,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor ...@@ -2828,7 +2815,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor
for (i = 0; i < 500; i++) { for (i = 0; i < 500; i++) {
if (readw(baseAddr + Magic_no) == Magic_code) if (readw(baseAddr + Magic_no) == Magic_code)
break; break;
moxadelay(1); msleep(10);
} }
if (readw(baseAddr + Magic_no) != Magic_code) if (readw(baseAddr + Magic_no) != Magic_code)
return (-102); return (-102);
...@@ -2842,7 +2829,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor ...@@ -2842,7 +2829,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor
for (i = 0; i < 600; i++) { for (i = 0; i < 600; i++) {
if (readw(baseAddr + Magic_no) == Magic_code) if (readw(baseAddr + Magic_no) == Magic_code)
break; break;
moxadelay(1); msleep(10);
} }
if (readw(baseAddr + Magic_no) != Magic_code) if (readw(baseAddr + Magic_no) != Magic_code)
return (-102); return (-102);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment