diff options
Diffstat (limited to 'drivers/char/hvc_console.c')
-rw-r--r-- | drivers/char/hvc_console.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c index 3650c904401e..2d256dc80529 100644 --- a/drivers/char/hvc_console.c +++ b/drivers/char/hvc_console.c | |||
@@ -374,6 +374,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp) | |||
374 | if (hp->ops->notifier_del) | 374 | if (hp->ops->notifier_del) |
375 | hp->ops->notifier_del(hp, hp->data); | 375 | hp->ops->notifier_del(hp, hp->data); |
376 | 376 | ||
377 | /* cancel pending tty resize work */ | ||
378 | cancel_work_sync(&hp->tty_resize); | ||
379 | |||
377 | /* | 380 | /* |
378 | * Chain calls chars_in_buffer() and returns immediately if | 381 | * Chain calls chars_in_buffer() and returns immediately if |
379 | * there is no buffered data otherwise sleeps on a wait queue | 382 | * there is no buffered data otherwise sleeps on a wait queue |
@@ -399,6 +402,9 @@ static void hvc_hangup(struct tty_struct *tty) | |||
399 | if (!hp) | 402 | if (!hp) |
400 | return; | 403 | return; |
401 | 404 | ||
405 | /* cancel pending tty resize work */ | ||
406 | cancel_work_sync(&hp->tty_resize); | ||
407 | |||
402 | spin_lock_irqsave(&hp->lock, flags); | 408 | spin_lock_irqsave(&hp->lock, flags); |
403 | 409 | ||
404 | /* | 410 | /* |
@@ -494,6 +500,39 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count | |||
494 | return written; | 500 | return written; |
495 | } | 501 | } |
496 | 502 | ||
503 | /** | ||
504 | * hvc_set_winsz() - Resize the hvc tty terminal window. | ||
505 | * @work: work structure. | ||
506 | * | ||
507 | * The routine shall not be called within an atomic context because it | ||
508 | * might sleep. | ||
509 | * | ||
510 | * Locking: hp->lock | ||
511 | */ | ||
512 | static void hvc_set_winsz(struct work_struct *work) | ||
513 | { | ||
514 | struct hvc_struct *hp; | ||
515 | unsigned long hvc_flags; | ||
516 | struct tty_struct *tty; | ||
517 | struct winsize ws; | ||
518 | |||
519 | hp = container_of(work, struct hvc_struct, tty_resize); | ||
520 | if (!hp) | ||
521 | return; | ||
522 | |||
523 | spin_lock_irqsave(&hp->lock, hvc_flags); | ||
524 | if (!hp->tty) { | ||
525 | spin_unlock_irqrestore(&hp->lock, hvc_flags); | ||
526 | return; | ||
527 | } | ||
528 | ws = hp->ws; | ||
529 | tty = tty_kref_get(hp->tty); | ||
530 | spin_unlock_irqrestore(&hp->lock, hvc_flags); | ||
531 | |||
532 | tty_do_resize(tty, tty, &ws); | ||
533 | tty_kref_put(tty); | ||
534 | } | ||
535 | |||
497 | /* | 536 | /* |
498 | * This is actually a contract between the driver and the tty layer outlining | 537 | * This is actually a contract between the driver and the tty layer outlining |
499 | * how much write room the driver can guarantee will be sent OR BUFFERED. This | 538 | * how much write room the driver can guarantee will be sent OR BUFFERED. This |
@@ -638,6 +677,24 @@ int hvc_poll(struct hvc_struct *hp) | |||
638 | } | 677 | } |
639 | EXPORT_SYMBOL_GPL(hvc_poll); | 678 | EXPORT_SYMBOL_GPL(hvc_poll); |
640 | 679 | ||
680 | /** | ||
681 | * hvc_resize() - Update terminal window size information. | ||
682 | * @hp: HVC console pointer | ||
683 | * @ws: Terminal window size structure | ||
684 | * | ||
685 | * Stores the specified window size information in the hvc structure of @hp. | ||
686 | * The function schedule the tty resize update. | ||
687 | * | ||
688 | * Locking: Locking free; the function MUST be called holding hp->lock | ||
689 | */ | ||
690 | void hvc_resize(struct hvc_struct *hp, struct winsize ws) | ||
691 | { | ||
692 | if ((hp->ws.ws_row != ws.ws_row) || (hp->ws.ws_col != ws.ws_col)) { | ||
693 | hp->ws = ws; | ||
694 | schedule_work(&hp->tty_resize); | ||
695 | } | ||
696 | } | ||
697 | |||
641 | /* | 698 | /* |
642 | * This kthread is either polling or interrupt driven. This is determined by | 699 | * This kthread is either polling or interrupt driven. This is determined by |
643 | * calling hvc_poll() who determines whether a console adapter support | 700 | * calling hvc_poll() who determines whether a console adapter support |
@@ -720,6 +777,7 @@ struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int data, | |||
720 | 777 | ||
721 | kref_init(&hp->kref); | 778 | kref_init(&hp->kref); |
722 | 779 | ||
780 | INIT_WORK(&hp->tty_resize, hvc_set_winsz); | ||
723 | spin_lock_init(&hp->lock); | 781 | spin_lock_init(&hp->lock); |
724 | spin_lock(&hvc_structs_lock); | 782 | spin_lock(&hvc_structs_lock); |
725 | 783 | ||