USB, select/poll for ucom

Shunsuke Akiyama akiyama at jp.FreeBSD.org
Thu Jul 3 08:39:46 PDT 2003


At Wed, 02 Jul 2003 10:29:51 +0300,
Danny Braniss wrote:
> 
> for the record:
> 	I can now confirm that select/poll/FIONREAD do work with the
> usb/ucom/uplcom!
> 
> what seems to be broken is the call to 'tcflush(fd, TCIFLUSH)'
> this works fine with /dev/cuaa0 but not with /dev/ucom0

Humm...
I'd reviewed sys/dev/usb/ucom.c, and found missing things.
Please try attached patch.
-- 
Shunsuke Akiyama
akiyama at jp.FreeBSD.org
akiyama at FreeBSD.org

Index: sys/dev/usb/ucom.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/usb/ucom.c,v
retrieving revision 1.29
diff -u -r1.29 ucom.c
--- sys/dev/usb/ucom.c	9 Mar 2003 11:33:26 -0000	1.29
+++ sys/dev/usb/ucom.c	2 Jul 2003 10:39:28 -0000
@@ -544,6 +544,10 @@
 	int error;
 	int s;
 	int d;
+#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
+	u_long oldcmd;
+	struct termios term;
+#endif
 
 	USB_GET_SC(ucom, UCOMUNIT(dev), sc);
 	tp = sc->sc_tty;
@@ -553,15 +557,28 @@
 
 	DPRINTF(("ucomioctl: cmd = 0x%08lx\n", cmd));
 
+#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
+	term = tp->t_termios;
+	oldcmd = cmd;
+	error = ttsetcompat(tp, &cmd, data, &term);
+	if (error != 0)
+		return (error);
+	if (cmd != oldcmd)
+		data = (caddr_t)&term;
+#endif
+
 	error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
-	if (error >= 0) {
+	if (error != ENOIOCTL) {
 		DPRINTF(("ucomioctl: l_ioctl: error = %d\n", error));
 		return (error);
 	}
 
+	s = spltty();
+
 	error = ttioctl(tp, cmd, data, flag);
 	disc_optim(tp, &tp->t_termios, sc);
-	if (error >= 0) {
+	if (error != ENOIOCTL) {
+		splx(s);
 		DPRINTF(("ucomioctl: ttioctl: error = %d\n", error));
 		return (error);
 	}
@@ -577,8 +594,6 @@
 	error = 0;
 
 	DPRINTF(("ucomioctl: our cmd = 0x%08lx\n", cmd));
-
-	s = spltty();
 
 	switch (cmd) {
 	case TIOCSBRK:


More information about the freebsd-hackers mailing list