aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2006-12-08 05:38:28 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-08 11:28:54 -0500
commit938ef1804049eb1c527e25568ff70c6a2a2bfdcc (patch)
tree4949a467047bb88561168a1e5af6eee5948996c3 /drivers
parenteae4436a4e513f5f912dcc5dac79038f22fb6403 (diff)
[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: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/mxser_new.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/drivers/char/mxser_new.c b/drivers/char/mxser_new.c
index 27871e503d80..e665dfccd956 100644
--- a/drivers/char/mxser_new.c
+++ b/drivers/char/mxser_new.c
@@ -2830,12 +2830,19 @@ static int __init mxser_module_init(void)
2830 mxvar_sdriver->subtype = SERIAL_TYPE_NORMAL; 2830 mxvar_sdriver->subtype = SERIAL_TYPE_NORMAL;
2831 mxvar_sdriver->init_termios = tty_std_termios; 2831 mxvar_sdriver->init_termios = tty_std_termios;
2832 mxvar_sdriver->init_termios.c_cflag = B9600|CS8|CREAD|HUPCL|CLOCAL; 2832 mxvar_sdriver->init_termios.c_cflag = B9600|CS8|CREAD|HUPCL|CLOCAL;
2833 mxvar_sdriver->flags = TTY_DRIVER_REAL_RAW; 2833 mxvar_sdriver->flags = TTY_DRIVER_REAL_RAW|TTY_DRIVER_DYNAMIC_DEV;
2834 tty_set_operations(mxvar_sdriver, &mxser_ops); 2834 tty_set_operations(mxvar_sdriver, &mxser_ops);
2835 mxvar_sdriver->ttys = mxvar_tty; 2835 mxvar_sdriver->ttys = mxvar_tty;
2836 mxvar_sdriver->termios = mxvar_termios; 2836 mxvar_sdriver->termios = mxvar_termios;
2837 mxvar_sdriver->termios_locked = mxvar_termios_locked; 2837 mxvar_sdriver->termios_locked = mxvar_termios_locked;
2838 2838
2839 retval = tty_register_driver(mxvar_sdriver);
2840 if (retval) {
2841 printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family "
2842 "tty driver !\n");
2843 goto err_put;
2844 }
2845
2839 mxvar_diagflag = 0; 2846 mxvar_diagflag = 0;
2840 2847
2841 m = 0; 2848 m = 0;
@@ -2885,6 +2892,10 @@ static int __init mxser_module_init(void)
2885 if (mxser_initbrd(brd) < 0) 2892 if (mxser_initbrd(brd) < 0)
2886 continue; 2893 continue;
2887 2894
2895 for (i = 0; i < brd->nports; i++)
2896 tty_register_device(mxvar_sdriver,
2897 m * MXSER_PORTS_PER_BOARD + i, NULL);
2898
2888 m++; 2899 m++;
2889 } 2900 }
2890 2901
@@ -2939,6 +2950,11 @@ static int __init mxser_module_init(void)
2939 /* mxser_initbrd will hook ISR. */ 2950 /* mxser_initbrd will hook ISR. */
2940 if (mxser_initbrd(brd) < 0) 2951 if (mxser_initbrd(brd) < 0)
2941 continue; 2952 continue;
2953 for (i = 0; i < brd->nports; i++)
2954 tty_register_device(mxvar_sdriver,
2955 m * MXSER_PORTS_PER_BOARD + i,
2956 &pdev->dev);
2957
2942 m++; 2958 m++;
2943 /* Keep an extra reference if we succeeded. It will 2959 /* Keep an extra reference if we succeeded. It will
2944 be returned at unload time */ 2960 be returned at unload time */
@@ -2946,20 +2962,18 @@ static int __init mxser_module_init(void)
2946 } 2962 }
2947 } 2963 }
2948 2964
2949 retval = tty_register_driver(mxvar_sdriver); 2965 if (!m) {
2950 if (retval) { 2966 retval = -ENODEV;
2951 printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family" 2967 goto err_unr;
2952 " driver !\n");
2953 put_tty_driver(mxvar_sdriver);
2954
2955 for (i = 0; i < MXSER_BOARDS; i++)
2956 if (mxser_boards[i].board_type != -1)
2957 mxser_release_res(&mxser_boards[i], 1);
2958 return retval;
2959 } 2968 }
2960 2969
2961 pr_debug("Done.\n"); 2970 pr_debug("Done.\n");
2962 2971
2972 return 0;
2973err_unr:
2974 tty_unregister_driver(mxvar_sdriver);
2975err_put:
2976 put_tty_driver(mxvar_sdriver);
2963 return retval; 2977 return retval;
2964} 2978}
2965 2979
@@ -2969,6 +2983,8 @@ static void __exit mxser_module_exit(void)
2969 2983
2970 pr_debug("Unloading module mxser ...\n"); 2984 pr_debug("Unloading module mxser ...\n");
2971 2985
2986 for (i = 0; i < MXSER_PORTS; i++)
2987 tty_unregister_device(mxvar_sdriver, i);
2972 tty_unregister_driver(mxvar_sdriver); 2988 tty_unregister_driver(mxvar_sdriver);
2973 put_tty_driver(mxvar_sdriver); 2989 put_tty_driver(mxvar_sdriver);
2974 2990