Commit bed5e39c authored by Al Viro's avatar Al Viro Committed by Richard Weinberger

um: switch users of ->chan_list to ->chan_{in,out} (easy cases)

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent ee485070
......@@ -27,24 +27,24 @@ struct chan {
void *data;
};
extern void chan_interrupt(struct list_head *chans, struct delayed_work *task,
extern void chan_interrupt(struct line *line, struct delayed_work *task,
struct tty_struct *tty, 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 list_head *chans, const char *buf, int len,
extern int write_chan(struct chan *chan, const char *buf, int len,
int write_irq);
extern int console_write_chan(struct list_head *chans, const char *buf,
extern int console_write_chan(struct chan *chan, const char *buf,
int len);
extern int console_open_chan(struct line *line, struct console *co);
extern void deactivate_chan(struct list_head *chans, int irq);
extern void reactivate_chan(struct list_head *chans, int irq);
extern void chan_enable_winch(struct list_head *chans, struct tty_struct *tty);
extern void deactivate_chan(struct chan *chan, int irq);
extern void reactivate_chan(struct chan *chan, int irq);
extern void chan_enable_winch(struct chan *chan, struct tty_struct *tty);
extern int enable_chan(struct line *line);
extern void close_chan(struct list_head *chans, int delay_free_irq);
extern int chan_window_size(struct list_head *chans,
extern int chan_window_size(struct line *line,
unsigned short *rows_out,
unsigned short *cols_out);
extern int chan_config_string(struct list_head *chans, char *str, int size,
extern int chan_config_string(struct line *line, char *str, int size,
char **error_out);
#endif
......@@ -140,18 +140,10 @@ static int open_chan(struct list_head *chans)
return err;
}
void chan_enable_winch(struct list_head *chans, struct tty_struct *tty)
void chan_enable_winch(struct chan *chan, struct tty_struct *tty)
{
struct list_head *ele;
struct chan *chan;
list_for_each(ele, chans) {
chan = list_entry(ele, struct chan, list);
if (chan->primary && chan->output && chan->ops->winch) {
register_winch(chan->fd, tty);
return;
}
}
if (chan && chan->primary && chan->ops->winch)
register_winch(chan->fd, tty);
}
int enable_chan(struct line *line)
......@@ -258,72 +250,45 @@ void close_chan(struct list_head *chans, int delay_free_irq)
}
}
void deactivate_chan(struct list_head *chans, int irq)
void deactivate_chan(struct chan *chan, int irq)
{
struct list_head *ele;
struct chan *chan;
list_for_each(ele, chans) {
chan = list_entry(ele, struct chan, list);
if (chan->enabled && chan->input)
deactivate_fd(chan->fd, irq);
}
if (chan && chan->enabled)
deactivate_fd(chan->fd, irq);
}
void reactivate_chan(struct list_head *chans, int irq)
void reactivate_chan(struct chan *chan, int irq)
{
struct list_head *ele;
struct chan *chan;
list_for_each(ele, chans) {
chan = list_entry(ele, struct chan, list);
if (chan->enabled && chan->input)
reactivate_fd(chan->fd, irq);
}
if (chan && chan->enabled)
reactivate_fd(chan->fd, irq);
}
int write_chan(struct list_head *chans, const char *buf, int len,
int write_chan(struct chan *chan, const char *buf, int len,
int write_irq)
{
struct list_head *ele;
struct chan *chan = NULL;
int n, ret = 0;
if (len == 0)
if (len == 0 || !chan || !chan->ops->write)
return 0;
list_for_each(ele, chans) {
chan = list_entry(ele, struct chan, list);
if (!chan->output || (chan->ops->write == NULL))
continue;
n = chan->ops->write(chan->fd, buf, len, chan->data);
if (chan->primary) {
ret = n;
if ((ret == -EAGAIN) || ((ret >= 0) && (ret < len)))
reactivate_fd(chan->fd, write_irq);
}
n = chan->ops->write(chan->fd, buf, len, chan->data);
if (chan->primary) {
ret = n;
if ((ret == -EAGAIN) || ((ret >= 0) && (ret < len)))
reactivate_fd(chan->fd, write_irq);
}
return ret;
}
int console_write_chan(struct list_head *chans, const char *buf, int len)
int console_write_chan(struct chan *chan, const char *buf, int len)
{
struct list_head *ele;
struct chan *chan;
int n, ret = 0;
list_for_each(ele, chans) {
chan = list_entry(ele, struct chan, list);
if (!chan->output || (chan->ops->console_write == NULL))
continue;
if (!chan || !chan->ops->console_write)
return 0;
n = chan->ops->console_write(chan->fd, buf, len);
if (chan->primary)
ret = n;
}
n = chan->ops->console_write(chan->fd, buf, len);
if (chan->primary)
ret = n;
return ret;
}
......@@ -340,20 +305,24 @@ int console_open_chan(struct line *line, struct console *co)
return 0;
}
int chan_window_size(struct list_head *chans, unsigned short *rows_out,
int chan_window_size(struct line *line, unsigned short *rows_out,
unsigned short *cols_out)
{
struct list_head *ele;
struct chan *chan;
list_for_each(ele, chans) {
chan = list_entry(ele, struct chan, list);
if (chan->primary) {
if (chan->ops->window_size == NULL)
return 0;
return chan->ops->window_size(chan->fd, chan->data,
rows_out, cols_out);
}
chan = line->chan_in;
if (chan && chan->primary) {
if (chan->ops->window_size == NULL)
return 0;
return chan->ops->window_size(chan->fd, chan->data,
rows_out, cols_out);
}
chan = line->chan_out;
if (chan && chan->primary) {
if (chan->ops->window_size == NULL)
return 0;
return chan->ops->window_size(chan->fd, chan->data,
rows_out, cols_out);
}
return 0;
}
......@@ -429,21 +398,15 @@ static int chan_pair_config_string(struct chan *in, struct chan *out,
return n;
}
int chan_config_string(struct list_head *chans, char *str, int size,
int chan_config_string(struct line *line, char *str, int size,
char **error_out)
{
struct list_head *ele;
struct chan *chan, *in = NULL, *out = NULL;
struct chan *in = line->chan_in, *out = line->chan_out;
list_for_each(ele, chans) {
chan = list_entry(ele, struct chan, list);
if (!chan->primary)
continue;
if (chan->input)
in = chan;
if (chan->output)
out = chan;
}
if (in && !in->primary)
in = NULL;
if (out && !out->primary)
out = NULL;
return chan_pair_config_string(in, out, str, size, error_out);
}
......@@ -589,39 +552,36 @@ int parse_chan_pair(char *str, struct line *line, int device,
return 0;
}
void chan_interrupt(struct list_head *chans, struct delayed_work *task,
void chan_interrupt(struct line *line, struct delayed_work *task,
struct tty_struct *tty, int irq)
{
struct list_head *ele, *next;
struct chan *chan;
struct chan *chan = line->chan_in;
int err;
char c;
list_for_each_safe(ele, next, chans) {
chan = list_entry(ele, struct chan, list);
if (!chan->input || (chan->ops->read == NULL))
continue;
do {
if (tty && !tty_buffer_request_room(tty, 1)) {
schedule_delayed_work(task, 1);
goto out;
}
err = chan->ops->read(chan->fd, &c, chan->data);
if (err > 0)
tty_receive_char(tty, c);
} while (err > 0);
if (err == 0)
reactivate_fd(chan->fd, irq);
if (err == -EIO) {
if (chan->primary) {
if (tty != NULL)
tty_hangup(tty);
close_chan(chans, 1);
return;
}
else close_one_chan(chan, 1);
if (!chan || !chan->ops->read)
goto out;
do {
if (tty && !tty_buffer_request_room(tty, 1)) {
schedule_delayed_work(task, 1);
goto out;
}
err = chan->ops->read(chan->fd, &c, chan->data);
if (err > 0)
tty_receive_char(tty, c);
} while (err > 0);
if (err == 0)
reactivate_fd(chan->fd, irq);
if (err == -EIO) {
if (chan->primary) {
if (tty != NULL)
tty_hangup(tty);
close_chan(&line->chan_list, 1);
return;
}
else close_one_chan(chan, 1);
}
out:
if (tty)
......
......@@ -21,7 +21,7 @@ static irqreturn_t line_interrupt(int irq, void *data)
struct line *line = chan->line;
if (line)
chan_interrupt(&line->chan_list, &line->task, line->tty, irq);
chan_interrupt(line, &line->task, line->tty, irq);
return IRQ_HANDLED;
}
......@@ -30,7 +30,7 @@ static void line_timer_cb(struct work_struct *work)
struct line *line = container_of(work, struct line, task.work);
if (!line->throttled)
chan_interrupt(&line->chan_list, &line->task, line->tty,
chan_interrupt(line, &line->task, line->tty,
line->driver->read_irq);
}
......@@ -145,7 +145,7 @@ static int flush_buffer(struct line *line)
/* line->buffer + LINE_BUFSIZE is the end of the buffer! */
count = line->buffer + LINE_BUFSIZE - line->head;
n = write_chan(&line->chan_list, line->head, count,
n = write_chan(line->chan_out, line->head, count,
line->driver->write_irq);
if (n < 0)
return n;
......@@ -162,7 +162,7 @@ static int flush_buffer(struct line *line)
}
count = line->tail - line->head;
n = write_chan(&line->chan_list, line->head, count,
n = write_chan(line->chan_out, line->head, count,
line->driver->write_irq);
if (n < 0)
......@@ -206,7 +206,7 @@ int line_write(struct tty_struct *tty, const unsigned char *buf, int len)
if (line->head != line->tail)
ret = buffer_data(line, buf, len);
else {
n = write_chan(&line->chan_list, buf, len,
n = write_chan(line->chan_out, buf, len,
line->driver->write_irq);
if (n < 0) {
ret = n;
......@@ -318,7 +318,7 @@ void line_throttle(struct tty_struct *tty)
{
struct line *line = tty->driver_data;
deactivate_chan(&line->chan_list, line->driver->read_irq);
deactivate_chan(line->chan_in, line->driver->read_irq);
line->throttled = 1;
}
......@@ -327,7 +327,7 @@ void line_unthrottle(struct tty_struct *tty)
struct line *line = tty->driver_data;
line->throttled = 0;
chan_interrupt(&line->chan_list, &line->task, tty,
chan_interrupt(line, &line->task, tty,
line->driver->read_irq);
/*
......@@ -336,7 +336,7 @@ void line_unthrottle(struct tty_struct *tty)
* again and we shouldn't turn the interrupt back on.
*/
if (!line->throttled)
reactivate_chan(&line->chan_list, line->driver->read_irq);
reactivate_chan(line->chan_in, line->driver->read_irq);
}
static irqreturn_t line_write_interrupt(int irq, void *data)
......@@ -428,11 +428,11 @@ int line_open(struct line *lines, struct tty_struct *tty)
INIT_DELAYED_WORK(&line->task, line_timer_cb);
if (!line->sigio) {
chan_enable_winch(&line->chan_list, tty);
chan_enable_winch(line->chan_out, tty);
line->sigio = 1;
}
chan_window_size(&line->chan_list, &tty->winsize.ws_row,
chan_window_size(line, &tty->winsize.ws_row,
&tty->winsize.ws_col);
out_unlock:
mutex_unlock(&line->count_lock);
......@@ -624,7 +624,7 @@ int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
CONFIG_CHUNK(str, size, n, "none", 1);
else if (line->tty == NULL)
CONFIG_CHUNK(str, size, n, line->init_str, 1);
else n = chan_config_string(&line->chan_list, str, size, error_out);
else n = chan_config_string(line, str, size, error_out);
mutex_unlock(&line->count_lock);
return n;
......@@ -761,7 +761,7 @@ static irqreturn_t winch_interrupt(int irq, void *data)
if (tty != NULL) {
line = tty->driver_data;
if (line != NULL) {
chan_window_size(&line->chan_list, &tty->winsize.ws_row,
chan_window_size(line, &tty->winsize.ws_row,
&tty->winsize.ws_col);
kill_pgrp(tty->pgrp, SIGWINCH, 1);
}
......
......@@ -151,7 +151,7 @@ static void ssl_console_write(struct console *c, const char *string,
unsigned long flags;
spin_lock_irqsave(&line->lock, flags);
console_write_chan(&line->chan_list, string, len);
console_write_chan(line->chan_out, string, len);
spin_unlock_irqrestore(&line->lock, flags);
}
......
......@@ -124,7 +124,7 @@ static void uml_console_write(struct console *console, const char *string,
unsigned long flags;
spin_lock_irqsave(&line->lock, flags);
console_write_chan(&line->chan_list, string, len);
console_write_chan(line->chan_out, string, len);
spin_unlock_irqrestore(&line->lock, flags);
}
......
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