OSDN Git Service

drivers: leds: Import Xiaomi changes
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / include / linux / msm_remote_spinlock.h
1 /* Copyright (c) 2009, 2011, 2013-2015 The Linux Foundation.
2  * All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 and
6  * only version 2 as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  */
14
15 /*
16  * Part of this this code is based on the standard ARM spinlock
17  * implementation (asm/spinlock.h) found in the 2.6.29 kernel.
18  */
19
20 #ifndef __ASM__ARCH_QC_REMOTE_SPINLOCK_H
21 #define __ASM__ARCH_QC_REMOTE_SPINLOCK_H
22
23 #include <linux/io.h>
24 #include <linux/types.h>
25
26 #define REMOTE_SPINLOCK_NUM_PID 128
27 #define REMOTE_SPINLOCK_TID_START REMOTE_SPINLOCK_NUM_PID
28
29 /* Remote spinlock definitions. */
30
31 typedef struct {
32         volatile uint32_t lock;
33 } raw_remote_spinlock_t;
34
35 typedef raw_remote_spinlock_t *_remote_spinlock_t;
36
37 #define remote_spinlock_id_t const char *
38
39 #if defined(CONFIG_REMOTE_SPINLOCK_MSM)
40 int _remote_spin_lock_init(remote_spinlock_id_t, _remote_spinlock_t *lock);
41 void _remote_spin_release_all(uint32_t pid);
42 void _remote_spin_lock(_remote_spinlock_t *lock);
43 void _remote_spin_unlock(_remote_spinlock_t *lock);
44 int _remote_spin_trylock(_remote_spinlock_t *lock);
45 int _remote_spin_release(_remote_spinlock_t *lock, uint32_t pid);
46 int _remote_spin_owner(_remote_spinlock_t *lock);
47 void _remote_spin_lock_rlock_id(_remote_spinlock_t *lock, uint32_t tid);
48 void _remote_spin_unlock_rlock(_remote_spinlock_t *lock);
49 int _remote_spin_get_hw_spinlocks_element(_remote_spinlock_t *lock);
50 #else
51 static inline
52 int _remote_spin_lock_init(remote_spinlock_id_t id, _remote_spinlock_t *lock)
53 {
54         return -EINVAL;
55 }
56 static inline void _remote_spin_release_all(uint32_t pid) {}
57 static inline void _remote_spin_lock(_remote_spinlock_t *lock) {}
58 static inline void _remote_spin_unlock(_remote_spinlock_t *lock) {}
59 static inline int _remote_spin_trylock(_remote_spinlock_t *lock)
60 {
61         return -ENODEV;
62 }
63 static inline int _remote_spin_release(_remote_spinlock_t *lock, uint32_t pid)
64 {
65         return -ENODEV;
66 }
67 static inline int _remote_spin_owner(_remote_spinlock_t *lock)
68 {
69         return -ENODEV;
70 }
71 static inline void _remote_spin_lock_rlock_id(_remote_spinlock_t *lock,
72                                               uint32_t tid) {}
73 static inline void _remote_spin_unlock_rlock(_remote_spinlock_t *lock) {}
74 static inline int _remote_spin_get_hw_spinlocks_element(
75                 _remote_spinlock_t *lock)
76 {
77         return -ENODEV;
78 }
79 #endif
80 #endif /* __ASM__ARCH_QC_REMOTE_SPINLOCK_H */