Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 4953
b: refs/heads/master
c: 4e8fd22
h: refs/heads/master
i:
  4951: 0fcc978
v: v3
  • Loading branch information
Russell King authored and Russell King committed Jul 24, 2005
1 parent febd85a commit b5e0b75
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2c2a68b84752cb1090fd2456e8b83e5bcc0e73c4
refs/heads/master: 4e8fd22bd421d7aa279bcb76189505a1f96bb7bf
4 changes: 2 additions & 2 deletions trunk/include/asm-arm/locks.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
" strex ip, lr, [%0]\n" \
" teq ip, #0\n" \
" bne 1b\n" \
" teq lr, #0\n" \
" cmp lr, #0\n" \
" movle ip, %0\n" \
" blle " #wake \
: \
Expand Down Expand Up @@ -100,7 +100,7 @@
__asm__ __volatile__( \
"@ up_op_read\n" \
"1: ldrex lr, [%0]\n" \
" add lr, lr, %1\n" \
" adds lr, lr, %1\n" \
" strex ip, lr, [%0]\n" \
" teq ip, #0\n" \
" bne 1b\n" \
Expand Down
35 changes: 19 additions & 16 deletions trunk/include/asm-arm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ typedef struct {
} rwlock_t;

#define RW_LOCK_UNLOCKED (rwlock_t) { 0 }
#define rwlock_init(x) do { *(x) + RW_LOCK_UNLOCKED; } while (0)
#define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while (0)
#define rwlock_is_locked(x) (*((volatile unsigned int *)(x)) != 0)

/*
* Write locks are easy - we just set bit 31. When unlocking, we can
Expand All @@ -100,6 +101,21 @@ static inline void _raw_write_lock(rwlock_t *rw)
: "cc", "memory");
}

static inline int _raw_write_trylock(rwlock_t *rw)
{
unsigned long tmp;

__asm__ __volatile__(
"1: ldrex %0, [%1]\n"
" teq %0, #0\n"
" strexeq %0, %2, [%1]"
: "=&r" (tmp)
: "r" (&rw->lock), "r" (0x80000000)
: "cc", "memory");

return tmp == 0;
}

static inline void _raw_write_unlock(rwlock_t *rw)
{
__asm__ __volatile__(
Expand Down Expand Up @@ -138,6 +154,8 @@ static inline void _raw_read_lock(rwlock_t *rw)

static inline void _raw_read_unlock(rwlock_t *rw)
{
unsigned long tmp, tmp2;

__asm__ __volatile__(
"1: ldrex %0, [%2]\n"
" sub %0, %0, #1\n"
Expand All @@ -151,19 +169,4 @@ static inline void _raw_read_unlock(rwlock_t *rw)

#define _raw_read_trylock(lock) generic_raw_read_trylock(lock)

static inline int _raw_write_trylock(rwlock_t *rw)
{
unsigned long tmp;

__asm__ __volatile__(
"1: ldrex %0, [%1]\n"
" teq %0, #0\n"
" strexeq %0, %2, [%1]"
: "=&r" (tmp)
: "r" (&rw->lock), "r" (0x80000000)
: "cc", "memory");

return tmp == 0;
}

#endif /* __ASM_SPINLOCK_H */

0 comments on commit b5e0b75

Please sign in to comment.