aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-02-10 04:44:02 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-11 13:51:21 -0500
commit67608e0c809ceca1b44755ee818199af7478ca77 (patch)
treea407374a1accc3d11494e9b770dd9e936691890c /arch/um
parentd832fc60d533d52da7170cf5f95271c331259bca (diff)
[PATCH] uml: port driver formatting
Whitespace and style fixes. Signed-off-by: Jeff Dike <jdike@addtoit.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')
-rw-r--r--arch/um/drivers/port_kern.c46
-rw-r--r--arch/um/drivers/port_user.c51
2 files changed, 43 insertions, 54 deletions
diff --git a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c
index c688da722177..4dd7d8a11db2 100644
--- a/arch/um/drivers/port_kern.c
+++ b/arch/um/drivers/port_kern.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -55,9 +55,9 @@ static irqreturn_t pipe_interrupt(int irq, void *data)
55 fd = os_rcv_fd(conn->socket[0], &conn->helper_pid); 55 fd = os_rcv_fd(conn->socket[0], &conn->helper_pid);
56 if(fd < 0){ 56 if(fd < 0){
57 if(fd == -EAGAIN) 57 if(fd == -EAGAIN)
58 return(IRQ_NONE); 58 return IRQ_NONE;
59 59
60 printk(KERN_ERR "pipe_interrupt : os_rcv_fd returned %d\n", 60 printk(KERN_ERR "pipe_interrupt : os_rcv_fd returned %d\n",
61 -fd); 61 -fd);
62 os_close_file(conn->fd); 62 os_close_file(conn->fd);
63 } 63 }
@@ -68,7 +68,7 @@ static irqreturn_t pipe_interrupt(int irq, void *data)
68 list_add(&conn->list, &conn->port->connections); 68 list_add(&conn->list, &conn->port->connections);
69 69
70 complete(&conn->port->done); 70 complete(&conn->port->done);
71 return(IRQ_HANDLED); 71 return IRQ_HANDLED;
72} 72}
73 73
74#define NO_WAITER_MSG \ 74#define NO_WAITER_MSG \
@@ -97,14 +97,14 @@ static int port_accept(struct port_list *port)
97 "connection\n"); 97 "connection\n");
98 goto out_close; 98 goto out_close;
99 } 99 }
100 *conn = ((struct connection) 100 *conn = ((struct connection)
101 { .list = LIST_HEAD_INIT(conn->list), 101 { .list = LIST_HEAD_INIT(conn->list),
102 .fd = fd, 102 .fd = fd,
103 .socket = { socket[0], socket[1] }, 103 .socket = { socket[0], socket[1] },
104 .telnetd_pid = pid, 104 .telnetd_pid = pid,
105 .port = port }); 105 .port = port });
106 106
107 if(um_request_irq(TELNETD_IRQ, socket[0], IRQ_READ, pipe_interrupt, 107 if(um_request_irq(TELNETD_IRQ, socket[0], IRQ_READ, pipe_interrupt,
108 IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM, 108 IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM,
109 "telnetd", conn)){ 109 "telnetd", conn)){
110 printk(KERN_ERR "port_accept : failed to get IRQ for " 110 printk(KERN_ERR "port_accept : failed to get IRQ for "
@@ -117,17 +117,17 @@ static int port_accept(struct port_list *port)
117 printk("No one waiting for port\n"); 117 printk("No one waiting for port\n");
118 } 118 }
119 list_add(&conn->list, &port->pending); 119 list_add(&conn->list, &port->pending);
120 return(1); 120 return 1;
121 121
122 out_free: 122 out_free:
123 kfree(conn); 123 kfree(conn);
124 out_close: 124 out_close:
125 os_close_file(fd); 125 os_close_file(fd);
126 if(pid != -1) 126 if(pid != -1)
127 os_kill_process(pid, 1); 127 os_kill_process(pid, 1);
128 out: 128 out:
129 return(ret); 129 return ret;
130} 130}
131 131
132static DECLARE_MUTEX(ports_sem); 132static DECLARE_MUTEX(ports_sem);
133static struct list_head ports = LIST_HEAD_INIT(ports); 133static struct list_head ports = LIST_HEAD_INIT(ports);
@@ -158,8 +158,8 @@ static irqreturn_t port_interrupt(int irq, void *data)
158 158
159 port->has_connection = 1; 159 port->has_connection = 1;
160 schedule_work(&port_work); 160 schedule_work(&port_work);
161 return(IRQ_HANDLED); 161 return IRQ_HANDLED;
162} 162}
163 163
164void *port_data(int port_num) 164void *port_data(int port_num)
165{ 165{
@@ -185,14 +185,14 @@ void *port_data(int port_num)
185 port_num, -fd); 185 port_num, -fd);
186 goto out_free; 186 goto out_free;
187 } 187 }
188 if(um_request_irq(ACCEPT_IRQ, fd, IRQ_READ, port_interrupt, 188 if(um_request_irq(ACCEPT_IRQ, fd, IRQ_READ, port_interrupt,
189 IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM, "port", 189 IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM,
190 port)){ 190 "port", port)){
191 printk(KERN_ERR "Failed to get IRQ for port %d\n", port_num); 191 printk(KERN_ERR "Failed to get IRQ for port %d\n", port_num);
192 goto out_close; 192 goto out_close;
193 } 193 }
194 194
195 *port = ((struct port_list) 195 *port = ((struct port_list)
196 { .list = LIST_HEAD_INIT(port->list), 196 { .list = LIST_HEAD_INIT(port->list),
197 .wait_count = ATOMIC_INIT(0), 197 .wait_count = ATOMIC_INIT(0),
198 .has_connection = 0, 198 .has_connection = 0,
@@ -222,7 +222,7 @@ void *port_data(int port_num)
222 os_close_file(fd); 222 os_close_file(fd);
223 out: 223 out:
224 up(&ports_sem); 224 up(&ports_sem);
225 return(dev); 225 return dev;
226} 226}
227 227
228int port_wait(void *data) 228int port_wait(void *data)
@@ -232,15 +232,15 @@ int port_wait(void *data)
232 struct port_list *port = dev->port; 232 struct port_list *port = dev->port;
233 int fd; 233 int fd;
234 234
235 atomic_inc(&port->wait_count); 235 atomic_inc(&port->wait_count);
236 while(1){ 236 while(1){
237 fd = -ERESTARTSYS; 237 fd = -ERESTARTSYS;
238 if(wait_for_completion_interruptible(&port->done)) 238 if(wait_for_completion_interruptible(&port->done))
239 goto out; 239 goto out;
240 240
241 spin_lock(&port->lock); 241 spin_lock(&port->lock);
242 242
243 conn = list_entry(port->connections.next, struct connection, 243 conn = list_entry(port->connections.next, struct connection,
244 list); 244 list);
245 list_del(&conn->list); 245 list_del(&conn->list);
246 spin_unlock(&port->lock); 246 spin_unlock(&port->lock);
@@ -248,12 +248,12 @@ int port_wait(void *data)
248 os_shutdown_socket(conn->socket[0], 1, 1); 248 os_shutdown_socket(conn->socket[0], 1, 1);
249 os_close_file(conn->socket[0]); 249 os_close_file(conn->socket[0]);
250 os_shutdown_socket(conn->socket[1], 1, 1); 250 os_shutdown_socket(conn->socket[1], 1, 1);
251 os_close_file(conn->socket[1]); 251 os_close_file(conn->socket[1]);
252 252
253 /* This is done here because freeing an IRQ can't be done 253 /* This is done here because freeing an IRQ can't be done
254 * within the IRQ handler. So, pipe_interrupt always ups 254 * within the IRQ handler. So, pipe_interrupt always ups
255 * the semaphore regardless of whether it got a successful 255 * the semaphore regardless of whether it got a successful
256 * connection. Then we loop here throwing out failed 256 * connection. Then we loop here throwing out failed
257 * connections until a good one is found. 257 * connections until a good one is found.
258 */ 258 */
259 free_irq(TELNETD_IRQ, conn); 259 free_irq(TELNETD_IRQ, conn);
diff --git a/arch/um/drivers/port_user.c b/arch/um/drivers/port_user.c
index bc6afaf74c1a..80508023054f 100644
--- a/arch/um/drivers/port_user.c
+++ b/arch/um/drivers/port_user.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -38,18 +38,18 @@ static void *port_init(char *str, int device, const struct chan_opts *opts)
38 if(*str != ':'){ 38 if(*str != ':'){
39 printk("port_init : channel type 'port' must specify a " 39 printk("port_init : channel type 'port' must specify a "
40 "port number\n"); 40 "port number\n");
41 return(NULL); 41 return NULL;
42 } 42 }
43 str++; 43 str++;
44 port = strtoul(str, &end, 0); 44 port = strtoul(str, &end, 0);
45 if((*end != '\0') || (end == str)){ 45 if((*end != '\0') || (end == str)){
46 printk("port_init : couldn't parse port '%s'\n", str); 46 printk("port_init : couldn't parse port '%s'\n", str);
47 return(NULL); 47 return NULL;
48 } 48 }
49 49
50 kern_data = port_data(port); 50 kern_data = port_data(port);
51 if(kern_data == NULL) 51 if(kern_data == NULL)
52 return(NULL); 52 return NULL;
53 53
54 data = um_kmalloc(sizeof(*data)); 54 data = um_kmalloc(sizeof(*data));
55 if(data == NULL) 55 if(data == NULL)
@@ -59,10 +59,10 @@ static void *port_init(char *str, int device, const struct chan_opts *opts)
59 .kernel_data = kern_data }); 59 .kernel_data = kern_data });
60 sprintf(data->dev, "%d", port); 60 sprintf(data->dev, "%d", port);
61 61
62 return(data); 62 return data;
63 err: 63 err:
64 port_kern_free(kern_data); 64 port_kern_free(kern_data);
65 return(NULL); 65 return NULL;
66} 66}
67 67
68static void port_free(void *d) 68static void port_free(void *d)
@@ -83,14 +83,14 @@ static int port_open(int input, int output, int primary, void *d,
83 if((fd >= 0) && data->raw){ 83 if((fd >= 0) && data->raw){
84 CATCH_EINTR(err = tcgetattr(fd, &data->tt)); 84 CATCH_EINTR(err = tcgetattr(fd, &data->tt));
85 if(err) 85 if(err)
86 return(err); 86 return err;
87 87
88 err = raw(fd); 88 err = raw(fd);
89 if(err) 89 if(err)
90 return(err); 90 return err;
91 } 91 }
92 *dev_out = data->dev; 92 *dev_out = data->dev;
93 return(fd); 93 return fd;
94} 94}
95 95
96static void port_close(int fd, void *d) 96static void port_close(int fd, void *d)
@@ -120,8 +120,8 @@ int port_listen_fd(int port)
120 int fd, err, arg; 120 int fd, err, arg;
121 121
122 fd = socket(PF_INET, SOCK_STREAM, 0); 122 fd = socket(PF_INET, SOCK_STREAM, 0);
123 if(fd == -1) 123 if(fd == -1)
124 return(-errno); 124 return -errno;
125 125
126 arg = 1; 126 arg = 1;
127 if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &arg, sizeof(arg)) < 0){ 127 if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &arg, sizeof(arg)) < 0){
@@ -136,7 +136,7 @@ int port_listen_fd(int port)
136 err = -errno; 136 err = -errno;
137 goto out; 137 goto out;
138 } 138 }
139 139
140 if(listen(fd, 1) < 0){ 140 if(listen(fd, 1) < 0){
141 err = -errno; 141 err = -errno;
142 goto out; 142 goto out;
@@ -146,10 +146,10 @@ int port_listen_fd(int port)
146 if(err < 0) 146 if(err < 0)
147 goto out; 147 goto out;
148 148
149 return(fd); 149 return fd;
150 out: 150 out:
151 os_close_file(fd); 151 os_close_file(fd);
152 return(err); 152 return err;
153} 153}
154 154
155struct port_pre_exec_data { 155struct port_pre_exec_data {
@@ -173,13 +173,13 @@ void port_pre_exec(void *arg)
173int port_connection(int fd, int *socket, int *pid_out) 173int port_connection(int fd, int *socket, int *pid_out)
174{ 174{
175 int new, err; 175 int new, err;
176 char *argv[] = { "/usr/sbin/in.telnetd", "-L", 176 char *argv[] = { "/usr/sbin/in.telnetd", "-L",
177 "/usr/lib/uml/port-helper", NULL }; 177 "/usr/lib/uml/port-helper", NULL };
178 struct port_pre_exec_data data; 178 struct port_pre_exec_data data;
179 179
180 new = os_accept_connection(fd); 180 new = os_accept_connection(fd);
181 if(new < 0) 181 if(new < 0)
182 return(new); 182 return new;
183 183
184 err = os_pipe(socket, 0, 0); 184 err = os_pipe(socket, 0, 0);
185 if(err < 0) 185 if(err < 0)
@@ -190,29 +190,18 @@ int port_connection(int fd, int *socket, int *pid_out)
190 .pipe_fd = socket[1] }); 190 .pipe_fd = socket[1] });
191 191
192 err = run_helper(port_pre_exec, &data, argv, NULL); 192 err = run_helper(port_pre_exec, &data, argv, NULL);
193 if(err < 0) 193 if(err < 0)
194 goto out_shutdown; 194 goto out_shutdown;
195 195
196 *pid_out = err; 196 *pid_out = err;
197 return(new); 197 return new;
198 198
199 out_shutdown: 199 out_shutdown:
200 os_shutdown_socket(socket[0], 1, 1); 200 os_shutdown_socket(socket[0], 1, 1);
201 os_close_file(socket[0]); 201 os_close_file(socket[0]);
202 os_shutdown_socket(socket[1], 1, 1); 202 os_shutdown_socket(socket[1], 1, 1);
203 os_close_file(socket[1]); 203 os_close_file(socket[1]);
204 out_close: 204 out_close:
205 os_close_file(new); 205 os_close_file(new);
206 return(err); 206 return err;
207} 207}
208
209/*
210 * Overrides for Emacs so that we follow Linus's tabbing style.
211 * Emacs will notice this stuff at the end of the file and automatically
212 * adjust the settings for this buffer only. This must remain at the end
213 * of the file.
214 * ---------------------------------------------------------------------------
215 * Local variables:
216 * c-file-style: "linux"
217 * End:
218 */