1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  *
4  * (C) COPYRIGHT 2012-2013, 2015, 2018, 2020-2021 ARM Limited. All rights reserved.
5  *
6  * This program is free software and is provided to you under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation, and any use by you of this program is subject to the terms
9  * of such GNU license.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you can access it online at
18  * http://www.gnu.org/licenses/gpl-2.0.html.
19  *
20  */
21 
22 #ifndef _KBASE_UTILITY_H
23 #define _KBASE_UTILITY_H
24 
25 #ifndef _KBASE_H_
26 #error "Don't include this file directly, use mali_kbase.h instead"
27 #endif
28 
kbase_timer_setup(struct timer_list *timer, void (*callback)(struct timer_list *timer))29 static inline void kbase_timer_setup(struct timer_list *timer,
30 				     void (*callback)(struct timer_list *timer))
31 {
32 #if KERNEL_VERSION(4, 14, 0) > LINUX_VERSION_CODE
33 	setup_timer(timer, (void (*)(unsigned long)) callback,
34 			(unsigned long) timer);
35 #else
36 	timer_setup(timer, callback, 0);
37 #endif
38 }
39 
40 #ifndef WRITE_ONCE
41 	#ifdef ASSIGN_ONCE
42 		#define WRITE_ONCE(x, val) ASSIGN_ONCE(val, x)
43 	#else
44 		#define WRITE_ONCE(x, val) (ACCESS_ONCE(x) = (val))
45 	#endif
46 #endif
47 
48 #ifndef READ_ONCE
49 	#define READ_ONCE(x) ACCESS_ONCE(x)
50 #endif
51 
52 #endif				/* _KBASE_UTILITY_H */
53