blob: 31b69c4ea800971748fe80d042b11b6cc8de69a8 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#include <linux/stddef.h>
7#include <linux/kernel.h>
8#include <linux/list.h>
9#include <linux/slab.h>
10#include <linux/tty.h>
11#include <linux/string.h>
12#include <linux/tty_flip.h>
13#include <asm/irq.h>
14#include "chan_kern.h"
15#include "user_util.h"
16#include "kern.h"
17#include "irq_user.h"
18#include "sigio.h"
19#include "line.h"
20#include "os.h"
21
Paolo 'Blaisorblade' Giarrussofac97ae2005-09-22 21:44:22 -070022/* XXX: could well be moved to somewhere else, if needed. */
23static int my_printf(const char * fmt, ...)
24 __attribute__ ((format (printf, 1, 2)));
Jeff Dike84ddaa82005-05-20 13:59:12 -070025
Paolo 'Blaisorblade' Giarrussofac97ae2005-09-22 21:44:22 -070026static int my_printf(const char * fmt, ...)
27{
28 /* Yes, can be called on atomic context.*/
29 char *buf = kmalloc(4096, GFP_ATOMIC);
30 va_list args;
31 int r;
32
33 if (!buf) {
34 /* We print directly fmt.
35 * Yes, yes, yes, feel free to complain. */
36 r = strlen(fmt);
37 } else {
38 va_start(args, fmt);
39 r = vsprintf(buf, fmt, args);
40 va_end(args);
41 fmt = buf;
42 }
43
44 if (r)
45 r = os_write_file(1, fmt, r);
46 return r;
47
48}
49
50#ifdef CONFIG_NOCONFIG_CHAN
51/* Despite its name, there's no added trailing newline. */
52static int my_puts(const char * buf)
53{
54 return os_write_file(1, buf, strlen(buf));
55}
Jeff Dike84ddaa82005-05-20 13:59:12 -070056
Linus Torvalds1da177e2005-04-16 15:20:36 -070057static void *not_configged_init(char *str, int device, struct chan_opts *opts)
58{
Paolo 'Blaisorblade' Giarrussofac97ae2005-09-22 21:44:22 -070059 my_puts("Using a channel type which is configured out of "
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 "UML\n");
Jeff Diked50084a2006-01-06 00:18:50 -080061 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -070062}
63
64static int not_configged_open(int input, int output, int primary, void *data,
65 char **dev_out)
66{
Paolo 'Blaisorblade' Giarrussofac97ae2005-09-22 21:44:22 -070067 my_puts("Using a channel type which is configured out of "
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 "UML\n");
Jeff Diked50084a2006-01-06 00:18:50 -080069 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070}
71
72static void not_configged_close(int fd, void *data)
73{
Paolo 'Blaisorblade' Giarrussofac97ae2005-09-22 21:44:22 -070074 my_puts("Using a channel type which is configured out of "
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 "UML\n");
76}
77
78static int not_configged_read(int fd, char *c_out, void *data)
79{
Paolo 'Blaisorblade' Giarrussofac97ae2005-09-22 21:44:22 -070080 my_puts("Using a channel type which is configured out of "
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 "UML\n");
Jeff Diked50084a2006-01-06 00:18:50 -080082 return -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -070083}
84
85static int not_configged_write(int fd, const char *buf, int len, void *data)
86{
Paolo 'Blaisorblade' Giarrussofac97ae2005-09-22 21:44:22 -070087 my_puts("Using a channel type which is configured out of "
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 "UML\n");
Jeff Diked50084a2006-01-06 00:18:50 -080089 return -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -070090}
91
Paolo 'Blaisorblade' Giarrusso55c033c2005-11-13 16:07:11 -080092static int not_configged_console_write(int fd, const char *buf, int len)
Linus Torvalds1da177e2005-04-16 15:20:36 -070093{
Paolo 'Blaisorblade' Giarrussofac97ae2005-09-22 21:44:22 -070094 my_puts("Using a channel type which is configured out of "
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 "UML\n");
Jeff Diked50084a2006-01-06 00:18:50 -080096 return -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097}
98
99static int not_configged_window_size(int fd, void *data, unsigned short *rows,
100 unsigned short *cols)
101{
Paolo 'Blaisorblade' Giarrussofac97ae2005-09-22 21:44:22 -0700102 my_puts("Using a channel type which is configured out of "
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 "UML\n");
Jeff Diked50084a2006-01-06 00:18:50 -0800104 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105}
106
107static void not_configged_free(void *data)
108{
Paolo 'Blaisorblade' Giarrussofac97ae2005-09-22 21:44:22 -0700109 my_puts("Using a channel type which is configured out of "
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 "UML\n");
111}
112
113static struct chan_ops not_configged_ops = {
114 .init = not_configged_init,
115 .open = not_configged_open,
116 .close = not_configged_close,
117 .read = not_configged_read,
118 .write = not_configged_write,
119 .console_write = not_configged_console_write,
120 .window_size = not_configged_window_size,
121 .free = not_configged_free,
122 .winch = 0,
123};
124#endif /* CONFIG_NOCONFIG_CHAN */
125
126void generic_close(int fd, void *unused)
127{
128 os_close_file(fd);
129}
130
131int generic_read(int fd, char *c_out, void *unused)
132{
133 int n;
134
135 n = os_read_file(fd, c_out, sizeof(*c_out));
136
137 if(n == -EAGAIN)
Jeff Diked50084a2006-01-06 00:18:50 -0800138 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 else if(n == 0)
Jeff Diked50084a2006-01-06 00:18:50 -0800140 return -EIO;
141 return n;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142}
143
144/* XXX Trivial wrapper around os_write_file */
145
146int generic_write(int fd, const char *buf, int n, void *unused)
147{
Jeff Diked50084a2006-01-06 00:18:50 -0800148 return os_write_file(fd, buf, n);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149}
150
151int generic_window_size(int fd, void *unused, unsigned short *rows_out,
152 unsigned short *cols_out)
153{
154 int rows, cols;
155 int ret;
156
157 ret = os_window_size(fd, &rows, &cols);
158 if(ret < 0)
Jeff Diked50084a2006-01-06 00:18:50 -0800159 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160
161 ret = ((*rows_out != rows) || (*cols_out != cols));
162
163 *rows_out = rows;
164 *cols_out = cols;
165
Jeff Diked50084a2006-01-06 00:18:50 -0800166 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167}
168
169void generic_free(void *data)
170{
171 kfree(data);
172}
173
174static void tty_receive_char(struct tty_struct *tty, char ch)
175{
176 if(tty == NULL) return;
177
178 if(I_IXON(tty) && !I_IXOFF(tty) && !tty->raw) {
179 if(ch == STOP_CHAR(tty)){
180 stop_tty(tty);
181 return;
182 }
183 else if(ch == START_CHAR(tty)){
184 start_tty(tty);
185 return;
186 }
187 }
188
Jeff Diked50084a2006-01-06 00:18:50 -0800189 if((tty->flip.flag_buf_ptr == NULL) ||
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 (tty->flip.char_buf_ptr == NULL))
191 return;
192 tty_insert_flip_char(tty, ch, TTY_NORMAL);
193}
194
Jeff Diked50084a2006-01-06 00:18:50 -0800195static int open_one_chan(struct chan *chan)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196{
197 int fd;
198
Jeff Diked50084a2006-01-06 00:18:50 -0800199 if(chan->opened)
200 return 0;
201
202 if(chan->ops->open == NULL)
203 fd = 0;
204 else fd = (*chan->ops->open)(chan->input, chan->output, chan->primary,
205 chan->data, &chan->dev);
206 if(fd < 0)
207 return fd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 chan->fd = fd;
209
210 chan->opened = 1;
Jeff Diked50084a2006-01-06 00:18:50 -0800211 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212}
213
214int open_chan(struct list_head *chans)
215{
216 struct list_head *ele;
217 struct chan *chan;
218 int ret, err = 0;
219
220 list_for_each(ele, chans){
221 chan = list_entry(ele, struct chan, list);
Jeff Diked50084a2006-01-06 00:18:50 -0800222 ret = open_one_chan(chan);
223 if(chan->primary)
224 err = ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 }
Jeff Diked50084a2006-01-06 00:18:50 -0800226 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227}
228
229void chan_enable_winch(struct list_head *chans, struct tty_struct *tty)
230{
231 struct list_head *ele;
232 struct chan *chan;
233
234 list_for_each(ele, chans){
235 chan = list_entry(ele, struct chan, list);
236 if(chan->primary && chan->output && chan->ops->winch){
237 register_winch(chan->fd, tty);
238 return;
239 }
240 }
241}
242
243void enable_chan(struct list_head *chans, struct tty_struct *tty)
244{
245 struct list_head *ele;
246 struct chan *chan;
247
248 list_for_each(ele, chans){
249 chan = list_entry(ele, struct chan, list);
250 if(!chan->opened) continue;
251
252 line_setup_irq(chan->fd, chan->input, chan->output, tty);
253 }
254}
255
256void close_chan(struct list_head *chans)
257{
258 struct chan *chan;
259
260 /* Close in reverse order as open in case more than one of them
261 * refers to the same device and they save and restore that device's
262 * state. Then, the first one opened will have the original state,
263 * so it must be the last closed.
264 */
265 list_for_each_entry_reverse(chan, chans, list) {
266 if(!chan->opened) continue;
267 if(chan->ops->close != NULL)
268 (*chan->ops->close)(chan->fd, chan->data);
269 chan->opened = 0;
270 chan->fd = -1;
271 }
272}
273
Jeff Diked50084a2006-01-06 00:18:50 -0800274int write_chan(struct list_head *chans, const char *buf, int len,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 int write_irq)
276{
277 struct list_head *ele;
278 struct chan *chan = NULL;
279 int n, ret = 0;
280
281 list_for_each(ele, chans) {
282 chan = list_entry(ele, struct chan, list);
283 if (!chan->output || (chan->ops->write == NULL))
284 continue;
285 n = chan->ops->write(chan->fd, buf, len, chan->data);
286 if (chan->primary) {
287 ret = n;
288 if ((ret == -EAGAIN) || ((ret >= 0) && (ret < len)))
289 reactivate_fd(chan->fd, write_irq);
290 }
291 }
Jeff Diked50084a2006-01-06 00:18:50 -0800292 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293}
294
295int console_write_chan(struct list_head *chans, const char *buf, int len)
296{
297 struct list_head *ele;
298 struct chan *chan;
299 int n, ret = 0;
300
301 list_for_each(ele, chans){
302 chan = list_entry(ele, struct chan, list);
303 if(!chan->output || (chan->ops->console_write == NULL))
304 continue;
Paolo 'Blaisorblade' Giarrusso55c033c2005-11-13 16:07:11 -0800305 n = chan->ops->console_write(chan->fd, buf, len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 if(chan->primary) ret = n;
307 }
Jeff Diked50084a2006-01-06 00:18:50 -0800308 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309}
310
Jeff Diked50084a2006-01-06 00:18:50 -0800311int console_open_chan(struct line *line, struct console *co,
312 struct chan_opts *opts)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313{
Jeff Dike1f801712006-01-06 00:18:55 -0800314 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315
Jeff Dike1f801712006-01-06 00:18:55 -0800316 err = open_chan(&line->chan_list);
317 if(err)
318 return err;
319
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 printk("Console initialized on /dev/%s%d\n",co->name,co->index);
321 return 0;
322}
323
324int chan_window_size(struct list_head *chans, unsigned short *rows_out,
325 unsigned short *cols_out)
326{
327 struct list_head *ele;
328 struct chan *chan;
329
330 list_for_each(ele, chans){
331 chan = list_entry(ele, struct chan, list);
332 if(chan->primary){
Jeff Diked50084a2006-01-06 00:18:50 -0800333 if(chan->ops->window_size == NULL)
334 return 0;
335 return chan->ops->window_size(chan->fd, chan->data,
336 rows_out, cols_out);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 }
338 }
Jeff Diked50084a2006-01-06 00:18:50 -0800339 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340}
341
342void free_one_chan(struct chan *chan)
343{
344 list_del(&chan->list);
345 if(chan->ops->free != NULL)
346 (*chan->ops->free)(chan->data);
347 free_irq_by_fd(chan->fd);
348 if(chan->primary && chan->output) ignore_sigio_fd(chan->fd);
349 kfree(chan);
350}
351
352void free_chan(struct list_head *chans)
353{
354 struct list_head *ele, *next;
355 struct chan *chan;
356
357 list_for_each_safe(ele, next, chans){
358 chan = list_entry(ele, struct chan, list);
359 free_one_chan(chan);
360 }
361}
362
363static int one_chan_config_string(struct chan *chan, char *str, int size,
364 char **error_out)
365{
366 int n = 0;
367
368 if(chan == NULL){
369 CONFIG_CHUNK(str, size, n, "none", 1);
Jeff Diked50084a2006-01-06 00:18:50 -0800370 return n;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 }
372
373 CONFIG_CHUNK(str, size, n, chan->ops->type, 0);
374
375 if(chan->dev == NULL){
376 CONFIG_CHUNK(str, size, n, "", 1);
Jeff Diked50084a2006-01-06 00:18:50 -0800377 return n;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 }
379
380 CONFIG_CHUNK(str, size, n, ":", 0);
381 CONFIG_CHUNK(str, size, n, chan->dev, 0);
382
Jeff Diked50084a2006-01-06 00:18:50 -0800383 return n;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384}
385
Jeff Diked50084a2006-01-06 00:18:50 -0800386static int chan_pair_config_string(struct chan *in, struct chan *out,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 char *str, int size, char **error_out)
388{
389 int n;
390
391 n = one_chan_config_string(in, str, size, error_out);
392 str += n;
393 size -= n;
394
395 if(in == out){
396 CONFIG_CHUNK(str, size, n, "", 1);
Jeff Diked50084a2006-01-06 00:18:50 -0800397 return n;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 }
399
400 CONFIG_CHUNK(str, size, n, ",", 1);
401 n = one_chan_config_string(out, str, size, error_out);
402 str += n;
403 size -= n;
404 CONFIG_CHUNK(str, size, n, "", 1);
405
Jeff Diked50084a2006-01-06 00:18:50 -0800406 return n;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407}
408
Jeff Diked50084a2006-01-06 00:18:50 -0800409int chan_config_string(struct list_head *chans, char *str, int size,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 char **error_out)
411{
412 struct list_head *ele;
413 struct chan *chan, *in = NULL, *out = NULL;
414
415 list_for_each(ele, chans){
416 chan = list_entry(ele, struct chan, list);
417 if(!chan->primary)
418 continue;
419 if(chan->input)
420 in = chan;
421 if(chan->output)
422 out = chan;
423 }
424
Jeff Diked50084a2006-01-06 00:18:50 -0800425 return chan_pair_config_string(in, out, str, size, error_out);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426}
427
428struct chan_type {
429 char *key;
430 struct chan_ops *ops;
431};
432
433struct chan_type chan_table[] = {
434 { "fd", &fd_ops },
435
436#ifdef CONFIG_NULL_CHAN
437 { "null", &null_ops },
438#else
439 { "null", &not_configged_ops },
440#endif
441
442#ifdef CONFIG_PORT_CHAN
443 { "port", &port_ops },
444#else
445 { "port", &not_configged_ops },
446#endif
447
448#ifdef CONFIG_PTY_CHAN
449 { "pty", &pty_ops },
450 { "pts", &pts_ops },
451#else
452 { "pty", &not_configged_ops },
453 { "pts", &not_configged_ops },
454#endif
455
456#ifdef CONFIG_TTY_CHAN
457 { "tty", &tty_ops },
458#else
459 { "tty", &not_configged_ops },
460#endif
461
462#ifdef CONFIG_XTERM_CHAN
463 { "xterm", &xterm_ops },
464#else
465 { "xterm", &not_configged_ops },
466#endif
467};
468
Jeff Dike88890b82006-01-06 00:18:52 -0800469static struct chan *parse_chan(char *str, int device, struct chan_opts *opts)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470{
471 struct chan_type *entry;
472 struct chan_ops *ops;
473 struct chan *chan;
474 void *data;
475 int i;
476
477 ops = NULL;
478 data = NULL;
479 for(i = 0; i < sizeof(chan_table)/sizeof(chan_table[0]); i++){
480 entry = &chan_table[i];
481 if(!strncmp(str, entry->key, strlen(entry->key))){
482 ops = entry->ops;
483 str += strlen(entry->key);
484 break;
485 }
486 }
487 if(ops == NULL){
Paolo 'Blaisorblade' Giarrussofac97ae2005-09-22 21:44:22 -0700488 my_printf("parse_chan couldn't parse \"%s\"\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 str);
Jeff Diked50084a2006-01-06 00:18:50 -0800490 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 }
Jeff Diked50084a2006-01-06 00:18:50 -0800492 if(ops->init == NULL)
493 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 data = (*ops->init)(str, device, opts);
Jeff Diked50084a2006-01-06 00:18:50 -0800495 if(data == NULL)
496 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497
Paolo 'Blaisorblade' Giarrusso79ae2cb2005-09-22 21:44:21 -0700498 chan = kmalloc(sizeof(*chan), GFP_ATOMIC);
Jeff Diked50084a2006-01-06 00:18:50 -0800499 if(chan == NULL)
500 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 *chan = ((struct chan) { .list = LIST_HEAD_INIT(chan->list),
502 .primary = 1,
503 .input = 0,
504 .output = 0,
505 .opened = 0,
506 .fd = -1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 .ops = ops,
508 .data = data });
Jeff Diked50084a2006-01-06 00:18:50 -0800509 return chan;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510}
511
Jeff Dike88890b82006-01-06 00:18:52 -0800512int parse_chan_pair(char *str, struct list_head *chans, int device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 struct chan_opts *opts)
514{
515 struct chan *new, *chan;
516 char *in, *out;
517
518 if(!list_empty(chans)){
519 chan = list_entry(chans->next, struct chan, list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 free_chan(chans);
521 INIT_LIST_HEAD(chans);
522 }
523
524 out = strchr(str, ',');
525 if(out != NULL){
526 in = str;
527 *out = '\0';
528 out++;
Jeff Dike88890b82006-01-06 00:18:52 -0800529 new = parse_chan(in, device, opts);
Jeff Diked50084a2006-01-06 00:18:50 -0800530 if(new == NULL)
531 return -1;
532
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 new->input = 1;
534 list_add(&new->list, chans);
535
Jeff Dike88890b82006-01-06 00:18:52 -0800536 new = parse_chan(out, device, opts);
Jeff Diked50084a2006-01-06 00:18:50 -0800537 if(new == NULL)
538 return -1;
539
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 list_add(&new->list, chans);
541 new->output = 1;
542 }
543 else {
Jeff Dike88890b82006-01-06 00:18:52 -0800544 new = parse_chan(str, device, opts);
Jeff Diked50084a2006-01-06 00:18:50 -0800545 if(new == NULL)
546 return -1;
547
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 list_add(&new->list, chans);
549 new->input = 1;
550 new->output = 1;
551 }
Jeff Diked50084a2006-01-06 00:18:50 -0800552 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553}
554
555int chan_out_fd(struct list_head *chans)
556{
557 struct list_head *ele;
558 struct chan *chan;
559
560 list_for_each(ele, chans){
561 chan = list_entry(ele, struct chan, list);
562 if(chan->primary && chan->output)
Jeff Diked50084a2006-01-06 00:18:50 -0800563 return chan->fd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 }
Jeff Diked50084a2006-01-06 00:18:50 -0800565 return -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566}
567
568void chan_interrupt(struct list_head *chans, struct work_struct *task,
569 struct tty_struct *tty, int irq)
570{
571 struct list_head *ele, *next;
572 struct chan *chan;
573 int err;
574 char c;
575
576 list_for_each_safe(ele, next, chans){
577 chan = list_entry(ele, struct chan, list);
578 if(!chan->input || (chan->ops->read == NULL)) continue;
579 do {
Jeff Diked50084a2006-01-06 00:18:50 -0800580 if((tty != NULL) &&
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 (tty->flip.count >= TTY_FLIPBUF_SIZE)){
582 schedule_work(task);
583 goto out;
584 }
585 err = chan->ops->read(chan->fd, &c, chan->data);
586 if(err > 0)
587 tty_receive_char(tty, c);
588 } while(err > 0);
589
590 if(err == 0) reactivate_fd(chan->fd, irq);
591 if(err == -EIO){
592 if(chan->primary){
593 if(tty != NULL)
594 tty_hangup(tty);
595 line_disable(tty, irq);
596 close_chan(chans);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 return;
598 }
599 else {
600 if(chan->ops->close != NULL)
601 chan->ops->close(chan->fd, chan->data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 }
603 }
604 }
605 out:
606 if(tty) tty_flip_buffer_push(tty);
607}
608
609/*
610 * Overrides for Emacs so that we follow Linus's tabbing style.
611 * Emacs will notice this stuff at the end of the file and automatically
612 * adjust the settings for this buffer only. This must remain at the end
613 * of the file.
614 * ---------------------------------------------------------------------------
615 * Local variables:
616 * c-file-style: "linux"
617 * End:
618 */