Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b8bc2f7 authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge Committed by H. Peter Anvin
Browse files

x86: Use xadd helper more widely



This covers the trivial cases from open-coded xadd to the xadd macros.

Signed-off-by: default avatarJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Link: http://lkml.kernel.org/r/4E5BCC40.3030501@goop.org


Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
parent 433b3520
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -172,18 +172,14 @@ static inline int atomic_add_negative(int i, atomic_t *v)
 */
static inline int atomic_add_return(int i, atomic_t *v)
{
	int __i;
#ifdef CONFIG_M386
	int __i;
	unsigned long flags;
	if (unlikely(boot_cpu_data.x86 <= 3))
		goto no_xadd;
#endif
	/* Modern 486+ processor */
	__i = i;
	asm volatile(LOCK_PREFIX "xaddl %0, %1"
		     : "+r" (i), "+m" (v->counter)
		     : : "memory");
	return i + __i;
	return i + xadd(&v->counter, i);

#ifdef CONFIG_M386
no_xadd: /* Legacy 386 processor */
+1 −5
Original line number Diff line number Diff line
@@ -170,11 +170,7 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
 */
static inline long atomic64_add_return(long i, atomic64_t *v)
{
	long __i = i;
	asm volatile(LOCK_PREFIX "xaddq %0, %1;"
		     : "+r" (i), "+m" (v->counter)
		     : : "memory");
	return i + __i;
	return i + xadd(&v->counter, i);
}

static inline long atomic64_sub_return(long i, atomic64_t *v)
+1 −7
Original line number Diff line number Diff line
@@ -204,13 +204,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
 */
static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
{
	long tmp = delta;

	asm volatile(LOCK_PREFIX "xadd %0,%1"
		     : "+r" (tmp), "+m" (sem->count)
		     : : "memory");

	return tmp + delta;
	return delta + xadd(&sem->count, delta);
}

#endif /* __KERNEL__ */
+1 −5
Original line number Diff line number Diff line
@@ -656,11 +656,7 @@ static inline int atomic_read_short(const struct atomic_short *v)
 */
static inline int atom_asr(short i, struct atomic_short *v)
{
	short __i = i;
	asm volatile(LOCK_PREFIX "xaddw %0, %1"
			: "+r" (i), "+m" (v->counter)
			: : "memory");
	return i + __i;
	return i + xadd(&v->counter, i);
}

/*