From owner-svn-src-head@FreeBSD.ORG Sun Dec 14 20:03:47 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 57D7D106564A; Sun, 14 Dec 2008 20:03:47 +0000 (UTC) (envelope-from phk@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 459E48FC13; Sun, 14 Dec 2008 20:03:47 +0000 (UTC) (envelope-from phk@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mBEK3lPW069823; Sun, 14 Dec 2008 20:03:47 GMT (envelope-from phk@svn.freebsd.org) Received: (from phk@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBEK3lRR069821; Sun, 14 Dec 2008 20:03:47 GMT (envelope-from phk@svn.freebsd.org) Message-Id: <200812142003.mBEK3lRR069821@svn.freebsd.org> From: Poul-Henning Kamp Date: Sun, 14 Dec 2008 20:03:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186091 - head/sys/dev/usb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Dec 2008 20:03:47 -0000 Author: phk Date: Sun Dec 14 20:03:46 2008 New Revision: 186091 URL: http://svn.freebsd.org/changeset/base/186091 Log: Move the code that injects received characters into the tty system into a separate public function ucomrxchars(), to avoid requirement of simple metadata prefixing on the USB data stream. Modified: head/sys/dev/usb/ucom.c head/sys/dev/usb/ucomvar.h Modified: head/sys/dev/usb/ucom.c ============================================================================== --- head/sys/dev/usb/ucom.c Sun Dec 14 19:39:53 2008 (r186090) +++ head/sys/dev/usb/ucom.c Sun Dec 14 20:03:46 2008 (r186091) @@ -700,11 +700,30 @@ ucomstartread(struct ucom_softc *sc) return (USBD_NORMAL_COMPLETION); } +void +ucomrxchars(struct ucom_softc *sc, u_char *cp, u_int32_t cc) +{ + struct tty *tp = sc->sc_tty; + + /* Give characters to tty layer. */ + while (cc > 0) { + DPRINTFN(7, ("ucomreadcb: char = 0x%02x\n", *cp)); + if (ttydisc_rint(tp, *cp, 0) == -1) { + /* XXX what should we do? */ + printf("%s: lost %d chars\n", + device_get_nameunit(sc->sc_dev), cc); + break; + } + cc--; + cp++; + } + ttydisc_rint_done(tp); +} + static void ucomreadcb(usbd_xfer_handle xfer, usbd_private_handle p, usbd_status status) { struct ucom_softc *sc = (struct ucom_softc *)p; - struct tty *tp = sc->sc_tty; usbd_status err; u_int32_t cc; u_char *cp; @@ -737,22 +756,8 @@ ucomreadcb(usbd_xfer_handle xfer, usbd_p device_get_nameunit(sc->sc_dev), cc); goto resubmit; } - if (cc < 1) - goto resubmit; - - /* Give characters to tty layer. */ - while (cc > 0) { - DPRINTFN(7, ("ucomreadcb: char = 0x%02x\n", *cp)); - if (ttydisc_rint(tp, *cp, 0) == -1) { - /* XXX what should we do? */ - printf("%s: lost %d chars\n", - device_get_nameunit(sc->sc_dev), cc); - break; - } - cc--; - cp++; - } - ttydisc_rint_done(tp); + if (cc > 0) + ucomrxchars(sc, cp, cc); resubmit: err = ucomstartread(sc); Modified: head/sys/dev/usb/ucomvar.h ============================================================================== --- head/sys/dev/usb/ucomvar.h Sun Dec 14 19:39:53 2008 (r186090) +++ head/sys/dev/usb/ucomvar.h Sun Dec 14 20:03:46 2008 (r186091) @@ -166,3 +166,4 @@ void ucom_attach_tty(struct ucom_softc * int ucom_attach(struct ucom_softc *); int ucom_detach(struct ucom_softc *); void ucom_status_change(struct ucom_softc *); +void ucomrxchars(struct ucom_softc *sc, u_char *cp, u_int32_t cc);