Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2427028pxj; Mon, 10 May 2021 02:41:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxI92mkdVKkQ5OrkhXgUcilU9ri1dBjDx/I25jBZVLO3gXMJ3ZqGjUTOx5Drth3v8MPGVKT X-Received: by 2002:a92:1805:: with SMTP id 5mr20408824ily.82.1620639698688; Mon, 10 May 2021 02:41:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620639698; cv=none; d=google.com; s=arc-20160816; b=G7Fh4gbBVReemL64D3bdBdxoc8nPlG4el44elqaLN6klbd03J1AqoA5y7jUVSjaWcc zXoIfsFa8Hi0NXAh4GcNjDSHI7d7JMDEvI5E5XuZKhaVedrqaGNqlbaghsfZOtC3suBV PTLWZM6qqxLDvyp5x9He2CxG07rK/qMpN0qCZ7KT8hAqEIFeDFPbymmLQsA5NpoZCKqg GSq8xc4yna5TDThb/wY01pf11qcjQYeRKNUkcLR2OoLpSzsDXSlb4FE1azQmDrooSaDF i0gn1zW/N/THPk9XvLWKb6ArJoULiO3VwSIKA8dhPxpcfGSMBlO31Gtr6mI9XcZzz7H3 nnsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=nAmozBVpeaIOzKCGhNfsjvTcwo9XM58C/WeK/4Alouk=; b=fXBdzoosr6163UQKjspvurEla6C530Td34cm7i0Kj7WVm4YdFfR/gmLgWmPyjEQ5Gr KD7M0jVnVgYKRaheXLvtlrG32fJfoGbNBPNmeYieGFg/+vfh8x5ZjM8EnA8DDs2pmfZ4 mf89o/XrAPOX8z1CSuCxMBTs5PCg88cgC2DqqcrAAOnXuM8J/qQ5RmgStGKUk4juVk4i Zd9Ug0St3q+YtfP6dS6YdggWHqdo2MzmXZvy1W5MU+DbhsfPMarSDMMXqW7AfADUOuQy S+jQ4athd+ouBCrRg+7XW21Cr+9ZmP1UPTGcsGEhr1xKFQH02O6bESGUiF4ssX+Pa2v3 eYtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t23si14630692ioj.71.2021.05.10.02.41.26; Mon, 10 May 2021 02:41:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230377AbhEJJlY (ORCPT + 99 others); Mon, 10 May 2021 05:41:24 -0400 Received: from foss.arm.com ([217.140.110.172]:50842 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230400AbhEJJlT (ORCPT ); Mon, 10 May 2021 05:41:19 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4758F1435; Mon, 10 May 2021 02:40:15 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1C52D3F73B; Mon, 10 May 2021 02:40:11 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org, will@kernel.org, boqun.feng@gmail.com, peterz@infradead.org Cc: aou@eecs.berkeley.edu, arnd@arndb.de, bcain@codeaurora.org, benh@kernel.crashing.org, chris@zankel.net, dalias@libc.org, davem@davemloft.net, deanbo422@gmail.com, deller@gmx.de, geert@linux-m68k.org, green.hu@gmail.com, guoren@kernel.org, ink@jurassic.park.msu.ru, James.Bottomley@HansenPartnership.com, jcmvbkbc@gmail.com, jonas@southpole.se, ley.foon.tan@intel.com, linux@armlinux.org.uk, mark.rutland@arm.com, mattst88@gmail.com, monstr@monstr.eu, mpe@ellerman.id.au, nickhu@andestech.com, palmer@dabbelt.com, paulus@samba.org, paul.walmsley@sifive.com, rth@twiddle.net, shorne@gmail.com, stefan.kristiansson@saunalahti.fi, tsbogend@alpha.franken.de, vgupta@synopsys.com, ysato@users.sourceforge.jp Subject: [PATCH 08/33] locking/atomic: atomic: simplify ifdeffery Date: Mon, 10 May 2021 10:37:28 +0100 Message-Id: <20210510093753.40683-9-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210510093753.40683-1-mark.rutland@arm.com> References: <20210510093753.40683-1-mark.rutland@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that asm-generic/atomic.h is only used by architectures without any architecture-specific atomic definitions, we know that there will be no architecture-specific implementations to override, and can remove the ifdeffery this has previously required, bringing it into line with asm-generic/atomic64.h. At the same time, we can implement atomic_add() and atomic_sub() directly using ATOMIC_OP(), since we know architectures won't provide atomic_add_return() or atomic_sub_return(). There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland Cc: Arnd Bergmann Cc: Boqun Feng Cc: Peter Zijlstra Cc: Will Deacon --- include/asm-generic/atomic.h | 46 ++++---------------------------------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h index d4bf803d6491..316c82a27b0a 100644 --- a/include/asm-generic/atomic.h +++ b/include/asm-generic/atomic.h @@ -93,65 +93,27 @@ static inline int atomic_fetch_##op(int i, atomic_t *v) \ #endif /* CONFIG_SMP */ -#ifndef atomic_add_return ATOMIC_OP_RETURN(add, +) -#endif - -#ifndef atomic_sub_return ATOMIC_OP_RETURN(sub, -) -#endif -#ifndef atomic_fetch_add ATOMIC_FETCH_OP(add, +) -#endif - -#ifndef atomic_fetch_sub ATOMIC_FETCH_OP(sub, -) -#endif - -#ifndef atomic_fetch_and ATOMIC_FETCH_OP(and, &) -#endif - -#ifndef atomic_fetch_or ATOMIC_FETCH_OP(or, |) -#endif - -#ifndef atomic_fetch_xor ATOMIC_FETCH_OP(xor, ^) -#endif -#ifndef atomic_and +ATOMIC_OP(add, +) +ATOMIC_OP(sub, -) ATOMIC_OP(and, &) -#endif - -#ifndef atomic_or ATOMIC_OP(or, |) -#endif - -#ifndef atomic_xor ATOMIC_OP(xor, ^) -#endif #undef ATOMIC_FETCH_OP #undef ATOMIC_OP_RETURN #undef ATOMIC_OP -#ifndef atomic_read -#define atomic_read(v) READ_ONCE((v)->counter) -#endif - -#define atomic_set(v, i) WRITE_ONCE(((v)->counter), (i)) - -static inline void atomic_add(int i, atomic_t *v) -{ - atomic_add_return(i, v); -} - -static inline void atomic_sub(int i, atomic_t *v) -{ - atomic_sub_return(i, v); -} +#define atomic_read(v) READ_ONCE((v)->counter) +#define atomic_set(v, i) WRITE_ONCE(((v)->counter), (i)) #define atomic_xchg(ptr, v) (xchg(&(ptr)->counter, (v))) #define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new))) -- 2.11.0