Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1530587lqe; Mon, 8 Apr 2024 11:30:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUX8qDTcoKz+iJ4r87nlE7CGTKrpAnhOEk3u8rIrpdpmIk4mUNQjZ8dun2UZU3DLISLKBTYLQ+DJkCZ79ddYK3o4LZqMPNH0iQAPXRcVw== X-Google-Smtp-Source: AGHT+IEXtd00RjXem5lDpTgDaACdQpjtF+7yTpLli1SoDGoWRBQpej/ZqPNk6mnFbh08oJd50A3s X-Received: by 2002:a05:6a20:1588:b0:1a7:9ed1:fc21 with SMTP id h8-20020a056a20158800b001a79ed1fc21mr732281pzj.22.1712601059520; Mon, 08 Apr 2024 11:30:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712601059; cv=pass; d=google.com; s=arc-20160816; b=mebQOOvNKEJWXBDxZV5DR/y/H2YruCdpgMLLnEBrhknvC9VUv67yFqX47FVBU4OjIt oj4a2FsgeNib9XFOWk5dYSe2tBRujPwEI4HB8Et8mRJQfYoFiZ42sxQ01j1KIPIs4kGT dhgZ+Vq/T6ikU/kpL/WRgZAMc0ViLlAx9YIOmHKJoZr0H9K7xTrmrgMuKhnvzHm1IYvQ r+3fhJ30D4vfax3QOdYJCjmVDiL46n1i2XDC/FlFzW1lsEFqO/wIbTCbbtka3p0+3ITp q0cFYl6rILzZOY02by9Cge6z8Vl/eT9dIU9xqHuhUMV3FvraT2mBUas+rwLm0LEzCuoB K6Gw== 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:dkim-signature; bh=YsWmPGMZs71kYUX+hBGA7f+uZkOfCEDz0DkhIsro3qA=; fh=w9S2XPug8Iuwyxj1huAxJ8xgXHl/EkJ/564y4G32wHQ=; b=Yi0blOPOSawUG3GHOT1RKKoLdTxlV4ZaFotBEkPSLYWtTuPkQEKZM23mlMhk4COzsJ /bZLgXqaBpkpGHkkOJXPWExucLaDx8QY6fb1d5qKUeMs58UUp089uVzF6kFI4nve+Z5X bFXcIR+VwDexlB7tftyhLyLuRawCD95V3jeEYZylz/V4Zq+0sfb8hg/EYB7wL3t+rNy7 o6e0+yF7bHzFc+BmKkS7IA0F64pq0WYARn6bDJxrd4JHIIyPr2rtQSvIxJp9qh06HII3 CiRHeSfaILwX17BMtaQMii8nBR9Hi3OsMvUQTw9QHMTYVO1eiLzb4bU8SOU60Fw3sy9x HpiQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KMkplKrG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-135773-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135773-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e12-20020a631e0c000000b005cdf37c9c29si6844262pge.703.2024.04.08.11.30.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 11:30:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135773-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KMkplKrG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-135773-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135773-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 5E231B291A1 for ; Mon, 8 Apr 2024 17:50:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 09425145B17; Mon, 8 Apr 2024 17:49:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KMkplKrG" 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 21A5A1442F4; Mon, 8 Apr 2024 17:49:47 +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=1712598587; cv=none; b=j0gHxmXaqK9JW71WgUVjNINOY2cCdjBAHfOU8uoC/hbq4NINLh8aGvAFqn3xkzLq9HFJ89BWZxNnRVeQ0phK9EDT4wywnw8LT6KAJB4dHH2J8qeHXrry2m8RWt6w3+aMVwPXoKaSX12bC4qFJBtWjfGueJti0D/xSxgYpwSxnr0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712598587; c=relaxed/simple; bh=ehpYlEI/7ddbuIzdM9fBMt5Xa6+QYchqcgxnWBcCufs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EFAXiLBLt7AL8NO6uvpQ/ZuEw/d1NZMZBfKT8ibYYWNgtfl/wTaeJ6uP9sg0KxXgwd/SkMXD9GZjma8ifLWURs2qCHk/AaZZ6FIilK9o62ahxX55BG9GBB+w3+mYqAXJ9lD+2wsOADEojN7r2Y2+whe33+/9Qer0QDLMhAT2fE4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KMkplKrG; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE3A0C43141; Mon, 8 Apr 2024 17:49:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712598587; bh=ehpYlEI/7ddbuIzdM9fBMt5Xa6+QYchqcgxnWBcCufs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KMkplKrGYFAtzogNbXrfO5h2hdRTKK2H1oDTPZK3PtZpII2Eut8dHtbmuX+0L30lo yeWI9cdO+h9UMGwnPuD7g1EjVZxbgIBlnoUC/HSB7WjeziMyA2TzOxb7tuZGvtiDp3 VWdbTUekftlFq1IE8g4sz0PoLMrOHiyjwzl42bpahqg/ao536zBSTpO9YQu+BtUbg4 0qN+M4hOC6d+M2VtXjUvLrPr7+pqd3NDASqs750SMUTZc27Qrrm3e5l5B4HXcenVoX x2fhiZQYipVqbaM0YIUY8R1MFK0CaejI8s1ciP13QayFQDEMp/Eewj3yUB6xzuQJPD DAmVdPVDWgRQg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 4A1BCCE1F7A; Mon, 8 Apr 2024 10:49:46 -0700 (PDT) From: "Paul E. McKenney" To: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Cc: elver@google.com, akpm@linux-foundation.org, tglx@linutronix.de, peterz@infradead.org, dianders@chromium.org, pmladek@suse.com, torvalds@linux-foundation.org, Arnd Bergmann , Al Viro , "Paul E . McKenney" Subject: [PATCH cmpxchg 06/14] parisc: unify implementations of __cmpxchg_u{8,32,64} Date: Mon, 8 Apr 2024 10:49:36 -0700 Message-Id: <20240408174944.907695-6-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <7b3646e0-667c-48e2-8f09-e493c43c30cb@paulmck-laptop> References: <7b3646e0-667c-48e2-8f09-e493c43c30cb@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Al Viro identical except for type name involved Signed-off-by: Al Viro Signed-off-by: Paul E. McKenney --- arch/parisc/lib/bitops.c | 51 +++++++++++++--------------------------- 1 file changed, 16 insertions(+), 35 deletions(-) diff --git a/arch/parisc/lib/bitops.c b/arch/parisc/lib/bitops.c index ae2231d921985..cae30a3eb6d9b 100644 --- a/arch/parisc/lib/bitops.c +++ b/arch/parisc/lib/bitops.c @@ -56,38 +56,19 @@ unsigned long notrace __xchg8(char x, volatile char *ptr) } -u64 notrace __cmpxchg_u64(volatile u64 *ptr, u64 old, u64 new) -{ - unsigned long flags; - u64 prev; - - _atomic_spin_lock_irqsave(ptr, flags); - if ((prev = *ptr) == old) - *ptr = new; - _atomic_spin_unlock_irqrestore(ptr, flags); - return prev; -} - -u32 notrace __cmpxchg_u32(volatile u32 *ptr, u32 old, u32 new) -{ - unsigned long flags; - u32 prev; - - _atomic_spin_lock_irqsave(ptr, flags); - if ((prev = *ptr) == old) - *ptr = new; - _atomic_spin_unlock_irqrestore(ptr, flags); - return prev; -} - -u8 notrace __cmpxchg_u8(volatile u8 *ptr, u8 old, u8 new) -{ - unsigned long flags; - u8 prev; - - _atomic_spin_lock_irqsave(ptr, flags); - if ((prev = *ptr) == old) - *ptr = new; - _atomic_spin_unlock_irqrestore(ptr, flags); - return prev; -} +#define CMPXCHG(T) \ + T notrace __cmpxchg_##T(volatile T *ptr, T old, T new) \ + { \ + unsigned long flags; \ + T prev; \ + \ + _atomic_spin_lock_irqsave(ptr, flags); \ + if ((prev = *ptr) == old) \ + *ptr = new; \ + _atomic_spin_unlock_irqrestore(ptr, flags); \ + return prev; \ + } + +CMPXCHG(u64) +CMPXCHG(u32) +CMPXCHG(u8) -- 2.40.1