diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2008-04-30 03:53:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-30 11:29:42 -0400 |
commit | 0bcc4caadc8f5396b52950ee03c67b76875602df (patch) | |
tree | 7d820dd1d4668cae11ad029695e9fa4b0410b10a /drivers/char/moxa.c | |
parent | 810ab09b2f3a4e9a6f553e3d1e84a27f4074de9c (diff) |
Char: moxa, timer cleanup
- schedule timer even after some card is installed, not after insmod
- cleanup timer functions
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Tested-by: Oyvind Aabling <Oyvind.Aabling@uni-c.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/moxa.c')
-rw-r--r-- | drivers/char/moxa.c | 62 |
1 files changed, 21 insertions, 41 deletions
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index b2f3de0195c9..fdfa7783e992 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c | |||
@@ -215,7 +215,6 @@ static void moxa_receive_data(struct moxa_port *); | |||
215 | */ | 215 | */ |
216 | static int MoxaDriverIoctl(struct tty_struct *, unsigned int, unsigned long); | 216 | static int MoxaDriverIoctl(struct tty_struct *, unsigned int, unsigned long); |
217 | static int MoxaDriverPoll(void); | 217 | static int MoxaDriverPoll(void); |
218 | static int MoxaPortsOfCard(int); | ||
219 | static void MoxaPortEnable(struct moxa_port *); | 218 | static void MoxaPortEnable(struct moxa_port *); |
220 | static void MoxaPortDisable(struct moxa_port *); | 219 | static void MoxaPortDisable(struct moxa_port *); |
221 | static int MoxaPortSetTermio(struct moxa_port *, struct ktermios *, speed_t); | 220 | static int MoxaPortSetTermio(struct moxa_port *, struct ktermios *, speed_t); |
@@ -715,6 +714,9 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev) | |||
715 | 714 | ||
716 | brd->ready = 1; | 715 | brd->ready = 1; |
717 | 716 | ||
717 | if (!timer_pending(&moxaTimer)) | ||
718 | mod_timer(&moxaTimer, jiffies + HZ / 50); | ||
719 | |||
718 | return 0; | 720 | return 0; |
719 | err_free: | 721 | err_free: |
720 | kfree(brd->ports); | 722 | kfree(brd->ports); |
@@ -856,8 +858,6 @@ static int __init moxa_init(void) | |||
856 | return -1; | 858 | return -1; |
857 | } | 859 | } |
858 | 860 | ||
859 | mod_timer(&moxaTimer, jiffies + HZ / 50); | ||
860 | |||
861 | /* Find the boards defined from module args. */ | 861 | /* Find the boards defined from module args. */ |
862 | #ifdef MODULE | 862 | #ifdef MODULE |
863 | { | 863 | { |
@@ -1285,10 +1285,10 @@ static void moxa_hangup(struct tty_struct *tty) | |||
1285 | 1285 | ||
1286 | static void moxa_poll(unsigned long ignored) | 1286 | static void moxa_poll(unsigned long ignored) |
1287 | { | 1287 | { |
1288 | register int card; | ||
1289 | struct moxa_port *ch; | 1288 | struct moxa_port *ch; |
1290 | struct tty_struct *tp; | 1289 | struct tty_struct *tty; |
1291 | int i, ports; | 1290 | unsigned int card; |
1291 | int i; | ||
1292 | 1292 | ||
1293 | del_timer(&moxaTimer); | 1293 | del_timer(&moxaTimer); |
1294 | 1294 | ||
@@ -1296,36 +1296,38 @@ static void moxa_poll(unsigned long ignored) | |||
1296 | mod_timer(&moxaTimer, jiffies + HZ / 50); | 1296 | mod_timer(&moxaTimer, jiffies + HZ / 50); |
1297 | return; | 1297 | return; |
1298 | } | 1298 | } |
1299 | |||
1299 | for (card = 0; card < MAX_BOARDS; card++) { | 1300 | for (card = 0; card < MAX_BOARDS; card++) { |
1300 | if ((ports = MoxaPortsOfCard(card)) <= 0) | 1301 | if (!moxa_boards[card].ready) |
1301 | continue; | 1302 | continue; |
1302 | ch = moxa_boards[card].ports; | 1303 | ch = moxa_boards[card].ports; |
1303 | for (i = 0; i < ports; i++, ch++) { | 1304 | for (i = 0; i < moxa_boards[card].numPorts; i++, ch++) { |
1304 | if ((ch->asyncflags & ASYNC_INITIALIZED) == 0) | 1305 | if ((ch->asyncflags & ASYNC_INITIALIZED) == 0) |
1305 | continue; | 1306 | continue; |
1306 | if (!(ch->statusflags & THROTTLE) && | 1307 | if (!(ch->statusflags & THROTTLE) && |
1307 | (MoxaPortRxQueue(ch) > 0)) | 1308 | (MoxaPortRxQueue(ch) > 0)) |
1308 | moxa_receive_data(ch); | 1309 | moxa_receive_data(ch); |
1309 | if ((tp = ch->tty) == 0) | 1310 | tty = ch->tty; |
1311 | if (tty == NULL) | ||
1310 | continue; | 1312 | continue; |
1311 | if (ch->statusflags & LOWWAIT) { | 1313 | if (ch->statusflags & LOWWAIT) { |
1312 | if (MoxaPortTxQueue(ch) <= WAKEUP_CHARS) { | 1314 | if (MoxaPortTxQueue(ch) <= WAKEUP_CHARS) { |
1313 | if (!tp->stopped) { | 1315 | if (!tty->stopped) { |
1314 | ch->statusflags &= ~LOWWAIT; | 1316 | ch->statusflags &= ~LOWWAIT; |
1315 | tty_wakeup(tp); | 1317 | tty_wakeup(tty); |
1316 | } | 1318 | } |
1317 | } | 1319 | } |
1318 | } | 1320 | } |
1319 | if (!I_IGNBRK(tp) && (MoxaPortResetBrkCnt(ch) > 0)) { | 1321 | if (!I_IGNBRK(tty) && (MoxaPortResetBrkCnt(ch) > 0)) { |
1320 | tty_insert_flip_char(tp, 0, TTY_BREAK); | 1322 | tty_insert_flip_char(tty, 0, TTY_BREAK); |
1321 | tty_schedule_flip(tp); | 1323 | tty_schedule_flip(tty); |
1322 | } | 1324 | } |
1323 | if (MoxaPortDCDChange(ch)) { | 1325 | if (MoxaPortDCDChange(ch)) { |
1324 | if (ch->asyncflags & ASYNC_CHECK_CD) { | 1326 | if (ch->asyncflags & ASYNC_CHECK_CD) { |
1325 | if (MoxaPortDCDON(ch)) | 1327 | if (MoxaPortDCDON(ch)) |
1326 | wake_up_interruptible(&ch->open_wait); | 1328 | wake_up_interruptible(&ch->open_wait); |
1327 | else { | 1329 | else { |
1328 | tty_hangup(tp); | 1330 | tty_hangup(tty); |
1329 | wake_up_interruptible(&ch->open_wait); | 1331 | wake_up_interruptible(&ch->open_wait); |
1330 | ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE; | 1332 | ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE; |
1331 | } | 1333 | } |
@@ -1671,15 +1673,14 @@ copy: | |||
1671 | return -ENOIOCTLCMD; | 1673 | return -ENOIOCTLCMD; |
1672 | } | 1674 | } |
1673 | 1675 | ||
1674 | int MoxaDriverPoll(void) | 1676 | static int MoxaDriverPoll(void) |
1675 | { | 1677 | { |
1676 | struct moxa_board_conf *brd; | 1678 | struct moxa_board_conf *brd; |
1677 | struct moxa_port *p; | 1679 | struct moxa_port *p; |
1678 | register ushort temp; | ||
1679 | register int card; | ||
1680 | void __iomem *ofsAddr; | 1680 | void __iomem *ofsAddr; |
1681 | void __iomem *ip; | 1681 | void __iomem *ip; |
1682 | int port, ports; | 1682 | unsigned int port, ports, card; |
1683 | ushort temp; | ||
1683 | 1684 | ||
1684 | for (card = 0; card < MAX_BOARDS; card++) { | 1685 | for (card = 0; card < MAX_BOARDS; card++) { |
1685 | brd = &moxa_boards[card]; | 1686 | brd = &moxa_boards[card]; |
@@ -1729,19 +1730,8 @@ int MoxaDriverPoll(void) | |||
1729 | } | 1730 | } |
1730 | } | 1731 | } |
1731 | moxaLowWaterChk = 0; | 1732 | moxaLowWaterChk = 0; |
1732 | return (0); | ||
1733 | } | ||
1734 | 1733 | ||
1735 | /***************************************************************************** | 1734 | return 0; |
1736 | * Card level function: * | ||
1737 | * 1. MoxaPortsOfCard(int cardno); * | ||
1738 | *****************************************************************************/ | ||
1739 | int MoxaPortsOfCard(int cardno) | ||
1740 | { | ||
1741 | |||
1742 | if (moxa_boards[cardno].boardType == 0) | ||
1743 | return (0); | ||
1744 | return (moxa_boards[cardno].numPorts); | ||
1745 | } | 1735 | } |
1746 | 1736 | ||
1747 | /***************************************************************************** | 1737 | /***************************************************************************** |
@@ -1812,16 +1802,6 @@ int MoxaPortsOfCard(int cardno) | |||
1812 | * -1 : no any Moxa card. | 1802 | * -1 : no any Moxa card. |
1813 | * | 1803 | * |
1814 | * | 1804 | * |
1815 | * Function 4: Get the ports of this card. | ||
1816 | * Syntax: | ||
1817 | * int MoxaPortsOfCard(int cardno); | ||
1818 | * | ||
1819 | * int cardno : card number (0 - 3) | ||
1820 | * | ||
1821 | * return: 0 : this card is invalid | ||
1822 | * 8/16/24/32 | ||
1823 | * | ||
1824 | * | ||
1825 | * Function 6: Enable this port to start Tx/Rx data. | 1805 | * Function 6: Enable this port to start Tx/Rx data. |
1826 | * Syntax: | 1806 | * Syntax: |
1827 | * void MoxaPortEnable(int port); | 1807 | * void MoxaPortEnable(int port); |