Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Dec 2008 12:26:25 -0800
From:      Andrew Thompson <thompsa@FreeBSD.org>
To:        Poul-Henning Kamp <phk@FreeBSD.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r186091 - head/sys/dev/usb
Message-ID:  <20081214202625.GB80520@citylink.fud.org.nz>
In-Reply-To: <200812142003.mBEK3lRR069821@svn.freebsd.org>
References:  <200812142003.mBEK3lRR069821@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Dec 14, 2008 at 08:03:47PM +0000, Poul-Henning Kamp wrote:
> 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);
> +}

How about passing the whole buffer before doing a per-char handoff.

Andrew


Index: ucom.c
===================================================================
--- ucom.c	(revision 186092)
+++ ucom.c	(working copy)
@@ -704,8 +704,15 @@ void
 ucomrxchars(struct ucom_softc *sc, u_char *cp, u_int32_t cc)
 {
 	struct tty *tp = sc->sc_tty;
+	size_t len;
 
 	/* Give characters to tty layer. */
+	if (ttydisc_can_bypass(tp)) {
+		DPRINTFN(7, ("ucomreadcb: buf=%*D\n", cc, cp, ""));
+		len = ttydisc_rint_bypass(tp, cp, cc);
+		cp += len;
+		cc -= len;
+	}
 	while (cc > 0) {
 		DPRINTFN(7, ("ucomreadcb: char = 0x%02x\n", *cp));
 		if (ttydisc_rint(tp, *cp, 0) == -1) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081214202625.GB80520>