浏览代码

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>
Jiri Slaby 13 年之前
父节点
当前提交
092f737799
共有 1 个文件被更改,包括 14 次插入10 次删除
  1. 14 10
      drivers/s390/char/sclp_vt220.c

+ 14 - 10
drivers/s390/char/sclp_vt220.c

@@ -56,8 +56,7 @@ struct sclp_vt220_sccb {
 /* Structures and data needed to register tty driver */
 /* Structures and data needed to register tty driver */
 static struct tty_driver *sclp_vt220_driver;
 static struct tty_driver *sclp_vt220_driver;
 
 
-/* The tty_struct that the kernel associated with us */
-static struct tty_struct *sclp_vt220_tty;
+static struct tty_port sclp_vt220_port;
 
 
 /* Lock to protect internal data from concurrent access */
 /* Lock to protect internal data from concurrent access */
 static spinlock_t sclp_vt220_lock;
 static spinlock_t sclp_vt220_lock;
@@ -116,6 +115,7 @@ static struct sclp_register sclp_vt220_register = {
 static void
 static void
 sclp_vt220_process_queue(struct sclp_vt220_request *request)
 sclp_vt220_process_queue(struct sclp_vt220_request *request)
 {
 {
+	struct tty_struct *tty;
 	unsigned long flags;
 	unsigned long flags;
 	void *page;
 	void *page;
 
 
@@ -141,8 +141,10 @@ sclp_vt220_process_queue(struct sclp_vt220_request *request)
 	if (request == NULL && sclp_vt220_flush_later)
 	if (request == NULL && sclp_vt220_flush_later)
 		sclp_vt220_emit_current();
 		sclp_vt220_emit_current();
 	/* Check if the tty needs a wake up call */
 	/* Check if the tty needs a wake up call */
-	if (sclp_vt220_tty != NULL) {
-		tty_wakeup(sclp_vt220_tty);
+	tty = tty_port_tty_get(&sclp_vt220_port);
+	if (tty) {
+		tty_wakeup(tty);
+		tty_kref_put(tty);
 	}
 	}
 }
 }
 
 
@@ -460,11 +462,12 @@ sclp_vt220_write(struct tty_struct *tty, const unsigned char *buf, int count)
 static void
 static void
 sclp_vt220_receiver_fn(struct evbuf_header *evbuf)
 sclp_vt220_receiver_fn(struct evbuf_header *evbuf)
 {
 {
+	struct tty_struct *tty = tty_port_tty_get(&sclp_vt220_port);
 	char *buffer;
 	char *buffer;
 	unsigned int count;
 	unsigned int count;
 
 
 	/* Ignore input if device is not open */
 	/* Ignore input if device is not open */
-	if (sclp_vt220_tty == NULL)
+	if (tty == NULL)
 		return;
 		return;
 
 
 	buffer = (char *) ((addr_t) evbuf + sizeof(struct evbuf_header));
 	buffer = (char *) ((addr_t) evbuf + sizeof(struct evbuf_header));
@@ -478,10 +481,11 @@ sclp_vt220_receiver_fn(struct evbuf_header *evbuf)
 		/* Send input to line discipline */
 		/* Send input to line discipline */
 		buffer++;
 		buffer++;
 		count--;
 		count--;
-		tty_insert_flip_string(sclp_vt220_tty, buffer, count);
-		tty_flip_buffer_push(sclp_vt220_tty);
+		tty_insert_flip_string(tty, buffer, count);
+		tty_flip_buffer_push(tty);
 		break;
 		break;
 	}
 	}
+	tty_kref_put(tty);
 }
 }
 
 
 /*
 /*
@@ -491,7 +495,7 @@ static int
 sclp_vt220_open(struct tty_struct *tty, struct file *filp)
 sclp_vt220_open(struct tty_struct *tty, struct file *filp)
 {
 {
 	if (tty->count == 1) {
 	if (tty->count == 1) {
-		sclp_vt220_tty = tty;
+		tty_port_tty_set(&sclp_vt220_port, tty);
 		tty->driver_data = kmalloc(SCLP_VT220_BUF_SIZE, GFP_KERNEL);
 		tty->driver_data = kmalloc(SCLP_VT220_BUF_SIZE, GFP_KERNEL);
 		if (tty->driver_data == NULL)
 		if (tty->driver_data == NULL)
 			return -ENOMEM;
 			return -ENOMEM;
@@ -511,7 +515,7 @@ static void
 sclp_vt220_close(struct tty_struct *tty, struct file *filp)
 sclp_vt220_close(struct tty_struct *tty, struct file *filp)
 {
 {
 	if (tty->count == 1) {
 	if (tty->count == 1) {
-		sclp_vt220_tty = NULL;
+		tty_port_tty_set(&sclp_vt220_port, NULL);
 		kfree(tty->driver_data);
 		kfree(tty->driver_data);
 		tty->driver_data = NULL;
 		tty->driver_data = NULL;
 	}
 	}
@@ -635,9 +639,9 @@ static int __init __sclp_vt220_init(int num_pages)
 	INIT_LIST_HEAD(&sclp_vt220_empty);
 	INIT_LIST_HEAD(&sclp_vt220_empty);
 	INIT_LIST_HEAD(&sclp_vt220_outqueue);
 	INIT_LIST_HEAD(&sclp_vt220_outqueue);
 	init_timer(&sclp_vt220_timer);
 	init_timer(&sclp_vt220_timer);
+	tty_port_init(&sclp_vt220_port);
 	sclp_vt220_current_request = NULL;
 	sclp_vt220_current_request = NULL;
 	sclp_vt220_buffered_chars = 0;
 	sclp_vt220_buffered_chars = 0;
-	sclp_vt220_tty = NULL;
 	sclp_vt220_flush_later = 0;
 	sclp_vt220_flush_later = 0;
 
 
 	/* Allocate pages for output buffering */
 	/* Allocate pages for output buffering */