[PATCH] uml console channels: remove console_write wrappers
[linux-2.6/libata-dev.git] / arch / um / drivers / tty.c
blob94c9265a4f2ca54e034f4f79c11bf48ee061bdf2
1 /*
2 * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
6 #include <stdio.h>
7 #include <termios.h>
8 #include <errno.h>
9 #include <unistd.h>
10 #include "chan_user.h"
11 #include "user_util.h"
12 #include "user.h"
13 #include "os.h"
15 struct tty_chan {
16 char *dev;
17 int raw;
18 struct termios tt;
21 static void *tty_chan_init(char *str, int device, struct chan_opts *opts)
23 struct tty_chan *data;
25 if(*str != ':'){
26 printk("tty_init : channel type 'tty' must specify "
27 "a device\n");
28 return(NULL);
30 str++;
32 data = um_kmalloc(sizeof(*data));
33 if(data == NULL)
34 return(NULL);
35 *data = ((struct tty_chan) { .dev = str,
36 .raw = opts->raw });
38 return(data);
41 static int tty_open(int input, int output, int primary, void *d,
42 char **dev_out)
44 struct tty_chan *data = d;
45 int fd, err;
47 fd = os_open_file(data->dev, of_set_rw(OPENFLAGS(), input, output), 0);
48 if(fd < 0) return(fd);
49 if(data->raw){
50 CATCH_EINTR(err = tcgetattr(fd, &data->tt));
51 if(err)
52 return(err);
54 err = raw(fd);
55 if(err)
56 return(err);
59 *dev_out = data->dev;
60 return(fd);
63 struct chan_ops tty_ops = {
64 .type = "tty",
65 .init = tty_chan_init,
66 .open = tty_open,
67 .close = generic_close,
68 .read = generic_read,
69 .write = generic_write,
70 .console_write = generic_console_write,
71 .window_size = generic_window_size,
72 .free = generic_free,
73 .winch = 0,
77 * Overrides for Emacs so that we follow Linus's tabbing style.
78 * Emacs will notice this stuff at the end of the file and automatically
79 * adjust the settings for this buffer only. This must remain at the end
80 * of the file.
81 * ---------------------------------------------------------------------------
82 * Local variables:
83 * c-file-style: "linux"
84 * End: