From patchwork Fri Oct 30 00:27:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Coolidge X-Patchwork-Id: 7522811 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C5DF0BEEA4 for ; Fri, 30 Oct 2015 00:29:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EEEC0207BF for ; Fri, 30 Oct 2015 00:29:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2FF0C207B9 for ; Fri, 30 Oct 2015 00:29:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZrxXT-0000pZ-Lx; Fri, 30 Oct 2015 00:27:27 +0000 Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZrxXQ-0000nb-Er for linux-arm-kernel@lists.infradead.org; Fri, 30 Oct 2015 00:27:24 +0000 Received: by pacfv9 with SMTP id fv9so57726890pac.3 for ; Thu, 29 Oct 2015 17:27:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Bu3TOU9fqlIQ/OuGGuJagzsJEWbXo5MKocMjWC9i9cc=; b=IDZuiaq3yY/4hg4yH9ZNNOWewCEa94EeJ6O8HLeFg2nlRX5fgLc8CkhHTnEfpq3swa A6ySMOs1q3nSBrTcMe31jdgKkk6BETUJm5kfhxOXXvEN164ciW5q5IA0q2vHbxV8Z8zk rwHgWix9v9koFvzlBN4FhHYeOUZPbEMeFIE4Hu+jcUXHoK2rsnbHMZ8i3mWQ6FGHzwZ+ I+uTQUIPyxGjXMBYLF3TqkFTr6eJB83ONn+BTuZk5Ujsm3x3PGxOaS8aZuW1M7YHaDFB ZfHBEmjaNjI7tLIwSWXPkUSFcUSUjEu1vFH0whLJlngTwNwPmsKNhq5t81d3jFuNH4/I Jeiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Bu3TOU9fqlIQ/OuGGuJagzsJEWbXo5MKocMjWC9i9cc=; b=FmYtkFHPqoUOD3T35xel0/ZJRxbLZsAFOUH30E1deXWz1jNU55gJgZMMtFvKsOoY7f OSL+jPK0gG414q/v6XPDfyiaDaEUn6Eg/1KaRxzJyErDin3BTYxzxH8F352W77EcQclL 8wBasc2d75YtMuRKknV7v6NHzrz+bHIQZVe11PyklYbPbEw8UCnksObICkx1Wtq1MAD/ ThwA/HhQDKLTv5l+BLqX32Aq1auuTmnrrJR+ROv73T5Z6Lgwujo+1HgzriCoCtLwNvKT 5m9BYiDUj1/xjyJ4WUeb6vcmmyEeqPigpGBTFpMLwP1J1UDfe7EksYKQosbve0FCv8IT F7yQ== X-Gm-Message-State: ALoCoQmdRgTVIQzRyPDBLJjWx7Mrv64NBVtoPi7W9kCkI3fD4Dgmas4Slutmj6/Qz4bHhBL3tD08 X-Received: by 10.68.88.2 with SMTP id bc2mr5133413pbb.117.1446164823456; Thu, 29 Oct 2015 17:27:03 -0700 (PDT) Received: from grimace.mtv.corp.google.com ([172.18.104.49]) by smtp.gmail.com with ESMTPSA id k5sm4440466pbq.74.2015.10.29.17.27.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Oct 2015 17:27:02 -0700 (PDT) Received: by grimace.mtv.corp.google.com (Postfix, from userid 268106) id E68FA201815; Thu, 29 Oct 2015 17:27:01 -0700 (PDT) From: Ian Coolidge To: arnd@arndb.de, linux@arm.linux.org.uk Subject: [PATCH] arm: spinlock: const qualify read-only functions. Date: Thu, 29 Oct 2015 17:27:00 -0700 Message-Id: <1446164820-16144-1-git-send-email-icoolidge@google.com> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 In-Reply-To: <1446061495-38554-1-git-send-email-icoolidge@google.com> References: <1446061495-38554-1-git-send-email-icoolidge@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151029_172724_570626_D4DFD883 X-CRM114-Status: GOOD ( 13.09 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, Ian Coolidge MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This allows assert_spin_locked() to be used against spinlocks that are const qualified. For example: struct instance_t { int data; spinlock_t lock; }; /* * foo does not mutate instance. * foo must be called while the lock is held. */ int foo(const instance_t *instance) { assert_spin_locked(&instance->lock); /* Code that assumes the lock is held */ return 0; } Signed-off-by: Ian Coolidge --- arch/arm/include/asm/spinlock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/spinlock.h b/arch/arm/include/asm/spinlock.h index 0fa4184..274ceb1 100644 --- a/arch/arm/include/asm/spinlock.h +++ b/arch/arm/include/asm/spinlock.h @@ -118,12 +118,12 @@ static inline int arch_spin_value_unlocked(arch_spinlock_t lock) return lock.tickets.owner == lock.tickets.next; } -static inline int arch_spin_is_locked(arch_spinlock_t *lock) +static inline int arch_spin_is_locked(const arch_spinlock_t *lock) { return !arch_spin_value_unlocked(READ_ONCE(*lock)); } -static inline int arch_spin_is_contended(arch_spinlock_t *lock) +static inline int arch_spin_is_contended(const arch_spinlock_t *lock) { struct __raw_tickets tickets = READ_ONCE(lock->tickets); return (tickets.next - tickets.owner) > 1;