Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1841799lqz; Mon, 1 Apr 2024 21:28:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCViD1ZGXEmJWTvKCxWXh0yMfsilEiYk9ooOsM9qI6x0tI82qNl8GZgca88ENlCR1sQonQ3Aq1RdyqDkfEPQq73igtYV5/5sRvakr26Ruw== X-Google-Smtp-Source: AGHT+IFgmTJ685QoUJU+Iz8I6eD6oop7X5/HXhHsotHMSolUe4ZOwI5c27apNdsP7IngCmATNNzl X-Received: by 2002:a05:6808:1b10:b0:3c4:ea77:ba9a with SMTP id bx16-20020a0568081b1000b003c4ea77ba9amr5417002oib.48.1712032116537; Mon, 01 Apr 2024 21:28:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712032116; cv=pass; d=google.com; s=arc-20160816; b=hvP6BrR4QxjkPZhXCdG5MlxVTjf3NGO+3Z2K+S+oGsqGlZAjlY5JX1eH8JzJhBoih8 1DlRetZr13goXU3J7RD97Wd+DYpy8FV0CeQ8NfsOEX1D1HelNOgmozX1ZWxXSVZlNRGM FY8UZTb2byTRkBYIbe7jOu3OpoTRQwQZsz1ZsEwTZWtFjmrAETMVk3DFw6n7N0A1aF1p D6iXr33nWXwxcCERz9iliRvcQdudiuuNMea+0npdHC8vTrU+4RTsvTnE2kGuqNJJVSyD fQCWNZ8NG/xXeg739O/APxmELCSQqeUMMPvv6Aj4uihadnjS77i0AKKiZfsDTni8fnNw +gjQ== 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=o9/7o2adCc/ZZSHYbxn5AL5IPMCTsdWlmYCG6bjRgDE=; fh=5XKO4FJFa744F7hHLL6pG6MPZgtIgKlwP2n1WruVqgQ=; b=Ts+a5HDAlELAhoY805Ua1QY5UElgU2Svab7/bebUpWIM4JxeEm+3TnmyLUoQkGn4eO mlamh6a9wynrTlxmAozzyc/ou7NGeX5ciX6cqTt1eRw6saWkkbrIjq6BR+vi+U52o/9+ m8mPqDP4KxSz8HZ68cmOih8/DMntLm9B/bJ8D5zAQriICbSOgZpSGwxvjR49RI1Aq+gq uzXRVK+54XpUGLGGEOGsuobLrNrMR7rLWnb+jny6Nx5cgCk+ZaIAZA7txTSu0U4ZwUaP Ne4nGkhd8oRuVXve/9i9WTfdzJE9fYU4KyHqBEK/52b696LJZp5cDsCPx2ymqk4eBlKH bUUw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-127377-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127377-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 sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s20-20020a632154000000b005f3cba260e6si903077pgm.807.2024.04.01.21.28.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 21:28:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127377-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; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-127377-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127377-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id B2F13B2373A for ; Tue, 2 Apr 2024 04:28:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1AB03224FA; Tue, 2 Apr 2024 04:27:15 +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 99E7522313 for ; Tue, 2 Apr 2024 04:27:14 +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=1712032034; cv=none; b=o0r91r10w0F88K1l3ZRAnOgo+XpK6YRVg9daouqbnsLtOAxpHfXPVbGQn2eI89BywEwWi7ipXEu4xPX7xNn41jUc4mJDac4R7kd/KIzitEfZZQhgy0035Ei+9W+QukJ6lL1iyKqcFO9St8bgdQYailQaeix8q6yWISNjOHIXKSQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712032034; c=relaxed/simple; bh=1MizhstMEeC0AVY1oEJM1Q9Lsl46flUajVFqAXBsSt0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IDkJuFWq/ag/WRNCWL94IPHyZNjZtiOZwY5lL4INop9xYu8OdINq8iJbNnv6xI3gHsH+4svbUXpWoUH7T5WnEdjtKAkpYvcuxNYdwN8B9ELVoCPqbXaDq0L2HJI8o+d3jkm/5kVwGpYBmgmrL9V1kFHyD6ukLuU33bNzovmkomA= 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 79AB4C433F1; Tue, 2 Apr 2024 04:27:13 +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 6/8] parisc: unify implementations of __cmpxchg_u{8,32,64} Date: Tue, 2 Apr 2024 00:28:33 -0400 Message-Id: <20240402042835.11815-6-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 identical except for type name involved Signed-off-by: Al Viro --- 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 ae2231d92198..cae30a3eb6d9 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.39.2