X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fchar%2Friscom8.c;h=55a3a0188eda09084f5e1056451162f7d8f85fc5;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=a35ea03a3227777156776e98ea3138e7fec4d43a;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c index a35ea03a3..55a3a0188 100644 --- a/drivers/char/riscom8.c +++ b/drivers/char/riscom8.c @@ -45,6 +45,7 @@ #include #include #include +#include #include @@ -1114,8 +1115,7 @@ static void rc_close(struct tty_struct * tty, struct file * filp) */ timeout = jiffies+HZ; while(port->IER & IER_TXEMPTY) { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(port->timeout); + msleep_interruptible(jiffies_to_msecs(port->timeout)); if (time_after(jiffies, timeout)) break; } @@ -1130,8 +1130,7 @@ static void rc_close(struct tty_struct * tty, struct file * filp) port->tty = NULL; if (port->blocked_open) { if (port->close_delay) { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(port->close_delay); + msleep_interruptible(jiffies_to_msecs(port->close_delay)); } wake_up_interruptible(&port->open_wait); } @@ -1140,7 +1139,7 @@ static void rc_close(struct tty_struct * tty, struct file * filp) out: restore_flags(flags); } -static int rc_write(struct tty_struct * tty, int from_user, +static int rc_write(struct tty_struct * tty, const unsigned char *buf, int count) { struct riscom_port *port = (struct riscom_port *)tty->driver_data; @@ -1157,54 +1156,23 @@ static int rc_write(struct tty_struct * tty, int from_user, return 0; save_flags(flags); - if (from_user) { - down(&tmp_buf_sem); - while (1) { - cli(); - c = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1, - SERIAL_XMIT_SIZE - port->xmit_head)); - if (c <= 0) - break; - - c -= copy_from_user(tmp_buf, buf, c); - if (!c) { - if (!total) - total = -EFAULT; - break; - } - - cli(); - c = min_t(int, c, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1, - SERIAL_XMIT_SIZE - port->xmit_head)); - memcpy(port->xmit_buf + port->xmit_head, tmp_buf, c); - port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1); - port->xmit_cnt += c; + while (1) { + cli(); + c = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1, + SERIAL_XMIT_SIZE - port->xmit_head)); + if (c <= 0) { restore_flags(flags); - - buf += c; - count -= c; - total += c; + break; } - up(&tmp_buf_sem); - } else { - while (1) { - cli(); - c = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1, - SERIAL_XMIT_SIZE - port->xmit_head)); - if (c <= 0) { - restore_flags(flags); - break; - } - memcpy(port->xmit_buf + port->xmit_head, buf, c); - port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1); - port->xmit_cnt += c; - restore_flags(flags); + memcpy(port->xmit_buf + port->xmit_head, buf, c); + port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1); + port->xmit_cnt += c; + restore_flags(flags); - buf += c; - count -= c; - total += c; - } + buf += c; + count -= c; + total += c; } cli();