Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp780271lqm; Wed, 1 May 2024 16:03:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX8ZGlPAIN7PwtmNHoQfx/rbOXm7vXZs0+9Osy1ss671N/TnVyJIwsrF+zuS1OtLVilk8NDAvBuDXxoddju4VwhaP8jQ4Zrh8pRXqqtlQ== X-Google-Smtp-Source: AGHT+IFuXb86tySLwBjLtf1yLnr6yv8EQnsspRtjW0Mc1i6M+pyEuFywwwVzHF/+3EZ73yQ4x7/0 X-Received: by 2002:a17:902:c255:b0:1e8:a63b:d427 with SMTP id 21-20020a170902c25500b001e8a63bd427mr4116920plg.49.1714604588209; Wed, 01 May 2024 16:03:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714604588; cv=pass; d=google.com; s=arc-20160816; b=g8EpdQliBkdQnVQM2vcOxMN28G0MRkraenIf4eqeHxO/TAvLnV/nK6iAVmlMZ+zUcP WJr77zs3Oquhn991B/YrgWjP1qBlFnf5/MGAKab+plHV/oZmlDr3yvwMX9jaljvRqczr 2cZNHDcXZ5Z7Py7pyOW4us8j1vSMZJvbxZlB6sjTQjbYoGc1y73wFu7ulCtFg+bhmBHU tmOU8ouPWaWeCicAfbFGiaf4X9rz9K8yHYPViCpm7BabwXVpdQoYf8E8Y5ml69xmcyWB tIsgl32p+dlkhUPNOen6eKIh5h1+FO2dV8wMgRpvSoyia+ICtL3+233+H7NAM0VYXHgw jBRw== 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=Zlz3/cvqYWy6KB/xg1MK1MpG72Qtzx4fhinCkH5WKpk=; b=Uwl4L0jogRACmqwc7C+35fJWXs+w2D82GQ6eWRE4vxvLEtVy9NqLHDIFDZ/GTY9Jen BYclnJfRb9VN5ToB2eI1gBVIO7qz47THHfcAiWTP608qp4Pxp65qbVLfWqbvttc1iDCF Y5WC6tNrblgxjjPxKccLfFFUE6ASfcjMveom3nlU4s5ayx5wdBEac1wO9v+9gESjAIXK /nfBOHzz+HAPiEd/jlrcbfzWx7/iVHqWHHVwAMoi78cclmbff1MaP31I5mCWTCOrKmBX tGxMhMIvVEhs4VteETCjK4jD8DAEf5nStf4j1tdtjFo8OEXnBkllS62Sn2dlvhIHGlyt nGoA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t2KtLMkK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165808-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165808-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a11-20020a170902eccb00b001e920e191c3si21299187plh.127.2024.05.01.16.03.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 16:03:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165808-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t2KtLMkK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165808-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165808-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 768662834F3 for ; Wed, 1 May 2024 23:03:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C876716DEAE; Wed, 1 May 2024 23:01:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="t2KtLMkK" 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 F0B7C168AED; Wed, 1 May 2024 23:01:32 +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=1714604493; cv=none; b=qtuTBG1iu0v7bKQqNSVLx5w7OJiTRAmapONZJphNeRgCVEXojjPXT2YoF36VcYv/eVUpngE0lCS63J3SjWWP+w/GciMrmFjxCPjzpSR5rUet+qyxmuL8DNnKaieVHnB2rQouYZuqA5ASLcenOqqxZmCZjzqYuXxGikehQxMsv90= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714604493; c=relaxed/simple; bh=ehpYlEI/7ddbuIzdM9fBMt5Xa6+QYchqcgxnWBcCufs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=habGulP+3HxPtGnzer1nYPSbHyqF+UCLATlvpcnUg8NjPOLnrP8GOaT6vNhrNQA2n8ypk1nbmDEvB0zApF1X++QHJxlBaaE4CaoIEYsMqNYhJjQkC3c/yEHRdknAZqji8AKF8JAQmnIvyVteRaIztLplR/HjeOYDQCntZcrmaaU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t2KtLMkK; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 821FCC4AF4D; Wed, 1 May 2024 23:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714604492; bh=ehpYlEI/7ddbuIzdM9fBMt5Xa6+QYchqcgxnWBcCufs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t2KtLMkKSwpi3V6yfk2x80G1xvO37BHZJpU4pzwPsYJATGnBPLIK8Xwd4b90+VtgV Ucs1mN317R0+ZCd9f/u4jUetGp/Yd2epdeLdPWml5VZBzdcanpn9WOMqyd7Ebs32OS QnKGSGZm+NesLnXvtgTox7Ls2fuqw/J8MvyqvRv8QCYsGRb80qxt87r3S1pGY594sI VSNYFavCYTAPhQ/MFhQMy3PwpM+J57RJJT1W+UitNzQoASnfCkNyLGqbtnbgI7ETT0 +e9hG6sgvzTQxx4AZtKrMZPBpMwqI11zbGEDcA6VGKqoOnMzCXk0wbp1ZxPW+vFn50 R2KepK/5DKD8g== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id CA9A5CE226C; Wed, 1 May 2024 16:01:31 -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, arnd@arndb.de, torvalds@linux-foundation.org, kernel-team@meta.com, Al Viro , "Paul E . McKenney" Subject: [PATCH v2 cmpxchg 06/13] parisc: unify implementations of __cmpxchg_u{8,32,64} Date: Wed, 1 May 2024 16:01:23 -0700 Message-Id: <20240501230130.1111603-6-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: 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