ALSA: usb-audio: add support for Akai MPD16
[safe/jmp/linux-2.6] / ipc / sem.c
index 7eb6f04..dbef95b 100644 (file)
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -474,6 +474,17 @@ again:
                q = (struct sem_queue *)((char *)walk - offset);
                walk = walk->next;
 
+               /* If we are scanning the single sop, per-semaphore list of
+                * one semaphore and that semaphore is 0, then it is not
+                * necessary to scan the "alter" entries: simple increments
+                * that affect only one entry succeed immediately and cannot
+                * be in the  per semaphore pending queue, and decrements
+                * cannot be successful if the value is already 0.
+                */
+               if (semnum != -1 && sma->sem_base[semnum].semval == 0 &&
+                               q->alter)
+                       break;
+
                error = try_atomic_semop(sma, q->sops, q->nsops,
                                         q->undo, q->pid);
 
@@ -613,7 +624,7 @@ static unsigned long copy_semid_to_user(void __user *buf, struct semid64_ds *in,
 static int semctl_nolock(struct ipc_namespace *ns, int semid,
                         int cmd, int version, union semun arg)
 {
-       int err = -EINVAL;
+       int err;
        struct sem_array *sma;
 
        switch(cmd) {
@@ -690,7 +701,6 @@ static int semctl_nolock(struct ipc_namespace *ns, int semid,
        default:
                return -EINVAL;
        }
-       return err;
 out_unlock:
        sem_unlock(sma);
        return err;