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

David Howells
2018-04-01T20:44:20Z

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@redhat.com>
---

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);
}