Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
powerpc: Implement arch_spin_is_locked() using arch_spin_value_unlock…
Browse files Browse the repository at this point in the history
…ed()

At a glance these are just the inverse of each other. The one subtlety
is that arch_spin_value_unlocked() takes the lock by value, rather than
as a pointer, which is important for the lockref code.

On the other hand arch_spin_is_locked() doesn't really care, so
implement it in terms of arch_spin_value_unlocked().

Signed-off-by: Michael Ellerman <[email protected]>
Signed-off-by: Benjamin Herrenschmidt <[email protected]>
  • Loading branch information
mpe authored and ozbenh committed Jan 28, 2014
1 parent 3405d23 commit 7179ba5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions arch/powerpc/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
#include <asm/synch.h>
#include <asm/ppc-opcode.h>

#define arch_spin_is_locked(x) ((x)->slock != 0)

#ifdef CONFIG_PPC64
/* use 0x800000yy when locked, where yy == CPU number */
#ifdef __BIG_ENDIAN__
Expand Down Expand Up @@ -59,6 +57,11 @@ static __always_inline int arch_spin_value_unlocked(arch_spinlock_t lock)
return lock.slock == 0;
}

static inline int arch_spin_is_locked(arch_spinlock_t *lock)
{
return !arch_spin_value_unlocked(*lock);
}

/*
* This returns the old value in the lock, so we succeeded
* in getting the lock if the return value is 0.
Expand Down

0 comments on commit 7179ba5

Please sign in to comment.