From patchwork Sun Jan 15 13:15:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 9517405 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 55A7E601DA for ; Sun, 15 Jan 2017 13:16:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CAE7283FB for ; Sun, 15 Jan 2017 13:16:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41C58283FF; Sun, 15 Jan 2017 13:16:14 +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 DDC18283FB for ; Sun, 15 Jan 2017 13:16:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751099AbdAONQN (ORCPT ); Sun, 15 Jan 2017 08:16:13 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:35385 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751077AbdAONQM (ORCPT ); Sun, 15 Jan 2017 08:16:12 -0500 Received: by mail-pg0-f68.google.com with SMTP id 204so2984415pge.2; Sun, 15 Jan 2017 05:16:11 -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=zjIO5qKmxFdmhc6AUSogoHYSBFOqMz6Dr3txNIKmh44=; b=Utk3vc9PcoLX4Z1+oOWVbPmhUKLJTeo0NGo/RRjOV7W7m+qjFQrYjMA4eOqf9G8BMY nQvx1SpeIch6mnvLy0Yg33TIskWQhQb8E/HBJ3O86HCps2R88uLj4FBTukDFRyzGlSWz hrE8ztCsGB6CZF6KczZT/Do3D+/vuRWqsrzdTpKegg1u2elwxRXXE5d1x65aXhvctdC+ xEH/G6LhcmAV/Z3e3ZYLdUhR0Mdijg5dg9cZazQXiazAgUZdyoGsCUMhuQCPxOdPQH2j y9pzftfu5ITLO9E9rNtinaprV/qezyaH2y3P18NdGJnOtsKXjiqq9GehpOceYK8FxG+/ IuNA== 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=zjIO5qKmxFdmhc6AUSogoHYSBFOqMz6Dr3txNIKmh44=; b=c6SBOVlyLuU5iyQswo+kDLr+WJnEP9AlamAznZiqbdq+e3UJHQGJ9ZuR2QkGodfhoy s/peKfI8doRqYJCzqSsdLditZPcq4bV6NmBKSIUR4IZSEURhpfe32NhqZm7wzmzwYTSV XrRx2Hsi9lthUu8zBQP8sorRyVusYuynGPUbJG3WteULQorxn+Y4wClAD57ozepNle51 1jPz+6bpMJT1r8s3YxCB0nisAGUDSmr0qc6slsi5o7N4tabOSwIzJVUge5eog8aVv0vq Q4t6V3b/WaZOLbspdKdZSKOyNdrYJgDSEShswLFgo7nauYPtUakSIw5YEw1onOf0yDRk wrUg== X-Gm-Message-State: AIkVDXJ3+vk45pWQ0qEhSJtoNyXNthUlZ6mPIHwjTa1MqMqVz5LV44nxV1zlENhycEwSoQ== X-Received: by 10.84.215.207 with SMTP id g15mr43089375plj.166.1484486171521; Sun, 15 Jan 2017 05:16:11 -0800 (PST) Received: from localhost.localdomain ([240f:4:c2bc:1:9509:afdd:5ccb:93b]) by smtp.gmail.com with ESMTPSA id n70sm10038237pfg.34.2017.01.15.05.16.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 15 Jan 2017 05:16:11 -0800 (PST) From: Akinobu Mita To: linux-input@vger.kernel.org, devicetree@vger.kernel.org Cc: Akinobu Mita , Dmitry Torokhov Subject: [PATCH v2 4/5] Input: mpr121 - handle multiple bits change of status register Date: Sun, 15 Jan 2017 22:15:43 +0900 Message-Id: <1484486144-27947-5-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484486144-27947-1-git-send-email-akinobu.mita@gmail.com> References: <1484486144-27947-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 --- * Use for_each_set_bit() to search changed bit drivers/input/keyboard/mpr121_touchkey.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/input/keyboard/mpr121_touchkey.c b/drivers/input/keyboard/mpr121_touchkey.c index 2558c60..a0210ae 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 long bit_changed; + unsigned int key_num; int reg; reg = i2c_smbus_read_byte_data(client, ELE_TOUCH_STATUS_1_ADDR); @@ -104,18 +105,22 @@ 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_each_set_bit(key_num, &bit_changed, mpr121->keycount) { + unsigned int key_val, pressed; - key_val = mpr121->keycodes[key_num]; + 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); - input_sync(input); + 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;