xref: /dflybsd-src/sys/dev/drm/include/linux/sched/task.h (revision 3f2dd94a569761201b5b0a18b2f697f97fe1b9dc)
1*3f2dd94aSFrançois Tigeot /*
2*3f2dd94aSFrançois Tigeot  * Copyright (c) 2020 François Tigeot <ftigeot@wolfpond.org>
3*3f2dd94aSFrançois Tigeot  * All rights reserved.
4*3f2dd94aSFrançois Tigeot  *
5*3f2dd94aSFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
6*3f2dd94aSFrançois Tigeot  * modification, are permitted provided that the following conditions
7*3f2dd94aSFrançois Tigeot  * are met:
8*3f2dd94aSFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
9*3f2dd94aSFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
10*3f2dd94aSFrançois Tigeot  *    disclaimer.
11*3f2dd94aSFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
12*3f2dd94aSFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
13*3f2dd94aSFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
14*3f2dd94aSFrançois Tigeot  *
15*3f2dd94aSFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16*3f2dd94aSFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17*3f2dd94aSFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18*3f2dd94aSFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19*3f2dd94aSFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20*3f2dd94aSFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21*3f2dd94aSFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22*3f2dd94aSFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23*3f2dd94aSFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24*3f2dd94aSFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*3f2dd94aSFrançois Tigeot  */
26*3f2dd94aSFrançois Tigeot 
27*3f2dd94aSFrançois Tigeot #ifndef _LINUX_SCHED_TASK_H_
28*3f2dd94aSFrançois Tigeot #define _LINUX_SCHED_TASK_H_
29*3f2dd94aSFrançois Tigeot 
30*3f2dd94aSFrançois Tigeot #include <linux/sched.h>
31*3f2dd94aSFrançois Tigeot 
32*3f2dd94aSFrançois Tigeot static inline void
get_task_struct(struct task_struct * ts)33*3f2dd94aSFrançois Tigeot get_task_struct(struct task_struct *ts)
34*3f2dd94aSFrançois Tigeot {
35*3f2dd94aSFrançois Tigeot 	atomic_inc(&ts->usage_counter);
36*3f2dd94aSFrançois Tigeot }
37*3f2dd94aSFrançois Tigeot 
38*3f2dd94aSFrançois Tigeot static inline void
put_task_struct(struct task_struct * ts)39*3f2dd94aSFrançois Tigeot put_task_struct(struct task_struct *ts)
40*3f2dd94aSFrançois Tigeot {
41*3f2dd94aSFrançois Tigeot 	if (atomic_dec_and_test(&ts->usage_counter))
42*3f2dd94aSFrançois Tigeot 		linux_task_drop(curthread);
43*3f2dd94aSFrançois Tigeot }
44*3f2dd94aSFrançois Tigeot 
45*3f2dd94aSFrançois Tigeot #endif	/* _LINUX_SCHED_TASK_H_ */
46