-/*
- * If copying direct from user space we need to be able to handle page
- * faults while we are copying. To do this copy as much as we can now
- * into a kernel buffer. From there we copy it into shared memory. The
- * big problem is that we do not want shared memory enabled when we are
- * sleeping (other boards may be serviced while asleep). Something else
- * to note here is the reading of the tail twice. Since the boards
- * shared memory can be on an 8-bit bus then we need to be very careful
- * reading 16 bit quantities - since both the board (slave) and host
- * could be writing and reading at the same time.
- */
- if (from_user) {
- save_flags(flags);
- cli();
- EBRDENABLE(brdp);
- ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr);
- head = (unsigned int) ap->txq.head;
- tail = (unsigned int) ap->txq.tail;
- if (tail != ((unsigned int) ap->txq.tail))
- tail = (unsigned int) ap->txq.tail;
- len = (head >= tail) ? (portp->txsize - (head - tail) - 1) :
- (tail - head - 1);
- count = MIN(len, count);
- EBRDDISABLE(brdp);
- restore_flags(flags);
-
- down(&stli_tmpwritesem);
- if (copy_from_user(stli_tmpwritebuf, chbuf, count))
- return -EFAULT;
- chbuf = &stli_tmpwritebuf[0];
- }
-