1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-18 10:35:55 +00:00

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.
This commit is contained in:
Poul-Henning Kamp 2008-12-14 20:03:46 +00:00
parent 54ebdd631d
commit da8fce5a73
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=186091
2 changed files with 23 additions and 17 deletions

View File

@ -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_private_handle p, usbd_status status)
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);

View File

@ -166,3 +166,4 @@ void ucom_attach_tty(struct ucom_softc *, char*, int);
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);