aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/mxser.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/mxser.c')
-rw-r--r--drivers/char/mxser.c48
1 files changed, 17 insertions, 31 deletions
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index 45d012d85e8c..26448f176803 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -38,7 +38,6 @@
38 38
39#include <linux/config.h> 39#include <linux/config.h>
40#include <linux/module.h> 40#include <linux/module.h>
41#include <linux/version.h>
42#include <linux/autoconf.h> 41#include <linux/autoconf.h>
43#include <linux/errno.h> 42#include <linux/errno.h>
44#include <linux/signal.h> 43#include <linux/signal.h>
@@ -470,6 +469,8 @@ static struct tty_operations mxser_ops = {
470 .stop = mxser_stop, 469 .stop = mxser_stop,
471 .start = mxser_start, 470 .start = mxser_start,
472 .hangup = mxser_hangup, 471 .hangup = mxser_hangup,
472 .break_ctl = mxser_rs_break,
473 .wait_until_sent = mxser_wait_until_sent,
473 .tiocmget = mxser_tiocmget, 474 .tiocmget = mxser_tiocmget,
474 .tiocmset = mxser_tiocmset, 475 .tiocmset = mxser_tiocmset,
475}; 476};
@@ -492,14 +493,18 @@ static int __init mxser_module_init(void)
492 493
493static void __exit mxser_module_exit(void) 494static void __exit mxser_module_exit(void)
494{ 495{
495 int i, err = 0; 496 int i, err;
496 497
497 if (verbose) 498 if (verbose)
498 printk(KERN_DEBUG "Unloading module mxser ...\n"); 499 printk(KERN_DEBUG "Unloading module mxser ...\n");
499 500
500 if ((err |= tty_unregister_driver(mxvar_sdriver))) 501 err = tty_unregister_driver(mxvar_sdriver);
502 if (!err)
503 put_tty_driver(mxvar_sdriver);
504 else
501 printk(KERN_ERR "Couldn't unregister MOXA Smartio/Industio family serial driver\n"); 505 printk(KERN_ERR "Couldn't unregister MOXA Smartio/Industio family serial driver\n");
502 506
507
503 for (i = 0; i < MXSER_BOARDS; i++) { 508 for (i = 0; i < MXSER_BOARDS; i++) {
504 struct pci_dev *pdev; 509 struct pci_dev *pdev;
505 510
@@ -688,7 +693,6 @@ static int mxser_get_PCI_conf(int busnum, int devnum, int board_type, struct mxs
688static int mxser_init(void) 693static int mxser_init(void)
689{ 694{
690 int i, m, retval, b, n; 695 int i, m, retval, b, n;
691 int ret1;
692 struct pci_dev *pdev = NULL; 696 struct pci_dev *pdev = NULL;
693 int index; 697 int index;
694 unsigned char busnum, devnum; 698 unsigned char busnum, devnum;
@@ -722,24 +726,6 @@ static int mxser_init(void)
722 mxvar_sdriver->termios = mxvar_termios; 726 mxvar_sdriver->termios = mxvar_termios;
723 mxvar_sdriver->termios_locked = mxvar_termios_locked; 727 mxvar_sdriver->termios_locked = mxvar_termios_locked;
724 728
725 mxvar_sdriver->open = mxser_open;
726 mxvar_sdriver->close = mxser_close;
727 mxvar_sdriver->write = mxser_write;
728 mxvar_sdriver->put_char = mxser_put_char;
729 mxvar_sdriver->flush_chars = mxser_flush_chars;
730 mxvar_sdriver->write_room = mxser_write_room;
731 mxvar_sdriver->chars_in_buffer = mxser_chars_in_buffer;
732 mxvar_sdriver->flush_buffer = mxser_flush_buffer;
733 mxvar_sdriver->ioctl = mxser_ioctl;
734 mxvar_sdriver->throttle = mxser_throttle;
735 mxvar_sdriver->unthrottle = mxser_unthrottle;
736 mxvar_sdriver->set_termios = mxser_set_termios;
737 mxvar_sdriver->stop = mxser_stop;
738 mxvar_sdriver->start = mxser_start;
739 mxvar_sdriver->hangup = mxser_hangup;
740 mxvar_sdriver->break_ctl = mxser_rs_break;
741 mxvar_sdriver->wait_until_sent = mxser_wait_until_sent;
742
743 mxvar_diagflag = 0; 729 mxvar_diagflag = 0;
744 memset(mxvar_table, 0, MXSER_PORTS * sizeof(struct mxser_struct)); 730 memset(mxvar_table, 0, MXSER_PORTS * sizeof(struct mxser_struct));
745 memset(&mxvar_log, 0, sizeof(struct mxser_log)); 731 memset(&mxvar_log, 0, sizeof(struct mxser_log));
@@ -870,14 +856,11 @@ static int mxser_init(void)
870 } 856 }
871#endif 857#endif
872 858
873 ret1 = 0; 859 retval = tty_register_driver(mxvar_sdriver);
874 if (!(ret1 = tty_register_driver(mxvar_sdriver))) { 860 if (retval) {
875 return 0;
876 } else
877 printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family driver !\n"); 861 printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family driver !\n");
862 put_tty_driver(mxvar_sdriver);
878 863
879
880 if (ret1) {
881 for (i = 0; i < MXSER_BOARDS; i++) { 864 for (i = 0; i < MXSER_BOARDS; i++) {
882 if (mxsercfg[i].board_type == -1) 865 if (mxsercfg[i].board_type == -1)
883 continue; 866 continue;
@@ -886,10 +869,10 @@ static int mxser_init(void)
886 //todo: release io, vector 869 //todo: release io, vector
887 } 870 }
888 } 871 }
889 return -1; 872 return retval;
890 } 873 }
891 874
892 return (0); 875 return 0;
893} 876}
894 877
895static void mxser_do_softint(void *private_) 878static void mxser_do_softint(void *private_)
@@ -933,6 +916,9 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
933 struct mxser_struct *info; 916 struct mxser_struct *info;
934 int retval, line; 917 int retval, line;
935 918
919 /* initialize driver_data in case something fails */
920 tty->driver_data = NULL;
921
936 line = tty->index; 922 line = tty->index;
937 if (line == MXSER_PORTS) 923 if (line == MXSER_PORTS)
938 return 0; 924 return 0;
@@ -995,7 +981,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
995 if (tty->index == MXSER_PORTS) 981 if (tty->index == MXSER_PORTS)
996 return; 982 return;
997 if (!info) 983 if (!info)
998 BUG(); 984 return;
999 985
1000 spin_lock_irqsave(&info->slock, flags); 986 spin_lock_irqsave(&info->slock, flags);
1001 987