Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp279603ybl; Thu, 12 Dec 2019 18:12:23 -0800 (PST) X-Google-Smtp-Source: APXvYqyYHj9O65LQxWWvljISQC8faf+ZJJ3z/qZ+NEcDw7fA9tFs1Bjl3LaEfR8xr8mhsyfzFT4g X-Received: by 2002:a05:6830:1ed0:: with SMTP id c16mr11455710otj.21.1576203143206; Thu, 12 Dec 2019 18:12:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576203143; cv=none; d=google.com; s=arc-20160816; b=Oo0BAD0bDZqKfmhSlgY/pGSDAPQxV2U0ogGlYKjIb3+z04ttCzSmJn/LdON/a5O9SD zQMRHDAhmdZS1XB0AyBU/BnfqtlHIzSck2ogY/LGwGljuoux7cuufPzvHXCtTW25v4iZ G4rLDBvwkzVPIE6FQZRwOuJBehjBfq9C1xWN8QwFAVTh0rE08nhcNY1HUiipSBhENwdM h5fWiDBjsvGPXRrHnj0dHFcmMefpyuWZkiaJuelZsOazZoYcZTT6kOIU2Viv5bz51Uo2 zhbZ3UNfQ4/Xzln7kmo8mt59QHjIJ5dfby8b+bbFtSH5qzVmwWvmeYCgCv0IXNk2JM3x XnPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=/dvyckOCe0xQTHoyT4AWzPK5ChSol26DHIghgERlVLk=; b=eZGmodmYKiePJsg437SEoxBTb5S3AP0VVjj0xFxQ5BPdQ70jqqHEk/Ln3IMLORxUip mYqKXeyx1gkneqMlVf2HJ+Kl8+WxRpFau8v/HOxcOfiDGp6zhPDKJolmAUNNejPW+3DQ ZcCgFapKhCHNGdaHiolQIA41TVba7ZGBVIAIJgNMRJQQ3N6a1/OHoteBc06QN9RFdQdr caSusnGk3wSCWNU8igzHeWqTxDPtn4HIxebYjd1VGwJ08myqUfUkIil/07KAY6BP9eNZ fXw+OpbK0UqPrKmlHER0j7NWNPVnNDAdWhsQkGznY3kqJjs5HXEIFK4O9k5UPiRIsaYr eBng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x126si4176184oix.53.2019.12.12.18.12.05; Thu, 12 Dec 2019 18:12:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731914AbfLMCLJ (ORCPT + 99 others); Thu, 12 Dec 2019 21:11:09 -0500 Received: from inva020.nxp.com ([92.121.34.13]:54430 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727778AbfLMCLJ (ORCPT ); Thu, 12 Dec 2019 21:11:09 -0500 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id C9ED61A0149; Fri, 13 Dec 2019 03:11:07 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 4E73F1A031E; Fri, 13 Dec 2019 03:11:03 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 7474640296; Fri, 13 Dec 2019 10:10:57 +0800 (SGT) From: Anson Huang To: dmitry.torokhov@gmail.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, robh@kernel.org, linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Linux-imx@nxp.com Subject: [PATCH] input: keyboard: imx_sc_key: Only take the valid data from SCU firmware as key state Date: Fri, 13 Dec 2019 10:08:29 +0800 Message-Id: <1576202909-1661-1-git-send-email-Anson.Huang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When reading key state from SCU, the response data from SCU firmware is 4 bytes due to MU message protocol, but ONLY the first byte is the key state, other 3 bytes could be some dirty data, so we should ONLY take the first byte as key state to avoid reporting incorrect state. Signed-off-by: Anson Huang --- drivers/input/keyboard/imx_sc_key.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/input/keyboard/imx_sc_key.c b/drivers/input/keyboard/imx_sc_key.c index 5379952..9f809ae 100644 --- a/drivers/input/keyboard/imx_sc_key.c +++ b/drivers/input/keyboard/imx_sc_key.c @@ -78,7 +78,13 @@ static void imx_sc_check_for_events(struct work_struct *work) return; } - state = (bool)msg.state; + /* + * The response data from SCU firmware is 4 bytes, + * but ONLY the first byte is the key state, other + * 3 bytes could be some dirty data, so we should + * ONLY take the first byte as key state. + */ + state = (bool)(msg.state & 0xff); if (state ^ priv->keystate) { priv->keystate = state; -- 2.7.4