xref: /dragonfly/sys/dev/drm/include/linux/interrupt.h (revision 335b9e93)
1 /*
2  * Copyright (c) 2017-2020 François Tigeot <ftigeot@wolfpond.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice unmodified, this list of conditions, and the following
10  *    disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #ifndef _LINUX_INTERRUPT_H_
28 #define _LINUX_INTERRUPT_H_
29 
30 #include <linux/kernel.h>
31 #include <linux/bitops.h>
32 #include <linux/preempt.h>
33 #include <linux/cpumask.h>
34 #include <linux/irqreturn.h>
35 #include <linux/hardirq.h>
36 #include <linux/irqflags.h>
37 #include <linux/hrtimer.h>
38 #include <linux/kref.h>
39 
40 #include <linux/atomic.h>
41 
42 #define IRQF_SHARED	0x00000080
43 
44 struct tasklet_struct {
45 	unsigned long state;
46 	void (*func)(unsigned long);
47 	unsigned long data;
48 	atomic_t count;
49 };
50 
51 enum {
52 	TASKLET_STATE_SCHED,
53 	TASKLET_STATE_RUN,
54 	TASKLET_IS_DYING
55 };
56 
57 typedef irqreturn_t (*irq_handler_t)(int, void *);
58 
59 int request_irq(unsigned int irq, irq_handler_t handler,
60 		unsigned long flags, const char *name, void *dev);
61 
62 void free_irq(unsigned int irq, void *dev_id);
63 
64 void disable_irq(unsigned int irq);
65 void enable_irq(unsigned int irq);
66 
67 void tasklet_init(struct tasklet_struct *t,
68 		  void (*func)(unsigned long), unsigned long data);
69 void tasklet_schedule(struct tasklet_struct *t);
70 void tasklet_hi_schedule(struct tasklet_struct *t);
71 void tasklet_kill(struct tasklet_struct *t);
72 
73 static inline void
74 tasklet_enable(struct tasklet_struct *t)
75 {
76 	atomic_dec(&t->count);
77 }
78 
79 static inline void
80 tasklet_disable(struct tasklet_struct *t)
81 {
82 	atomic_inc(&t->count);
83 }
84 
85 #endif	/* _LINUX_INTERRUPT_H_ */
86