Commit 938ef180 authored by Jiri Slaby's avatar Jiri Slaby Committed by Linus Torvalds

[PATCH] Char: mxser_new, register tty devices on the fly

Register tty indexes only for real devices, udev then creates nodes for them
(and only for them).  Move tty_register_driver before probing, to be correct
when calling tty_register_device.  Also tell tty layer by tty_driver flags,
that we are registering devices.

Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: default avatarJiri Slaby <jirislaby@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent eae4436a
...@@ -2830,12 +2830,19 @@ static int __init mxser_module_init(void) ...@@ -2830,12 +2830,19 @@ static int __init mxser_module_init(void)
mxvar_sdriver->subtype = SERIAL_TYPE_NORMAL; mxvar_sdriver->subtype = SERIAL_TYPE_NORMAL;
mxvar_sdriver->init_termios = tty_std_termios; mxvar_sdriver->init_termios = tty_std_termios;
mxvar_sdriver->init_termios.c_cflag = B9600|CS8|CREAD|HUPCL|CLOCAL; mxvar_sdriver->init_termios.c_cflag = B9600|CS8|CREAD|HUPCL|CLOCAL;
mxvar_sdriver->flags = TTY_DRIVER_REAL_RAW; mxvar_sdriver->flags = TTY_DRIVER_REAL_RAW|TTY_DRIVER_DYNAMIC_DEV;
tty_set_operations(mxvar_sdriver, &mxser_ops); tty_set_operations(mxvar_sdriver, &mxser_ops);
mxvar_sdriver->ttys = mxvar_tty; mxvar_sdriver->ttys = mxvar_tty;
mxvar_sdriver->termios = mxvar_termios; mxvar_sdriver->termios = mxvar_termios;
mxvar_sdriver->termios_locked = mxvar_termios_locked; mxvar_sdriver->termios_locked = mxvar_termios_locked;
retval = tty_register_driver(mxvar_sdriver);
if (retval) {
printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family "
"tty driver !\n");
goto err_put;
}
mxvar_diagflag = 0; mxvar_diagflag = 0;
m = 0; m = 0;
...@@ -2885,6 +2892,10 @@ static int __init mxser_module_init(void) ...@@ -2885,6 +2892,10 @@ static int __init mxser_module_init(void)
if (mxser_initbrd(brd) < 0) if (mxser_initbrd(brd) < 0)
continue; continue;
for (i = 0; i < brd->nports; i++)
tty_register_device(mxvar_sdriver,
m * MXSER_PORTS_PER_BOARD + i, NULL);
m++; m++;
} }
...@@ -2939,6 +2950,11 @@ static int __init mxser_module_init(void) ...@@ -2939,6 +2950,11 @@ static int __init mxser_module_init(void)
/* mxser_initbrd will hook ISR. */ /* mxser_initbrd will hook ISR. */
if (mxser_initbrd(brd) < 0) if (mxser_initbrd(brd) < 0)
continue; continue;
for (i = 0; i < brd->nports; i++)
tty_register_device(mxvar_sdriver,
m * MXSER_PORTS_PER_BOARD + i,
&pdev->dev);
m++; m++;
/* Keep an extra reference if we succeeded. It will /* Keep an extra reference if we succeeded. It will
be returned at unload time */ be returned at unload time */
...@@ -2946,20 +2962,18 @@ static int __init mxser_module_init(void) ...@@ -2946,20 +2962,18 @@ static int __init mxser_module_init(void)
} }
} }
retval = tty_register_driver(mxvar_sdriver); if (!m) {
if (retval) { retval = -ENODEV;
printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family" goto err_unr;
" driver !\n");
put_tty_driver(mxvar_sdriver);
for (i = 0; i < MXSER_BOARDS; i++)
if (mxser_boards[i].board_type != -1)
mxser_release_res(&mxser_boards[i], 1);
return retval;
} }
pr_debug("Done.\n"); pr_debug("Done.\n");
return 0;
err_unr:
tty_unregister_driver(mxvar_sdriver);
err_put:
put_tty_driver(mxvar_sdriver);
return retval; return retval;
} }
...@@ -2969,6 +2983,8 @@ static void __exit mxser_module_exit(void) ...@@ -2969,6 +2983,8 @@ static void __exit mxser_module_exit(void)
pr_debug("Unloading module mxser ...\n"); pr_debug("Unloading module mxser ...\n");
for (i = 0; i < MXSER_PORTS; i++)
tty_unregister_device(mxvar_sdriver, i);
tty_unregister_driver(mxvar_sdriver); tty_unregister_driver(mxvar_sdriver);
put_tty_driver(mxvar_sdriver); put_tty_driver(mxvar_sdriver);
......
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