Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3366667ybb; Tue, 31 Mar 2020 03:55:04 -0700 (PDT) X-Google-Smtp-Source: ADFU+vumLEjr0DUDem3OkKT2Rcdb//Yfs2jfAZsTQhpxTpLgavaVof0kvJrZLEbehTtkzpHlMU8z X-Received: by 2002:a9d:128:: with SMTP id 37mr12173193otu.270.1585652104761; Tue, 31 Mar 2020 03:55:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585652104; cv=none; d=google.com; s=arc-20160816; b=ID1ni+f+iTwMEG79rZCbiJj27Wmu91Dah1AyHTpYwExRUQVpVEi5e5b2/9rR87shvx mbKydURU+q4P2QTmMDIAVcMcFb3AGnHQ4bhNMuPD1F+TVKRWa7rUJHoAVRUcmAsZWS/Q us0ye5foQ7K+SvDgKF/vuIaj5tpiN8jDlYQNjm/zFNOB9eXbDsgEIke4NBCAz5VUj1l4 AO6eoJcQPG1fIAvm2YPjdYflC/ha24xCrB0Knz/dLsiwiD/x0GcgY0NOoRFETdjiIzZ7 KI7CUaXfTDnnQQkl/+YQgleufbIKt/UG64VG+SO2TUNdIgOcgwJbSlNFHrbi3D5/rrBX AeYQ== 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=zqY73mF6vA3dLDGVLZA9MKI9L8jPKQBUWqLP/Qxc+Zk=; b=ru4dr1DNfQH7xT9r7BlPOOWrJMmmfnLLsK1xFFoMC9u6T9X63hI9xqjUxfYcm9IKqg omas8ZyLUnWT3w+1Beze1xGPECAT2S8/eZaYJxq3wtTjn6O6vR9DFYk9jVZ/mLOJg2Rj fLyymR1xsSCNUVm7dVmkYqRhdBrzUiVYFxJ/c/xWdh2WTh3N3BWvJ0JeemLZdXanstcf WSVEwt+cTviUlyPI9ELaWmr60fkJLdzD1beDb8xMV3tbWrYlWv4YDgxbf7trT5LlG8NK 80QngkpOC8VpybviD+Ysd768uTLALj+H6ItrnMyyooYnVPqAPQpmWDMPzm4tczLgT6BE toCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a23si7754434oos.67.2020.03.31.03.54.53; Tue, 31 Mar 2020 03:55:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730811AbgCaKxH (ORCPT + 99 others); Tue, 31 Mar 2020 06:53:07 -0400 Received: from esa4.mentor.iphmx.com ([68.232.137.252]:43597 "EHLO esa4.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730497AbgCaKxG (ORCPT ); Tue, 31 Mar 2020 06:53:06 -0400 IronPort-SDR: oR1zdraQR2Oq6tyT6hUiO4LUTi/T43yJ75nF2JVr8lcow5mL/FA4oaT2yFU8pke6skTEeQ5Y2Q jID3IC4ZaFHy7K20C31F3U2E94s9dLrUy4JlBPwB9Q9sITUOD3mGxNA9kuKxMuB/C5AEEiaVY3 O1sTn/Ri/TG1zVI4oiLaAcqgNEtw7/bcyZt2JUcJwCp3c2kbS31LLDR+YCQu5X39UW4e3qbZDD xYND5mUXPr1mMgYL+r0plauMryxl3Q+pX8lnEJK4cr/lWfI6f/RX/kzk33GdH5T3dLcu4FbQPM VrU= X-IronPort-AV: E=Sophos;i="5.72,327,1580803200"; d="scan'208";a="47330806" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 31 Mar 2020 02:53:05 -0800 IronPort-SDR: uy/C6AvSx5m9rpEpUQmOzqb2tVvZ6uaSBMSnIcgkJYlUQ34C59JYkayaUO2SxOdF1nG3f5V9TD h2+Ja12mEq58Rh34b8k89asToLxgDBmKmZhf4TVnVMTYHPDVBuBF2fCymlWV0ecZTa/8KSJCV3 z1ilXK2aW4Q7i4IP+Wbw2CirVSJfhUhuvJPfuO07yjeNGx6NDPxVkCsKVL+wsvIKfLCoSepbxr NRJoXm5yOvlWp78nEwpy7ToIoL8Ql1m6W0OFlq00NpYmM5Xj6q6TtZIz/mM4/KjM3pHR00zmqT R2Y= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v10 34/55] Input: atmel_mxt_ts - implement debug output for messages Date: Tue, 31 Mar 2020 03:50:30 -0700 Message-ID: <20200331105051.58896-35-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200331105051.58896-1-jiada_wang@mentor.com> References: <20200331105051.58896-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 b1f54bf207b8..656d956f9c93 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -335,6 +335,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; @@ -460,8 +461,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, @@ -1211,6 +1215,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; @@ -1245,9 +1250,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; } @@ -3519,6 +3527,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[] = { @@ -3535,6 +3573,7 @@ static DEVICE_ATTR_RO(hw_version); static DEVICE_ATTR(object, S_IRUGO, mxt_object_show, NULL); 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, @@ -3542,6 +3581,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