#include <linux/keyboard.h>
#include <linux/init.h>
#include <linux/pm.h>
-#include <linux/bitops.h>
-#include <linux/delay.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/system.h>
#include <asm/segment.h>
+#include <asm/bitops.h>
#include <asm/delay.h>
#include <asm/uaccess.h>
extern void console_printn(const char * b, int count);
-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);
unsigned long flags;
if (!info->port)
return;
- set_current_state(TASK_INTERRUPTIBLE);
+ current->state = TASK_INTERRUPTIBLE;
save_flags(flags);
cli();
#ifdef USE_INTS
#endif
if (info->blocked_open) {
if (info->close_delay) {
- msleep_interruptible(jiffies_to_msecs(info->close_delay));
+ current->state = TASK_INTERRUPTIBLE;
+ schedule_timeout(info->close_delay);
}
wake_up_interruptible(&info->open_wait);
}