aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers/line.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/drivers/line.c')
-rw-r--r--arch/um/drivers/line.c237
1 files changed, 117 insertions, 120 deletions
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 3e0b68e297f2..76fe0b0da996 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -1,22 +1,14 @@
1/* 1/*
2 * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include "linux/kernel.h" 6#include "linux/irqreturn.h"
7#include "linux/sched.h"
8#include "linux/slab.h"
9#include "linux/list.h"
10#include "linux/kd.h" 7#include "linux/kd.h"
11#include "linux/interrupt.h"
12#include "asm/uaccess.h"
13#include "chan_kern.h" 8#include "chan_kern.h"
9#include "irq_kern.h"
14#include "irq_user.h" 10#include "irq_user.h"
15#include "line.h"
16#include "kern.h"
17#include "kern_util.h"
18#include "os.h" 11#include "os.h"
19#include "irq_kern.h"
20 12
21#define LINE_BUFSIZE 4096 13#define LINE_BUFSIZE 4096
22 14
@@ -35,12 +27,13 @@ static void line_timer_cb(struct work_struct *work)
35{ 27{
36 struct line *line = container_of(work, struct line, task.work); 28 struct line *line = container_of(work, struct line, task.work);
37 29
38 if(!line->throttled) 30 if (!line->throttled)
39 chan_interrupt(&line->chan_list, &line->task, line->tty, 31 chan_interrupt(&line->chan_list, &line->task, line->tty,
40 line->driver->read_irq); 32 line->driver->read_irq);
41} 33}
42 34
43/* Returns the free space inside the ring buffer of this line. 35/*
36 * Returns the free space inside the ring buffer of this line.
44 * 37 *
45 * Should be called while holding line->lock (this does not modify datas). 38 * Should be called while holding line->lock (this does not modify datas).
46 */ 39 */
@@ -107,11 +100,12 @@ static int buffer_data(struct line *line, const char *buf, int len)
107{ 100{
108 int end, room; 101 int end, room;
109 102
110 if(line->buffer == NULL){ 103 if (line->buffer == NULL) {
111 line->buffer = kmalloc(LINE_BUFSIZE, GFP_ATOMIC); 104 line->buffer = kmalloc(LINE_BUFSIZE, GFP_ATOMIC);
112 if (line->buffer == NULL) { 105 if (line->buffer == NULL) {
113 printk("buffer_data - atomic allocation failed\n"); 106 printk(KERN_ERR "buffer_data - atomic allocation "
114 return(0); 107 "failed\n");
108 return 0;
115 } 109 }
116 line->head = line->buffer; 110 line->head = line->buffer;
117 line->tail = line->buffer; 111 line->tail = line->buffer;
@@ -122,7 +116,7 @@ static int buffer_data(struct line *line, const char *buf, int len)
122 116
123 end = line->buffer + LINE_BUFSIZE - line->tail; 117 end = line->buffer + LINE_BUFSIZE - line->tail;
124 118
125 if (len < end){ 119 if (len < end) {
126 memcpy(line->tail, buf, len); 120 memcpy(line->tail, buf, len);
127 line->tail += len; 121 line->tail += len;
128 } 122 }
@@ -162,8 +156,10 @@ static int flush_buffer(struct line *line)
162 if (n < 0) 156 if (n < 0)
163 return n; 157 return n;
164 if (n == count) { 158 if (n == count) {
165 /* We have flushed from ->head to buffer end, now we 159 /*
166 * must flush only from the beginning to ->tail.*/ 160 * We have flushed from ->head to buffer end, now we
161 * must flush only from the beginning to ->tail.
162 */
167 line->head = line->buffer; 163 line->head = line->buffer;
168 } else { 164 } else {
169 line->head += n; 165 line->head += n;
@@ -175,7 +171,7 @@ static int flush_buffer(struct line *line)
175 n = write_chan(&line->chan_list, line->head, count, 171 n = write_chan(&line->chan_list, line->head, count,
176 line->driver->write_irq); 172 line->driver->write_irq);
177 173
178 if(n < 0) 174 if (n < 0)
179 return n; 175 return n;
180 176
181 line->head += n; 177 line->head += n;
@@ -189,19 +185,18 @@ void line_flush_buffer(struct tty_struct *tty)
189 int err; 185 int err;
190 186
191 /*XXX: copied from line_write, verify if it is correct!*/ 187 /*XXX: copied from line_write, verify if it is correct!*/
192 if(tty->stopped) 188 if (tty->stopped)
193 return; 189 return;
194 190
195 spin_lock_irqsave(&line->lock, flags); 191 spin_lock_irqsave(&line->lock, flags);
196 err = flush_buffer(line); 192 err = flush_buffer(line);
197 /*if (err == 1)
198 err = 0;*/
199 spin_unlock_irqrestore(&line->lock, flags); 193 spin_unlock_irqrestore(&line->lock, flags);
200 //return err;
201} 194}
202 195
203/* We map both ->flush_chars and ->put_char (which go in pair) onto ->flush_buffer 196/*
204 * and ->write. Hope it's not that bad.*/ 197 * We map both ->flush_chars and ->put_char (which go in pair) onto
198 * ->flush_buffer and ->write. Hope it's not that bad.
199 */
205void line_flush_chars(struct tty_struct *tty) 200void line_flush_chars(struct tty_struct *tty)
206{ 201{
207 line_flush_buffer(tty); 202 line_flush_buffer(tty);
@@ -216,18 +211,15 @@ int line_write(struct tty_struct *tty, const unsigned char *buf, int len)
216{ 211{
217 struct line *line = tty->driver_data; 212 struct line *line = tty->driver_data;
218 unsigned long flags; 213 unsigned long flags;
219 int n, err, ret = 0; 214 int n, ret = 0;
220 215
221 if(tty->stopped) 216 if (tty->stopped)
222 return 0; 217 return 0;
223 218
224 spin_lock_irqsave(&line->lock, flags); 219 spin_lock_irqsave(&line->lock, flags);
225 if (line->head != line->tail) { 220 if (line->head != line->tail)
226 ret = buffer_data(line, buf, len); 221 ret = buffer_data(line, buf, len);
227 err = flush_buffer(line); 222 else {
228 if (err <= 0 && (err != -EAGAIN || !ret))
229 ret = err;
230 } else {
231 n = write_chan(&line->chan_list, buf, len, 223 n = write_chan(&line->chan_list, buf, len,
232 line->driver->write_irq); 224 line->driver->write_irq);
233 if (n < 0) { 225 if (n < 0) {
@@ -257,17 +249,17 @@ static const struct {
257} tty_ioctls[] = { 249} tty_ioctls[] = {
258 /* don't print these, they flood the log ... */ 250 /* don't print these, they flood the log ... */
259 { TCGETS, NULL, "TCGETS" }, 251 { TCGETS, NULL, "TCGETS" },
260 { TCSETS, NULL, "TCSETS" }, 252 { TCSETS, NULL, "TCSETS" },
261 { TCSETSW, NULL, "TCSETSW" }, 253 { TCSETSW, NULL, "TCSETSW" },
262 { TCFLSH, NULL, "TCFLSH" }, 254 { TCFLSH, NULL, "TCFLSH" },
263 { TCSBRK, NULL, "TCSBRK" }, 255 { TCSBRK, NULL, "TCSBRK" },
264 256
265 /* general tty stuff */ 257 /* general tty stuff */
266 { TCSETSF, KERN_DEBUG, "TCSETSF" }, 258 { TCSETSF, KERN_DEBUG, "TCSETSF" },
267 { TCGETA, KERN_DEBUG, "TCGETA" }, 259 { TCGETA, KERN_DEBUG, "TCGETA" },
268 { TIOCMGET, KERN_DEBUG, "TIOCMGET" }, 260 { TIOCMGET, KERN_DEBUG, "TIOCMGET" },
269 { TCSBRKP, KERN_DEBUG, "TCSBRKP" }, 261 { TCSBRKP, KERN_DEBUG, "TCSBRKP" },
270 { TIOCMSET, KERN_DEBUG, "TIOCMSET" }, 262 { TIOCMSET, KERN_DEBUG, "TIOCMSET" },
271 263
272 /* linux-specific ones */ 264 /* linux-specific ones */
273 { TIOCLINUX, KERN_INFO, "TIOCLINUX" }, 265 { TIOCLINUX, KERN_INFO, "TIOCLINUX" },
@@ -324,12 +316,7 @@ int line_ioctl(struct tty_struct *tty, struct file * file,
324 for (i = 0; i < ARRAY_SIZE(tty_ioctls); i++) 316 for (i = 0; i < ARRAY_SIZE(tty_ioctls); i++)
325 if (cmd == tty_ioctls[i].cmd) 317 if (cmd == tty_ioctls[i].cmd)
326 break; 318 break;
327 if (i < ARRAY_SIZE(tty_ioctls)) { 319 if (i == ARRAY_SIZE(tty_ioctls)) {
328 if (NULL != tty_ioctls[i].level)
329 printk("%s%s: %s: ioctl %s called\n",
330 tty_ioctls[i].level, __FUNCTION__,
331 tty->name, tty_ioctls[i].name);
332 } else {
333 printk(KERN_ERR "%s: %s: unknown ioctl: 0x%x\n", 320 printk(KERN_ERR "%s: %s: unknown ioctl: 0x%x\n",
334 __FUNCTION__, tty->name, cmd); 321 __FUNCTION__, tty->name, cmd);
335 } 322 }
@@ -355,11 +342,12 @@ void line_unthrottle(struct tty_struct *tty)
355 chan_interrupt(&line->chan_list, &line->task, tty, 342 chan_interrupt(&line->chan_list, &line->task, tty,
356 line->driver->read_irq); 343 line->driver->read_irq);
357 344
358 /* Maybe there is enough stuff pending that calling the interrupt 345 /*
346 * Maybe there is enough stuff pending that calling the interrupt
359 * throttles us again. In this case, line->throttled will be 1 347 * throttles us again. In this case, line->throttled will be 1
360 * again and we shouldn't turn the interrupt back on. 348 * again and we shouldn't turn the interrupt back on.
361 */ 349 */
362 if(!line->throttled) 350 if (!line->throttled)
363 reactivate_chan(&line->chan_list, line->driver->read_irq); 351 reactivate_chan(&line->chan_list, line->driver->read_irq);
364} 352}
365 353
@@ -370,27 +358,30 @@ static irqreturn_t line_write_interrupt(int irq, void *data)
370 struct tty_struct *tty = line->tty; 358 struct tty_struct *tty = line->tty;
371 int err; 359 int err;
372 360
373 /* Interrupts are disabled here because we registered the interrupt with 361 /*
374 * IRQF_DISABLED (see line_setup_irq).*/ 362 * Interrupts are disabled here because we registered the interrupt with
363 * IRQF_DISABLED (see line_setup_irq).
364 */
375 365
376 spin_lock(&line->lock); 366 spin_lock(&line->lock);
377 err = flush_buffer(line); 367 err = flush_buffer(line);
378 if (err == 0) { 368 if (err == 0) {
379 return IRQ_NONE; 369 return IRQ_NONE;
380 } else if(err < 0) { 370 } else if (err < 0) {
381 line->head = line->buffer; 371 line->head = line->buffer;
382 line->tail = line->buffer; 372 line->tail = line->buffer;
383 } 373 }
384 spin_unlock(&line->lock); 374 spin_unlock(&line->lock);
385 375
386 if(tty == NULL) 376 if (tty == NULL)
387 return IRQ_NONE; 377 return IRQ_NONE;
388 378
389 if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) && 379 if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) &&
390 (tty->ldisc.write_wakeup != NULL)) 380 (tty->ldisc.write_wakeup != NULL))
391 (tty->ldisc.write_wakeup)(tty); 381 (tty->ldisc.write_wakeup)(tty);
392 382
393 /* BLOCKING mode 383 /*
384 * BLOCKING mode
394 * In blocking mode, everything sleeps on tty->write_wait. 385 * In blocking mode, everything sleeps on tty->write_wait.
395 * Sleeping in the console driver would break non-blocking 386 * Sleeping in the console driver would break non-blocking
396 * writes. 387 * writes.
@@ -420,7 +411,8 @@ int line_setup_irq(int fd, int input, int output, struct line *line, void *data)
420 return err; 411 return err;
421} 412}
422 413
423/* Normally, a driver like this can rely mostly on the tty layer 414/*
415 * Normally, a driver like this can rely mostly on the tty layer
424 * locking, particularly when it comes to the driver structure. 416 * locking, particularly when it comes to the driver structure.
425 * However, in this case, mconsole requests can come in "from the 417 * However, in this case, mconsole requests can come in "from the
426 * side", and race with opens and closes. 418 * side", and race with opens and closes.
@@ -442,11 +434,11 @@ int line_open(struct line *lines, struct tty_struct *tty)
442 int err = -ENODEV; 434 int err = -ENODEV;
443 435
444 spin_lock(&line->count_lock); 436 spin_lock(&line->count_lock);
445 if(!line->valid) 437 if (!line->valid)
446 goto out_unlock; 438 goto out_unlock;
447 439
448 err = 0; 440 err = 0;
449 if(tty->count > 1) 441 if (tty->count > 1)
450 goto out_unlock; 442 goto out_unlock;
451 443
452 spin_unlock(&line->count_lock); 444 spin_unlock(&line->count_lock);
@@ -460,7 +452,7 @@ int line_open(struct line *lines, struct tty_struct *tty)
460 452
461 INIT_DELAYED_WORK(&line->task, line_timer_cb); 453 INIT_DELAYED_WORK(&line->task, line_timer_cb);
462 454
463 if(!line->sigio){ 455 if (!line->sigio) {
464 chan_enable_winch(&line->chan_list, tty); 456 chan_enable_winch(&line->chan_list, tty);
465 line->sigio = 1; 457 line->sigio = 1;
466 } 458 }
@@ -481,20 +473,21 @@ void line_close(struct tty_struct *tty, struct file * filp)
481{ 473{
482 struct line *line = tty->driver_data; 474 struct line *line = tty->driver_data;
483 475
484 /* If line_open fails (and tty->driver_data is never set), 476 /*
477 * If line_open fails (and tty->driver_data is never set),
485 * tty_open will call line_close. So just return in this case. 478 * tty_open will call line_close. So just return in this case.
486 */ 479 */
487 if(line == NULL) 480 if (line == NULL)
488 return; 481 return;
489 482
490 /* We ignore the error anyway! */ 483 /* We ignore the error anyway! */
491 flush_buffer(line); 484 flush_buffer(line);
492 485
493 spin_lock(&line->count_lock); 486 spin_lock(&line->count_lock);
494 if(!line->valid) 487 if (!line->valid)
495 goto out_unlock; 488 goto out_unlock;
496 489
497 if(tty->count > 1) 490 if (tty->count > 1)
498 goto out_unlock; 491 goto out_unlock;
499 492
500 spin_unlock(&line->count_lock); 493 spin_unlock(&line->count_lock);
@@ -502,10 +495,10 @@ void line_close(struct tty_struct *tty, struct file * filp)
502 line->tty = NULL; 495 line->tty = NULL;
503 tty->driver_data = NULL; 496 tty->driver_data = NULL;
504 497
505 if(line->sigio){ 498 if (line->sigio) {
506 unregister_winch(tty); 499 unregister_winch(tty);
507 line->sigio = 0; 500 line->sigio = 0;
508 } 501 }
509 502
510 return; 503 return;
511 504
@@ -529,12 +522,12 @@ static int setup_one_line(struct line *lines, int n, char *init, int init_prio,
529 522
530 spin_lock(&line->count_lock); 523 spin_lock(&line->count_lock);
531 524
532 if(line->tty != NULL){ 525 if (line->tty != NULL) {
533 *error_out = "Device is already open"; 526 *error_out = "Device is already open";
534 goto out; 527 goto out;
535 } 528 }
536 529
537 if (line->init_pri <= init_prio){ 530 if (line->init_pri <= init_prio) {
538 line->init_pri = init_prio; 531 line->init_pri = init_prio;
539 if (!strcmp(init, "none")) 532 if (!strcmp(init, "none"))
540 line->valid = 0; 533 line->valid = 0;
@@ -549,7 +542,8 @@ out:
549 return err; 542 return err;
550} 543}
551 544
552/* Common setup code for both startup command line and mconsole initialization. 545/*
546 * Common setup code for both startup command line and mconsole initialization.
553 * @lines contains the array (of size @num) to modify; 547 * @lines contains the array (of size @num) to modify;
554 * @init is the setup string; 548 * @init is the setup string;
555 * @error_out is an error string in the case of failure; 549 * @error_out is an error string in the case of failure;
@@ -561,14 +555,16 @@ int line_setup(struct line *lines, unsigned int num, char *init,
561 int i, n, err; 555 int i, n, err;
562 char *end; 556 char *end;
563 557
564 if(*init == '=') { 558 if (*init == '=') {
565 /* We said con=/ssl= instead of con#=, so we are configuring all 559 /*
566 * consoles at once.*/ 560 * We said con=/ssl= instead of con#=, so we are configuring all
561 * consoles at once.
562 */
567 n = -1; 563 n = -1;
568 } 564 }
569 else { 565 else {
570 n = simple_strtoul(init, &end, 0); 566 n = simple_strtoul(init, &end, 0);
571 if(*end != '='){ 567 if (*end != '=') {
572 *error_out = "Couldn't parse device number"; 568 *error_out = "Couldn't parse device number";
573 return -EINVAL; 569 return -EINVAL;
574 } 570 }
@@ -580,16 +576,16 @@ int line_setup(struct line *lines, unsigned int num, char *init,
580 *error_out = "Device number out of range"; 576 *error_out = "Device number out of range";
581 return -EINVAL; 577 return -EINVAL;
582 } 578 }
583 else if (n >= 0){ 579 else if (n >= 0) {
584 err = setup_one_line(lines, n, init, INIT_ONE, error_out); 580 err = setup_one_line(lines, n, init, INIT_ONE, error_out);
585 if(err) 581 if (err)
586 return err; 582 return err;
587 } 583 }
588 else { 584 else {
589 for(i = 0; i < num; i++){ 585 for(i = 0; i < num; i++) {
590 err = setup_one_line(lines, i, init, INIT_ALL, 586 err = setup_one_line(lines, i, init, INIT_ALL,
591 error_out); 587 error_out);
592 if(err) 588 if (err)
593 return err; 589 return err;
594 } 590 }
595 } 591 }
@@ -603,18 +599,18 @@ int line_config(struct line *lines, unsigned int num, char *str,
603 char *new; 599 char *new;
604 int n; 600 int n;
605 601
606 if(*str == '='){ 602 if (*str == '=') {
607 *error_out = "Can't configure all devices from mconsole"; 603 *error_out = "Can't configure all devices from mconsole";
608 return -EINVAL; 604 return -EINVAL;
609 } 605 }
610 606
611 new = kstrdup(str, GFP_KERNEL); 607 new = kstrdup(str, GFP_KERNEL);
612 if(new == NULL){ 608 if (new == NULL) {
613 *error_out = "Failed to allocate memory"; 609 *error_out = "Failed to allocate memory";
614 return -ENOMEM; 610 return -ENOMEM;
615 } 611 }
616 n = line_setup(lines, num, new, error_out); 612 n = line_setup(lines, num, new, error_out);
617 if(n < 0) 613 if (n < 0)
618 return n; 614 return n;
619 615
620 line = &lines[n]; 616 line = &lines[n];
@@ -629,12 +625,12 @@ int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
629 int dev, n = 0; 625 int dev, n = 0;
630 626
631 dev = simple_strtoul(name, &end, 0); 627 dev = simple_strtoul(name, &end, 0);
632 if((*end != '\0') || (end == name)){ 628 if ((*end != '\0') || (end == name)) {
633 *error_out = "line_get_config failed to parse device number"; 629 *error_out = "line_get_config failed to parse device number";
634 return 0; 630 return 0;
635 } 631 }
636 632
637 if((dev < 0) || (dev >= num)){ 633 if ((dev < 0) || (dev >= num)) {
638 *error_out = "device number out of range"; 634 *error_out = "device number out of range";
639 return 0; 635 return 0;
640 } 636 }
@@ -642,9 +638,9 @@ int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
642 line = &lines[dev]; 638 line = &lines[dev];
643 639
644 spin_lock(&line->count_lock); 640 spin_lock(&line->count_lock);
645 if(!line->valid) 641 if (!line->valid)
646 CONFIG_CHUNK(str, size, n, "none", 1); 642 CONFIG_CHUNK(str, size, n, "none", 1);
647 else if(line->tty == NULL) 643 else if (line->tty == NULL)
648 CONFIG_CHUNK(str, size, n, line->init_str, 1); 644 CONFIG_CHUNK(str, size, n, line->init_str, 1);
649 else n = chan_config_string(&line->chan_list, str, size, error_out); 645 else n = chan_config_string(&line->chan_list, str, size, error_out);
650 spin_unlock(&line->count_lock); 646 spin_unlock(&line->count_lock);
@@ -655,16 +651,16 @@ int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
655int line_id(char **str, int *start_out, int *end_out) 651int line_id(char **str, int *start_out, int *end_out)
656{ 652{
657 char *end; 653 char *end;
658 int n; 654 int n;
659 655
660 n = simple_strtoul(*str, &end, 0); 656 n = simple_strtoul(*str, &end, 0);
661 if((*end != '\0') || (end == *str)) 657 if ((*end != '\0') || (end == *str))
662 return -1; 658 return -1;
663 659
664 *str = end; 660 *str = end;
665 *start_out = n; 661 *start_out = n;
666 *end_out = n; 662 *end_out = n;
667 return n; 663 return n;
668} 664}
669 665
670int line_remove(struct line *lines, unsigned int num, int n, char **error_out) 666int line_remove(struct line *lines, unsigned int num, int n, char **error_out)
@@ -674,7 +670,7 @@ int line_remove(struct line *lines, unsigned int num, int n, char **error_out)
674 670
675 sprintf(config, "%d=none", n); 671 sprintf(config, "%d=none", n);
676 err = line_setup(lines, num, config, error_out); 672 err = line_setup(lines, num, config, error_out);
677 if(err >= 0) 673 if (err >= 0)
678 err = 0; 674 err = 0;
679 return err; 675 return err;
680} 676}
@@ -700,14 +696,14 @@ struct tty_driver *register_lines(struct line_driver *line_driver,
700 tty_set_operations(driver, ops); 696 tty_set_operations(driver, ops);
701 697
702 if (tty_register_driver(driver)) { 698 if (tty_register_driver(driver)) {
703 printk("%s: can't register %s driver\n", 699 printk(KERN_ERR "register_lines : can't register %s driver\n",
704 __FUNCTION__,line_driver->name); 700 line_driver->name);
705 put_tty_driver(driver); 701 put_tty_driver(driver);
706 return NULL; 702 return NULL;
707 } 703 }
708 704
709 for(i = 0; i < nlines; i++){ 705 for(i = 0; i < nlines; i++) {
710 if(!lines[i].valid) 706 if (!lines[i].valid)
711 tty_unregister_device(driver, i); 707 tty_unregister_device(driver, i);
712 } 708 }
713 709
@@ -724,20 +720,20 @@ void lines_init(struct line *lines, int nlines, struct chan_opts *opts)
724 char *error; 720 char *error;
725 int i; 721 int i;
726 722
727 for(i = 0; i < nlines; i++){ 723 for(i = 0; i < nlines; i++) {
728 line = &lines[i]; 724 line = &lines[i];
729 INIT_LIST_HEAD(&line->chan_list); 725 INIT_LIST_HEAD(&line->chan_list);
730 726
731 if(line->init_str == NULL) 727 if (line->init_str == NULL)
732 continue; 728 continue;
733 729
734 line->init_str = kstrdup(line->init_str, GFP_KERNEL); 730 line->init_str = kstrdup(line->init_str, GFP_KERNEL);
735 if(line->init_str == NULL) 731 if (line->init_str == NULL)
736 printk("lines_init - kstrdup returned NULL\n"); 732 printk(KERN_ERR "lines_init - kstrdup returned NULL\n");
737 733
738 if(parse_chan_pair(line->init_str, line, i, opts, &error)){ 734 if (parse_chan_pair(line->init_str, line, i, opts, &error)) {
739 printk("parse_chan_pair failed for device %d : %s\n", 735 printk(KERN_ERR "parse_chan_pair failed for "
740 i, error); 736 "device %d : %s\n", i, error);
741 line->valid = 0; 737 line->valid = 0;
742 } 738 }
743 } 739 }
@@ -775,14 +771,14 @@ static irqreturn_t winch_interrupt(int irq, void *data)
775 int err; 771 int err;
776 char c; 772 char c;
777 773
778 if(winch->fd != -1){ 774 if (winch->fd != -1) {
779 err = generic_read(winch->fd, &c, NULL); 775 err = generic_read(winch->fd, &c, NULL);
780 if(err < 0){ 776 if (err < 0) {
781 if(err != -EAGAIN){ 777 if (err != -EAGAIN) {
782 printk("winch_interrupt : read failed, " 778 printk(KERN_ERR "winch_interrupt : "
783 "errno = %d\n", -err); 779 "read failed, errno = %d\n", -err);
784 printk("fd %d is losing SIGWINCH support\n", 780 printk(KERN_ERR "fd %d is losing SIGWINCH "
785 winch->tty_fd); 781 "support\n", winch->tty_fd);
786 free_winch(winch, 0); 782 free_winch(winch, 0);
787 return IRQ_HANDLED; 783 return IRQ_HANDLED;
788 } 784 }
@@ -797,7 +793,7 @@ static irqreturn_t winch_interrupt(int irq, void *data)
797 kill_pgrp(tty->pgrp, SIGWINCH, 1); 793 kill_pgrp(tty->pgrp, SIGWINCH, 1);
798 } 794 }
799 out: 795 out:
800 if(winch->fd != -1) 796 if (winch->fd != -1)
801 reactivate_fd(winch->fd, WINCH_IRQ); 797 reactivate_fd(winch->fd, WINCH_IRQ);
802 return IRQ_HANDLED; 798 return IRQ_HANDLED;
803} 799}
@@ -809,7 +805,7 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty,
809 805
810 winch = kmalloc(sizeof(*winch), GFP_KERNEL); 806 winch = kmalloc(sizeof(*winch), GFP_KERNEL);
811 if (winch == NULL) { 807 if (winch == NULL) {
812 printk("register_winch_irq - kmalloc failed\n"); 808 printk(KERN_ERR "register_winch_irq - kmalloc failed\n");
813 goto cleanup; 809 goto cleanup;
814 } 810 }
815 811
@@ -823,7 +819,8 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty,
823 if (um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt, 819 if (um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt,
824 IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM, 820 IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM,
825 "winch", winch) < 0) { 821 "winch", winch) < 0) {
826 printk("register_winch_irq - failed to register IRQ\n"); 822 printk(KERN_ERR "register_winch_irq - failed to register "
823 "IRQ\n");
827 goto out_free; 824 goto out_free;
828 } 825 }
829 826
@@ -849,13 +846,13 @@ static void unregister_winch(struct tty_struct *tty)
849 846
850 spin_lock(&winch_handler_lock); 847 spin_lock(&winch_handler_lock);
851 848
852 list_for_each(ele, &winch_handlers){ 849 list_for_each(ele, &winch_handlers) {
853 winch = list_entry(ele, struct winch, list); 850 winch = list_entry(ele, struct winch, list);
854 if(winch->tty == tty){ 851 if (winch->tty == tty) {
855 free_winch(winch, 1); 852 free_winch(winch, 1);
856 break; 853 break;
857 } 854 }
858 } 855 }
859 spin_unlock(&winch_handler_lock); 856 spin_unlock(&winch_handler_lock);
860} 857}
861 858
@@ -866,7 +863,7 @@ static void winch_cleanup(void)
866 863
867 spin_lock(&winch_handler_lock); 864 spin_lock(&winch_handler_lock);
868 865
869 list_for_each_safe(ele, next, &winch_handlers){ 866 list_for_each_safe(ele, next, &winch_handlers) {
870 winch = list_entry(ele, struct winch, list); 867 winch = list_entry(ele, struct winch, list);
871 free_winch(winch, 1); 868 free_winch(winch, 1);
872 } 869 }
@@ -881,13 +878,13 @@ char *add_xterm_umid(char *base)
881 int len; 878 int len;
882 879
883 umid = get_umid(); 880 umid = get_umid();
884 if(*umid == '\0') 881 if (*umid == '\0')
885 return base; 882 return base;
886 883
887 len = strlen(base) + strlen(" ()") + strlen(umid) + 1; 884 len = strlen(base) + strlen(" ()") + strlen(umid) + 1;
888 title = kmalloc(len, GFP_KERNEL); 885 title = kmalloc(len, GFP_KERNEL);
889 if(title == NULL){ 886 if (title == NULL) {
890 printk("Failed to allocate buffer for xterm title\n"); 887 printk(KERN_ERR "Failed to allocate buffer for xterm title\n");
891 return base; 888 return base;
892 } 889 }
893 890