1 /*
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2019 Western Digital Corporation or its affiliates.
5  *
6  * Authors:
7  *   Anup Patel <anup.patel@wdc.com>
8  */
9 
10 #ifndef __RISCV_LOCKS_H__
11 #define __RISCV_LOCKS_H__
12 
13 typedef struct {
14 	volatile long lock;
15 } spinlock_t;
16 
17 #define __RISCV_SPIN_UNLOCKED 0
18 
19 #define SPIN_LOCK_INIT(_lptr) (_lptr)->lock = __RISCV_SPIN_UNLOCKED
20 
21 #define SPIN_LOCK_INITIALIZER                  \
22 	{                                      \
23 		.lock = __RISCV_SPIN_UNLOCKED, \
24 	}
25 
26 int spin_lock_check(spinlock_t *lock);
27 
28 int spin_trylock(spinlock_t *lock);
29 
30 void spin_lock(spinlock_t *lock);
31 
32 void spin_unlock(spinlock_t *lock);
33 
34 #endif
35