Commit a33fbe40 authored by Thomas Gleixner's avatar Thomas Gleixner

semaphore: Add DEFINE_SEMAPHORE, semaphore_init, semaphore_init_locked

The full cleanup of init_MUTEX[_LOCKED] and DECLARE_MUTEX has not been
done. Some of the users are real semaphores and we should name them as
such instead of confusing everyone with "MUTEX".

Provide the infrastructure to get finally rid of init_MUTEX[_LOCKED]
and DECLARE_MUTEX.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 4be3bd78
...@@ -26,6 +26,9 @@ struct semaphore { ...@@ -26,6 +26,9 @@ struct semaphore {
.wait_list = LIST_HEAD_INIT((name).wait_list), \ .wait_list = LIST_HEAD_INIT((name).wait_list), \
} }
#define DEFINE_SEMAPHORE(name) \
struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
#define DECLARE_MUTEX(name) \ #define DECLARE_MUTEX(name) \
struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
...@@ -36,6 +39,20 @@ static inline void sema_init(struct semaphore *sem, int val) ...@@ -36,6 +39,20 @@ static inline void sema_init(struct semaphore *sem, int val)
lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0); lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0);
} }
static inline void semaphore_init(struct semaphore *sem)
{
sema_init(sem, 1);
}
/*
* semaphore_init_locked() is mostly a sign for a mutex which is
* abused as completion.
*/
static inline void __deprecated semaphore_init_locked(struct semaphore *sem)
{
sema_init(sem, 0);
}
#define init_MUTEX(sem) sema_init(sem, 1) #define init_MUTEX(sem) sema_init(sem, 1)
#define init_MUTEX_LOCKED(sem) sema_init(sem, 0) #define init_MUTEX_LOCKED(sem) sema_init(sem, 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment