aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2006-01-06 03:18:50 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-06 11:33:45 -0500
commitd50084a2991f3d9490d5c0f3af72e6fe1515a493 (patch)
tree051d6c46ddab1ee47db40252cdad4cbbe0a04f5b /arch/um
parent1b57e9c27882a908f180d4daf72ee12c6f137178 (diff)
[PATCH] uml: Formatting changes
This patch makes a bunch of non-functional changes - return(foo); becomes return foo; some statements are broken across lines for readability some trailing whitespace is cleaned up open_one_chan took four arguments, three of which could be deduced from the first. Accordingly, they were eliminated. some examples of "} else {" had a newline added some whitespace cleanup in the indentation lines_init got some control flow cleanup some long lines were broken removed another emacs-specific C formatting comment Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/drivers/chan_kern.c124
-rw-r--r--arch/um/drivers/line.c47
-rw-r--r--arch/um/drivers/mconsole_kern.c25
-rw-r--r--arch/um/drivers/ssl.c29
-rw-r--r--arch/um/drivers/stdio_console.c26
-rw-r--r--arch/um/include/chan_kern.h11
-rw-r--r--arch/um/include/line.h22
-rw-r--r--arch/um/os-Linux/aio.c465
8 files changed, 381 insertions, 368 deletions
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index 5b58fad45290..8b1262e9fb66 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -58,7 +58,7 @@ static void *not_configged_init(char *str, int device, struct chan_opts *opts)
58{ 58{
59 my_puts("Using a channel type which is configured out of " 59 my_puts("Using a channel type which is configured out of "
60 "UML\n"); 60 "UML\n");
61 return(NULL); 61 return NULL;
62} 62}
63 63
64static int not_configged_open(int input, int output, int primary, void *data, 64static int not_configged_open(int input, int output, int primary, void *data,
@@ -66,7 +66,7 @@ static int not_configged_open(int input, int output, int primary, void *data,
66{ 66{
67 my_puts("Using a channel type which is configured out of " 67 my_puts("Using a channel type which is configured out of "
68 "UML\n"); 68 "UML\n");
69 return(-ENODEV); 69 return -ENODEV;
70} 70}
71 71
72static void not_configged_close(int fd, void *data) 72static void not_configged_close(int fd, void *data)
@@ -79,21 +79,21 @@ static int not_configged_read(int fd, char *c_out, void *data)
79{ 79{
80 my_puts("Using a channel type which is configured out of " 80 my_puts("Using a channel type which is configured out of "
81 "UML\n"); 81 "UML\n");
82 return(-EIO); 82 return -EIO;
83} 83}
84 84
85static int not_configged_write(int fd, const char *buf, int len, void *data) 85static int not_configged_write(int fd, const char *buf, int len, void *data)
86{ 86{
87 my_puts("Using a channel type which is configured out of " 87 my_puts("Using a channel type which is configured out of "
88 "UML\n"); 88 "UML\n");
89 return(-EIO); 89 return -EIO;
90} 90}
91 91
92static int not_configged_console_write(int fd, const char *buf, int len) 92static int not_configged_console_write(int fd, const char *buf, int len)
93{ 93{
94 my_puts("Using a channel type which is configured out of " 94 my_puts("Using a channel type which is configured out of "
95 "UML\n"); 95 "UML\n");
96 return(-EIO); 96 return -EIO;
97} 97}
98 98
99static int not_configged_window_size(int fd, void *data, unsigned short *rows, 99static int not_configged_window_size(int fd, void *data, unsigned short *rows,
@@ -101,7 +101,7 @@ static int not_configged_window_size(int fd, void *data, unsigned short *rows,
101{ 101{
102 my_puts("Using a channel type which is configured out of " 102 my_puts("Using a channel type which is configured out of "
103 "UML\n"); 103 "UML\n");
104 return(-ENODEV); 104 return -ENODEV;
105} 105}
106 106
107static void not_configged_free(void *data) 107static void not_configged_free(void *data)
@@ -135,17 +135,17 @@ int generic_read(int fd, char *c_out, void *unused)
135 n = os_read_file(fd, c_out, sizeof(*c_out)); 135 n = os_read_file(fd, c_out, sizeof(*c_out));
136 136
137 if(n == -EAGAIN) 137 if(n == -EAGAIN)
138 return(0); 138 return 0;
139 else if(n == 0) 139 else if(n == 0)
140 return(-EIO); 140 return -EIO;
141 return(n); 141 return n;
142} 142}
143 143
144/* XXX Trivial wrapper around os_write_file */ 144/* XXX Trivial wrapper around os_write_file */
145 145
146int generic_write(int fd, const char *buf, int n, void *unused) 146int generic_write(int fd, const char *buf, int n, void *unused)
147{ 147{
148 return(os_write_file(fd, buf, n)); 148 return os_write_file(fd, buf, n);
149} 149}
150 150
151int generic_window_size(int fd, void *unused, unsigned short *rows_out, 151int generic_window_size(int fd, void *unused, unsigned short *rows_out,
@@ -156,14 +156,14 @@ int generic_window_size(int fd, void *unused, unsigned short *rows_out,
156 156
157 ret = os_window_size(fd, &rows, &cols); 157 ret = os_window_size(fd, &rows, &cols);
158 if(ret < 0) 158 if(ret < 0)
159 return(ret); 159 return ret;
160 160
161 ret = ((*rows_out != rows) || (*cols_out != cols)); 161 ret = ((*rows_out != rows) || (*cols_out != cols));
162 162
163 *rows_out = rows; 163 *rows_out = rows;
164 *cols_out = cols; 164 *cols_out = cols;
165 165
166 return(ret); 166 return ret;
167} 167}
168 168
169void generic_free(void *data) 169void generic_free(void *data)
@@ -186,25 +186,29 @@ static void tty_receive_char(struct tty_struct *tty, char ch)
186 } 186 }
187 } 187 }
188 188
189 if((tty->flip.flag_buf_ptr == NULL) || 189 if((tty->flip.flag_buf_ptr == NULL) ||
190 (tty->flip.char_buf_ptr == NULL)) 190 (tty->flip.char_buf_ptr == NULL))
191 return; 191 return;
192 tty_insert_flip_char(tty, ch, TTY_NORMAL); 192 tty_insert_flip_char(tty, ch, TTY_NORMAL);
193} 193}
194 194
195static int open_one_chan(struct chan *chan, int input, int output, int primary) 195static int open_one_chan(struct chan *chan)
196{ 196{
197 int fd; 197 int fd;
198 198
199 if(chan->opened) return(0); 199 if(chan->opened)
200 if(chan->ops->open == NULL) fd = 0; 200 return 0;
201 else fd = (*chan->ops->open)(input, output, primary, chan->data, 201
202 &chan->dev); 202 if(chan->ops->open == NULL)
203 if(fd < 0) return(fd); 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;
204 chan->fd = fd; 208 chan->fd = fd;
205 209
206 chan->opened = 1; 210 chan->opened = 1;
207 return(0); 211 return 0;
208} 212}
209 213
210int open_chan(struct list_head *chans) 214int open_chan(struct list_head *chans)
@@ -215,11 +219,11 @@ int open_chan(struct list_head *chans)
215 219
216 list_for_each(ele, chans){ 220 list_for_each(ele, chans){
217 chan = list_entry(ele, struct chan, list); 221 chan = list_entry(ele, struct chan, list);
218 ret = open_one_chan(chan, chan->input, chan->output, 222 ret = open_one_chan(chan);
219 chan->primary); 223 if(chan->primary)
220 if(chan->primary) err = ret; 224 err = ret;
221 } 225 }
222 return(err); 226 return err;
223} 227}
224 228
225void chan_enable_winch(struct list_head *chans, struct tty_struct *tty) 229void chan_enable_winch(struct list_head *chans, struct tty_struct *tty)
@@ -267,7 +271,7 @@ void close_chan(struct list_head *chans)
267 } 271 }
268} 272}
269 273
270int write_chan(struct list_head *chans, const char *buf, int len, 274int write_chan(struct list_head *chans, const char *buf, int len,
271 int write_irq) 275 int write_irq)
272{ 276{
273 struct list_head *ele; 277 struct list_head *ele;
@@ -285,7 +289,7 @@ int write_chan(struct list_head *chans, const char *buf, int len,
285 reactivate_fd(chan->fd, write_irq); 289 reactivate_fd(chan->fd, write_irq);
286 } 290 }
287 } 291 }
288 return(ret); 292 return ret;
289} 293}
290 294
291int console_write_chan(struct list_head *chans, const char *buf, int len) 295int console_write_chan(struct list_head *chans, const char *buf, int len)
@@ -301,10 +305,11 @@ int console_write_chan(struct list_head *chans, const char *buf, int len)
301 n = chan->ops->console_write(chan->fd, buf, len); 305 n = chan->ops->console_write(chan->fd, buf, len);
302 if(chan->primary) ret = n; 306 if(chan->primary) ret = n;
303 } 307 }
304 return(ret); 308 return ret;
305} 309}
306 310
307int console_open_chan(struct line *line, struct console *co, struct chan_opts *opts) 311int console_open_chan(struct line *line, struct console *co,
312 struct chan_opts *opts)
308{ 313{
309 if (!list_empty(&line->chan_list)) 314 if (!list_empty(&line->chan_list))
310 return 0; 315 return 0;
@@ -327,12 +332,13 @@ int chan_window_size(struct list_head *chans, unsigned short *rows_out,
327 list_for_each(ele, chans){ 332 list_for_each(ele, chans){
328 chan = list_entry(ele, struct chan, list); 333 chan = list_entry(ele, struct chan, list);
329 if(chan->primary){ 334 if(chan->primary){
330 if(chan->ops->window_size == NULL) return(0); 335 if(chan->ops->window_size == NULL)
331 return(chan->ops->window_size(chan->fd, chan->data, 336 return 0;
332 rows_out, cols_out)); 337 return chan->ops->window_size(chan->fd, chan->data,
338 rows_out, cols_out);
333 } 339 }
334 } 340 }
335 return(0); 341 return 0;
336} 342}
337 343
338void free_one_chan(struct chan *chan) 344void free_one_chan(struct chan *chan)
@@ -363,23 +369,23 @@ static int one_chan_config_string(struct chan *chan, char *str, int size,
363 369
364 if(chan == NULL){ 370 if(chan == NULL){
365 CONFIG_CHUNK(str, size, n, "none", 1); 371 CONFIG_CHUNK(str, size, n, "none", 1);
366 return(n); 372 return n;
367 } 373 }
368 374
369 CONFIG_CHUNK(str, size, n, chan->ops->type, 0); 375 CONFIG_CHUNK(str, size, n, chan->ops->type, 0);
370 376
371 if(chan->dev == NULL){ 377 if(chan->dev == NULL){
372 CONFIG_CHUNK(str, size, n, "", 1); 378 CONFIG_CHUNK(str, size, n, "", 1);
373 return(n); 379 return n;
374 } 380 }
375 381
376 CONFIG_CHUNK(str, size, n, ":", 0); 382 CONFIG_CHUNK(str, size, n, ":", 0);
377 CONFIG_CHUNK(str, size, n, chan->dev, 0); 383 CONFIG_CHUNK(str, size, n, chan->dev, 0);
378 384
379 return(n); 385 return n;
380} 386}
381 387
382static int chan_pair_config_string(struct chan *in, struct chan *out, 388static int chan_pair_config_string(struct chan *in, struct chan *out,
383 char *str, int size, char **error_out) 389 char *str, int size, char **error_out)
384{ 390{
385 int n; 391 int n;
@@ -390,7 +396,7 @@ static int chan_pair_config_string(struct chan *in, struct chan *out,
390 396
391 if(in == out){ 397 if(in == out){
392 CONFIG_CHUNK(str, size, n, "", 1); 398 CONFIG_CHUNK(str, size, n, "", 1);
393 return(n); 399 return n;
394 } 400 }
395 401
396 CONFIG_CHUNK(str, size, n, ",", 1); 402 CONFIG_CHUNK(str, size, n, ",", 1);
@@ -399,10 +405,10 @@ static int chan_pair_config_string(struct chan *in, struct chan *out,
399 size -= n; 405 size -= n;
400 CONFIG_CHUNK(str, size, n, "", 1); 406 CONFIG_CHUNK(str, size, n, "", 1);
401 407
402 return(n); 408 return n;
403} 409}
404 410
405int chan_config_string(struct list_head *chans, char *str, int size, 411int chan_config_string(struct list_head *chans, char *str, int size,
406 char **error_out) 412 char **error_out)
407{ 413{
408 struct list_head *ele; 414 struct list_head *ele;
@@ -418,7 +424,7 @@ int chan_config_string(struct list_head *chans, char *str, int size,
418 out = chan; 424 out = chan;
419 } 425 }
420 426
421 return(chan_pair_config_string(in, out, str, size, error_out)); 427 return chan_pair_config_string(in, out, str, size, error_out);
422} 428}
423 429
424struct chan_type { 430struct chan_type {
@@ -462,7 +468,7 @@ struct chan_type chan_table[] = {
462#endif 468#endif
463}; 469};
464 470
465static struct chan *parse_chan(char *str, int pri, int device, 471static struct chan *parse_chan(char *str, int pri, int device,
466 struct chan_opts *opts) 472 struct chan_opts *opts)
467{ 473{
468 struct chan_type *entry; 474 struct chan_type *entry;
@@ -484,14 +490,17 @@ static struct chan *parse_chan(char *str, int pri, int device,
484 if(ops == NULL){ 490 if(ops == NULL){
485 my_printf("parse_chan couldn't parse \"%s\"\n", 491 my_printf("parse_chan couldn't parse \"%s\"\n",
486 str); 492 str);
487 return(NULL); 493 return NULL;
488 } 494 }
489 if(ops->init == NULL) return(NULL); 495 if(ops->init == NULL)
496 return NULL;
490 data = (*ops->init)(str, device, opts); 497 data = (*ops->init)(str, device, opts);
491 if(data == NULL) return(NULL); 498 if(data == NULL)
499 return NULL;
492 500
493 chan = kmalloc(sizeof(*chan), GFP_ATOMIC); 501 chan = kmalloc(sizeof(*chan), GFP_ATOMIC);
494 if(chan == NULL) return(NULL); 502 if(chan == NULL)
503 return NULL;
495 *chan = ((struct chan) { .list = LIST_HEAD_INIT(chan->list), 504 *chan = ((struct chan) { .list = LIST_HEAD_INIT(chan->list),
496 .primary = 1, 505 .primary = 1,
497 .input = 0, 506 .input = 0,
@@ -501,7 +510,7 @@ static struct chan *parse_chan(char *str, int pri, int device,
501 .pri = pri, 510 .pri = pri,
502 .ops = ops, 511 .ops = ops,
503 .data = data }); 512 .data = data });
504 return(chan); 513 return chan;
505} 514}
506 515
507int parse_chan_pair(char *str, struct list_head *chans, int pri, int device, 516int parse_chan_pair(char *str, struct list_head *chans, int pri, int device,
@@ -512,7 +521,8 @@ int parse_chan_pair(char *str, struct list_head *chans, int pri, int device,
512 521
513 if(!list_empty(chans)){ 522 if(!list_empty(chans)){
514 chan = list_entry(chans->next, struct chan, list); 523 chan = list_entry(chans->next, struct chan, list);
515 if(chan->pri >= pri) return(0); 524 if(chan->pri >= pri)
525 return 0;
516 free_chan(chans); 526 free_chan(chans);
517 INIT_LIST_HEAD(chans); 527 INIT_LIST_HEAD(chans);
518 } 528 }
@@ -523,23 +533,29 @@ int parse_chan_pair(char *str, struct list_head *chans, int pri, int device,
523 *out = '\0'; 533 *out = '\0';
524 out++; 534 out++;
525 new = parse_chan(in, pri, device, opts); 535 new = parse_chan(in, pri, device, opts);
526 if(new == NULL) return(-1); 536 if(new == NULL)
537 return -1;
538
527 new->input = 1; 539 new->input = 1;
528 list_add(&new->list, chans); 540 list_add(&new->list, chans);
529 541
530 new = parse_chan(out, pri, device, opts); 542 new = parse_chan(out, pri, device, opts);
531 if(new == NULL) return(-1); 543 if(new == NULL)
544 return -1;
545
532 list_add(&new->list, chans); 546 list_add(&new->list, chans);
533 new->output = 1; 547 new->output = 1;
534 } 548 }
535 else { 549 else {
536 new = parse_chan(str, pri, device, opts); 550 new = parse_chan(str, pri, device, opts);
537 if(new == NULL) return(-1); 551 if(new == NULL)
552 return -1;
553
538 list_add(&new->list, chans); 554 list_add(&new->list, chans);
539 new->input = 1; 555 new->input = 1;
540 new->output = 1; 556 new->output = 1;
541 } 557 }
542 return(0); 558 return 0;
543} 559}
544 560
545int chan_out_fd(struct list_head *chans) 561int chan_out_fd(struct list_head *chans)
@@ -550,9 +566,9 @@ int chan_out_fd(struct list_head *chans)
550 list_for_each(ele, chans){ 566 list_for_each(ele, chans){
551 chan = list_entry(ele, struct chan, list); 567 chan = list_entry(ele, struct chan, list);
552 if(chan->primary && chan->output) 568 if(chan->primary && chan->output)
553 return(chan->fd); 569 return chan->fd;
554 } 570 }
555 return(-1); 571 return -1;
556} 572}
557 573
558void chan_interrupt(struct list_head *chans, struct work_struct *task, 574void chan_interrupt(struct list_head *chans, struct work_struct *task,
@@ -567,7 +583,7 @@ void chan_interrupt(struct list_head *chans, struct work_struct *task,
567 chan = list_entry(ele, struct chan, list); 583 chan = list_entry(ele, struct chan, list);
568 if(!chan->input || (chan->ops->read == NULL)) continue; 584 if(!chan->input || (chan->ops->read == NULL)) continue;
569 do { 585 do {
570 if((tty != NULL) && 586 if((tty != NULL) &&
571 (tty->flip.count >= TTY_FLIPBUF_SIZE)){ 587 (tty->flip.count >= TTY_FLIPBUF_SIZE)){
572 schedule_work(task); 588 schedule_work(task);
573 goto out; 589 goto out;
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index c31fc541e210..2ee00cbe8f9a 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -124,7 +124,8 @@ static int buffer_data(struct line *line, const char *buf, int len)
124 if (len < end){ 124 if (len < end){
125 memcpy(line->tail, buf, len); 125 memcpy(line->tail, buf, len);
126 line->tail += len; 126 line->tail += len;
127 } else { 127 }
128 else {
128 /* The circular buffer is wrapping */ 129 /* The circular buffer is wrapping */
129 memcpy(line->tail, buf, end); 130 memcpy(line->tail, buf, end);
130 buf += end; 131 buf += end;
@@ -170,7 +171,7 @@ static int flush_buffer(struct line *line)
170 } 171 }
171 172
172 count = line->tail - line->head; 173 count = line->tail - line->head;
173 n = write_chan(&line->chan_list, line->head, count, 174 n = write_chan(&line->chan_list, line->head, count,
174 line->driver->write_irq); 175 line->driver->write_irq);
175 176
176 if(n < 0) 177 if(n < 0)
@@ -227,7 +228,7 @@ int line_write(struct tty_struct *tty, const unsigned char *buf, int len)
227 if (err <= 0 && (err != -EAGAIN || !ret)) 228 if (err <= 0 && (err != -EAGAIN || !ret))
228 ret = err; 229 ret = err;
229 } else { 230 } else {
230 n = write_chan(&line->chan_list, buf, len, 231 n = write_chan(&line->chan_list, buf, len,
231 line->driver->write_irq); 232 line->driver->write_irq);
232 if (n < 0) { 233 if (n < 0) {
233 ret = n; 234 ret = n;
@@ -384,13 +385,13 @@ int line_setup_irq(int fd, int input, int output, struct tty_struct *tty)
384 385
385 if (input) 386 if (input)
386 err = um_request_irq(driver->read_irq, fd, IRQ_READ, 387 err = um_request_irq(driver->read_irq, fd, IRQ_READ,
387 line_interrupt, flags, 388 line_interrupt, flags,
388 driver->read_irq_name, tty); 389 driver->read_irq_name, tty);
389 if (err) 390 if (err)
390 return err; 391 return err;
391 if (output) 392 if (output)
392 err = um_request_irq(driver->write_irq, fd, IRQ_WRITE, 393 err = um_request_irq(driver->write_irq, fd, IRQ_WRITE,
393 line_write_interrupt, flags, 394 line_write_interrupt, flags,
394 driver->write_irq_name, tty); 395 driver->write_irq_name, tty);
395 line->have_irq = 1; 396 line->have_irq = 1;
396 return err; 397 return err;
@@ -512,10 +513,11 @@ int line_setup(struct line *lines, unsigned int num, char *init, int all_allowed
512 /* We said con=/ssl= instead of con#=, so we are configuring all 513 /* We said con=/ssl= instead of con#=, so we are configuring all
513 * consoles at once.*/ 514 * consoles at once.*/
514 n = -1; 515 n = -1;
515 } else { 516 }
517 else {
516 n = simple_strtoul(init, &end, 0); 518 n = simple_strtoul(init, &end, 0);
517 if(*end != '='){ 519 if(*end != '='){
518 printk(KERN_ERR "line_setup failed to parse \"%s\"\n", 520 printk(KERN_ERR "line_setup failed to parse \"%s\"\n",
519 init); 521 init);
520 return 0; 522 return 0;
521 } 523 }
@@ -527,7 +529,8 @@ int line_setup(struct line *lines, unsigned int num, char *init, int all_allowed
527 printk("line_setup - %d out of range ((0 ... %d) allowed)\n", 529 printk("line_setup - %d out of range ((0 ... %d) allowed)\n",
528 n, num - 1); 530 n, num - 1);
529 return 0; 531 return 0;
530 } else if (n >= 0){ 532 }
533 else if (n >= 0){
531 if (lines[n].count > 0) { 534 if (lines[n].count > 0) {
532 printk("line_setup - device %d is open\n", n); 535 printk("line_setup - device %d is open\n", n);
533 return 0; 536 return 0;
@@ -541,11 +544,13 @@ int line_setup(struct line *lines, unsigned int num, char *init, int all_allowed
541 lines[n].valid = 1; 544 lines[n].valid = 1;
542 } 545 }
543 } 546 }
544 } else if(!all_allowed){ 547 }
548 else if(!all_allowed){
545 printk("line_setup - can't configure all devices from " 549 printk("line_setup - can't configure all devices from "
546 "mconsole\n"); 550 "mconsole\n");
547 return 0; 551 return 0;
548 } else { 552 }
553 else {
549 for(i = 0; i < num; i++){ 554 for(i = 0; i < num; i++){
550 if(lines[i].init_pri <= INIT_ALL){ 555 if(lines[i].init_pri <= INIT_ALL){
551 lines[i].init_pri = INIT_ALL; 556 lines[i].init_pri = INIT_ALL;
@@ -627,7 +632,7 @@ int line_remove(struct line *lines, unsigned int num, int n)
627} 632}
628 633
629struct tty_driver *line_register_devfs(struct lines *set, 634struct tty_driver *line_register_devfs(struct lines *set,
630 struct line_driver *line_driver, 635 struct line_driver *line_driver,
631 struct tty_operations *ops, struct line *lines, 636 struct tty_operations *ops, struct line *lines,
632 int nlines) 637 int nlines)
633{ 638{
@@ -656,7 +661,7 @@ struct tty_driver *line_register_devfs(struct lines *set,
656 } 661 }
657 662
658 for(i = 0; i < nlines; i++){ 663 for(i = 0; i < nlines; i++){
659 if(!lines[i].valid) 664 if(!lines[i].valid)
660 tty_unregister_device(driver, i); 665 tty_unregister_device(driver, i);
661 } 666 }
662 667
@@ -677,11 +682,12 @@ void lines_init(struct line *lines, int nlines)
677 line = &lines[i]; 682 line = &lines[i];
678 INIT_LIST_HEAD(&line->chan_list); 683 INIT_LIST_HEAD(&line->chan_list);
679 spin_lock_init(&line->lock); 684 spin_lock_init(&line->lock);
680 if(line->init_str != NULL){ 685 if(line->init_str == NULL)
681 line->init_str = kstrdup(line->init_str, GFP_KERNEL); 686 continue;
682 if(line->init_str == NULL) 687
683 printk("lines_init - kstrdup returned NULL\n"); 688 line->init_str = kstrdup(line->init_str, GFP_KERNEL);
684 } 689 if(line->init_str == NULL)
690 printk("lines_init - kstrdup returned NULL\n");
685 } 691 }
686} 692}
687 693
@@ -717,8 +723,7 @@ irqreturn_t winch_interrupt(int irq, void *data, struct pt_regs *unused)
717 tty = winch->tty; 723 tty = winch->tty;
718 if (tty != NULL) { 724 if (tty != NULL) {
719 line = tty->driver_data; 725 line = tty->driver_data;
720 chan_window_size(&line->chan_list, 726 chan_window_size(&line->chan_list, &tty->winsize.ws_row,
721 &tty->winsize.ws_row,
722 &tty->winsize.ws_col); 727 &tty->winsize.ws_col);
723 kill_pg(tty->pgrp, SIGWINCH, 1); 728 kill_pg(tty->pgrp, SIGWINCH, 1);
724 } 729 }
@@ -749,7 +754,7 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty)
749 spin_unlock(&winch_handler_lock); 754 spin_unlock(&winch_handler_lock);
750 755
751 if(um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt, 756 if(um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt,
752 SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM, 757 SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM,
753 "winch", winch) < 0) 758 "winch", winch) < 0)
754 printk("register_winch_irq - failed to register IRQ\n"); 759 printk("register_winch_irq - failed to register IRQ\n");
755} 760}
@@ -800,7 +805,7 @@ static void winch_cleanup(void)
800 deactivate_fd(winch->fd, WINCH_IRQ); 805 deactivate_fd(winch->fd, WINCH_IRQ);
801 os_close_file(winch->fd); 806 os_close_file(winch->fd);
802 } 807 }
803 if(winch->pid != -1) 808 if(winch->pid != -1)
804 os_kill_process(winch->pid, 1); 809 os_kill_process(winch->pid, 1);
805 } 810 }
806} 811}
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index b36786410453..355866af5e0b 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -34,7 +34,7 @@
34#include "irq_kern.h" 34#include "irq_kern.h"
35#include "choose-mode.h" 35#include "choose-mode.h"
36 36
37static int do_unlink_socket(struct notifier_block *notifier, 37static int do_unlink_socket(struct notifier_block *notifier,
38 unsigned long what, void *data) 38 unsigned long what, void *data)
39{ 39{
40 return(mconsole_unlink_socket()); 40 return(mconsole_unlink_socket());
@@ -46,7 +46,7 @@ static struct notifier_block reboot_notifier = {
46 .priority = 0, 46 .priority = 0,
47}; 47};
48 48
49/* Safe without explicit locking for now. Tasklets provide their own 49/* Safe without explicit locking for now. Tasklets provide their own
50 * locking, and the interrupt handler is safe because it can't interrupt 50 * locking, and the interrupt handler is safe because it can't interrupt
51 * itself and it can only happen on CPU 0. 51 * itself and it can only happen on CPU 0.
52 */ 52 */
@@ -60,7 +60,7 @@ static void mc_work_proc(void *unused)
60 60
61 while(!list_empty(&mc_requests)){ 61 while(!list_empty(&mc_requests)){
62 local_save_flags(flags); 62 local_save_flags(flags);
63 req = list_entry(mc_requests.next, struct mconsole_entry, 63 req = list_entry(mc_requests.next, struct mconsole_entry,
64 list); 64 list);
65 list_del(&req->list); 65 list_del(&req->list);
66 local_irq_restore(flags); 66 local_irq_restore(flags);
@@ -103,8 +103,8 @@ void mconsole_version(struct mc_request *req)
103{ 103{
104 char version[256]; 104 char version[256];
105 105
106 sprintf(version, "%s %s %s %s %s", system_utsname.sysname, 106 sprintf(version, "%s %s %s %s %s", system_utsname.sysname,
107 system_utsname.nodename, system_utsname.release, 107 system_utsname.nodename, system_utsname.release,
108 system_utsname.version, system_utsname.machine); 108 system_utsname.version, system_utsname.machine);
109 mconsole_reply(req, version, 0, 0); 109 mconsole_reply(req, version, 0, 0);
110} 110}
@@ -348,7 +348,7 @@ static struct mc_device *mconsole_find_dev(char *name)
348 348
349#define CONFIG_BUF_SIZE 64 349#define CONFIG_BUF_SIZE 64
350 350
351static void mconsole_get_config(int (*get_config)(char *, char *, int, 351static void mconsole_get_config(int (*get_config)(char *, char *, int,
352 char **), 352 char **),
353 struct mc_request *req, char *name) 353 struct mc_request *req, char *name)
354{ 354{
@@ -389,7 +389,6 @@ static void mconsole_get_config(int (*get_config)(char *, char *, int,
389 out: 389 out:
390 if(buf != default_buf) 390 if(buf != default_buf)
391 kfree(buf); 391 kfree(buf);
392
393} 392}
394 393
395void mconsole_config(struct mc_request *req) 394void mconsole_config(struct mc_request *req)
@@ -420,7 +419,7 @@ void mconsole_config(struct mc_request *req)
420 419
421void mconsole_remove(struct mc_request *req) 420void mconsole_remove(struct mc_request *req)
422{ 421{
423 struct mc_device *dev; 422 struct mc_device *dev;
424 char *ptr = req->request.data, *err_msg = ""; 423 char *ptr = req->request.data, *err_msg = "";
425 char error[256]; 424 char error[256];
426 int err, start, end, n; 425 int err, start, end, n;
@@ -534,7 +533,7 @@ void mconsole_stack(struct mc_request *req)
534/* Changed by mconsole_setup, which is __setup, and called before SMP is 533/* Changed by mconsole_setup, which is __setup, and called before SMP is
535 * active. 534 * active.
536 */ 535 */
537static char *notify_socket = NULL; 536static char *notify_socket = NULL;
538 537
539int mconsole_init(void) 538int mconsole_init(void)
540{ 539{
@@ -566,13 +565,13 @@ int mconsole_init(void)
566 notify_socket = kstrdup(notify_socket, GFP_KERNEL); 565 notify_socket = kstrdup(notify_socket, GFP_KERNEL);
567 if(notify_socket != NULL) 566 if(notify_socket != NULL)
568 mconsole_notify(notify_socket, MCONSOLE_SOCKET, 567 mconsole_notify(notify_socket, MCONSOLE_SOCKET,
569 mconsole_socket_name, 568 mconsole_socket_name,
570 strlen(mconsole_socket_name) + 1); 569 strlen(mconsole_socket_name) + 1);
571 else printk(KERN_ERR "mconsole_setup failed to strdup " 570 else printk(KERN_ERR "mconsole_setup failed to strdup "
572 "string\n"); 571 "string\n");
573 } 572 }
574 573
575 printk("mconsole (version %d) initialized on %s\n", 574 printk("mconsole (version %d) initialized on %s\n",
576 MCONSOLE_VERSION, mconsole_socket_name); 575 MCONSOLE_VERSION, mconsole_socket_name);
577 return(0); 576 return(0);
578} 577}
@@ -585,7 +584,7 @@ static int write_proc_mconsole(struct file *file, const char __user *buffer,
585 char *buf; 584 char *buf;
586 585
587 buf = kmalloc(count + 1, GFP_KERNEL); 586 buf = kmalloc(count + 1, GFP_KERNEL);
588 if(buf == NULL) 587 if(buf == NULL)
589 return(-ENOMEM); 588 return(-ENOMEM);
590 589
591 if(copy_from_user(buf, buffer, count)){ 590 if(copy_from_user(buf, buffer, count)){
@@ -661,7 +660,7 @@ static int notify_panic(struct notifier_block *self, unsigned long unused1,
661 660
662 if(notify_socket == NULL) return(0); 661 if(notify_socket == NULL) return(0);
663 662
664 mconsole_notify(notify_socket, MCONSOLE_PANIC, message, 663 mconsole_notify(notify_socket, MCONSOLE_PANIC, message,
665 strlen(message) + 1); 664 strlen(message) + 1);
666 return(0); 665 return(0);
667} 666}
diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c
index 62e04ecfada8..95a3eaa7163c 100644
--- a/arch/um/drivers/ssl.c
+++ b/arch/um/drivers/ssl.c
@@ -69,7 +69,7 @@ static struct line_driver driver = {
69 .name = "ssl", 69 .name = "ssl",
70 .config = ssl_config, 70 .config = ssl_config,
71 .get_config = ssl_get_config, 71 .get_config = ssl_get_config,
72 .id = line_id, 72 .id = line_id,
73 .remove = ssl_remove, 73 .remove = ssl_remove,
74 }, 74 },
75}; 75};
@@ -84,21 +84,21 @@ static struct lines lines = LINES_INIT(NR_PORTS);
84 84
85static int ssl_config(char *str) 85static int ssl_config(char *str)
86{ 86{
87 return(line_config(serial_lines, 87 return line_config(serial_lines,
88 sizeof(serial_lines)/sizeof(serial_lines[0]), str)); 88 sizeof(serial_lines)/sizeof(serial_lines[0]), str);
89} 89}
90 90
91static int ssl_get_config(char *dev, char *str, int size, char **error_out) 91static int ssl_get_config(char *dev, char *str, int size, char **error_out)
92{ 92{
93 return(line_get_config(dev, serial_lines, 93 return line_get_config(dev, serial_lines,
94 sizeof(serial_lines)/sizeof(serial_lines[0]), 94 sizeof(serial_lines)/sizeof(serial_lines[0]),
95 str, size, error_out)); 95 str, size, error_out);
96} 96}
97 97
98static int ssl_remove(int n) 98static int ssl_remove(int n)
99{ 99{
100 return line_remove(serial_lines, 100 return line_remove(serial_lines,
101 sizeof(serial_lines)/sizeof(serial_lines[0]), n); 101 sizeof(serial_lines)/sizeof(serial_lines[0]), n);
102} 102}
103 103
104int ssl_open(struct tty_struct *tty, struct file *filp) 104int ssl_open(struct tty_struct *tty, struct file *filp)
@@ -183,7 +183,7 @@ static int ssl_console_setup(struct console *co, char *options)
183{ 183{
184 struct line *line = &serial_lines[co->index]; 184 struct line *line = &serial_lines[co->index];
185 185
186 return console_open_chan(line,co,&opts); 186 return console_open_chan(line, co, &opts);
187} 187}
188 188
189static struct console ssl_cons = { 189static struct console ssl_cons = {
@@ -199,10 +199,11 @@ int ssl_init(void)
199{ 199{
200 char *new_title; 200 char *new_title;
201 201
202 printk(KERN_INFO "Initializing software serial port version %d\n", 202 printk(KERN_INFO "Initializing software serial port version %d\n",
203 ssl_version); 203 ssl_version);
204 ssl_driver = line_register_devfs(&lines, &driver, &ssl_ops, 204 ssl_driver = line_register_devfs(&lines, &driver, &ssl_ops,
205 serial_lines, ARRAY_SIZE(serial_lines)); 205 serial_lines,
206 ARRAY_SIZE(serial_lines));
206 207
207 lines_init(serial_lines, sizeof(serial_lines)/sizeof(serial_lines[0])); 208 lines_init(serial_lines, sizeof(serial_lines)/sizeof(serial_lines[0]));
208 209
@@ -212,7 +213,7 @@ int ssl_init(void)
212 213
213 ssl_init_done = 1; 214 ssl_init_done = 1;
214 register_console(&ssl_cons); 215 register_console(&ssl_cons);
215 return(0); 216 return 0;
216} 217}
217late_initcall(ssl_init); 218late_initcall(ssl_init);
218 219
@@ -227,9 +228,9 @@ __uml_exitcall(ssl_exit);
227 228
228static int ssl_chan_setup(char *str) 229static int ssl_chan_setup(char *str)
229{ 230{
230 return(line_setup(serial_lines, 231 return line_setup(serial_lines,
231 sizeof(serial_lines)/sizeof(serial_lines[0]), 232 sizeof(serial_lines)/sizeof(serial_lines[0]),
232 str, 1)); 233 str, 1);
233} 234}
234 235
235__setup("ssl", ssl_chan_setup); 236__setup("ssl", ssl_chan_setup);
diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c
index 005aa6333b6e..8f3b168a4b6a 100644
--- a/arch/um/drivers/stdio_console.c
+++ b/arch/um/drivers/stdio_console.c
@@ -75,7 +75,7 @@ static struct line_driver driver = {
75 .name = "con", 75 .name = "con",
76 .config = con_config, 76 .config = con_config,
77 .get_config = con_get_config, 77 .get_config = con_get_config,
78 .id = line_id, 78 .id = line_id,
79 .remove = con_remove, 79 .remove = con_remove,
80 }, 80 },
81}; 81};
@@ -86,23 +86,23 @@ static struct lines console_lines = LINES_INIT(MAX_TTYS);
86 * individual elements are protected by individual semaphores. 86 * individual elements are protected by individual semaphores.
87 */ 87 */
88struct line vts[MAX_TTYS] = { LINE_INIT(CONFIG_CON_ZERO_CHAN, &driver), 88struct line vts[MAX_TTYS] = { LINE_INIT(CONFIG_CON_ZERO_CHAN, &driver),
89 [ 1 ... MAX_TTYS - 1 ] = 89 [ 1 ... MAX_TTYS - 1 ] =
90 LINE_INIT(CONFIG_CON_CHAN, &driver) }; 90 LINE_INIT(CONFIG_CON_CHAN, &driver) };
91 91
92static int con_config(char *str) 92static int con_config(char *str)
93{ 93{
94 return(line_config(vts, sizeof(vts)/sizeof(vts[0]), str)); 94 return line_config(vts, sizeof(vts)/sizeof(vts[0]), str);
95} 95}
96 96
97static int con_get_config(char *dev, char *str, int size, char **error_out) 97static int con_get_config(char *dev, char *str, int size, char **error_out)
98{ 98{
99 return(line_get_config(dev, vts, sizeof(vts)/sizeof(vts[0]), str, 99 return line_get_config(dev, vts, sizeof(vts)/sizeof(vts[0]), str,
100 size, error_out)); 100 size, error_out);
101} 101}
102 102
103static int con_remove(int n) 103static int con_remove(int n)
104{ 104{
105 return line_remove(vts, sizeof(vts)/sizeof(vts[0]), n); 105 return line_remove(vts, sizeof(vts)/sizeof(vts[0]), n);
106} 106}
107 107
108static int con_open(struct tty_struct *tty, struct file *filp) 108static int con_open(struct tty_struct *tty, struct file *filp)
@@ -117,7 +117,7 @@ static struct tty_operations console_ops = {
117 .close = line_close, 117 .close = line_close,
118 .write = line_write, 118 .write = line_write,
119 .put_char = line_put_char, 119 .put_char = line_put_char,
120 .write_room = line_write_room, 120 .write_room = line_write_room,
121 .chars_in_buffer = line_chars_in_buffer, 121 .chars_in_buffer = line_chars_in_buffer,
122 .flush_buffer = line_flush_buffer, 122 .flush_buffer = line_flush_buffer,
123 .flush_chars = line_flush_chars, 123 .flush_chars = line_flush_chars,
@@ -126,7 +126,7 @@ static struct tty_operations console_ops = {
126}; 126};
127 127
128static void uml_console_write(struct console *console, const char *string, 128static void uml_console_write(struct console *console, const char *string,
129 unsigned len) 129 unsigned len)
130{ 130{
131 struct line *line = &vts[console->index]; 131 struct line *line = &vts[console->index];
132 unsigned long flags; 132 unsigned long flags;
@@ -146,7 +146,7 @@ static int uml_console_setup(struct console *co, char *options)
146{ 146{
147 struct line *line = &vts[co->index]; 147 struct line *line = &vts[co->index];
148 148
149 return console_open_chan(line,co,&opts); 149 return console_open_chan(line, co, &opts);
150} 150}
151 151
152static struct console stdiocons = { 152static struct console stdiocons = {
@@ -156,7 +156,7 @@ static struct console stdiocons = {
156 .setup = uml_console_setup, 156 .setup = uml_console_setup,
157 .flags = CON_PRINTBUFFER, 157 .flags = CON_PRINTBUFFER,
158 .index = -1, 158 .index = -1,
159 .data = &vts, 159 .data = &vts,
160}; 160};
161 161
162int stdio_init(void) 162int stdio_init(void)
@@ -166,7 +166,7 @@ int stdio_init(void)
166 console_driver = line_register_devfs(&console_lines, &driver, 166 console_driver = line_register_devfs(&console_lines, &driver,
167 &console_ops, vts, 167 &console_ops, vts,
168 ARRAY_SIZE(vts)); 168 ARRAY_SIZE(vts));
169 if (NULL == console_driver) 169 if (console_driver == NULL)
170 return -1; 170 return -1;
171 printk(KERN_INFO "Initialized stdio console driver\n"); 171 printk(KERN_INFO "Initialized stdio console driver\n");
172 172
@@ -178,7 +178,7 @@ int stdio_init(void)
178 178
179 con_init_done = 1; 179 con_init_done = 1;
180 register_console(&stdiocons); 180 register_console(&stdiocons);
181 return(0); 181 return 0;
182} 182}
183late_initcall(stdio_init); 183late_initcall(stdio_init);
184 184
@@ -192,7 +192,7 @@ __uml_exitcall(console_exit);
192 192
193static int console_chan_setup(char *str) 193static int console_chan_setup(char *str)
194{ 194{
195 return(line_setup(vts, sizeof(vts)/sizeof(vts[0]), str, 1)); 195 return line_setup(vts, sizeof(vts)/sizeof(vts[0]), str, 1);
196} 196}
197__setup("con", console_chan_setup); 197__setup("con", console_chan_setup);
198__channel_help(console_chan_setup, "con"); 198__channel_help(console_chan_setup, "con");
diff --git a/arch/um/include/chan_kern.h b/arch/um/include/chan_kern.h
index da9a6717e7a4..9ac069107107 100644
--- a/arch/um/include/chan_kern.h
+++ b/arch/um/include/chan_kern.h
@@ -47,14 +47,3 @@ extern int chan_config_string(struct list_head *chans, char *str, int size,
47 char **error_out); 47 char **error_out);
48 48
49#endif 49#endif
50
51/*
52 * Overrides for Emacs so that we follow Linus's tabbing style.
53 * Emacs will notice this stuff at the end of the file and automatically
54 * adjust the settings for this buffer only. This must remain at the end
55 * of the file.
56 * ---------------------------------------------------------------------------
57 * Local variables:
58 * c-file-style: "linux"
59 * End:
60 */
diff --git a/arch/um/include/line.h b/arch/um/include/line.h
index 5323d22a6ca7..315788ce59fa 100644
--- a/arch/um/include/line.h
+++ b/arch/um/include/line.h
@@ -64,8 +64,8 @@ struct line {
64 head : NULL, \ 64 head : NULL, \
65 tail : NULL, \ 65 tail : NULL, \
66 sigio : 0, \ 66 sigio : 0, \
67 driver : d, \ 67 driver : d, \
68 have_irq : 0 } 68 have_irq : 0 }
69 69
70struct lines { 70struct lines {
71 int num; 71 int num;
@@ -74,11 +74,12 @@ struct lines {
74#define LINES_INIT(n) { num : n } 74#define LINES_INIT(n) { num : n }
75 75
76extern void line_close(struct tty_struct *tty, struct file * filp); 76extern void line_close(struct tty_struct *tty, struct file * filp);
77extern int line_open(struct line *lines, struct tty_struct *tty, 77extern int line_open(struct line *lines, struct tty_struct *tty,
78 struct chan_opts *opts); 78 struct chan_opts *opts);
79extern int line_setup(struct line *lines, unsigned int sizeof_lines, char *init, 79extern int line_setup(struct line *lines, unsigned int sizeof_lines, char *init,
80 int all_allowed); 80 int all_allowed);
81extern int line_write(struct tty_struct *tty, const unsigned char *buf, int len); 81extern int line_write(struct tty_struct *tty, const unsigned char *buf,
82 int len);
82extern void line_put_char(struct tty_struct *tty, unsigned char ch); 83extern void line_put_char(struct tty_struct *tty, unsigned char ch);
83extern void line_set_termios(struct tty_struct *tty, struct termios * old); 84extern void line_set_termios(struct tty_struct *tty, struct termios * old);
84extern int line_chars_in_buffer(struct tty_struct *tty); 85extern int line_chars_in_buffer(struct tty_struct *tty);
@@ -89,21 +90,24 @@ extern int line_ioctl(struct tty_struct *tty, struct file * file,
89 unsigned int cmd, unsigned long arg); 90 unsigned int cmd, unsigned long arg);
90 91
91extern char *add_xterm_umid(char *base); 92extern char *add_xterm_umid(char *base);
92extern int line_setup_irq(int fd, int input, int output, struct tty_struct *tty); 93extern int line_setup_irq(int fd, int input, int output,
94 struct tty_struct *tty);
93extern void line_close_chan(struct line *line); 95extern void line_close_chan(struct line *line);
94extern void line_disable(struct tty_struct *tty, int current_irq); 96extern void line_disable(struct tty_struct *tty, int current_irq);
95extern struct tty_driver * line_register_devfs(struct lines *set, 97extern struct tty_driver * line_register_devfs(struct lines *set,
96 struct line_driver *line_driver, 98 struct line_driver *line_driver,
97 struct tty_operations *driver, 99 struct tty_operations *driver,
98 struct line *lines, 100 struct line *lines,
99 int nlines); 101 int nlines);
100extern void lines_init(struct line *lines, int nlines); 102extern void lines_init(struct line *lines, int nlines);
101extern void close_lines(struct line *lines, int nlines); 103extern void close_lines(struct line *lines, int nlines);
102 104
103extern int line_config(struct line *lines, unsigned int sizeof_lines, char *str); 105extern int line_config(struct line *lines, unsigned int sizeof_lines,
106 char *str);
104extern int line_id(char **str, int *start_out, int *end_out); 107extern int line_id(char **str, int *start_out, int *end_out);
105extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n); 108extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n);
106extern int line_get_config(char *dev, struct line *lines, unsigned int sizeof_lines, char *str, 109extern int line_get_config(char *dev, struct line *lines,
110 unsigned int sizeof_lines, char *str,
107 int size, char **error_out); 111 int size, char **error_out);
108 112
109#endif 113#endif
diff --git a/arch/um/os-Linux/aio.c b/arch/um/os-Linux/aio.c
index 0b78bb7a994a..f897140cc4ae 100644
--- a/arch/um/os-Linux/aio.c
+++ b/arch/um/os-Linux/aio.c
@@ -16,12 +16,12 @@
16#include "mode.h" 16#include "mode.h"
17 17
18struct aio_thread_req { 18struct aio_thread_req {
19 enum aio_type type; 19 enum aio_type type;
20 int io_fd; 20 int io_fd;
21 unsigned long long offset; 21 unsigned long long offset;
22 char *buf; 22 char *buf;
23 int len; 23 int len;
24 struct aio_context *aio; 24 struct aio_context *aio;
25}; 25};
26 26
27static int aio_req_fd_r = -1; 27static int aio_req_fd_r = -1;
@@ -38,18 +38,18 @@ static int aio_req_fd_w = -1;
38 38
39static long io_setup(int n, aio_context_t *ctxp) 39static long io_setup(int n, aio_context_t *ctxp)
40{ 40{
41 return syscall(__NR_io_setup, n, ctxp); 41 return syscall(__NR_io_setup, n, ctxp);
42} 42}
43 43
44static long io_submit(aio_context_t ctx, long nr, struct iocb **iocbpp) 44static long io_submit(aio_context_t ctx, long nr, struct iocb **iocbpp)
45{ 45{
46 return syscall(__NR_io_submit, ctx, nr, iocbpp); 46 return syscall(__NR_io_submit, ctx, nr, iocbpp);
47} 47}
48 48
49static long io_getevents(aio_context_t ctx_id, long min_nr, long nr, 49static long io_getevents(aio_context_t ctx_id, long min_nr, long nr,
50 struct io_event *events, struct timespec *timeout) 50 struct io_event *events, struct timespec *timeout)
51{ 51{
52 return syscall(__NR_io_getevents, ctx_id, min_nr, nr, events, timeout); 52 return syscall(__NR_io_getevents, ctx_id, min_nr, nr, events, timeout);
53} 53}
54 54
55#endif 55#endif
@@ -66,150 +66,150 @@ static long io_getevents(aio_context_t ctx_id, long min_nr, long nr,
66 */ 66 */
67 67
68static int do_aio(aio_context_t ctx, enum aio_type type, int fd, char *buf, 68static int do_aio(aio_context_t ctx, enum aio_type type, int fd, char *buf,
69 int len, unsigned long long offset, struct aio_context *aio) 69 int len, unsigned long long offset, struct aio_context *aio)
70{ 70{
71 struct iocb iocb, *iocbp = &iocb; 71 struct iocb iocb, *iocbp = &iocb;
72 char c; 72 char c;
73 int err; 73 int err;
74 74
75 iocb = ((struct iocb) { .aio_data = (unsigned long) aio, 75 iocb = ((struct iocb) { .aio_data = (unsigned long) aio,
76 .aio_reqprio = 0, 76 .aio_reqprio = 0,
77 .aio_fildes = fd, 77 .aio_fildes = fd,
78 .aio_buf = (unsigned long) buf, 78 .aio_buf = (unsigned long) buf,
79 .aio_nbytes = len, 79 .aio_nbytes = len,
80 .aio_offset = offset, 80 .aio_offset = offset,
81 .aio_reserved1 = 0, 81 .aio_reserved1 = 0,
82 .aio_reserved2 = 0, 82 .aio_reserved2 = 0,
83 .aio_reserved3 = 0 }); 83 .aio_reserved3 = 0 });
84 84
85 switch(type){ 85 switch(type){
86 case AIO_READ: 86 case AIO_READ:
87 iocb.aio_lio_opcode = IOCB_CMD_PREAD; 87 iocb.aio_lio_opcode = IOCB_CMD_PREAD;
88 err = io_submit(ctx, 1, &iocbp); 88 err = io_submit(ctx, 1, &iocbp);
89 break; 89 break;
90 case AIO_WRITE: 90 case AIO_WRITE:
91 iocb.aio_lio_opcode = IOCB_CMD_PWRITE; 91 iocb.aio_lio_opcode = IOCB_CMD_PWRITE;
92 err = io_submit(ctx, 1, &iocbp); 92 err = io_submit(ctx, 1, &iocbp);
93 break; 93 break;
94 case AIO_MMAP: 94 case AIO_MMAP:
95 iocb.aio_lio_opcode = IOCB_CMD_PREAD; 95 iocb.aio_lio_opcode = IOCB_CMD_PREAD;
96 iocb.aio_buf = (unsigned long) &c; 96 iocb.aio_buf = (unsigned long) &c;
97 iocb.aio_nbytes = sizeof(c); 97 iocb.aio_nbytes = sizeof(c);
98 err = io_submit(ctx, 1, &iocbp); 98 err = io_submit(ctx, 1, &iocbp);
99 break; 99 break;
100 default: 100 default:
101 printk("Bogus op in do_aio - %d\n", type); 101 printk("Bogus op in do_aio - %d\n", type);
102 err = -EINVAL; 102 err = -EINVAL;
103 break; 103 break;
104 } 104 }
105 105
106 if(err > 0) 106 if(err > 0)
107 err = 0; 107 err = 0;
108 else 108 else
109 err = -errno; 109 err = -errno;
110 110
111 return err; 111 return err;
112} 112}
113 113
114static aio_context_t ctx = 0; 114static aio_context_t ctx = 0;
115 115
116static int aio_thread(void *arg) 116static int aio_thread(void *arg)
117{ 117{
118 struct aio_thread_reply reply; 118 struct aio_thread_reply reply;
119 struct io_event event; 119 struct io_event event;
120 int err, n, reply_fd; 120 int err, n, reply_fd;
121 121
122 signal(SIGWINCH, SIG_IGN); 122 signal(SIGWINCH, SIG_IGN);
123 123
124 while(1){ 124 while(1){
125 n = io_getevents(ctx, 1, 1, &event, NULL); 125 n = io_getevents(ctx, 1, 1, &event, NULL);
126 if(n < 0){ 126 if(n < 0){
127 if(errno == EINTR) 127 if(errno == EINTR)
128 continue; 128 continue;
129 printk("aio_thread - io_getevents failed, " 129 printk("aio_thread - io_getevents failed, "
130 "errno = %d\n", errno); 130 "errno = %d\n", errno);
131 } 131 }
132 else { 132 else {
133 reply = ((struct aio_thread_reply) 133 reply = ((struct aio_thread_reply)
134 { .data = (void *) (long) event.data, 134 { .data = (void *) (long) event.data,
135 .err = event.res }); 135 .err = event.res });
136 reply_fd = ((struct aio_context *) reply.data)->reply_fd; 136 reply_fd = ((struct aio_context *) reply.data)->reply_fd;
137 err = os_write_file(reply_fd, &reply, sizeof(reply)); 137 err = os_write_file(reply_fd, &reply, sizeof(reply));
138 if(err != sizeof(reply)) 138 if(err != sizeof(reply))
139 printk("aio_thread - write failed, fd = %d, " 139 printk("aio_thread - write failed, fd = %d, "
140 "err = %d\n", aio_req_fd_r, -err); 140 "err = %d\n", aio_req_fd_r, -err);
141 } 141 }
142 } 142 }
143 return 0; 143 return 0;
144} 144}
145 145
146#endif 146#endif
147 147
148static int do_not_aio(struct aio_thread_req *req) 148static int do_not_aio(struct aio_thread_req *req)
149{ 149{
150 char c; 150 char c;
151 int err; 151 int err;
152 152
153 switch(req->type){ 153 switch(req->type){
154 case AIO_READ: 154 case AIO_READ:
155 err = os_seek_file(req->io_fd, req->offset); 155 err = os_seek_file(req->io_fd, req->offset);
156 if(err) 156 if(err)
157 goto out; 157 goto out;
158 158
159 err = os_read_file(req->io_fd, req->buf, req->len); 159 err = os_read_file(req->io_fd, req->buf, req->len);
160 break; 160 break;
161 case AIO_WRITE: 161 case AIO_WRITE:
162 err = os_seek_file(req->io_fd, req->offset); 162 err = os_seek_file(req->io_fd, req->offset);
163 if(err) 163 if(err)
164 goto out; 164 goto out;
165 165
166 err = os_write_file(req->io_fd, req->buf, req->len); 166 err = os_write_file(req->io_fd, req->buf, req->len);
167 break; 167 break;
168 case AIO_MMAP: 168 case AIO_MMAP:
169 err = os_seek_file(req->io_fd, req->offset); 169 err = os_seek_file(req->io_fd, req->offset);
170 if(err) 170 if(err)
171 goto out; 171 goto out;
172 172
173 err = os_read_file(req->io_fd, &c, sizeof(c)); 173 err = os_read_file(req->io_fd, &c, sizeof(c));
174 break; 174 break;
175 default: 175 default:
176 printk("do_not_aio - bad request type : %d\n", req->type); 176 printk("do_not_aio - bad request type : %d\n", req->type);
177 err = -EINVAL; 177 err = -EINVAL;
178 break; 178 break;
179 } 179 }
180 180
181 out: 181out:
182 return err; 182 return err;
183} 183}
184 184
185static int not_aio_thread(void *arg) 185static int not_aio_thread(void *arg)
186{ 186{
187 struct aio_thread_req req; 187 struct aio_thread_req req;
188 struct aio_thread_reply reply; 188 struct aio_thread_reply reply;
189 int err; 189 int err;
190 190
191 signal(SIGWINCH, SIG_IGN); 191 signal(SIGWINCH, SIG_IGN);
192 while(1){ 192 while(1){
193 err = os_read_file(aio_req_fd_r, &req, sizeof(req)); 193 err = os_read_file(aio_req_fd_r, &req, sizeof(req));
194 if(err != sizeof(req)){ 194 if(err != sizeof(req)){
195 if(err < 0) 195 if(err < 0)
196 printk("not_aio_thread - read failed, " 196 printk("not_aio_thread - read failed, "
197 "fd = %d, err = %d\n", aio_req_fd_r, 197 "fd = %d, err = %d\n", aio_req_fd_r,
198 -err); 198 -err);
199 else { 199 else {
200 printk("not_aio_thread - short read, fd = %d, " 200 printk("not_aio_thread - short read, fd = %d, "
201 "length = %d\n", aio_req_fd_r, err); 201 "length = %d\n", aio_req_fd_r, err);
202 } 202 }
203 continue; 203 continue;
204 } 204 }
205 err = do_not_aio(&req); 205 err = do_not_aio(&req);
206 reply = ((struct aio_thread_reply) { .data = req.aio, 206 reply = ((struct aio_thread_reply) { .data = req.aio,
207 .err = err }); 207 .err = err });
208 err = os_write_file(req.aio->reply_fd, &reply, sizeof(reply)); 208 err = os_write_file(req.aio->reply_fd, &reply, sizeof(reply));
209 if(err != sizeof(reply)) 209 if(err != sizeof(reply))
210 printk("not_aio_thread - write failed, fd = %d, " 210 printk("not_aio_thread - write failed, fd = %d, "
211 "err = %d\n", aio_req_fd_r, -err); 211 "err = %d\n", aio_req_fd_r, -err);
212 } 212 }
213 213
214 return 0; 214 return 0;
215} 215}
@@ -218,93 +218,93 @@ static int aio_pid = -1;
218 218
219static int init_aio_24(void) 219static int init_aio_24(void)
220{ 220{
221 unsigned long stack; 221 unsigned long stack;
222 int fds[2], err; 222 int fds[2], err;
223 223
224 err = os_pipe(fds, 1, 1); 224 err = os_pipe(fds, 1, 1);
225 if(err) 225 if(err)
226 goto out; 226 goto out;
227 227
228 aio_req_fd_w = fds[0]; 228 aio_req_fd_w = fds[0];
229 aio_req_fd_r = fds[1]; 229 aio_req_fd_r = fds[1];
230 err = run_helper_thread(not_aio_thread, NULL, 230 err = run_helper_thread(not_aio_thread, NULL,
231 CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0); 231 CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0);
232 if(err < 0) 232 if(err < 0)
233 goto out_close_pipe; 233 goto out_close_pipe;
234 234
235 aio_pid = err; 235 aio_pid = err;
236 goto out; 236 goto out;
237 237
238 out_close_pipe: 238out_close_pipe:
239 os_close_file(fds[0]); 239 os_close_file(fds[0]);
240 os_close_file(fds[1]); 240 os_close_file(fds[1]);
241 aio_req_fd_w = -1; 241 aio_req_fd_w = -1;
242 aio_req_fd_r = -1; 242 aio_req_fd_r = -1;
243 out: 243out:
244#ifndef HAVE_AIO_ABI 244#ifndef HAVE_AIO_ABI
245 printk("/usr/include/linux/aio_abi.h not present during build\n"); 245 printk("/usr/include/linux/aio_abi.h not present during build\n");
246#endif 246#endif
247 printk("2.6 host AIO support not used - falling back to I/O " 247 printk("2.6 host AIO support not used - falling back to I/O "
248 "thread\n"); 248 "thread\n");
249 return 0; 249 return 0;
250} 250}
251 251
252#ifdef HAVE_AIO_ABI 252#ifdef HAVE_AIO_ABI
253#define DEFAULT_24_AIO 0 253#define DEFAULT_24_AIO 0
254static int init_aio_26(void) 254static int init_aio_26(void)
255{ 255{
256 unsigned long stack; 256 unsigned long stack;
257 int err; 257 int err;
258 258
259 if(io_setup(256, &ctx)){ 259 if(io_setup(256, &ctx)){
260 err = -errno; 260 err = -errno;
261 printk("aio_thread failed to initialize context, err = %d\n", 261 printk("aio_thread failed to initialize context, err = %d\n",
262 errno); 262 errno);
263 return err; 263 return err;
264 } 264 }
265 265
266 err = run_helper_thread(aio_thread, NULL, 266 err = run_helper_thread(aio_thread, NULL,
267 CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0); 267 CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0);
268 if(err < 0) 268 if(err < 0)
269 return err; 269 return err;
270 270
271 aio_pid = err; 271 aio_pid = err;
272 272
273 printk("Using 2.6 host AIO\n"); 273 printk("Using 2.6 host AIO\n");
274 return 0; 274 return 0;
275} 275}
276 276
277static int submit_aio_26(enum aio_type type, int io_fd, char *buf, int len, 277static int submit_aio_26(enum aio_type type, int io_fd, char *buf, int len,
278 unsigned long long offset, struct aio_context *aio) 278 unsigned long long offset, struct aio_context *aio)
279{ 279{
280 struct aio_thread_reply reply; 280 struct aio_thread_reply reply;
281 int err; 281 int err;
282 282
283 err = do_aio(ctx, type, io_fd, buf, len, offset, aio); 283 err = do_aio(ctx, type, io_fd, buf, len, offset, aio);
284 if(err){ 284 if(err){
285 reply = ((struct aio_thread_reply) { .data = aio, 285 reply = ((struct aio_thread_reply) { .data = aio,
286 .err = err }); 286 .err = err });
287 err = os_write_file(aio->reply_fd, &reply, sizeof(reply)); 287 err = os_write_file(aio->reply_fd, &reply, sizeof(reply));
288 if(err != sizeof(reply)) 288 if(err != sizeof(reply))
289 printk("submit_aio_26 - write failed, " 289 printk("submit_aio_26 - write failed, "
290 "fd = %d, err = %d\n", aio->reply_fd, -err); 290 "fd = %d, err = %d\n", aio->reply_fd, -err);
291 else err = 0; 291 else err = 0;
292 } 292 }
293 293
294 return err; 294 return err;
295} 295}
296 296
297#else 297#else
298#define DEFAULT_24_AIO 1 298#define DEFAULT_24_AIO 1
299static int init_aio_26(void) 299static int init_aio_26(void)
300{ 300{
301 return -ENOSYS; 301 return -ENOSYS;
302} 302}
303 303
304static int submit_aio_26(enum aio_type type, int io_fd, char *buf, int len, 304static int submit_aio_26(enum aio_type type, int io_fd, char *buf, int len,
305 unsigned long long offset, struct aio_context *aio) 305 unsigned long long offset, struct aio_context *aio)
306{ 306{
307 return -ENOSYS; 307 return -ENOSYS;
308} 308}
309#endif 309#endif
310 310
@@ -312,8 +312,8 @@ static int aio_24 = DEFAULT_24_AIO;
312 312
313static int __init set_aio_24(char *name, int *add) 313static int __init set_aio_24(char *name, int *add)
314{ 314{
315 aio_24 = 1; 315 aio_24 = 1;
316 return 0; 316 return 0;
317} 317}
318 318
319__uml_setup("aio=2.4", set_aio_24, 319__uml_setup("aio=2.4", set_aio_24,
@@ -330,28 +330,27 @@ __uml_setup("aio=2.4", set_aio_24,
330 330
331static int init_aio(void) 331static int init_aio(void)
332{ 332{
333 int err; 333 int err;
334 334
335 CHOOSE_MODE(({ 335 CHOOSE_MODE(({ if(!aio_24){
336 if(!aio_24){ 336 printk("Disabling 2.6 AIO in tt mode\n");
337 printk("Disabling 2.6 AIO in tt mode\n"); 337 aio_24 = 1;
338 aio_24 = 1; 338 } }), (void) 0);
339 } }), (void) 0); 339
340 340 if(!aio_24){
341 if(!aio_24){ 341 err = init_aio_26();
342 err = init_aio_26(); 342 if(err && (errno == ENOSYS)){
343 if(err && (errno == ENOSYS)){ 343 printk("2.6 AIO not supported on the host - "
344 printk("2.6 AIO not supported on the host - " 344 "reverting to 2.4 AIO\n");
345 "reverting to 2.4 AIO\n"); 345 aio_24 = 1;
346 aio_24 = 1; 346 }
347 } 347 else return err;
348 else return err; 348 }
349 } 349
350 350 if(aio_24)
351 if(aio_24) 351 return init_aio_24();
352 return init_aio_24(); 352
353 353 return 0;
354 return 0;
355} 354}
356 355
357/* The reason for the __initcall/__uml_exitcall asymmetry is that init_aio 356/* The reason for the __initcall/__uml_exitcall asymmetry is that init_aio
@@ -364,8 +363,8 @@ __initcall(init_aio);
364 363
365static void exit_aio(void) 364static void exit_aio(void)
366{ 365{
367 if(aio_pid != -1) 366 if(aio_pid != -1)
368 os_kill_process(aio_pid, 1); 367 os_kill_process(aio_pid, 1);
369} 368}
370 369
371__uml_exitcall(exit_aio); 370__uml_exitcall(exit_aio);
@@ -373,30 +372,30 @@ __uml_exitcall(exit_aio);
373static int submit_aio_24(enum aio_type type, int io_fd, char *buf, int len, 372static int submit_aio_24(enum aio_type type, int io_fd, char *buf, int len,
374 unsigned long long offset, struct aio_context *aio) 373 unsigned long long offset, struct aio_context *aio)
375{ 374{
376 struct aio_thread_req req = { .type = type, 375 struct aio_thread_req req = { .type = type,
377 .io_fd = io_fd, 376 .io_fd = io_fd,
378 .offset = offset, 377 .offset = offset,
379 .buf = buf, 378 .buf = buf,
380 .len = len, 379 .len = len,
381 .aio = aio, 380 .aio = aio,
382 }; 381 };
383 int err; 382 int err;
384 383
385 err = os_write_file(aio_req_fd_w, &req, sizeof(req)); 384 err = os_write_file(aio_req_fd_w, &req, sizeof(req));
386 if(err == sizeof(req)) 385 if(err == sizeof(req))
387 err = 0; 386 err = 0;
388 387
389 return err; 388 return err;
390} 389}
391 390
392int submit_aio(enum aio_type type, int io_fd, char *buf, int len, 391int submit_aio(enum aio_type type, int io_fd, char *buf, int len,
393 unsigned long long offset, int reply_fd, 392 unsigned long long offset, int reply_fd,
394 struct aio_context *aio) 393 struct aio_context *aio)
395{ 394{
396 aio->reply_fd = reply_fd; 395 aio->reply_fd = reply_fd;
397 if(aio_24) 396 if(aio_24)
398 return submit_aio_24(type, io_fd, buf, len, offset, aio); 397 return submit_aio_24(type, io_fd, buf, len, offset, aio);
399 else { 398 else {
400 return submit_aio_26(type, io_fd, buf, len, offset, aio); 399 return submit_aio_26(type, io_fd, buf, len, offset, aio);
401 } 400 }
402} 401}