From patchwork Wed Aug 18 15:49:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair X-Patchwork-Id: 499988 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.7 required=3.0 tests=BAYES_00, DATE_IN_PAST_12_24, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C4EBC4338F for ; Thu, 19 Aug 2021 11:21:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3676E610D2 for ; Thu, 19 Aug 2021 11:21:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238912AbhHSLV4 (ORCPT ); Thu, 19 Aug 2021 07:21:56 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:51437 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238828AbhHSLVs (ORCPT ); Thu, 19 Aug 2021 07:21:48 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 88E28580C0E; Thu, 19 Aug 2021 07:21:12 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 19 Aug 2021 07:21:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alistair23.me; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=sudXsL0XPHhcq 21swpLW5Hc8hH7ACZW0Krc92I1Upyo=; b=epf/JGchTVtEAe4Qi35cQdLR2q1sJ /OwIjYoQr97Ajoo8QoQRayVGwzgs7E56r82NEJBoyXFK22FWMgkZI8NrKpjVGeOe hjDqJYzpcvxlXzwkxH1ryAP5ixvDBVIoEFFiPzSkkf0deb5gk8MrxXZMwNySY3x+ v4vR0aMjWVtO1roEZOXcfhHz9UXZ0zSTrfOh3ibho5GLidUl4PJXvY0gzJKabuY8 EEmOMPKh1Yxcxy36vK+k1ZHVsbMDp9DZ9yr/wyPzehJIYTRwxYivjElICaL1uJ7S O1H5a/GdoEYJrMaB/i3SRp1T1jUXaUMBzybmcywHrGFKM2CZuvz5aM3kg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=sudXsL0XPHhcq21swpLW5Hc8hH7ACZW0Krc92I1Upyo=; b=DkCLnlal l2i5lh6cQc0LMeh3PAn08CtfGR2bwOCMfCK0CAWMkv85V/+JfgD8YIAtQpn0no+H ZDOhAnvGmnFiUUO25pstFbuVkXYBYpztlFZ+YgKj6+Rbq/uU4qUtMdPMBXVXycIC 49AW78uBSrBruNLuVg7ZF1iiXvt0dD7vnCcA00Zydc/JhvKg+x6oMh+Enidj3OSO +NOQUy50az5Sdgbn7M044hKbJtJB4g56zCiFx/Xz/tVAS/ZEGuJqw0FPF6shpcWt Stgr8c4XhbHAj7SnFzS0Bdu0Ao3JeNVl8Huz8fGr3rxkibaOWcZlQmE2TLWQmBnP R3ntL6tVPFcyUA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrleejgdefjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpeetlhhishhtrghirhcuhfhrrghntghishcuoegrlhhishhtrghi rhesrghlihhsthgrihhrvdefrdhmvgeqnecuggftrfgrthhtvghrnhepgeegtdetjeekge eguefgheeuvedugedvteejveeiudegvddtkeffkeehtdetudfhnecuvehluhhsthgvrhfu ihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomheprghlihhsthgrihhrsegrlhhish htrghirhdvfedrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 19 Aug 2021 07:21:08 -0400 (EDT) From: Alistair Francis To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, pinglinux@gmail.com, tatsunosuke.tobita@wacom.com, junkpainting@gmail.com, ping.cheng@wacom.com Cc: linux-kernel@vger.kernel.org, alistair23@gmail.com, robh+dt@kernel.org, devicetree@vger.kernel.org, Alistair Francis Subject: [PATCH v9 08/11] Input: wacom_i2c - Use macros for the bit masks Date: Thu, 19 Aug 2021 01:49:32 +1000 Message-Id: <20210818154935.1154-9-alistair@alistair23.me> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210818154935.1154-1-alistair@alistair23.me> References: <20210818154935.1154-1-alistair@alistair23.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org To make the code easier to read use macros for the bit masks. Signed-off-by: Alistair Francis --- drivers/input/touchscreen/wacom_i2c.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/wacom_i2c.c b/drivers/input/touchscreen/wacom_i2c.c index fd486b8ef2cc..c6579a1a8d04 100644 --- a/drivers/input/touchscreen/wacom_i2c.c +++ b/drivers/input/touchscreen/wacom_i2c.c @@ -18,6 +18,14 @@ #include #include +// Bitmasks (for data[3]) +#define WACOM_TIP_SWITCH_bm (1 << 0) +#define WACOM_BARREL_SWITCH_bm (1 << 1) +#define WACOM_ERASER_bm (1 << 2) +#define WACOM_INVERT_bm (1 << 3) +#define WACOM_BARREL_SWITCH_2_bm (1 << 4) +#define WACOM_IN_RANGE_bm (1 << 5) + // Registers #define WACOM_COMMAND_LSB 0x04 #define WACOM_COMMAND_MSB 0x00 @@ -148,10 +156,10 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id) if (error < 0) goto out; - tsw = data[3] & 0x01; - ers = data[3] & 0x04; - f1 = data[3] & 0x02; - f2 = data[3] & 0x10; + tsw = data[3] & WACOM_TIP_SWITCH_bm; + ers = data[3] & WACOM_ERASER_bm; + f1 = data[3] & WACOM_BARREL_SWITCH_bm; + f2 = data[3] & WACOM_BARREL_SWITCH_2_bm; x = le16_to_cpup((__le16 *)&data[4]); y = le16_to_cpup((__le16 *)&data[6]); pressure = le16_to_cpup((__le16 *)&data[8]);