aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-s390/semaphore.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-s390/semaphore.h')
-rw-r--r--include/asm-s390/semaphore.h19
1 files changed, 10 insertions, 9 deletions
diff --git a/include/asm-s390/semaphore.h b/include/asm-s390/semaphore.h
index 702cf436698c..dbce058aefa9 100644
--- a/include/asm-s390/semaphore.h
+++ b/include/asm-s390/semaphore.h
@@ -37,7 +37,8 @@ struct semaphore {
37 37
38static inline void sema_init (struct semaphore *sem, int val) 38static inline void sema_init (struct semaphore *sem, int val)
39{ 39{
40 *sem = (struct semaphore) __SEMAPHORE_INITIALIZER((*sem),val); 40 atomic_set(&sem->count, val);
41 init_waitqueue_head(&sem->wait);
41} 42}
42 43
43static inline void init_MUTEX (struct semaphore *sem) 44static inline void init_MUTEX (struct semaphore *sem)
@@ -84,17 +85,17 @@ static inline int down_trylock(struct semaphore * sem)
84 * sem->count.counter = --new_val; 85 * sem->count.counter = --new_val;
85 * In the ppc code this is called atomic_dec_if_positive. 86 * In the ppc code this is called atomic_dec_if_positive.
86 */ 87 */
87 __asm__ __volatile__ ( 88 asm volatile(
88 " l %0,0(%3)\n" 89 " l %0,0(%3)\n"
89 "0: ltr %1,%0\n" 90 "0: ltr %1,%0\n"
90 " jle 1f\n" 91 " jle 1f\n"
91 " ahi %1,-1\n" 92 " ahi %1,-1\n"
92 " cs %0,%1,0(%3)\n" 93 " cs %0,%1,0(%3)\n"
93 " jl 0b\n" 94 " jl 0b\n"
94 "1:" 95 "1:"
95 : "=&d" (old_val), "=&d" (new_val), "=m" (sem->count.counter) 96 : "=&d" (old_val), "=&d" (new_val), "=m" (sem->count.counter)
96 : "a" (&sem->count.counter), "m" (sem->count.counter) 97 : "a" (&sem->count.counter), "m" (sem->count.counter)
97 : "cc", "memory" ); 98 : "cc", "memory");
98 return old_val <= 0; 99 return old_val <= 0;
99} 100}
100 101