linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: mail@richard-neumann.de
To: nehal-bakulchandra.shah@amd.com, sandeep.singh@amd.com,
	mail@richard-neumann.de, jikos@kernel.org,
	benjamin.tissoires@redhat.com, arnd@arndb.de,
	linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Subject: [PATCH v2 1/3] Outsourced sensor masks to PCI driver header.
Date: Wed, 27 Jan 2021 17:25:58 +0100	[thread overview]
Message-ID: <20210127162600.35927-2-mail@richard-neumann.de> (raw)
In-Reply-To: <20210127162600.35927-1-mail@richard-neumann.de>

From: Richard Neumann <mail@richard-neumann.de>

Outsourced the mask definitions of the four sensors into
the PCI device driver header file for later use with the quirks.
Also renamed the values from *_EN to *_MASK to emphasize that
they are actually sensor bitmasks for matching against activestatus.

Signed-off-by: Richard Neumann <mail@richard-neumann.de>
---
 drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 13 ++++---------
 drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
index dbac16641662..4b0ceb2ee86a 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
@@ -20,11 +20,6 @@
 #define DRIVER_NAME	"pcie_mp2_amd"
 #define DRIVER_DESC	"AMD(R) PCIe MP2 Communication Driver"
 
-#define ACEL_EN		BIT(0)
-#define GYRO_EN		BIT(1)
-#define MAGNO_EN		BIT(2)
-#define ALS_EN		BIT(19)
-
 void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info)
 {
 	union sfh_cmd_param cmd_param;
@@ -79,16 +74,16 @@ int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id)
 
 	privdata->activecontrolstatus = readl(privdata->mmio + AMD_P2C_MSG3);
 	activestatus = privdata->activecontrolstatus >> 4;
-	if (ACEL_EN  & activestatus)
+	if (ACCEL_MASK  & activestatus)
 		sensor_id[num_of_sensors++] = accel_idx;
 
-	if (GYRO_EN & activestatus)
+	if (GYRO_MASK & activestatus)
 		sensor_id[num_of_sensors++] = gyro_idx;
 
-	if (MAGNO_EN & activestatus)
+	if (MAGNO_MASK & activestatus)
 		sensor_id[num_of_sensors++] = mag_idx;
 
-	if (ALS_EN & activestatus)
+	if (ALS_MASK & activestatus)
 		sensor_id[num_of_sensors++] = als_idx;
 
 	return num_of_sensors;
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
index 8f8d19b2cfe5..a39f02352c3b 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
@@ -57,6 +57,20 @@ enum sensor_idx {
 	als_idx = 19
 };
 
+/**
+ * Bit masks for sensors matching.
+ * @ACCEL_MASK:	Bit mask of the accelerometer
+ * @GYRO_MASK:	Bit mask of the gyroscope
+ * @MAGNO_MASK:	Bit mask of the magnetometer
+ * @ALS_MASK:	Bit mask of the ambient light sensor
+ */
+enum sensor_mask {
+	ACCEL_MASK = BIT(accel_idx),
+	GYRO_MASK = BIT(gyro_idx),
+	MAGNO_MASK = BIT(mag_idx),
+	ALS_MASK = BIT(als_idx),
+};
+
 struct amd_mp2_dev {
 	struct pci_dev *pdev;
 	struct amdtp_cl_data *cl_data;
-- 
2.30.0


  reply	other threads:[~2021-01-27 16:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27 16:25 [PATCH v2 0/3] Add quirks to AMD Sensor Fusion Hub driver mail
2021-01-27 16:25 ` mail [this message]
2021-01-27 16:25 ` [PATCH v2 2/3] Added quirks to detect sensor masks mail
2021-01-27 16:26 ` [PATCH v2 3/3] Updated MAINTAINERS mail
2021-02-09  9:39 ` [PATCH v2 0/3] Add quirks to AMD Sensor Fusion Hub driver Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210127162600.35927-2-mail@richard-neumann.de \
    --to=mail@richard-neumann.de \
    --cc=arnd@arndb.de \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nehal-bakulchandra.shah@amd.com \
    --cc=sandeep.singh@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).