Commit e76b1544 authored by Jan Kiszka's avatar Jan Kiszka Committed by David S. Miller

CAPI: Clean up capinc_tty_init/exit

Return proper error code if tty_register_driver fails. In contrast,
tty_unregister_driver cannot practically fail, so drop that error
handling. Finally, mark capinc_tty_init/exit with __init/__exit.
Signed-off-by: default avatarJan Kiszka <jan.kiszka@web.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 81d17fe5
...@@ -1307,9 +1307,10 @@ static const struct tty_operations capinc_ops = { ...@@ -1307,9 +1307,10 @@ static const struct tty_operations capinc_ops = {
.send_xchar = capinc_tty_send_xchar, .send_xchar = capinc_tty_send_xchar,
}; };
static int capinc_tty_init(void) static int __init capinc_tty_init(void)
{ {
struct tty_driver *drv; struct tty_driver *drv;
int err;
if (capi_ttyminors > CAPINC_MAX_PORTS) if (capi_ttyminors > CAPINC_MAX_PORTS)
capi_ttyminors = CAPINC_MAX_PORTS; capi_ttyminors = CAPINC_MAX_PORTS;
...@@ -1340,23 +1341,22 @@ static int capinc_tty_init(void) ...@@ -1340,23 +1341,22 @@ static int capinc_tty_init(void)
drv->init_termios.c_lflag = 0; drv->init_termios.c_lflag = 0;
drv->flags = TTY_DRIVER_REAL_RAW|TTY_DRIVER_RESET_TERMIOS; drv->flags = TTY_DRIVER_REAL_RAW|TTY_DRIVER_RESET_TERMIOS;
tty_set_operations(drv, &capinc_ops); tty_set_operations(drv, &capinc_ops);
if (tty_register_driver(drv)) {
err = tty_register_driver(drv);
if (err) {
put_tty_driver(drv); put_tty_driver(drv);
kfree(capiminors); kfree(capiminors);
printk(KERN_ERR "Couldn't register capi_nc driver\n"); printk(KERN_ERR "Couldn't register capi_nc driver\n");
return -1; return err;
} }
capinc_tty_driver = drv; capinc_tty_driver = drv;
return 0; return 0;
} }
static void capinc_tty_exit(void) static void __exit capinc_tty_exit(void)
{ {
struct tty_driver *drv = capinc_tty_driver; tty_unregister_driver(capinc_tty_driver);
int retval; put_tty_driver(capinc_tty_driver);
if ((retval = tty_unregister_driver(drv)))
printk(KERN_ERR "capi: failed to unregister capi_nc driver (%d)\n", retval);
put_tty_driver(drv);
kfree(capiminors); kfree(capiminors);
} }
......
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