Skip to content

Commit

Permalink
TTY: switch tty_flip_buffer_push
Browse files Browse the repository at this point in the history
Now, we start converting tty buffer functions to actually use
tty_port. This will allow us to get rid of the need of tty in many
call sites. Only tty_port will needed and hence no more
tty_port_tty_get in those paths.

Now, the one where most of tty_port_tty_get gets removed:
tty_flip_buffer_push.

IOW we also closed all the races in drivers not using tty_port_tty_get
at all yet.

Also we move tty_flip_buffer_push declaration from include/linux/tty.h
to include/linux/tty_flip.h to all others while we are changing it
anyway.

Signed-off-by: Jiri Slaby <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Jiri Slaby authored and gregkh committed Jan 16, 2013
1 parent d6c53c0 commit 2e124b4
Show file tree
Hide file tree
Showing 146 changed files with 446 additions and 988 deletions.
18 changes: 4 additions & 14 deletions arch/ia64/hp/sim/simserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ struct tty_driver *hp_simserial_driver;

static struct console *console;

static void receive_chars(struct tty_struct *tty)
static void receive_chars(struct tty_port *port)
{
struct tty_port *port = tty->port;
unsigned char ch;
static unsigned char seen_esc = 0;

Expand Down Expand Up @@ -85,7 +84,7 @@ static void receive_chars(struct tty_struct *tty)
if (tty_insert_flip_char(port, ch, TTY_NORMAL) == 0)
break;
}
tty_flip_buffer_push(tty);
tty_flip_buffer_push(port);
}

/*
Expand All @@ -94,18 +93,9 @@ static void receive_chars(struct tty_struct *tty)
static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
{
struct serial_state *info = dev_id;
struct tty_struct *tty = tty_port_tty_get(&info->port);

if (!tty) {
printk(KERN_INFO "%s: tty=0 problem\n", __func__);
return IRQ_NONE;
}
/*
* pretty simple in our case, because we only get interrupts
* on inbound traffic
*/
receive_chars(tty);
tty_kref_put(tty);
receive_chars(&info->port);

return IRQ_HANDLED;
}

Expand Down
7 changes: 3 additions & 4 deletions arch/mn10300/kernel/mn10300-serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,6 @@ static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port)
{
struct uart_icount *icount = &port->uart.icount;
struct tty_port *port = &port->uart.state->port;
struct tty_struct *tty = port->tty;
unsigned ix;
int count;
u8 st, ch, push, status, overrun;
Expand All @@ -538,7 +537,7 @@ static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port)
count = tty_buffer_request_room(port, count);
if (count == 0) {
if (!port->low_latency)
tty_flip_buffer_push(tty);
tty_flip_buffer_push(port);
return;
}

Expand All @@ -547,7 +546,7 @@ static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port)
ix = ACCESS_ONCE(port->rx_outp);
if (CIRC_CNT(port->rx_inp, ix, MNSC_BUFFER_SIZE) == 0) {
if (push && !port->low_latency)
tty_flip_buffer_push(tty);
tty_flip_buffer_push(port);
return;
}

Expand Down Expand Up @@ -679,7 +678,7 @@ static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port)
count--;
if (count <= 0) {
if (!port->low_latency)
tty_flip_buffer_push(tty);
tty_flip_buffer_push(port);
return;
}

