Commit e415109f authored by Jiri Slaby's avatar Jiri Slaby Committed by Linus Torvalds

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: default avatarJiri Slaby <jirislaby@gmail.com>
Cc: "Ingo Korb" <ingo@akana.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 64834b22
...@@ -4710,6 +4710,29 @@ static int __init stallion_module_init(void) ...@@ -4710,6 +4710,29 @@ static int __init stallion_module_init(void)
spin_lock_init(&stallion_lock); spin_lock_init(&stallion_lock);
spin_lock_init(&brd_lock); spin_lock_init(&brd_lock);
stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
if (!stl_serial) {
retval = -ENOMEM;
goto err;
}
stl_serial->owner = THIS_MODULE;
stl_serial->driver_name = stl_drvname;
stl_serial->name = "ttyE";
stl_serial->major = STL_SERIALMAJOR;
stl_serial->minor_start = 0;
stl_serial->type = TTY_DRIVER_TYPE_SERIAL;
stl_serial->subtype = SERIAL_TYPE_NORMAL;
stl_serial->init_termios = stl_deftermios;
stl_serial->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
tty_set_operations(stl_serial, &stl_ops);
retval = tty_register_driver(stl_serial);
if (retval) {
printk("STALLION: failed to register serial driver\n");
goto err_frtty;
}
/* /*
* Find any dynamically supported boards. That is via module load * Find any dynamically supported boards. That is via module load
* line options. * line options.
...@@ -4739,13 +4762,9 @@ static int __init stallion_module_init(void) ...@@ -4739,13 +4762,9 @@ static int __init stallion_module_init(void)
/* this has to be _after_ isa finding because of locking */ /* this has to be _after_ isa finding because of locking */
retval = pci_register_driver(&stl_pcidriver); retval = pci_register_driver(&stl_pcidriver);
if (retval && stl_nrbrds == 0) if (retval && stl_nrbrds == 0) {
goto err; printk(KERN_ERR "STALLION: can't register pci driver\n");
goto err_unrtty;
stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
if (!stl_serial) {
retval = -ENOMEM;
goto err_pcidr;
} }
/* /*
...@@ -4756,43 +4775,18 @@ static int __init stallion_module_init(void) ...@@ -4756,43 +4775,18 @@ static int __init stallion_module_init(void)
printk("STALLION: failed to register serial board device\n"); printk("STALLION: failed to register serial board device\n");
stallion_class = class_create(THIS_MODULE, "staliomem"); stallion_class = class_create(THIS_MODULE, "staliomem");
if (IS_ERR(stallion_class)) { if (IS_ERR(stallion_class))
retval = PTR_ERR(stallion_class); printk("STALLION: failed to create class\n");
goto err_reg;
}
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
class_device_create(stallion_class, NULL, class_device_create(stallion_class, NULL,
MKDEV(STL_SIOMEMMAJOR, i), NULL, MKDEV(STL_SIOMEMMAJOR, i), NULL,
"staliomem%d", i); "staliomem%d", i);
stl_serial->owner = THIS_MODULE;
stl_serial->driver_name = stl_drvname;
stl_serial->name = "ttyE";
stl_serial->major = STL_SERIALMAJOR;
stl_serial->minor_start = 0;
stl_serial->type = TTY_DRIVER_TYPE_SERIAL;
stl_serial->subtype = SERIAL_TYPE_NORMAL;
stl_serial->init_termios = stl_deftermios;
stl_serial->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
tty_set_operations(stl_serial, &stl_ops);
retval = tty_register_driver(stl_serial);
if (retval) {
printk("STALLION: failed to register serial driver\n");
goto err_clsdev;
}
return 0; return 0;
err_clsdev: err_unrtty:
for (i = 0; i < 4; i++) tty_unregister_driver(stl_serial);
class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i)); err_frtty:
class_destroy(stallion_class);
err_reg:
unregister_chrdev(STL_SIOMEMMAJOR, "staliomem");
put_tty_driver(stl_serial); put_tty_driver(stl_serial);
err_pcidr:
pci_unregister_driver(&stl_pcidriver);
stl_free_isabrds();
err: err:
return retval; return retval;
} }
...@@ -4821,8 +4815,6 @@ static void __exit stallion_module_exit(void) ...@@ -4821,8 +4815,6 @@ static void __exit stallion_module_exit(void)
tty_unregister_device(stl_serial, tty_unregister_device(stl_serial,
brdp->brdnr * STL_MAXPORTS + j); brdp->brdnr * STL_MAXPORTS + j);
} }
tty_unregister_driver(stl_serial);
put_tty_driver(stl_serial);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i)); class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i));
...@@ -4834,6 +4826,9 @@ static void __exit stallion_module_exit(void) ...@@ -4834,6 +4826,9 @@ static void __exit stallion_module_exit(void)
pci_unregister_driver(&stl_pcidriver); pci_unregister_driver(&stl_pcidriver);
stl_free_isabrds(); stl_free_isabrds();
tty_unregister_driver(stl_serial);
put_tty_driver(stl_serial);
} }
module_init(stallion_module_init); module_init(stallion_module_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment