[PATCH 40/45] C++: Fix sema_init()

From: David Howells
Date: Sun Apr 01 2018 - 16:44:24 EST


Fix sema_init() to manually initialise the semaphore rather than using
__SEMAPHORE_INITIALIZER() as that doesn't seem to work on C++.

Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
---

include/linux/semaphore.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
index 11c86fbfeb98..364fb4721db5 100644
--- a/include/linux/semaphore.h
+++ b/include/linux/semaphore.h
@@ -32,7 +32,10 @@ struct semaphore {
static inline void sema_init(struct semaphore *sem, int val)
{
static struct lock_class_key __key;
- *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val);
+
+ sem->count = val;
+ INIT_LIST_HEAD(&sem->wait_list);
+ raw_spin_lock_init(&sem->lock);
lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0);
}