aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/char
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-04-02 07:54:13 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-09 14:28:17 -0400
commit092f73779906899c687c5db58d2603c9619c7763 (patch)
treeb764b365859a3af4ebc8a4db26d56ced33daccdb /drivers/s390/char
parent0ea63da2ffa54f6196405010379d56f0c8085b7e (diff)
TTY: sclp_vt220, add tty_port
tty_port will hold tty buffers in the future. So we need to have it even here. The only needed member here is tty, so let us store it in the structure now. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: linux390@de.ibm.com Cc: linux-s390@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/s390/char')
-rw-r--r--drivers/s390/char/sclp_vt220.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
index b635472ae660..25cf2e8c162a 100644
--- a/drivers/s390/char/sclp_vt220.c
+++ b/drivers/s390/char/sclp_vt220.c
@@ -56,8 +56,7 @@ struct sclp_vt220_sccb {
56/* Structures and data needed to register tty driver */ 56/* Structures and data needed to register tty driver */
57static struct tty_driver *sclp_vt220_driver; 57static struct tty_driver *sclp_vt220_driver;
58 58
59/* The tty_struct that the kernel associated with us */ 59static struct tty_port sclp_vt220_port;
60static struct tty_struct *sclp_vt220_tty;
61 60
62/* Lock to protect internal data from concurrent access */ 61/* Lock to protect internal data from concurrent access */
63static spinlock_t sclp_vt220_lock; 62static spinlock_t sclp_vt220_lock;
@@ -116,6 +115,7 @@ static struct sclp_register sclp_vt220_register = {
116static void 115static void
117sclp_vt220_process_queue(struct sclp_vt220_request *request) 116sclp_vt220_process_queue(struct sclp_vt220_request *request)
118{ 117{
118 struct tty_struct *tty;
119 unsigned long flags; 119 unsigned long flags;
120 void *page; 120 void *page;
121 121
@@ -141,8 +141,10 @@ sclp_vt220_process_queue(struct sclp_vt220_request *request)
141 if (request == NULL && sclp_vt220_flush_later) 141 if (request == NULL && sclp_vt220_flush_later)
142 sclp_vt220_emit_current(); 142 sclp_vt220_emit_current();
143 /* Check if the tty needs a wake up call */ 143 /* Check if the tty needs a wake up call */
144 if (sclp_vt220_tty != NULL) { 144 tty = tty_port_tty_get(&sclp_vt220_port);
145 tty_wakeup(sclp_vt220_tty); 145 if (tty) {
146 tty_wakeup(tty);
147 tty_kref_put(tty);
146 } 148 }
147} 149}
148 150
@@ -460,11 +462,12 @@ sclp_vt220_write(struct tty_struct *tty, const unsigned char *buf, int count)
460static void 462static void
461sclp_vt220_receiver_fn(struct evbuf_header *evbuf) 463sclp_vt220_receiver_fn(struct evbuf_header *evbuf)
462{ 464{
465 struct tty_struct *tty = tty_port_tty_get(&sclp_vt220_port);
463 char *buffer; 466 char *buffer;
464 unsigned int count; 467 unsigned int count;
465 468
466 /* Ignore input if device is not open */ 469 /* Ignore input if device is not open */
467 if (sclp_vt220_tty == NULL) 470 if (tty == NULL)
468 return; 471 return;
469 472
470 buffer = (char *) ((addr_t) evbuf + sizeof(struct evbuf_header)); 473 buffer = (char *) ((addr_t) evbuf + sizeof(struct evbuf_header));
@@ -478,10 +481,11 @@ sclp_vt220_receiver_fn(struct evbuf_header *evbuf)
478 /* Send input to line discipline */ 481 /* Send input to line discipline */
479 buffer++; 482 buffer++;
480 count--; 483 count--;
481 tty_insert_flip_string(sclp_vt220_tty, buffer, count); 484 tty_insert_flip_string(tty, buffer, count);
482 tty_flip_buffer_push(sclp_vt220_tty); 485 tty_flip_buffer_push(tty);
483 break; 486 break;
484 } 487 }
488 tty_kref_put(tty);
485} 489}
486 490
487/* 491/*
@@ -491,7 +495,7 @@ static int
491sclp_vt220_open(struct tty_struct *tty, struct file *filp) 495sclp_vt220_open(struct tty_struct *tty, struct file *filp)
492{ 496{
493 if (tty->count == 1) { 497 if (tty->count == 1) {
494 sclp_vt220_tty = tty; 498 tty_port_tty_set(&sclp_vt220_port, tty);
495 tty->driver_data = kmalloc(SCLP_VT220_BUF_SIZE, GFP_KERNEL); 499 tty->driver_data = kmalloc(SCLP_VT220_BUF_SIZE, GFP_KERNEL);
496 if (tty->driver_data == NULL) 500 if (tty->driver_data == NULL)
497 return -ENOMEM; 501 return -ENOMEM;
@@ -511,7 +515,7 @@ static void
511sclp_vt220_close(struct tty_struct *tty, struct file *filp) 515sclp_vt220_close(struct tty_struct *tty, struct file *filp)
512{ 516{
513 if (tty->count == 1) { 517 if (tty->count == 1) {
514 sclp_vt220_tty = NULL; 518 tty_port_tty_set(&sclp_vt220_port, NULL);
515 kfree(tty->driver_data); 519 kfree(tty->driver_data);
516 tty->driver_data = NULL; 520 tty->driver_data = NULL;
517 } 521 }
@@ -635,9 +639,9 @@ static int __init __sclp_vt220_init(int num_pages)
635 INIT_LIST_HEAD(&sclp_vt220_empty); 639 INIT_LIST_HEAD(&sclp_vt220_empty);
636 INIT_LIST_HEAD(&sclp_vt220_outqueue); 640 INIT_LIST_HEAD(&sclp_vt220_outqueue);
637 init_timer(&sclp_vt220_timer); 641 init_timer(&sclp_vt220_timer);
642 tty_port_init(&sclp_vt220_port);
638 sclp_vt220_current_request = NULL; 643 sclp_vt220_current_request = NULL;
639 sclp_vt220_buffered_chars = 0; 644 sclp_vt220_buffered_chars = 0;
640 sclp_vt220_tty = NULL;
641 sclp_vt220_flush_later = 0; 645 sclp_vt220_flush_later = 0;
642 646
643 /* Allocate pages for output buffering */ 647 /* Allocate pages for output buffering */