Teach usb_rem_task to return whether removed from queue or not.

This commit is contained in:
riastradh 2020-02-12 15:59:30 +00:00
parent f006c3623b
commit 611f3a357f
2 changed files with 11 additions and 7 deletions

View File

@ -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, struct usb_task *task, int queue)
/*
* 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, struct usb_task *task)
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 */
}
/*

View File

@ -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))