Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp991326pxb; Fri, 22 Apr 2022 16:09:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVtu890JbGHWVr54Xm2TO0qxrZ+qaU1f6xt4oXiaH/EaUhb2wBELBbswjM7wr+hTUiS2w5 X-Received: by 2002:a17:903:248:b0:155:e660:b774 with SMTP id j8-20020a170903024800b00155e660b774mr6738699plh.174.1650668968572; Fri, 22 Apr 2022 16:09:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650668968; cv=none; d=google.com; s=arc-20160816; b=EfKpE9rm1R83r8PyK9AHzt9KjMpBiilRnHub78upkFpVbzlNcTdoJnZeZ7Ngzg0rbr wtEt+MyJn6Xxb4YAILlen7NgOqqaD15Is+zAt49DgS9NmP527eW11PVF7uH0DRagscuy RLELHatSWfUEG0izJHVOni/xLoytzphUY2p3kUb6o/BJcuMxqUolSN1vTITVtM3feQKx ILzewMXjjKRHiJDwXzgf3AC8lKV+99RBYSmft4USSQxyVm55UQh6QVOFcLclbnHSDKXc D2ysHrCfXyw+Aj5xkK0q12hFXKS6Y7M7aHVRGq18hpn7+yTn8Ljxf4i1D960Mx5yvA6L +OGw== 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=NjyCdhLo/+6wBZuPLg1Nbm+QWlZCmoW2o/WQOrItWF387BRYgEmTEtS3Q3p/OCOfnG wQW492smu4yTI6ByxaghzyoIZgIMpolMtld5jyhHDeBzadR5aTGf956epGEAuhHyd19j Vggyb9VHIgdxtW6KKl3hs19vT5n53UldEnUkmu5o2Qvr6tKuWTm7qAN89efGYOtrI7o8 OWVNJirEULV+Dp/0xLI4d92XWSP6SzibYPHlnVH2hn2ReP+1/6iaKbwzThwAeJQeHtsW 3fFT3b1+1CEGn0rxhyFIuNe33s/YnVI/85aZQ2BJyKE8ck0sSYK7BinTXUH5NATnjUXv qKeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=mWARJDqW; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g19-20020a63e613000000b0039d91c88814si9432055pgh.149.2022.04.22.16.09.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 16:09:28 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=mWARJDqW; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ED64A300775; Fri, 22 Apr 2022 15:09:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231824AbiDVWKh (ORCPT + 99 others); Fri, 22 Apr 2022 18:10:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232380AbiDVWIO (ORCPT ); Fri, 22 Apr 2022 18:08:14 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 049F12C6E05; Fri, 22 Apr 2022 13:54:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1650660877; x=1682196877; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=G4z9WMGmzn5R8PACI1EDOWSQ9HwBuIwz18XwcrjNmJ0=; b=mWARJDqWM6+0BoB7IhpG02582jjwpwAWrvBTP++d6kDLP7t7M8THnB76 g9K4gje8poAvzzphzYmz3JoIRmjeoJVxNnk+lbOX7ZTDV09a8HB2TjyUo FjCof7KqHOXJVtqFbKFBtI3uckFzsfptnpq0x6ZdhGjuRwVqVKBLzUs4H 4=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-01.qualcomm.com with ESMTP; 22 Apr 2022 12:14:37 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg02-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2022 12:14:36 -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; Fri, 22 Apr 2022 12:14:36 -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; Fri, 22 Apr 2022 12:14:36 -0700 From: Anjelique Melendez To: , , , CC: , , , , , , , , David Collins , Anjelique Melendez Subject: [PATCH v6 5/5] input: misc: pm8941-pwrkey: simulate missed key press events Date: Fri, 22 Apr 2022 12:12:43 -0700 Message-ID: <20220422191239.6271-6-quic_amelende@quicinc.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220422191239.6271-1-quic_amelende@quicinc.com> References: <20220422191239.6271-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: nalasex01a.na.qualcomm.com (10.47.209.196) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=no 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