X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fs390%2Fchar%2Ftty3270.c;h=debc2b02c20169f8c6afe76aa55668e07fb027b5;hb=9e1bf581d67d87a1d7fc0ea500729e3a03643a26;hp=555f32b5567d00a05fb0dbb087bbd4b7308bfdc7;hpb=8d40237c730b8be87c1b80a5d96b9c603fefa829;p=linux-2.6.git diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c index 555f32b55..debc2b02c 100644 --- a/drivers/s390/char/tty3270.c +++ b/drivers/s390/char/tty3270.c @@ -124,12 +124,16 @@ void tty3270_set_timer(struct tty3270 *tp, int expires) { if (expires == 0) { - if (del_timer(&tp->timer)) + if (timer_pending(&tp->timer)) { raw3270_put_view(&tp->view); + del_timer(&tp->timer); + } return; } - if (mod_timer(&tp->timer, jiffies + expires)) - return; + if (timer_pending(&tp->timer)) { + if (mod_timer(&tp->timer, jiffies + expires)) + return; + } raw3270_get_view(&tp->view); tp->timer.function = (void (*)(unsigned long)) tty3270_update; tp->timer.data = (unsigned long) tp; @@ -1595,10 +1599,11 @@ tty3270_do_write(struct tty3270 *tp, const unsigned char *buf, int count) * String write routine for 3270 ttys */ static int -tty3270_write(struct tty_struct * tty, +tty3270_write(struct tty_struct * tty, int from_user, const unsigned char *buf, int count) { struct tty3270 *tp; + int length, ret; tp = tty->driver_data; if (!tp) @@ -1607,8 +1612,26 @@ tty3270_write(struct tty_struct * tty, tty3270_do_write(tp, tp->char_buf, tp->char_count); tp->char_count = 0; } - tty3270_do_write(tp, buf, count); - return count; + if (!from_user) { + tty3270_do_write(tp, buf, count); + return count; + } + ret = 0; + while (count > 0) { + length = count < TTY3270_CHAR_BUF_SIZE ? + count : TTY3270_CHAR_BUF_SIZE; + length -= copy_from_user(tp->char_buf, buf, length); + if (length == 0) { + if (!ret) + ret = -EFAULT; + break; + } + tty3270_do_write(tp, tp->char_buf, count); + buf += length; + count -= length; + ret += length; + } + return ret; } /*