Skip to content

Commit

Permalink
x86: use immediates instead of RW_LOCK_BIAS_STR
Browse files Browse the repository at this point in the history
Use immediate instead of the RW_LOCK_BIAS_STR.
Makes the code more readable and gets rid of the string constant.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Thomas Gleixner authored and Ingo Molnar committed Jan 30, 2008
1 parent a33fff3 commit 6514f93
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion include/asm-x86/rwlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define _ASM_X86_RWLOCK_H

#define RW_LOCK_BIAS 0x01000000
#define RW_LOCK_BIAS_STR "0x01000000"

/* Actual code is in asm/spinlock.h or in arch/x86/lib/rwlock.S */

Expand Down
8 changes: 4 additions & 4 deletions include/asm-x86/spinlock_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ static inline void __raw_read_lock(raw_rwlock_t *rw)

static inline void __raw_write_lock(raw_rwlock_t *rw)
{
asm volatile(LOCK_PREFIX " subl $" RW_LOCK_BIAS_STR ",(%0)\n\t"
asm volatile(LOCK_PREFIX " subl %1,(%0)\n\t"
"jz 1f\n"
"call __write_lock_failed\n\t"
"1:\n"
::"a" (rw) : "memory");
::"a" (rw), "i" (RW_LOCK_BIAS) : "memory");
}

static inline int __raw_read_trylock(raw_rwlock_t *lock)
Expand Down Expand Up @@ -191,8 +191,8 @@ static inline void __raw_read_unlock(raw_rwlock_t *rw)

static inline void __raw_write_unlock(raw_rwlock_t *rw)
{
asm volatile(LOCK_PREFIX "addl $" RW_LOCK_BIAS_STR ", %0"
: "+m" (rw->lock) : : "memory");
asm volatile(LOCK_PREFIX "addl %1, %0"
: "+m" (rw->lock) : "i" (RW_LOCK_BIAS) : "memory");
}

#define _raw_spin_relax(lock) cpu_relax()
Expand Down
6 changes: 3 additions & 3 deletions include/asm-x86/spinlock_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static inline void __raw_read_lock(raw_rwlock_t *rw)
"jns 1f\n"
"call __read_lock_failed\n\t"
"1:\n"
::"D" (rw), "i" (RW_LOCK_BIAS) : "memory");
::"D" (rw) : "memory");
}

static inline void __raw_write_lock(raw_rwlock_t *rw)
Expand Down Expand Up @@ -167,8 +167,8 @@ static inline void __raw_read_unlock(raw_rwlock_t *rw)

static inline void __raw_write_unlock(raw_rwlock_t *rw)
{
asm volatile(LOCK_PREFIX "addl $" RW_LOCK_BIAS_STR ", %0"
: "+m" (rw->lock) : : "memory");
asm volatile(LOCK_PREFIX "addl %1, %0"
: "+m" (rw->lock) : "i" (RW_LOCK_BIAS) : "memory");
}

#define _raw_spin_relax(lock) cpu_relax()
Expand Down

0 comments on commit 6514f93

Please sign in to comment.