Lines Matching refs:count
90 atomic_long_set(&sem->count, LDSEM_UNLOCKED); in __init_ldsem()
101 long adjust, count; in __ldsem_wake_readers() local
109 count = atomic_long_add_return(adjust, &sem->count); in __ldsem_wake_readers()
111 if (count > 0) in __ldsem_wake_readers()
113 if (atomic_long_try_cmpxchg(&sem->count, &count, count - adjust)) in __ldsem_wake_readers()
134 long count = atomic_long_add_return(LDSEM_ACTIVE_BIAS, &sem->count); in writer_trylock() local
136 if ((count & LDSEM_ACTIVE_MASK) == LDSEM_ACTIVE_BIAS) in writer_trylock()
138 if (atomic_long_try_cmpxchg(&sem->count, &count, count - LDSEM_ACTIVE_BIAS)) in writer_trylock()
180 down_read_failed(struct ld_semaphore *sem, long count, long timeout) in down_read_failed() argument
194 if (atomic_long_try_cmpxchg(&sem->count, &count, count + adjust)) { in down_read_failed()
195 count += adjust; in down_read_failed()
198 if (count > 0) { in down_read_failed()
211 if ((count & LDSEM_ACTIVE_MASK) == 0) in down_read_failed()
237 atomic_long_add_return(-LDSEM_WAIT_BIAS, &sem->count); in down_read_failed()
253 down_write_failed(struct ld_semaphore *sem, long count, long timeout) in down_write_failed() argument
268 if (atomic_long_try_cmpxchg(&sem->count, &count, count + adjust)) in down_write_failed()
270 if ((count & LDSEM_ACTIVE_MASK) == LDSEM_ACTIVE_BIAS) { in down_write_failed()
294 atomic_long_add_return(-LDSEM_WAIT_BIAS, &sem->count); in down_write_failed()
311 long count; in __ldsem_down_read_nested() local
315 count = atomic_long_add_return(LDSEM_READ_BIAS, &sem->count); in __ldsem_down_read_nested()
316 if (count <= 0) { in __ldsem_down_read_nested()
318 if (!down_read_failed(sem, count, timeout)) { in __ldsem_down_read_nested()
330 long count; in __ldsem_down_write_nested() local
334 count = atomic_long_add_return(LDSEM_WRITE_BIAS, &sem->count); in __ldsem_down_write_nested()
335 if ((count & LDSEM_ACTIVE_MASK) != LDSEM_ACTIVE_BIAS) { in __ldsem_down_write_nested()
337 if (!down_write_failed(sem, count, timeout)) { in __ldsem_down_write_nested()
361 long count = atomic_long_read(&sem->count); in ldsem_down_read_trylock() local
363 while (count >= 0) { in ldsem_down_read_trylock()
364 if (atomic_long_try_cmpxchg(&sem->count, &count, count + LDSEM_READ_BIAS)) { in ldsem_down_read_trylock()
387 long count = atomic_long_read(&sem->count); in ldsem_down_write_trylock() local
389 while ((count & LDSEM_ACTIVE_MASK) == 0) { in ldsem_down_write_trylock()
390 if (atomic_long_try_cmpxchg(&sem->count, &count, count + LDSEM_WRITE_BIAS)) { in ldsem_down_write_trylock()
404 long count; in ldsem_up_read() local
408 count = atomic_long_add_return(-LDSEM_READ_BIAS, &sem->count); in ldsem_up_read()
409 if (count < 0 && (count & LDSEM_ACTIVE_MASK) == 0) in ldsem_up_read()
418 long count; in ldsem_up_write() local
422 count = atomic_long_add_return(-LDSEM_WRITE_BIAS, &sem->count); in ldsem_up_write()
423 if (count < 0) in ldsem_up_write()