From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752507AbbISElU (ORCPT ); Sat, 19 Sep 2015 00:41:20 -0400 Received: from mail-out.m-online.net ([212.18.0.10]:38736 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751796AbbISElD (ORCPT ); Sat, 19 Sep 2015 00:41:03 -0400 X-Auth-Info: po8lIkKVnzLl1egBVze9/PjP8tD9h1w+CbmLXY+xb5M= From: Marek Vasut To: linux-kernel@vger.kernel.org Cc: lftan@altera.com, Marek Vasut Subject: [PATCH] nios2: Switch to generic __xchg() Date: Sat, 19 Sep 2015 06:41:09 +0200 Message-Id: <1442637669-10753-1-git-send-email-marex@denx.de> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The generic __xchg() implementation present in asm-generic/cmpxchg.h is correct on nios2 and even generates the same code. Switch to this generic implementation to trim down the amount of ad-hoc copies of the code. Signed-off-by: Marek Vasut --- arch/nios2/include/asm/cmpxchg.h | 47 ---------------------------------------- 1 file changed, 47 deletions(-) diff --git a/arch/nios2/include/asm/cmpxchg.h b/arch/nios2/include/asm/cmpxchg.h index 8593871..a7978f1 100644 --- a/arch/nios2/include/asm/cmpxchg.h +++ b/arch/nios2/include/asm/cmpxchg.h @@ -9,53 +9,6 @@ #ifndef _ASM_NIOS2_CMPXCHG_H #define _ASM_NIOS2_CMPXCHG_H -#include - -#define xchg(ptr, x) \ - ((__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), sizeof(*(ptr)))) - -struct __xchg_dummy { unsigned long a[100]; }; -#define __xg(x) ((volatile struct __xchg_dummy *)(x)) - -static inline unsigned long __xchg(unsigned long x, volatile void *ptr, - int size) -{ - unsigned long tmp, flags; - - local_irq_save(flags); - - switch (size) { - case 1: - __asm__ __volatile__( - "ldb %0, %2\n" - "stb %1, %2\n" - : "=&r" (tmp) - : "r" (x), "m" (*__xg(ptr)) - : "memory"); - break; - case 2: - __asm__ __volatile__( - "ldh %0, %2\n" - "sth %1, %2\n" - : "=&r" (tmp) - : "r" (x), "m" (*__xg(ptr)) - : "memory"); - break; - case 4: - __asm__ __volatile__( - "ldw %0, %2\n" - "stw %1, %2\n" - : "=&r" (tmp) - : "r" (x), "m" (*__xg(ptr)) - : "memory"); - break; - } - - local_irq_restore(flags); - return tmp; -} - #include -#include #endif /* _ASM_NIOS2_CMPXCHG_H */ -- 2.1.4