aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/stallion.c
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2007-06-08 16:46:52 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-06-08 20:23:33 -0400
commite415109f5a1ec9ca7dac4fad2b852113ce303c96 (patch)
treeef088e17cc9591caac6dcc4a918a424ffc4f81f6 /drivers/char/stallion.c
parent64834b226b237e654ab164d3af88ceaa65f10362 (diff)
Char: stallion, alloc tty before pci devices init
this causes oops, because pci probe function calls tty_register_device for each device found. Thanks to Ingo. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Cc: "Ingo Korb" <ingo@akana.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/stallion.c')
-rw-r--r--drivers/char/stallion.c73
1 files changed, 34 insertions, 39 deletions
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 265abadcf776..23ea4c881f58 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -4710,6 +4710,29 @@ static int __init stallion_module_init(void)
4710 spin_lock_init(&stallion_lock); 4710 spin_lock_init(&stallion_lock);
4711 spin_lock_init(&brd_lock); 4711 spin_lock_init(&brd_lock);
4712 4712
4713 stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
4714 if (!stl_serial) {
4715 retval = -ENOMEM;
4716 goto err;
4717 }
4718
4719 stl_serial->owner = THIS_MODULE;
4720 stl_serial->driver_name = stl_drvname;
4721 stl_serial->name = "ttyE";
4722 stl_serial->major = STL_SERIALMAJOR;
4723 stl_serial->minor_start = 0;
4724 stl_serial->type = TTY_DRIVER_TYPE_SERIAL;
4725 stl_serial->subtype = SERIAL_TYPE_NORMAL;
4726 stl_serial->init_termios = stl_deftermios;
4727 stl_serial->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
4728 tty_set_operations(stl_serial, &stl_ops);
4729
4730 retval = tty_register_driver(stl_serial);
4731 if (retval) {
4732 printk("STALLION: failed to register serial driver\n");
4733 goto err_frtty;
4734 }
4735
4713/* 4736/*
4714 * Find any dynamically supported boards. That is via module load 4737 * Find any dynamically supported boards. That is via module load
4715 * line options. 4738 * line options.
@@ -4739,13 +4762,9 @@ static int __init stallion_module_init(void)
4739 4762
4740 /* this has to be _after_ isa finding because of locking */ 4763 /* this has to be _after_ isa finding because of locking */
4741 retval = pci_register_driver(&stl_pcidriver); 4764 retval = pci_register_driver(&stl_pcidriver);
4742 if (retval && stl_nrbrds == 0) 4765 if (retval && stl_nrbrds == 0) {
4743 goto err; 4766 printk(KERN_ERR "STALLION: can't register pci driver\n");
4744 4767 goto err_unrtty;
4745 stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
4746 if (!stl_serial) {
4747 retval = -ENOMEM;
4748 goto err_pcidr;
4749 } 4768 }
4750 4769
4751/* 4770/*
@@ -4756,43 +4775,18 @@ static int __init stallion_module_init(void)
4756 printk("STALLION: failed to register serial board device\n"); 4775 printk("STALLION: failed to register serial board device\n");
4757 4776
4758 stallion_class = class_create(THIS_MODULE, "staliomem"); 4777 stallion_class = class_create(THIS_MODULE, "staliomem");
4759 if (IS_ERR(stallion_class)) { 4778 if (IS_ERR(stallion_class))
4760 retval = PTR_ERR(stallion_class); 4779 printk("STALLION: failed to create class\n");
4761 goto err_reg;
4762 }
4763 for (i = 0; i < 4; i++) 4780 for (i = 0; i < 4; i++)
4764 class_device_create(stallion_class, NULL, 4781 class_device_create(stallion_class, NULL,
4765 MKDEV(STL_SIOMEMMAJOR, i), NULL, 4782 MKDEV(STL_SIOMEMMAJOR, i), NULL,
4766 "staliomem%d", i); 4783 "staliomem%d", i);
4767 4784
4768 stl_serial->owner = THIS_MODULE;
4769 stl_serial->driver_name = stl_drvname;
4770 stl_serial->name = "ttyE";
4771 stl_serial->major = STL_SERIALMAJOR;
4772 stl_serial->minor_start = 0;
4773 stl_serial->type = TTY_DRIVER_TYPE_SERIAL;
4774 stl_serial->subtype = SERIAL_TYPE_NORMAL;
4775 stl_serial->init_termios = stl_deftermios;
4776 stl_serial->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
4777 tty_set_operations(stl_serial, &stl_ops);
4778
4779 retval = tty_register_driver(stl_serial);
4780 if (retval) {
4781 printk("STALLION: failed to register serial driver\n");
4782 goto err_clsdev;
4783 }
4784
4785 return 0; 4785 return 0;
4786err_clsdev: 4786err_unrtty:
4787 for (i = 0; i < 4; i++) 4787 tty_unregister_driver(stl_serial);
4788 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i)); 4788err_frtty:
4789 class_destroy(stallion_class);
4790err_reg:
4791 unregister_chrdev(STL_SIOMEMMAJOR, "staliomem");
4792 put_tty_driver(stl_serial); 4789 put_tty_driver(stl_serial);
4793err_pcidr:
4794 pci_unregister_driver(&stl_pcidriver);
4795 stl_free_isabrds();
4796err: 4790err:
4797 return retval; 4791 return retval;
4798} 4792}
@@ -4821,8 +4815,6 @@ static void __exit stallion_module_exit(void)
4821 tty_unregister_device(stl_serial, 4815 tty_unregister_device(stl_serial,
4822 brdp->brdnr * STL_MAXPORTS + j); 4816 brdp->brdnr * STL_MAXPORTS + j);
4823 } 4817 }
4824 tty_unregister_driver(stl_serial);
4825 put_tty_driver(stl_serial);
4826 4818
4827 for (i = 0; i < 4; i++) 4819 for (i = 0; i < 4; i++)
4828 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i)); 4820 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i));
@@ -4834,6 +4826,9 @@ static void __exit stallion_module_exit(void)
4834 pci_unregister_driver(&stl_pcidriver); 4826 pci_unregister_driver(&stl_pcidriver);
4835 4827
4836 stl_free_isabrds(); 4828 stl_free_isabrds();
4829
4830 tty_unregister_driver(stl_serial);
4831 put_tty_driver(stl_serial);
4837} 4832}
4838 4833
4839module_init(stallion_module_init); 4834module_init(stallion_module_init);