aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2007-07-17 07:05:19 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-17 13:23:10 -0400
commit24c032f1dd393c995545ecefa8c1585ae9ef6b37 (patch)
tree5c7e4b21cf4d6935e090c4cc4b95a94ad6a82ec0 /drivers/char
parent4969b3a43dd9e234b363f7bf52d0f6c4b6139eea (diff)
Char: moxa, eliminate busy waiting
blah, moxa delays 250+ ms in busy waiting, use msleep instead. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/moxa.c37
1 files changed, 12 insertions, 25 deletions
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index e0d35c20c04f..ed76f0a127fd 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -1405,7 +1405,6 @@ static int moxaCard;
1405static struct mon_str moxaLog; 1405static struct mon_str moxaLog;
1406static int moxaFuncTout = HZ / 2; 1406static int moxaFuncTout = HZ / 2;
1407 1407
1408static void moxadelay(int);
1409static void moxafunc(void __iomem *, int, ushort); 1408static void moxafunc(void __iomem *, int, ushort);
1410static void wait_finish(void __iomem *); 1409static void wait_finish(void __iomem *);
1411static void low_water_check(void __iomem *); 1410static void low_water_check(void __iomem *);
@@ -2404,10 +2403,10 @@ void MoxaPortSendBreak(int port, int ms100)
2404 ofsAddr = moxa_ports[port].tableAddr; 2403 ofsAddr = moxa_ports[port].tableAddr;
2405 if (ms100) { 2404 if (ms100) {
2406 moxafunc(ofsAddr, FC_SendBreak, Magic_code); 2405 moxafunc(ofsAddr, FC_SendBreak, Magic_code);
2407 moxadelay(ms100 * (HZ / 10)); 2406 msleep(ms100 * 10);
2408 } else { 2407 } else {
2409 moxafunc(ofsAddr, FC_SendBreak, Magic_code); 2408 moxafunc(ofsAddr, FC_SendBreak, Magic_code);
2410 moxadelay(HZ / 4); /* 250 ms */ 2409 msleep(250);
2411 } 2410 }
2412 moxafunc(ofsAddr, FC_StopBreak, Magic_code); 2411 moxafunc(ofsAddr, FC_StopBreak, Magic_code);
2413} 2412}
@@ -2476,18 +2475,6 @@ static int moxa_set_serial_info(struct moxa_port *info,
2476/***************************************************************************** 2475/*****************************************************************************
2477 * Static local functions: * 2476 * Static local functions: *
2478 *****************************************************************************/ 2477 *****************************************************************************/
2479/*
2480 * moxadelay - delays a specified number ticks
2481 */
2482static void moxadelay(int tick)
2483{
2484 unsigned long st, et;
2485
2486 st = jiffies;
2487 et = st + tick;
2488 while (time_before(jiffies, et));
2489}
2490
2491static void moxafunc(void __iomem *ofsAddr, int cmd, ushort arg) 2478static void moxafunc(void __iomem *ofsAddr, int cmd, ushort arg)
2492{ 2479{
2493 2480
@@ -2535,7 +2522,7 @@ static int moxaloadbios(int cardno, unsigned char __user *tmp, int len)
2535 return -EFAULT; 2522 return -EFAULT;
2536 baseAddr = moxa_boards[cardno].basemem; 2523 baseAddr = moxa_boards[cardno].basemem;
2537 writeb(HW_reset, baseAddr + Control_reg); /* reset */ 2524 writeb(HW_reset, baseAddr + Control_reg); /* reset */
2538 moxadelay(1); /* delay 10 ms */ 2525 msleep(10);
2539 for (i = 0; i < 4096; i++) 2526 for (i = 0; i < 4096; i++)
2540 writeb(0, baseAddr + i); /* clear fix page */ 2527 writeb(0, baseAddr + i); /* clear fix page */
2541 for (i = 0; i < len; i++) 2528 for (i = 0; i < len; i++)
@@ -2713,7 +2700,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)
2713 for (i = 0; i < 100; i++) { 2700 for (i = 0; i < 100; i++) {
2714 if (readw(baseAddr + C218_key) == keycode) 2701 if (readw(baseAddr + C218_key) == keycode)
2715 break; 2702 break;
2716 moxadelay(1); /* delay 10 ms */ 2703 msleep(10);
2717 } 2704 }
2718 if (readw(baseAddr + C218_key) != keycode) { 2705 if (readw(baseAddr + C218_key) != keycode) {
2719 return (-1); 2706 return (-1);
@@ -2725,7 +2712,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)
2725 for (i = 0; i < 100; i++) { 2712 for (i = 0; i < 100; i++) {
2726 if (readw(baseAddr + C218_key) == keycode) 2713 if (readw(baseAddr + C218_key) == keycode)
2727 break; 2714 break;
2728 moxadelay(1); /* delay 10 ms */ 2715 msleep(10);
2729 } 2716 }
2730 retry++; 2717 retry++;
2731 } while ((readb(baseAddr + C218chksum_ok) != 1) && (retry < 3)); 2718 } while ((readb(baseAddr + C218chksum_ok) != 1) && (retry < 3));
@@ -2736,7 +2723,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)
2736 for (i = 0; i < 100; i++) { 2723 for (i = 0; i < 100; i++) {
2737 if (readw(baseAddr + Magic_no) == Magic_code) 2724 if (readw(baseAddr + Magic_no) == Magic_code)
2738 break; 2725 break;
2739 moxadelay(1); /* delay 10 ms */ 2726 msleep(10);
2740 } 2727 }
2741 if (readw(baseAddr + Magic_no) != Magic_code) { 2728 if (readw(baseAddr + Magic_no) != Magic_code) {
2742 return (-1); 2729 return (-1);
@@ -2746,7 +2733,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)
2746 for (i = 0; i < 100; i++) { 2733 for (i = 0; i < 100; i++) {
2747 if (readw(baseAddr + Magic_no) == Magic_code) 2734 if (readw(baseAddr + Magic_no) == Magic_code)
2748 break; 2735 break;
2749 moxadelay(1); /* delay 10 ms */ 2736 msleep(10);
2750 } 2737 }
2751 if (readw(baseAddr + Magic_no) != Magic_code) { 2738 if (readw(baseAddr + Magic_no) != Magic_code) {
2752 return (-1); 2739 return (-1);
@@ -2788,7 +2775,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor
2788 for (i = 0; i < 10; i++) { 2775 for (i = 0; i < 10; i++) {
2789 if (readw(baseAddr + C320_key) == C320_KeyCode) 2776 if (readw(baseAddr + C320_key) == C320_KeyCode)
2790 break; 2777 break;
2791 moxadelay(1); 2778 msleep(10);
2792 } 2779 }
2793 if (readw(baseAddr + C320_key) != C320_KeyCode) 2780 if (readw(baseAddr + C320_key) != C320_KeyCode)
2794 return (-1); 2781 return (-1);
@@ -2799,7 +2786,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor
2799 for (i = 0; i < 10; i++) { 2786 for (i = 0; i < 10; i++) {
2800 if (readw(baseAddr + C320_key) == C320_KeyCode) 2787 if (readw(baseAddr + C320_key) == C320_KeyCode)
2801 break; 2788 break;
2802 moxadelay(1); 2789 msleep(10);
2803 } 2790 }
2804 retry++; 2791 retry++;
2805 } while ((readb(baseAddr + C320chksum_ok) != 1) && (retry < 3)); 2792 } 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 for (i = 0; i < 600; i++) { 2796 for (i = 0; i < 600; i++) {
2810 if (readw(baseAddr + Magic_no) == Magic_code) 2797 if (readw(baseAddr + Magic_no) == Magic_code)
2811 break; 2798 break;
2812 moxadelay(1); 2799 msleep(10);
2813 } 2800 }
2814 if (readw(baseAddr + Magic_no) != Magic_code) 2801 if (readw(baseAddr + Magic_no) != Magic_code)
2815 return (-100); 2802 return (-100);
@@ -2828,7 +2815,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor
2828 for (i = 0; i < 500; i++) { 2815 for (i = 0; i < 500; i++) {
2829 if (readw(baseAddr + Magic_no) == Magic_code) 2816 if (readw(baseAddr + Magic_no) == Magic_code)
2830 break; 2817 break;
2831 moxadelay(1); 2818 msleep(10);
2832 } 2819 }
2833 if (readw(baseAddr + Magic_no) != Magic_code) 2820 if (readw(baseAddr + Magic_no) != Magic_code)
2834 return (-102); 2821 return (-102);
@@ -2842,7 +2829,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor
2842 for (i = 0; i < 600; i++) { 2829 for (i = 0; i < 600; i++) {
2843 if (readw(baseAddr + Magic_no) == Magic_code) 2830 if (readw(baseAddr + Magic_no) == Magic_code)
2844 break; 2831 break;
2845 moxadelay(1); 2832 msleep(10);
2846 } 2833 }
2847 if (readw(baseAddr + Magic_no) != Magic_code) 2834 if (readw(baseAddr + Magic_no) != Magic_code)
2848 return (-102); 2835 return (-102);