Module Name: src
Committed By: riastradh
Date: Wed Feb 12 15:59:44 UTC 2020
Modified Files:
src/sys/dev/usb: usb.c usbdi.h
Log Message:
New function usb_task_pending for diagnostic assertions.
Usable only for negative diagnostic assertions:
KASSERT(!usb_task_pending(dev, task))
If you can think of a better name for this than !usb_task_pending,
I'm all ears.
To generate a diff of this commit:
cvs rdiff -u -r1.181 -r1.182 src/sys/dev/usb/usb.c
cvs rdiff -u -r1.99 -r1.100 src/sys/dev/usb/usbdi.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/usb/usb.c
diff -u src/sys/dev/usb/usb.c:1.181 src/sys/dev/usb/usb.c:1.182
--- src/sys/dev/usb/usb.c:1.181 Wed Feb 12 15:59:30 2020
+++ src/sys/dev/usb/usb.c Wed Feb 12 15:59:44 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: usb.c,v 1.181 2020/02/12 15:59:30 riastradh Exp $ */
+/* $NetBSD: usb.c,v 1.182 2020/02/12 15:59:44 riastradh Exp $ */
/*
* Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.181 2020/02/12 15:59:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.182 2020/02/12 15:59:44 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -530,6 +530,23 @@ usb_rem_task_wait(struct usbd_device *de
return removed;
}
+/*
+ * usb_task_pending(dev, task)
+ *
+ * True if task is queued, false if not. Note that if task is
+ * already running, it is not considered queued.
+ *
+ * For _negative_ diagnostic assertions only:
+ *
+ * KASSERT(!usb_task_pending(dev, task));
+ */
+bool
+usb_task_pending(struct usbd_device *dev, struct usb_task *task)
+{
+
+ return task->queue != USB_NUM_TASKQS;
+}
+
void
usb_event_thread(void *arg)
{
Index: src/sys/dev/usb/usbdi.h
diff -u src/sys/dev/usb/usbdi.h:1.99 src/sys/dev/usb/usbdi.h:1.100
--- src/sys/dev/usb/usbdi.h:1.99 Wed Feb 12 15:59:30 2020
+++ src/sys/dev/usb/usbdi.h Wed Feb 12 15:59:44 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.h,v 1.99 2020/02/12 15:59:30 riastradh Exp $ */
+/* $NetBSD: usbdi.h,v 1.100 2020/02/12 15:59:44 riastradh Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $ */
/*
@@ -225,6 +225,7 @@ void usb_add_task(struct usbd_device *,
bool usb_rem_task(struct usbd_device *, struct usb_task *);
bool usb_rem_task_wait(struct usbd_device *, struct usb_task *, int,
kmutex_t *);
+bool usb_task_pending(struct usbd_device *, struct usb_task *);
#define usb_init_task(t, f, a, fl) ((t)->fun = (f), (t)->arg = (a), (t)->queue = USB_NUM_TASKQS, (t)->flags = (fl))
struct usb_devno {