- if (!from_user) {
- tty3270_do_write(tp, buf, count);
- return count;
- }
- ret = 0;
- while (count > 0) {
- length = count < TTY3270_CHAR_BUF_SIZE ?
- count : TTY3270_CHAR_BUF_SIZE;
- length -= copy_from_user(tp->char_buf, buf, length);
- if (length == 0) {
- if (!ret)
- ret = -EFAULT;
- break;
- }
- tty3270_do_write(tp, tp->char_buf, count);
- buf += length;
- count -= length;
- ret += length;
- }
- return ret;