Commit 86176ed9 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

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: default avatarJiri Slaby <jslaby@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3dd332c5
...@@ -2868,14 +2868,14 @@ static const struct tty_port_operations gsm_port_ops = { ...@@ -2868,14 +2868,14 @@ static const struct tty_port_operations gsm_port_ops = {
.dtr_rts = gsm_dtr_rts, .dtr_rts = gsm_dtr_rts,
}; };
static int gsmtty_install(struct tty_driver *driver, struct tty_struct *tty)
static int gsmtty_open(struct tty_struct *tty, struct file *filp)
{ {
struct gsm_mux *gsm; struct gsm_mux *gsm;
struct gsm_dlci *dlci; struct gsm_dlci *dlci;
struct tty_port *port;
unsigned int line = tty->index; unsigned int line = tty->index;
unsigned int mux = line >> 6; unsigned int mux = line >> 6;
bool alloc = false;
int ret;
line = line & 0x3F; line = line & 0x3F;
...@@ -2890,13 +2890,30 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp) ...@@ -2890,13 +2890,30 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
if (gsm->dead) if (gsm->dead)
return -EL2HLT; return -EL2HLT;
dlci = gsm->dlci[line]; dlci = gsm->dlci[line];
if (dlci == NULL) if (dlci == NULL) {
alloc = true;
dlci = gsm_dlci_alloc(gsm, line); dlci = gsm_dlci_alloc(gsm, line);
}
if (dlci == NULL) if (dlci == NULL)
return -ENOMEM; return -ENOMEM;
port = &dlci->port; ret = tty_port_install(&dlci->port, driver, tty);
port->count++; if (ret) {
if (alloc)
dlci_put(dlci);
return ret;
}
tty->driver_data = dlci; tty->driver_data = dlci;
return 0;
}
static int gsmtty_open(struct tty_struct *tty, struct file *filp)
{
struct gsm_dlci *dlci = tty->driver_data;
struct tty_port *port = &dlci->port;
port->count++;
dlci_get(dlci); dlci_get(dlci);
dlci_get(dlci->gsm->dlci[0]); dlci_get(dlci->gsm->dlci[0]);
mux_get(dlci->gsm); mux_get(dlci->gsm);
...@@ -3085,6 +3102,7 @@ static int gsmtty_break_ctl(struct tty_struct *tty, int state) ...@@ -3085,6 +3102,7 @@ static int gsmtty_break_ctl(struct tty_struct *tty, int state)
/* Virtual ttys for the demux */ /* Virtual ttys for the demux */
static const struct tty_operations gsmtty_ops = { static const struct tty_operations gsmtty_ops = {
.install = gsmtty_install,
.open = gsmtty_open, .open = gsmtty_open,
.close = gsmtty_close, .close = gsmtty_close,
.write = gsmtty_write, .write = gsmtty_write,
......
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