Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1369031ybj; Thu, 7 May 2020 23:02:35 -0700 (PDT) X-Google-Smtp-Source: APiQypJbIEUyNvz5iwIyaVSjGGrvGqxVXd/DHuZ/+drIRGSVEM1a4V0IY5T8Q9L6hC62PO9IaC6y X-Received: by 2002:a17:906:af6f:: with SMTP id os15mr531571ejb.78.1588917755705; Thu, 07 May 2020 23:02:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588917755; cv=none; d=google.com; s=arc-20160816; b=EW1ww+rhRr8TyQmoUW9TiXIFY9HJJz+3WmPnqMLzEViqXEtYY+D4eDXLpW9bx0d2Do taOUKxObpgQNGDudlFa8UWGVBgMXfP3UPVO4fbRjWk8ewGvnNFr8CHI/GYsmeyVv2HPG mJnelExrQr1r++LJcG/kdxpkg314fQwX5ndOOGEONbJjqf/ZhFHk9njX0/B9qTM9Xdii 0Mbeg5upD/ozLktxrvp/EL4mMXEF7mV+1ZwK4c1/DPDQCuik1/HGDtEHCJNkWyzgv/ff 35Ak4ye0ZsdJ+eqCxh3ddFTkp9r+81gnyvLxoC1MoOtBM5KF9Rv+eQtot468E7FF9IQH tMhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=VsdIgPEeehW88+e/XePZnCh0vtaMnIZ2iwDKHP+EoZc=; b=f+cK46roQsAVAfDvWoxF0uEfEYXRphsqnd7lh7Wnp00orecvBCEkiNcPM4P/mxZvmD 4GCUvUeRK5GowmLUrtDscGGjP4QSv5s/35rSa3jq+GGjfWsBj/bQJgPw2hCznEf2fe9B Dh7EVhFhKbAIKNkwuhA6uzZZZycoFWVAB0j8g++xYIFihqdSNNIUYyOvMk5fwmfbtYI4 1NslLFFZiFqW+NqkPBkLZ5wWGX7fPCeRtHf9CE6dPGKqX4OB3XUIw7KwUANDYg9DetM8 0dcYYqrNhk7RAvvjyzHddyQdDECw1rKH0OO9JidohvZOqFL1oXH3xbw+K0gzZDrsUsTO 7kPQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e7si356247ejx.367.2020.05.07.23.02.12; Thu, 07 May 2020 23:02:35 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728289AbgEHF77 (ORCPT + 99 others); Fri, 8 May 2020 01:59:59 -0400 Received: from esa2.mentor.iphmx.com ([68.232.141.98]:22062 "EHLO esa2.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727104AbgEHF7S (ORCPT ); Fri, 8 May 2020 01:59:18 -0400 IronPort-SDR: Ef7ooS/g+dUBxga/7WSmWDbeAMsS/BZITWmQnYCoEU8Tu5FqQMogSADT9IrufU0VHPhoACSnic JcySAcnNnmhHsp85ER/xqzUhbaf5I7fUx/D7Wkjs+xRRIF2P6Rifcl/dSapiz21CmbRCiGmmwF BiCzQn5SejSRnxW8asn9POa5d0cY1cL2muKJ0YgFDAu+wcvr10tCh3/CPWJCu2ONQzH1H/Q2IX OtKkvHDB1v1CtSWblsA/tBuEfgquHdEfFmLl5liXbTZuLlK8FqhXDl5RsuAHMJK72WTAc+EBzf Peo= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48589120" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 07 May 2020 21:59:17 -0800 IronPort-SDR: /151iejCQ14UkWcq1PC2SpC2EGv6MEZlEhO+H4MrdNPMSdiDiKHosyb/L1NP2kFFslHfnf5NzY o4K28EdsRSpuIXVJLXmCxVt6X+kJ7hmO8FBlUrNX/HQ+8YLIlyJlFJbX13qknUJwkyNiWgrxql PS0rGM/trQPStR7NQ5VZCGGh+4a3tBeYjOsskeTzu00Yoajxak3tCyPGvDkBVYPGlUE8OYIDEj yJJWCb8jgY5bA9C3EGQsacxuAH+9CDRE++UkZJkVft7gEnNSDoJbW0iF4784neiZxj2LRvSue4 ak4= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 36/56] Input: atmel_mxt_ts - implement debug output for messages Date: Thu, 7 May 2020 22:56:36 -0700 Message-ID: <20200508055656.96389-37-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nick Dyer Add a debug switch which causes all messages from the touch controller to be dumped to the dmesg log with a set prefix "MXT MSG:". This is used by Atmel user-space utilities to debug touch operation. Enabling this output does impact touch performance. Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit 3c3fcfdd4889dfeb1c80ae8cd94a622c6342b06a) [gdavis: Forward port and fix conflicts.] Signed-off-by: George G. Davis [jiada: Rename mxt_debug_enable_store to debug_enable_store Rename mxt_debug_enable_show to debug_enable_show Replace DEVICE_ATTR with DEVICE_ATTR_RW] Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 46 ++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 1027ebbc3978..7d48c4d1f57d 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -336,6 +336,7 @@ struct mxt_data { u8 t100_aux_ampl; u8 t100_aux_area; u8 t100_aux_vect; + bool debug_enabled; u8 max_reportid; u32 config_crc; u32 info_crc; @@ -461,8 +462,11 @@ static bool mxt_object_readable(unsigned int type) static void mxt_dump_message(struct mxt_data *data, u8 *message) { - dev_dbg(&data->client->dev, "message: %*ph\n", - data->T5_msg_size, message); + /* debug message with prefix 'MXT MSG:' used by + * Atmel user-space utilities to debug touch operation + */ + dev_dbg(&data->client->dev, "MXT MSG: %*ph\n", + data->T5_msg_size, message); } static int mxt_wait_for_completion(struct mxt_data *data, @@ -1212,6 +1216,7 @@ static void mxt_proc_t93_messages(struct mxt_data *data, u8 *msg) static int mxt_proc_message(struct mxt_data *data, u8 *message) { u8 report_id = message[0]; + bool dump = data->debug_enabled; if (report_id == MXT_RPTID_NOMSG) return 0; @@ -1246,9 +1251,12 @@ static int mxt_proc_message(struct mxt_data *data, u8 *message) } else if (report_id == data->T93_reportid) { mxt_proc_t93_messages(data, message); } else { - mxt_dump_message(data, message); + dump = true; } + if (dump) + mxt_dump_message(data, message); + return 1; } @@ -3498,6 +3506,36 @@ static ssize_t update_cfg_store(struct device *dev, return ret; } +static ssize_t debug_enable_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct mxt_data *data = dev_get_drvdata(dev); + char c; + + c = data->debug_enabled ? '1' : '0'; + return scnprintf(buf, PAGE_SIZE, "%c\n", c); +} + +static ssize_t debug_enable_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct mxt_data *data = dev_get_drvdata(dev); + u8 i; + ssize_t ret; + + if (kstrtou8(buf, 0, &i) == 0 && i < 2) { + data->debug_enabled = (i == 1); + + dev_dbg(dev, "%s\n", i ? "debug enabled" : "debug disabled"); + ret = count; + } else { + dev_dbg(dev, "debug_enabled write error\n"); + ret = -EINVAL; + } + + return ret; +} + static DEVICE_ATTR_WO(update_fw); static struct attribute *mxt_fw_attrs[] = { @@ -3514,6 +3552,7 @@ static DEVICE_ATTR_RO(hw_version); static DEVICE_ATTR_RO(object); static DEVICE_ATTR_WO(update_cfg); static DEVICE_ATTR_RO(config_crc); +static DEVICE_ATTR_RW(debug_enable); static struct attribute *mxt_attrs[] = { &dev_attr_fw_version.attr, @@ -3521,6 +3560,7 @@ static struct attribute *mxt_attrs[] = { &dev_attr_object.attr, &dev_attr_update_cfg.attr, &dev_attr_config_crc.attr, + &dev_attr_debug_enable.attr, NULL }; -- 2.17.1