Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1841566lqz; Mon, 1 Apr 2024 21:27:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV52oBCPZln39+2fmEFvcBW2kknqbWa71DWA67aQbf8NWjQJNWy+8s1uZUnJE1hfouJy0PZYgTAIYBIp2V29ej0W6Y4AlOAQ0qFYlj9dw== X-Google-Smtp-Source: AGHT+IHxc4raPg1XV5KcH43Nyc2XOB21NcODWkpPFhTsYxGLclwk/t652CxptCk5WVaDRrNQt2pJ X-Received: by 2002:a17:906:3457:b0:a4e:26f7:4478 with SMTP id d23-20020a170906345700b00a4e26f74478mr6680459ejb.34.1712032065332; Mon, 01 Apr 2024 21:27:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712032065; cv=pass; d=google.com; s=arc-20160816; b=RpWeZeE4cy3Lky3/j2WXCPdD0LNkp1apz21r/xLWy1FJMC+lZWg2LthKQV+dNgpbrt Wk9S7ZG6yZINcu+6PySJL+Es70co9xegRP649ZO53IQcYXlHHsoie+kbacPy2gCwgROg h9KsKg57YduSjBV3j5VMp/cjEv4FD7bNd/VOV+1JfNAKq+WgkZX6mribEdssM3JEBoA2 2x4YKFVSaYxy6OiSnUxuD+6UFqnUdd3Ut2HD9ikzDCqFkESsxvCXk5uHpscFZQi2N0bO TuTmJT4McGibSlEhtmaYhMxlhg2j30MKC+07Xp+yLpVhtc/Md0FIqfmCAGoDSJz4nXiC //2w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=t4ri/Fq6lZ2A3vZ1xYxxvk1vL+cRIwMMoNSdmi5OUqg=; fh=5XKO4FJFa744F7hHLL6pG6MPZgtIgKlwP2n1WruVqgQ=; b=igwYlxFgenWaZDPtNx3QHFlkk5qwrE3xkVGGFseNJzPPirgIZ63ynpYF95bDpe+OfY 8nUC5G7toRRvqNDijuKTxIw1A+FU84KdW1SyrYFx2SkJmMCMwFnZUf+9FEGioTTXYkyj /fsTMxTYkkvQJz8cM4TqT3/9lNF0feHxD+CYzEQvNmMH0AO7Qua/tbUSUslvFAWnlwQ8 24C0tpogHzu5vlRQxAYo+fbXQakj/1yrmAzXFxL7yufPDJxoM+CxLi3QkTaq4yRQYQ6c CBufY7Ap1ub3aL+m4KvpXrPZpVcrv6h+GD2ZGQWFFQdH4Y9EDJTBj4zzT1FzZax1M5af RSrg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-127374-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127374-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ky8-20020a170907778800b00a45cdfe075esi5249928ejc.940.2024.04.01.21.27.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 21:27:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127374-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-127374-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127374-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B61B91F245AA for ; Tue, 2 Apr 2024 04:27:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8391F182BD; Tue, 2 Apr 2024 04:27:12 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D15D18028 for ; Tue, 2 Apr 2024 04:27:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712032032; cv=none; b=AxQxr6PIRKv62tjpabtfjgEEh88zGgE0pk/DzqpokrhGjJbENXxpoo2NHj/1ht8YnW9ozOZghIGYoUiPA24jixzwH1ir7QcdNQrXzCYtF+sT6BLZ+oyq0xpodTGy//asne6W2GWXkz1Xpu2j3r45DIjaKe7rHV0FuSgTbxaAU4M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712032032; c=relaxed/simple; bh=0ty19jRxcR5LG1UDzrTwUm/X+9XwoVNaxUPstJldl5w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gGAQNic9m6vMRi8JA8y8t7kfmPGwGCF0B4HgsQzwRf9oQfzXYa4PCACaWpgflqDz7m/v4eGd7RurKkcn7aqerkuHGQBCTUj8C7ejsxe0E28Ulkoh/OX2PEbb1LbBNUo6ldwRE6k1PhPeMtkuSjV4ljh7W22MDodOagIRO2pGa2A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7EC1C43390; Tue, 2 Apr 2024 04:27:10 +0000 (UTC) From: Al Viro To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, "David S. Miller" , Andreas Larsson , Palmer Dabbelt , Arnd Bergmann , Marco Elver Subject: [PATCH 3/8] sparc32: unify __cmpxchg_u{32,64} Date: Tue, 2 Apr 2024 00:28:30 -0400 Message-Id: <20240402042835.11815-3-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240402042835.11815-1-viro@zeniv.linux.org.uk> References: <20240402041138.GF538574@ZenIV> <20240402042835.11815-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add a macro that expands to one of those when given u32 or u64 as an argument - atomic32.c has a lot of similar stuff already. Signed-off-by: Al Viro --- arch/sparc/lib/atomic32.c | 41 +++++++++++++++------------------------ 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/arch/sparc/lib/atomic32.c b/arch/sparc/lib/atomic32.c index e15affbbb523..0d215a772428 100644 --- a/arch/sparc/lib/atomic32.c +++ b/arch/sparc/lib/atomic32.c @@ -159,32 +159,23 @@ unsigned long sp32___change_bit(unsigned long *addr, unsigned long mask) } EXPORT_SYMBOL(sp32___change_bit); -u32 __cmpxchg_u32(volatile u32 *ptr, u32 old, u32 new) -{ - unsigned long flags; - u32 prev; - - spin_lock_irqsave(ATOMIC_HASH(ptr), flags); - if ((prev = *ptr) == old) - *ptr = new; - spin_unlock_irqrestore(ATOMIC_HASH(ptr), flags); - - return prev; -} +#define CMPXCHG(T) \ + T __cmpxchg_##T(volatile T *ptr, T old, T new) \ + { \ + unsigned long flags; \ + T prev; \ + \ + spin_lock_irqsave(ATOMIC_HASH(ptr), flags); \ + if ((prev = *ptr) == old) \ + *ptr = new; \ + spin_unlock_irqrestore(ATOMIC_HASH(ptr), flags);\ + \ + return prev; \ + } + +CMPXCHG(u32) +CMPXCHG(u64) EXPORT_SYMBOL(__cmpxchg_u32); - -u64 __cmpxchg_u64(volatile u64 *ptr, u64 old, u64 new) -{ - unsigned long flags; - u64 prev; - - spin_lock_irqsave(ATOMIC_HASH(ptr), flags); - if ((prev = *ptr) == old) - *ptr = new; - spin_unlock_irqrestore(ATOMIC_HASH(ptr), flags); - - return prev; -} EXPORT_SYMBOL(__cmpxchg_u64); unsigned long __xchg_u32(volatile u32 *ptr, u32 new) -- 2.39.2