aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/moxa.c54
1 files changed, 14 insertions, 40 deletions
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index 80a2bdf7b92c..84797a090a97 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -210,13 +210,6 @@ module_param_array(numports, int, NULL, 0);
210module_param(ttymajor, int, 0); 210module_param(ttymajor, int, 0);
211module_param(verbose, bool, 0644); 211module_param(verbose, bool, 0644);
212 212
213static struct tty_driver *moxaDriver;
214static struct moxa_str moxaChannels[MAX_PORTS];
215static int moxaTimer_on;
216static struct timer_list moxaTimer;
217static int moxaEmptyTimer_on[MAX_PORTS];
218static struct timer_list moxaEmptyTimer[MAX_PORTS];
219
220/* 213/*
221 * static functions: 214 * static functions:
222 */ 215 */
@@ -300,6 +293,10 @@ static const struct tty_operations moxa_ops = {
300 .tiocmset = moxa_tiocmset, 293 .tiocmset = moxa_tiocmset,
301}; 294};
302 295
296static struct tty_driver *moxaDriver;
297static struct moxa_str moxaChannels[MAX_PORTS];
298static DEFINE_TIMER(moxaTimer, moxa_poll, 0, 0);
299static struct timer_list moxaEmptyTimer[MAX_PORTS];
303static DEFINE_SPINLOCK(moxa_lock); 300static DEFINE_SPINLOCK(moxa_lock);
304 301
305#ifdef CONFIG_PCI 302#ifdef CONFIG_PCI
@@ -372,17 +369,11 @@ static int __init moxa_init(void)
372 put_tty_driver(moxaDriver); 369 put_tty_driver(moxaDriver);
373 return -1; 370 return -1;
374 } 371 }
375 for (i = 0; i < MAX_PORTS; i++) { 372 for (i = 0; i < MAX_PORTS; i++)
376 init_timer(&moxaEmptyTimer[i]); 373 setup_timer(&moxaEmptyTimer[i], check_xmit_empty,
377 moxaEmptyTimer[i].function = check_xmit_empty; 374 (unsigned long)&moxaChannels[i]);
378 moxaEmptyTimer[i].data = (unsigned long) & moxaChannels[i];
379 }
380 375
381 init_timer(&moxaTimer); 376 mod_timer(&moxaTimer, jiffies + HZ / 50);
382 moxaTimer.function = moxa_poll;
383 moxaTimer.expires = jiffies + (HZ / 50);
384 moxaTimer_on = 1;
385 add_timer(&moxaTimer);
386 377
387 /* Find the boards defined in source code */ 378 /* Find the boards defined in source code */
388 numBoards = 0; 379 numBoards = 0;
@@ -468,12 +459,10 @@ static void __exit moxa_exit(void)
468 if (verbose) 459 if (verbose)
469 printk("Unloading module moxa ...\n"); 460 printk("Unloading module moxa ...\n");
470 461
471 if (moxaTimer_on) 462 del_timer(&moxaTimer);
472 del_timer(&moxaTimer);
473 463
474 for (i = 0; i < MAX_PORTS; i++) 464 for (i = 0; i < MAX_PORTS; i++)
475 if (moxaEmptyTimer_on[i]) 465 del_timer(&moxaEmptyTimer[i]);
476 del_timer(&moxaEmptyTimer[i]);
477 466
478 if (tty_unregister_driver(moxaDriver)) 467 if (tty_unregister_driver(moxaDriver))
479 printk("Couldn't unregister MOXA Intellio family serial driver\n"); 468 printk("Couldn't unregister MOXA Intellio family serial driver\n");
@@ -589,7 +578,6 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
589 if (ch->asyncflags & ASYNC_INITIALIZED) { 578 if (ch->asyncflags & ASYNC_INITIALIZED) {
590 setup_empty_event(tty); 579 setup_empty_event(tty);
591 tty_wait_until_sent(tty, 30 * HZ); /* 30 seconds timeout */ 580 tty_wait_until_sent(tty, 30 * HZ); /* 30 seconds timeout */
592 moxaEmptyTimer_on[ch->port] = 0;
593 del_timer(&moxaEmptyTimer[ch->port]); 581 del_timer(&moxaEmptyTimer[ch->port]);
594 } 582 }
595 shut_down(ch); 583 shut_down(ch);
@@ -885,14 +873,10 @@ static void moxa_poll(unsigned long ignored)
885 struct tty_struct *tp; 873 struct tty_struct *tp;
886 int i, ports; 874 int i, ports;
887 875
888 moxaTimer_on = 0;
889 del_timer(&moxaTimer); 876 del_timer(&moxaTimer);
890 877
891 if (MoxaDriverPoll() < 0) { 878 if (MoxaDriverPoll() < 0) {
892 moxaTimer.function = moxa_poll; 879 mod_timer(&moxaTimer, jiffies + HZ / 50);
893 moxaTimer.expires = jiffies + (HZ / 50);
894 moxaTimer_on = 1;
895 add_timer(&moxaTimer);
896 return; 880 return;
897 } 881 }
898 for (card = 0; card < MAX_BOARDS; card++) { 882 for (card = 0; card < MAX_BOARDS; card++) {
@@ -932,10 +916,7 @@ static void moxa_poll(unsigned long ignored)
932 } 916 }
933 } 917 }
934 918
935 moxaTimer.function = moxa_poll; 919 mod_timer(&moxaTimer, jiffies + HZ / 50);
936 moxaTimer.expires = jiffies + (HZ / 50);
937 moxaTimer_on = 1;
938 add_timer(&moxaTimer);
939} 920}
940 921
941/******************************************************************************/ 922/******************************************************************************/
@@ -1062,11 +1043,7 @@ static void setup_empty_event(struct tty_struct *tty)
1062 1043
1063 spin_lock_irqsave(&moxa_lock, flags); 1044 spin_lock_irqsave(&moxa_lock, flags);
1064 ch->statusflags |= EMPTYWAIT; 1045 ch->statusflags |= EMPTYWAIT;
1065 moxaEmptyTimer_on[ch->port] = 0; 1046 mod_timer(&moxaEmptyTimer[ch->port], jiffies + HZ);
1066 del_timer(&moxaEmptyTimer[ch->port]);
1067 moxaEmptyTimer[ch->port].expires = jiffies + HZ;
1068 moxaEmptyTimer_on[ch->port] = 1;
1069 add_timer(&moxaEmptyTimer[ch->port]);
1070 spin_unlock_irqrestore(&moxa_lock, flags); 1047 spin_unlock_irqrestore(&moxa_lock, flags);
1071} 1048}
1072 1049
@@ -1075,7 +1052,6 @@ static void check_xmit_empty(unsigned long data)
1075 struct moxa_str *ch; 1052 struct moxa_str *ch;
1076 1053
1077 ch = (struct moxa_str *) data; 1054 ch = (struct moxa_str *) data;
1078 moxaEmptyTimer_on[ch->port] = 0;
1079 del_timer(&moxaEmptyTimer[ch->port]); 1055 del_timer(&moxaEmptyTimer[ch->port]);
1080 if (ch->tty && (ch->statusflags & EMPTYWAIT)) { 1056 if (ch->tty && (ch->statusflags & EMPTYWAIT)) {
1081 if (MoxaPortTxQueue(ch->port) == 0) { 1057 if (MoxaPortTxQueue(ch->port) == 0) {
@@ -1083,9 +1059,7 @@ static void check_xmit_empty(unsigned long data)
1083 tty_wakeup(ch->tty); 1059 tty_wakeup(ch->tty);
1084 return; 1060 return;
1085 } 1061 }
1086 moxaEmptyTimer[ch->port].expires = jiffies + HZ; 1062 mod_timer(&moxaEmptyTimer[ch->port], jiffies + HZ);
1087 moxaEmptyTimer_on[ch->port] = 1;
1088 add_timer(&moxaEmptyTimer[ch->port]);
1089 } else 1063 } else
1090 ch->statusflags &= ~EMPTYWAIT; 1064 ch->statusflags &= ~EMPTYWAIT;
1091} 1065}