#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
#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>
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;
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);