[PATCH v1 1/3] Outsourced sensor masks to PCI driver header.

From: mail
Date: Wed Jan 27 2021 - 10:44:35 EST


From: Richard Neumann <mail@xxxxxxxxxxxxxxxxxx>

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@xxxxxxxxxxxxxxxxxx>
---
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