Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e124b4a authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman
Browse files

TTY: switch tty_flip_buffer_push



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: default avatarJiri Slaby <jslaby@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d6c53c0e
Loading
Loading
Loading
Loading
+4 −14
Original line number Diff line number Diff line
@@ -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;

@@ -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);
}

/*
@@ -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;
}

+3 −4
Original line number Diff line number Diff line
@@ -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;
@@ -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;
	}

@@ -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;
	}

@@ -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;
	}

+1 −7
Original line number Diff line number Diff line
@@ -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);
@@ -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);
+1 −2
Original line number Diff line number Diff line
@@ -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,
+7 −7
Original line number Diff line number Diff line
@@ -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)
@@ -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;
@@ -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);
		}
@@ -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);
}
Loading