1 /* $OpenBSD: irq_work.h,v 1.2 2019/05/11 14:39:13 jsg Exp $ */ 2 /* 3 * Copyright (c) 2015 Mark Kettenis 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 #ifndef _LINUX_IRQ_WORK_H 19 #define _LINUX_IRQ_WORK_H 20 21 #include <sys/param.h> 22 #include <sys/systm.h> 23 #include <sys/task.h> 24 25 struct workqueue_struct; 26 27 extern struct workqueue_struct *system_wq; 28 29 struct irq_work { 30 struct task task; 31 struct taskq *tq; 32 }; 33 34 typedef void (*irq_work_func_t)(struct irq_work *); 35 36 static inline void 37 init_irq_work(struct irq_work *work, irq_work_func_t func) 38 { 39 work->tq = (struct taskq *)system_wq; 40 task_set(&work->task, (void (*)(void *))func, work); 41 } 42 43 static inline bool 44 irq_work_queue(struct irq_work *work) 45 { 46 return task_add(work->tq, &work->task); 47 } 48 49 #endif 50