This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / drivers / tc / zs.c
index a8c4d11..c5befc9 100644 (file)
@@ -55,7 +55,6 @@
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
-#include <linux/bitops.h>
 #ifdef CONFIG_SERIAL_CONSOLE
 #include <linux/console.h>
 #endif
@@ -64,6 +63,7 @@
 #include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <asm/system.h>
+#include <asm/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/wbflush.h>
 #include <asm/bootinfo.h>
@@ -927,7 +927,7 @@ static void rs_flush_chars(struct tty_struct *tty)
        restore_flags(flags);
 }
 
-static int rs_write(struct tty_struct * tty,
+static int rs_write(struct tty_struct * tty, int from_user,
                    const unsigned char *buf, int count)
 {
        int     c, total = 0;
@@ -948,7 +948,15 @@ static int rs_write(struct tty_struct * tty,
                if (c <= 0)
                        break;
 
-               memcpy(info->xmit_buf + info->xmit_head, buf, c);
+               if (from_user) {
+                       down(&tmp_buf_sem);
+                       copy_from_user(tmp_buf, buf, c);
+                       c = min_t(int, c, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
+                                             SERIAL_XMIT_SIZE - info->xmit_head));
+                       memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c);
+                       up(&tmp_buf_sem);
+               } else
+                       memcpy(info->xmit_buf + info->xmit_head, buf, c);
                info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
                info->xmit_cnt += c;
                restore_flags(flags);