Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / s390 / char / con3215.c
index 9c72ffb..606f6ad 100644 (file)
 #include <linux/types.h>
 #include <linux/kdev_t.h>
 #include <linux/tty.h>
+#include <linux/tty_flip.h>
 #include <linux/vt_kern.h>
 #include <linux/init.h>
 #include <linux/console.h>
 #include <linux/interrupt.h>
+#include <linux/err.h>
 
 #include <linux/slab.h>
 #include <linux/bootmem.h>
@@ -102,7 +104,7 @@ struct raw3215_info {
 /* array of 3215 devices structures */
 static struct raw3215_info *raw3215[NR_3215];
 /* spinlock to protect the raw3215 array */
-static spinlock_t raw3215_device_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(raw3215_device_lock);
 /* list of free request structures */
 static struct raw3215_req *raw3215_freelist;
 /* spinlock to protect free list */
@@ -432,8 +434,6 @@ raw3215_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
                                if (count > slen)
                                        count = slen;
                        } else
-                       if (count >= TTY_FLIPBUF_SIZE - tty->flip.count)
-                               count = TTY_FLIPBUF_SIZE - tty->flip.count - 1;
                        EBCASC(raw->inbuf, count);
                        cchar = ctrlchar_handle(raw->inbuf, count, tty);
                        switch (cchar & CTRLCHAR_MASK) {
@@ -441,28 +441,20 @@ raw3215_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
                                break;
 
                        case CTRLCHAR_CTRL:
-                               tty->flip.count++;
-                               *tty->flip.flag_buf_ptr++ = TTY_NORMAL;
-                               *tty->flip.char_buf_ptr++ = cchar;
+                               tty_insert_flip_char(tty, cchar, TTY_NORMAL);
                                tty_flip_buffer_push(raw->tty);
                                break;
 
                        case CTRLCHAR_NONE:
-                               memcpy(tty->flip.char_buf_ptr,
-                                      raw->inbuf, count);
                                if (count < 2 ||
-                                   (strncmp(raw->inbuf+count-2, "^n", 2) &&
-                                   strncmp(raw->inbuf+count-2, "\252n", 2)) ) {
-                                       /* don't add the auto \n */
-                                       tty->flip.char_buf_ptr[count] = '\n';
-                                       memset(tty->flip.flag_buf_ptr,
-                                              TTY_NORMAL, count + 1);
+                                   (strncmp(raw->inbuf+count-2, "\252n", 2) &&
+                                    strncmp(raw->inbuf+count-2, "^n", 2)) ) {
+                                       /* add the auto \n */
+                                       raw->inbuf[count] = '\n';
                                        count++;
                                } else
-                                       count-=2;
-                               tty->flip.char_buf_ptr += count;
-                               tty->flip.flag_buf_ptr += count;
-                               tty->flip.count += count;
+                                       count -= 2;
+                               tty_insert_flip_string(tty, raw->inbuf, count);
                                tty_flip_buffer_push(raw->tty);
                                break;
                        }
@@ -727,8 +719,7 @@ raw3215_remove (struct ccw_device *cdev)
        raw = cdev->dev.driver_data;
        if (raw) {
                cdev->dev.driver_data = NULL;
-               if (raw->buffer)
-                       kfree(raw->buffer);
+               kfree(raw->buffer);
                kfree(raw);
        }
 }
@@ -860,8 +851,8 @@ con3215_init(void)
 
        /* Set the console mode for VM */
        if (MACHINE_IS_VM) {
-               cpcmd("TERM CONMODE 3215", NULL, 0);
-               cpcmd("TERM AUTOCR OFF", NULL, 0);
+               cpcmd("TERM CONMODE 3215", NULL, 0, NULL);
+               cpcmd("TERM AUTOCR OFF", NULL, 0, NULL);
        }
 
        /* allocate 3215 request structures */
@@ -874,7 +865,7 @@ con3215_init(void)
        }
 
        cdev = ccw_device_probe_console();
-       if (!cdev)
+       if (IS_ERR(cdev))
                return -ENODEV;
 
        raw3215[0] = raw = (struct raw3215_info *)
@@ -983,35 +974,16 @@ tty3215_write_room(struct tty_struct *tty)
  * String write routine for 3215 ttys
  */
 static int
-tty3215_write(struct tty_struct * tty, int from_user,
+tty3215_write(struct tty_struct * tty,
              const unsigned char *buf, int count)
 {
        struct raw3215_info *raw;
-       int length, ret;
 
        if (!tty)
                return 0;
        raw = (struct raw3215_info *) tty->driver_data;
-       if (!from_user) {
-               raw3215_write(raw, buf, count);
-               return count;
-       }
-       ret = 0;
-       while (count > 0) {
-               length = count < 80 ? count : 80;
-               length -= copy_from_user(raw->ubuffer,
-                               (const unsigned char __user *)buf, length);
-               if (length == 0) {
-                       if (!ret)
-                               ret = -EFAULT;
-                       break;
-               }
-               raw3215_write(raw, raw->ubuffer, count);
-               buf += length;
-               count -= length;
-               ret += length;
-       }
-       return ret;
+       raw3215_write(raw, buf, count);
+       return count;
 }
 
 /*