svn commit: r186091 - head/sys/dev/usb

Andrew Thompson thompsa at FreeBSD.org
Sun Dec 14 20:26:32 UTC 2008


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) {


More information about the svn-src-all mailing list