TTY: simserial, pass tty down to functions
This avoids pain with tty refcounting and touching tty_port in the future. It allows us to remove some state->tty tests because the tty passed down to them can never be NULL. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Tony Luck <tony.luck@intel.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
588993dd8d
commit
5e99d54587
@ -202,7 +202,8 @@ static int rs_put_char(struct tty_struct *tty, unsigned char ch)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void transmit_chars(struct serial_state *info, int *intr_done)
|
static void transmit_chars(struct tty_struct *tty, struct serial_state *info,
|
||||||
|
int *intr_done)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
@ -220,10 +221,11 @@ static void transmit_chars(struct serial_state *info, int *intr_done)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->xmit.head == info->xmit.tail || info->tty->stopped || info->tty->hw_stopped) {
|
if (info->xmit.head == info->xmit.tail || tty->stopped ||
|
||||||
|
tty->hw_stopped) {
|
||||||
#ifdef SIMSERIAL_DEBUG
|
#ifdef SIMSERIAL_DEBUG
|
||||||
printk("transmit_chars: head=%d, tail=%d, stopped=%d\n",
|
printk("transmit_chars: head=%d, tail=%d, stopped=%d\n",
|
||||||
info->xmit.head, info->xmit.tail, info->tty->stopped);
|
info->xmit.head, info->xmit.tail, tty->stopped);
|
||||||
#endif
|
#endif
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -261,7 +263,7 @@ static void rs_flush_chars(struct tty_struct *tty)
|
|||||||
!info->xmit.buf)
|
!info->xmit.buf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
transmit_chars(info, NULL);
|
transmit_chars(tty, info, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -295,7 +297,7 @@ static int rs_write(struct tty_struct * tty,
|
|||||||
*/
|
*/
|
||||||
if (CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE)
|
if (CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE)
|
||||||
&& !tty->stopped && !tty->hw_stopped) {
|
&& !tty->stopped && !tty->hw_stopped) {
|
||||||
transmit_chars(info, NULL);
|
transmit_chars(tty, info, NULL);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -340,7 +342,7 @@ static void rs_send_xchar(struct tty_struct *tty, char ch)
|
|||||||
* I guess we could call console->write() directly but
|
* I guess we could call console->write() directly but
|
||||||
* let's do that for now.
|
* let's do that for now.
|
||||||
*/
|
*/
|
||||||
transmit_chars(info, NULL);
|
transmit_chars(tty, info, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,7 +444,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
|
|||||||
* This routine will shutdown a serial port; interrupts are disabled, and
|
* This routine will shutdown a serial port; interrupts are disabled, and
|
||||||
* DTR is dropped if the hangup on close termio flag is on.
|
* DTR is dropped if the hangup on close termio flag is on.
|
||||||
*/
|
*/
|
||||||
static void shutdown(struct serial_state *info)
|
static void shutdown(struct tty_struct *tty, struct serial_state *info)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
@ -464,7 +466,7 @@ static void shutdown(struct serial_state *info)
|
|||||||
info->xmit.buf = NULL;
|
info->xmit.buf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags);
|
set_bit(TTY_IO_ERROR, &tty->flags);
|
||||||
|
|
||||||
info->flags &= ~ASYNC_INITIALIZED;
|
info->flags &= ~ASYNC_INITIALIZED;
|
||||||
}
|
}
|
||||||
@ -528,7 +530,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
|
|||||||
* Now we wait for the transmit buffer to clear; and we notify
|
* Now we wait for the transmit buffer to clear; and we notify
|
||||||
* the line discipline to only process XON/XOFF characters.
|
* the line discipline to only process XON/XOFF characters.
|
||||||
*/
|
*/
|
||||||
shutdown(info);
|
shutdown(tty, info);
|
||||||
rs_flush_buffer(tty);
|
rs_flush_buffer(tty);
|
||||||
tty_ldisc_flush(tty);
|
tty_ldisc_flush(tty);
|
||||||
info->tty = NULL;
|
info->tty = NULL;
|
||||||
@ -563,7 +565,7 @@ static void rs_hangup(struct tty_struct *tty)
|
|||||||
rs_flush_buffer(tty);
|
rs_flush_buffer(tty);
|
||||||
if (info->flags & ASYNC_CLOSING)
|
if (info->flags & ASYNC_CLOSING)
|
||||||
return;
|
return;
|
||||||
shutdown(info);
|
shutdown(tty, info);
|
||||||
|
|
||||||
info->count = 0;
|
info->count = 0;
|
||||||
info->flags &= ~ASYNC_NORMAL_ACTIVE;
|
info->flags &= ~ASYNC_NORMAL_ACTIVE;
|
||||||
@ -572,7 +574,7 @@ static void rs_hangup(struct tty_struct *tty)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int startup(struct serial_state *state)
|
static int startup(struct tty_struct *tty, struct serial_state *state)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int retval=0;
|
int retval=0;
|
||||||
@ -590,8 +592,7 @@ static int startup(struct serial_state *state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!state->port || !state->type) {
|
if (!state->port || !state->type) {
|
||||||
if (state->tty)
|
set_bit(TTY_IO_ERROR, &tty->flags);
|
||||||
set_bit(TTY_IO_ERROR, &state->tty->flags);
|
|
||||||
free_page(page);
|
free_page(page);
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
@ -614,8 +615,7 @@ static int startup(struct serial_state *state)
|
|||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->tty)
|
clear_bit(TTY_IO_ERROR, &tty->flags);
|
||||||
clear_bit(TTY_IO_ERROR, &state->tty->flags);
|
|
||||||
|
|
||||||
state->xmit.head = state->xmit.tail = 0;
|
state->xmit.head = state->xmit.tail = 0;
|
||||||
|
|
||||||
@ -630,16 +630,14 @@ static int startup(struct serial_state *state)
|
|||||||
/*
|
/*
|
||||||
* Set up the tty->alt_speed kludge
|
* Set up the tty->alt_speed kludge
|
||||||
*/
|
*/
|
||||||
if (state->tty) {
|
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
|
||||||
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
|
tty->alt_speed = 57600;
|
||||||
state->tty->alt_speed = 57600;
|
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
|
||||||
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
|
tty->alt_speed = 115200;
|
||||||
state->tty->alt_speed = 115200;
|
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
|
||||||
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
|
tty->alt_speed = 230400;
|
||||||
state->tty->alt_speed = 230400;
|
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
|
||||||
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
|
tty->alt_speed = 460800;
|
||||||
state->tty->alt_speed = 460800;
|
|
||||||
}
|
|
||||||
|
|
||||||
state->flags |= ASYNC_INITIALIZED;
|
state->flags |= ASYNC_INITIALIZED;
|
||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
@ -699,7 +697,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
|
|||||||
/*
|
/*
|
||||||
* Start up serial port
|
* Start up serial port
|
||||||
*/
|
*/
|
||||||
retval = startup(info);
|
retval = startup(tty, info);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user