Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp223463pxb; Mon, 11 Apr 2022 23:46:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/4cmIsvuFmZza+Xc4Q9guOavK8RiaJXzMo7Kx8UiIkc0n6S7v8fKnkMr74iEL3E93xUWi X-Received: by 2002:a17:903:22d2:b0:158:67ff:dcb with SMTP id y18-20020a17090322d200b0015867ff0dcbmr8520578plg.32.1649745986244; Mon, 11 Apr 2022 23:46:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649745986; cv=none; d=google.com; s=arc-20160816; b=gatLxWeyMGtDcfe2iLA0HOb9y0iOf/4Bnhcvy+m58LVyOoLndWP2bo51/6sR3Bwrlj KzvyMDy7aD4wCXChygjj2n2QApKvz8blOz41N3/+2IueGWCclVbkRzGSA3IgFiXW6+hN 1dgUBvZqoCEk05L7V80yWx8KQHXagW3CAe2TaNGuSiW6FePLuWIxM8KT5PMCjtWnHac5 pPXkaggTBpjbi6wnEDK8RXRXEJzHGeUCzGbDd07BtftYGBeerjmUrDb64hGHbMOa9Pme VxsYetZMq6hWP2k0KHjMjEljLoW8z7xIvHSyonihGtmhKLgNPYKTYmdE/BVUhHFEZA9H ZnQg== 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:cc:to:from :dkim-signature; bh=G4z9WMGmzn5R8PACI1EDOWSQ9HwBuIwz18XwcrjNmJ0=; b=VRf/pEIee4K2Y8E0PUZ9JE+BZN42aX0S+U0nycohx3Xv+rfXDZFfRK3A01TkAE2nr6 BTw2rjEsekH/CZt4jPTglWhPOAbGseHRyj5FxAkM4WCZK6sdNJwoTTLZB20NW7V/apFU DnkwqC/mQNAgOex9zojhnrUbPw3QcxQTDNzHLkR2dtvRbQK6xoAZm7U9qNcJLZwdEaFk 81UjlQ8pB4p9RVOpsskL9PoByZBbMkx3/nU41w38cSh6hzT4Y6QotHcdfMK0T4oh50LN LomcPID6BpiY6v4YDXLlFAQS1SgiNa5e0C3TISmbxUjTxoGOtFiwP/2HQx6uuOnMlyTO gfIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=mgoU+Rdd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f10-20020a17090aa78a00b001cb8336d612si6117198pjq.91.2022.04.11.23.46.11; Mon, 11 Apr 2022 23:46:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=mgoU+Rdd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349820AbiDKUIq (ORCPT + 99 others); Mon, 11 Apr 2022 16:08:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349797AbiDKUIn (ORCPT ); Mon, 11 Apr 2022 16:08:43 -0400 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 382AC2DAAD; Mon, 11 Apr 2022 13:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1649707588; x=1681243588; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=G4z9WMGmzn5R8PACI1EDOWSQ9HwBuIwz18XwcrjNmJ0=; b=mgoU+RddxGAFLkbNONd/hhqvG/gO7BmrJu3tzwhuAZCn5nqFeCN8qLYu 4NdQXi8rOP3P5VMZ2cUcaHUk6NvmeV0hkgkh1H5f2LmAfJ1GL0cOegcoC 3cyg+MDsoylGPy1+AwF3vFCho4yx5fwutospIJb3RNX0vkXZMKOXk2ICP w=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-02.qualcomm.com with ESMTP; 11 Apr 2022 13:06:27 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg03-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2022 13:06:26 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 11 Apr 2022 13:06:26 -0700 Received: from hu-amelende-lv.qualcomm.com (10.49.16.6) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 11 Apr 2022 13:06:25 -0700 From: Anjelique Melendez To: , , , CC: , , , , , , , , , , Anjelique Melendez Subject: [PATCH v5 5/5] input: misc: pm8941-pwrkey: simulate missed key press events Date: Mon, 11 Apr 2022 13:05:11 -0700 Message-ID: <20220411200506.22891-6-quic_amelende@quicinc.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220411200506.22891-1-quic_amelende@quicinc.com> References: <20220411200506.22891-1-quic_amelende@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Collins The status of the keys connected to the KPDPWR_N and RESIN_N pins is identified by reading corresponding bits in the interrupt real time status register. If the status has changed by the time that the interrupt is handled then a press event will be missed. Maintain a last known status variable to find unbalanced release events and simulate press events for each accordingly. Signed-off-by: David Collins Signed-off-by: Anjelique Melendez --- drivers/input/misc/pm8941-pwrkey.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c index 881943ab4d55..3519152759dd 100644 --- a/drivers/input/misc/pm8941-pwrkey.c +++ b/drivers/input/misc/pm8941-pwrkey.c @@ -76,6 +76,7 @@ struct pm8941_pwrkey { u32 code; u32 sw_debounce_time_us; ktime_t sw_debounce_end_time; + bool last_status; const struct pm8941_data *data; }; @@ -162,6 +163,16 @@ static irqreturn_t pm8941_pwrkey_irq(int irq, void *_data) pwrkey->sw_debounce_end_time = ktime_add_us(ktime_get(), pwrkey->sw_debounce_time_us); + /* + * Simulate a press event in case a release event occurred without a + * corresponding press event. + */ + if (!pwrkey->last_status && !sts) { + input_report_key(pwrkey->input, pwrkey->code, 1); + input_sync(pwrkey->input); + } + pwrkey->last_status = sts; + input_report_key(pwrkey->input, pwrkey->code, sts); input_sync(pwrkey->input); -- 2.35.1