Expand Down
8 changes: 1 addition & 7 deletions arch/parisc/kernel/pdc_cons.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,6 @@ static const struct tty_operations pdc_console_tty_ops = {
static void pdc_console_poll(unsigned long unused)
{
int data, count = 0;
struct tty_struct *tty = tty_port_tty_get(&tty_port);

if (!tty)
return;

while (1) {
data = pdc_console_poll_key(NULL);
Expand All @@ -152,9 +148,7 @@ static void pdc_console_poll(unsigned long unused)
}

if (count)
tty_flip_buffer_push(tty);

tty_kref_put(tty);
tty_flip_buffer_push(&tty_port);

if (pdc_cons.flags & CON_ENABLED)
mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY);
Expand Down
3 changes: 1 addition & 2 deletions arch/um/drivers/chan.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ struct chan {
void *data;
};

extern void chan_interrupt(struct line *line,
struct tty_struct *tty, int irq);
extern void chan_interrupt(struct line *line, int irq);
extern int parse_chan_pair(char *str, struct line *line, int device,
const struct chan_opts *opts, char **error_out);
extern int write_chan(struct chan *chan, const char *buf, int len,
Expand Down
14 changes: 7 additions & 7 deletions arch/um/drivers/chan_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,9 @@ void chan_enable_winch(struct chan *chan, struct tty_struct *tty)
static void line_timer_cb(struct work_struct *work)
{
struct line *line = container_of(work, struct line, task.work);
struct tty_struct *tty = tty_port_tty_get(&line->port);

if (!line->throttled)
chan_interrupt(line, tty, line->driver->read_irq);
tty_kref_put(tty);
chan_interrupt(line, line->driver->read_irq);
}

int enable_chan(struct line *line)
Expand Down Expand Up @@ -546,7 +544,7 @@ int parse_chan_pair(char *str, struct line *line, int device,
return 0;
}

void chan_interrupt(struct line *line, struct tty_struct *tty, int irq)
void chan_interrupt(struct line *line, int irq)
{
struct tty_port *port = &line->port;
struct chan *chan = line->chan_in;
Expand All @@ -570,8 +568,11 @@ void chan_interrupt(struct line *line, struct tty_struct *tty, int irq)
reactivate_fd(chan->fd, irq);
if (err == -EIO) {
if (chan->primary) {
if (tty != NULL)
struct tty_struct *tty = tty_port_tty_get(&line->port);
if (tty != NULL) {
tty_hangup(tty);
tty_kref_put(tty);
}
if (line->chan_out != chan)
close_one_chan(line->chan_out, 1);
}
Expand All @@ -580,6 +581,5 @@ void chan_interrupt(struct line *line, struct tty_struct *tty, int irq)
return;
}
out:
if (tty)
tty_flip_buffer_push(tty);
tty_flip_buffer_push(port);
}
7 changes: 3 additions & 4 deletions arch/um/drivers/line.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ static irqreturn_t line_interrupt(int irq, void *data)
{
struct chan *chan = data;
struct line *line = chan->line;
struct tty_struct *tty = tty_port_tty_get(&line->port);

if (line)
chan_interrupt(line, tty, irq);
tty_kref_put(tty);
chan_interrupt(line, irq);

return IRQ_HANDLED;
}

Expand Down Expand Up @@ -234,7 +233,7 @@ void line_unthrottle(struct tty_struct *tty)
struct line *line = tty->driver_data;

line->throttled = 0;
chan_interrupt(line, tty, line->driver->read_irq);
chan_interrupt(line, line->driver->read_irq);

/*
* Maybe there is enough stuff pending that calling the interrupt
Expand Down
9 changes: 4 additions & 5 deletions arch/xtensa/platforms/iss/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
tty->port = &serial_port;
spin_lock(&timer_lock);
if (tty->count == 1) {
setup_timer(&serial_timer, rs_poll, (unsigned long)tty);
setup_timer(&serial_timer, rs_poll,
(unsigned long)&serial_port);
mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE);
}
spin_unlock(&timer_lock);
Expand Down Expand Up @@ -97,9 +98,7 @@ static int rs_write(struct tty_struct * tty,

static void rs_poll(unsigned long priv)
{
struct tty_struct* tty = (struct tty_struct*) priv;
struct tty_port *port = tty->port;

struct tty_port *port = (struct tty_port *)priv;
struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };
int i = 0;
unsigned char c;
Expand All @@ -113,7 +112,7 @@ static void rs_poll(unsigned long priv)
}

if (i)
tty_flip_buffer_push(tty);
tty_flip_buffer_push(port);


mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE);
Expand Down
14 changes: 3 additions & 11 deletions drivers/char/pcmcia/synclink_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,22 +886,14 @@ static void rx_ready_hdlc(MGSLPC_INFO *info, int eom)
issue_command(info, CHA, CMD_RXFIFO);
}

static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty)
static void rx_ready_async(MGSLPC_INFO *info, int tcd)
{
struct tty_port *port = &info->port;
unsigned char data, status, flag;
int fifo_count;
int work = 0;
struct mgsl_icount *icount = &info->icount;

if (!tty) {
/* tty is not available anymore */
issue_command(info, CHA, CMD_RXRESET);
if (debug_level >= DEBUG_LEVEL_ISR)
printk("%s(%d):rx_ready_async(tty=NULL)\n",__FILE__,__LINE__);
return;
}

if (tcd) {
/* early termination, get FIFO count from RBCL register */
fifo_count = (unsigned char)(read_reg(info, CHA+RBCL) & 0x1f);
Expand Down Expand Up @@ -958,7 +950,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty)
}

