Commit 9aead90a authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

TTY: simserial, use tty_port_open

So now we convert startup to be ->activate of tty_port. This means we
no longer care about INITIALIZED and TTY_IO_ERROR flags.

After we have ->activate much of the code may go as it duplicates what
tty_port_open does. In this case tty_port_open adds block_til_ready to
the path. But we do not define carrier hooks, so it is a noop.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3a5c2423
...@@ -473,9 +473,10 @@ static void rs_hangup(struct tty_struct *tty) ...@@ -473,9 +473,10 @@ static void rs_hangup(struct tty_struct *tty)
} }
static int startup(struct tty_struct *tty, struct serial_state *state) static int activate(struct tty_port *port, struct tty_struct *tty)
{ {
struct tty_port *port = &state->port; struct serial_state *state = container_of(port, struct serial_state,
port);
unsigned long flags; unsigned long flags;
int retval=0; int retval=0;
unsigned long page; unsigned long page;
...@@ -486,20 +487,11 @@ static int startup(struct tty_struct *tty, struct serial_state *state) ...@@ -486,20 +487,11 @@ static int startup(struct tty_struct *tty, struct serial_state *state)
local_irq_save(flags); local_irq_save(flags);
if (port->flags & ASYNC_INITIALIZED) {
free_page(page);
goto errout;
}
if (state->xmit.buf) if (state->xmit.buf)
free_page(page); free_page(page);
else else
state->xmit.buf = (unsigned char *) page; state->xmit.buf = (unsigned char *) page;
#ifdef SIMSERIAL_DEBUG
printk("startup: ttys%d (irq %d)...", state->line, state->irq);
#endif
/* /*
* Allocate the IRQ if necessary * Allocate the IRQ if necessary
*/ */
...@@ -510,18 +502,8 @@ static int startup(struct tty_struct *tty, struct serial_state *state) ...@@ -510,18 +502,8 @@ static int startup(struct tty_struct *tty, struct serial_state *state)
goto errout; goto errout;
} }
clear_bit(TTY_IO_ERROR, &tty->flags);
state->xmit.head = state->xmit.tail = 0; state->xmit.head = state->xmit.tail = 0;
#if 0
/*
* Set up serial timers...
*/
timer_table[RS_TIMER].expires = jiffies + 2*HZ/100;
timer_active |= 1 << RS_TIMER;
#endif
/* /*
* Set up the tty->alt_speed kludge * Set up the tty->alt_speed kludge
*/ */
...@@ -534,10 +516,6 @@ static int startup(struct tty_struct *tty, struct serial_state *state) ...@@ -534,10 +516,6 @@ static int startup(struct tty_struct *tty, struct serial_state *state)
if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
tty->alt_speed = 460800; tty->alt_speed = 460800;
port->flags |= ASYNC_INITIALIZED;
local_irq_restore(flags);
return 0;
errout: errout:
local_irq_restore(flags); local_irq_restore(flags);
return retval; return retval;
...@@ -554,40 +532,10 @@ static int rs_open(struct tty_struct *tty, struct file * filp) ...@@ -554,40 +532,10 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
{ {
struct serial_state *info = rs_table + tty->index; struct serial_state *info = rs_table + tty->index;
struct tty_port *port = &info->port; struct tty_port *port = &info->port;
int retval;
port->count++;
tty_port_tty_set(port, tty);
tty->driver_data = info; tty->driver_data = info;
tty->port = port;
#ifdef SIMSERIAL_DEBUG
printk("rs_open %s, count = %d\n", tty->name, port->count);
#endif
tty->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; tty->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
/*
* If the port is the middle of closing, bail out now
*/
if (tty_hung_up_p(filp) || (port->flags & ASYNC_CLOSING)) {
if (port->flags & ASYNC_CLOSING)
interruptible_sleep_on(&port->close_wait);
#ifdef SERIAL_DO_RESTART
return ((port->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS);
#else
return -EAGAIN;
#endif
}
/*
* Start up serial port
*/
retval = startup(tty, info);
if (retval) {
return retval;
}
/* /*
* figure out which console to use (should be one already) * figure out which console to use (should be one already)
*/ */
...@@ -597,10 +545,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp) ...@@ -597,10 +545,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
console = console->next; console = console->next;
} }
#ifdef SIMSERIAL_DEBUG return tty_port_open(port, tty, filp);
printk("rs_open ttys%d successful\n", info->line);
#endif
return 0;
} }
/* /*
...@@ -669,6 +614,7 @@ static const struct tty_operations hp_ops = { ...@@ -669,6 +614,7 @@ static const struct tty_operations hp_ops = {
}; };
static const struct tty_port_operations hp_port_ops = { static const struct tty_port_operations hp_port_ops = {
.activate = activate,
}; };
/* /*
......
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