diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2008-04-30 03:53:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-30 11:29:43 -0400 |
commit | 2a5413416b6b2fd8a5a38601a4fe3b56a52cfb86 (patch) | |
tree | 42957e12d04a369af4a481ed9b275099dd59348e /drivers/char | |
parent | 2108eba5c531c12f5ae2ed2ef4cee7bf4246897b (diff) |
Char: moxa, serialise timer
- del timer after we are sure it won't be fired again
- make timer scheduling atomic
- don't reschedule timer when all cards have gone
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')
-rw-r--r-- | drivers/char/moxa.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index 797284fe5fce..abcc16eba44f 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c | |||
@@ -846,10 +846,11 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev) | |||
846 | if (ret) | 846 | if (ret) |
847 | goto err_free; | 847 | goto err_free; |
848 | 848 | ||
849 | spin_lock_bh(&moxa_lock); | ||
849 | brd->ready = 1; | 850 | brd->ready = 1; |
850 | |||
851 | if (!timer_pending(&moxaTimer)) | 851 | if (!timer_pending(&moxaTimer)) |
852 | mod_timer(&moxaTimer, jiffies + HZ / 50); | 852 | mod_timer(&moxaTimer, jiffies + HZ / 50); |
853 | spin_unlock_bh(&moxa_lock); | ||
853 | 854 | ||
854 | return 0; | 855 | return 0; |
855 | err_free: | 856 | err_free: |
@@ -1041,13 +1042,6 @@ static void __exit moxa_exit(void) | |||
1041 | { | 1042 | { |
1042 | int i; | 1043 | int i; |
1043 | 1044 | ||
1044 | del_timer_sync(&moxaTimer); | ||
1045 | |||
1046 | if (tty_unregister_driver(moxaDriver)) | ||
1047 | printk(KERN_ERR "Couldn't unregister MOXA Intellio family " | ||
1048 | "serial driver\n"); | ||
1049 | put_tty_driver(moxaDriver); | ||
1050 | |||
1051 | #ifdef CONFIG_PCI | 1045 | #ifdef CONFIG_PCI |
1052 | pci_unregister_driver(&moxa_pci_driver); | 1046 | pci_unregister_driver(&moxa_pci_driver); |
1053 | #endif | 1047 | #endif |
@@ -1055,6 +1049,13 @@ static void __exit moxa_exit(void) | |||
1055 | for (i = 0; i < MAX_BOARDS; i++) /* ISA boards */ | 1049 | for (i = 0; i < MAX_BOARDS; i++) /* ISA boards */ |
1056 | if (moxa_boards[i].ready) | 1050 | if (moxa_boards[i].ready) |
1057 | moxa_board_deinit(&moxa_boards[i]); | 1051 | moxa_board_deinit(&moxa_boards[i]); |
1052 | |||
1053 | del_timer_sync(&moxaTimer); | ||
1054 | |||
1055 | if (tty_unregister_driver(moxaDriver)) | ||
1056 | printk(KERN_ERR "Couldn't unregister MOXA Intellio family " | ||
1057 | "serial driver\n"); | ||
1058 | put_tty_driver(moxaDriver); | ||
1058 | } | 1059 | } |
1059 | 1060 | ||
1060 | module_init(moxa_init); | 1061 | module_init(moxa_init); |
@@ -1432,7 +1433,7 @@ static void moxa_poll(unsigned long ignored) | |||
1432 | { | 1433 | { |
1433 | struct moxa_board_conf *brd; | 1434 | struct moxa_board_conf *brd; |
1434 | u16 __iomem *ip; | 1435 | u16 __iomem *ip; |
1435 | unsigned int card, port; | 1436 | unsigned int card, port, served = 0; |
1436 | 1437 | ||
1437 | spin_lock(&moxa_lock); | 1438 | spin_lock(&moxa_lock); |
1438 | for (card = 0; card < MAX_BOARDS; card++) { | 1439 | for (card = 0; card < MAX_BOARDS; card++) { |
@@ -1440,6 +1441,8 @@ static void moxa_poll(unsigned long ignored) | |||
1440 | if (!brd->ready) | 1441 | if (!brd->ready) |
1441 | continue; | 1442 | continue; |
1442 | 1443 | ||
1444 | served++; | ||
1445 | |||
1443 | ip = NULL; | 1446 | ip = NULL; |
1444 | if (readb(brd->intPend) == 0xff) | 1447 | if (readb(brd->intPend) == 0xff) |
1445 | ip = brd->intTable + readb(brd->intNdx); | 1448 | ip = brd->intTable + readb(brd->intNdx); |
@@ -1460,9 +1463,10 @@ static void moxa_poll(unsigned long ignored) | |||
1460 | } | 1463 | } |
1461 | } | 1464 | } |
1462 | moxaLowWaterChk = 0; | 1465 | moxaLowWaterChk = 0; |
1463 | spin_unlock(&moxa_lock); | ||
1464 | 1466 | ||
1465 | mod_timer(&moxaTimer, jiffies + HZ / 50); | 1467 | if (served) |
1468 | mod_timer(&moxaTimer, jiffies + HZ / 50); | ||
1469 | spin_unlock(&moxa_lock); | ||
1466 | } | 1470 | } |
1467 | 1471 | ||
1468 | /******************************************************************************/ | 1472 | /******************************************************************************/ |