diff options
Diffstat (limited to 'arch/sh/include/asm')
-rw-r--r-- | arch/sh/include/asm/mutex-llsc.h | 21 | ||||
-rw-r--r-- | arch/sh/include/asm/syscall_32.h | 22 | ||||
-rw-r--r-- | arch/sh/include/asm/syscall_64.h | 22 |
3 files changed, 15 insertions, 50 deletions
diff --git a/arch/sh/include/asm/mutex-llsc.h b/arch/sh/include/asm/mutex-llsc.h index ee839ee58ac8..090358a7e1bb 100644 --- a/arch/sh/include/asm/mutex-llsc.h +++ b/arch/sh/include/asm/mutex-llsc.h | |||
@@ -21,38 +21,36 @@ | |||
21 | static inline void | 21 | static inline void |
22 | __mutex_fastpath_lock(atomic_t *count, void (*fail_fn)(atomic_t *)) | 22 | __mutex_fastpath_lock(atomic_t *count, void (*fail_fn)(atomic_t *)) |
23 | { | 23 | { |
24 | int __ex_flag, __res; | 24 | int __done, __res; |
25 | 25 | ||
26 | __asm__ __volatile__ ( | 26 | __asm__ __volatile__ ( |
27 | "movli.l @%2, %0 \n" | 27 | "movli.l @%2, %0 \n" |
28 | "add #-1, %0 \n" | 28 | "add #-1, %0 \n" |
29 | "movco.l %0, @%2 \n" | 29 | "movco.l %0, @%2 \n" |
30 | "movt %1 \n" | 30 | "movt %1 \n" |
31 | : "=&z" (__res), "=&r" (__ex_flag) | 31 | : "=&z" (__res), "=&r" (__done) |
32 | : "r" (&(count)->counter) | 32 | : "r" (&(count)->counter) |
33 | : "t"); | 33 | : "t"); |
34 | 34 | ||
35 | __res |= !__ex_flag; | 35 | if (unlikely(!__done || __res != 0)) |
36 | if (unlikely(__res != 0)) | ||
37 | fail_fn(count); | 36 | fail_fn(count); |
38 | } | 37 | } |
39 | 38 | ||
40 | static inline int | 39 | static inline int |
41 | __mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *)) | 40 | __mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *)) |
42 | { | 41 | { |
43 | int __ex_flag, __res; | 42 | int __done, __res; |
44 | 43 | ||
45 | __asm__ __volatile__ ( | 44 | __asm__ __volatile__ ( |
46 | "movli.l @%2, %0 \n" | 45 | "movli.l @%2, %0 \n" |
47 | "add #-1, %0 \n" | 46 | "add #-1, %0 \n" |
48 | "movco.l %0, @%2 \n" | 47 | "movco.l %0, @%2 \n" |
49 | "movt %1 \n" | 48 | "movt %1 \n" |
50 | : "=&z" (__res), "=&r" (__ex_flag) | 49 | : "=&z" (__res), "=&r" (__done) |
51 | : "r" (&(count)->counter) | 50 | : "r" (&(count)->counter) |
52 | : "t"); | 51 | : "t"); |
53 | 52 | ||
54 | __res |= !__ex_flag; | 53 | if (unlikely(!__done || __res != 0)) |
55 | if (unlikely(__res != 0)) | ||
56 | __res = fail_fn(count); | 54 | __res = fail_fn(count); |
57 | 55 | ||
58 | return __res; | 56 | return __res; |
@@ -61,19 +59,18 @@ __mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *)) | |||
61 | static inline void | 59 | static inline void |
62 | __mutex_fastpath_unlock(atomic_t *count, void (*fail_fn)(atomic_t *)) | 60 | __mutex_fastpath_unlock(atomic_t *count, void (*fail_fn)(atomic_t *)) |
63 | { | 61 | { |
64 | int __ex_flag, __res; | 62 | int __done, __res; |
65 | 63 | ||
66 | __asm__ __volatile__ ( | 64 | __asm__ __volatile__ ( |
67 | "movli.l @%2, %0 \n\t" | 65 | "movli.l @%2, %0 \n\t" |
68 | "add #1, %0 \n\t" | 66 | "add #1, %0 \n\t" |
69 | "movco.l %0, @%2 \n\t" | 67 | "movco.l %0, @%2 \n\t" |
70 | "movt %1 \n\t" | 68 | "movt %1 \n\t" |
71 | : "=&z" (__res), "=&r" (__ex_flag) | 69 | : "=&z" (__res), "=&r" (__done) |
72 | : "r" (&(count)->counter) | 70 | : "r" (&(count)->counter) |
73 | : "t"); | 71 | : "t"); |
74 | 72 | ||
75 | __res |= !__ex_flag; | 73 | if (unlikely(!__done || __res <= 0)) |
76 | if (unlikely(__res <= 0)) | ||
77 | fail_fn(count); | 74 | fail_fn(count); |
78 | } | 75 | } |
79 | 76 | ||
diff --git a/arch/sh/include/asm/syscall_32.h b/arch/sh/include/asm/syscall_32.h index 05a868a71ef5..5bc34681d994 100644 --- a/arch/sh/include/asm/syscall_32.h +++ b/arch/sh/include/asm/syscall_32.h | |||
@@ -21,23 +21,10 @@ static inline void syscall_rollback(struct task_struct *task, | |||
21 | */ | 21 | */ |
22 | } | 22 | } |
23 | 23 | ||
24 | static inline bool syscall_has_error(struct pt_regs *regs) | ||
25 | { | ||
26 | return (regs->sr & 0x1) ? true : false; | ||
27 | } | ||
28 | static inline void syscall_set_error(struct pt_regs *regs) | ||
29 | { | ||
30 | regs->sr |= 0x1; | ||
31 | } | ||
32 | static inline void syscall_clear_error(struct pt_regs *regs) | ||
33 | { | ||
34 | regs->sr &= ~0x1; | ||
35 | } | ||
36 | |||
37 | static inline long syscall_get_error(struct task_struct *task, | 24 | static inline long syscall_get_error(struct task_struct *task, |
38 | struct pt_regs *regs) | 25 | struct pt_regs *regs) |
39 | { | 26 | { |
40 | return syscall_has_error(regs) ? regs->regs[0] : 0; | 27 | return IS_ERR_VALUE(regs->regs[0]) ? regs->regs[0] : 0; |
41 | } | 28 | } |
42 | 29 | ||
43 | static inline long syscall_get_return_value(struct task_struct *task, | 30 | static inline long syscall_get_return_value(struct task_struct *task, |
@@ -50,13 +37,10 @@ static inline void syscall_set_return_value(struct task_struct *task, | |||
50 | struct pt_regs *regs, | 37 | struct pt_regs *regs, |
51 | int error, long val) | 38 | int error, long val) |
52 | { | 39 | { |
53 | if (error) { | 40 | if (error) |
54 | syscall_set_error(regs); | ||
55 | regs->regs[0] = -error; | 41 | regs->regs[0] = -error; |
56 | } else { | 42 | else |
57 | syscall_clear_error(regs); | ||
58 | regs->regs[0] = val; | 43 | regs->regs[0] = val; |
59 | } | ||
60 | } | 44 | } |
61 | 45 | ||
62 | static inline void syscall_get_arguments(struct task_struct *task, | 46 | static inline void syscall_get_arguments(struct task_struct *task, |
diff --git a/arch/sh/include/asm/syscall_64.h b/arch/sh/include/asm/syscall_64.h index e1143b9784d6..c3561ca72bee 100644 --- a/arch/sh/include/asm/syscall_64.h +++ b/arch/sh/include/asm/syscall_64.h | |||
@@ -21,23 +21,10 @@ static inline void syscall_rollback(struct task_struct *task, | |||
21 | */ | 21 | */ |
22 | } | 22 | } |
23 | 23 | ||
24 | static inline bool syscall_has_error(struct pt_regs *regs) | ||
25 | { | ||
26 | return (regs->sr & 0x1) ? true : false; | ||
27 | } | ||
28 | static inline void syscall_set_error(struct pt_regs *regs) | ||
29 | { | ||
30 | regs->sr |= 0x1; | ||
31 | } | ||
32 | static inline void syscall_clear_error(struct pt_regs *regs) | ||
33 | { | ||
34 | regs->sr &= ~0x1; | ||
35 | } | ||
36 | |||
37 | static inline long syscall_get_error(struct task_struct *task, | 24 | static inline long syscall_get_error(struct task_struct *task, |
38 | struct pt_regs *regs) | 25 | struct pt_regs *regs) |
39 | { | 26 | { |
40 | return syscall_has_error(regs) ? regs->regs[9] : 0; | 27 | return IS_ERR_VALUE(regs->regs[9]) ? regs->regs[9] : 0; |
41 | } | 28 | } |
42 | 29 | ||
43 | static inline long syscall_get_return_value(struct task_struct *task, | 30 | static inline long syscall_get_return_value(struct task_struct *task, |
@@ -50,13 +37,10 @@ static inline void syscall_set_return_value(struct task_struct *task, | |||
50 | struct pt_regs *regs, | 37 | struct pt_regs *regs, |
51 | int error, long val) | 38 | int error, long val) |
52 | { | 39 | { |
53 | if (error) { | 40 | if (error) |
54 | syscall_set_error(regs); | ||
55 | regs->regs[9] = -error; | 41 | regs->regs[9] = -error; |
56 | } else { | 42 | else |
57 | syscall_clear_error(regs); | ||
58 | regs->regs[9] = val; | 43 | regs->regs[9] = val; |
59 | } | ||
60 | } | 44 | } |
61 | 45 | ||
62 | static inline void syscall_get_arguments(struct task_struct *task, | 46 | static inline void syscall_get_arguments(struct task_struct *task, |