Char: moxa, eliminate busy waiting
PATCH 1/3 Char: moxa, eliminate busy waiting
moxa, eliminate busy waiting
blah, moxa delays 250+ ms in busy waiting, use msleep instead.
---
commit 3f4308a387d98370556455e729787cc47f200757
tree 26ae5bab0e6f56a06c71c8f15533f643d070da4f
parent 4ea1257b890befc706f6d43562ba68671db39195
author Jiri Slaby <[email protected]> Wed, 23 May 2007 16:24:40 +0200 committer Jiri Slaby <[email protected]> Wed, 23 May 2007 16:24:40 +0200
drivers/char/moxa.c | 37 ++++++++++++------------------------- 1 files changed, 12 insertions(+), 25 deletions(-)
drivers/char/moxa.c +12 -25
@@ -1405,7 +1405,6 @@ static int moxaCard;static struct mon_str moxaLog;static int moxaFuncTout =HZ /2 ; -static void moxadelay (int );static void moxafunc (void __iomem *,int ,ushort );static void wait_finish (void __iomem *);static void low_water_check (void __iomem *);
@@ -2404,10 +2403,10 @@ void MoxaPortSendBreak(int port, int ms100) ofsAddr = moxa_ports[port].tableAddr;if (ms100) {moxafunc (ofsAddr, FC_SendBreak, Magic_code); -moxadelay (ms100 * (HZ /10 )); +msleep (ms100 *10 ); }else {moxafunc (ofsAddr, FC_SendBreak, Magic_code); -moxadelay (HZ /4 );/* 250 ms */ +msleep (250 ); }moxafunc (ofsAddr, FC_StopBreak, Magic_code); }
@@ -2476,18 +2475,6 @@ static int moxa_set_serial_info(struct moxa_port *info,/***************************************************************************** * 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) {
@@ -2535,7 +2522,7 @@ static int moxaloadbios(int cardno, unsigned char __user *tmp, int len)return -EFAULT ; baseAddr = moxa_boards[cardno].basemem;writeb (HW_reset, baseAddr + Control_reg);/* reset */ -moxadelay (1 );/* delay 10 ms */ +msleep (10 );for (i =0 ; i <4096 ; i++)writeb (0 , baseAddr + i);/* clear fix page */ for (i =0 ; i < len; i++)
@@ -2713,7 +2700,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)for (i =0 ; i <100 ; i++) {if (readw (baseAddr + C218_key) == keycode)break ; -moxadelay (1 );/* delay 10 ms */ +msleep (10 ); }if (readw (baseAddr + C218_key) != keycode) {return (-1 );
@@ -2725,7 +2712,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)for (i =0 ; i <100 ; i++) {if (readw (baseAddr + C218_key) == keycode)break ; -moxadelay (1 );/* delay 10 ms */ +msleep (10 ); } retry++; }while ((readb (baseAddr + C218chksum_ok) !=1 ) && (retry <3 ));
@@ -2736,7 +2723,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)for (i =0 ; i <100 ; i++) {if (readw (baseAddr + Magic_no) == Magic_code)break ; -moxadelay (1 );/* delay 10 ms */ +msleep (10 ); }if (readw (baseAddr + Magic_no) != Magic_code) {return (-1 );
@@ -2746,7 +2733,7 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)for (i =0 ; i <100 ; i++) {if (readw (baseAddr + Magic_no) == Magic_code)break ; -moxadelay (1 );/* delay 10 ms */ +msleep (10 ); }if (readw (baseAddr + Magic_no) != Magic_code) {return (-1 );
@@ -2788,7 +2775,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPorfor (i =0 ; i <10 ; i++) {if (readw (baseAddr + C320_key) == C320_KeyCode)break ; -moxadelay (1 ); +msleep (10 ); }if (readw (baseAddr + C320_key) != C320_KeyCode)return (-1 );
@@ -2799,7 +2786,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPorfor (i =0 ; i <10 ; i++) {if (readw (baseAddr + C320_key) == C320_KeyCode)break ; -moxadelay (1 ); +msleep (10 ); } retry++; }while ((readb (baseAddr + C320chksum_ok) !=1 ) && (retry <3 ));
@@ -2809,7 +2796,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPorfor (i =0 ; i <600 ; i++) {if (readw (baseAddr + Magic_no) == Magic_code)break ; -moxadelay (1 ); +msleep (10 ); }if (readw (baseAddr + Magic_no) != Magic_code)return (-100 );
@@ -2828,7 +2815,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPorfor (i =0 ; i <500 ; i++) {if (readw (baseAddr + Magic_no) == Magic_code)break ; -moxadelay (1 ); +msleep (10 ); }if (readw (baseAddr + Magic_no) != Magic_code)return (-102 );
@@ -2842,7 +2829,7 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPorfor (i =0 ; i <600 ; i++) {if (readw (baseAddr + Magic_no) == Magic_code)break ; -moxadelay (1 ); +msleep (10 ); }if (readw (baseAddr + Magic_no) != Magic_code)return (-102 );
PATCH 2/3 Char: specialix, remove busy waiting
specialix, remove busy waiting
use msleep instead, because not in atomic
---
commit a677db846e7951118d0409956f4197cc01194f99
tree f0b69d293f8c779111a1a7f0cf9cc37cf164a0c6
parent 3f4308a387d98370556455e729787cc47f200757
author Jiri Slaby <[email protected]> Wed, 23 May 2007 16:46:36 +0200 committer Jiri Slaby <[email protected]> Wed, 23 May 2007 16:46:36 +0200
drivers/char/specialix.c | 16 ++-------------- 1 files changed, 2 insertions(+), 14 deletions(-)
drivers/char/specialix.c +2 -14
@@ -345,18 +345,6 @@ static inline void sx_release_io_range(struct specialix_board * bp) } -/* Must be called with enabled interrupts */ -/* Ugly. Very ugly. Don't use this for anything else than initialization -code */ -static inline void sx_long_delay (unsigned long delay) -{ -unsigned long i; - -for (i = jiffies + delay;time_after (i, jiffies); ) ; -} - - -/* Set the IRQ using the RTS lines that run to the PAL on the board.... */ static int sx_set_irq (struct specialix_board *bp) {
@@ -397,7 +385,7 @@ static int sx_init_CD186x(struct specialix_board * bp)spin_lock_irqsave (&bp->lock, flags);sx_out_off (bp, CD186x_CCR,CCR_HARDRESET );/* Reset CD186x chip */ spin_unlock_irqrestore (&bp->lock, flags); -sx_long_delay (HZ /20 );/* Delay 0.05 sec */ +msleep (50 );/* Delay 0.05 sec */ spin_lock_irqsave (&bp->lock, flags);sx_out_off (bp, CD186x_GIVR,SX_ID );/* Set ID for this chip */ sx_out_off (bp, CD186x_GICR,0 );/* Clear all bits */
@@ -533,7 +521,7 @@ static int sx_probe(struct specialix_board *bp)sx_wait_CCR (bp);sx_out (bp, CD186x_CCR,CCR_TXEN );/* Enable transmitter */ sx_out (bp, CD186x_IER,IER_TXRDY );/* Enable tx empty intr */ -sx_long_delay (HZ /20 ); +msleep (50 ); irqs =probe_irq_off (irqs);dprintk (SX_DEBUG_INIT ,"SRSR = %02x, " ,sx_in (bp, CD186x_SRSR));
PATCH 3/3 Char: riscom8, eliminate busy loop
In reply to Jiri Slabyriscom8, eliminate busy loop
---
commit 221eebee5eedfa7c2463dcbfb545b92595512310
tree ea667b3ef038cff3a0e86266d37d364766a17303
parent a677db846e7951118d0409956f4197cc01194f99
author Jiri Slaby <[email protected]> Wed, 23 May 2007 17:30:19 +0200 committer Jiri Slaby <[email protected]> Wed, 23 May 2007 17:30:19 +0200
drivers/char/riscom8.c | 12 ++---------- 1 files changed, 2 insertions(+), 10 deletions(-)
drivers/char/riscom8.c +2 -10
@@ -213,14 +213,6 @@ static inline void rc_release_io_range(struct riscom_board * const bp)release_region (RC_TO_ISA (rc_ioport[i]) + bp->base,1 ); } -/* Must be called with enabled interrupts */ -static inline void rc_long_delay (unsigned long delay) -{ -unsigned long i; - -for (i = jiffies + delay;time_after (i,jiffies); ) ; -} -/* Reset and setup CD180 chip */ static void __init rc_init_CD180 (struct riscom_board const * bp) {
@@ -231,7 +223,7 @@ static void __init rc_init_CD180(struct riscom_board const * bp)rc_wait_CCR (bp);/* Wait for CCR ready */ rc_out (bp,CD180_CCR ,CCR_HARDRESET );/* Reset CD180 chip */ sti (); -rc_long_delay (HZ /20 );/* Delay 0.05 sec */ +msleep (50 );/* Delay 0.05 sec */ cli ();rc_out (bp,CD180_GIVR ,RC_ID );/* Set ID for this chip */ rc_out (bp,CD180_GICR ,0 );/* Clear all bits */
@@ -280,7 +272,7 @@ static int __init rc_probe(struct riscom_board *bp)rc_wait_CCR (bp);rc_out (bp,CD180_CCR ,CCR_TXEN );/* Enable transmitter */ rc_out (bp,CD180_IER ,IER_TXRDY );/* Enable tx empty intr */ -rc_long_delay (HZ /20 ); +msleep (50 ); irqs =probe_irq_off (irqs); val1 =rc_in (bp,RC_BSR );/* Get Board Status reg */ val2 =rc_in (bp,RC_ACK_TINT );/* ACK interrupt */