]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - arch/openrisc/include/asm/futex.h
futex: Remove duplicated code and fix undefined behaviour
[mirror_ubuntu-artful-kernel.git] / arch / openrisc / include / asm / futex.h
index 7780873419771e27cf92b684887790029f5de113..8fed278a24b8afa4cf159363be081597c9ef9bbb 100644 (file)
 })
 
 static inline int
-futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
+arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
 {
-       int op = (encoded_op >> 28) & 7;
-       int cmp = (encoded_op >> 24) & 15;
-       int oparg = (encoded_op << 8) >> 20;
-       int cmparg = (encoded_op << 20) >> 20;
        int oldval = 0, ret;
 
-       if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
-               oparg = 1 << oparg;
-
-       if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
-               return -EFAULT;
-
        pagefault_disable();
 
        switch (op) {
@@ -68,30 +58,9 @@ futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
 
        pagefault_enable();
 
-       if (!ret) {
-               switch (cmp) {
-               case FUTEX_OP_CMP_EQ:
-                       ret = (oldval == cmparg);
-                       break;
-               case FUTEX_OP_CMP_NE:
-                       ret = (oldval != cmparg);
-                       break;
-               case FUTEX_OP_CMP_LT:
-                       ret = (oldval < cmparg);
-                       break;
-               case FUTEX_OP_CMP_GE:
-                       ret = (oldval >= cmparg);
-                       break;
-               case FUTEX_OP_CMP_LE:
-                       ret = (oldval <= cmparg);
-                       break;
-               case FUTEX_OP_CMP_GT:
-                       ret = (oldval > cmparg);
-                       break;
-               default:
-                       ret = -ENOSYS;
-               }
-       }
+       if (!ret)
+               *oval = oldval;
+
        return ret;
 }