From patchwork Wed Jan 11 17:42:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 9510825 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CD8456075C for ; Wed, 11 Jan 2017 17:42:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC414284E6 for ; Wed, 11 Jan 2017 17:42:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B132D285BB; Wed, 11 Jan 2017 17:42:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55362284E6 for ; Wed, 11 Jan 2017 17:42:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030982AbdAKRm4 (ORCPT ); Wed, 11 Jan 2017 12:42:56 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:34351 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937680AbdAKRmx (ORCPT ); Wed, 11 Jan 2017 12:42:53 -0500 Received: by mail-pf0-f194.google.com with SMTP id y143so12197139pfb.1; Wed, 11 Jan 2017 09:42:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WINgmP2jSdXKCBU7aDUxJOK/3pcIFsYxqpEHkipfWBc=; b=eRYnBBw8zzWiTmw+fFyBybvEHIJSvTg+wnKi6uN66wARY1iyoqoPdEcIgRFjYrIDFk M1ms3yIuWkWuK9LbCcpq0AmEQ9ZsbgXJLOIqQ+pfrPTo6EEyJ/ULXWpYjCqmyxglSGWA hvs3jxeCsJjnj1vRmD7krNyA/eDGWqdGOfRQGHWjIkSqMu5+YTdkZSfuBzrDslwdhy/Z KYznHCyIa1OTKPJ6ODoXHjMfA2+asO2HvqNfJ5Phi7KOLs1rwx3DloZoHZOkQE83Tkwb 44U69rTxlpQ+rD9nSZJPqUqeOX3JHaQQLfRy/a6sE3TBdNpTftV0eYQ6tIJOyaNj/Cfx uVqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WINgmP2jSdXKCBU7aDUxJOK/3pcIFsYxqpEHkipfWBc=; b=Xui1TC5E8B36oiov2CPNgTcLAe3VWHJ5kG2gv96cySnvMCZiRc/zr6D3YdDkw+/tfS bKzHkuUUBfolbufDqaXKh0z/owhTrQ4+Byt9TFul5htbAVonDo11Fsn/7+//njZLdA2A SgyEp8f313FM7tR5e3E+sU7f7ZzIy9bjAMXIlbqxtfVsypGJLlEN+OT1p4/Fvc5XJN8Q 70meyiehbiA+RyEPelUUhZhYGI/dtiaC77k6dW8TvNZwSc7kNXh4gFu90PuLO1TbbfJ7 HEcg2b7jl8/BGv28NCVXar5xOLdhZC5F6eON7o05Xbdsps3zqnyHaB/3lpkUHSKdnkVY jpxA== X-Gm-Message-State: AIkVDXJB1Q2DHSkUSJZF14PxFt4qa1kwpvczr/804RPSSuHrjgGRb7RajMSoDKd5E9c+Xw== X-Received: by 10.98.13.90 with SMTP id v87mr11574374pfi.54.1484156573117; Wed, 11 Jan 2017 09:42:53 -0800 (PST) Received: from localhost.localdomain ([240f:4:c2bc:1:9509:afdd:5ccb:93b]) by smtp.gmail.com with ESMTPSA id d69sm15350651pfd.11.2017.01.11.09.42.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jan 2017 09:42:52 -0800 (PST) From: Akinobu Mita To: linux-input@vger.kernel.org, devicetree@vger.kernel.org Cc: Akinobu Mita , Dmitry Torokhov Subject: [PATCH 3/5] Input: mpr121 - handle multiple bits change of status register Date: Thu, 12 Jan 2017 02:42:27 +0900 Message-Id: <1484156549-26585-4-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484156549-26585-1-git-send-email-akinobu.mita@gmail.com> References: <1484156549-26585-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This driver reports input events on their interrupts which are triggered by the sensor's status register changes. But only single bit change is reported in the interrupt handler. So if there are multiple bits are changed at almost the same time, other press or release events are ignored. This fixes it by detecting all changed bits in the status register. Cc: Dmitry Torokhov Signed-off-by: Akinobu Mita --- drivers/input/keyboard/mpr121_touchkey.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/input/keyboard/mpr121_touchkey.c b/drivers/input/keyboard/mpr121_touchkey.c index a2c5305..c809f70 100644 --- a/drivers/input/keyboard/mpr121_touchkey.c +++ b/drivers/input/keyboard/mpr121_touchkey.c @@ -86,7 +86,8 @@ static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id) struct mpr121_touchkey *mpr121 = dev_id; struct i2c_client *client = mpr121->client; struct input_dev *input = mpr121->input_dev; - unsigned int key_num, key_val, pressed; + unsigned int bit_changed; + unsigned int key_num; int reg; reg = i2c_smbus_read_byte_data(client, ELE_TOUCH_STATUS_1_ADDR); @@ -104,18 +105,25 @@ static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id) reg &= TOUCH_STATUS_MASK; /* use old press bit to figure out which bit changed */ - key_num = ffs(reg ^ mpr121->statusbits) - 1; - pressed = reg & (1 << key_num); + bit_changed = reg ^ mpr121->statusbits; mpr121->statusbits = reg; + for (key_num = 0; key_num < mpr121->keycount; key_num++) { + unsigned int key_val, pressed; - key_val = mpr121->keycodes[key_num]; + if (!(bit_changed & (1 << key_num))) + continue; - input_event(input, EV_MSC, MSC_SCAN, key_num); - input_report_key(input, key_val, pressed); - input_sync(input); + pressed = reg & (1 << key_num); + key_val = mpr121->keycodes[key_num]; + + input_event(input, EV_MSC, MSC_SCAN, key_num); + input_report_key(input, key_val, pressed); + + dev_dbg(&client->dev, "key %d %d %s\n", key_num, key_val, + pressed ? "pressed" : "released"); - dev_dbg(&client->dev, "key %d %d %s\n", key_num, key_val, - pressed ? "pressed" : "released"); + } + input_sync(input); out: return IRQ_HANDLED;