From b262697660f9ef734d3356b3d0123c6cc1ed0b3b Mon Sep 17 00:00:00 2001 From: Alfred Perlstein Date: Mon, 8 Jan 2007 23:21:06 +0000 Subject: [PATCH] Add the following functions to abstract away the creation of task threads for usb. I hope that this will eventually be used for generic devices that need full fledged blocking threads for event processing. Create a taskqueue: void usb_ether_task_init(device_t, int, struct usb_taskqueue *); Enqueue a task: void usb_ether_task_enqueue(struct usb_taskqueue *, struct task *); Wait for all tasks queued to complete: void usb_ether_task_drain(struct usb_taskqueue *, struct task *); Destroy the taskqueue: void usb_ether_task_destroy(struct usb_taskqueue *); --- sys/dev/usb/usb_ethersubr.c | 30 ++++++++++++++++++++++++++++++ sys/dev/usb/usb_ethersubr.h | 9 +++++++++ 2 files changed, 39 insertions(+) diff --git a/sys/dev/usb/usb_ethersubr.c b/sys/dev/usb/usb_ethersubr.c index ef43cdbc8a22..2cb5fa6c892b 100644 --- a/sys/dev/usb/usb_ethersubr.c +++ b/sys/dev/usb/usb_ethersubr.c @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -246,3 +247,32 @@ usb_ether_tx_list_free(struct ue_cdata *cd) } } } + +void +usb_ether_task_init(device_t dev, int flags, struct usb_taskqueue *tq) +{ + + /* nothing for now. */ +} + +void +usb_ether_task_enqueue(struct usb_taskqueue *tq, struct task *task) +{ + + taskqueue_enqueue(taskqueue_thread, task); +} + +void +usb_ether_task_drain(struct usb_taskqueue *tq, struct task *task) +{ + + taskqueue_drain(taskqueue_thread, task); +} + +void +usb_ether_task_destroy(struct usb_taskqueue *tq) +{ + + /* nothing for now */ + +} diff --git a/sys/dev/usb/usb_ethersubr.h b/sys/dev/usb/usb_ethersubr.h index cd4acc182895..f3d2e3429b48 100644 --- a/sys/dev/usb/usb_ethersubr.h +++ b/sys/dev/usb/usb_ethersubr.h @@ -79,4 +79,13 @@ int usb_ether_tx_list_init (void *, struct ue_cdata *, void usb_ether_rx_list_free (struct ue_cdata *); void usb_ether_tx_list_free (struct ue_cdata *); +struct usb_taskqueue { + int dummy; +}; + +void usb_ether_task_init(device_t, int, struct usb_taskqueue *); +void usb_ether_task_enqueue(struct usb_taskqueue *, struct task *); +void usb_ether_task_drain(struct usb_taskqueue *, struct task *); +void usb_ether_task_destroy(struct usb_taskqueue *); + #endif /* _USB_ETHERSUBR_H_ */