From patchwork Fri Sep 7 19:41:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin LABBE X-Patchwork-Id: 10592497 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C7C414E2 for ; Fri, 7 Sep 2018 19:43:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C0372B5F3 for ; Fri, 7 Sep 2018 19:43:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F15142B731; Fri, 7 Sep 2018 19:43:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8868C2B5F3 for ; Fri, 7 Sep 2018 19:43:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Om7Gf7Lv+Vbz+oXD0JjphL2pfZk5IKpZtXzDPpgKOn0=; b=eZloqI45RdW4iy4NSv4XL/qMwX CyPPBlMMtLlr7ew7qQHyrm4//im5Zv+J7sdZNRqaUaK8PtT04ItzVFBXmciFaHLWjk4qlvUa9djoO JaDHa1pZcpC+CdTOHP4zu6C0F9yIRSaSW923dVHGIF3ZWHZP7MtOgvIRuzyA04FK2NpCyUjFgqG0z TwMMQMjgepcu5Hq5CJNHrgWsfX7ctCjlN143QcrGdbjdB9zjKLdNSsqMWe1/VKff97aXp6UvShYTQ C7iyV0pXeuV6kIE5GZDHKQoKXZ5pQhEW5zRa2/xlSQMGyez2uDTTv46WQdSmfh59vkDpILgwTmJAa X49h2z3Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyMf2-0003aX-RR; Fri, 07 Sep 2018 19:43:20 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyMeG-0003BS-Tx for linux-amlogic@lists.infradead.org; Fri, 07 Sep 2018 19:42:37 +0000 Received: by mail-wm0-x244.google.com with SMTP id t25-v6so15617452wmi.3 for ; Fri, 07 Sep 2018 12:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2OBVCDONGEzIwTm7QfSFZEKxjwVO4pekD/4rVjP1wLE=; b=0JTsFfytjLjlW8adkFTtXKjzuqmxH5bQeUHfO575Wp6BlZusLZmwGH+2UqmV75F6Oa c54j7sFdBh3f6iHYH1e4yXsrMZcAVNpegkdv0fuDmSGJ0Ig4cn4XnMhjhfAAjTxflUZV HWCxENCPENNdkvi8Rzx0KV6g8JGNNb3/MzQbvoi3UflS6GC3Bs6uLOfMSakge5Cmslv8 voxm9R+dyIE0A4q/tGMzCGS+7vFyLRL2LY47sJY7ZlyXVQXtprYb2kt3hPxUukU6hZYW tK91IAU5fAYkHClcS25SlGPvZ/YalZEmoEy10K24VpuFrVv9RcacI7wDILN38P8qrBoe OYhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2OBVCDONGEzIwTm7QfSFZEKxjwVO4pekD/4rVjP1wLE=; b=Xfq3HXcwrNb/aTsM5P+7COT9vJSGvaVIDaDU/B5sFJXuy0C1i9U5vDaOj74iS7c1h6 4KEbn5BWDi4IkiEAORbm0hml1Q9ks3A5pk8+9/pypsc6n2MK/SB9xCkxbJPVSq1qlJop ueZf5paVhZ+/QhgB+WrsAy1HvAJbigG3uZvvoEx9b8YUpbMU6khb/O2oP5dYuQ2mzj35 uC1Bg5T4bsxIAp+DXtsYjq3FhbUdPEFODMw+juYNe4/rdndqvIOJy+wpBkW7f9bBihT8 Y5a9TJ0nZMSKKlJEeFQ5mglXiatKOFJlJjbU+SOwTVSGbMJ4DelCMGYu1dHmKQXcHAx6 2DbA== X-Gm-Message-State: APzg51AhS+NZwblqaqrRVJpHPbeNfUM9kqkm8Js6+4wqDbqMnrrvCndI MHsVC14Z79sDia8fQdFJSKnWiw== X-Google-Smtp-Source: ANB0Vda3a1G3h/a0T7QOpgIWFBqrTWDEHU2LI/VoQLK/4NyCFWEZeJPvihMr17URkYAc7FNgfNxKBw== X-Received: by 2002:a1c:70b:: with SMTP id 11-v6mr6061230wmh.151.1536349341273; Fri, 07 Sep 2018 12:42:21 -0700 (PDT) Received: from localhost.localdomain ([51.15.160.169]) by smtp.googlemail.com with ESMTPSA id y17-v6sm11700133wrh.49.2018.09.07.12.42.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Sep 2018 12:42:20 -0700 (PDT) From: Corentin Labbe To: Gilles.Muller@lip6.fr, Julia.Lawall@lip6.fr, agust@denx.de, alexandre.torgue@st.com, alistair@popple.id.au, benh@kernel.crashing.org, carlo@caione.org, davem@davemloft.net, galak@kernel.crashing.org, joabreu@synopsys.com, khilman@baylibre.com, maxime.ripard@bootlin.com, michal.lkml@markovi.net, mpe@ellerman.id.au, mporter@kernel.crashing.org, nicolas.palix@imag.fr, oss@buserror.net, paulus@samba.org, peppe.cavallaro@st.com, tj@kernel.org, vitb@kernel.crashing.org, wens@csie.org Subject: [PATCH 2/5] include: add setbits32/clrbits32/clrsetbits32/setbits64/clrbits64/clrsetbits64 in linux/setbits.h Date: Fri, 7 Sep 2018 19:41:44 +0000 Message-Id: <1536349307-20714-3-git-send-email-clabbe@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536349307-20714-1-git-send-email-clabbe@baylibre.com> References: <1536349307-20714-1-git-send-email-clabbe@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180907_124232_997666_59C153A8 X-CRM114-Status: GOOD ( 10.58 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe , linux-amlogic@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, cocci@systeme.lip6.fr, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds setbits32/clrbits32/clrsetbits32 and setbits64/clrbits64/clrsetbits64 in linux/setbits.h header. Signed-off-by: Corentin Labbe --- include/linux/setbits.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 include/linux/setbits.h diff --git a/include/linux/setbits.h b/include/linux/setbits.h new file mode 100644 index 000000000000..3e1e273551bb --- /dev/null +++ b/include/linux/setbits.h @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LINUX_SETBITS_H +#define __LINUX_SETBITS_H + +#include + +#define __setbits(readfunction, writefunction, addr, set) \ + writefunction((readfunction(addr) | (set)), addr) +#define __clrbits(readfunction, writefunction, addr, mask) \ + writefunction((readfunction(addr) & ~(mask)), addr) +#define __clrsetbits(readfunction, writefunction, addr, mask, set) \ + writefunction(((readfunction(addr) & ~(mask)) | (set)), addr) +#define __setclrbits(readfunction, writefunction, addr, mask, set) \ + writefunction(((readfunction(addr) | (seti)) & ~(mask)), addr) + +#define setbits32(addr, set) __setbits(readl, writel, addr, set) +#define setbits32_relaxed(addr, set) __setbits(readl_relaxed, writel_relaxed, \ + addr, set) + +#define clrbits32(addr, mask) __clrbits(readl, writel, addr, mask) +#define clrbits32_relaxed(addr, mask) __clrbits(readl_relaxed, writel_relaxed, \ + addr, mask) + +#define clrsetbits32(addr, mask, set) __clrsetbits(readl, writel, addr, mask, set) +#define clrsetbits32_relaxed(addr, mask, set) __clrsetbits(readl_relaxed, \ + writel_relaxed, \ + addr, mask, set) + +#define setclrbits32(addr, mask, set) __setclrbits(readl, writel, addr, mask, set) +#define setclrbits32_relaxed(addr, mask, set) __setclrbits(readl_relaxed, \ + writel_relaxed, \ + addr, mask, set) + +/* We cannot use CONFIG_64BIT as some x86 drivers use writeq */ +#if defined(writeq) && defined(readq) +#define setbits64(addr, set) __setbits(readq, writeq, addr, set) +#define setbits64_relaxed(addr, set) __setbits(readq_relaxed, writeq_relaxed, \ + addr, set) + +#define clrbits64(addr, mask) __clrbits(readq, writeq, addr, mask) +#define clrbits64_relaxed(addr, mask) __clrbits(readq_relaxed, writeq_relaxed, \ + addr, mask) + +#define clrsetbits64(addr, mask, set) __clrsetbits(readq, writeq, addr, mask, set) +#define clrsetbits64_relaxed(addr, mask, set) __clrsetbits(readq_relaxed, \ + writeq_relaxed, \ + addr, mask, set) + +#define setclrbits64(addr, mask, set) __setclrbits(readq, writeq, addr, mask, set) +#define setclrbits64_relaxed(addr, mask, set) __setclrbits(readq_relaxed, \ + writeq_relaxed, \ + addr, mask, set) +#endif /* writeq/readq */ + +#endif /* __LINUX_SETBITS_H */