From e5d614282345edc8b0debadebd8f5e7da6ed7552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= <rene.kijewski@fu-berlin.de> Date: Fri, 18 Jul 2014 13:44:11 +0200 Subject: [PATCH] core: simplify mutex signatures --- core/include/mutex.h | 18 +++++++----------- core/mutex.c | 8 ++------ 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/core/include/mutex.h b/core/include/mutex.h index e230ddd4ee..0cdff269d3 100644 --- a/core/include/mutex.h +++ b/core/include/mutex.h @@ -50,7 +50,7 @@ typedef struct mutex_t { * * @return Always returns 1, always succeeds. */ -int mutex_init(struct mutex_t *mutex); +int mutex_init(mutex_t *mutex); /** @@ -62,32 +62,28 @@ int mutex_init(struct mutex_t *mutex); * @return 1 if mutex was unlocked, now it is locked. * @return 0 if the mutex was locked. */ -int mutex_trylock(struct mutex_t *mutex); +int mutex_trylock(mutex_t *mutex); /** - * @brief Tries to get a mutex, blocking. + * @brief Locks a mutex, blocking. * - * @param[in] mutex Mutex object to lock. Has to be initialized first. Must not - * be NULL. - * - * @return 1 getting the mutex was successful - * @return <1 there was an error. + * @param[in] mutex Mutex object to lock. Has to be initialized first. Must not be NULL. */ -int mutex_lock(struct mutex_t *mutex); +void mutex_lock(mutex_t *mutex); /** * @brief Unlocks the mutex. * * @param[in] mutex Mutex object to unlock, must not be NULL. */ -void mutex_unlock(struct mutex_t *mutex); +void mutex_unlock(mutex_t *mutex); /** * @brief Unlocks the mutex and sends the current thread to sleep * * @param[in] mutex Mutex object to unlock, must not be NULL. */ -void mutex_unlock_and_sleep(struct mutex_t *mutex); +void mutex_unlock_and_sleep(mutex_t *mutex); #endif /* __MUTEX_H_ */ /** @} */ diff --git a/core/mutex.c b/core/mutex.c index ea60f76ee5..180b3416bf 100644 --- a/core/mutex.c +++ b/core/mutex.c @@ -35,15 +35,13 @@ static void mutex_wait(struct mutex_t *mutex); -int mutex_init(struct mutex_t *mutex) +void mutex_init(struct mutex_t *mutex) { mutex->val = 0; mutex->queue.priority = 0; mutex->queue.data = 0; mutex->queue.next = NULL; - - return 1; } int mutex_trylock(struct mutex_t *mutex) @@ -52,7 +50,7 @@ int mutex_trylock(struct mutex_t *mutex) return (atomic_set_return(&mutex->val, 1) == 0); } -int mutex_lock(struct mutex_t *mutex) +void mutex_lock(struct mutex_t *mutex) { DEBUG("%s: trying to get mutex. val: %u\n", sched_active_thread->name, mutex->val); @@ -60,8 +58,6 @@ int mutex_lock(struct mutex_t *mutex) /* mutex was locked. */ mutex_wait(mutex); } - - return 1; } static void mutex_wait(struct mutex_t *mutex) -- GitLab