Module Name: src
Committed By: riastradh
Date: Wed Feb 12 15:59:30 UTC 2020
Modified Files:
src/sys/dev/usb: usb.c usbdi.h
Log Message:
Teach usb_rem_task to return whether removed from queue or not.
To generate a diff of this commit:
cvs rdiff -u -r1.180 -r1.181 src/sys/dev/usb/usb.c
cvs rdiff -u -r1.98 -r1.99 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.180 src/sys/dev/usb/usb.c:1.181
--- src/sys/dev/usb/usb.c:1.180 Wed Aug 21 10:48:37 2019
+++ src/sys/dev/usb/usb.c Wed Feb 12 15:59:30 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: usb.c,v 1.180 2019/08/21 10:48:37 mrg Exp $ */
+/* $NetBSD: usb.c,v 1.181 2020/02/12 15:59:30 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.180 2019/08/21 10:48:37 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.181 2020/02/12 15:59:30 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -431,14 +431,16 @@ usb_add_task(struct usbd_device *dev, st
/*
* usb_rem_task(dev, task)
*
- * If task is queued to run, remove it from the queue.
+ * If task is queued to run, remove it from the queue. Return
+ * true if it successfully removed the task from the queue, false
+ * if not.
*
* Caller is _not_ guaranteed that the task is not running when
* this is done.
*
* Never sleeps.
*/
-void
+bool
usb_rem_task(struct usbd_device *dev, struct usb_task *task)
{
unsigned queue;
@@ -452,10 +454,12 @@ usb_rem_task(struct usbd_device *dev, st
TAILQ_REMOVE(&taskq->tasks, task, next);
task->queue = USB_NUM_TASKQS;
mutex_exit(&taskq->lock);
- break;
+ return true; /* removed from the queue */
}
mutex_exit(&taskq->lock);
}
+
+ return false; /* was not removed from the queue */
}
/*
Index: src/sys/dev/usb/usbdi.h
diff -u src/sys/dev/usb/usbdi.h:1.98 src/sys/dev/usb/usbdi.h:1.99
--- src/sys/dev/usb/usbdi.h:1.98 Sat Feb 8 07:38:17 2020
+++ src/sys/dev/usb/usbdi.h Wed Feb 12 15:59:30 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.h,v 1.98 2020/02/08 07:38:17 maxv Exp $ */
+/* $NetBSD: usbdi.h,v 1.99 2020/02/12 15:59:30 riastradh Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $ */
/*
@@ -222,7 +222,7 @@ struct usb_task {
#define USB_TASKQ_MPSAFE 0x80
void usb_add_task(struct usbd_device *, struct usb_task *, int);
-void usb_rem_task(struct usbd_device *, struct usb_task *);
+bool usb_rem_task(struct usbd_device *, struct usb_task *);
bool usb_rem_task_wait(struct usbd_device *, struct usb_task *, int,
kmutex_t *);
#define usb_init_task(t, f, a, fl) ((t)->fun = (f), (t)->arg = (a), (t)->queue = USB_NUM_TASKQS, (t)->flags = (fl))