Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4395770pxj; Tue, 25 May 2021 07:07:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLn6GGUbf8MpREhA15H+zrcQmN0IiWF7hyeS4QOze2Jjc08jt/bK8zWcp0ZU9Qk/h7dtZS X-Received: by 2002:a05:6402:5211:: with SMTP id s17mr32803474edd.352.1621951637011; Tue, 25 May 2021 07:07:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621951637; cv=none; d=google.com; s=arc-20160816; b=0X4a6qiqArHn2i2pXzE9EJ0mrMB4Odldt3mHtl8hG3ZRy9Qu4tww7SAfZcw7RDCMzK 8nsuFiqZdnqCszxg3zPwlKNuPMJsRAXW9AJp3hHjtYfYQp74t48RGZAYXaUGi4y5xkSq XoRaD/z+jJoUnzfBIVMbkeDwraQJToWA0+6PSCnIOc1i//lsWVdyYI3yL2JbUN/Dt0P2 O/Fa8/GhDjQG2xTmdZIvfONqIbNfKMgt56kRNdaUpC7ym8yDGBPLjHQSjIovbEAWtmnJ VT2YuW45bBLj9BnP3GWZHLGx0SJpa0NI2jBLl1Z7CMwlzOSbjnhYc51K+J3PSY2E6sCT dMtQ== 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=qVVlMAO44QDsNVOojIoRjAQm7BFvYMv3mdDmTQlHL8pD/V77AhJRxNkKeZuKFZ9Dxt QlQlDNhhZrgFHBBZgcoWDttb/AlNJVZpsjon+8otuV7SZfpwiVBgrIyq5JMqDpympypF 9jP4nc5FqMTZDHG9gc2U2+YlZ57rlK5++aWfDY3ydSTHxyjVV3yq/Ljc4n6Oz6JCnqvn IOrur2cEG4xvfg95RDuS+DyRv+syBbbjhdTBNB/jkhm0u0VhGODb0W3fiJW4hSjRayPN GQBFHQLB2sErrRFTfJc//JJlb0snCYEfMT88+pU7OFAiuW71Q41wT66hifyHn//mKLQx YH0g== 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 by2si16210322edb.489.2021.05.25.07.06.54; Tue, 25 May 2021 07:07:16 -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 S233603AbhEYOG0 (ORCPT + 99 others); Tue, 25 May 2021 10:06:26 -0400 Received: from foss.arm.com ([217.140.110.172]:57060 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233536AbhEYOGY (ORCPT ); Tue, 25 May 2021 10:06:24 -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 221E01478; Tue, 25 May 2021 07:04:54 -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 D27853F73D; Tue, 25 May 2021 07:04:49 -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, gerg@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, palmerdabbelt@google.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 v2 08/33] locking/atomic: atomic: simplify ifdeffery Date: Tue, 25 May 2021 15:02:07 +0100 Message-Id: <20210525140232.53872-9-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210525140232.53872-1-mark.rutland@arm.com> References: <20210525140232.53872-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