aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-08-07 15:47:28 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-08-10 16:27:50 -0400
commit86176ed905454e568539c77e0cba5759085830bb (patch)
tree27b0e14b29d496859488cddb654b80e0f4fce82b
parent3dd332c553996eec2593110b05abf8a4819b5c28 (diff)
TTY: n_gsm, use tty_port_install
We need to link a port to a tty in install. And since dlci is allocated even in open, we need to create gsmtty_install, allocate dlci there and create also the link. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/n_gsm.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 7a4bf3053a15..3778687f748b 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2868,14 +2868,14 @@ static const struct tty_port_operations gsm_port_ops = {
2868 .dtr_rts = gsm_dtr_rts, 2868 .dtr_rts = gsm_dtr_rts,
2869}; 2869};
2870 2870
2871 2871static int gsmtty_install(struct tty_driver *driver, struct tty_struct *tty)
2872static int gsmtty_open(struct tty_struct *tty, struct file *filp)
2873{ 2872{
2874 struct gsm_mux *gsm; 2873 struct gsm_mux *gsm;
2875 struct gsm_dlci *dlci; 2874 struct gsm_dlci *dlci;
2876 struct tty_port *port;
2877 unsigned int line = tty->index; 2875 unsigned int line = tty->index;
2878 unsigned int mux = line >> 6; 2876 unsigned int mux = line >> 6;
2877 bool alloc = false;
2878 int ret;
2879 2879
2880 line = line & 0x3F; 2880 line = line & 0x3F;
2881 2881
@@ -2890,13 +2890,30 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
2890 if (gsm->dead) 2890 if (gsm->dead)
2891 return -EL2HLT; 2891 return -EL2HLT;
2892 dlci = gsm->dlci[line]; 2892 dlci = gsm->dlci[line];
2893 if (dlci == NULL) 2893 if (dlci == NULL) {
2894 alloc = true;
2894 dlci = gsm_dlci_alloc(gsm, line); 2895 dlci = gsm_dlci_alloc(gsm, line);
2896 }
2895 if (dlci == NULL) 2897 if (dlci == NULL)
2896 return -ENOMEM; 2898 return -ENOMEM;
2897 port = &dlci->port; 2899 ret = tty_port_install(&dlci->port, driver, tty);
2898 port->count++; 2900 if (ret) {
2901 if (alloc)
2902 dlci_put(dlci);
2903 return ret;
2904 }
2905
2899 tty->driver_data = dlci; 2906 tty->driver_data = dlci;
2907
2908 return 0;
2909}
2910
2911static int gsmtty_open(struct tty_struct *tty, struct file *filp)
2912{
2913 struct gsm_dlci *dlci = tty->driver_data;
2914 struct tty_port *port = &dlci->port;
2915
2916 port->count++;
2900 dlci_get(dlci); 2917 dlci_get(dlci);
2901 dlci_get(dlci->gsm->dlci[0]); 2918 dlci_get(dlci->gsm->dlci[0]);
2902 mux_get(dlci->gsm); 2919 mux_get(dlci->gsm);
@@ -3085,6 +3102,7 @@ static int gsmtty_break_ctl(struct tty_struct *tty, int state)
3085 3102
3086/* Virtual ttys for the demux */ 3103/* Virtual ttys for the demux */
3087static const struct tty_operations gsmtty_ops = { 3104static const struct tty_operations gsmtty_ops = {
3105 .install = gsmtty_install,
3088 .open = gsmtty_open, 3106 .open = gsmtty_open,
3089 .close = gsmtty_close, 3107 .close = gsmtty_close,
3090 .write = gsmtty_write, 3108 .write = gsmtty_write,