svn commit: r213881 - user/weongyo/usb/sys/dev/usb

Weongyo Jeong weongyo at FreeBSD.org
Thu Oct 14 22:45:14 UTC 2010


Author: weongyo
Date: Thu Oct 14 22:45:14 2010
New Revision: 213881
URL: http://svn.freebsd.org/changeset/base/213881

Log:
  Adds two ioctl interfaces, UIOCSRTIMEOUT and UIOCGRTIMEOUT to specify
  the read timeout.  While I'm here fixes wrong group ids for other
  interfaces.

Modified:
  user/weongyo/usb/sys/dev/usb/usb_pf.c
  user/weongyo/usb/sys/dev/usb/usb_pf.h

Modified: user/weongyo/usb/sys/dev/usb/usb_pf.c
==============================================================================
--- user/weongyo/usb/sys/dev/usb/usb_pf.c	Thu Oct 14 22:14:55 2010	(r213880)
+++ user/weongyo/usb/sys/dev/usb/usb_pf.c	Thu Oct 14 22:45:14 2010	(r213881)
@@ -1185,6 +1185,34 @@ usbpf_ioctl(struct cdev *dev, u_long cmd
 		error = usbpf_setf(ud, (struct usbpf_program *)addr, cmd);
 		break;
 
+	/*
+	 * Set read timeout.
+	 */
+	case UIOCSRTIMEOUT:
+		{
+			struct timeval *tv = (struct timeval *)addr;
+
+			/*
+			 * Subtract 1 tick from tvtohz() since this isn't
+			 * a one-shot timer.
+			 */
+			if ((error = itimerfix(tv)) == 0)
+				ud->ud_rtout = tvtohz(tv) - 1;
+			break;
+		}
+
+	/*
+	 * Get read timeout.
+	 */
+	case UIOCGRTIMEOUT:
+		{
+			struct timeval *tv = (struct timeval *)addr;
+
+			tv->tv_sec = ud->ud_rtout / hz;
+			tv->tv_usec = (ud->ud_rtout % hz) * tick;
+			break;
+		}
+
 	case UIOCVERSION:
 		{
 			struct usbpf_version *uv = (struct usbpf_version *)addr;

Modified: user/weongyo/usb/sys/dev/usb/usb_pf.h
==============================================================================
--- user/weongyo/usb/sys/dev/usb/usb_pf.h	Thu Oct 14 22:14:55 2010	(r213880)
+++ user/weongyo/usb/sys/dev/usb/usb_pf.h	Thu Oct 14 22:45:14 2010	(r213881)
@@ -260,10 +260,12 @@ struct usbpf_program {
 
 #define	UIOCGBLEN	_IOR('U', 102, u_int)
 #define	UIOCSBLEN	_IOWR('U', 102, u_int)
-#define	UIOCSETF	_IOW('B', 103, struct usbpf_program)
+#define	UIOCSETF	_IOW('U', 103, struct usbpf_program)
 #define	UIOCSETIF	_IOW('U', 108, struct usbpf_ifreq)
+#define	UIOCSRTIMEOUT	_IOW('U', 109, struct timeval)
+#define	UIOCGRTIMEOUT	_IOR('U', 110, struct timeval)
 #define	UIOCVERSION	_IOR('U', 113, struct usbpf_version)
-#define	UIOCSETWF	_IOW('B', 123, struct usbpf_program)
+#define	UIOCSETWF	_IOW('U', 123, struct usbpf_program)
 
 #define	USBPF_XFERTAP_SUBMIT	0
 #define	USBPF_XFERTAP_DONE	1


More information about the svn-src-user mailing list