aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-mips/spinlock.h
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2006-08-31 09:16:06 -0400
committerRalf Baechle <ralf@linux-mips.org>2006-09-27 08:37:39 -0400
commit65316fd13ad9d82560edbad0a940d684380f7461 (patch)
tree9b3bf885035525a42143a49952b5eabb45fab65e /include/asm-mips/spinlock.h
parent09f451bfb9fe5ceea763a9ebd6ec73dd05e4faf8 (diff)
[MIPS] Replace generic__raw_read_trylock usage
generic__raw_read_trylock() is a defect generic function actually doing a __raw_read_lock ... Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'include/asm-mips/spinlock.h')
-rw-r--r--include/asm-mips/spinlock.h47
1 files changed, 46 insertions, 1 deletions
diff --git a/include/asm-mips/spinlock.h b/include/asm-mips/spinlock.h
index 669b8e349ff2..4c1a1b53aeaf 100644
--- a/include/asm-mips/spinlock.h
+++ b/include/asm-mips/spinlock.h
@@ -239,7 +239,51 @@ static inline void __raw_write_unlock(raw_rwlock_t *rw)
239 : "memory"); 239 : "memory");
240} 240}
241 241
242#define __raw_read_trylock(lock) generic__raw_read_trylock(lock) 242static inline int __raw_read_trylock(raw_rwlock_t *rw)
243{
244 unsigned int tmp;
245 int ret;
246
247 if (R10000_LLSC_WAR) {
248 __asm__ __volatile__(
249 " .set noreorder # __raw_read_trylock \n"
250 " li %2, 0 \n"
251 "1: ll %1, %3 \n"
252 " bnez %1, 2f \n"
253 " addu %1, 1 \n"
254 " sc %1, %0 \n"
255 " beqzl %1, 1b \n"
256 " .set reorder \n"
257#ifdef CONFIG_SMP
258 " sync \n"
259#endif
260 " li %2, 1 \n"
261 "2: \n"
262 : "=m" (rw->lock), "=&r" (tmp), "=&r" (ret)
263 : "m" (rw->lock)
264 : "memory");
265 } else {
266 __asm__ __volatile__(
267 " .set noreorder # __raw_read_trylock \n"
268 " li %2, 0 \n"
269 "1: ll %1, %3 \n"
270 " bnez %1, 2f \n"
271 " addu %1, 1 \n"
272 " sc %1, %0 \n"
273 " beqz %1, 1b \n"
274 " .set reorder \n"
275#ifdef CONFIG_SMP
276 " sync \n"
277#endif
278 " li %2, 1 \n"
279 "2: \n"
280 : "=m" (rw->lock), "=&r" (tmp), "=&r" (ret)
281 : "m" (rw->lock)
282 : "memory");
283 }
284
285 return ret;
286}
243 287
244static inline int __raw_write_trylock(raw_rwlock_t *rw) 288static inline int __raw_write_trylock(raw_rwlock_t *rw)
245{ 289{
@@ -283,4 +327,5 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw)
283 return ret; 327 return ret;
284} 328}
285 329
330
286#endif /* _ASM_SPINLOCK_H */ 331#endif /* _ASM_SPINLOCK_H */