aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers/fd.c
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-10-16 04:26:41 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:43:04 -0400
commite99525f9706900417f37721e601d2b414d41bfee (patch)
treefb407ea65a7c4c8bf457dd2ccab98842570cc62f /arch/um/drivers/fd.c
parent79f662334fefa2dd3fdf66c44a4d2dca5e378ab4 (diff)
uml: console subsystem tidying
This does a lot of cleanup on the UML console system. This patch should be entirely non-functional. The tidying is as follows: header cleanups - the includes should be closer to minimal and complete all printks now have a severity lots of style fixes fd_close is restructured a little in order to reduce the nesting some functions were calling the os_* wrappers when they can call libc directly port_accept had a unnecessary variable it also tested a pid unecessarily before killing it some functions were made static xterm_free is gone, as it was identical to generic_free Signed-off-by: Jeff Dike <jdike@linux.intel.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/drivers/fd.c')
-rw-r--r--arch/um/drivers/fd.c74
1 files changed, 35 insertions, 39 deletions
diff --git a/arch/um/drivers/fd.c b/arch/um/drivers/fd.c
index 39c01ffd45c..207b0444c9d 100644
--- a/arch/um/drivers/fd.c
+++ b/arch/um/drivers/fd.c
@@ -1,17 +1,19 @@
1/* 1/*
2 * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include <stdio.h> 6#include <stddef.h>
7#include <stdlib.h> 7#include <stdlib.h>
8#include <unistd.h> 8#include <stdio.h>
9#include <termios.h>
10#include <errno.h> 9#include <errno.h>
11#include "user.h" 10#include <termios.h>
11#include <unistd.h>
12#include "chan_user.h" 12#include "chan_user.h"
13#include "os.h"
14#include "um_malloc.h" 13#include "um_malloc.h"
14#include "user.h"
15#include "os.h"
16#include "kern_constants.h"
15 17
16struct fd_chan { 18struct fd_chan {
17 int fd; 19 int fd;
@@ -26,22 +28,26 @@ static void *fd_init(char *str, int device, const struct chan_opts *opts)
26 char *end; 28 char *end;
27 int n; 29 int n;
28 30
29 if(*str != ':'){ 31 if (*str != ':') {
30 printk("fd_init : channel type 'fd' must specify a file " 32 printk(UM_KERN_ERR "fd_init : channel type 'fd' must specify a "
31 "descriptor\n"); 33 "file descriptor\n");
32 return(NULL); 34 return NULL;
33 } 35 }
34 str++; 36 str++;
35 n = strtoul(str, &end, 0); 37 n = strtoul(str, &end, 0);
36 if((*end != '\0') || (end == str)){ 38 if ((*end != '\0') || (end == str)) {
37 printk("fd_init : couldn't parse file descriptor '%s'\n", str); 39 printk(UM_KERN_ERR "fd_init : couldn't parse file descriptor "
38 return(NULL); 40 "'%s'\n", str);
41 return NULL;
39 } 42 }
43
40 data = kmalloc(sizeof(*data), UM_GFP_KERNEL); 44 data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
41 if(data == NULL) return(NULL); 45 if(data == NULL)
46 return NULL;
47
42 *data = ((struct fd_chan) { .fd = n, 48 *data = ((struct fd_chan) { .fd = n,
43 .raw = opts->raw }); 49 .raw = opts->raw });
44 return(data); 50 return data;
45} 51}
46 52
47static int fd_open(int input, int output, int primary, void *d, char **dev_out) 53static int fd_open(int input, int output, int primary, void *d, char **dev_out)
@@ -49,18 +55,18 @@ static int fd_open(int input, int output, int primary, void *d, char **dev_out)
49 struct fd_chan *data = d; 55 struct fd_chan *data = d;
50 int err; 56 int err;
51 57
52 if(data->raw && isatty(data->fd)){ 58 if (data->raw && isatty(data->fd)) {
53 CATCH_EINTR(err = tcgetattr(data->fd, &data->tt)); 59 CATCH_EINTR(err = tcgetattr(data->fd, &data->tt));
54 if(err) 60 if (err)
55 return(err); 61 return err;
56 62
57 err = raw(data->fd); 63 err = raw(data->fd);
58 if(err) 64 if (err)
59 return(err); 65 return err;
60 } 66 }
61 sprintf(data->str, "%d", data->fd); 67 sprintf(data->str, "%d", data->fd);
62 *dev_out = data->str; 68 *dev_out = data->str;
63 return(data->fd); 69 return data->fd;
64} 70}
65 71
66static void fd_close(int fd, void *d) 72static void fd_close(int fd, void *d)
@@ -68,13 +74,14 @@ static void fd_close(int fd, void *d)
68 struct fd_chan *data = d; 74 struct fd_chan *data = d;
69 int err; 75 int err;
70 76
71 if(data->raw && isatty(fd)){ 77 if (!data->raw || !isatty(fd))
72 CATCH_EINTR(err = tcsetattr(fd, TCSAFLUSH, &data->tt)); 78 return;
73 if(err) 79
74 printk("Failed to restore terminal state - " 80 CATCH_EINTR(err = tcsetattr(fd, TCSAFLUSH, &data->tt));
75 "errno = %d\n", -err); 81 if (err)
76 data->raw = 0; 82 printk(UM_KERN_ERR "Failed to restore terminal state - "
77 } 83 "errno = %d\n", -err);
84 data->raw = 0;
78} 85}
79 86
80const struct chan_ops fd_ops = { 87const struct chan_ops fd_ops = {
@@ -89,14 +96,3 @@ const struct chan_ops fd_ops = {
89 .free = generic_free, 96 .free = generic_free,
90 .winch = 1, 97 .winch = 1,
91}; 98};
92
93/*
94 * Overrides for Emacs so that we follow Linus's tabbing style.
95 * Emacs will notice this stuff at the end of the file and automatically
96 * adjust the settings for this buffer only. This must remain at the end
97 * of the file.
98 * ---------------------------------------------------------------------------
99 * Local variables:
100 * c-file-style: "linux"
101 * End:
102 */