From patchwork Mon Sep 24 19:04:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin LABBE X-Patchwork-Id: 10612793 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 BD8E3112B for ; Mon, 24 Sep 2018 19:07:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B078A29B49 for ; Mon, 24 Sep 2018 19:07:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A42E12A586; Mon, 24 Sep 2018 19:07:45 +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 3A60529B49 for ; Mon, 24 Sep 2018 19:07:45 +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=xw2hH+Urs63vh3bS0d4jDCyI8YiYPnJIZlg2E+MgqVQ=; b=hs3z4FYoHyztRCA+WykFDRuC9i +ibuzoH9f7mgD3p9l5J6FpMAImQe5VAeLgWOR5sqwhIy5Rpo4m5dpceRxNm37lf14XPBpH1yKRILn HW3UldXjqdLypumdVYQQonKIpht2WtE2VEDSJ5SqYTeljwneUl4AlDEe5qM7v4RKZVFr6HxAhLe8c bssjWPIDXU8rII9LUDw4zDJb2ddPhgSLrfReIU6LZYj5NZZ91XhSKK5sYSlIWieHLsGozCsFzV4uj 2e3bp6kl/FlOv1dNmBSivcGysVa7DsYdPUGljeJgqNvzmjGIoVIrWaAzVrzvFx4TvOjgI5Qu6FCxC 20KWNsSQ==; 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 1g4WCt-0002Zg-9J; Mon, 24 Sep 2018 19:07:43 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g4WAG-0000hL-9k for linux-amlogic@lists.infradead.org; Mon, 24 Sep 2018 19:05:13 +0000 Received: by mail-wr1-x443.google.com with SMTP id n11-v6so9581354wro.0 for ; Mon, 24 Sep 2018 12:04:29 -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=6E4+VPjtB94gJyVOtzNM+qGka7vvhkBZMLrEEDusNF8=; b=DFch6TlWvHU3BjCFhugwRc0uJ9IFby1P4WNiK8cTIU1UdggWNFcKpuznFtq8NjfW0R ylax0kvSksRMTx3SSnv/Aaozm1tA5sFgtIfcLSi/W5+FlZ25LIspLehEZMEAVOAbcHou WSt96xXlu66XmKc3Em9cQhCzVMEbKpxTOFqB7gAgzPXD3DesLBlat6fmMs6lIFs+FLy2 kVDkLSiaJ9oTzoLTAVg6CTcAL5Vj9Xqm2wZm/xUz4Q2Xe+aHb+OyF0L6jmJszHXG98vu stZGI/cEpUev7dtRXjRuuYu6ox5csQPt+S8yvaZ8+stUnd/LO0SyUdgSjm/NbCxdbcFm PHrg== 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=6E4+VPjtB94gJyVOtzNM+qGka7vvhkBZMLrEEDusNF8=; b=LC45LGQeWZT2qiqVDry9ZGgn8NgNVb77lXRJtZndmjetxCdctG/Bepm9pU9lr5Wsyr ZzuIyozNHFdyP5WKbsB5nz3dj0sUFZzn9//zxRccr025HZBebQckV3ZMajX5zwdDRal1 Mkv/Ra6q1ELPxViVpGqSKuzRyiCXkw6WO08kjZ3g2rzSHR/l5F7jXu2U/Hu07tJCheS0 ugQld8dUEp6RozL2minwF6QAQK6m5CmERTXq/Jyi2sCLD5bU5pv8AnBGpz3IXgbHjfc0 3Zg3DIpamcWn6PxnFY6yUL5VtUdtUeMHyVrW/qoSvcqin4GopTX2yvcCCqeKiEX2y8ib XvwA== X-Gm-Message-State: ABuFfohiaWNZiSSA3tBxVC+fy74mg95r2p7ccQSBup/bKJ7jmGEJEs54 XpCkxniq13O+ZMS9tEU+vHhXmA== X-Google-Smtp-Source: ACcGV63LfsE3461zNLXOFeDMzsJgBaNQTjjw/sXPLWbNtKpDZCLuC4pwSEfcO96nQKkwH748H0caLw== X-Received: by 2002:a5d:61c1:: with SMTP id q1-v6mr150645wrv.33.1537815868736; Mon, 24 Sep 2018 12:04:28 -0700 (PDT) Received: from localhost.localdomain ([51.15.160.169]) by smtp.googlemail.com with ESMTPSA id e141-v6sm27721433wmd.32.2018.09.24.12.04.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Sep 2018 12:04:28 -0700 (PDT) From: Corentin Labbe To: Gilles.Muller@lip6.fr, Julia.Lawall@lip6.fr, agust@denx.de, airlied@linux.ie, 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, narmstrong@baylibre.com, 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 v2 2/7] include: add setbits32/clrbits32/clrsetbits32/setbits64/clrbits64/clrsetbits64 in linux/setbits.h Date: Mon, 24 Sep 2018 19:04:11 +0000 Message-Id: <1537815856-31728-3-git-send-email-clabbe@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537815856-31728-1-git-send-email-clabbe@baylibre.com> References: <1537815856-31728-1-git-send-email-clabbe@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180924_120500_490722_018473EB X-CRM114-Status: GOOD ( 11.41 ) 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, dri-devel@lists.freedesktop.org, linux-ide@vger.kernel.org, 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 | 88 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 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..6e7e257134ae --- /dev/null +++ b/include/linux/setbits.h @@ -0,0 +1,88 @@ +/* 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) | (set)) & ~(mask)), addr) + +#ifndef setbits_le32 +#define setbits_le32(addr, set) __setbits(readl, writel, addr, set) +#endif +#ifndef setbits_le32_relaxed +#define setbits_le32_relaxed(addr, set) __setbits(readl_relaxed, writel_relaxed, \ + addr, set) +#endif + +#ifndef clrbits_le32 +#define clrbits_le32(addr, mask) __clrbits(readl, writel, addr, mask) +#endif +#ifndef clrbits_le32_relaxed +#define clrbits_le32_relaxed(addr, mask) __clrbits(readl_relaxed, writel_relaxed, \ + addr, mask) +#endif + +#ifndef clrsetbits_le32 +#define clrsetbits_le32(addr, mask, set) __clrsetbits(readl, writel, addr, mask, set) +#endif +#ifndef clrsetbits_le32_relaxed +#define clrsetbits_le32_relaxed(addr, mask, set) __clrsetbits(readl_relaxed, \ + writel_relaxed, \ + addr, mask, set) +#endif + +#ifndef setclrbits_le32 +#define setclrbits_le32(addr, mask, set) __setclrbits(readl, writel, addr, mask, set) +#endif +#ifndef setclrbits_le32_relaxed +#define setclrbits_le32_relaxed(addr, mask, set) __setclrbits(readl_relaxed, \ + writel_relaxed, \ + addr, mask, set) +#endif + +/* We cannot use CONFIG_64BIT as some x86 drivers use non-atomicwriteq() */ +#if defined(writeq) && defined(readq) +#ifndef setbits_le64 +#define setbits_le64(addr, set) __setbits(readq, writeq, addr, set) +#endif +#ifndef setbits_le64_relaxed +#define setbits_le64_relaxed(addr, set) __setbits(readq_relaxed, writeq_relaxed, \ + addr, set) +#endif + +#ifndef clrbits_le64 +#define clrbits_le64(addr, mask) __clrbits(readq, writeq, addr, mask) +#endif +#ifndef clrbits_le64_relaxed +#define clrbits_le64_relaxed(addr, mask) __clrbits(readq_relaxed, writeq_relaxed, \ + addr, mask) +#endif + +#ifndef clrsetbits_le64 +#define clrsetbits_le64(addr, mask, set) __clrsetbits(readq, writeq, addr, mask, set) +#endif +#ifndef clrsetbits_le64_relaxed +#define clrsetbits_le64_relaxed(addr, mask, set) __clrsetbits(readq_relaxed, \ + writeq_relaxed, \ + addr, mask, set) +#endif + +#ifndef setclrbits_le64 +#define setclrbits_le64(addr, mask, set) __setclrbits(readq, writeq, addr, mask, set) +#endif +#ifndef setclrbits_le64_relaxed +#define setclrbits_le64_relaxed(addr, mask, set) __setclrbits(readq_relaxed, \ + writeq_relaxed, \ + addr, mask, set) +#endif + +#endif /* writeq/readq */ + +#endif /* __LINUX_SETBITS_H */