Lines Matching refs:chan
84 static int open_one_chan(struct chan *chan) in open_one_chan() argument
88 if (chan->opened) in open_one_chan()
91 if (chan->ops->open == NULL) in open_one_chan()
93 else fd = (*chan->ops->open)(chan->input, chan->output, chan->primary, in open_one_chan()
94 chan->data, &chan->dev); in open_one_chan()
100 (*chan->ops->close)(fd, chan->data); in open_one_chan()
104 chan->fd = fd; in open_one_chan()
106 chan->opened = 1; in open_one_chan()
113 struct chan *chan; in open_chan() local
117 chan = list_entry(ele, struct chan, list); in open_chan()
118 ret = open_one_chan(chan); in open_chan()
119 if (chan->primary) in open_chan()
125 void chan_enable_winch(struct chan *chan, struct tty_port *port) in chan_enable_winch() argument
127 if (chan && chan->primary && chan->ops->winch) in chan_enable_winch()
128 register_winch(chan->fd, port); in chan_enable_winch()
142 struct chan *chan; in enable_chan() local
148 chan = list_entry(ele, struct chan, list); in enable_chan()
149 err = open_one_chan(chan); in enable_chan()
151 if (chan->primary) in enable_chan()
157 if (chan->enabled) in enable_chan()
159 err = line_setup_irq(chan->fd, chan->input, chan->output, line, in enable_chan()
160 chan); in enable_chan()
164 chan->enabled = 1; in enable_chan()
185 struct chan *chan; in free_irqs() local
195 chan = list_entry(ele, struct chan, free_list); in free_irqs()
197 if (chan->input && chan->enabled) in free_irqs()
198 um_free_irq(chan->line->driver->read_irq, chan); in free_irqs()
199 if (chan->output && chan->enabled) in free_irqs()
200 um_free_irq(chan->line->driver->write_irq, chan); in free_irqs()
201 chan->enabled = 0; in free_irqs()
205 static void close_one_chan(struct chan *chan, int delay_free_irq) in close_one_chan() argument
209 if (!chan->opened) in close_one_chan()
214 list_add(&chan->free_list, &irqs_to_free); in close_one_chan()
217 if (chan->input && chan->enabled) in close_one_chan()
218 um_free_irq(chan->line->driver->read_irq, chan); in close_one_chan()
219 if (chan->output && chan->enabled) in close_one_chan()
220 um_free_irq(chan->line->driver->write_irq, chan); in close_one_chan()
221 chan->enabled = 0; in close_one_chan()
223 if (chan->ops->close != NULL) in close_one_chan()
224 (*chan->ops->close)(chan->fd, chan->data); in close_one_chan()
226 chan->opened = 0; in close_one_chan()
227 chan->fd = -1; in close_one_chan()
232 struct chan *chan; in close_chan() local
239 list_for_each_entry_reverse(chan, &line->chan_list, list) { in close_chan()
240 close_one_chan(chan, 0); in close_chan()
244 void deactivate_chan(struct chan *chan, int irq) in deactivate_chan() argument
246 if (chan && chan->enabled) in deactivate_chan()
247 deactivate_fd(chan->fd, irq); in deactivate_chan()
250 int write_chan(struct chan *chan, const char *buf, int len, in write_chan() argument
255 if (len == 0 || !chan || !chan->ops->write) in write_chan()
258 n = chan->ops->write(chan->fd, buf, len, chan->data); in write_chan()
259 if (chan->primary) { in write_chan()
265 int console_write_chan(struct chan *chan, const char *buf, int len) in console_write_chan() argument
269 if (!chan || !chan->ops->console_write) in console_write_chan()
272 n = chan->ops->console_write(chan->fd, buf, len); in console_write_chan()
273 if (chan->primary) in console_write_chan()
294 struct chan *chan; in chan_window_size() local
296 chan = line->chan_in; in chan_window_size()
297 if (chan && chan->primary) { in chan_window_size()
298 if (chan->ops->window_size == NULL) in chan_window_size()
300 return chan->ops->window_size(chan->fd, chan->data, in chan_window_size()
303 chan = line->chan_out; in chan_window_size()
304 if (chan && chan->primary) { in chan_window_size()
305 if (chan->ops->window_size == NULL) in chan_window_size()
307 return chan->ops->window_size(chan->fd, chan->data, in chan_window_size()
313 static void free_one_chan(struct chan *chan) in free_one_chan() argument
315 list_del(&chan->list); in free_one_chan()
317 close_one_chan(chan, 0); in free_one_chan()
319 if (chan->ops->free != NULL) in free_one_chan()
320 (*chan->ops->free)(chan->data); in free_one_chan()
322 if (chan->primary && chan->output) in free_one_chan()
323 ignore_sigio_fd(chan->fd); in free_one_chan()
324 kfree(chan); in free_one_chan()
330 struct chan *chan; in free_chan() local
333 chan = list_entry(ele, struct chan, list); in free_chan()
334 free_one_chan(chan); in free_chan()
338 static int one_chan_config_string(struct chan *chan, char *str, int size, in one_chan_config_string() argument
343 if (chan == NULL) { in one_chan_config_string()
348 CONFIG_CHUNK(str, size, n, chan->ops->type, 0); in one_chan_config_string()
350 if (chan->dev == NULL) { in one_chan_config_string()
356 CONFIG_CHUNK(str, size, n, chan->dev, 0); in one_chan_config_string()
361 static int chan_pair_config_string(struct chan *in, struct chan *out, in chan_pair_config_string()
387 struct chan *in = line->chan_in, *out = line->chan_out; in chan_config_string()
438 static struct chan *parse_chan(struct line *line, char *str, int device, in parse_chan()
443 struct chan *chan; in parse_chan() local
468 chan = kmalloc(sizeof(*chan), GFP_ATOMIC); in parse_chan()
469 if (chan == NULL) { in parse_chan()
473 *chan = ((struct chan) { .list = LIST_HEAD_INIT(chan->list), in parse_chan()
475 LIST_HEAD_INIT(chan->free_list), in parse_chan()
485 return chan; in parse_chan()
492 struct chan *new; in parse_chan_pair()
541 struct chan *chan = line->chan_in; in chan_interrupt() local
545 if (!chan || !chan->ops->read) in chan_interrupt()
553 err = chan->ops->read(chan->fd, &c, chan->data); in chan_interrupt()
559 if (chan->primary) { in chan_interrupt()
561 if (line->chan_out != chan) in chan_interrupt()
564 close_one_chan(chan, 1); in chan_interrupt()
565 if (chan->primary) in chan_interrupt()