diff options
Diffstat (limited to 'drivers/char/mxser.c')
-rw-r--r-- | drivers/char/mxser.c | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index 45d012d85e8c..3b965a651da4 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c | |||
@@ -470,6 +470,8 @@ static struct tty_operations mxser_ops = { | |||
470 | .stop = mxser_stop, | 470 | .stop = mxser_stop, |
471 | .start = mxser_start, | 471 | .start = mxser_start, |
472 | .hangup = mxser_hangup, | 472 | .hangup = mxser_hangup, |
473 | .break_ctl = mxser_rs_break, | ||
474 | .wait_until_sent = mxser_wait_until_sent, | ||
473 | .tiocmget = mxser_tiocmget, | 475 | .tiocmget = mxser_tiocmget, |
474 | .tiocmset = mxser_tiocmset, | 476 | .tiocmset = mxser_tiocmset, |
475 | }; | 477 | }; |
@@ -492,14 +494,18 @@ static int __init mxser_module_init(void) | |||
492 | 494 | ||
493 | static void __exit mxser_module_exit(void) | 495 | static void __exit mxser_module_exit(void) |
494 | { | 496 | { |
495 | int i, err = 0; | 497 | int i, err; |
496 | 498 | ||
497 | if (verbose) | 499 | if (verbose) |
498 | printk(KERN_DEBUG "Unloading module mxser ...\n"); | 500 | printk(KERN_DEBUG "Unloading module mxser ...\n"); |
499 | 501 | ||
500 | if ((err |= tty_unregister_driver(mxvar_sdriver))) | 502 | err = tty_unregister_driver(mxvar_sdriver); |
503 | if (!err) | ||
504 | put_tty_driver(mxvar_sdriver); | ||
505 | else | ||
501 | printk(KERN_ERR "Couldn't unregister MOXA Smartio/Industio family serial driver\n"); | 506 | printk(KERN_ERR "Couldn't unregister MOXA Smartio/Industio family serial driver\n"); |
502 | 507 | ||
508 | |||
503 | for (i = 0; i < MXSER_BOARDS; i++) { | 509 | for (i = 0; i < MXSER_BOARDS; i++) { |
504 | struct pci_dev *pdev; | 510 | struct pci_dev *pdev; |
505 | 511 | ||
@@ -688,7 +694,6 @@ static int mxser_get_PCI_conf(int busnum, int devnum, int board_type, struct mxs | |||
688 | static int mxser_init(void) | 694 | static int mxser_init(void) |
689 | { | 695 | { |
690 | int i, m, retval, b, n; | 696 | int i, m, retval, b, n; |
691 | int ret1; | ||
692 | struct pci_dev *pdev = NULL; | 697 | struct pci_dev *pdev = NULL; |
693 | int index; | 698 | int index; |
694 | unsigned char busnum, devnum; | 699 | unsigned char busnum, devnum; |
@@ -722,24 +727,6 @@ static int mxser_init(void) | |||
722 | mxvar_sdriver->termios = mxvar_termios; | 727 | mxvar_sdriver->termios = mxvar_termios; |
723 | mxvar_sdriver->termios_locked = mxvar_termios_locked; | 728 | mxvar_sdriver->termios_locked = mxvar_termios_locked; |
724 | 729 | ||
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; | 730 | mxvar_diagflag = 0; |
744 | memset(mxvar_table, 0, MXSER_PORTS * sizeof(struct mxser_struct)); | 731 | memset(mxvar_table, 0, MXSER_PORTS * sizeof(struct mxser_struct)); |
745 | memset(&mxvar_log, 0, sizeof(struct mxser_log)); | 732 | memset(&mxvar_log, 0, sizeof(struct mxser_log)); |
@@ -870,14 +857,11 @@ static int mxser_init(void) | |||
870 | } | 857 | } |
871 | #endif | 858 | #endif |
872 | 859 | ||
873 | ret1 = 0; | 860 | retval = tty_register_driver(mxvar_sdriver); |
874 | if (!(ret1 = tty_register_driver(mxvar_sdriver))) { | 861 | if (retval) { |
875 | return 0; | ||
876 | } else | ||
877 | printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family driver !\n"); | 862 | printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family driver !\n"); |
863 | put_tty_driver(mxvar_sdriver); | ||
878 | 864 | ||
879 | |||
880 | if (ret1) { | ||
881 | for (i = 0; i < MXSER_BOARDS; i++) { | 865 | for (i = 0; i < MXSER_BOARDS; i++) { |
882 | if (mxsercfg[i].board_type == -1) | 866 | if (mxsercfg[i].board_type == -1) |
883 | continue; | 867 | continue; |
@@ -886,10 +870,10 @@ static int mxser_init(void) | |||
886 | //todo: release io, vector | 870 | //todo: release io, vector |
887 | } | 871 | } |
888 | } | 872 | } |
889 | return -1; | 873 | return retval; |
890 | } | 874 | } |
891 | 875 | ||
892 | return (0); | 876 | return 0; |
893 | } | 877 | } |
894 | 878 | ||
895 | static void mxser_do_softint(void *private_) | 879 | static void mxser_do_softint(void *private_) |
@@ -933,6 +917,9 @@ static int mxser_open(struct tty_struct *tty, struct file *filp) | |||
933 | struct mxser_struct *info; | 917 | struct mxser_struct *info; |
934 | int retval, line; | 918 | int retval, line; |
935 | 919 | ||
920 | /* initialize driver_data in case something fails */ | ||
921 | tty->driver_data = NULL; | ||
922 | |||
936 | line = tty->index; | 923 | line = tty->index; |
937 | if (line == MXSER_PORTS) | 924 | if (line == MXSER_PORTS) |
938 | return 0; | 925 | return 0; |
@@ -995,7 +982,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) | |||
995 | if (tty->index == MXSER_PORTS) | 982 | if (tty->index == MXSER_PORTS) |
996 | return; | 983 | return; |
997 | if (!info) | 984 | if (!info) |
998 | BUG(); | 985 | return; |
999 | 986 | ||
1000 | spin_lock_irqsave(&info->slock, flags); | 987 | spin_lock_irqsave(&info->slock, flags); |
1001 | 988 | ||