if (work)
tty_flip_buffer_push(tty);
tty_flip_buffer_push(port);
}


Expand Down Expand Up @@ -1218,7 +1210,7 @@ static irqreturn_t mgslpc_isr(int dummy, void *dev_id)
if (info->params.mode == MGSL_MODE_HDLC)
rx_ready_hdlc(info, isr & IRQ_RXEOM);
else
rx_ready_async(info, isr & IRQ_RXEOM, tty);
rx_ready_async(info, isr & IRQ_RXEOM);
}

/* transmit IRQs */
Expand Down
14 changes: 4 additions & 10 deletions drivers/ipack/devices/ipoctal.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ static int ipoctal_get_icount(struct tty_struct *tty,
return 0;
}

static void ipoctal_irq_rx(struct ipoctal_channel *channel,
struct tty_struct *tty, u8 sr)
static void ipoctal_irq_rx(struct ipoctal_channel *channel, u8 sr)
{
struct tty_port *port = &channel->tty_port;
unsigned char value;
Expand Down Expand Up @@ -176,7 +175,7 @@ static void ipoctal_irq_rx(struct ipoctal_channel *channel,
sr = ioread8(&channel->regs->r.sr);
} while (isr & channel->isr_rx_rdy_mask);

tty_flip_buffer_push(tty);
tty_flip_buffer_push(port);
}

static void ipoctal_irq_tx(struct ipoctal_channel *channel)
Expand Down Expand Up @@ -209,15 +208,11 @@ static void ipoctal_irq_tx(struct ipoctal_channel *channel)
static void ipoctal_irq_channel(struct ipoctal_channel *channel)
{
u8 isr, sr;
struct tty_struct *tty;

/* If there is no client, skip the check */
if (!atomic_read(&channel->open))
return;

tty = tty_port_tty_get(&channel->tty_port);
if (!tty)
return;
/* The HW is organized in pair of channels. See which register we need
* to read from */
isr = ioread8(&channel->block_regs->r.isr);
Expand All @@ -236,14 +231,13 @@ static void ipoctal_irq_channel(struct ipoctal_channel *channel)

/* RX data */
if ((isr & channel->isr_rx_rdy_mask) && (sr & SR_RX_READY))
ipoctal_irq_rx(channel, tty, sr);
ipoctal_irq_rx(channel, sr);

/* TX of each character */
if ((isr & channel->isr_tx_rdy_mask) && (sr & SR_TX_READY))
ipoctal_irq_tx(channel);

tty_flip_buffer_push(tty);
tty_kref_put(tty);
tty_flip_buffer_push(&channel->tty_port);
}

static irqreturn_t ipoctal_irq_handler(void *arg)
Expand Down
10 changes: 1 addition & 9 deletions drivers/isdn/gigaset/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,16 +562,8 @@ void gigaset_if_free(struct cardstate *cs)
void gigaset_if_receive(struct cardstate *cs,
unsigned char *buffer, size_t len)
{
struct tty_struct *tty = tty_port_tty_get(&cs->port);

if (tty == NULL) {
gig_dbg(DEBUG_IF, "receive on closed device");
return;
}

tty_insert_flip_string(&cs->port, buffer, len);
tty_flip_buffer_push(tty);
tty_kref_put(tty);
tty_flip_buffer_push(&cs->port);
}
EXPORT_SYMBOL_GPL(gigaset_if_receive);

Expand Down
Loading

0 comments on commit 2e124b4

Please sign in to comment.