aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/char/sclp_vt220.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390/char/sclp_vt220.c')
-rw-r--r--drivers/s390/char/sclp_vt220.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
index b635472ae660..edfc0fd73dc6 100644
--- a/drivers/s390/char/sclp_vt220.c
+++ b/drivers/s390/char/sclp_vt220.c
@@ -34,7 +34,6 @@
34#define SCLP_VT220_DEVICE_NAME "ttysclp" 34#define SCLP_VT220_DEVICE_NAME "ttysclp"
35#define SCLP_VT220_CONSOLE_NAME "ttyS" 35#define SCLP_VT220_CONSOLE_NAME "ttyS"
36#define SCLP_VT220_CONSOLE_INDEX 1 /* console=ttyS1 */ 36#define SCLP_VT220_CONSOLE_INDEX 1 /* console=ttyS1 */
37#define SCLP_VT220_BUF_SIZE 80
38 37
39/* Representation of a single write request */ 38/* Representation of a single write request */
40struct sclp_vt220_request { 39struct sclp_vt220_request {
@@ -56,8 +55,7 @@ struct sclp_vt220_sccb {
56/* Structures and data needed to register tty driver */ 55/* Structures and data needed to register tty driver */
57static struct tty_driver *sclp_vt220_driver; 56static struct tty_driver *sclp_vt220_driver;
58 57
59/* The tty_struct that the kernel associated with us */ 58static struct tty_port sclp_vt220_port;
60static struct tty_struct *sclp_vt220_tty;
61 59
62/* Lock to protect internal data from concurrent access */ 60/* Lock to protect internal data from concurrent access */
63static spinlock_t sclp_vt220_lock; 61static spinlock_t sclp_vt220_lock;
@@ -116,6 +114,7 @@ static struct sclp_register sclp_vt220_register = {
116static void 114static void
117sclp_vt220_process_queue(struct sclp_vt220_request *request) 115sclp_vt220_process_queue(struct sclp_vt220_request *request)
118{ 116{
117 struct tty_struct *tty;
119 unsigned long flags; 118 unsigned long flags;
120 void *page; 119 void *page;
121 120
@@ -141,8 +140,10 @@ sclp_vt220_process_queue(struct sclp_vt220_request *request)
141 if (request == NULL && sclp_vt220_flush_later) 140 if (request == NULL && sclp_vt220_flush_later)
142 sclp_vt220_emit_current(); 141 sclp_vt220_emit_current();
143 /* Check if the tty needs a wake up call */ 142 /* Check if the tty needs a wake up call */
144 if (sclp_vt220_tty != NULL) { 143 tty = tty_port_tty_get(&sclp_vt220_port);
145 tty_wakeup(sclp_vt220_tty); 144 if (tty) {
145 tty_wakeup(tty);
146 tty_kref_put(tty);
146 } 147 }
147} 148}
148 149
@@ -460,11 +461,12 @@ sclp_vt220_write(struct tty_struct *tty, const unsigned char *buf, int count)
460static void 461static void
461sclp_vt220_receiver_fn(struct evbuf_header *evbuf) 462sclp_vt220_receiver_fn(struct evbuf_header *evbuf)
462{ 463{
464 struct tty_struct *tty = tty_port_tty_get(&sclp_vt220_port);
463 char *buffer; 465 char *buffer;
464 unsigned int count; 466 unsigned int count;
465 467
466 /* Ignore input if device is not open */ 468 /* Ignore input if device is not open */
467 if (sclp_vt220_tty == NULL) 469 if (tty == NULL)
468 return; 470 return;
469 471
470 buffer = (char *) ((addr_t) evbuf + sizeof(struct evbuf_header)); 472 buffer = (char *) ((addr_t) evbuf + sizeof(struct evbuf_header));
@@ -478,10 +480,11 @@ sclp_vt220_receiver_fn(struct evbuf_header *evbuf)
478 /* Send input to line discipline */ 480 /* Send input to line discipline */
479 buffer++; 481 buffer++;
480 count--; 482 count--;
481 tty_insert_flip_string(sclp_vt220_tty, buffer, count); 483 tty_insert_flip_string(tty, buffer, count);
482 tty_flip_buffer_push(sclp_vt220_tty); 484 tty_flip_buffer_push(tty);
483 break; 485 break;
484 } 486 }
487 tty_kref_put(tty);
485} 488}
486 489
487/* 490/*
@@ -491,10 +494,7 @@ static int
491sclp_vt220_open(struct tty_struct *tty, struct file *filp) 494sclp_vt220_open(struct tty_struct *tty, struct file *filp)
492{ 495{
493 if (tty->count == 1) { 496 if (tty->count == 1) {
494 sclp_vt220_tty = tty; 497 tty_port_tty_set(&sclp_vt220_port, tty);
495 tty->driver_data = kmalloc(SCLP_VT220_BUF_SIZE, GFP_KERNEL);
496 if (tty->driver_data == NULL)
497 return -ENOMEM;
498 tty->low_latency = 0; 498 tty->low_latency = 0;
499 if (!tty->winsize.ws_row && !tty->winsize.ws_col) { 499 if (!tty->winsize.ws_row && !tty->winsize.ws_col) {
500 tty->winsize.ws_row = 24; 500 tty->winsize.ws_row = 24;
@@ -510,11 +510,8 @@ sclp_vt220_open(struct tty_struct *tty, struct file *filp)
510static void 510static void
511sclp_vt220_close(struct tty_struct *tty, struct file *filp) 511sclp_vt220_close(struct tty_struct *tty, struct file *filp)
512{ 512{
513 if (tty->count == 1) { 513 if (tty->count == 1)
514 sclp_vt220_tty = NULL; 514 tty_port_tty_set(&sclp_vt220_port, NULL);
515 kfree(tty->driver_data);
516 tty->driver_data = NULL;
517 }
518} 515}
519 516
520/* 517/*
@@ -635,9 +632,9 @@ static int __init __sclp_vt220_init(int num_pages)
635 INIT_LIST_HEAD(&sclp_vt220_empty); 632 INIT_LIST_HEAD(&sclp_vt220_empty);
636 INIT_LIST_HEAD(&sclp_vt220_outqueue); 633 INIT_LIST_HEAD(&sclp_vt220_outqueue);
637 init_timer(&sclp_vt220_timer); 634 init_timer(&sclp_vt220_timer);
635 tty_port_init(&sclp_vt220_port);
638 sclp_vt220_current_request = NULL; 636 sclp_vt220_current_request = NULL;
639 sclp_vt220_buffered_chars = 0; 637 sclp_vt220_buffered_chars = 0;
640 sclp_vt220_tty = NULL;
641 sclp_vt220_flush_later = 0; 638 sclp_vt220_flush_later = 0;
642 639
643 /* Allocate pages for output buffering */ 640 /* Allocate pages for output buffering */