Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp24253lqz; Fri, 29 Mar 2024 07:29:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWdJxHakK/tHQR7687VP+npZ4L/by+0KMNZeTKESN1JwLA8aVMXsgsWu/ytPgIT5Nt3Mbv9Db6/HqPpMQQHOe0sFQIkW1ninQBahla0pg== X-Google-Smtp-Source: AGHT+IGJg4diRvE4hw3ThQ5IZ9dO78+fA657/tiebGlpgF8pIO5/wQEQ3+TS+o2DPMapKGZyFYUS X-Received: by 2002:a05:6a20:9586:b0:1a3:4df6:b3a1 with SMTP id iu6-20020a056a20958600b001a34df6b3a1mr3489574pzb.30.1711722566939; Fri, 29 Mar 2024 07:29:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711722566; cv=pass; d=google.com; s=arc-20160816; b=Fg2+U6xTkrRDjAGzVhdcRZ+eUT5+i3SWHsfyUDE1NW4eGpAycHc/bmENmXNBl1zfVe KhgW62t3wSB17Y1CEJ6d3mklxgKP0kWfqV8dYO53TqI/OJC9680i57F/2GsdfDYgXOKR AHvEMY2vt2Jhg57/L63Q9cJE8iSBWpbCG+Uy5cGfM5UNCWBQhRONJMbdsFU10YIEGKKw hIPufoAkFz2bNd0KRO6hWJn8JZouJqKx0mAIb2kUuCskx5a5P4veXiH2AYjw5pwSjQ+h RiOS77whx12OOoCM5KioKOX+WYa4dSw0JiRURWbKX4D9LfDsdSLJD2QGZ1JUC+pksK7E uL0w== 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:dkim-signature; bh=knpN3Pv0EV7g7xeQfW0XX4A7pDGDUJ/Z9c2fHNruZ8U=; fh=TWTyTjU6SFQTzyWjbOYv6OxpKkNnC4lPeb9vj3E1sW4=; b=lmRQRTeGGt9y9l45gw5ywhu5om1CO3o7otDsL25Ykw/RIkrltO7XtzcMHEqhc3Zq3A KYPx91q9MLUWBB+mDeOnbAndSYVpJNoqFT/n7BEqHjYpigBVMoz3uYwAaFHbR/m/f5Iq 9/IWTUFs8ElgQ9hiBSvOlOMmnHap5Jy4TiW7jNHAVgVudlJjWBRakTIAfHsVvzRdIBss 7DzbMR0I5OeUoA3JwMeGqeY0M2+cElPRnTduSHtAlhAeoZbjy0stDalhpUv4dOCbHoXD 542CGeQEZTfXb54cKcEhBzAgbWXs8/ynQhCgPy6rYsRwcJM3y6hYJqKEg8Sd6kw4dtjc HBSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z8JvhvO+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124930-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124930-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id jw23-20020a056a00929700b006eadf8e8b12si2925587pfb.359.2024.03.29.07.29.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:29:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124930-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z8JvhvO+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124930-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124930-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 93305280294 for ; Fri, 29 Mar 2024 14:29:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F311F14D283; Fri, 29 Mar 2024 12:47:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z8JvhvO+" 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 050F41A4C27; Fri, 29 Mar 2024 12:47:25 +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=1711716446; cv=none; b=g5xBYiriBcOcQhozOD0bkNaooJiWRpnib+Y5Okddnid4nePjsyZAW1/SBlDGjRgiSsnfuRRaaNYAf3PSzPOF3B9ctD88h1d8qpSHfePxqXgoUd4K2Vot3WM8yy/w+zjqtmDi4LdyP+ilWmoSuBZkPdPmcBMy67LYDPeSGKs4Mis= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716446; c=relaxed/simple; bh=Mn7N1ozQqdE6mhvio1X9Hr3zBPDlDOlw/tcFv09VTWQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=r/lsdYtzmwT5VB/+zkhxD4Ju54z0fapA7VegAnmJFOPvecuiAa/6vHxbDtnz+k/11SbIquvwb3uyDwBUNWXYDNfbvQcyRghGTPmYAGDP71TGd6bTFOspMrHp1J9buKXmMWwUi78jd3aUct1WUL927V6JiuKBcUN4u/s5dKpbwV0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z8JvhvO+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8E46C433C7; Fri, 29 Mar 2024 12:47:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711716445; bh=Mn7N1ozQqdE6mhvio1X9Hr3zBPDlDOlw/tcFv09VTWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z8JvhvO+nwkLvX3TyOWwOkZ2HaFC80AESUx08vt7cRM4IQ8d7h5/9Bx8ZJokuRZ+4 JIkjfI/gyEJjtXxhsnDmnk1jRwaHJrya8IdbXKdrPiaK3tRrhZfVrHaDyyIyH56G8Z 2dWgFSx41tkPmj2EC19iGSJKx7qy7cEre1kAkJt3C3LNpjOnVyilcgh6cfTyfRm8W7 1ao/oe6DVqB1rOezDwWO3YCwMC1nvAdSwIRnTqhh2aO24ASozieah6vZr+m69qo2jc tWeEndXjXqX8HpB/VAZjbnZU6T8GcEvUgge7WWPRoKGx91li8ZZNZzF8GO7HMAr+20 tAcb6a+cxoGvA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Duje=20Mihanovi=C4=87?= , Dmitry Torokhov , Sasha Levin , markuss.broks@gmail.com, linux-input@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 46/52] Input: imagis - use FIELD_GET where applicable Date: Fri, 29 Mar 2024 08:45:40 -0400 Message-ID: <20240329124605.3091273-46-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329124605.3091273-1-sashal@kernel.org> References: <20240329124605.3091273-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.83 Content-Transfer-Encoding: 8bit From: Duje Mihanović [ Upstream commit c0ca3dbd03d66c6b9e044f48720e6ab5cef37ae5 ] Instead of manually extracting certain bits from registers with binary ANDs and shifts, the FIELD_GET macro can be used. With this in mind, the *_SHIFT macros can be dropped. Signed-off-by: Duje Mihanović Link: https://lore.kernel.org/r/20240306-b4-imagis-keys-v3-1-2c429afa8420@skole.hr Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- drivers/input/touchscreen/imagis.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/input/touchscreen/imagis.c b/drivers/input/touchscreen/imagis.c index 400d53eae9424..fecda5cdc482b 100644 --- a/drivers/input/touchscreen/imagis.c +++ b/drivers/input/touchscreen/imagis.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only +#include #include #include #include @@ -29,12 +30,9 @@ #define IST3038C_I2C_RETRY_COUNT 3 #define IST3038C_MAX_FINGER_NUM 10 #define IST3038C_X_MASK GENMASK(23, 12) -#define IST3038C_X_SHIFT 12 #define IST3038C_Y_MASK GENMASK(11, 0) #define IST3038C_AREA_MASK GENMASK(27, 24) -#define IST3038C_AREA_SHIFT 24 #define IST3038C_FINGER_COUNT_MASK GENMASK(15, 12) -#define IST3038C_FINGER_COUNT_SHIFT 12 #define IST3038C_FINGER_STATUS_MASK GENMASK(9, 0) struct imagis_properties { @@ -106,8 +104,7 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id) goto out; } - finger_count = (intr_message & IST3038C_FINGER_COUNT_MASK) >> - IST3038C_FINGER_COUNT_SHIFT; + finger_count = FIELD_GET(IST3038C_FINGER_COUNT_MASK, intr_message); if (finger_count > IST3038C_MAX_FINGER_NUM) { dev_err(&ts->client->dev, "finger count %d is more than maximum supported\n", @@ -115,7 +112,7 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id) goto out; } - finger_pressed = intr_message & IST3038C_FINGER_STATUS_MASK; + finger_pressed = FIELD_GET(IST3038C_FINGER_STATUS_MASK, intr_message); for (i = 0; i < finger_count; i++) { if (ts->tdata->protocol_b) @@ -136,12 +133,11 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id) input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, finger_pressed & BIT(i)); touchscreen_report_pos(ts->input_dev, &ts->prop, - (finger_status & IST3038C_X_MASK) >> - IST3038C_X_SHIFT, - finger_status & IST3038C_Y_MASK, 1); + FIELD_GET(IST3038C_X_MASK, finger_status), + FIELD_GET(IST3038C_Y_MASK, finger_status), + true); input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, - (finger_status & IST3038C_AREA_MASK) >> - IST3038C_AREA_SHIFT); + FIELD_GET(IST3038C_AREA_MASK, finger_status)); } input_mt_sync_frame(ts->input_dev); -- 2.43.0