aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/um/drivers/line.c228
1 files changed, 114 insertions, 114 deletions
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index b4538dfb4820..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);
@@ -218,7 +213,7 @@ int line_write(struct tty_struct *tty, const unsigned char *buf, int len)
218 unsigned long flags; 213 unsigned long flags;
219 int n, 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);
@@ -254,17 +249,17 @@ static const struct {
254} tty_ioctls[] = { 249} tty_ioctls[] = {
255 /* don't print these, they flood the log ... */ 250 /* don't print these, they flood the log ... */
256 { TCGETS, NULL, "TCGETS" }, 251 { TCGETS, NULL, "TCGETS" },
257 { TCSETS, NULL, "TCSETS" }, 252 { TCSETS, NULL, "TCSETS" },
258 { TCSETSW, NULL, "TCSETSW" }, 253 { TCSETSW, NULL, "TCSETSW" },
259 { TCFLSH, NULL, "TCFLSH" }, 254 { TCFLSH, NULL, "TCFLSH" },
260 { TCSBRK, NULL, "TCSBRK" }, 255 { TCSBRK, NULL, "TCSBRK" },
261 256
262 /* general tty stuff */ 257 /* general tty stuff */
263 { TCSETSF, KERN_DEBUG, "TCSETSF" }, 258 { TCSETSF, KERN_DEBUG, "TCSETSF" },
264 { TCGETA, KERN_DEBUG, "TCGETA" }, 259 { TCGETA, KERN_DEBUG, "TCGETA" },
265 { TIOCMGET, KERN_DEBUG, "TIOCMGET" }, 260 { TIOCMGET, KERN_DEBUG, "TIOCMGET" },
266 { TCSBRKP, KERN_DEBUG, "TCSBRKP" }, 261 { TCSBRKP, KERN_DEBUG, "TCSBRKP" },
267 { TIOCMSET, KERN_DEBUG, "TIOCMSET" }, 262 { TIOCMSET, KERN_DEBUG, "TIOCMSET" },
268 263
269 /* linux-specific ones */ 264 /* linux-specific ones */
270 { TIOCLINUX, KERN_INFO, "TIOCLINUX" }, 265 { TIOCLINUX, KERN_INFO, "TIOCLINUX" },
@@ -321,12 +316,7 @@ int line_ioctl(struct tty_struct *tty, struct file * file,
321 for (i = 0; i < ARRAY_SIZE(tty_ioctls); i++) 316 for (i = 0; i < ARRAY_SIZE(tty_ioctls); i++)
322 if (cmd == tty_ioctls[i].cmd) 317 if (cmd == tty_ioctls[i].cmd)
323 break; 318 break;
324 if (i < ARRAY_SIZE(tty_ioctls)) { 319 if (i == ARRAY_SIZE(tty_ioctls)) {
325 if (NULL != tty_ioctls[i].level)
326 printk("%s%s: %s: ioctl %s called\n",
327 tty_ioctls[i].level, __FUNCTION__,
328 tty->name, tty_ioctls[i].name);
329 } else {
330 printk(KERN_ERR "%s: %s: unknown ioctl: 0x%x\n", 320 printk(KERN_ERR "%s: %s: unknown ioctl: 0x%x\n",
331 __FUNCTION__, tty->name, cmd); 321 __FUNCTION__, tty->name, cmd);
332 } 322 }
@@ -352,11 +342,12 @@ void line_unthrottle(struct tty_struct *tty)
352 chan_interrupt(&line->chan_list, &line->task, tty, 342 chan_interrupt(&line->chan_list, &line->task, tty,
353 line->driver->read_irq); 343 line->driver->read_irq);
354 344
355 /* Maybe there is enough stuff pending that calling the interrupt 345 /*
346 * Maybe there is enough stuff pending that calling the interrupt
356 * throttles us again. In this case, line->throttled will be 1 347 * throttles us again. In this case, line->throttled will be 1
357 * again and we shouldn't turn the interrupt back on. 348 * again and we shouldn't turn the interrupt back on.
358 */ 349 */
359 if(!line->throttled) 350 if (!line->throttled)
360 reactivate_chan(&line->chan_list, line->driver->read_irq); 351 reactivate_chan(&line->chan_list, line->driver->read_irq);
361} 352}
362 353
@@ -367,27 +358,30 @@ static irqreturn_t line_write_interrupt(int irq, void *data)
367 struct tty_struct *tty = line->tty; 358 struct tty_struct *tty = line->tty;
368 int err; 359 int err;
369 360
370 /* Interrupts are disabled here because we registered the interrupt with 361 /*
371 * 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 */
372 365
373 spin_lock(&line->lock); 366 spin_lock(&line->lock);
374 err = flush_buffer(line); 367 err = flush_buffer(line);
375 if (err == 0) { 368 if (err == 0) {
376 return IRQ_NONE; 369 return IRQ_NONE;
377 } else if(err < 0) { 370 } else if (err < 0) {
378 line->head = line->buffer; 371 line->head = line->buffer;
379 line->tail = line->buffer; 372 line->tail = line->buffer;
380 } 373 }
381 spin_unlock(&line->lock); 374 spin_unlock(&line->lock);
382 375
383 if(tty == NULL) 376 if (tty == NULL)
384 return IRQ_NONE; 377 return IRQ_NONE;
385 378
386 if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) && 379 if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) &&
387 (tty->ldisc.write_wakeup != NULL)) 380 (tty->ldisc.write_wakeup != NULL))
388 (tty->ldisc.write_wakeup)(tty); 381 (tty->ldisc.write_wakeup)(tty);
389 382
390 /* BLOCKING mode 383 /*
384 * BLOCKING mode
391 * In blocking mode, everything sleeps on tty->write_wait. 385 * In blocking mode, everything sleeps on tty->write_wait.
392 * Sleeping in the console driver would break non-blocking 386 * Sleeping in the console driver would break non-blocking
393 * writes. 387 * writes.
@@ -417,7 +411,8 @@ int line_setup_irq(int fd, int input, int output, struct line *line, void *data)
417 return err; 411 return err;
418} 412}
419 413
420/* 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
421 * locking, particularly when it comes to the driver structure. 416 * locking, particularly when it comes to the driver structure.
422 * However, in this case, mconsole requests can come in "from the 417 * However, in this case, mconsole requests can come in "from the
423 * side", and race with opens and closes. 418 * side", and race with opens and closes.
@@ -439,11 +434,11 @@ int line_open(struct line *lines, struct tty_struct *tty)
439 int err = -ENODEV; 434 int err = -ENODEV;
440 435
441 spin_lock(&line->count_lock); 436 spin_lock(&line->count_lock);
442 if(!line->valid) 437 if (!line->valid)
443 goto out_unlock; 438 goto out_unlock;
444 439
445 err = 0; 440 err = 0;
446 if(tty->count > 1) 441 if (tty->count > 1)
447 goto out_unlock; 442 goto out_unlock;
448 443
449 spin_unlock(&line->count_lock); 444 spin_unlock(&line->count_lock);
@@ -457,7 +452,7 @@ int line_open(struct line *lines, struct tty_struct *tty)
457 452
458 INIT_DELAYED_WORK(&line->task, line_timer_cb); 453 INIT_DELAYED_WORK(&line->task, line_timer_cb);
459 454
460 if(!line->sigio){ 455 if (!line->sigio) {
461 chan_enable_winch(&line->chan_list, tty); 456 chan_enable_winch(&line->chan_list, tty);
462 line->sigio = 1; 457 line->sigio = 1;
463 } 458 }
@@ -478,20 +473,21 @@ void line_close(struct tty_struct *tty, struct file * filp)
478{ 473{
479 struct line *line = tty->driver_data; 474 struct line *line = tty->driver_data;
480 475
481 /* If line_open fails (and tty->driver_data is never set), 476 /*
477 * If line_open fails (and tty->driver_data is never set),
482 * 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.
483 */ 479 */
484 if(line == NULL) 480 if (line == NULL)
485 return; 481 return;
486 482
487 /* We ignore the error anyway! */ 483 /* We ignore the error anyway! */
488 flush_buffer(line); 484 flush_buffer(line);
489 485
490 spin_lock(&line->count_lock); 486 spin_lock(&line->count_lock);
491 if(!line->valid) 487 if (!line->valid)
492 goto out_unlock; 488 goto out_unlock;
493 489
494 if(tty->count > 1) 490 if (tty->count > 1)
495 goto out_unlock; 491 goto out_unlock;
496 492
497 spin_unlock(&line->count_lock); 493 spin_unlock(&line->count_lock);
@@ -499,10 +495,10 @@ void line_close(struct tty_struct *tty, struct file * filp)
499 line->tty = NULL; 495 line->tty = NULL;
500 tty->driver_data = NULL; 496 tty->driver_data = NULL;
501 497
502 if(line->sigio){ 498 if (line->sigio) {
503 unregister_winch(tty); 499 unregister_winch(tty);
504 line->sigio = 0; 500 line->sigio = 0;
505 } 501 }
506 502
507 return; 503 return;
508 504
@@ -526,12 +522,12 @@ static int setup_one_line(struct line *lines, int n, char *init, int init_prio,
526 522
527 spin_lock(&line->count_lock); 523 spin_lock(&line->count_lock);
528 524
529 if(line->tty != NULL){ 525 if (line->tty != NULL) {
530 *error_out = "Device is already open"; 526 *error_out = "Device is already open";
531 goto out; 527 goto out;
532 } 528 }
533 529
534 if (line->init_pri <= init_prio){ 530 if (line->init_pri <= init_prio) {
535 line->init_pri = init_prio; 531 line->init_pri = init_prio;
536 if (!strcmp(init, "none")) 532 if (!strcmp(init, "none"))
537 line->valid = 0; 533 line->valid = 0;
@@ -546,7 +542,8 @@ out:
546 return err; 542 return err;
547} 543}
548 544
549/* Common setup code for both startup command line and mconsole initialization. 545/*
546 * Common setup code for both startup command line and mconsole initialization.
550 * @lines contains the array (of size @num) to modify; 547 * @lines contains the array (of size @num) to modify;
551 * @init is the setup string; 548 * @init is the setup string;
552 * @error_out is an error string in the case of failure; 549 * @error_out is an error string in the case of failure;
@@ -558,14 +555,16 @@ int line_setup(struct line *lines, unsigned int num, char *init,
558 int i, n, err; 555 int i, n, err;
559 char *end; 556 char *end;
560 557
561 if(*init == '=') { 558 if (*init == '=') {
562 /* We said con=/ssl= instead of con#=, so we are configuring all 559 /*
563 * consoles at once.*/ 560 * We said con=/ssl= instead of con#=, so we are configuring all
561 * consoles at once.
562 */
564 n = -1; 563 n = -1;
565 } 564 }
566 else { 565 else {
567 n = simple_strtoul(init, &end, 0); 566 n = simple_strtoul(init, &end, 0);
568 if(*end != '='){ 567 if (*end != '=') {
569 *error_out = "Couldn't parse device number"; 568 *error_out = "Couldn't parse device number";
570 return -EINVAL; 569 return -EINVAL;
571 } 570 }
@@ -577,16 +576,16 @@ int line_setup(struct line *lines, unsigned int num, char *init,
577 *error_out = "Device number out of range"; 576 *error_out = "Device number out of range";
578 return -EINVAL; 577 return -EINVAL;
579 } 578 }
580 else if (n >= 0){ 579 else if (n >= 0) {
581 err = setup_one_line(lines, n, init, INIT_ONE, error_out); 580 err = setup_one_line(lines, n, init, INIT_ONE, error_out);
582 if(err) 581 if (err)
583 return err; 582 return err;
584 } 583 }
585 else { 584 else {
586 for(i = 0; i < num; i++){ 585 for(i = 0; i < num; i++) {
587 err = setup_one_line(lines, i, init, INIT_ALL, 586 err = setup_one_line(lines, i, init, INIT_ALL,
588 error_out); 587 error_out);
589 if(err) 588 if (err)
590 return err; 589 return err;
591 } 590 }
592 } 591 }
@@ -600,18 +599,18 @@ int line_config(struct line *lines, unsigned int num, char *str,
600 char *new; 599 char *new;
601 int n; 600 int n;
602 601
603 if(*str == '='){ 602 if (*str == '=') {
604 *error_out = "Can't configure all devices from mconsole"; 603 *error_out = "Can't configure all devices from mconsole";
605 return -EINVAL; 604 return -EINVAL;
606 } 605 }
607 606
608 new = kstrdup(str, GFP_KERNEL); 607 new = kstrdup(str, GFP_KERNEL);
609 if(new == NULL){ 608 if (new == NULL) {
610 *error_out = "Failed to allocate memory"; 609 *error_out = "Failed to allocate memory";
611 return -ENOMEM; 610 return -ENOMEM;
612 } 611 }
613 n = line_setup(lines, num, new, error_out); 612 n = line_setup(lines, num, new, error_out);
614 if(n < 0) 613 if (n < 0)
615 return n; 614 return n;
616 615
617 line = &lines[n]; 616 line = &lines[n];
@@ -626,12 +625,12 @@ int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
626 int dev, n = 0; 625 int dev, n = 0;
627 626
628 dev = simple_strtoul(name, &end, 0); 627 dev = simple_strtoul(name, &end, 0);
629 if((*end != '\0') || (end == name)){ 628 if ((*end != '\0') || (end == name)) {
630 *error_out = "line_get_config failed to parse device number"; 629 *error_out = "line_get_config failed to parse device number";
631 return 0; 630 return 0;
632 } 631 }
633 632
634 if((dev < 0) || (dev >= num)){ 633 if ((dev < 0) || (dev >= num)) {
635 *error_out = "device number out of range"; 634 *error_out = "device number out of range";
636 return 0; 635 return 0;
637 } 636 }
@@ -639,9 +638,9 @@ int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
639 line = &lines[dev]; 638 line = &lines[dev];
640 639
641 spin_lock(&line->count_lock); 640 spin_lock(&line->count_lock);
642 if(!line->valid) 641 if (!line->valid)
643 CONFIG_CHUNK(str, size, n, "none", 1); 642 CONFIG_CHUNK(str, size, n, "none", 1);
644 else if(line->tty == NULL) 643 else if (line->tty == NULL)
645 CONFIG_CHUNK(str, size, n, line->init_str, 1); 644 CONFIG_CHUNK(str, size, n, line->init_str, 1);
646 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);
647 spin_unlock(&line->count_lock); 646 spin_unlock(&line->count_lock);
@@ -652,16 +651,16 @@ int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
652int line_id(char **str, int *start_out, int *end_out) 651int line_id(char **str, int *start_out, int *end_out)
653{ 652{
654 char *end; 653 char *end;
655 int n; 654 int n;
656 655
657 n = simple_strtoul(*str, &end, 0); 656 n = simple_strtoul(*str, &end, 0);
658 if((*end != '\0') || (end == *str)) 657 if ((*end != '\0') || (end == *str))
659 return -1; 658 return -1;
660 659
661 *str = end; 660 *str = end;
662 *start_out = n; 661 *start_out = n;
663 *end_out = n; 662 *end_out = n;
664 return n; 663 return n;
665} 664}
666 665
667int 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)
@@ -671,7 +670,7 @@ int line_remove(struct line *lines, unsigned int num, int n, char **error_out)
671 670
672 sprintf(config, "%d=none", n); 671 sprintf(config, "%d=none", n);
673 err = line_setup(lines, num, config, error_out); 672 err = line_setup(lines, num, config, error_out);
674 if(err >= 0) 673 if (err >= 0)
675 err = 0; 674 err = 0;
676 return err; 675 return err;
677} 676}
@@ -697,14 +696,14 @@ struct tty_driver *register_lines(struct line_driver *line_driver,
697 tty_set_operations(driver, ops); 696 tty_set_operations(driver, ops);
698 697
699 if (tty_register_driver(driver)) { 698 if (tty_register_driver(driver)) {
700 printk("%s: can't register %s driver\n", 699 printk(KERN_ERR "register_lines : can't register %s driver\n",
701 __FUNCTION__,line_driver->name); 700 line_driver->name);
702 put_tty_driver(driver); 701 put_tty_driver(driver);
703 return NULL; 702 return NULL;
704 } 703 }
705 704
706 for(i = 0; i < nlines; i++){ 705 for(i = 0; i < nlines; i++) {
707 if(!lines[i].valid) 706 if (!lines[i].valid)
708 tty_unregister_device(driver, i); 707 tty_unregister_device(driver, i);
709 } 708 }
710 709
@@ -721,20 +720,20 @@ void lines_init(struct line *lines, int nlines, struct chan_opts *opts)
721 char *error; 720 char *error;
722 int i; 721 int i;
723 722
724 for(i = 0; i < nlines; i++){ 723 for(i = 0; i < nlines; i++) {
725 line = &lines[i]; 724 line = &lines[i];
726 INIT_LIST_HEAD(&line->chan_list); 725 INIT_LIST_HEAD(&line->chan_list);
727 726
728 if(line->init_str == NULL) 727 if (line->init_str == NULL)
729 continue; 728 continue;
730 729
731 line->init_str = kstrdup(line->init_str, GFP_KERNEL); 730 line->init_str = kstrdup(line->init_str, GFP_KERNEL);
732 if(line->init_str == NULL) 731 if (line->init_str == NULL)
733 printk("lines_init - kstrdup returned NULL\n"); 732 printk(KERN_ERR "lines_init - kstrdup returned NULL\n");
734 733
735 if(parse_chan_pair(line->init_str, line, i, opts, &error)){ 734 if (parse_chan_pair(line->init_str, line, i, opts, &error)) {
736 printk("parse_chan_pair failed for device %d : %s\n", 735 printk(KERN_ERR "parse_chan_pair failed for "
737 i, error); 736 "device %d : %s\n", i, error);
738 line->valid = 0; 737 line->valid = 0;
739 } 738 }
740 } 739 }
@@ -772,14 +771,14 @@ static irqreturn_t winch_interrupt(int irq, void *data)
772 int err; 771 int err;
773 char c; 772 char c;
774 773
775 if(winch->fd != -1){ 774 if (winch->fd != -1) {
776 err = generic_read(winch->fd, &c, NULL); 775 err = generic_read(winch->fd, &c, NULL);
777 if(err < 0){ 776 if (err < 0) {
778 if(err != -EAGAIN){ 777 if (err != -EAGAIN) {
779 printk("winch_interrupt : read failed, " 778 printk(KERN_ERR "winch_interrupt : "
780 "errno = %d\n", -err); 779 "read failed, errno = %d\n", -err);
781 printk("fd %d is losing SIGWINCH support\n", 780 printk(KERN_ERR "fd %d is losing SIGWINCH "
782 winch->tty_fd); 781 "support\n", winch->tty_fd);
783 free_winch(winch, 0); 782 free_winch(winch, 0);
784 return IRQ_HANDLED; 783 return IRQ_HANDLED;
785 } 784 }
@@ -794,7 +793,7 @@ static irqreturn_t winch_interrupt(int irq, void *data)
794 kill_pgrp(tty->pgrp, SIGWINCH, 1); 793 kill_pgrp(tty->pgrp, SIGWINCH, 1);
795 } 794 }
796 out: 795 out:
797 if(winch->fd != -1) 796 if (winch->fd != -1)
798 reactivate_fd(winch->fd, WINCH_IRQ); 797 reactivate_fd(winch->fd, WINCH_IRQ);
799 return IRQ_HANDLED; 798 return IRQ_HANDLED;
800} 799}
@@ -806,7 +805,7 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty,
806 805
807 winch = kmalloc(sizeof(*winch), GFP_KERNEL); 806 winch = kmalloc(sizeof(*winch), GFP_KERNEL);
808 if (winch == NULL) { 807 if (winch == NULL) {
809 printk("register_winch_irq - kmalloc failed\n"); 808 printk(KERN_ERR "register_winch_irq - kmalloc failed\n");
810 goto cleanup; 809 goto cleanup;
811 } 810 }
812 811
@@ -820,7 +819,8 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty,
820 if (um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt, 819 if (um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt,
821 IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM, 820 IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM,
822 "winch", winch) < 0) { 821 "winch", winch) < 0) {
823 printk("register_winch_irq - failed to register IRQ\n"); 822 printk(KERN_ERR "register_winch_irq - failed to register "
823 "IRQ\n");
824 goto out_free; 824 goto out_free;
825 } 825 }
826 826
@@ -846,13 +846,13 @@ static void unregister_winch(struct tty_struct *tty)
846 846
847 spin_lock(&winch_handler_lock); 847 spin_lock(&winch_handler_lock);
848 848
849 list_for_each(ele, &winch_handlers){ 849 list_for_each(ele, &winch_handlers) {
850 winch = list_entry(ele, struct winch, list); 850 winch = list_entry(ele, struct winch, list);
851 if(winch->tty == tty){ 851 if (winch->tty == tty) {
852 free_winch(winch, 1); 852 free_winch(winch, 1);
853 break; 853 break;
854 } 854 }
855 } 855 }
856 spin_unlock(&winch_handler_lock); 856 spin_unlock(&winch_handler_lock);
857} 857}
858 858
@@ -863,7 +863,7 @@ static void winch_cleanup(void)
863 863
864 spin_lock(&winch_handler_lock); 864 spin_lock(&winch_handler_lock);
865 865
866 list_for_each_safe(ele, next, &winch_handlers){ 866 list_for_each_safe(ele, next, &winch_handlers) {
867 winch = list_entry(ele, struct winch, list); 867 winch = list_entry(ele, struct winch, list);
868 free_winch(winch, 1); 868 free_winch(winch, 1);
869 } 869 }
@@ -878,13 +878,13 @@ char *add_xterm_umid(char *base)
878 int len; 878 int len;
879 879
880 umid = get_umid(); 880 umid = get_umid();
881 if(*umid == '\0') 881 if (*umid == '\0')
882 return base; 882 return base;
883 883
884 len = strlen(base) + strlen(" ()") + strlen(umid) + 1; 884 len = strlen(base) + strlen(" ()") + strlen(umid) + 1;
885 title = kmalloc(len, GFP_KERNEL); 885 title = kmalloc(len, GFP_KERNEL);
886 if(title == NULL){ 886 if (title == NULL) {
887 printk("Failed to allocate buffer for xterm title\n"); 887 printk(KERN_ERR "Failed to allocate buffer for xterm title\n");
888 return base; 888 return base;
889 } 889 }
890 890