PERFORCE change 108551 for review
Warner Losh
imp at FreeBSD.org
Fri Oct 27 06:58:08 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=108551
Change 108551 by imp at imp_lighthouse on 2006/10/27 06:57:28
read side lower half.
Affected files ...
.. //depot/projects/arm/src/sys/arm/at91/at91_ssc.c#17 edit
Differences ...
==== //depot/projects/arm/src/sys/arm/at91/at91_ssc.c#17 (text+ko) ====
@@ -373,7 +373,42 @@
static int
at91_ssc_read(struct cdev *dev, struct uio *uio, int flag)
{
- return EIO;
+ struct at91_ssc_softc *sc;
+ int err, ret, len;
+
+ sc = CDEV2SOFTC(dev);
+ // must read a multiple of 4 bytes
+ if ((uio->uio_resid & 0x3) != 0)
+ return (EINVAL);
+ err = 0;
+ ret = 0;
+ while (uio->uio_resid) {
+ // If there's no buffered data, but we've already copied
+ // some data, then go ahead and return what we have now.
+ if (sc->rd_end == sc->rd_buf && ret != 0)
+ break;
+ err = msleep(&sc->rxdone, &sc->sc_mtx, PCATCH | PZERO,
+ "sscrd", 0);
+ if (err != 0)
+ break;
+ if (sc->rd_end == sc->rd_buf)
+ continue;
+ len = MIN(sc->rd_end - sc->rd_buf, uio->uio_resid);
+ err = uiomove(sc->rd_buf, len, uio);
+ if (err != 0)
+ break;
+ // If we read the whole thing, no datacopy is needed,
+ // otherwise we move the data down.
+ ret += len;
+ if (len == sc->rd_end - sc->rd_buf)
+ sc->rd_end = sc->rd_buf;
+ else {
+ bcopy(sc->rd_buf + len, sc->rd_buf,
+ sc->rd_end - sc->rd_buf - len);
+ sc->rd_end -= len;
+ }
+ }
+ return (err);
}
static int
More information about the p4-projects
mailing list