Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp592382pxb; Wed, 27 Jan 2021 16:06:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIpCyvIK/LeFQWnB9UFa5gzukowNFARWbda9M5RtEw0dFXNwhLPgGtSc8ATQ2Linzm4wZQ X-Received: by 2002:aa7:cdcb:: with SMTP id h11mr11358597edw.237.1611792401444; Wed, 27 Jan 2021 16:06:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611792401; cv=none; d=google.com; s=arc-20160816; b=QS0t10wpUZFTTaR4pja5eggDhC/7kDC/UPluA2iWp0ACzlzZcG/sym6w034bC+8srJ fAcxcSwhq60WgOI92Iqa3zVK53LCZgHOIsHkrtkg3SwtjJVmnBYmZUktMKlzWd1tBscl 8bfCqWy1HFdODr4lQkrBj+CLT0G6KTd/zrcHxkq3mt/vb4f1XTJe5eNfGMf/USqKleFJ LQUrjEQxg1ITxp4WO3wzmM80CDWl+m99A8lVnKJ0CUuvDIjQhUPDvcJnaFAZuoZxCNNb vGQKoHeak5QWw26hKPGWKjRLc/xjaBFKUNntsj/NEyez0S+zyx7EQH2UunlbE3Fo6KJP SECA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from; bh=7tvemJhpXKH8U5m4fHuzqZrInZ40ukMMd/PnpaLjoUA=; b=O46f8ogNlhBQ8Zlt26kBsv/FoSGLN1TWaViwYwsBjE6WuXaOebw5zcscyiG4uAizAP +ToFGAbS9zfMh1QBNG4s+Zh0ZM39J94CSizgepI0Ght4z5DO1bI5c6aP/Q3dVDjQY1W6 AJjYyM+qoCQUXxMzIGSLJ6T08RNrINr3A+q1KYf+tgj0tHSTvSa56Tmmyl42EXQMDlf1 njCqytxQr0vNzhG51UBshgtZtViJOe12oqAuRrOaErXp6Dw0I5w7kBFARm4f6OwPtGA2 ilYqtTzfZuOVaSKh/cadIFC/tdwPvQ3+IYvlrCnT/slPyGDyhIIM6ob7DkWl/zTpA2nM SCXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dc22si60998edb.145.2021.01.27.16.06.18; Wed, 27 Jan 2021 16:06:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343977AbhA0Q26 (ORCPT + 99 others); Wed, 27 Jan 2021 11:28:58 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:38999 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343771AbhA0Q2x (ORCPT ); Wed, 27 Jan 2021 11:28:53 -0500 Received: from envy.fritz.box ([82.207.222.125]) by mrelayeu.kundenserver.de (mreue010 [213.165.67.97]) with ESMTPSA (Nemesis) id 1Ml6Vg-1lpzxw0zBE-00lUNz; Wed, 27 Jan 2021 17:26:04 +0100 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 Message-Id: <20210127162600.35927-2-mail@richard-neumann.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210127162600.35927-1-mail@richard-neumann.de> References: <20210127162600.35927-1-mail@richard-neumann.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:mFABr6ZjPwfKAm12WSrIGFP1FF7lE2KsykK9TtzaZdc6lsrfm9h PfwThXyLy5crws55dfhXAkgk/0ECkykqHG4ZaAKvq1k37I34DxQAx//v6CJMZjlp+kiqke9 MxosF1jOk5qbhoxY+4AjHbI30F1N+MbEVGckErquWCAQmOBqBFxmrsgsFjUdTcW/B0PTR0W EKb5c+FN1SXSbJXAsqvKw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:sh8ePC+axWs=:U/YfR4WCjWSbIelt4WeMRc ngqxx4aDOC3JP+HRLrxN6xE4nfVJZ/Uu3P8GfrS8wPodAjKJhrE2RZJHRSoSBfjhPisazzgCI TDs5fEBYug16jFXE60UXYX7jx2zrTsXgIheP3zELlnajyOzKKehvfXJP4ON13Qs8xbZE9L374 cQCqynh4CsZ1dtH55K8ux1FE43ejiMSZ2AfQqcxT6z6S7uGBUUZ5LS6HhNyI1CYo7Jn8GtXsn xOoSg/oEq4Q8Z5vj2zfXqlJarFhXLIDYg72V96YVP3xLwBW517tXrUBlTIRZEqswgjgvuqHeo 9msiwzbfPXaQ3+MBR4l+YAzO2ebDfLM16B6U97DK/ul9Ea7ja8qytJiTxPxe3Dxtczl9/fkVU EiJ25vdr+7mUrsD0LpOvRuD23W94r7iOoYvSgfM8k6QloOnmVOr+4KEa7GZINqVGYJlQ+56bh dUE15o63AA== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Richard Neumann 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 --- 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