patch-2.4.5 linux/drivers/char/specialix.c
Next file: linux/drivers/char/synclink.c
Previous file: linux/drivers/char/softdog.c
Back to the patch index
Back to the overall index
- Lines: 77
- Date:
Wed May 16 10:31:27 2001
- Orig file:
v2.4.4/linux/drivers/char/specialix.c
- Orig date:
Wed Dec 6 12:06:18 2000
diff -u --recursive --new-file v2.4.4/linux/drivers/char/specialix.c linux/drivers/char/specialix.c
@@ -1611,33 +1611,56 @@
if (!tty || !port->xmit_buf || !tmp_buf)
return 0;
- if (from_user)
+ save_flags(flags);
+ if (from_user) {
down(&tmp_buf_sem);
+ while (1) {
+ c = MIN(count, MIN(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
+ SERIAL_XMIT_SIZE - port->xmit_head));
+ if (c <= 0)
+ break;
- save_flags(flags);
- while (1) {
- cli();
- c = MIN(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;
+ }
- if (from_user) {
- copy_from_user(tmp_buf, buf, c);
+ cli();
c = MIN(c, MIN(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
- SERIAL_XMIT_SIZE - port->xmit_head));
+ SERIAL_XMIT_SIZE - port->xmit_head));
memcpy(port->xmit_buf + port->xmit_head, tmp_buf, c);
- } else
+ port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
+ port->xmit_cnt += c;
+ restore_flags(flags);
+
+ buf += c;
+ count -= c;
+ total += c;
+ }
+ up(&tmp_buf_sem);
+ } else {
+ while (1) {
+ cli();
+ c = MIN(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);
- buf += c;
- count -= c;
- total += 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;
+ }
}
- if (from_user)
- up(&tmp_buf_sem);
+
+ cli();
if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped &&
!(port->IER & IER_TXRDY)) {
port->IER |= IER_TXRDY;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)