Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp76468ybt; Tue, 30 Jun 2020 15:10:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2uT3oTyE/U6/982wVLL4MwxBSmVNxphCyZYkyjYsQb8tFFgXTffmmpolFjettNrtDV5SP X-Received: by 2002:a17:906:7115:: with SMTP id x21mr19745705ejj.86.1593554575886; Tue, 30 Jun 2020 15:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593554575; cv=none; d=google.com; s=arc-20160816; b=HlI2tuvbD1Pql7BM7JUuw5KF2rElu4hQ/q8zfyjzFGPtt+baAgq/lEromSpXvP7Akj fdqUFgOG8Y1Xz6c4h3k7EGVInq9Y3tiihJXC6pHArL0Nt3y8wj5m4i5MxAXrIM2Fi8v2 viPWMhLTu/ve/jvU43pIaB/BI1Hc04SLSuLQ9mUtDSsOOSBQfWS96JGaAdbhIe5Zwhv2 yGXn6tHBqdWCqH8R8mCzygLNqBzgnp6tmLaFz2DDDqxeApIJBCmbAb9iHe3I9uHDF2Uc qwFRfg93es834iHdkECUw8TLA6S+3jjyFiyqXAtFqUMsUC/YeNZ0mfitWsGDCCmHlGoB WPjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=MV644q9HdgOcMKjgfG3T+AvIinwaeIV1aDYJmZ0o2No=; b=cDC0qnsE3SIh+kubRGKE8ODlzrwNGmdGxbeKo8MpNn54BLNL1rPmeNgYQABLF7plm2 2kp/RRhW/jnmjMx3laH0cCSc83rEDTttNkHhEtxIboK5WCk9Ut9z3QUPryvOjn8mUDiW vi/0xXD91CLL3SwQ5KwxH/oq8PshlEQ+J/r2ku0dr+vfumrej9Vh1DFmUtl7n1w4lpjB acfhBRq0x4Kp4qusdluPYF8f4eb7X/nzpkVuUC5EUKs4jJwfYh2LFtxlufCdW+8sjt+i /hHBNVYz7rs2cGUGT4Vfx/E49FZ77fa6EnZAaC+V2JGAkq+ymv9WCv5a+rM7u/l8pBjB +8wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HchvKg8a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b18si2417929eju.78.2020.06.30.15.02.31; Tue, 30 Jun 2020 15:02:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HchvKg8a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726990AbgF3VpC (ORCPT + 99 others); Tue, 30 Jun 2020 17:45:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726142AbgF3VpC (ORCPT ); Tue, 30 Jun 2020 17:45:02 -0400 Received: from mail-yb1-xb41.google.com (mail-yb1-xb41.google.com [IPv6:2607:f8b0:4864:20::b41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1832EC061755 for ; Tue, 30 Jun 2020 14:45:02 -0700 (PDT) Received: by mail-yb1-xb41.google.com with SMTP id y13so10840272ybj.10 for ; Tue, 30 Jun 2020 14:45:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MV644q9HdgOcMKjgfG3T+AvIinwaeIV1aDYJmZ0o2No=; b=HchvKg8aGsg2M1dEaZcfZu7LlzxTSPddVSg1ojsLydYKfMBLGtZR5sC4jXYsApabBl BkvwGrJ0KtlKu/1DVZSXDWActWbw4zH5L/lN1sRVI72DBdxEq8DouKLQwj8vPD+RZBeu qm8p4G50gMANVFwvIzdZRLOT0+sZxDUDCeGW0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MV644q9HdgOcMKjgfG3T+AvIinwaeIV1aDYJmZ0o2No=; b=ACrgxmhMouAbv5828HTMCevLRTBaiMNetv+79A/6BBkXb14amzdSIMK5czJ2ulZFqO eM/pNMcOp0gqu1727nClPFcLPI4eyJb/CKDAxHqaahfHrtcKuzQ/I46Uoff1zbm7rjgl eORRSfBmmlrwNbBnX03u2P6pojuCLCXjILGzdsmH58JJPIyjidSVQb/Rva3yfpo2zFsB oGhB75YW1wjsZT76YwCdzm20B2xhnGzTOVO1DnF5dOkKEZjKoMkxKHSPa/ltK2yFLjSd AzC4sORSISkXCklsTq3bOptiOaTFIhogl7pMBX/l9B0taSTrTHul+rcAKDmR6XuvSCyQ Ctew== X-Gm-Message-State: AOAM531jMz5cwVctXCc7GVobfuSQ1sp9Z2XXFjN+Irs9jvxdKEXyjWD5 vEy37E4eKkzmvrsDNGIp8IS5gR3B39n7Jh+lkhtCVg== X-Received: by 2002:a25:ae8c:: with SMTP id b12mr34313493ybj.502.1593553500134; Tue, 30 Jun 2020 14:45:00 -0700 (PDT) MIME-Version: 1.0 References: <20200630005707.2181126-1-dbasehore@chromium.org> <20200630051619.GG248110@dtor-ws> In-Reply-To: <20200630051619.GG248110@dtor-ws> From: "dbasehore ." Date: Tue, 30 Jun 2020 14:44:48 -0700 Message-ID: Subject: Re: [PATCH] Input: elan_i2c - only increment wakeup count on touch To: Dmitry Torokhov Cc: jiada_wang@mentor.com, jeffrey.l.hugo@gmail.com, benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 29, 2020 at 10:16 PM Dmitry Torokhov wrote: > > On Mon, Jun 29, 2020 at 05:57:07PM -0700, Derek Basehore wrote: > > This moves the wakeup increment for elan devices to the touch report. > > This prevents the drivers from incorrectly reporting a wakeup when the > > resume callback resets then device, which causes an interrupt to > > occur. This also avoids error messages when these interrupts occur, > > since this behavior is expected. > > > > Signed-off-by: Derek Basehore > > --- > > drivers/input/mouse/elan_i2c_core.c | 16 +++++++++++++--- > > 1 file changed, 13 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c > > index cdbe6b38c73c1..6ad53a75f9807 100644 > > --- a/drivers/input/mouse/elan_i2c_core.c > > +++ b/drivers/input/mouse/elan_i2c_core.c > > @@ -49,6 +49,7 @@ > > > > #define ETP_MAX_FINGERS 5 > > #define ETP_FINGER_DATA_LEN 5 > > +#define ETP_REPORT_LEN_OFFSET 0 > > #define ETP_REPORT_ID 0x5D > > #define ETP_TP_REPORT_ID 0x5E > > #define ETP_REPORT_ID_OFFSET 2 > > @@ -1018,6 +1019,8 @@ static void elan_report_absolute(struct elan_tp_data *data, u8 *packet) > > u8 hover_info = packet[ETP_HOVER_INFO_OFFSET]; > > bool contact_valid, hover_event; > > > > + pm_wakeup_event(&data->client->dev, 0); > > + > > hover_event = hover_info & 0x40; > > for (i = 0; i < ETP_MAX_FINGERS; i++) { > > contact_valid = tp_info & (1U << (3 + i)); > > @@ -1041,6 +1044,8 @@ static void elan_report_trackpoint(struct elan_tp_data *data, u8 *report) > > u8 *packet = &report[ETP_REPORT_ID_OFFSET + 1]; > > int x, y; > > > > + pm_wakeup_event(&data->client->dev, 0); > > + > > if (!data->tp_input) { > > dev_warn_once(&data->client->dev, > > "received a trackpoint report while no trackpoint device has been created. Please report upstream.\n"); > > @@ -1065,7 +1070,6 @@ static void elan_report_trackpoint(struct elan_tp_data *data, u8 *report) > > static irqreturn_t elan_isr(int irq, void *dev_id) > > { > > struct elan_tp_data *data = dev_id; > > - struct device *dev = &data->client->dev; > > int error; > > u8 report[ETP_MAX_REPORT_LEN]; > > > > @@ -1083,7 +1087,13 @@ static irqreturn_t elan_isr(int irq, void *dev_id) > > if (error) > > goto out; > > > > - pm_wakeup_event(dev, 0); > > + /* > > + * Controllers may send a full length report on power on and reset > > + * cases. There are only meaningless bytes in these reports except for > > + * report[ETP_REPORT_LEN_OFFSET], which is 0. > > + */ > > Is this true for all versions of firmware? Also, should we pay attention > to the value of this field for various types of reports? > I wrote the patch with input from Elan on our bug tracker, and they say that this will work. This is HID over I2C, so the first and second byte are the length. Since the packets are never long, just the first byte suffices for everything, but I think we should actually take the first and second byte for the length. Just in case some new version of the chip starts sending 256+ byte responses. > > + if (!report[ETP_REPORT_LEN_OFFSET]) > > + goto out; > > > > switch (report[ETP_REPORT_ID_OFFSET]) { > > case ETP_REPORT_ID: > > @@ -1093,7 +1103,7 @@ static irqreturn_t elan_isr(int irq, void *dev_id) > > elan_report_trackpoint(data, report); > > break; > > default: > > - dev_err(dev, "invalid report id data (%x)\n", > > + dev_err(&data->client->dev, "invalid report id data (%x)\n", > > report[ETP_REPORT_ID_OFFSET]); > > } > > > > -- > > 2.27.0.212.ge8ba1cc988-goog > > > > Thanks. > > -- > Dmitry