aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rwsem.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rwsem.c')
-rw-r--r--lib/rwsem.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/rwsem.c b/lib/rwsem.c
index 318d435dcebb..f236d7cd5cf3 100644
--- a/lib/rwsem.c
+++ b/lib/rwsem.c
@@ -171,8 +171,9 @@ __rwsem_do_wake(struct rw_semaphore *sem, int wake_type)
171 */ 171 */
172static struct rw_semaphore __sched * 172static struct rw_semaphore __sched *
173rwsem_down_failed_common(struct rw_semaphore *sem, 173rwsem_down_failed_common(struct rw_semaphore *sem,
174 struct rwsem_waiter *waiter, signed long adjustment) 174 unsigned int flags, signed long adjustment)
175{ 175{
176 struct rwsem_waiter waiter;
176 struct task_struct *tsk = current; 177 struct task_struct *tsk = current;
177 signed long count; 178 signed long count;
178 179
@@ -180,12 +181,13 @@ rwsem_down_failed_common(struct rw_semaphore *sem,
180 181
181 /* set up my own style of waitqueue */ 182 /* set up my own style of waitqueue */
182 spin_lock_irq(&sem->wait_lock); 183 spin_lock_irq(&sem->wait_lock);
183 waiter->task = tsk; 184 waiter.task = tsk;
185 waiter.flags = flags;
184 get_task_struct(tsk); 186 get_task_struct(tsk);
185 187
186 if (list_empty(&sem->wait_list)) 188 if (list_empty(&sem->wait_list))
187 adjustment += RWSEM_WAITING_BIAS; 189 adjustment += RWSEM_WAITING_BIAS;
188 list_add_tail(&waiter->list, &sem->wait_list); 190 list_add_tail(&waiter.list, &sem->wait_list);
189 191
190 /* we're now waiting on the lock, but no longer actively locking */ 192 /* we're now waiting on the lock, but no longer actively locking */
191 count = rwsem_atomic_update(adjustment, sem); 193 count = rwsem_atomic_update(adjustment, sem);
@@ -206,7 +208,7 @@ rwsem_down_failed_common(struct rw_semaphore *sem,
206 208
207 /* wait to be given the lock */ 209 /* wait to be given the lock */
208 for (;;) { 210 for (;;) {
209 if (!waiter->task) 211 if (!waiter.task)
210 break; 212 break;
211 schedule(); 213 schedule();
212 set_task_state(tsk, TASK_UNINTERRUPTIBLE); 214 set_task_state(tsk, TASK_UNINTERRUPTIBLE);
@@ -223,11 +225,8 @@ rwsem_down_failed_common(struct rw_semaphore *sem,
223asmregparm struct rw_semaphore __sched * 225asmregparm struct rw_semaphore __sched *
224rwsem_down_read_failed(struct rw_semaphore *sem) 226rwsem_down_read_failed(struct rw_semaphore *sem)
225{ 227{
226 struct rwsem_waiter waiter; 228 return rwsem_down_failed_common(sem, RWSEM_WAITING_FOR_READ,
227 229 -RWSEM_ACTIVE_READ_BIAS);
228 waiter.flags = RWSEM_WAITING_FOR_READ;
229 rwsem_down_failed_common(sem, &waiter, -RWSEM_ACTIVE_READ_BIAS);
230 return sem;
231} 230}
232 231
233/* 232/*
@@ -236,12 +235,8 @@ rwsem_down_read_failed(struct rw_semaphore *sem)
236asmregparm struct rw_semaphore __sched * 235asmregparm struct rw_semaphore __sched *
237rwsem_down_write_failed(struct rw_semaphore *sem) 236rwsem_down_write_failed(struct rw_semaphore *sem)
238{ 237{
239 struct rwsem_waiter waiter; 238 return rwsem_down_failed_common(sem, RWSEM_WAITING_FOR_WRITE,
240 239 -RWSEM_ACTIVE_WRITE_BIAS);
241 waiter.flags = RWSEM_WAITING_FOR_WRITE;
242 rwsem_down_failed_common(sem, &waiter, -RWSEM_ACTIVE_WRITE_BIAS);
243
244 return sem;
245} 240}
246 241
247/* 242/*