Lines Matching refs:sem

36 static noinline void __down(struct semaphore *sem);
37 static noinline int __down_interruptible(struct semaphore *sem);
38 static noinline int __down_killable(struct semaphore *sem);
39 static noinline int __down_timeout(struct semaphore *sem, long timeout);
40 static noinline void __up(struct semaphore *sem);
53 void down(struct semaphore *sem) in down() argument
58 raw_spin_lock_irqsave(&sem->lock, flags); in down()
59 if (likely(sem->count > 0)) in down()
60 sem->count--; in down()
62 __down(sem); in down()
63 raw_spin_unlock_irqrestore(&sem->lock, flags); in down()
76 int down_interruptible(struct semaphore *sem) in down_interruptible() argument
82 raw_spin_lock_irqsave(&sem->lock, flags); in down_interruptible()
83 if (likely(sem->count > 0)) in down_interruptible()
84 sem->count--; in down_interruptible()
86 result = __down_interruptible(sem); in down_interruptible()
87 raw_spin_unlock_irqrestore(&sem->lock, flags); in down_interruptible()
103 int down_killable(struct semaphore *sem) in down_killable() argument
109 raw_spin_lock_irqsave(&sem->lock, flags); in down_killable()
110 if (likely(sem->count > 0)) in down_killable()
111 sem->count--; in down_killable()
113 result = __down_killable(sem); in down_killable()
114 raw_spin_unlock_irqrestore(&sem->lock, flags); in down_killable()
133 int down_trylock(struct semaphore *sem) in down_trylock() argument
138 raw_spin_lock_irqsave(&sem->lock, flags); in down_trylock()
139 count = sem->count - 1; in down_trylock()
141 sem->count = count; in down_trylock()
142 raw_spin_unlock_irqrestore(&sem->lock, flags); in down_trylock()
158 int down_timeout(struct semaphore *sem, long timeout) in down_timeout() argument
164 raw_spin_lock_irqsave(&sem->lock, flags); in down_timeout()
165 if (likely(sem->count > 0)) in down_timeout()
166 sem->count--; in down_timeout()
168 result = __down_timeout(sem, timeout); in down_timeout()
169 raw_spin_unlock_irqrestore(&sem->lock, flags); in down_timeout()
182 void up(struct semaphore *sem) in up() argument
186 raw_spin_lock_irqsave(&sem->lock, flags); in up()
187 if (likely(list_empty(&sem->wait_list))) in up()
188 sem->count++; in up()
190 __up(sem); in up()
191 raw_spin_unlock_irqrestore(&sem->lock, flags); in up()
208 static inline int __sched __down_common(struct semaphore *sem, long state, in __down_common() argument
213 list_add_tail(&waiter.list, &sem->wait_list); in __down_common()
223 raw_spin_unlock_irq(&sem->lock); in __down_common()
225 raw_spin_lock_irq(&sem->lock); in __down_common()
239 static noinline void __sched __down(struct semaphore *sem) in __down() argument
241 __down_common(sem, TASK_UNINTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); in __down()
244 static noinline int __sched __down_interruptible(struct semaphore *sem) in __down_interruptible() argument
246 return __down_common(sem, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); in __down_interruptible()
249 static noinline int __sched __down_killable(struct semaphore *sem) in __down_killable() argument
251 return __down_common(sem, TASK_KILLABLE, MAX_SCHEDULE_TIMEOUT); in __down_killable()
254 static noinline int __sched __down_timeout(struct semaphore *sem, long timeout) in __down_timeout() argument
256 return __down_common(sem, TASK_UNINTERRUPTIBLE, timeout); in __down_timeout()
259 static noinline void __sched __up(struct semaphore *sem) in __up() argument
261 struct semaphore_waiter *waiter = list_first_entry(&sem->wait_list, in __up()