Commit 0ea63da2 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

TTY: sclp_tty, 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: default avatarJiri 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: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fe2fc9ca
...@@ -48,7 +48,7 @@ static struct sclp_buffer *sclp_ttybuf; ...@@ -48,7 +48,7 @@ static struct sclp_buffer *sclp_ttybuf;
/* Timer for delayed output of console messages. */ /* Timer for delayed output of console messages. */
static struct timer_list sclp_tty_timer; static struct timer_list sclp_tty_timer;
static struct tty_struct *sclp_tty; static struct tty_port sclp_port;
static unsigned char sclp_tty_chars[SCLP_TTY_BUF_SIZE]; static unsigned char sclp_tty_chars[SCLP_TTY_BUF_SIZE];
static unsigned short int sclp_tty_chars_count; static unsigned short int sclp_tty_chars_count;
...@@ -64,7 +64,7 @@ static int sclp_tty_columns = 80; ...@@ -64,7 +64,7 @@ static int sclp_tty_columns = 80;
static int static int
sclp_tty_open(struct tty_struct *tty, struct file *filp) sclp_tty_open(struct tty_struct *tty, struct file *filp)
{ {
sclp_tty = tty; tty_port_tty_set(&sclp_port, tty);
tty->driver_data = NULL; tty->driver_data = NULL;
tty->low_latency = 0; tty->low_latency = 0;
return 0; return 0;
...@@ -76,7 +76,7 @@ sclp_tty_close(struct tty_struct *tty, struct file *filp) ...@@ -76,7 +76,7 @@ sclp_tty_close(struct tty_struct *tty, struct file *filp)
{ {
if (tty->count > 1) if (tty->count > 1)
return; return;
sclp_tty = NULL; tty_port_tty_set(&sclp_port, NULL);
} }
/* /*
...@@ -108,6 +108,7 @@ sclp_tty_write_room (struct tty_struct *tty) ...@@ -108,6 +108,7 @@ sclp_tty_write_room (struct tty_struct *tty)
static void static void
sclp_ttybuf_callback(struct sclp_buffer *buffer, int rc) sclp_ttybuf_callback(struct sclp_buffer *buffer, int rc)
{ {
struct tty_struct *tty;
unsigned long flags; unsigned long flags;
void *page; void *page;
...@@ -126,8 +127,10 @@ sclp_ttybuf_callback(struct sclp_buffer *buffer, int rc) ...@@ -126,8 +127,10 @@ sclp_ttybuf_callback(struct sclp_buffer *buffer, int rc)
spin_unlock_irqrestore(&sclp_tty_lock, flags); spin_unlock_irqrestore(&sclp_tty_lock, flags);
} while (buffer && sclp_emit_buffer(buffer, sclp_ttybuf_callback)); } while (buffer && sclp_emit_buffer(buffer, sclp_ttybuf_callback));
/* check if the tty needs a wake up call */ /* check if the tty needs a wake up call */
if (sclp_tty != NULL) { tty = tty_port_tty_get(&sclp_port);
tty_wakeup(sclp_tty); if (tty != NULL) {
tty_wakeup(tty);
tty_kref_put(tty);
} }
} }
...@@ -326,21 +329,22 @@ sclp_tty_flush_buffer(struct tty_struct *tty) ...@@ -326,21 +329,22 @@ sclp_tty_flush_buffer(struct tty_struct *tty)
static void static void
sclp_tty_input(unsigned char* buf, unsigned int count) sclp_tty_input(unsigned char* buf, unsigned int count)
{ {
struct tty_struct *tty = tty_port_tty_get(&sclp_port);
unsigned int cchar; unsigned int cchar;
/* /*
* If this tty driver is currently closed * If this tty driver is currently closed
* then throw the received input away. * then throw the received input away.
*/ */
if (sclp_tty == NULL) if (tty == NULL)
return; return;
cchar = ctrlchar_handle(buf, count, sclp_tty); cchar = ctrlchar_handle(buf, count, tty);
switch (cchar & CTRLCHAR_MASK) { switch (cchar & CTRLCHAR_MASK) {
case CTRLCHAR_SYSRQ: case CTRLCHAR_SYSRQ:
break; break;
case CTRLCHAR_CTRL: case CTRLCHAR_CTRL:
tty_insert_flip_char(sclp_tty, cchar, TTY_NORMAL); tty_insert_flip_char(tty, cchar, TTY_NORMAL);
tty_flip_buffer_push(sclp_tty); tty_flip_buffer_push(tty);
break; break;
case CTRLCHAR_NONE: case CTRLCHAR_NONE:
/* send (normal) input to line discipline */ /* send (normal) input to line discipline */
...@@ -348,13 +352,14 @@ sclp_tty_input(unsigned char* buf, unsigned int count) ...@@ -348,13 +352,14 @@ sclp_tty_input(unsigned char* buf, unsigned int count)
(strncmp((const char *) buf + count - 2, "^n", 2) && (strncmp((const char *) buf + count - 2, "^n", 2) &&
strncmp((const char *) buf + count - 2, "\252n", 2))) { strncmp((const char *) buf + count - 2, "\252n", 2))) {
/* add the auto \n */ /* add the auto \n */
tty_insert_flip_string(sclp_tty, buf, count); tty_insert_flip_string(tty, buf, count);
tty_insert_flip_char(sclp_tty, '\n', TTY_NORMAL); tty_insert_flip_char(tty, '\n', TTY_NORMAL);
} else } else
tty_insert_flip_string(sclp_tty, buf, count - 2); tty_insert_flip_string(tty, buf, count - 2);
tty_flip_buffer_push(sclp_tty); tty_flip_buffer_push(tty);
break; break;
} }
tty_kref_put(tty);
} }
/* /*
...@@ -543,7 +548,7 @@ sclp_tty_init(void) ...@@ -543,7 +548,7 @@ sclp_tty_init(void)
sclp_tty_tolower = 1; sclp_tty_tolower = 1;
} }
sclp_tty_chars_count = 0; sclp_tty_chars_count = 0;
sclp_tty = NULL; tty_port_init(&sclp_port);
rc = sclp_register(&sclp_input_event); rc = sclp_register(&sclp_input_event);
if (rc) { if (rc) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment