From owner-p4-projects@FreeBSD.ORG Fri Oct 27 06:58:08 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id EE7FB16A415; Fri, 27 Oct 2006 06:58:07 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9A48216A412 for ; Fri, 27 Oct 2006 06:58:07 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 57E4D43D60 for ; Fri, 27 Oct 2006 06:58:07 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k9R6w7uw051755 for ; Fri, 27 Oct 2006 06:58:07 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k9R6w7u6051752 for perforce@freebsd.org; Fri, 27 Oct 2006 06:58:07 GMT (envelope-from imp@freebsd.org) Date: Fri, 27 Oct 2006 06:58:07 GMT Message-Id: <200610270658.k9R6w7u6051752@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 108551 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2006 06:58:08 -0000 http://perforce.freebsd.org/chv.cgi?CH=108551 Change 108551 by imp@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