X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fs390%2Fchar%2Ftty3270.c;h=9a141776873fc42de018fb59f1cb8a681819a6e5;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=debc2b02c20169f8c6afe76aa55668e07fb027b5;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c index debc2b02c..9a1417768 100644 --- a/drivers/s390/char/tty3270.c +++ b/drivers/s390/char/tty3270.c @@ -124,16 +124,13 @@ void tty3270_set_timer(struct tty3270 *tp, int expires) { if (expires == 0) { - if (timer_pending(&tp->timer)) { + if (timer_pending(&tp->timer) && del_timer(&tp->timer)) raw3270_put_view(&tp->view); - del_timer(&tp->timer); - } return; } - if (timer_pending(&tp->timer)) { - if (mod_timer(&tp->timer, jiffies + expires)) - return; - } + if (timer_pending(&tp->timer) && + 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; @@ -656,18 +653,12 @@ tty3270_activate(struct raw3270_view *view) tp->update_flags = TTY_UPDATE_ALL; tty3270_set_timer(tp, 1); spin_unlock_irqrestore(&tp->view.lock, flags); - start_tty(tp->tty); return 0; } static void tty3270_deactivate(struct raw3270_view *view) { - struct tty3270 *tp; - - tp = (struct tty3270 *) view; - if (tp && tp->tty) - stop_tty(tp->tty); } static int @@ -700,15 +691,15 @@ tty3270_alloc_view(void) struct tty3270 *tp; int pages; - tp = kmalloc(sizeof(struct tty3270),GFP_KERNEL); + tp = kzalloc(sizeof(struct tty3270), GFP_KERNEL); if (!tp) goto out_err; - memset(tp, 0, sizeof(struct tty3270)); tp->freemem_pages = kmalloc(sizeof(void *) * TTY3270_STRING_PAGES, GFP_KERNEL); if (!tp->freemem_pages) goto out_tp; INIT_LIST_HEAD(&tp->freemem); + init_timer(&tp->timer); for (pages = 0; pages < TTY3270_STRING_PAGES; pages++) { tp->freemem_pages[pages] = (void *) __get_free_pages(GFP_KERNEL|GFP_DMA, 0); @@ -718,13 +709,13 @@ tty3270_alloc_view(void) tp->freemem_pages[pages], PAGE_SIZE); } tp->write = raw3270_request_alloc(TTY3270_OUTPUT_BUFFER_SIZE); - if (!tp->write) + if (IS_ERR(tp->write)) goto out_pages; tp->read = raw3270_request_alloc(0); - if (!tp->read) + if (IS_ERR(tp->read)) goto out_write; tp->kreset = raw3270_request_alloc(1); - if (!tp->kreset) + if (IS_ERR(tp->kreset)) goto out_read; tp->kbd = kbd_alloc(); if (!tp->kbd) @@ -775,16 +766,14 @@ tty3270_alloc_screen(struct tty3270 *tp) int lines; size = sizeof(struct tty3270_line) * (tp->view.rows - 2); - tp->screen = kmalloc(size, GFP_KERNEL); + tp->screen = kzalloc(size, GFP_KERNEL); if (!tp->screen) goto out_err; - memset(tp->screen, 0, size); for (lines = 0; lines < tp->view.rows - 2; lines++) { size = sizeof(struct tty3270_cell) * tp->view.cols; - tp->screen[lines].cells = kmalloc(size, GFP_KERNEL); + tp->screen[lines].cells = kzalloc(size, GFP_KERNEL); if (!tp->screen[lines].cells) goto out_screen; - memset(tp->screen[lines].cells, 0, size); } return 0; out_screen: @@ -847,7 +836,8 @@ tty3270_del_views(void) int i; for (i = 0; i < tty3270_max_index; i++) { - tp = (struct tty3270 *) raw3270_find_view(&tty3270_fn, i); + tp = (struct tty3270 *) + raw3270_find_view(&tty3270_fn, i + RAW3270_FIRSTMINOR); if (!IS_ERR(tp)) raw3270_del_view(&tp->view); } @@ -873,7 +863,9 @@ tty3270_open(struct tty_struct *tty, struct file * filp) if (tty->count > 1) return 0; /* Check if the tty3270 is already there. */ - tp = (struct tty3270 *) raw3270_find_view(&tty3270_fn, tty->index); + tp = (struct tty3270 *) + raw3270_find_view(&tty3270_fn, + tty->index + RAW3270_FIRSTMINOR); if (!IS_ERR(tp)) { tty->driver_data = tp; tty->winsize.ws_row = tp->view.rows - 2; @@ -905,7 +897,8 @@ tty3270_open(struct tty_struct *tty, struct file * filp) (void (*)(unsigned long)) tty3270_read_tasklet, (unsigned long) tp->read); - rc = raw3270_add_view(&tp->view, &tty3270_fn, tty->index); + rc = raw3270_add_view(&tp->view, &tty3270_fn, + tty->index + RAW3270_FIRSTMINOR); if (rc) { tty3270_free_view(tp); return rc; @@ -913,8 +906,8 @@ tty3270_open(struct tty_struct *tty, struct file * filp) rc = tty3270_alloc_screen(tp); if (rc) { - raw3270_del_view(&tp->view); raw3270_put_view(&tp->view); + raw3270_del_view(&tp->view); return rc; } @@ -1599,11 +1592,10 @@ 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, int from_user, +tty3270_write(struct tty_struct * tty, const unsigned char *buf, int count) { struct tty3270 *tp; - int length, ret; tp = tty->driver_data; if (!tp) @@ -1612,26 +1604,8 @@ tty3270_write(struct tty_struct * tty, int from_user, tty3270_do_write(tp, tp->char_buf, tp->char_count); tp->char_count = 0; } - 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; + tty3270_do_write(tp, buf, count); + return count; } /* @@ -1801,7 +1775,7 @@ tty3270_init(void) struct tty_driver *driver; int ret; - driver = alloc_tty_driver(256); + driver = alloc_tty_driver(RAW3270_MAXDEVS); if (!driver) return -ENOMEM; @@ -1815,6 +1789,7 @@ tty3270_init(void) driver->driver_name = "ttyTUB"; driver->name = "ttyTUB"; driver->major = IBM_TTY3270_MAJOR; + driver->minor_start = RAW3270_FIRSTMINOR; driver->type = TTY_DRIVER_TYPE_SYSTEM; driver->subtype = SYSTEM_TYPE_TTY; driver->init_termios = tty_std_termios;