Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5591777pxb; Mon, 14 Feb 2022 02:54:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJy7wvVZiZYyiXj0PsbV0MRKOHS8Di3v6tQ31kY2bSrGl3pgzVMth2M38mLrIBs1HZ8K7x1g X-Received: by 2002:a17:90b:4b8e:: with SMTP id lr14mr5559306pjb.23.1644836047377; Mon, 14 Feb 2022 02:54:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644836047; cv=none; d=google.com; s=arc-20160816; b=VnK1mJpiZp84oySQoSVfQSHaGON+gjpNMzzp8fANOcOQCOuz+zMxn4DcUwp6KOw5EA yeRU0iCP224oRdNi1br4XCutZKX74EB69LSMfh2LswqCVsVI3V1NdhTsK/uUDWLORLNQ 0I/an0wMZ0Cx/Y6qY1zgYQU+aL0uLYWUTCg6kscxHslQvP+oOfLN1S/st/iCMYRnhraN nbPyJd6wq8fGCj7AHqvdCFHmb1atafXObj6iOOF14xGoKz39WtRDr5cjs2AN1/9i00h1 KiwoUeOQ6iJddMfH+4GUZnSwPFSa7gxTAZGl99SBvwyXWmP88N08VKNGC8UaZgW2LfDm SyMA== 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=rQYl0dGLPQaYPKlZy5p+ObPQe0jk7S0A9el98YwShaU=; b=pqJo/PJKksmEmES+vkav8DHlQ3BSGaUfcpTFy0slrWSrJd7hK6FHlTa+z3cN5xPIrh BCzu8oiJgIcnClxxMJ9voww6EmoL7UkKzeJBjPkOTiTOU0eJ92lmzKlfvXxIz2iv60ej 64IwQKJXVTQSvP0grGmWOY49VM4KGXH1lbCsgbJOvTRlSNtFhZm1NYNwE3fzvbgzvYzn othy/MSv/3A+fh+HVMh5uWujTFQvKQlYpWv/Kq+3VEVnymGJ3Chqu8BUcG6rkHJXZpOo RzSANtKqbux8qc91vEPS40VMxWSAa+gNaThnoyMD1itKEuVUuGu70G7GTf7xcFHPsKxb t4nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=cNDAwwYF; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b17si8699442pgh.350.2022.02.14.02.53.52; Mon, 14 Feb 2022 02:54:07 -0800 (PST) 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=@amarulasolutions.com header.s=google header.b=cNDAwwYF; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237357AbiBMRQ3 (ORCPT + 99 others); Sun, 13 Feb 2022 12:16:29 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:38634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237360AbiBMRQZ (ORCPT ); Sun, 13 Feb 2022 12:16:25 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE50D58E6D for ; Sun, 13 Feb 2022 09:16:19 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id z21so2630971edb.13 for ; Sun, 13 Feb 2022 09:16:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rQYl0dGLPQaYPKlZy5p+ObPQe0jk7S0A9el98YwShaU=; b=cNDAwwYFmPeLVTViYQOxsGrwgPWtQ2157SqHTdz0SHEHEHMcFVv1Ifd29mytsT/x6w zWF/eA4M3y7+O8TB/k74oNy6OZnWef///qSI93LQRfpP3x1KNN6AJeB/IMOjczivruAS +G+2FPSob0cF73MOsaahsLbrgQE/lSun03Eb8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rQYl0dGLPQaYPKlZy5p+ObPQe0jk7S0A9el98YwShaU=; b=7OcoDF73fN0i4/o+wxeR93nfySziKgsS8k3J5/AS4oghui1SHaE5e6DCAcUz6VWezo iY2gJm+XuTTRPF4zNhLf/syKeE6TEwT3496eHqLGzl/Cjn5DFSvhrapKsgBvQGlf/YuA e2FhDCyihAda23tw0zGJS0TnACYojPHbVvxeYqNQZISW5PT0XGszE6f/KqiQSsfsaaAM iRD/yZLbGB1muLSfZKzIFxY/FIxQ1DJ/6yFsC3tug+20r2HOKB+ZqyDtCaVXC6q9/G/l A31iA81aMGdgSE7zMRrU77ZRE5D4YEdjgaftiW+SxLpB2E3S18vpJsKPK0UFWrnaTZLb R+JA== X-Gm-Message-State: AOAM532STkPfnI3IfTRr9Y5akgloAUUJeyVdi9m5Z4e+q4OLjVJdXdyo HhAoLHAqW38QmA0GH2EAO2piTEQKs2WCZQ== X-Received: by 2002:a05:6402:4313:: with SMTP id m19mr11792561edc.320.1644772578260; Sun, 13 Feb 2022 09:16:18 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-82-52-8-210.retail.telecomitalia.it. [82.52.8.210]) by smtp.gmail.com with ESMTPSA id o10sm6598878ejj.6.2022.02.13.09.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Feb 2022 09:16:17 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Dario Binacchi , Michael Trimarchi , Dmitry Torokhov , Oliver Graute , Stephan Gerhold , linux-input@vger.kernel.org Subject: [PATCH 6/6] Input: edt-ft5x06 - show crc and header errors by sysfs Date: Sun, 13 Feb 2022 18:15:32 +0100 Message-Id: <20220213171532.346270-7-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220213171532.346270-1-dario.binacchi@amarulasolutions.com> References: <20220213171532.346270-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 M06 sends packets with header and crc for data verification. Now you can check at runtime how many packets have been dropped. Co-developed-by: Michael Trimarchi Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- drivers/input/touchscreen/edt-ft5x06.c | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index 2c946c155108..376aa4405104 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -133,6 +133,8 @@ struct edt_ft5x06_ts_data { struct edt_reg_addr reg_addr; enum edt_ver version; + unsigned int crc_errors; + unsigned int header_errors; }; struct edt_i2c_chip_data { @@ -181,6 +183,7 @@ static bool edt_ft5x06_ts_check_crc(struct edt_ft5x06_ts_data *tsdata, crc ^= buf[i]; if (crc != buf[buflen-1]) { + tsdata->crc_errors++; dev_err_ratelimited(&tsdata->client->dev, "crc error: 0x%02x expected, got 0x%02x\n", crc, buf[buflen-1]); @@ -238,6 +241,7 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id) if (tsdata->version == EDT_M06) { if (rdbuf[0] != 0xaa || rdbuf[1] != 0xaa || rdbuf[2] != datalen) { + tsdata->header_errors++; dev_err_ratelimited(dev, "Unexpected header: %02x%02x%02x!\n", rdbuf[0], rdbuf[1], rdbuf[2]); @@ -552,6 +556,30 @@ static ssize_t fw_version_show(struct device *dev, static DEVICE_ATTR_RO(fw_version); +/* m06 only */ +static ssize_t header_errors_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); + + return scnprintf(buf, PAGE_SIZE, "%d\n", tsdata->header_errors); +} + +static DEVICE_ATTR_RO(header_errors); + +/* m06 only */ +static ssize_t crc_errors_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); + + return scnprintf(buf, PAGE_SIZE, "%d\n", tsdata->crc_errors); +} + +static DEVICE_ATTR_RO(crc_errors); + static struct attribute *edt_ft5x06_attrs[] = { &edt_ft5x06_attr_gain.dattr.attr, &edt_ft5x06_attr_offset.dattr.attr, @@ -561,6 +589,8 @@ static struct attribute *edt_ft5x06_attrs[] = { &edt_ft5x06_attr_report_rate.dattr.attr, &dev_attr_model.attr, &dev_attr_fw_version.attr, + &dev_attr_header_errors.attr, + &dev_attr_crc_errors.attr, NULL }; -- 2.32.0