aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/stallion.c
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2006-12-08 05:38:40 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-08 11:28:55 -0500
commit23b85a152b4598ae007db7d5a5318458ea2fd647 (patch)
tree3e42c461ee32152134b0cd07159fea25ea591873 /drivers/char/stallion.c
parentca7ed0f22f4876986b2eb1fbd80ba78e07fd69d5 (diff)
[PATCH] Char: stallion, move init/deinit
- Move code from stl_init into module init function, because calling it was the only one thing, that it did. - Move this code to the end of the driver (usual place for this) to resolve dependencies simply -- without prototypes. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/stallion.c')
-rw-r--r--drivers/char/stallion.c256
1 files changed, 120 insertions, 136 deletions
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index b108ac6e3d83..f49f145e20ee 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -278,9 +278,6 @@ static struct {
278/* 278/*
279 * Define the module agruments. 279 * Define the module agruments.
280 */ 280 */
281MODULE_AUTHOR("Greg Ungerer");
282MODULE_DESCRIPTION("Stallion Multiport Serial Driver");
283MODULE_LICENSE("GPL");
284 281
285module_param_array(board0, charp, &stl_nargs, 0); 282module_param_array(board0, charp, &stl_nargs, 0);
286MODULE_PARM_DESC(board0, "Board 0 config -> name[,ioaddr[,ioaddr2][,irq]]"); 283MODULE_PARM_DESC(board0, "Board 0 config -> name[,ioaddr[,ioaddr2][,irq]]");
@@ -458,7 +455,6 @@ static int stl_parsebrd(struct stlconf *confp, char **argp);
458 455
459static unsigned long stl_atol(char *str); 456static unsigned long stl_atol(char *str);
460 457
461static int stl_init(void);
462static int stl_open(struct tty_struct *tty, struct file *filp); 458static int stl_open(struct tty_struct *tty, struct file *filp);
463static void stl_close(struct tty_struct *tty, struct file *filp); 459static void stl_close(struct tty_struct *tty, struct file *filp);
464static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count); 460static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count);
@@ -708,91 +704,9 @@ static const struct file_operations stl_fsiomem = {
708 .ioctl = stl_memioctl, 704 .ioctl = stl_memioctl,
709}; 705};
710 706
711/*****************************************************************************/
712
713static struct class *stallion_class; 707static struct class *stallion_class;
714 708
715/* 709/*
716 * Loadable module initialization stuff.
717 */
718
719static int __init stallion_module_init(void)
720{
721 stl_init();
722 return 0;
723}
724
725/*****************************************************************************/
726
727static void __exit stallion_module_exit(void)
728{
729 struct stlbrd *brdp;
730 struct stlpanel *panelp;
731 struct stlport *portp;
732 int i, j, k;
733
734 pr_debug("cleanup_module()\n");
735
736 printk(KERN_INFO "Unloading %s: version %s\n", stl_drvtitle,
737 stl_drvversion);
738
739/*
740 * Free up all allocated resources used by the ports. This includes
741 * memory and interrupts. As part of this process we will also do
742 * a hangup on every open port - to try to flush out any processes
743 * hanging onto ports.
744 */
745 i = tty_unregister_driver(stl_serial);
746 put_tty_driver(stl_serial);
747 if (i) {
748 printk("STALLION: failed to un-register tty driver, "
749 "errno=%d\n", -i);
750 return;
751 }
752 for (i = 0; i < 4; i++)
753 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i));
754 if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
755 printk("STALLION: failed to un-register serial memory device, "
756 "errno=%d\n", -i);
757 class_destroy(stallion_class);
758
759 for (i = 0; (i < stl_nrbrds); i++) {
760 if ((brdp = stl_brds[i]) == NULL)
761 continue;
762
763 free_irq(brdp->irq, brdp);
764
765 for (j = 0; (j < STL_MAXPANELS); j++) {
766 panelp = brdp->panels[j];
767 if (panelp == NULL)
768 continue;
769 for (k = 0; (k < STL_PORTSPERPANEL); k++) {
770 portp = panelp->ports[k];
771 if (portp == NULL)
772 continue;
773 if (portp->tty != NULL)
774 stl_hangup(portp->tty);
775 kfree(portp->tx.buf);
776 kfree(portp);
777 }
778 kfree(panelp);
779 }
780
781 release_region(brdp->ioaddr1, brdp->iosize1);
782 if (brdp->iosize2 > 0)
783 release_region(brdp->ioaddr2, brdp->iosize2);
784
785 kfree(brdp);
786 stl_brds[i] = NULL;
787 }
788}
789
790module_init(stallion_module_init);
791module_exit(stallion_module_exit);
792
793/*****************************************************************************/
794
795/*
796 * Check for any arguments passed in on the module load command line. 710 * Check for any arguments passed in on the module load command line.
797 */ 711 */
798 712
@@ -2935,55 +2849,6 @@ static const struct tty_operations stl_ops = {
2935}; 2849};
2936 2850
2937/*****************************************************************************/ 2851/*****************************************************************************/
2938
2939static int __init stl_init(void)
2940{
2941 int i;
2942 printk(KERN_INFO "%s: version %s\n", stl_drvtitle, stl_drvversion);
2943
2944 spin_lock_init(&stallion_lock);
2945 spin_lock_init(&brd_lock);
2946
2947 stl_initbrds();
2948
2949 stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
2950 if (!stl_serial)
2951 return -1;
2952
2953/*
2954 * Set up a character driver for per board stuff. This is mainly used
2955 * to do stats ioctls on the ports.
2956 */
2957 if (register_chrdev(STL_SIOMEMMAJOR, "staliomem", &stl_fsiomem))
2958 printk("STALLION: failed to register serial board device\n");
2959
2960 stallion_class = class_create(THIS_MODULE, "staliomem");
2961 for (i = 0; i < 4; i++)
2962 class_device_create(stallion_class, NULL,
2963 MKDEV(STL_SIOMEMMAJOR, i), NULL,
2964 "staliomem%d", i);
2965
2966 stl_serial->owner = THIS_MODULE;
2967 stl_serial->driver_name = stl_drvname;
2968 stl_serial->name = "ttyE";
2969 stl_serial->major = STL_SERIALMAJOR;
2970 stl_serial->minor_start = 0;
2971 stl_serial->type = TTY_DRIVER_TYPE_SERIAL;
2972 stl_serial->subtype = SERIAL_TYPE_NORMAL;
2973 stl_serial->init_termios = stl_deftermios;
2974 stl_serial->flags = TTY_DRIVER_REAL_RAW;
2975 tty_set_operations(stl_serial, &stl_ops);
2976
2977 if (tty_register_driver(stl_serial)) {
2978 put_tty_driver(stl_serial);
2979 printk("STALLION: failed to register serial driver\n");
2980 return -1;
2981 }
2982
2983 return 0;
2984}
2985
2986/*****************************************************************************/
2987/* CD1400 HARDWARE FUNCTIONS */ 2852/* CD1400 HARDWARE FUNCTIONS */
2988/*****************************************************************************/ 2853/*****************************************************************************/
2989 2854
@@ -4954,4 +4819,123 @@ static void stl_sc26198otherisr(struct stlport *portp, unsigned int iack)
4954 } 4819 }
4955} 4820}
4956 4821
4957/*****************************************************************************/ 4822/*
4823 * Loadable module initialization stuff.
4824 */
4825static int __init stallion_module_init(void)
4826{
4827 unsigned int i;
4828
4829 printk(KERN_INFO "%s: version %s\n", stl_drvtitle, stl_drvversion);
4830
4831 spin_lock_init(&stallion_lock);
4832 spin_lock_init(&brd_lock);
4833
4834 stl_initbrds();
4835
4836 stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
4837 if (!stl_serial)
4838 return -1;
4839
4840/*
4841 * Set up a character driver for per board stuff. This is mainly used
4842 * to do stats ioctls on the ports.
4843 */
4844 if (register_chrdev(STL_SIOMEMMAJOR, "staliomem", &stl_fsiomem))
4845 printk("STALLION: failed to register serial board device\n");
4846
4847 stallion_class = class_create(THIS_MODULE, "staliomem");
4848 for (i = 0; i < 4; i++)
4849 class_device_create(stallion_class, NULL,
4850 MKDEV(STL_SIOMEMMAJOR, i), NULL,
4851 "staliomem%d", i);
4852
4853 stl_serial->owner = THIS_MODULE;
4854 stl_serial->driver_name = stl_drvname;
4855 stl_serial->name = "ttyE";
4856 stl_serial->major = STL_SERIALMAJOR;
4857 stl_serial->minor_start = 0;
4858 stl_serial->type = TTY_DRIVER_TYPE_SERIAL;
4859 stl_serial->subtype = SERIAL_TYPE_NORMAL;
4860 stl_serial->init_termios = stl_deftermios;
4861 stl_serial->flags = TTY_DRIVER_REAL_RAW;
4862 tty_set_operations(stl_serial, &stl_ops);
4863
4864 if (tty_register_driver(stl_serial)) {
4865 put_tty_driver(stl_serial);
4866 printk("STALLION: failed to register serial driver\n");
4867 return -1;
4868 }
4869
4870 return 0;
4871}
4872
4873static void __exit stallion_module_exit(void)
4874{
4875 struct stlbrd *brdp;
4876 struct stlpanel *panelp;
4877 struct stlport *portp;
4878 int i, j, k;
4879
4880 pr_debug("cleanup_module()\n");
4881
4882 printk(KERN_INFO "Unloading %s: version %s\n", stl_drvtitle,
4883 stl_drvversion);
4884
4885/*
4886 * Free up all allocated resources used by the ports. This includes
4887 * memory and interrupts. As part of this process we will also do
4888 * a hangup on every open port - to try to flush out any processes
4889 * hanging onto ports.
4890 */
4891 i = tty_unregister_driver(stl_serial);
4892 put_tty_driver(stl_serial);
4893 if (i) {
4894 printk("STALLION: failed to un-register tty driver, "
4895 "errno=%d\n", -i);
4896 return;
4897 }
4898 for (i = 0; i < 4; i++)
4899 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i));
4900 if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
4901 printk("STALLION: failed to un-register serial memory device, "
4902 "errno=%d\n", -i);
4903 class_destroy(stallion_class);
4904
4905 for (i = 0; (i < stl_nrbrds); i++) {
4906 if ((brdp = stl_brds[i]) == NULL)
4907 continue;
4908
4909 free_irq(brdp->irq, brdp);
4910
4911 for (j = 0; (j < STL_MAXPANELS); j++) {
4912 panelp = brdp->panels[j];
4913 if (panelp == NULL)
4914 continue;
4915 for (k = 0; (k < STL_PORTSPERPANEL); k++) {
4916 portp = panelp->ports[k];
4917 if (portp == NULL)
4918 continue;
4919 if (portp->tty != NULL)
4920 stl_hangup(portp->tty);
4921 kfree(portp->tx.buf);
4922 kfree(portp);
4923 }
4924 kfree(panelp);
4925 }
4926
4927 release_region(brdp->ioaddr1, brdp->iosize1);
4928 if (brdp->iosize2 > 0)
4929 release_region(brdp->ioaddr2, brdp->iosize2);
4930
4931 kfree(brdp);
4932 stl_brds[i] = NULL;
4933 }
4934}
4935
4936module_init(stallion_module_init);
4937module_exit(stallion_module_exit);
4938
4939MODULE_AUTHOR("Greg Ungerer");
4940MODULE_DESCRIPTION("Stallion Multiport Serial Driver");
4941MODULE_LICENSE("GPL");