Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp1728126iof; Tue, 7 Jun 2022 10:23:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzE/EfcOPuEllyGOODWXsAfjBnf9x7Xj6bgfA+fJ+3ZZOtcTDPpwBv/6NC9HAqxwIOa1WQn X-Received: by 2002:a17:902:db06:b0:163:e89d:622c with SMTP id m6-20020a170902db0600b00163e89d622cmr30008305plx.143.1654622580781; Tue, 07 Jun 2022 10:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654622580; cv=none; d=google.com; s=arc-20160816; b=ors1X39M5F4kNFomL4FRC6dv0MIVPFaAoBZulfhQn0Da2JVP6LD1PojLmN9mAGQGK2 /mg9RateSqdTtH0jk+lpDDwSA9/MeZ/PgpPhl5KC89puGJDfsUl30oGyUSziwnNGcFJj 7dtFSyw4IQDZzG5C3cZG4XK8pd3hzxA1293RW3taldctz5S4fe82/jBFyxetAfpo6ItN 9F8kBNVTLwataERpm2vE2qtSislbUov/cLI3yxFTIqNcic1KAXJQ2jhuC0lYST6Y4lCI CEqelkSA/jfo53pawvNB54mESbXMdUiwC1kpaZUX3o5Rk14KsbQ86McX+E3ufWcUIVEO i4jA== 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=V78a4T+XxMalGYKe1sIzEqFdtRWisjMfkHNLxFh+Xuk=; b=UyVef77hxFzrrGFiXLjzc4xvN2gblIML8jIYu8r/CPaWApLdoJ/ehH8gEvlqQAeK7t mQwV+9JRn0YZHScmQOpPI4yQFYD9PXYVLeeklUxSAt7gifr33jGi2erp4gGZpUGSO2o6 ebdy2IOc3ttgQV6fKlCQMI6CFYU3IWc5BOWj+98B6jPOJo1EOec3KQQiFCro5+eKW+hY fxkSkiVAfpw85bOZdUiARqYLZDRUJvTzETnkjb3ZkSwmx5VE5UNM94cWT0p7LFf0Ahwo z/fWLbA/AHRAQl8tEvBuh1CddokKhneJCjKvsJ1V2AAqPQ08ZZCsfrHEk9I6Xu4CBUpB Q8mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=UeqdQBIq; 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=amarulasolutions.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u144-20020a627996000000b005188ba74699si16715523pfc.196.2022.06.07.10.22.46; Tue, 07 Jun 2022 10:23:00 -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=@amarulasolutions.com header.s=google header.b=UeqdQBIq; 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=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240444AbiFGJ4z (ORCPT + 99 others); Tue, 7 Jun 2022 05:56:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240360AbiFGJ4R (ORCPT ); Tue, 7 Jun 2022 05:56:17 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DD48E732A for ; Tue, 7 Jun 2022 02:56:16 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id q15so15345675wrc.11 for ; Tue, 07 Jun 2022 02:56:16 -0700 (PDT) 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=V78a4T+XxMalGYKe1sIzEqFdtRWisjMfkHNLxFh+Xuk=; b=UeqdQBIqsmTGRwOHQ4Jr2DMdLBVll20hUXUFdLGxWG8ra3rbSiXdwhwfvcxi6jxztV i6aqJsZzUxEreUYZeNgxdd9YOhQoRteN02H7LBm6qjZ6BQjJwadXjKxxOaxnaraVVy7a ZFizSjhfoJIV63U9vkDwaZqYwzOR5lOMPm4KM= 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=V78a4T+XxMalGYKe1sIzEqFdtRWisjMfkHNLxFh+Xuk=; b=4VMWWkXz/OHhdkF6z1uojfZ174U0Vmy/nSJvvM5ulIvsztsHKmS1Hf+IESws9V2Bup y/G/rHDL8XNKRfICeteysK04IeKdaDnp/f6SDDgGkITTmXccq1Xtr36x012/PWUtCPFH 53gJ1k8iz+4JMDr6PjPqZULkXeVg3vMITj/QStxp/e0igO2j9SuBvEp891k9bqs12pmE QtenqLXa7Ugt+uJ8r5PI5VZ/ZWvxhcDO8kbtLHBLu7UZTfQMXC6VCix4ETHDesyuAXbU JfAPcTE8A0XAnbjUieJ+DQ8qOwpp3Ze9v3ltSYsgkJ5eJ4b4z2fieRPtwM5+LJGsoU5Q U+/g== X-Gm-Message-State: AOAM530IlkPemP9LOxn6HzZcaahOak3nkS8hdPToctJuQmxeAjo+sE4+ z72RS75f5b9vklyVbYINJP8mPXTZKz9j+Q== X-Received: by 2002:adf:ecc9:0:b0:210:28d4:96a0 with SMTP id s9-20020adfecc9000000b0021028d496a0mr26093257wro.380.1654595774560; Tue, 07 Jun 2022 02:56:14 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-137-51.net.vodafone.it. [5.90.137.51]) by smtp.gmail.com with ESMTPSA id b12-20020a5d4b8c000000b0020feb9c44c2sm17693546wrt.20.2022.06.07.02.56.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:56:14 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Dario Binacchi , Michael Trimarchi , Dmitry Torokhov , Marco Felsch , Oliver Graute , linux-input@vger.kernel.org Subject: [RESEND PATCH v4 6/6] Input: edt-ft5x06 - show crc and header errors by sysfs Date: Tue, 7 Jun 2022 11:55:56 +0200 Message-Id: <20220607095556.1034338-7-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220607095556.1034338-1-dario.binacchi@amarulasolutions.com> References: <20220607095556.1034338-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 --- (no changes since v2) Changes in v2: - Add Oliver Graute's 'Acked-by' tag to: * Input: edt-ft5x06 - show model name by sysfs * Input: edt-ft5x06 - show firmware version by sysfs - Fix yaml file. Tested with `make DT_CHECKER_FLAGS=-m dt_binding_check'. 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 bab92344b2ea..3deb66d67469 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