From patchwork Sat Feb 10 21:51:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 771646 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC2505C022; Sat, 10 Feb 2024 21:52:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707601964; cv=none; b=bXjcQvBYYbFQzYHHR+SUCFFWxarzfQWeo+/oOgydy9sOp04TiyR8hkdonYTqxvzgv1bzYEl0izkw1fLF5sOHNszCN6FNlQkJL+MUkWIdVhlvxFV0Ja3FwNzVB8UcdeJhBetl4fzU6CbHGN+9K/j+QcwwQU9/6iGZIhz1SqK+NU0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707601964; c=relaxed/simple; bh=In6AjzUhpjR1wsN2+PVjNyG0mJE7eCf5Z00CO0JRxII=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Wweh74nH8EGF6Yrh++gR1xWz7jKqDsjjJOz0qKwCz23TR7pgpalkQFbOFx0hFo5FPXKa/EGCQRr/FQDJFhbrktjjb+3IQpCBN6s/c0mwfN/GaeGnyx/lawTEShzF0vOO/i2RsvOm2DAmk7BK2/ylCNmhRxuDkGfIs9+F6Msv1U0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QsqB+9Oi; arc=none smtp.client-ip=209.85.167.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QsqB+9Oi" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-5112bd13a4fso3307012e87.0; Sat, 10 Feb 2024 13:52:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707601961; x=1708206761; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5bVIdnxLoNAiGQ5a+gFJnwc3L5NJOVMhNajT8rAnKq8=; b=QsqB+9Oinb533P77nIIzRpXFmjCEc6hlFgal+J6xVCCfUse5W1NOg8dIJpMvVM8zit VKBuF9LtRB4LfG2X4RZnVTJNoPgYeL8tjcaK93Pr+xfaZiG/GKTP0KLRJamY3bW7syfy E102SApxg7+h7q9HA4RZzk/qR18HiMrhb2rg7J6tT7NXhGMa1NKUND9AeTxeEHIwWsma jnCh5Ez24ts6E8ivsGgB1pWc0YF9dGRJ8qmamQGRU4J6AdNWlf4LrIiPrlALDrX8RSWO /BGgI57NMFencl9slV/Q9tNVIfTC/tymrCE8+LlLGDHfOGnaHjfY0dsTTAl6UAjuoMUo x33w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707601961; x=1708206761; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5bVIdnxLoNAiGQ5a+gFJnwc3L5NJOVMhNajT8rAnKq8=; b=lZzAQMB6MRtC5E4vW/WCEMzuiMgqRxBBS2wwsGNaewwZ4vTicg72gQ9qzNOOyBGd4p jOxKSRhipw7mTHLu+wrjOWPghM0EDSBnj6KgfGkpmGVbPTraf1+d7UeT5VF6Sv2jnZvs 2NIliQlUtU7xC0Fd2L7/wH+b9sQPDQjK8Ir6yIV+a2+/IBc3WfEHoFnNCUTVf3bWx1gT 7r7ncz0TnfOuDva6GEv2WvWhXMO27hskXbBzqsgzzkdEwYzQvP3kJsJeZpiQu9t8EHhj WZOfFhGmQ6wOXChAsWqBuXmMQv+9lJ33B2/xBDHK0AHTrlNC2Yvpf5v1NtIYiurAt1XB gaKA== X-Gm-Message-State: AOJu0Yz88hFol1H76MBSPbEeuWjoxurcZwOyWwOWvBiMM3Pq7RPVid1t iYmMGfVMNKAiZBHjjt/6diUAaXSiR0p0x+hKl+7EbIXgW6rVDfUw X-Google-Smtp-Source: AGHT+IEn1jOg+iTOpFu9b/2Hjj7IPRdaZQgXXTN1f2zVoQ83djjyt75IsgvLhQUcdHCGZQwPHWrZsw== X-Received: by 2002:a05:6512:3e28:b0:511:737d:661a with SMTP id i40-20020a0565123e2800b00511737d661amr1911687lfv.28.1707601960449; Sat, 10 Feb 2024 13:52:40 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVy15nubP7lErYdPg9hq3DaopTIunsgke2MGdUAKi4yNlfd/emmlZSYH/N99ZLcsLUqZioozu50SjpstyYCfvQy1p08FE9CRNR1SE3RmD/WDbFyzrst9Hci615G2EMsqvtVeGRsPAlRoT5RpInYdmA+FCx+7/69UdV2Xu94EOG8iBVyStLt57cFs/wq2k2jE98FnesnwWCSzIaLDCh/7S6asUkQ9lbm7mHjptJugf1fvmGpnkEo+4aChq/13Mz7eHvQb1qgP7K2SHCZ2HFDI/mMt5iGfWdJ9XNEMT6G27q+dtpaZca8AYl8VLSAzPQYlIhrQ6+IqUx6kbIVotgh3nR8kgCowTkJ/Gj7RjQy0gBY+4e0EsmgiQ== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.52.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:52:40 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 01/19] hid-ft260: fix incompatible-pointer-types error Date: Sat, 10 Feb 2024 23:51:29 +0200 Message-Id: <20240210215147.77629-2-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Fixed compilation error introduced by "hid-ft260: Add serial driver" patch https://lore.kernel.org/all/20231218093153.192268-1-contact@christina-quast.de/ You are using: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0 CC [M] /home/michael/sw/hid-ft260/hid-ft260.o /home/michael/sw/hid-ft260/hid-ft260.c:1426:35: error: initialization of ‘int (*)(struct tty_struct *, const unsigned char *, int)’ from incompatible pointer type ‘ssize_t (*)(struct tty_struct *, const unsigned char *, size_t)’ {aka ‘long int (*)(struct tty_struct *, const unsigned char *, long unsigned int)’} [-Werror=incompatible-pointer-types] 1426 | .write = ft260_uart_write, | ^~~~~~~~~~~~~~~~ /home/michael/sw/hid-ft260/hid-ft260.c:1426:35: note: (near initialization for ‘ft260_uart_ops.write’) cc1: some warnings being treated as errors make[3]: *** [scripts/Makefile.build:251: /home/michael/sw/hid-ft260/hid-ft260.o] Error 1 make[2]: *** [/usr/src/linux-headers-6.5.0-14-generic/Makefile:2037: /home/michael/sw/hid-ft260] Error 2 make[1]: *** [Makefile:234: __sub-make] Error 2 Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index cc2cce3698e3..7273d401337a 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -1220,8 +1220,8 @@ static int ft260_uart_receive_chars(struct ft260_device *port, return ret; } -static ssize_t ft260_uart_write(struct tty_struct *tty, const unsigned char *buf, - size_t count) +static int ft260_uart_write(struct tty_struct *tty, const unsigned char *buf, + int count) { struct ft260_device *port = tty->driver_data; struct hid_device *hdev = port->hdev; From patchwork Sat Feb 10 21:51:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 772180 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 781443D54E; Sat, 10 Feb 2024 21:52:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707601974; cv=none; b=KyRellBa86Hw8d5c7N/t9rbjAtisUnBHM3L/9wnaMQJkclBNf/Q+7bVlQjbm1uqLTb5nM7zc41e5KvKIZI6eilLYM7+EVnuCPaNgOK63angmYq49w8SN9uDMMGjxM4IjF5m53DZzYAQnHZJ+bt2UALNpZauNNenrXGHbhITi6HU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707601974; c=relaxed/simple; bh=u259KnwOI46B8vtWRyb9ZfelL9BXUSRWHJ8fsCzW3P4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=SAc3D7NmiBnYVdQWLigVf+M5gN7iwHV/4BFL6MYDdS48kAeC8WRlVkt4ABQ5dINpl0EJjoRMgfYXE7baNwrOW2ErRFfk8Cxnn7TGt9Y04nWe2nlZepEdzYK2m4S4wd5NKzoDCyyVICpP1TSXONEEPOobludm6kzWLtlOACjtWyA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dL0FFOFu; arc=none smtp.client-ip=209.85.167.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dL0FFOFu" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-51182f8590bso697777e87.0; Sat, 10 Feb 2024 13:52:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707601971; x=1708206771; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ocnxbMsGoBgHErUm8d0uQ9FCaUr3+Pyz5TTyo3yrGuY=; b=dL0FFOFunmQGTsLw7MkjnnUQWpWGrwfAe4PdoJ9zwQZdy4mZY3oXWSN5ssJw88mK0H VswXJzTtXU3T4On+tzJKuXIPD6F6kDg3vR7kAvHaRAA51T1ZoNws9+P8uebCp+Yoe7tw UnGoplb8eLcEw5/fjMy1cSy1cBx0PmBNo909/kQXEnPkfiqPHoitaQ4bWWwD1Ve+dz5c zX6XAfKNvoM3pja2sVRqzp6Rvr8o/XXtoB4IO/a23homfSTzjVzd9bhy/BhRmQ25nWzR OneiVtJ/0x0ihmjwu/Jv48DD1Jt6CByQ9Q2CTiSwX+sf50rbC5Alt8t7/PKewNLk2h4t wTQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707601971; x=1708206771; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ocnxbMsGoBgHErUm8d0uQ9FCaUr3+Pyz5TTyo3yrGuY=; b=DA2WmUGIs0T8NiZapEEVz7mNhNdVv41kAd4wOD/Rsv/H2w5wz5HR/WTC2sWXKN6zFr TKzqjwPjbAaL2rcNn1OGR1sNK9DA0dptkZ6BahuD7NdAZWRd9/OvYJAWhzXJGqY74KYy kwW8wWEYplmZihbhlSxaqaogR4oqwjRhHRhnJ03gcjMB4dLs5w3ohwJp26d5hSkzsc+6 HtWO2bVXxVriunBUZJVMoVGm8Ww3oKWDvY0nj0s8YkC+gybhIHdoBiIbWC/pgcE/nwZ3 lba76ikzerQTfu+gGcEunZqmejXY3a+ZzX5QfXv/FOGt9CS0Om9++hwP4c8OMkrTYZky Q6+w== X-Gm-Message-State: AOJu0YyoU8r5Re8gc3d0XH0BgmjHdgn7vTpYj48yVzksMoXwrXqaPgRI RgLnrbR4LDGqVcPmjTMKtCc+sWVkoShIz1m8/pgXBZqw37VGnylz X-Google-Smtp-Source: AGHT+IGWbLOCgfzwfZc8tU+VsT9rKKHZsutZBdAsn+B39qTP/IIPgAb+S1esh1vqEJwGY1X1e+Rwtw== X-Received: by 2002:a19:ee09:0:b0:511:494b:c483 with SMTP id g9-20020a19ee09000000b00511494bc483mr1523278lfb.31.1707601970525; Sat, 10 Feb 2024 13:52:50 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVDzAqbKAN35hKpiDb98iWNg2jY3Xw2dAYYCI9MbzNHSdSbTQrWIApK1QMGBlZR+RI6GUGVzycQKhm1aBZ99EyKofzRIdL9nyyLpdyKoB4J8lWP9TrgfF6EyI8gb4R82R/Ssveych5JI20R30CSiTKUHe88fGbeMcruSZ+fGa9vYjdMHzqYPIA8T6ATtRdBx+3rDT7sMMIbuehCCClSEDlIR9kl5S4473vBGRflFW/R/tgCx4dzE9jsJBhjId51i2eVoccNgCKz2Jwu7mp4HfNwvotpBjb6vjxnqX14sb8lHuQwW+ukLPmNyj9CAnLADyfYVKIjowMHmaxcHrQ7zP16wGyBahOz1tvJjn5ssu1KWv/bF5Aecg== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:52:50 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 02/19] hid-ft260: fix Wformat warning Date: Sat, 10 Feb 2024 23:51:30 +0200 Message-Id: <20240210215147.77629-3-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Fixed compilation warning introduced by "hid-ft260: Add serial driver" patch https://lore.kernel.org/all/20231218093153.192268-1-contact@christina-quast.de/ You are using: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0 CC [M] /home/michael/sw/hid-ft260/hid-ft260.o In file included from ./include/linux/kernel.h:30, from ./arch/x86/include/asm/percpu.h:27, from ./arch/x86/include/asm/preempt.h:6, from ./include/linux/preempt.h:79, from ./include/linux/spinlock.h:56, from ./include/linux/mmzone.h:8, from ./include/linux/gfp.h:7, from ./include/linux/slab.h:16, from ./include/linux/hid.h:19, from ./include/uapi/linux/hidraw.h:19, from ./include/linux/hidraw.h:8, from /home/michael/sw/hid-ft260/hid-ft260.c:12: /home/michael/sw/hid-ft260/hid-ft260.c: In function ‘ft260_uart_write’: ./include/linux/kern_levels.h:5:25: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=] 5 | #define KERN_SOH "\001" /* ASCII Start Of Header */ | ^~~~~~ ./include/linux/printk.h:427:25: note: in definition of macro ‘printk_index_wrap’ 427 | _p_func(_fmt, ##__VA_ARGS__); \ | ^~~~ ./include/linux/printk.h:528:9: note: in expansion of macro ‘printk’ 528 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | ^~~~~~ ./include/linux/kern_levels.h:14:25: note: in expansion of macro ‘KERN_SOH’ 14 | #define KERN_INFO KERN_SOH "6" /* informational */ | ^~~~~~~~ ./include/linux/printk.h:528:16: note: in expansion of macro ‘KERN_INFO’ 528 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | ^~~~~~~~~ /home/michael/sw/hid-ft260/hid-ft260.c:38:25: note: in expansion of macro ‘pr_info’ 38 | pr_info("%s: " format, __func__, ##arg); \ | ^~~~~~~ /home/michael/sw/hid-ft260/hid-ft260.c:1231:9: note: in expansion of macro ‘ft260_dbg’ 1231 | ft260_dbg("count: %ld, len: %d", count, len); | ^~~~~~~~~ Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index 7273d401337a..a67c625c9165 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -1228,7 +1228,7 @@ static int ft260_uart_write(struct tty_struct *tty, const unsigned char *buf, int len, ret; len = kfifo_in_locked(&port->xmit_fifo, buf, count, &port->write_lock); - ft260_dbg("count: %ld, len: %d", count, len); + ft260_dbg("count: %d, len: %d", count, len); ret = ft260_uart_transmit_chars(port); if (ret < 0) { From patchwork Sat Feb 10 21:51:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 771645 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45F4E5FF1A; Sat, 10 Feb 2024 21:52:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707601977; cv=none; b=rWJaiNF+QYCAgPSWQrulBS+sobr1CJ49ExCiIc5tyFLLHjbf8MO7764oJGDn61R2PVSHq6ODNh5KKN9qsZPxDCE+f/Axy3CioiZnzONe+ispzMN0GSimaIrFP7l1U/ntN+3T3SPAe46umFozmcoSonAGIdCO6cWk4q3wGfEcq/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707601977; c=relaxed/simple; bh=tYkc4h4Bp8NHCaXbI+vtqrPfsBIKoN0wVgseUk6XCjo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G7uPQUXcWR0ubs2YrIwvpWhe51myKAZzsZ+ZgLtfsKoCl/JTWiZ29w+HHk7Ecwh4HCkHiUwj6zS1Vti2ghGIKDP4DMAb65t+czJSRXE/+y5eoUK8+fi5vC5HnGBgPeoZGx/Aw5lTd43HHSEPuritE2l2isw4JNljT77T4ZduIyA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LO8PTBP8; arc=none smtp.client-ip=209.85.167.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LO8PTBP8" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-51182f8590bso697806e87.0; Sat, 10 Feb 2024 13:52:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707601974; x=1708206774; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bVxhkjh/5tBWW60EFdNQVc5luLCi3ZBwXFOGT84jAw0=; b=LO8PTBP8YMAc2ZhLCB4w6V9aMGRFP2TG4Arl3XHo4vrcA7FMeYHD/UOvxBqFW/GxrI xUEAGBd/gUxK7uPcyyGu2vZN0h7RS+bLEQHo+vuHgyfdyRwL7SaxpLbeAGGUpiSrJ2JO cSFeYdXLX8aTfrvTw1EC0tqUkfYE7aEz66mAnMIdBk2k30oiaHiPWOlOPM2CdTS7TGmN e4YWXxDJA6X0SBExx6TDSuCedCJie7d3C3GwpEulZghCM8K84CbGud+6OayzkvXK+qIx VaHRwV+ZR6W62k8skKf0TJeqOoGeFYc0//59TKN8nUuldlf14STCHlhyFnhUAnPKu8Ej tafg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707601974; x=1708206774; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bVxhkjh/5tBWW60EFdNQVc5luLCi3ZBwXFOGT84jAw0=; b=jV9e8TYxiMFHRvmXq6C5piq0o/p/eNJmKROY6R3AoLP0oIXT1WRssI22Qm4P2Pjizn vALlKgy+N6dkdfsprmNBH7SiPgRpatitG8hxqjI1g0KE3VoGgJSZRm/lYDAvklq4ofu5 zSbSd/nixulDG8Q8S2RF8dIyugP8qg7VW1oXLO7//8bdxWquNvGDlLj0+Q/VQGCp0YAs M/yJo45lLvOGtc8hX3D4fZSja71c0BtwyeXOnaBG8CH4hCFMWxNn0Rt+v06rsM77GaIR lKuEhfQgja2VcE4Xzn4Me3DwddshO+0S14GIidoLM8ZXgwBmv1kmBFWxEGwVhFXo4WVe PyVw== X-Forwarded-Encrypted: i=1; AJvYcCUNvPgg9HQf/8poLPcYEeiGn+3k5UgzY4bZk0R7q+4Sn62zacMtregszEl1YVuZIsZsFzFSA1P24FHuMqA1q1L2kukvlxYXtD9MAGQW9FmK/BEcrDa0A5DbWG+Gc1JwtANu8yVfCxI0LIg= X-Gm-Message-State: AOJu0YzfD2L/DVow3czyejMN/XZPV7xhA3pNcLBUV41SdZllSUzWomWo 79yXp1WjB0djIqT9RFO/fwtkdQYZ+xmIbf2+vYXvbtdRpJtrZmmo X-Google-Smtp-Source: AGHT+IFJQUysvruKMIPCXMcKQdErntqFzt0ucLi0pfMC24Ug9r6LTLD+/RH+7IuBLhoFVwvIL/n1Rw== X-Received: by 2002:ac2:4a99:0:b0:511:86a1:fbe8 with SMTP id l25-20020ac24a99000000b0051186a1fbe8mr726188lfp.1.1707601974290; Sat, 10 Feb 2024 13:52:54 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXc0/2chnx0D0t1iCvdzBQ0haZRG3cbeuWr4bTFtGRlVJhusDLPRwFnCDPIwEQLXvUVinpbCeePa50YHotJZKvrd7u3k7fsJlA4QOpPW3WL1RE1P/GKx2JFariM1jxbmQUrYCVdFCS7QPXoTKN37lzE9vAIR+L6+z+I+s20taQ/FIfiBZu4U+4NyHRtZlGPZDrOe0lHQJPI+Hi9X3hLqFKtrDXft8xyi/zvS/ILeOJxSiz2gizGwuGDYxcHzmfPnlp5PxyUrrHtZ7zO9/WVY11NC2McRyY7PD9KfOZ+jDp1TjTgeEl5gRK0LPiD2YHN+vWJnBuisr4BzG1RpEuX3riOFHOlcko6ISCDCGRumI9/EY6gpbFUtg== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:52:54 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 03/19] hid-ft260: fix i2c driver regression in ft260_raw_event Date: Sat, 10 Feb 2024 23:51:31 +0200 Message-Id: <20240210215147.77629-4-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Fix i2c regression in ft260_raw_event introduced by "[PATCH v4 RESEND] hid-ft260: Add serial driver" patch: https://lore.kernel.org/all/20231218093153.192268-1-contact@christina-quast.de/ It caused wrong printout per every hid input report: [21912.237393] ft260 0003:0403:6030.000C: unhandled report 0xde [21912.247405] ft260 0003:0403:6030.000C: unhandled report 0xde [21912.249403] ft260 0003:0403:6030.000C: unhandled report 0xd1 [21912.275399] ft260 0003:0403:6030.000C: unhandled report 0xde [21912.285404] ft260 0003:0403:6030.000C: unhandled report 0xde [21912.287403] ft260 0003:0403:6030.000C: unhandled report 0xd1 [21912.315406] ft260 0003:0403:6030.000C: unhandled report 0xde [21912.326390] ft260 0003:0403:6030.000C: unhandled report 0xde [21912.327402] ft260 0003:0403:6030.000C: unhandled report 0xd1 Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index a67c625c9165..a348f11600c6 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -1755,6 +1755,8 @@ static int ft260_raw_event(struct hid_device *hdev, struct hid_report *report, if (dev->read_idx == dev->read_len) complete(&dev->wait); + return 0; + } else if (xfer->length > FT260_RD_DATA_MAX) { hid_err(hdev, "Received data too long (%d)\n", xfer->length); return -EBADR; From patchwork Sat Feb 10 21:51:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 772179 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D4C65FEE7; Sat, 10 Feb 2024 21:52:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707601980; cv=none; b=SkAVjlyX44Ok9lSFBM4OYor87+XN0JyD7ASVM/hW/aFzF2BAUk9jIbblI8NbjllZJk2liRRN7c5s/TSkO0iUTkpGsa3wco26P6oD4VPOMT+Kvp5YXZJ77Y2D2K9NUHjC9O0f99uwJ4HNqyGNBrFhGXSmzjN+iYEqk7+7Gh1zox4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707601980; c=relaxed/simple; bh=+gpFQT4ELKCeTcAffH47le2OqwH0PUarupoW82tKagk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qr+qEgrv8D2z3F7qjZxlojk6anTE51enpjKJuBzCQsLOcAQRda8n1wyDQ/MulbO5FKvHA4WgVNG7BDjumYlZKVG3pAQkAwv/8zLkoCRcAr/El31AGYOOVEGpZhH8JvqCIVwhrHcb5IUsbCDj6aBHmrY2VyLBEYzGxz5Hq4dlnQ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dhr4Mrvb; arc=none smtp.client-ip=209.85.167.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dhr4Mrvb" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-51142b5b76dso3208872e87.2; Sat, 10 Feb 2024 13:52:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707601977; x=1708206777; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BIdw/Yz0Q97V7CTgaGjXXRg1G+fU20Qvt8n1MGF3Yf0=; b=dhr4MrvbRqC4ZU7po7Lu6Mtj8xuAp8ececwH/zvWU9T665DXLHVfzHgB8gvLL7f358 kZ3Yu2pcxtPRuMXai8HK6Qhio73dE/oB060aUoxeINL+OjpJSfEfMDYPcPLScYnk/nFi rXypb8gS/c9jJVuZHGl0oikl6Zm+jEBdfgr8iy0XdwD9ue6JoIM/bv4OncT4VZ9zKsct B9TLe6c2ftmSqqFoK5xXfb/yx/Kkw+NvacTjk8ypS3oI2Dtu59P06vTjnjltp1S+01ED tGmYthAEHIOJ7TA0d9fr7myLxNzWrlAefIkMVDIaw5jA7UY4/ZJQ9paX8NvxQwzFqkXp VUog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707601977; x=1708206777; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BIdw/Yz0Q97V7CTgaGjXXRg1G+fU20Qvt8n1MGF3Yf0=; b=ZhVtAWRfXROUpEU3tGIGh34AROLok3uORizTIAqNQ8UOKfslr02lkSGTOx5bsHRebk ow9sCHhV0M7yWU7x+66fyMQrrHXtr9dD+u0TFrZQS+Qrc4sMscmwtagVE80sezMiIgP2 ACMOQG6w1Q7ILBUjR1JMQhxsku9zklHRcH5f6X08PTzn5/ABA1nnBghcAlv7FFjh+OAF nln6wIC3WY+q1Y9iWoQbsvc4I07p1LMDkBnLr2gvqm0caHDU0/sIlU9pQUJTS971281y w49Yd4/cCRmdhIHiQjb9ACUrpmQQ1juGJLuLOy3MIOhhAyeMZKO3MWFdTJaGsABfo61P 7euQ== X-Forwarded-Encrypted: i=1; AJvYcCUglLEmBL8jmRRY73kyI2+wckM1KT8qgZcCvntWp1u3iqMxM163LaTRfJgDFF3BfJqIpwKNKDGu3kIfVQI5ldBjKcdnVkb3eQS+gc75pkVf1JbBc8AKgFWsGrPf1z1Ssnkes91mRFcSgIw= X-Gm-Message-State: AOJu0Yx+SzdAAsoDREGEws8Jhudat4bZo+LRRzccXfhVVvVbCJGc/qoR tUEOoHlb3N8m+3a7DgQEnz3Jyq5liQpX9VhxCiF7UadFBXZ8tmEP X-Google-Smtp-Source: AGHT+IHhIQKjHQWG133TzasYPGdsz4BD2bTaKitWQe0Tz1DzqfhbEO8+6t+WhJpgEDFVvdgXMMzdvA== X-Received: by 2002:ac2:44ab:0:b0:511:87ee:297b with SMTP id c11-20020ac244ab000000b0051187ee297bmr422417lfm.53.1707601977045; Sat, 10 Feb 2024 13:52:57 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVKWen3NWtIxj8+5gqx8iABYDfx49aOEBAmRmf7Z2U8DH0HhkB++Y2dMBRcOjPbQvYzOTY5hsY0MwZA6Wgo4Z7/d7MYm4I9TX6LwK7dLqCN6gYyR0+w6KqoYJ8NchF9FtAItLfWAS2TePvmkk0qnJThWRUH8HH7fuxgMDDTUtLPDmSrmGW18/hJe/WlbM5DniHYlDh7Cp/rNmOkyqSz7XfIrXVkOg1eW8K1/8H14cA5T4SeFEMsvEYsVkczd66MtHDv+t4dYIRwqMERWBnRxtgmaEtIIRDs9R5EZZHp79XbOlzgt0DnzeFo1Ax4nM1m6LVpTUAk+GxkY07K9XioMdLmXv7/zNShAu5binsF/FDprvbz+++8tQ== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.52.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:52:56 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 04/19] hid-ft260: remove dead code in ft260_uart_receive_chars Date: Sat, 10 Feb 2024 23:51:32 +0200 Message-Id: <20240210215147.77629-5-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove conditional expression, which will never be true here since it is already filtered in the ft260_raw_event procedure. Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index a348f11600c6..77638cae595e 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -1202,16 +1202,11 @@ static int ft260_uart_receive_chars(struct ft260_device *port, u8 *data, u8 length) { struct hid_device *hdev = port->hdev; - int ret = 0; - - if (length > FT260_RD_DATA_MAX) { - hid_err(hdev, "Received too much data (%d)\n", length); - return -EBADR; - } + int ret; ret = tty_insert_flip_string(&port->port, data, length); if (ret != length) - hid_err(hdev, "%d char not inserted to flip buffer\n", length - ret); + hid_dbg(hdev, "%d char not inserted to flip buffer\n", length - ret); port->icount.rx += ret; if (ret) From patchwork Sat Feb 10 21:51:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 771644 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0B716027A; Sat, 10 Feb 2024 21:53:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707601983; cv=none; b=Qqs+RAemtkUC8SmvuA5z/kptIA6XUKSY6P3iX2NokI8wvv9luOcQEGUI3gK25MGlqgzJbVRtXbUWdwUYT5EmIoVjBXO2a1Yg2nusxqh2iGF0n4bnXdNrV9dFpPaTp33MxTLKePsT5pwmIjvzjWzh5n+ou9v+UEPGGvqt7gc8cvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707601983; c=relaxed/simple; bh=9o7zsXvraSjsCEIhLU7II+BaKhLy7FlP98jc26bW638=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VGpJ1H/7ZIYO6cjOiS6/viJwnkfNmDqC3sFfHt3+M/Gzmx7gjgpZZZXpY9CFWLRTx0MYmK/yWeY+qG+1v9i6csvwoH/GKlK4IW29m8KMao0ft5pKRON3++aLGyhbgUmp5uEQb80nbVSpzphlfrHd2S6ncdtxP3z4kpnmN9J9goE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=efZhc3TJ; arc=none smtp.client-ip=209.85.208.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="efZhc3TJ" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2d0a4e1789cso22774381fa.3; Sat, 10 Feb 2024 13:53:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707601980; x=1708206780; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s+VuQ9yysl3g1DNmr5ri0m5tR/HKq6LHQGQTGRbQekY=; b=efZhc3TJgQTF4sJR8WSMTw1p3qS1CXYCkKDnXoR0sr27FAMSJ1QWY8F4cSOkMhsInQ 28n543rlBSSf1ok+bGgLqkrCusgMJ3Kzq7uvIFeuAbYQd/y9pQe4OZLrhKAsBc8WOWxT 49NOoRmLHJ482yr44uCtXnoH/tOxFt8u01ZkPewveiwBC6+ufyAwsdEPtdvy+DXSS0zO bgM0K/CJW6KPG4AFUIYxNsH5b+tTqouC/nn0p2vWhKQBI8g2WVI68ydpdQ+hlXci9WwV R13QNtHZkyOOJmEOKEPXk/euUMuCsciFOKU7CFQz+qvWrQFFCqzh55Fc8Dhha9C1xdvF Xagw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707601980; x=1708206780; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s+VuQ9yysl3g1DNmr5ri0m5tR/HKq6LHQGQTGRbQekY=; b=qGyyFkiA8/DVUJPig4HkpNUVH4mWlTtPFZevFDP2cPjHmuicLrv5Tu25z3rhtQS2BN MExpmjuA4fF3LK1paMagLtswliu9HtvBvhQYQ7OL2Cp3e6axFAH6PTTh5a9HU1smghWt 7gbDErZrg8XMHJIqb1fx8QHeIC9riyR558hsHyiVxD4N0egLvIoESsBuSj+JcDjFcJkG 9IXAK8pouo+UKUE1ymZ49STel7UtRK0saUcHa762muGWc/z6gikSoCpWcGUmmmkoUGU+ /H4PscjLhLVSN8Bspk1ToWpXN4ZrVVgj/TFpkOFWXD0uAh+EESJXKxrnQC8PiTVVXX1N tHXg== X-Forwarded-Encrypted: i=1; AJvYcCXOUScT95L3ea628hR3+sAG16U//oKuvofbveQC12LDw8dttYHsgoMv7kO8/nSZ35CeU1T2yRIZGikfXKQEGTofJv49RY66OvrISlShVq1YaYWwgSrbOLzSGv8pcgPEu2crJQ/96vyyMOc= X-Gm-Message-State: AOJu0YwmY0wJWkNGh0wvPVNC/rfIulcaJBs5gGhWs+E9Q39g2ZpvZyrp TUanHMJR16C1HRwu3kEDT6BZzRxWGVv8B9TlFXDv6XB9fNXvnBWe X-Google-Smtp-Source: AGHT+IGw0OVQhQFYgKkVLvI6KnpqZ//x1zhr8YOO3UNJuiIirHCdyXrW80fmJRufwwn63Z+vykzFAw== X-Received: by 2002:a19:2d47:0:b0:511:47a4:ef0e with SMTP id t7-20020a192d47000000b0051147a4ef0emr1677909lft.7.1707601979600; Sat, 10 Feb 2024 13:52:59 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW2cPEPDaaSC/hrzZi+46NnAVWNP88hnIjxa10U8y44az98mEw8yO7NnW0zgknZAIvkOEZePm7dtPrLpXjOSIF/iDY36PUYTcXVdtUpYzpz4d41vs6jD39ZlxLMMFa0o69BbtyBnRVGKT7hv7T3ZJRitxjBEzzdgrnu1niUHF6Tgf3/z/gtqV9H/fAV/vXMez9nGi9/XFAI4Suy+XI64cbyPQU6uzLT0vVwDSmBbDaExoO8owVPhsVD5v8vaaXpHIq/f0jsxX2llD4wCoUVR/wJf6FYsIwYl70loRr4YESmRR9nIzIDg2jPILkxOp+p0chcbry1MnnHHuRx0v0OWT5CGyl/TVfyUh09wKbZa29nS1nXuXZfgw== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.52.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:52:59 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 05/19] hid-ft260: fix unprotected write_buf concurrent access Date: Sat, 10 Feb 2024 23:51:33 +0200 Message-Id: <20240210215147.77629-6-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The UART code uses the write_buf unsafely, compromising the data integrity of both I2C and UART channels. The I2C channel uses the write_buf to send the HID reports. It uses mutex to make it atomically. For UART to use this buffer, it should grab the same mutex first. But then it will degrade the performance of both channels. The better approach is to have a separate Tx buffer for UART. I fixed it and briefly tested the data integrity simultaneously writing via I2C and UART channels. Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index 77638cae595e..3d6beac0b8b6 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -38,9 +38,12 @@ MODULE_PARM_DESC(debug, "Toggle FT260 debugging messages"); pr_info("%s: " format, __func__, ##arg); \ } while (0) -#define FT260_REPORT_MAX_LENGTH (64) -#define FT260_I2C_DATA_REPORT_ID(len) (FT260_I2C_REPORT_MIN + (len - 1) / 4) -#define FT260_UART_DATA_REPORT_ID(len) (FT260_UART_REPORT_MIN + (len - 1) / 4) +#define FT260_REPORT_MAX_LEN (64) +#define FT260_DATA_REPORT_ID(min, len) (min + (len - 1) / 4) +#define FT260_I2C_DATA_REPORT_ID(len) \ + FT260_DATA_REPORT_ID(FT260_I2C_REPORT_MIN, len) +#define FT260_UART_DATA_REPORT_ID(len) \ + FT260_DATA_REPORT_ID(FT260_UART_REPORT_MIN, len) #define FT260_WAKEUP_NEEDED_AFTER_MS (4800) /* 5s minus 200ms margin */ @@ -56,7 +59,8 @@ MODULE_PARM_DESC(debug, "Toggle FT260 debugging messages"); * read payload length to be 180 bytes. */ #define FT260_RD_DATA_MAX (180) -#define FT260_WR_DATA_MAX (60) +#define FT260_WR_I2C_DATA_MAX (60) +#define FT260_WR_UART_DATA_MAX (62) /* * Device interface configuration. @@ -229,7 +233,7 @@ struct ft260_i2c_write_request_report { u8 address; /* 7-bit I2C address */ u8 flag; /* I2C transaction condition */ u8 length; /* data payload length */ - u8 data[FT260_WR_DATA_MAX]; /* data payload */ + u8 data[FT260_WR_I2C_DATA_MAX]; /* data payload */ } __packed; struct ft260_i2c_read_request_report { @@ -249,7 +253,7 @@ struct ft260_input_report { struct ft260_uart_write_request_report { u8 report; /* FT260_UART_REPORT */ u8 length; /* data payload length */ - u8 data[] __counted_by(length); /* variable data payload */ + u8 data[FT260_WR_UART_DATA_MAX]; /* data payload */ } __packed; struct ft260_configure_uart_request { @@ -318,10 +322,10 @@ struct ft260_device { struct work_struct wakeup_work; bool reschedule_work; - struct completion wait; struct mutex lock; - u8 write_buf[FT260_REPORT_MAX_LENGTH]; + u8 i2c_wr_buf[FT260_REPORT_MAX_LEN]; + u8 uart_wr_buf[FT260_REPORT_MAX_LEN]; unsigned long need_wakeup_at; u8 *read_buf; u16 read_idx; @@ -503,7 +507,7 @@ static int ft260_i2c_write(struct ft260_device *dev, u8 addr, u8 *data, int ret, wr_len, idx = 0; struct hid_device *hdev = dev->hdev; struct ft260_i2c_write_request_report *rep = - (struct ft260_i2c_write_request_report *)dev->write_buf; + (struct ft260_i2c_write_request_report *)dev->i2c_wr_buf; if (len < 1) return -EINVAL; @@ -511,12 +515,12 @@ static int ft260_i2c_write(struct ft260_device *dev, u8 addr, u8 *data, rep->flag = FT260_FLAG_START; do { - if (len <= FT260_WR_DATA_MAX) { + if (len <= FT260_WR_I2C_DATA_MAX) { wr_len = len; if (flag == FT260_FLAG_START_STOP) rep->flag |= FT260_FLAG_STOP; } else { - wr_len = FT260_WR_DATA_MAX; + wr_len = FT260_WR_I2C_DATA_MAX; } rep->report = FT260_I2C_DATA_REPORT_ID(wr_len); @@ -552,7 +556,7 @@ static int ft260_smbus_write(struct ft260_device *dev, u8 addr, u8 cmd, int len = 4; struct ft260_i2c_write_request_report *rep = - (struct ft260_i2c_write_request_report *)dev->write_buf; + (struct ft260_i2c_write_request_report *)dev->i2c_wr_buf; if (data_len >= sizeof(rep->data)) return -EINVAL; @@ -1167,10 +1171,10 @@ static int ft260_uart_transmit_chars(struct ft260_device *port) goto tty_out; } - rep = (struct ft260_uart_write_request_report *)port->write_buf; + rep = (struct ft260_uart_write_request_report *)port->uart_wr_buf; do { - len = min(data_len, FT260_WR_DATA_MAX); + len = min(data_len, FT260_WR_UART_DATA_MAX); rep->report = FT260_UART_DATA_REPORT_ID(len); rep->length = len; From patchwork Sat Feb 10 21:51:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 772178 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0871E604C6; Sat, 10 Feb 2024 21:53:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602001; cv=none; b=el5cACoWlvvStaLxZtno73YPr7Pw8E6japp8d1wMbJ0CnveV8xQsGfCIhVsE4BEdy9CmPU6ihscnCmV0WUIrvRGVd2+Pvbcxtu8woInuMyZitanLOO8ZYaH1xCKpQM+xmEVkou0mAI0VYMjSo/nZIl5s0pkKznDNyegB2UQ2TTE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602001; c=relaxed/simple; bh=QeLwyWmd7NPkYXcDqCuEyzt6u/pRusg8+Tyv90sqj9g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rK1aMV46caM386ykDvZ7MDricHYmrDf1Tj+eedTqMUGAeGUv9mBQDy9zi6zOlL4s71v3M+qfOiVk4GuoI7QOg+RJcxOAT/LUfMWzYnxBJWNAjN3yOzrhN/QjAamVLxvVgPo2O6GSCPNwbaL0bavzZIunfWnNPpKohtG5ZJl650Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FwgLb6wL; arc=none smtp.client-ip=209.85.167.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FwgLb6wL" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-51167e470f7so2601295e87.2; Sat, 10 Feb 2024 13:53:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707601998; x=1708206798; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pMdjM6y7kF9azHHy8v2BrI6Kc/oC+WGprWIMEkx9WQo=; b=FwgLb6wLlvmf4AbLRG2XQnG3fZaTplWO7W4OQfyDYcYY3k5Zt0xdD7IoqbNaFj0D7t V/abVZiBk19xt5q+K4l88sbN8809wf7shnol/aH2WDUMY7+K2++jFm8iMNQ4tck79Y7y XeYoqKpudej7Kubb0+dVhYksRfPELqu33odHaWSlk5xazBYykoAXCDpGfQ6sh90j+mhh 1atXVaLsg09zgxuUapKv2jT8zHKWrKKjrgh/MRDSrNtaeWOh7p12DaD9AqYnSobiTRpW UkmqWOOYMfOldLGZRKSJO/LoBlTcFnxaGeD4KtMyo/8kUSbljTB6Q4JL2xlKzCjfDqrn 0I0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707601998; x=1708206798; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pMdjM6y7kF9azHHy8v2BrI6Kc/oC+WGprWIMEkx9WQo=; b=SZFdCjyXDtZenMOpTsvyalmwJMX9hlyWuB1ZKhPplVD4HRBR2gq6GmanLpkhN7NMWK JToVigakLSs6dRolgHk++qb6Pu/Mnolu/rrz/FfjLc47lAUJEm+Zyc+HIFDLJYKo2eSU 5hb/Pyc+FyjvoMD9nHPea37QAGN0ewiYnMz+nSJBpm8CFUSKK7sWuJpXxheava6GvP2U eeMfomJ9CsI5X5jlsQnc/GtzTL5hHYV0G0ddeFUH5yozsGi8i1o36pAVPrdel9uyRbl/ 3A9kjGbgYtY/Kta760WXBMFUn6V8lxOicNQZ15fUbBjbAA7+W0wJfI4ND2XPQhyKdQPy NqzQ== X-Gm-Message-State: AOJu0YyRrHZ8VLoksVkE/tfqeqwDAZjqsH1+LQaTNJnGLDGjcCdriXJB 0rYrLHmSEcytaZzBsyFKOcWEVgAaa+WVrbP0739RRxoP/I+Ox/Oa X-Google-Smtp-Source: AGHT+IFBl89sLOcwTVbtEV5d6hlD62y9BvFRoAZgG0bWrj4BGKt0p7O63PX1FsOqis+J/DKKUFw/oA== X-Received: by 2002:a19:f805:0:b0:511:5361:20df with SMTP id a5-20020a19f805000000b00511536120dfmr1790854lff.13.1707601998077; Sat, 10 Feb 2024 13:53:18 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW9FrSZtrtzkAYHkZCEv3npM/qj+QrBYwEKI8UB4dCsHfGDISwwAfwY2sPB+uLw5CLe4fZiEDQnsE+n3cstkOHzNmPMACy5+6qxflVGGXjrTQ5k5qlyyRafvbqxCyOWOAx3xlMd0WBH/mV+VPkm2GvC75yjeG0LsKAKxaM4rj/2PIzrSckFQZpVZuJTM93uKYxGjhqL+y16/SZR4yfJixuvZ3xnOPr5NRNG5yzuY7q9chpOceV/2WJN42SIcGZtQTo8mcZ5FBACT9kDQc4Q8RS4lK2mxhU1wkdyZ9vYAO3ypnPgDgmRf69zFCjydoU13lbwq1Qi5kAs2uXJ3C2efK4SswCQOSRnauw4bWji7MRIAK1vcWAAFA== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.53.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:53:17 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 06/19] hid-ft260: uart: enable wakeup workaround Date: Sat, 10 Feb 2024 23:51:34 +0200 Message-Id: <20240210215147.77629-7-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The FT260 has a "power saving mode" that causes the device to switch to a 30 kHz oscillator if there's no activity for 5 seconds. Unfortunately, this mode can only be disabled by reprogramming internal fuses, or external eeprom if exists. One effect of this mode is to cause data loss on an Rx line at baud rates higher than 4800 after being idle for longer than 5 seconds. We work around this by sending a dummy report at least once per 4.8 seconds if the UART is in use. But it is not acctivated in the "[PATCH v4 RESEND] hid-ft260: Add serial driver" https://lore.kernel.org/all/20231218093153.192268-1-contact@christina-quast.de/ It causes data loss on the Rx line at the driver's default 9600 baud rate. Enable periodic dummy report to prevent data loss on Rx line upon exiting from power saving mode. Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index 3d6beac0b8b6..19599e64c6be 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -1575,7 +1575,7 @@ static int ft260_uart_probe(struct hid_device *hdev, struct ft260_device *dev) INIT_WORK(&dev->wakeup_work, ft260_uart_do_wakeup); // FIXME: Do I need that if I have cancel_work_sync? // FIXME: are all kfifo access secured by lock? with irq or not? - dev->reschedule_work = false; + dev->reschedule_work = true; /* Work not started at this point */ timer_setup(&dev->wakeup_timer, ft260_uart_start_wakeup, 0); From patchwork Sat Feb 10 21:51:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 771643 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8BB25FEFE; Sat, 10 Feb 2024 21:53:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602004; cv=none; b=H9wTAFThywDmgHq5x53pKI58R0mIAwILdKpaKaf/gcvWwC2XE2iHP2mztABEyQ6hkIIYp3j5wR/uDntMIJellLXOdO5mm8/daVDRjKMW3I2tKGUgBg2TOLDtAt92CrBtL9p2gcH9RU+zBdrIWrKEZQ7Bk7Pd9xgEpuCC3WlnlIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602004; c=relaxed/simple; bh=pwSX1S4pRoynSdWjUaQZWgc7CRvfTwI/pHP/UuzHyyQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Rg17wgEYGaH4hSx6fwpQxUQf9//v9ap7+LOZgp9VMuxUHrEDVz8H0cHd41EWDTM/E5mbNI8/qqS7fGfWhCdAizDFR7uqA2jGbmE+1yCNB+rhauQ/2gcsvt4wRU6qOdbkYwVoI9O8QlNRp/yAybDR4odg2KT+jIovskxtnHVOq5k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VvXmV+IC; arc=none smtp.client-ip=209.85.167.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VvXmV+IC" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-5116b540163so3043968e87.1; Sat, 10 Feb 2024 13:53:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707602001; x=1708206801; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TwWx4fA7QO2mU5cwtgYuWebfDJVD7zwbCewKNc48h3M=; b=VvXmV+ICZ+aMiCR+KUz6mavN46OMokygOkLOZ9GALAX/iOiaoA8C62BH5T4ZQqAjgI 9r4Zba1gOZaE4dOmRW6pbFZZItcf13/4KU0eZ0KvuO5AgDlbmuZUZ8pfkFqRvEasAAx6 xXdv2YTy3Lu8mNxU9BfoqhMPxAXqdCcMJ5roBcAjbnvhiJpE0QRrgF2LGN4tfjeHe1MK komPoLhQLf6IKtlM2VerHINQcV0j2/tucabrNtmFHQdqBJ/pecDg4GkbJX6vRpaA4Jsb UyfFZh/0MMvP3mOb7ibZrgwrze/T2gjEU6ZJuN0TKssXEOKzod9Bzkw4NxsOJU42gtse huNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707602001; x=1708206801; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TwWx4fA7QO2mU5cwtgYuWebfDJVD7zwbCewKNc48h3M=; b=YvWnfEOGsI+Kui4oN9Tf+u20JmdM72VopCk1N/AJ+ahNn1cnWU/EgR0tgaIHTT+BbJ 8ZRCVJuGVTVWlGFZRyZeF5fL0e0+zTkHuvC1+gEYJRwo4Cazjs1dVumIzLlxuXe/gmo0 mwDx/tYPTnR2ZXT8w3k2brz78DP7D/UPhXS7h8JybYgWf2i9pSo0Zv1EvTQ8h2OdCbIt wJJNXCmgknLkDldoIGtH1twNLq1Iq+XX5khkwcjnHQicPXe4wxh4Q/tbAHo0/EVvcaEd i4vrq2pASgLDQ1X71KPjd31ABwPBMxfb57ltbZML+4m/uG4xEYG34X5IetM+y8bi8jE5 FuZg== X-Forwarded-Encrypted: i=1; AJvYcCVXQneo2cv2aFsjvUksAkI/+/pzxvynScwjvhqnIwt/XgD8/z6vz3GqbGO11aKl39UEvmlKQTJy4Wu2p26dnIhTle1jww3MSlhs56qi0tv5SbHMYA7GZu6KhiSYNJVo7nZidUKwGpfnYZ4= X-Gm-Message-State: AOJu0YyM/DeR8LAiPmGKXSTGDDFkKzWY0pBe9KnOuPiRpasuoqEaLLzw 7OXqYDI2qiuTeLmmiyH3sUoN3ASO6u1alCBYqhbqEBANt089zSIl X-Google-Smtp-Source: AGHT+IHfmf7d7dxrnpt4DTQ5HpmzcY2L4+35UsaQkNZoQShTApQz5x5BDhKXlgT95/DVOCHlnisEBg== X-Received: by 2002:ac2:4ac9:0:b0:511:7b35:9563 with SMTP id m9-20020ac24ac9000000b005117b359563mr1497168lfp.19.1707602000706; Sat, 10 Feb 2024 13:53:20 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU7SKRtSC3z2GhqNZMTUsbMPy8izpVUK5n8o9Q8uxdOhOMj/yjoBiWihcZxOOc2LX27JaXymFlZjs1CP6Pqg7x1CXCnNW1u874a3MVnOxyvXS5N3OntQDJHdITfW5iKX+2p2JPbIPLwEas/wfMG9b0RC5G6WwvbAxs3+pvN+G8a4TiSvFjWXaWUr/PGDRC+qWCCEkxHbO3Y799j+Y2qpDk9JbDA/fHr1XtSLQRt5H2PSb+y5mBecXeBPzlrNhWqZAExGKYWkfmS58kjpcMagK4B/hvOaQvgd+ZkUY9Mr4Q70AQ5WwiyJc3LJuy9KDl4uGBHEAFLfSzG/X5dKOaaloh5fAVd878HXPjf8Dh2YTFf79gYWli1oQ== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.53.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:53:20 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 07/19] hid-ft260: depend wakeup workaround activation on uart baud rate Date: Sat, 10 Feb 2024 23:51:35 +0200 Message-Id: <20240210215147.77629-8-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The ft260 chip enters power save mode after 5 seconds of being in idle state. It causes the data loss on the Rx line. The implemented workaround sends a dummy report every 4.8 seconds, preventing the chip from entering the power save mode. But the baud rates below 4800 work fine without a wakeup workaround. This commit makes the wakeup workaround activation dependent on the UART rate, allowing entering the power saving mode for the UART rates below 4800 bauds. [11238.542841] ft260_uart_wakeup_workaraund_enable: Activate wakeup workaround [11238.542843] ft260_uart_change_speed: Configured termios: flow control: 0, baudrate: 9600, [11238.542845] ft260_uart_change_speed: data_bit: 8, parity: 0, stop_bit: 0, breaking: 0 [11238.543671] ft260_uart_wakeup_workaraund_enable: Deactivate wakeup workaround [11238.543683] ft260_uart_change_speed: Configured termios: flow control: 0, baudrate: 4800, [11238.543684] ft260_uart_change_speed: data_bit: 8, parity: 0, stop_bit: 0, breaking: 0 Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 48 +++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index 19599e64c6be..b24998092d22 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -296,6 +296,8 @@ enum { FT260_CFG_BAUD_MAX = 12000000, }; +#define FT260_UART_EN_PW_SAVE_BAUD 4800 + static const struct hid_device_id ft260_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_FUTURE_TECHNOLOGY, USB_DEVICE_ID_FT260) }, @@ -1056,6 +1058,15 @@ static const struct attribute_group ft260_attr_group = { static DEFINE_MUTEX(ft260_uart_list_lock); static LIST_HEAD(ft260_uart_device_list); +static void ft260_uart_wakeup(struct ft260_device *dev); + +static void ft260_uart_wakeup_workaraund_enable(struct ft260_device *port, + bool enable) +{ + port->reschedule_work = enable; + ft260_dbg("%s wakeup workaround", enable ? "Activate" : "Deactivate"); +} + static struct ft260_device *ft260_dev_by_index(int index) { struct ft260_device *port; @@ -1108,7 +1119,7 @@ static void ft260_uart_port_remove(struct ft260_device *port) spin_unlock(&port->write_lock); mutex_lock(&port->port.mutex); - port->reschedule_work = false; + ft260_uart_wakeup_workaraund_enable(port, false); tty_port_tty_hangup(&port->port, false); mutex_unlock(&port->port.mutex); @@ -1266,8 +1277,11 @@ static int ft260_uart_change_speed(struct ft260_device *port, struct hid_device *hdev = port->hdev; unsigned int baud; struct ft260_configure_uart_request req; + bool wakeup_workaraund = false; int ret; + ft260_uart_wakeup(port); + memset(&req, 0, sizeof(req)); req.report = FT260_SYSTEM_SETTINGS; @@ -1309,6 +1323,12 @@ static int ft260_uart_change_speed(struct ft260_device *port, tty_encode_baud_rate(tty, baud, baud); tty_kref_put(tty); } + + if (baud > FT260_UART_EN_PW_SAVE_BAUD) + wakeup_workaraund = true; + + ft260_uart_wakeup_workaraund_enable(port, wakeup_workaraund); + put_unaligned_le32(cpu_to_le32(baud), &req.baudrate); if (termios->c_cflag & CRTSCTS) @@ -1435,13 +1455,13 @@ static const struct tty_operations ft260_uart_ops = { /* The FT260 has a "power saving mode" that causes the device to switch * to a 30 kHz oscillator if there's no activity for 5 seconds. - * Unfortunately this mode can only be disabled by reprogramming + * Unfortunately, this mode can only be disabled by reprogramming * internal fuses, which requires an additional programming voltage. * - * One effect of this mode is to cause data loss on a fast UART that - * transmits after being idle for longer than 5 seconds. We work around - * this by sending a dummy report at least once per 4 seconds if the - * UART is in use. + * One effect of this mode is to cause data loss on an Rx line at baud + * rates higher than 4800 after being idle for longer than 5 seconds. + * We work around this by sending a dummy report at least once per 4.8 + * seconds if the UART is in use. */ static void ft260_uart_start_wakeup(struct timer_list *t) { @@ -1455,10 +1475,8 @@ static void ft260_uart_start_wakeup(struct timer_list *t) } } -static void ft260_uart_do_wakeup(struct work_struct *work) +static void ft260_uart_wakeup(struct ft260_device *dev) { - struct ft260_device *dev = - container_of(work, struct ft260_device, wakeup_work); struct ft260_get_chip_version_report version; int ret; @@ -1472,12 +1490,20 @@ static void ft260_uart_do_wakeup(struct work_struct *work) } } +static void ft260_uart_do_wakeup(struct work_struct *work) +{ + struct ft260_device *dev = + container_of(work, struct ft260_device, wakeup_work); + + ft260_uart_wakeup(dev); +} + static void ft260_uart_shutdown(struct tty_port *tport) { struct ft260_device *port = container_of(tport, struct ft260_device, port); - port->reschedule_work = false; + ft260_uart_wakeup_workaraund_enable(port, false); } static int ft260_uart_activate(struct tty_port *tport, struct tty_struct *tty) @@ -1575,7 +1601,7 @@ static int ft260_uart_probe(struct hid_device *hdev, struct ft260_device *dev) INIT_WORK(&dev->wakeup_work, ft260_uart_do_wakeup); // FIXME: Do I need that if I have cancel_work_sync? // FIXME: are all kfifo access secured by lock? with irq or not? - dev->reschedule_work = true; + ft260_uart_wakeup_workaraund_enable(dev, true); /* Work not started at this point */ timer_setup(&dev->wakeup_timer, ft260_uart_start_wakeup, 0); From patchwork Sat Feb 10 21:51:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 772177 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5071E604D7; Sat, 10 Feb 2024 21:53:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602007; cv=none; b=nivodCVHbiTJ2zWTXdbkNq/brJ3IwFu9EAMNM5udbZoKwz8rjKz3u5PT5re4+hj8Xm9Fv++KTKbJnajI8/m46oJG5znnDn/15Bli2quoRTCFqfGZfasg2JHlcVoOS2s6VmqglNAOwSVOtvzNTddnYSmPP+YzJJVZV4k4ZfKB3pc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602007; c=relaxed/simple; bh=gDhQUebaa7t6ieh8Y51ShSPwVNxKLw23nUX5WrKMldg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RGUHZxc5qjZ9t2X4xJ/yMFTHu1rxKEcYAkXEJwOeHfXS5AT0PV3pZ4XWOMw7BpgyfydDA11gxmXY0iEdtTNxGycVNw3F1Qkjat5WYlqMzijTXs1S1nPD+JlMhGvulGm5XdnrNeh1AfGXZzAQ4h1c1LH7WtHarf/fPlAM9HpYjNc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AfFNn46a; arc=none smtp.client-ip=209.85.167.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AfFNn46a" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5114b2b3b73so2465693e87.0; Sat, 10 Feb 2024 13:53:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707602003; x=1708206803; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UODuNfAGA+zsvY/n5h+6gJpvPpOhAjXDdRWfKreEhiw=; b=AfFNn46a2zhBgqbUvk6eFwLa/Mh+3QrPL+1FUiIWS5rvYUL7lrAAKZ4+YAdwurXBYS uQV+UnQltKtJ0xBe3CgsApuR2wI9WsULbWAXGHh9IRjRSHTDMyN3ir92MOi48QMzsyaz NhHKp/zuY8KXI6oYoIx1KtiNdGrONRCV6pVfjxGBuykId+oqkqbM5SpLQtSQAaoKjUdB W1lpPJi/D5u4QdRa6URyqAA7eD1xPWDSnb//YTojRw627UI1VDfBtTmdkwRlXpnBl5bM Fo2mP9Nh7IF1IfF2ss4FaZWUWLSD0YXnRVTpnSO/6/TjDklXSAcMglhqAsHR6L54e/jV XNlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707602003; x=1708206803; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UODuNfAGA+zsvY/n5h+6gJpvPpOhAjXDdRWfKreEhiw=; b=CgDHyw3liX8ODbCZ5ek4lu2DGDOj6wrcUIIqYRBvH2zpDR1fddmW9t0lpQHajH70kp Fplu4wAX58s3rtt22fmNngRqYjbMJQOZM9I1iX3rD8DgW0SWhvE0Su4WYjXtZ9jV6dpE m/0SFlaXaSM+OPRfkqquInuKJWqKd5n5PG2CQEopsDALm5fQE1p2zG0diMAKz659v/7u qyOe3Z6U02BCEnqRuIDsBONs6sxWGGY+rQqXM6Lcb7vV14YkqreexdkwIV/LQlkcYhdU EXMuksj7HHxof1b7TQHr6eZhIha2eWTfxBo7zHe9UGuHb4hxJhuW4IalhC0Q2rrTpSK3 tpew== X-Forwarded-Encrypted: i=1; AJvYcCUoGp7+k7JJjULpiQpdRGR6Td/htlYuLYyA+pu7zLWW8QCxCXJweIsYnrX5bodINENLcgIUW3Ju1ZOLjmSx/dOgiRpwj8Qn4+jx91vxgfNdBmGtQJCeEz3z1H0AFsQPoFG3AeZE6EmxEC8= X-Gm-Message-State: AOJu0Yx7nMZp64PqMK+ly/YdSn9ekWv3rS/cTxn/Alpvw+yg2b5EbYrb P1VXJKq8W8YoxVzby1GtxSOUUXfz78tThI0EyV/IG1v5Jk6NFSmF X-Google-Smtp-Source: AGHT+IEqofZLAjp83Pq1cN5RQ584GtEK65VSSqOrt+GNzw0tdk+B5sjqUQe5WiUwpym5FW4KIlWBKw== X-Received: by 2002:ac2:4d91:0:b0:511:82f8:d30d with SMTP id g17-20020ac24d91000000b0051182f8d30dmr1738073lfe.32.1707602003255; Sat, 10 Feb 2024 13:53:23 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWujr/UBh0ujT5bxNwSXnL461jiku4Mw6uUMQEXaJ7m80CBselpdh0gltd+Qnal67DxWkC++wt+wI+92G+Xwf2fcC1r4g2MwDslhaQgaOYJ8OG3QglQMGd32QUMmSpGHs8hESyfdmayEceTc+63eiVKtt9znx+ZFg+CsFbfvAyU8A5BGAgUYDsf+CdCCUO9jUTSfE0buwwgVtIfirpsWD/+ZJkPJTOqxyqrZLzz4EGamsK/1o1Db+CzCoQCfovpI2JPTcyxa1Pn/hmCJoVqwo4A7dHyB1YLw21zeM6avXXdF7Hi76KzkjSI3PsQ8uzC45PrH9SWdukPDPs2tlxXOxf4/5OF4WlY2w4WcYySGjiutTvRLOe28Q== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.53.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:53:22 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 08/19] hid-ft260: depend wakeup workaround activation on eeprom config Date: Sat, 10 Feb 2024 23:51:36 +0200 Message-Id: <20240210215147.77629-9-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Do not activate the 4.8-second wakeup workaround if power saving mode is disabled in EEPROM. Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index b24998092d22..ccd20f590720 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -323,6 +323,7 @@ struct ft260_device { struct timer_list wakeup_timer; struct work_struct wakeup_work; bool reschedule_work; + bool power_saving_en; struct completion wait; struct mutex lock; @@ -889,6 +890,7 @@ static int ft260_get_interface_type(struct hid_device *hdev, struct ft260_device ft260_dbg("uart_mode: 0x%02x\n", cfg.uart_mode); dev->ft260_is_serial = false; + dev->power_saving_en = cfg.power_saving_en; switch (cfg.chip_mode) { case FT260_MODE_ALL: @@ -1063,8 +1065,11 @@ static void ft260_uart_wakeup(struct ft260_device *dev); static void ft260_uart_wakeup_workaraund_enable(struct ft260_device *port, bool enable) { - port->reschedule_work = enable; - ft260_dbg("%s wakeup workaround", enable ? "Activate" : "Deactivate"); + if (port->power_saving_en) { + port->reschedule_work = enable; + ft260_dbg("%s wakeup workaround", + enable ? "Activate" : "Deactivate"); + } } static struct ft260_device *ft260_dev_by_index(int index) From patchwork Sat Feb 10 21:51:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 771642 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1882605B7; Sat, 10 Feb 2024 21:53:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602010; cv=none; b=bhS20jVm9PdI9ZvZkWpCfBkL8kxgNTzKwS1AeX//aCA/bCWSmSPyviDlmcq10+qqLUTcz+ERuT2+Z1UYuRx5SlyogSQ4hAS94vi5kY3bOEwXRqGyZTLNVE2wd26eV2NCRpC5nGUTsajC4K2GS0AHRuN635q2xfD11gnKKlbGRW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602010; c=relaxed/simple; bh=j9Y4Ee2XnyCp19O67N0N+PzpLOj8tGQB3EHMYWxJ/sY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KFgYE6BfmzntkvFWN6Lxg2k+tT5tBCN4cV8scyYlZWMfHerkPQibaamHbN12yb1kBinKNyyTgYhg+eGSu0T1G4G1Q1BTcchD9oWmjZ4v7hjM1B2zl2kmBWImnPjgX6q0zLbRL+3zBT2T+62aVRe6Xt4VmnFunZtmSPuX4nZk1nk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eR//btsk; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eR//btsk" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5116b2dbd16so1896344e87.1; Sat, 10 Feb 2024 13:53:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707602006; x=1708206806; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OmNBPg3VhiKxOz/cULC4NqhIweOs07gq4ld1aCJ07ik=; b=eR//btskc3xYMI32WmF2j4WJAmcIPQhmJyqI//tFcDwba+ucp8z4GWQgV47+xygtqS fFZHT8EUKLwbR7Fj8CGk6d3tUsupZJjIZUFNbAJ8y9Fb3kvP5elowQX+tbUsWRFE24Ir L3MW63/4TVDdpu2SFwwkisA2HjqDMtowTmonA3PJZSZgmpSR4hOt/UXycN1aDusky49k M0d8rZPyOLU/kybEk/62u757D3AklBLfqhJZfJeBcbWRUK+fDhT7vNECoE7I9ePQKVk7 UGnLUy0Dydog3j0b4rKx0taZ3iJhocu/k8CEw1nLlY8xLWCMzqiyMu04+/LwSL0sCciu /OrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707602006; x=1708206806; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OmNBPg3VhiKxOz/cULC4NqhIweOs07gq4ld1aCJ07ik=; b=tG5uMqD7hCEXB7EmIgyt+RVe/UYtAI1pPWA9BaedwFw1ZsptW4zPgoZALX+eoNfUKR eDtVNMRe+zO7X+M6SURrOKYGOarA9DTjQd1vCpRRnlzvUMvFNralitJwmoakme64GFy+ UxMZYkeBDuFAK7905ouWjKigz9LKWJ6i2OjAUWCXcorVjM5SNKY9O2H1f4PzxOzpB2aI R4JPTo29mwttlWAzbdglLxyymZF+Z9b1vDYuh4ABCQ7n1GQuLUOoGIWaGzzi+kcrm+Mm W4F/Re4+c3brF1iJCYY4PdiwxnX4ePzOejDG1nH24ugfBF9YRYDqQ/AmPV3btTtJ+Yhp aKTQ== X-Forwarded-Encrypted: i=1; AJvYcCU/cJV+MAY9aJnlWuFyA1rPChCEo2OtPxZG40cbVbSnIAPI/Xsd8i7YbymwPMxXjqDyWPhUaogZ8v0ubmRXgaY9tBYESKujdm+RpCp+0l0wvLhAG5XgA2RL0LT6G8ylnIx3ETQWdtAwYwI= X-Gm-Message-State: AOJu0YxdFtMkVYaPpKWC8yq68DWZyeZc95aL5fPfu1zLjsgAmXKjAsBi TUWaJeuJwy7Jg0//qSOpV7onLyxaFKsH/uGX9jsgdz0KrEm4GV+Y/JpcxDQr6MM= X-Google-Smtp-Source: AGHT+IH1MkC8JlAa6ok/Ho3gydGYTceQL7WsLWlITu0ssxcyQuJf3Jc+ddV0yuuKdyKBLFlh0OltjA== X-Received: by 2002:a05:6512:104f:b0:511:6ef0:33d1 with SMTP id c15-20020a056512104f00b005116ef033d1mr1893615lfb.13.1707602005668; Sat, 10 Feb 2024 13:53:25 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXpRR7HJZqaXevIfw6iIyhAwY/evQBQmdJ5JdA89zOvE6c8S4ZXVucky6TT2udu6PhZLAC2xaSQDSWsMwYQQVLk8uHWhGdfNmbVRA4r0suNeC6y0B/6T6+Nj2xGy9zDyUYUsymrPs9AEHHPrtp5Wk6IZ3pPdm2RkTQMCjBq+o/ED0QAhiHB55t76LI94E+zjYkdkfoLWSsh7qWVi4IHWSWSgfZyIewvuRbdRTy9sA34y+jWd2v+rpBVcpKRgQ+izYavgQLieMF8iX+4ebJV9qbDTB2D7oUhMKgABgoVGXo/FeAsiSYuAt65kbbTg5lm+afOD0Nkj6pfrhduFdWFJv3xOBudtjUiDKjI+ravAFkoCJ2NX81W1w== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:53:25 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 09/19] hid-ft260: uart: wakeup device early to not lose rx data Date: Sat, 10 Feb 2024 23:51:37 +0200 Message-Id: <20240210215147.77629-10-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Waking up the ft260 device from power saving mode earlier reduces the probability of incoming data loss. Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index ccd20f590720..6266e4f1100d 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -1285,8 +1285,6 @@ static int ft260_uart_change_speed(struct ft260_device *port, bool wakeup_workaraund = false; int ret; - ft260_uart_wakeup(port); - memset(&req, 0, sizeof(req)); req.report = FT260_SYSTEM_SETTINGS; @@ -1529,6 +1527,9 @@ static int ft260_uart_activate(struct tty_port *tport, struct tty_struct *tty) ft260_uart_change_speed(port, &tty->termios, NULL); clear_bit(TTY_IO_ERROR, &tty->flags); + /* Wake up the chip as early as possible to not miss incoming data */ + ft260_uart_wakeup(port); + if (port->reschedule_work) { mod_timer(&port->wakeup_timer, jiffies + msecs_to_jiffies(FT260_WAKEUP_NEEDED_AFTER_MS)); From patchwork Sat Feb 10 21:51:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 772176 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25A8E605CD; Sat, 10 Feb 2024 21:53:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602011; cv=none; b=FbvPDI8cK5ognvBFYEHyJuMwOXh5Jy2FViBDl5s24bGphoqWKFeiq76CbAbqS9qloSbDFPgi0jMgjgrMN5X0lNvtI6rl6348JYcACcDnyZVDZc+vmJopx8mYMS4jhFlNNJTrtkO5EhSuRZTUWxYuuZJOwTb2/2I6ivZkntPAKLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602011; c=relaxed/simple; bh=2HQBC1oCduA1pQkfyPQWKTxZnkT8froQM0NxJlNV7vQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HguZArN5U7T3Sdgtji2iqcdlfQxY6H1yYjzNiNDllfDjAGwcAVTMPxTj95q62i7Y7FYsEZy/zg7GBclKvdRsUTXIFpwIfrTQeGrptXMyaBxorB6ih4aOekHiExwuDYJrhemJT3qEYqOImHQzbziy279qaIjNQ1gUj+ydwfSAdGg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=K95GaYks; arc=none smtp.client-ip=209.85.208.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K95GaYks" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2d0ce22b5f3so22955021fa.1; Sat, 10 Feb 2024 13:53:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707602008; x=1708206808; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oCEBZkfO61YkhowePRQkJqIBYwM4+/L7NoDioaq1Xjk=; b=K95GaYksu40tCIzBWF+EsENOAXhkY9qU0IGPFFN+Vz57zzWfT8fJFVRsZfV4RPMnFn xuU9jkUvGVeVyh+KJcVCGZEuLAKmnKQFzJOL55iTZFy+XnkfUfNu/vdZr8Npt+2LJXik DndQOBQQORZNWNrw8WHDMfmYfvVBUqrSaZXPyz8PKpuzJlZ9miCfJhdgTv/QlToNiWVR TAwDLSJcPqNpWm06VUs3MmSs96wg4GuaTlRj8drhtQDuDMb6w4BZLhhY+LauYOiZwJhb XC+w95mvKxEXUg6dYlctFQRt/JV7M3uiDY8Ggl3BJnvGtZi6U870Ry8r2N/rm1k2/1+I Ne4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707602008; x=1708206808; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oCEBZkfO61YkhowePRQkJqIBYwM4+/L7NoDioaq1Xjk=; b=nxhXeMYEmx90RFKvwZvLvb4E9SCME8AsVvV/mSiNGJz+lvEN8SAAI9s8WcwTPpDMSA qeMWa1ewiP25WxvdeT0LoKAzUQiixqP/wYwWX5NBQYukEocFLdeyFEeK36PZE7gOFmyq 5b7WlsBq4InDNytyR8iitxXRCS+/VeYt8NuxBwgsrUizy92wQi+jZydh2DJ0ovO21oWZ /yygLYkHSL3zns0o6Dd8GT/mdZW3Kz1fOciFu7ggYK8LxUFJ7HDJZ+sb7uYIXTmS+L0Q KYp52tLORSjym1vX2Dp28KwP+1cLgxG8xeuqQ5Jv0E/GYbU5INeGo76sFII5unn6Njvm EHvg== X-Forwarded-Encrypted: i=1; AJvYcCVanm+PvCoeW4NRY81vsTZAqn1IjMU6jXDS1u4+6Rhg0H5AkFkQHnYORowdmNYAE4hTRX7Xb91bvRCn5/MNUIjl6N9URgjtNNE4xoB//GxypVWjc1RcoD/gJHgndcfhOJ8OaSmhk7Z3XSk= X-Gm-Message-State: AOJu0YyPJYZa0zsWzfw0+kUKIvX91rv2KdpIBIfVV5Wg2y2bvHs/ssZs 59uNVM90l22UspzEeAnBF8EDHmG0JvNiC50Oc3Cg2ppHvTHUxkQb X-Google-Smtp-Source: AGHT+IHNtXs69wkFhrqzHye+hspqM6GAnmLGKC8Oqu7KdPDJ832kJlkZXzfmfSfDRdwvgxFMeBaYYQ== X-Received: by 2002:a19:6501:0:b0:511:636f:ac29 with SMTP id z1-20020a196501000000b00511636fac29mr1426761lfb.64.1707602008134; Sat, 10 Feb 2024 13:53:28 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXK9kSfWuJsAjJtx34wlp/Sj2QLR8k0bLBY3mFY6YRkal3tGIOAusIHwEHuJ4b0DRjK/k8DiNiTwoXEQEKeNsrYxb4K6Qb17DznISY17hsFB2YrEXOpPlu46TsGxKj4DG88oiyyeywDqa1CfFcG3A9CcZ0czweZYKdXhtCfZHX8JqY6N0gZUG04HXfKa8jhly8HdBj42aSre7K4kDyErH2qOWWoapaN0DpMqWXJTZovgLrWGj/T9GmW89iInQSpxJipc7KbexFrXw9qtTQuK7R1/FxSGPzE8vLOY0VB369MNSnVQ8o54MnztpGct7H5cKEmBX7I4lwZokIjd+Ln/pf/LLilrlQX+VzoWanftkI5ypCDKKewZA== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.53.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:53:27 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 10/19] hid-ft260: uart: do not configure baud rate twice Date: Sat, 10 Feb 2024 23:51:38 +0200 Message-Id: <20240210215147.77629-11-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The uart speed settings are configured twice per session: the old settings - by the ft260_uart_port_activate() and the new - by the ft260_uart_set_termios() routine. We do not need to configure the old settings per tty session since they have already been sent to the device in the probe and passed to the tty via termios in the ft260_driver_init. Removed their coonfiguration from the ft260_uart_port_activate routine. Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index 6266e4f1100d..63839f02e9b5 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -1524,7 +1524,6 @@ static int ft260_uart_activate(struct tty_port *tport, struct tty_struct *tty) kfifo_reset(&port->xmit_fifo); spin_unlock(&port->write_lock); - ft260_uart_change_speed(port, &tty->termios, NULL); clear_bit(TTY_IO_ERROR, &tty->flags); /* Wake up the chip as early as possible to not miss incoming data */ From patchwork Sat Feb 10 21:51:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 771641 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C082660884; Sat, 10 Feb 2024 21:53:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602015; cv=none; b=NFgNgDDbhfX8lzedNIzD5wU8KMXlrDqJSsJld54Du/YGeMSO0mVg72xlsVNxx0OhoFa1wfb8m6tGMsEZNfyx/HYAmB1BV9Pk6GnuegPxJSrw+LJ0YET4u5YeArGM7hPDxu3q1ATen+zfAT6Wxa56Zdlie2JAaCx9vuMj8pet3gA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602015; c=relaxed/simple; bh=uZ/iEzHzCIhr+xNOOG6BX4XQZBvb2bh0UdKtK6p9C9Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=A4KwR/HcZkHYZ7SluVbHpAvkkTazo5+CO0xlKEk8ZsEpzgN5Eh+g6n9tQxwEU7GxErbvrzrl8A/sHYh6jzoU2AabVkHXtJpsuPCUVHOFqZG3aj679WOoeawtceA2R5QpNnAczd13lQMDJKGqOJ/+tHjV0UbL4XouHJlk8R+TPHk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VV/ZGUwd; arc=none smtp.client-ip=209.85.167.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VV/ZGUwd" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-5116b2dbd16so1896389e87.1; Sat, 10 Feb 2024 13:53:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707602012; x=1708206812; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CE/tMEMANhtdsJoNIgspcl6/nRhH557LKBYohiZkZ6M=; b=VV/ZGUwdRZiQbR1RvL2EH/k2hiPaNhyjQ7W1WHPSDdyRfWePkUuk0YbwlD5ybLMuLk kc8rQzlCCuB058rPTXkZKTV7lxyi+o/Ob8iEskWQCSFOWVhNCjVPf52MWpANK3oPoWvH cBXCR5LVIHiaym6fjw6E6F1ACrjjl9R9RyWH49vrySZ0fMCjh/okvKgzLx9cMSjf4uP3 /qlSUD5tq8wL53uK5bF2S+inPr3xocs+vduOD8qN0kp8fVh/ft3dI8bvMWm9e8Iebshu gsBsEt3+/8W5vgFbSDDtC1vtwxV1I3aJBFk16IRPYppFNieMUsHL5i9pfDAcAuIcsTB3 D82Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707602012; x=1708206812; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CE/tMEMANhtdsJoNIgspcl6/nRhH557LKBYohiZkZ6M=; b=fRmTY0KnwmY596qwKe7dlwDv7OSyNII6URI7BXFcVv8RBBENf53k2Exm97BmePRHRe UBJzWzZTppga70wPydUuSJe2gnMTpC3epDCpBxXeYkMdtHsLvN7uztR4myjMzVh1F39u 4tpMR49QFW+9UZlU1/eF5+mFXtelkH8Sc2N6pCNbTIli9dc0sxZia5W42H/i5KuKA1ZR N0Ng0l5God3HqSHFTV/Q6Q65D1ALWkWMD9YiGwH1JHmdDQ0iktdzoznZjlhSj36Lbidk rrBQIz0l6LpSOLvFZ+INZAjFRQldIXru19VzKb5CuBfEeVCde4Lh9+1fF8yvN5JUsmtP qS9w== X-Forwarded-Encrypted: i=1; AJvYcCWb+nwvmtV4LIOVUnMID+HKwKfidZkdV+zsMPoBlAj1mSe4iA+v0xMhvAg6W6W1i7gJbiWdz8+xWMBzECyfvxIBEepQxuWRxx+Qy49lqjyk+VPl2P2PdHGpa3QgOgSWGBaisdCF3uyFjDQ= X-Gm-Message-State: AOJu0YziS/ri408HFcVJwB0ReUwO1ARv2MM1NFnlqkId1Ma63qGho+qJ CZZMxdoe06oIVIm+oYDPpqeoAcOB+ZzPYqBqYDxRCb9aHXHXE6IK X-Google-Smtp-Source: AGHT+IGBj3+WUy+pImZngNF3w0si/MoMZcVC0tyTqNTsiFYm7kVn4yav0KugDUPggUYoc6bsO8gjxQ== X-Received: by 2002:a05:6512:7c:b0:511:889a:e3ef with SMTP id i28-20020a056512007c00b00511889ae3efmr96626lfo.5.1707602011842; Sat, 10 Feb 2024 13:53:31 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUZEqxMzhH+wqfPpTsjZqyH5h6GGyqVmixr1O7B/iLBtsEF+YAvIw12ixjWIiuXmjuH0/QuqJrZ3FkJeyChcylDHbQLSFiUutnNx6+k5JW+6Uu7RbNzl6PPsHcdeSj+2DlzsUdKlXph3xjW7SzQgdV9yS6lMmVMOCr77/07I4vpLrg4bvjQ/IHlrLpJoEL79qG1mZvz0KbSMjVcuPEILsooRZPs8ExRWVAV31yesXWukGG86K48Tvh7MkVShz113Vk/CSns5XNqoq6mueqJbcIY3NhA26ZmhWk9D5GMobBfZokHg7IwVRVIUSgkSrVJKRRcRTB+2JGqr8aW88cf/wyRRYcdtrnXDlj2NZ8MbtEzuxUTCRFcQw== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:53:31 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 11/19] hid-ft260: uart: do not disable wakeup workaround twice Date: Sat, 10 Feb 2024 23:51:39 +0200 Message-Id: <20240210215147.77629-12-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The wakeup workaround is terminated twice: first in the ft260_uart_port_shutdown and then, in the ft260_uart_port_remove routine. We do not need to do it in the ft260_uart_port_remove routine since it's always called when the wakeup mechanism is inactive: 1. Upon the ft260_uart_probe failure. 2. Upon the device/driver removal. Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index 63839f02e9b5..f8d4bf7e6c4f 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -1124,7 +1124,6 @@ static void ft260_uart_port_remove(struct ft260_device *port) spin_unlock(&port->write_lock); mutex_lock(&port->port.mutex); - ft260_uart_wakeup_workaraund_enable(port, false); tty_port_tty_hangup(&port->port, false); mutex_unlock(&port->port.mutex); From patchwork Sat Feb 10 21:51:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 772175 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69CA76088F; Sat, 10 Feb 2024 21:53:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602018; cv=none; b=Vgyl4mJbsXde9782gZqudL1MTLumr4sc9TGESICQiaME83s7rltmpReYcxMEHMT0qXvuo4ddc0vsDYKLcMT0VIJ7KOA+NtT0bAJV1hYlQ9YJ7e6ubMKBssp5llbuCynF10YQ/0i9uIkp2ej0D04smi+Z1iOulWwRsxu6pZnhfII= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602018; c=relaxed/simple; bh=ySgqpJ/s17i6lGxYCSwWoimJrGRy6L5UY5mJ/EH+6yo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qEjM2ikzQ9O6H4f6SW2+Wxes7jevv5hkMgJ2tfNCDFOv4Czy6cBIzAz8mfPbP82SRC6s1084wDxhRNOHJZL/IZSMpKL8H2Ij9cC5K9a2es9m+sHdxXs7bBGm/UoCDCxxavbHGEWTZZfPR5ElAG/krHWj2TETs1RNlBQG3V9nNYA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Z73ZevZk; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z73ZevZk" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5116588189aso3761049e87.1; Sat, 10 Feb 2024 13:53:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707602014; x=1708206814; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u+hI7qeo1D9gyYnUlkKG3fcFOY/MIqlDtpV0SLWt3F8=; b=Z73ZevZkPnaY9etMA6tBndgTH5lFUNdnLEmltubNZw5GvYxhP+b0A4aYR04EiaRyn5 j1XcQAedmBCJfuxNRVM6kP6FsQO4ahlDeLpbiRHT6L0V+3pHgjL507UdKy2TqMaMQkiz jxthU+Thjew+X6xvfAEMpkNEON2xqlttskuVAgLeULxmBezbVWl/U6vAUHGs1cETls92 ucwXTl5Ocd3R0ouYkoAKAl7MVom5aenxGSE8rcaqMSJgbN+yAYuR/eQYK1d6w7tzqRMI owyN61+KdKJS0ICrjGzSwW7Z0/79+lhBSNtLrMYIm5Wu0YubxfNIIW1LFgb/+/JlZ2/E ancA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707602014; x=1708206814; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u+hI7qeo1D9gyYnUlkKG3fcFOY/MIqlDtpV0SLWt3F8=; b=AEdsS5u8YmygEbmdtZLHjs6HvJXCeeOqlic2m+i8WJZVsBB6XPNdQ7i+RqVcgGQ80f UqXrXdLZjQpuzp7i5Yu/vnhrXDNGmvVHtzL/CJWIWC7qpbpS33w7aob9e/4l7vzK5ArY LBBwil1q7ZThRdxj9sjLLaY3J47IFG6p+Obv2h6HJMItWH+eZDZvrwPbvb5mvqRjJPPN rjVBG/lGlE99pDnh/nneNFOmtVoe9e3IKk14am6J+wU0fSrrEgGefPyzkUCj887Pp9Zi FPTwXMvL1tAc+kz1xaoAhAxlGTD5bwa58986NNneYWYIAgFyrXPDMfEdWLKikU2+dcUN 1ILw== X-Forwarded-Encrypted: i=1; AJvYcCVx69Ej2nwoqiLD9fKZgGCNcE5Fe68552IwmZDKFzRirR8nKxS5p/Q4O5WIMwX7r1470hX2DW+OhRvCaz7BSkhysEdoJfMPrtW/S3f6iWbAHNBYGYqq5sZUVFhzsza6G4JLEVGxBCZQoPw= X-Gm-Message-State: AOJu0YyKa/fjECBsDfRMz5dUKMRrtkAxnklPMMmuL76bIwIliq/AJIdA Ars7hy/+GuSsSGNQVPKpzsMiyA3hHssYU8P+qB/pqOX/UiEjlLPh X-Google-Smtp-Source: AGHT+IGZbdzHR6z/GDfg0eZ7PqBmHRRuhM3o4dRT7ySPAR0iJLVLzaUrmz2Zp0soZrzhWGnP83Kytg== X-Received: by 2002:a05:6512:3ba6:b0:511:33d4:c99a with SMTP id g38-20020a0565123ba600b0051133d4c99amr2208570lfv.61.1707602014417; Sat, 10 Feb 2024 13:53:34 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW43ztFfTUOkWc5NU3thkM0MOfULXb7jJ83SMO+SSeDMGpv3V3IZkY9SLxzB7a7HN7TM4c7+um2faE31oG7mSyztQ0Sby6B8qOVS+tcrW6HYYSMl9df0899uE43X+XfZ0hSl0qigdz6KDmHXMsxzUFw27nKZZrGf6YJNbbj+7E7g+m1zJ0XwIQDK2C3R01PlaGf9J3NcnoKEChiTc6VqAvxIum0wf/aQCbXMjt3Dq4qzpAIT1g1IHCIufJgJotH/iUOaJkimVBoZELDQiNso9wmhSWR3SNuWBYE4zmaCZKMmzMTyOgjs8+chZv6/sSNwjywYz0ek00r7h3cPtSyzMt5EodjPPURw80sgOggo07RssgAkeScUw== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.53.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:53:34 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 12/19] hid-ft260: uart: use kfifo_avail for fifo write room check Date: Sat, 10 Feb 2024 23:51:40 +0200 Message-Id: <20240210215147.77629-13-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace uart fifo write room calculation with the kfifo_avail kernel API. Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index f8d4bf7e6c4f..3d1a9ec88cb9 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -1264,7 +1264,7 @@ static unsigned int ft260_uart_write_room(struct tty_struct *tty) { struct ft260_device *port = tty->driver_data; - return FIFO_SIZE - kfifo_len(&port->xmit_fifo); + return kfifo_avail(&port->xmit_fifo); } static unsigned int ft260_uart_chars_in_buffer(struct tty_struct *tty) From patchwork Sat Feb 10 21:51:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 771640 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C285060884; Sat, 10 Feb 2024 21:53:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602020; cv=none; b=C+8VFLmLIyWSU0hIXnEjXX1/YrUg2jm+Ste2TOn5C6Q0v1TibD2AybLl4+t4W2lNaOOKHNh3aapAC2rQVED0v4/nghUai+fJj+kBzOzRmHoGwulv97qgykHr6CxEZBlmBnQY82cAdqtMNU4i/rIf+S/sGHi/uvCUpVOcDkefF7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602020; c=relaxed/simple; bh=bxc8EJBTU97uaAgMzrUDFX/3ZhRiWUNfsRvqcbGs/6c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Rdic3ixZ/7C5ualGvZxnQkxP17nGMhRF8puwaHG9kRQEu2Ko+Y0BDZGNTG4U9xy++M2SPagdcdyBy3j+wwIcT5S9sYjFF77TtmC7UGLbxb5Cj+fS7uou2ASowjRgZEVlQDQLjFnvW6bHLtYdE4XvEWFjbTk9JGWMEeuv5THdQ0c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NoYi3Gv2; arc=none smtp.client-ip=209.85.167.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NoYi3Gv2" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5114b2b3b73so2465771e87.0; Sat, 10 Feb 2024 13:53:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707602017; x=1708206817; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9Fkky7a9eT7SBkGtnfLXUQcC5w2wTxfnvBE3rXTwzAA=; b=NoYi3Gv2+8slDlMv3RhL/qHd31BUlLKnVRzF+qv2auZpvD7lmwCvVUIv05HuT5SSK/ DElsuwHLJSV4OKK6H4auehMVXfNPDbblZSlrTinsTNDm+jxElpfAEQQnDl98FAgX8mEK 8lCcMg0AqTBqf4sJM8HecszL9/1NL8cTtOFEiQqEIz2jQ4PbKZwfjoCo+KrqeG4gRlBA 1jXUNElXaQaTAkxarKj2C1t6xcyOPJVmkM+CLdgbRO5zFN2SETjaxLdVty5+8o5JB1F9 jPpcWZ5/mSK411hw3LYJkLNo7zS1EHWUWGUBpXPNEGePQFNKT3IHxoNuBMqaHR9fvRHq 8vGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707602017; x=1708206817; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9Fkky7a9eT7SBkGtnfLXUQcC5w2wTxfnvBE3rXTwzAA=; b=hY/RhWEuWjRpQ1iwZ/343kpYidMVeTaiaBuluyi45BOAdIvfoThNY6B0dz7MPLiMhf U+qynUeq6FiWyvP6v6c+wzLzEM9Re005gNvO4d0ZZJJXw1ywA0OF9T5SwyquutE3QQIG 6lXiEtifpspja6Fed8R80RmgOmAiAB1YMnxtNClYKp202EhmixtY8lvJluQLDn9eBdwo EnzB5bBMNXH4jtEhBZ8JnBKLdtUAETE7zPwklKDo4sR726Xr8nJ3XTwahW1yRe5b7oMI NkT+boRooISU6eWDFkQy13a4G4Iv5nMXuIkKR5uIQXknaKDj1QddsRvlG3UsYI7qiStt iBpw== X-Forwarded-Encrypted: i=1; AJvYcCWlDUnsa9pK9pyz7Mr4d11xvyi4uwm+XO6tswwbZ03Z2Fsdhga3GkTY/3SU/U4TVaABLSOhvDH3AQjMbXkHkaAvOi0T9Mm2wQfSEJSupH8SEoTanNOm5/VXYI6mgxnNjWSQe2QVJ1RRbLo= X-Gm-Message-State: AOJu0YzHBPJWM5ta7d6P/b1cgnOAaJiz23dHIpu3x+3BS3jl4JAFtLkE 3fIBUZcXvKGzkugXLnyDrQXs7ejwD5v+jgZhWZWNQ5dLHmpjOdyP X-Google-Smtp-Source: AGHT+IGZUoy9DgL8eOxFwcpjypDGMxA0fTk4GJiEvk5rdmh0fCWaCal43bOtiJuJU0Q5RutWI4dD0A== X-Received: by 2002:a05:6512:3994:b0:511:76e6:e0f9 with SMTP id j20-20020a056512399400b0051176e6e0f9mr2693656lfu.20.1707602016878; Sat, 10 Feb 2024 13:53:36 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVLG+/0Sw+CxnHF8MX7j3iHqX+zPcGBaAxanzd5wx681sDEwNPArqysdIikDA+56j+wQl8/Sp1Psjc4tku6NgNJXyPeK4odAhY/2KvLaM3D1JWWFH8hASgDdsRMwus1FgLFjXCr1uXkNKMTGvNsDMpqxRbvIoMGCv+p89+cVcECbc66j6cTgrfodOLjs0Jy90IZBE5JfiaXqwJpZ64TYXh2EVTAc0VmeB9MVGKIjACkQuGb6TjsToPO7k3xihSiHqWsyvaafyzDfdC+bP4WvoiuU/J3OITE0ShldqBjCYDfVIjDKPKi563wMRSZR8W4E4zkW23r5K8ojposWyFg9M6U281Qui9SteWaLVDWmLoly9Pch5SGGw== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.53.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:53:36 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 13/19] hid-ft260: improve usb interface type detection logic Date: Sat, 10 Feb 2024 23:51:41 +0200 Message-Id: <20240210215147.77629-14-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit simplifies the ft260_get_interface_type routine by replacing the ft260_is_serial with iface_type and making use of its return value as it's in the mainline ft260 driver code. Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index 3d1a9ec88cb9..9ecd91d173d2 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -309,7 +309,7 @@ struct ft260_device { struct i2c_adapter adap; struct hid_device *hdev; - bool ft260_is_serial; + int iface_type; struct list_head device_list; /* tty_port lifetime is equal to device lifetime */ @@ -889,28 +889,25 @@ static int ft260_get_interface_type(struct hid_device *hdev, struct ft260_device ft260_dbg("i2c_enable: 0x%02x\n", cfg.i2c_enable); ft260_dbg("uart_mode: 0x%02x\n", cfg.uart_mode); - dev->ft260_is_serial = false; dev->power_saving_en = cfg.power_saving_en; switch (cfg.chip_mode) { case FT260_MODE_ALL: case FT260_MODE_BOTH: - if (interface == 1) { + if (interface == 1) ret = FT260_IFACE_UART; - dev->ft260_is_serial = true; - } else { + else ret = FT260_IFACE_I2C; - } break; case FT260_MODE_UART: ret = FT260_IFACE_UART; - dev->ft260_is_serial = true; break; case FT260_MODE_I2C: ret = FT260_IFACE_I2C; break; } + dev->iface_type = ret; return ret; } @@ -1713,15 +1710,12 @@ static int ft260_probe(struct hid_device *hdev, const struct hid_device_id *id) mutex_init(&dev->lock); init_completion(&dev->wait); - if (!dev->ft260_is_serial) { + if (ret == FT260_IFACE_I2C) ret = ft260_i2c_probe(hdev, dev); - if (ret) - goto err_hid_close; - } else { + else ret = ft260_uart_probe(hdev, dev); - if (ret) - goto err_hid_close; - } + if (ret) + goto err_hid_close; return 0; @@ -1742,7 +1736,7 @@ static void ft260_remove(struct hid_device *hdev) if (!dev) return; - if (dev->ft260_is_serial) { + if (dev->iface_type == FT260_IFACE_UART) { // FIXME: cancel_work_sync(&dev->wakeup_work); tty_port_unregister_device(&dev->port, ft260_tty_driver, From patchwork Sat Feb 10 21:51:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 772174 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8893B60BBB; Sat, 10 Feb 2024 21:53:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602023; cv=none; b=cCfOM+KR8aXX9J+agykmOOhLYn2R5iGi7//mi5PKBht7iTvDRRL1gNCiEHLTTy28YifSijUmjQautxZbTwZ/dJ/ippxFuQMX8jvNRu6C/4A05WHm9JTgaQVBlqgmcBbP1pZOivXg0j9qFUvrs6jZaNQGSczbsLFSCF9hwLRLZ8g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602023; c=relaxed/simple; bh=cZVvMaKKvGT8H+94FmxDb3EJDNVeQNc3Rx6t6Z+hAow=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XMJGdo0TlDa/fRFBDVC7tvG40bISRNkvWyeWn93uviFrcuV7J8ZXhgapmqloF0dtHMm2yxMaNi4hEHWohjh1LsY4mL8ZeYgmcQdHc0sWZow6vUdp062W6+vctT7eojwr8b86Lqxyh9YdyCHgnqxid0hF4ytQLi5iJL6eTRP4V7Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EUylk4x5; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EUylk4x5" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5114cd44f6aso2779353e87.1; Sat, 10 Feb 2024 13:53:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707602019; x=1708206819; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1eIEXGPhrkeg0Pp1+p0C7tV+cMPOV+tqxXjLVVI0E5Y=; b=EUylk4x54yptqEM81B2EHKlIeQ/OokY+2lvNHPekjN1CJzASYqpvn4bv4zKoCLSrNf UUQRhO/QBumd4OMJRhyq9rtn2zoIMZnc+a++epZaAfqqswgKYWoiaHvwtpVKGRvG2Peu vhShh6CrXBojbX4rBSFGEuz8w5dg8BHc4vqijOlkCo2o0kl1icEVO/1wgM73nYAfvzd1 nac7g7Aq8P16mXeqZsqRD92N1IdX2e6nZJsssCE3wBpU+tE5bmkC42ecV5eBqSEbpQ+r cSoUxp//NcKAiuWp2EkKIUeQhQRnwPyy3JA3iFOixdJCItdwIX0DagRg5FAd1qsZcMyH eolQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707602019; x=1708206819; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1eIEXGPhrkeg0Pp1+p0C7tV+cMPOV+tqxXjLVVI0E5Y=; b=A48u5n76Ja34p6suMSWc2woR4eeekMeL+vKY/sJv2rm0Hmmhwn0QV2xUqhZvN+xEpy x8SXt6ahmdZyu4kkDuYAtKyjBIfOrnxeyMt7qJJAX9qFTp1tZBmFZ2770LxlFuX1RaOO QfgQV3dK+EtKsyQSeFARFM2eEujEz8CPSSKWOeXLS1oFxlYHqg2hCg9HsEBw4L5bI2B0 MBULZEToiEbYY8lRl5339UL6ZqDYaWfbrS4+2qk+Q4F5pnikMXRMmSQg3PsJG7UETL0P p77ZaxH3kixwdgyw/g9+RfdW7nzAnm8cvijJwejcscKIxufQyzKyAHS+7oY/QQ/j2qQp d58w== X-Forwarded-Encrypted: i=1; AJvYcCWobNLrEHWvTABbY6RP40pKP7dTfB2oGTUFN7X0qwWTi7XXoMk/atm/IcqSxk+qlfmzJTxaVHDrCna1WWKfnq925M29E9mJQiTbaqttVYSsw4EUvXijHwTwdAz+SsRUNvZpADX7nTVX23o= X-Gm-Message-State: AOJu0YxzN3VYj2Wl42J2drd1tvI17oU4SHtBBNK/W4v4CIU09eqSk3yt gNANYcwjM15FEKGkDkW9RjXNVyHGnwRywfAEwFDdwdYfSa30SkVL X-Google-Smtp-Source: AGHT+IEVBS0mSKBsrKF3sEkqSzPBEYYSK28/p3dGwKh4kvokNd+AEfTVc2t6wfvauolnYsNSQtSfYQ== X-Received: by 2002:a05:6512:3048:b0:511:676e:a491 with SMTP id b8-20020a056512304800b00511676ea491mr1972191lfb.18.1707602019319; Sat, 10 Feb 2024 13:53:39 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUvRi5uzJLSskOIko9QGOnZpuVNvIseaGO4QAfB6uKQF2/fKZHlXTjO6/kX/uGCMD9n1Yjs2JJaztKem7oDvv7ZkIUrcu8p5OsrhTAgB3SUzCfU4D5ucQIApVQLSrhN00YBHYE+TwM0kIVygeP5k6fht0Q+geUsWlWc4gBK9e63QE7aWJlmnXzLQwHArrpBLct1QJiYGQcFkVNAyHaW9KbVLHpiUHIrrm8vdpZjytPaSVtRNljSNtxfb5zi2iyckTbMRVJYBYYRNeMg6Bij/sA9WShQddB0t+umIx9PSOh28hHfWZfIC4/nUjric6zDVZw7+DYrK+0RQVmzPHo9K+i5BASt0i8FxvoDBT64CIVR7za5fzO0Uw== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:53:39 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 14/19] hid-ft260: uart: cleanup and refactoring Date: Sat, 10 Feb 2024 23:51:42 +0200 Message-Id: <20240210215147.77629-15-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 - Cleanup printouts and comments. - Refactor to adjust to the module's style. - Replace the kfifo_in_locked/kfifo_out_locked with kfifo_in_spinlocked/kfifo_out_spinlocked since the former may be dropped in the future. Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 148 ++++++++++++++++++---------------------- 1 file changed, 66 insertions(+), 82 deletions(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index 9ecd91d173d2..1c113f735524 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * hid-ft260.c - FTDI FT260 USB HID to I2C host bridge + * FTDI FT260 USB HID to I2C/UART host bridge * * Copyright (c) 2021, Michael Zaidman * @@ -18,11 +18,7 @@ #include #include #include -#include /* Needed for cpu_to_le16, le16_to_cpu */ - -#define UART_COUNT_MAX 4 /* Number of UARTs this driver can handle */ -#define FIFO_SIZE 256 -#define TTY_WAKEUP_WATERMARK (FIFO_SIZE / 2) +#include #ifdef DEBUG static int ft260_debug = 1; @@ -148,7 +144,7 @@ enum { FT260_FLAG_START_STOP_REPEATED = 0x07, }; -/* Return values for ft260_get_interface_type func */ +/* USB interface type values */ enum { FT260_IFACE_NONE, FT260_IFACE_I2C, @@ -250,18 +246,19 @@ struct ft260_input_report { } __packed; /* UART reports */ + struct ft260_uart_write_request_report { u8 report; /* FT260_UART_REPORT */ u8 length; /* data payload length */ u8 data[FT260_WR_UART_DATA_MAX]; /* data payload */ } __packed; -struct ft260_configure_uart_request { +struct ft260_configure_uart_request_report { u8 report; /* FT260_SYSTEM_SETTINGS */ u8 request; /* FT260_SET_UART_CONFIG */ u8 flow_ctrl; /* 0: OFF, 1: RTS_CTS, 2: DTR_DSR */ /* 3: XON_XOFF, 4: No flow ctrl */ - /* The baudrate field is unaligned: */ + /* The baudrate field is unaligned */ __le32 baudrate; /* little endian, 9600 = 0x2580, 19200 = 0x4B00 */ u8 data_bit; /* 7 or 8 */ u8 parity; /* 0: no parity, 1: odd, 2: even, 3: high, 4: low */ @@ -296,7 +293,11 @@ enum { FT260_CFG_BAUD_MAX = 12000000, }; -#define FT260_UART_EN_PW_SAVE_BAUD 4800 +#define FT260_UART_EN_PW_SAVE_BAUD (4800) + +#define UART_COUNT_MAX (4) /* Number of supported UARTs */ +#define XMIT_FIFO_SIZE (256) +#define TTY_WAKEUP_WATERMARK (XMIT_FIFO_SIZE / 2) static const struct hid_device_id ft260_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_FUTURE_TECHNOLOGY, @@ -308,23 +309,18 @@ MODULE_DEVICE_TABLE(hid, ft260_devices); struct ft260_device { struct i2c_adapter adap; struct hid_device *hdev; - int iface_type; struct list_head device_list; - - /* tty_port lifetime is equal to device lifetime */ struct tty_port port; + /* tty port index */ unsigned int index; struct kfifo xmit_fifo; - /* write_lock: lock to serialize access to xmit fifo */ - spinlock_t write_lock; + spinlock_t xmit_fifo_lock; struct uart_icount icount; - struct timer_list wakeup_timer; struct work_struct wakeup_work; bool reschedule_work; bool power_saving_en; - struct completion wait; struct mutex lock; u8 i2c_wr_buf[FT260_REPORT_MAX_LEN]; @@ -337,8 +333,7 @@ struct ft260_device { }; static int ft260_hid_feature_report_get(struct hid_device *hdev, - unsigned char report_id, u8 *data, - size_t len) + u8 report_id, u8 *data, size_t len) { u8 *buf; int ret; @@ -467,8 +462,6 @@ static int ft260_hid_output_report_check_status(struct ft260_device *dev, ret = ft260_hid_output_report(hdev, data, len); if (ret < 0) { - hid_dbg(hdev, "%s: failed to start transfer, ret %d\n", - __func__, ret); ft260_i2c_reset(hdev); return ret; } @@ -579,6 +572,8 @@ static int ft260_smbus_write(struct ft260_device *dev, u8 addr, u8 cmd, rep->report, addr, cmd, rep->length, len); ret = ft260_hid_output_report_check_status(dev, (u8 *)rep, len); + if (ret < 0) + hid_err(dev->hdev, "%s: failed with %d\n", __func__, ret); return ret; } @@ -682,8 +677,7 @@ static int ft260_i2c_write_read(struct ft260_device *dev, struct i2c_msg *msgs) else read_off = *msgs[0].buf; - ft260_dbg("%s: off %#x rlen %d wlen %d\n", __func__, - read_off, rd_len, wr_len); + ft260_dbg("off %#x rlen %d wlen %d\n", read_off, rd_len, wr_len); } ret = ft260_i2c_write(dev, addr, msgs[0].buf, wr_len, @@ -1051,9 +1045,6 @@ static const struct attribute_group ft260_attr_group = { } }; -/*** - * START Serial dev part - */ static DEFINE_MUTEX(ft260_uart_list_lock); static LIST_HEAD(ft260_uart_device_list); @@ -1065,7 +1056,7 @@ static void ft260_uart_wakeup_workaraund_enable(struct ft260_device *port, if (port->power_saving_en) { port->reschedule_work = enable; ft260_dbg("%s wakeup workaround", - enable ? "Activate" : "Deactivate"); + enable ? "activate" : "deactivate"); } } @@ -1085,8 +1076,8 @@ static int ft260_uart_add_port(struct ft260_device *port) int index = 0, ret = 0; struct ft260_device *dev; - spin_lock_init(&port->write_lock); - if (kfifo_alloc(&port->xmit_fifo, FIFO_SIZE, GFP_KERNEL)) + spin_lock_init(&port->xmit_fifo_lock); + if (kfifo_alloc(&port->xmit_fifo, XMIT_FIFO_SIZE, GFP_KERNEL)) return -ENOMEM; mutex_lock(&ft260_uart_list_lock); @@ -1116,9 +1107,9 @@ static void ft260_uart_port_remove(struct ft260_device *port) list_del(&port->device_list); mutex_unlock(&ft260_uart_list_lock); - spin_lock(&port->write_lock); + spin_lock(&port->xmit_fifo_lock); kfifo_free(&port->xmit_fifo); - spin_unlock(&port->write_lock); + spin_unlock(&port->xmit_fifo_lock); mutex_lock(&port->port.mutex); tty_port_tty_hangup(&port->port, false); @@ -1127,7 +1118,7 @@ static void ft260_uart_port_remove(struct ft260_device *port) ft260_uart_port_put(port); } -static struct ft260_device *ft260_uart_port_get(unsigned int index) +static struct ft260_device *ft260_uart_port_get(int index) { struct ft260_device *port; @@ -1191,20 +1182,18 @@ static int ft260_uart_transmit_chars(struct ft260_device *port) rep->report = FT260_UART_DATA_REPORT_ID(len); rep->length = len; - len = kfifo_out_locked(xmit, rep->data, len, &port->write_lock); + len = kfifo_out_spinlocked(xmit, rep->data, len, &port->xmit_fifo_lock); ret = ft260_hid_output_report(hdev, (u8 *)rep, len + sizeof(*rep)); - if (ret < 0) { - hid_err(hdev, "Failed to start transfer, ret %d\n", ret); + if (ret < 0) goto tty_out; - } data_len -= len; port->icount.tx += len; } while (data_len > 0); len = kfifo_len(xmit); - if ((FIFO_SIZE - len) > TTY_WAKEUP_WATERMARK) + if ((XMIT_FIFO_SIZE - len) > TTY_WAKEUP_WATERMARK) tty_wakeup(tty); ret = 0; @@ -1214,15 +1203,14 @@ static int ft260_uart_transmit_chars(struct ft260_device *port) return ret; } -static int ft260_uart_receive_chars(struct ft260_device *port, - u8 *data, u8 length) +static int ft260_uart_receive_chars(struct ft260_device *port, u8 *data, u8 length) { - struct hid_device *hdev = port->hdev; int ret; ret = tty_insert_flip_string(&port->port, data, length); if (ret != length) - hid_dbg(hdev, "%d char not inserted to flip buffer\n", length - ret); + ft260_dbg("%d char not inserted to flip buf\n", length - ret); + port->icount.rx += ret; if (ret) @@ -1231,27 +1219,25 @@ static int ft260_uart_receive_chars(struct ft260_device *port, return ret; } -static int ft260_uart_write(struct tty_struct *tty, const unsigned char *buf, - int count) +static int ft260_uart_write(struct tty_struct *tty, const u8 *buf, int cnt) { struct ft260_device *port = tty->driver_data; - struct hid_device *hdev = port->hdev; - int len, ret; + int len, ret, diff; - len = kfifo_in_locked(&port->xmit_fifo, buf, count, &port->write_lock); - ft260_dbg("count: %d, len: %d", count, len); + len = kfifo_in_spinlocked(&port->xmit_fifo, buf, cnt, &port->xmit_fifo_lock); + ft260_dbg("count: %d, len: %d", cnt, len); ret = ft260_uart_transmit_chars(port); if (ret < 0) { - hid_dbg(hdev, "Failed to transmit chars: %d\n", ret); + ft260_dbg("failed to transmit %d\n", ret); return 0; } ret = kfifo_len(&port->xmit_fifo); if (ret > 0) { - hid_dbg(hdev, "Failed to all kfifo data bytes\n"); - ft260_dbg("return: %d", len - ret); - return len - ret; + diff = len - ret; + ft260_dbg("failed to send %d out of %d bytes\n", diff, len); + return diff; } return len; @@ -1277,7 +1263,7 @@ static int ft260_uart_change_speed(struct ft260_device *port, { struct hid_device *hdev = port->hdev; unsigned int baud; - struct ft260_configure_uart_request req; + struct ft260_configure_uart_request_report req; bool wakeup_workaraund = false; int ret; @@ -1292,7 +1278,7 @@ static int ft260_uart_change_speed(struct ft260_device *port, break; case CS5: case CS6: - hid_err(hdev, "Invalid data bit size, setting to default (8 bit)\n"); + hid_err(hdev, "invalid data bit size, setting a default\n"); req.data_bit = FT260_CFG_DATA_BITS_8; termios->c_cflag &= ~CSIZE; termios->c_cflag |= CS8; @@ -1317,7 +1303,7 @@ static int ft260_uart_change_speed(struct ft260_device *port, if (baud == 0 || baud < FT260_CFG_BAUD_MIN || baud > FT260_CFG_BAUD_MAX) { struct tty_struct *tty = tty_port_tty_get(&port->port); - hid_err(hdev, "Invalid baud rate %d\n", baud); + hid_err(hdev, "invalid baud rate %d\n", baud); baud = 9600; tty_encode_baud_rate(tty, baud, baud); tty_kref_put(tty); @@ -1335,7 +1321,7 @@ static int ft260_uart_change_speed(struct ft260_device *port, else req.flow_ctrl = FT260_CFG_FLOW_CTRL_OFF; - ft260_dbg("Configured termios: flow control: %d, baudrate: %d, ", + ft260_dbg("configured termios: flow control: %d, baudrate: %d, ", req.flow_ctrl, baud); ft260_dbg("data_bit: %d, parity: %d, stop_bit: %d, breaking: %d\n", req.data_bit, req.parity, @@ -1346,7 +1332,7 @@ static int ft260_uart_change_speed(struct ft260_device *port, ret = ft260_hid_feature_report_set(hdev, (u8 *)&req, sizeof(req)); if (ret < 0) - hid_err(hdev, "ft260_hid_feature_report_set failed: %d\n", ret); + hid_err(hdev, "failed to change termios: %d\n", ret); return ret; } @@ -1396,8 +1382,8 @@ static int ft260_uart_proc_show(struct seq_file *m, void *v) { int i; - seq_printf(m, "ft260 info:1.0 driver%s%s revision:%s\n", - "", "", ""); + seq_printf(m, "ft260 info:1.0 driver%s%s revision:%s\n", "", "", ""); + for (i = 0; i < UART_COUNT_MAX; i++) { struct ft260_device *port = ft260_uart_port_get(i); @@ -1452,7 +1438,8 @@ static const struct tty_operations ft260_uart_ops = { .get_icount = ft260_uart_get_icount, }; -/* The FT260 has a "power saving mode" that causes the device to switch +/* + * The FT260 has a "power saving mode" that causes the device to switch * to a 30 kHz oscillator if there's no activity for 5 seconds. * Unfortunately, this mode can only be disabled by reprogramming * internal fuses, which requires an additional programming voltage. @@ -1476,16 +1463,14 @@ static void ft260_uart_start_wakeup(struct timer_list *t) static void ft260_uart_wakeup(struct ft260_device *dev) { - struct ft260_get_chip_version_report version; + struct ft260_get_chip_version_report ver; int ret; if (dev->reschedule_work) { ret = ft260_hid_feature_report_get(dev->hdev, FT260_CHIP_VERSION, - (u8 *)&version, sizeof(version)); + (u8 *)&ver, sizeof(ver)); if (ret < 0) - hid_err(dev->hdev, - "%s: failed to start transfer, ret %d\n", - __func__, ret); + hid_err(dev->hdev, "%s: failed with %d\n", __func__, ret); } } @@ -1497,7 +1482,7 @@ static void ft260_uart_do_wakeup(struct work_struct *work) ft260_uart_wakeup(dev); } -static void ft260_uart_shutdown(struct tty_port *tport) +static void ft260_uart_port_shutdown(struct tty_port *tport) { struct ft260_device *port = container_of(tport, struct ft260_device, port); @@ -1505,7 +1490,7 @@ static void ft260_uart_shutdown(struct tty_port *tport) ft260_uart_wakeup_workaraund_enable(port, false); } -static int ft260_uart_activate(struct tty_port *tport, struct tty_struct *tty) +static int ft260_uart_port_activate(struct tty_port *tport, struct tty_struct *tty) { struct ft260_device *port = container_of(tport, struct ft260_device, port); @@ -1516,9 +1501,9 @@ static int ft260_uart_activate(struct tty_port *tport, struct tty_struct *tty) */ set_bit(TTY_IO_ERROR, &tty->flags); - spin_lock(&port->write_lock); + spin_lock(&port->xmit_fifo_lock); kfifo_reset(&port->xmit_fifo); - spin_unlock(&port->write_lock); + spin_unlock(&port->xmit_fifo_lock); clear_bit(TTY_IO_ERROR, &tty->flags); @@ -1542,8 +1527,8 @@ static void ft260_uart_port_destroy(struct tty_port *tport) } static const struct tty_port_operations ft260_uart_port_ops = { - .shutdown = ft260_uart_shutdown, - .activate = ft260_uart_activate, + .shutdown = ft260_uart_port_shutdown, + .activate = ft260_uart_port_activate, .destruct = ft260_uart_port_destroy, }; @@ -1595,7 +1580,7 @@ static int ft260_i2c_probe(struct hid_device *hdev, struct ft260_device *dev) static int ft260_uart_probe(struct hid_device *hdev, struct ft260_device *dev) { - struct ft260_configure_uart_request req; + struct ft260_configure_uart_request_report req; int ret; struct device *devt; @@ -1623,10 +1608,10 @@ static int ft260_uart_probe(struct hid_device *hdev, struct ft260_device *dev) ret = PTR_ERR(devt); goto err_register_tty; } - hid_info(hdev, "Registering device /dev/%s%d\n", + hid_info(hdev, "registering device /dev/%s%d\n", ft260_tty_driver->name, dev->index); - /* Send Feature Report to Configure FT260 as UART 9600-8-N-1 */ + /* Configure UART to 9600n8 */ req.report = FT260_SYSTEM_SETTINGS; req.request = FT260_SET_UART_CONFIG; req.flow_ctrl = FT260_CFG_FLOW_CTRL_NONE; @@ -1638,8 +1623,7 @@ static int ft260_uart_probe(struct hid_device *hdev, struct ft260_device *dev) ret = ft260_hid_feature_report_set(hdev, (u8 *)&req, sizeof(req)); if (ret < 0) { - hid_err(hdev, "ft260_hid_feature_report_set failed: %d\n", - ret); + hid_err(hdev, "failed to configure uart: %d\n", ret); goto err_hid_report; } @@ -1660,9 +1644,9 @@ static int ft260_probe(struct hid_device *hdev, const struct hid_device_id *id) if (!hid_is_usb(hdev)) return -EINVAL; - - /* We cannot used devm_kzalloc here, because port has to survive until - * destroy function call + /* + * We cannot use devm_kzalloc here because the port has to survive + * until destroy function call. */ dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) { @@ -1742,7 +1726,7 @@ static void ft260_remove(struct hid_device *hdev) tty_port_unregister_device(&dev->port, ft260_tty_driver, dev->index); ft260_uart_port_remove(dev); - /* dev still needed, so we will free it in _destroy func */ + /* dev is still needed, so we will free it in _destroy func */ } else { sysfs_remove_group(&hdev->dev.kobj, &ft260_attr_group); i2c_del_adapter(&dev->adap); @@ -1781,7 +1765,7 @@ static int ft260_raw_event(struct hid_device *hdev, struct hid_report *report, return 0; } else if (xfer->length > FT260_RD_DATA_MAX) { - hid_err(hdev, "Received data too long (%d)\n", xfer->length); + hid_err(hdev, "received data too long (%d)\n", xfer->length); return -EBADR; } else if (xfer->report >= FT260_UART_REPORT_MIN && xfer->report <= FT260_UART_REPORT_MAX) { @@ -1830,7 +1814,7 @@ static int __init ft260_driver_init(void) goto err_reg_driver; } - ret = hid_register_driver(&(ft260_driver)); + ret = hid_register_driver(&ft260_driver); if (ret) { pr_err("hid_register_driver failed: %d\n", ret); goto err_reg_hid; @@ -1848,7 +1832,7 @@ static int __init ft260_driver_init(void) static void __exit ft260_driver_exit(void) { - hid_unregister_driver(&(ft260_driver)); + hid_unregister_driver(&ft260_driver); tty_unregister_driver(ft260_tty_driver); tty_driver_kref_put(ft260_tty_driver); } From patchwork Sat Feb 10 21:51:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 771639 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA12960DCD; Sat, 10 Feb 2024 21:53:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602025; cv=none; b=ASTR6zsZWfQu39HMkZS9xma+9vx5Kw0rnNYMUob+kaoijd1X8ZAIIY8lOS0PNa/NZF4CtYMYRjsBCdw3wXrifrpRCbsvzslJJGN1kZu0T9FuYisjBnRt6iUXS+sI5oE9HOwezwq6ltfLajAwDsVnXxKfFyhho6Waf8AwiVOdHXM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602025; c=relaxed/simple; bh=GNaoWdeQpKU9AVOEB3jYJkdbwqnSb7noVHcccptmsVw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kWWS69zmyR0UDg1iHJ5N7fFV8cWUnDGtpN6BnD/pVhBn1zEJREjBd1NYy0Ub8RHJS62ONqgVR+R8GjEPHFXkg2huzIvyK0BWtme1DHD/9j8rtW50FkTvk/g37h25GBn8Jjyo4wq5ZdZj6FBqTwTV43gFxqbVUBpJ73RPzYdq4eI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZGQE/Anw; arc=none smtp.client-ip=209.85.167.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZGQE/Anw" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-51185c33626so499793e87.0; Sat, 10 Feb 2024 13:53:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707602022; x=1708206822; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xZiCL02JzF0+cmAi1UQWcFqubmumV+rMpnfD27eX/H8=; b=ZGQE/AnwQnVmIRwy4HLdq+2Gnbt5EYWPPZjsi1DRfzVZT8uI6n4HxhhULcrfY/WSeO OVciLRksR9S5y51dS81yAdv9Bhc52LLop/ZC/S21ryDqkS6yzuX3odEBA6t1v7BfAdLP 5AZMO8TqU2MxqEm/xmgT4W3KfmT4ycmHb8kJ5PGNE25eM8ioKuAGbbsGFeQttFE0LIFN bt1JNhBT4s6k2g1Dc+BIONK/Gc+lrMA5bWquhJi/koa2qeDFHwL3OePQ16xbvAAWbnzz VaicZ2HFbeBbk2L0gpgrGoQ61Vvi9dbj3zTXQNGL9lPf3eARp9V67+r2t1rLppwL4NsH FyHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707602022; x=1708206822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xZiCL02JzF0+cmAi1UQWcFqubmumV+rMpnfD27eX/H8=; b=ahlTM8h91bg4rOX2o3mqHsa9n7ry35IRMVjjafI7OxCug58HBTl398zGD/seNwAxeo d/dzJkLwDulo0QtabysYP/xjfjhB+4nOlvTk4w/M0ltoGJolh4DZahLY3MB9aFhXJ7A+ /1wpW7gm+v4Zwo7iZT6wnB7x4j1cnX3Zu8L6wD+wyeIzgwPHyi5iiArLyCsT+x4Jnq2L RiaGtD1TCVv2M4Ja3wITZ0p+smo4DVRmKro75pk6vMp6NCu3OYfJ30nEYbcWruZqQi7y +36u7YJcICoZgl9b/NlXuT1o4uxe/8jsC6MOb+5R1u2D7qqhbq3aoadRVuL1MJYndwe+ kK1w== X-Gm-Message-State: AOJu0YwGhvcw1ONWZ2XmMqe956pSsBs4+7bWUZoxzYaib/oPSIb4CE5a vBEa7Twc08KOIhBMezmJ+w+ibluTx/Wqa75ZIwC9JHILDK5//a+h X-Google-Smtp-Source: AGHT+IHi1MP5EoY6rqmM5OT1pXXhNbPfdcYp8ZDZ3YCzteaVP2NQu+kqpqaA2H4zOs03qJN94S7K6g== X-Received: by 2002:a05:6512:3b96:b0:511:674d:88c5 with SMTP id g22-20020a0565123b9600b00511674d88c5mr2410949lfv.13.1707602021749; Sat, 10 Feb 2024 13:53:41 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVQrAe84oRhlYTBEbGuA4c/x3OkV5e1en9F9UQ1FnnwVa8jgdYkf5N/9d9Q4mrjrDJ7I1JMOtO/eeYKDHadMJw1JBueVTEVMxsT9vmnxn15RflgdR7+zYlaVZz4cQKRMvqBH54OVcr5awc2fJdP/dAQLnnzGSsuBtulGhRTlR3UfhPIhPMhGx+z2X6WV9QWSSKKmWfchmvM6jEzSwSEI/CS/MLhl9I9i/7oylM4at1yRXRc0qDbKiHDu/+u5fKpbMHKQVvCooIcPCqrNIxXhDGRmiGA6MVyGF8Z0DnRsJhjGYLRLfIyoSHT9Xb1pU0Mhc446yo9WJjTlJEmPYgNO/kQLgprlmkHyNoYrfhDNCyzRrl92mtmKA== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:53:41 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 15/19] hid-ft260: uart: remove FIXME for wake-up workaround Date: Sat, 10 Feb 2024 23:51:43 +0200 Message-Id: <20240210215147.77629-16-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The FIXME is related to the wake-up workaround cancelation - do we need the reschedule_work flag alongside the cancel_work_sync usage? The teardown sequence is as described below: Upon tty session termination: ft260_uart_port_shutdown ft260_uart_wakeup_workaraund_enable: deactivate wakeup workaround t260_uart_cleanup ft260_uart_port_put On rmmod: ft260_remove cancel_work_sync ft260_uart_port_remove timer_delete_sync ft260_uart_port_put ft260_uart_port_destroy The ft260_uart_start_wakeup timer_work can occur after the cancel_work_sync returns, rescheduling the wakeup_work again. The reschedule_work flag set earlier at the ft260_uart_port_shutdown time prevents it. The alternative could be performing the timer_delete_sync first, preventing the wakeup_timer and wakeup_work from rescheduling, and then canceling the last wakeup_work by calling the cancel_work_sync. However, we still need the reschedule_work flag to enable or bypass the power saving mode according to the requested baud rate. Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index 1c113f735524..52ccee83250e 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -1585,7 +1585,6 @@ static int ft260_uart_probe(struct hid_device *hdev, struct ft260_device *dev) struct device *devt; INIT_WORK(&dev->wakeup_work, ft260_uart_do_wakeup); - // FIXME: Do I need that if I have cancel_work_sync? // FIXME: are all kfifo access secured by lock? with irq or not? ft260_uart_wakeup_workaraund_enable(dev, true); /* Work not started at this point */ @@ -1721,7 +1720,6 @@ static void ft260_remove(struct hid_device *hdev) return; if (dev->iface_type == FT260_IFACE_UART) { - // FIXME: cancel_work_sync(&dev->wakeup_work); tty_port_unregister_device(&dev->port, ft260_tty_driver, dev->index); From patchwork Sat Feb 10 21:51:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 772173 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C62E6025A; Sat, 10 Feb 2024 21:53:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602028; cv=none; b=Bs+tmTdGJSg1YlLc+MviRmhjCv/YQGArTI7ict0DzdkYm66DAZUAQgyasH0fjorIRppYA3CHx/+l3SBwznETnsT7vxzx1h/x7B6CER7ZENyNfmTNJZLfxMT8rGC+snTj9kxGkR100e8zUDCrpC94nIXDzNUCDUBBKcl8fQ9nFb4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602028; c=relaxed/simple; bh=GKHPriFTGNHkJD6qCXBjTKuOyNY0TWh2kPZjPAtk1i8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=S83I6tiByRcUxGP46C8FDZjWK7BtgHrH25PFRWwlORxnvoVEDob8CUlVTPa1PRfAx+ZiqW2OG/AQH7DwJy3X0bWh1CFTyoUzAZuteo/dFq4EK2J7OBN2BxXqc/eylHiD7mMdDP+Xhi3lFtNbQMhQZDLpNycWzWVeCsATfIfb9Ek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LUKAxGRl; arc=none smtp.client-ip=209.85.167.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LUKAxGRl" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-5114cd44f6aso2779411e87.1; Sat, 10 Feb 2024 13:53:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707602024; x=1708206824; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LxIWnn2EO/cc0iUSZCRrpP4DP3wiDSt99iawfQ/4DlA=; b=LUKAxGRlcTatqTM50SmhK5rpPcdPqY8VR7eJwSCZrAHjnaG7uw4WWZh7GVGY9dBcDD PwM9YLpfEPpnmyrer/wULhAka+6i5SYDejMI37Vc7vhyPKIvyqgFJl5ovEQy+vbHDP9b edIHxkkjSGtvrcIAqHbMRUD+TxYJ5mE5Uy8kcoBR3bCcna/hd1rhLQ0ampzotbt305lK jXFcM9Rsmzz/Z4AjZbn4q6wmn4ZOKfsBM3VKL7DngVPMXQHgWWqEKS2eo+nzCDpF2MVm o/ii+l7MpLhkAkXnBSSzcqCKhwKmr+GWERt0TUbVC+Ga+eRkCSS0WfRbMrm8Gw6MakQV tMaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707602024; x=1708206824; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LxIWnn2EO/cc0iUSZCRrpP4DP3wiDSt99iawfQ/4DlA=; b=Q3KDLMAcRZ4jFG7fwwxGTlMMpZuafHod/s1bJhDz+pBEGydcmJhqpotxAXYa+6mBrz viI6tvZf20KuKcXKFVcLzoQpYPojvfSslrPVq89aPqY6mfKeYEeT388oksbsKNDXYflG m+gHvLJertT8Nh/vtQMiJv1j9AMFsXtL3/kGSMEazVGtMBXyyh9wkWD+RM2S/hZURo+9 SseMx42tiyTMwydMRaI64X50GjSrhJS/NXJaq8cSrOavp5HNO7UprQslmgKw92FoF8Ez 2fz9Pr24arr2mMDf/e5pgyMIBNxajyDbM+SdbTlQuTnWmksaD9NWE9KvF0j8knqi4X7B r7Fw== X-Forwarded-Encrypted: i=1; AJvYcCVi3J1Kx/teE9CI6H65vfJGWYInVk/h0RL7zmC7njcvPwlHYAuHJwQkZB9GSuC6MhnsiV5YzM/lT1kuIvqZe9Xnzc+o8fE5DNbpDcyEy4/W7MFEUw8jWks7//rMgFVOk2ECPKI8q/IDdcU= X-Gm-Message-State: AOJu0YxNWI4O6Vlo4ouiHFj7ajE4KYA3athcv05tdDV4YdgKyLodqKDY PQXCY4rGOlaSyJDcB1FhoHwJKJYjcg92NuvLAPWp+Xs+4PPhCKp6zBSn+SgH7+A= X-Google-Smtp-Source: AGHT+IGKle2VNm91jTGJj07sy3SfWm+RoYOpG5m1dTgQmKD1QWaDIvFWDxYszIgBQzQ4VuJqkfydiA== X-Received: by 2002:a05:6512:2255:b0:511:48ab:2f9c with SMTP id i21-20020a056512225500b0051148ab2f9cmr2295109lfu.42.1707602024091; Sat, 10 Feb 2024 13:53:44 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCX/ukWofMNAchS0pigBsSdKuxqPNzk0OIcYvZbBmxn4m9ipLFgCMbrfNSB0mI7NyGEKZwrLEZT2MvQRjtYfpEVSWVzP9zb1moNulAW70qn6Vk0uR+NQu/xtQRGbLvfhth2fF5rdxgZ2k0SImIbTI4UMJ9b4vuQCCGXzAaTI39g8mplIXlW3y67Ft/NXXGSq+fXDp0pWSEJArmBmeYT1/ph864LBawPyXWFwgyZNLufNnRFVSZpvPCc1OnuWplSj2NclWGfBgv3Eh/H1kVTv9BYdjDLtMWvVS9w5Qp4SCxu9eINZtnDft8wdKk/vVqAOvtnFNeL6oOkGD31uliCnY1Om3+KC5DHDx/8cN2ozFa9JRdZcgSl8KQ== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:53:43 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 16/19] hid-ft260: uart: suppress unhandled report 0xb1 dmesg Date: Sat, 10 Feb 2024 23:51:44 +0200 Message-Id: <20240210215147.77629-17-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Suppress the "unhandled report 0xb1" error since it's related to the UART DCD/RI function of the multifunctional GPIO pins status, which we do not use for serial console. The configuration of these pins is a part of the GPIO patch set. [ 5453.117113] ft260 0003:0403:6030.0008: unhandled report 0xb1 [ 6641.582307] ft260 0003:0403:6030.0008: unhandled report 0xb1 [13418.439085] ft260 0003:0403:6030.0008: unhandled report 0xb1 [14110.820786] ft260 0003:0403:6030.0008: unhandled report 0xb1 Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index 52ccee83250e..d7eb00aeb669 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -1768,6 +1768,8 @@ static int ft260_raw_event(struct hid_device *hdev, struct hid_report *report, } else if (xfer->report >= FT260_UART_REPORT_MIN && xfer->report <= FT260_UART_REPORT_MAX) { return ft260_uart_receive_chars(dev, xfer->data, xfer->length); + } else if (xfer->report == FT260_UART_INTERRUPT_STATUS) { + return 0; } hid_err(hdev, "unhandled report %#02x\n", xfer->report); From patchwork Sat Feb 10 21:51:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 771638 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CE3460EC8; Sat, 10 Feb 2024 21:53:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602030; cv=none; b=Inb9CutVj3PoPbaUPTwBH1A8AHZag5BD/rwfuDs5JwyynL8drzPsEdYggXH4emkEqK3L0H2qXEUTOL9qYoJCofxE+lSEiSDFZjKc0tt1mOTfcTfy2DvyyeH7XjS0Dc88irCCnPltk50qLpOjoQg+m6+uihV8q0AS1V9OrMTujds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602030; c=relaxed/simple; bh=6qkcHzfTU/XRV4Bz6RvhCN/NdCXvR92GNjpua2Ojrs0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NajN7CdcAju+EX6V9Xbg2ZE4uU0Ez0ml1mCUC5a8I0esW19JXul3+ZlSUUIwp4Q4vyEo5UBKytLgszYCmmq8iGcD/ocFUY2ZKU0SDQZRb1ik/ABboMa8/xeCoaJ0ZIQyp3yTCb6HQX6uGIiFxLLwEcFKprAH6Hspdasg8QK4JAM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iuEo6rKA; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iuEo6rKA" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-5116ec49365so2295569e87.3; Sat, 10 Feb 2024 13:53:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707602026; x=1708206826; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wjAuDrVvrKWSGT9QwD0z4gCom14B7n2OsRrtSBnn7j4=; b=iuEo6rKAf197gNALM8j1OBi+k0WM7TXnSSEb0U2BR3tqlqYgsMwORHi917DtYCu/L8 WNLrgFBUqQpGqf0DpIqf4jqejdIJ5DpFj7dFhkyZf7pAB8qB+9LLFxsXMa1M/aCZ/3aZ kbIZVWJs4MFwv2QdBcAWkXX/+anZ0EBxDo/OiAIBadFhnbV81BSdC97HhvoU1FaMq7NV N/3omvo9Ue8ttT8kqSUFWf1wNIcSSnOLIO7sBqM3ciAqMWnWSMoYZqn0YLcVREHKgRJs KhGFR+dIY7OOuE0qbUVUSMW/uUyILYio9sg5UvH2RTe9ZwNFyd9kkaqIk/dI6ahCDX7/ gv6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707602026; x=1708206826; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wjAuDrVvrKWSGT9QwD0z4gCom14B7n2OsRrtSBnn7j4=; b=EjNm+9qtLOxLi0Gsi6O6SBotDjOWUkmbqHgOER4aWMJHp4b+IhoIm7f2lgKpiqxpFY BnRJ2LB5zVC4nxUszpEvAV6LMJ29ohoN6D7gCyf8f5d3joj3SwX6IvObsP98MXG+vTuP vFEYDfBM0uZabsa61j8DToiTB2+4/2EV02aEvwslciWAn9NwKCDC7PX8uf/jCq3F6VsS yozawHdYwpvZ6bjxgumgjwhNkco9nPOKp1k/fskoWsKiYZPlpvAjw07Hpcy3K5HmEcbu CB2fUDfxoTHynYR3cHhDfFuSBM+wBcjCQRLddHTYzU825pboIN4ulG6yLDPVEP/5VfjT O5AA== X-Gm-Message-State: AOJu0YyclmqlWCYNgnsNaHsCjmZTzrG3TKjXt3trFVQDTLgsBYCIBbzv 78FhGhLdbDDfoKsEyXg3E7Kd5qPKl62hgcXDxP3EpgDd6fctAzgI X-Google-Smtp-Source: AGHT+IGUtOgUFaxpfrwJlT4SfRpkTvV7z0N3jQf7TiaBV2r+xcYI+qAhYk6KFSSK8Ecwaau4bnRPzw== X-Received: by 2002:ac2:4da4:0:b0:511:79ee:5f98 with SMTP id h4-20020ac24da4000000b0051179ee5f98mr1803335lfe.18.1707602026526; Sat, 10 Feb 2024 13:53:46 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVMxUjFQN8kLLBJFOD+xJkBq6Mqn2oPW7uUNxHYWcH65zJxGBRSqPNnEdeCvRj5eQnP6di1ea9tVhsbGsmZXI3qfQmKw6RZwMFNngFiFPu76Eb4ibI9djkr2pb36bvKiuyMCYu4s0R9tLswyQeuQc6R1KeYQgeO9Kpe8EF+79OKtfQxwUXKVbbtqrm7brhFmSDU4wnO/IDFp2so43xzlOVS2Nr3c81lR2jC7PbH2SQ3jOtmsv14NnJqXRPxO7cCCfsyVgkKiogy1gOWIRipEWEFxycfyMbKi0/eii+zZlafvsdihSb0VE8Y4thAP2lOQuuIUio0zaTzKrxt4hCeNUuefLGCr3+T+NjBZJGhwRg7T6zPHrN/Ow== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.53.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:53:46 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 17/19] hid-ft260: uart: arm wake-up timer unconditionally on tty session start Date: Sat, 10 Feb 2024 23:51:45 +0200 Message-Id: <20240210215147.77629-18-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The previous session deactivated the wake-up workaround. The next session calls ft260_uart_port_activate while the wake-up workaround flag is yet deactivated. It is enabled later, conditionally, in the ft260_uart_change_speed. Thus, the timer is never armed again, and the device enters power-saving mode and misses the incoming data. Arming the wake-up timer unconditionally on the tty session start resolved the issue. Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index d7eb00aeb669..7f3ef4f20075 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -1510,10 +1510,8 @@ static int ft260_uart_port_activate(struct tty_port *tport, struct tty_struct *t /* Wake up the chip as early as possible to not miss incoming data */ ft260_uart_wakeup(port); - if (port->reschedule_work) { - mod_timer(&port->wakeup_timer, jiffies + - msecs_to_jiffies(FT260_WAKEUP_NEEDED_AFTER_MS)); - } + mod_timer(&port->wakeup_timer, jiffies + + msecs_to_jiffies(FT260_WAKEUP_NEEDED_AFTER_MS)); return 0; } From patchwork Sat Feb 10 21:51:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 772172 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD789612C0; Sat, 10 Feb 2024 21:53:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602032; cv=none; b=jY+vH0zx734FS5RikuFzwsHPzNUZgXvrZdOOyiT1tXOECEwiW+UNM9n5buiai/sr7Edh+d50X6kCCVH40BGL7GXoGp1rFVCbQ7I9TmWd+uz65VL1e8Q62GM9VHudtH9YM0mVjSgYQyaO2+B5dgw1D1jRkmRVw0iuPLjYKUVr3S8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602032; c=relaxed/simple; bh=hxtieDaWSwkcjeIe/ZAb6AAFPHKxuZy5d5r6D0dbJgI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iqbqhMFNjvJJW4nK6a2e23nvIRmg/ZjgoXvForZSH47KFmEPXKtCYUHtuJYDrVcAv+fNV8+LZ9P9T7Olub1oquO45u0F/zB9VQGAusx1oTJiL7U5h5sgGkWmkTE+IgfbdRmg+Ivp68snsEgOpPYv4YjOJ35u4Z+seQWzsnBYSP0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GPEH+6Di; arc=none smtp.client-ip=209.85.167.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GPEH+6Di" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-51182f8590bso698288e87.0; Sat, 10 Feb 2024 13:53:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707602029; x=1708206829; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dKAJSxOnHFuRcH0gpZtmvgzHWy46iRoqpq2kIsiN4WA=; b=GPEH+6DidKCPW2Hsxb4R6BMd17CMJ3oDVkccU0d+o4pGsVsHfclatJTtoxPjljl6GU be/cobs2oNsNdBgo3GE//YnuxzymvJmpS5xx+DhZXiXXCD0KeOMmIl3v98I/pPBi5NAf KDcKpdzmJZrUfLatYvKVmIXt0Rb16+YNawrgVQxkrQb1yOKXI1Fq8xmnWmDfEiOD2gip +8lXDPYPsFEeZoFaTC4rvwe+eLfOseMuHOufnqUp6BZc4jqIsO1COv6VpV++853JX5zf BoLVvbrDQMUkFhQ+hi7Ql0F7IbJhkQ0Rnns2XTWHVJiM7CzXVXQ9LywwVP7BF84z1JRI m5zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707602029; x=1708206829; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dKAJSxOnHFuRcH0gpZtmvgzHWy46iRoqpq2kIsiN4WA=; b=ux0urDEovqOHThgthMSIJUo2J3JwxtcCJdWmxgAt2+STp6vBo/V/zZ1Nuj/J628FMQ YEnMf1e5IZm2XacYYNG1zM89UNjbF3XaraanNQPvzt37M1Kan8JrQkj7GeaM+IcsT+ou xhc1mtSM6cqvOAhYM7Pi4VneBo6ohLslIKuvlNO8z9nLqAJ4K6rMaa1jJeqLhOKtY1Zy KAEVEcnH8DZcsdiqWN3K6GD45hrDonfZrIK6nI4QV9hxB4n1XFxrvg2yT7E3k06lL5zu 18IVLZAKHL6Xknaeocx0KD6YhsnfMw098u3xY0EdCbNy0ZteEhAtmQ84tgyejE+lnAAf i97Q== X-Gm-Message-State: AOJu0YwfE5a8lNxc0nFQf3tY9cxL1c0gsgPWU+r7+/D6mARi93I0R4TH qTaDJTiXmAmm7EZ5jieeN9axGxyjeHeSn+jpz2PQMgeXiUAHop3o X-Google-Smtp-Source: AGHT+IGhaCUZKotZ5J3ijipBgkAxpbHWH3s+sNEqzMPTVkh8O0YEEHoS5wS+W2p+JwCXCUuGEWkqTQ== X-Received: by 2002:a05:6512:3051:b0:511:4824:6718 with SMTP id b17-20020a056512305100b0051148246718mr2150014lfb.56.1707602028892; Sat, 10 Feb 2024 13:53:48 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXlWEmNRpDb/Z/PrK2WkQ2hjz/foxg7fPNtJ4S1guX/ueGYQMh+jJ5vYxNmMqIIQR0HfT7oWYrZV4zMLRwsTuXEbfXNO6yldCZP2XQmtRxVw8vy7D2TgqU7DW+NZS8kpYRuqBCL7/6WUeMNVRh8MWAoHDhrNQZHjiw27l+jS+Maoew8mm4Emha1kggHASA5Pur55Z1iAA70g48JgtmGhY3ZubgSbmfasfu/1R6UnwZxladHxFk3YW+69iGoxgGB8dNX2dWgH3MhoftUqoqUXnoLrZhCtoeOyI5pBzMc3aDpmZ8motgxgkj3uKLIheDrpx2BOGlebK0rNMgLAg7m+3r35PO3ua1z9qrwsLKHYtHFXUzSgqIrZg== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.53.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:53:48 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 18/19] hid-ft260: uart: fix rx data loss after device reopening Date: Sat, 10 Feb 2024 23:51:46 +0200 Message-Id: <20240210215147.77629-19-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The port setting may remain intact after session termination. Then, when reopening the port without configuring the port setting, the wakeup mechanism is not activated, and UART Rx loses the data at speeds greater than 4800 bauds. To fix it, retrieve the baud rate from the device in the ft260_uart_port_activate to reactivate the wakeup workaround if needed. Example: 1. Configure the baud rate to 115200: $ sudo picocom -f n -p n -d 8 -b 115200 /dev/ttyFT0 2. Quit the picocom without resetting port setting by entering: C-a and C-q It deactivates the wakeup workaround: [31677.005464] ft260_uart_close: [31677.005466] ft260_uart_chars_in_buffer: [31677.005467] ft260_uart_port_shutdown: [31677.005468] ft260_uart_wakeup_workaraund_enable: deactivate wakeup workaround [31677.005476] ft260_uart_cleanup: [31677.005477] ft260_uart_port_put: 3. Reopen the ttyFT0 port, but do not configure it. The fix retrieves the port baud rate from the device, compares it against the threshold, and activates the wakeup mechanism when needed. $ sudo bash -c "cat < /dev/ttyFT0" [31693.304991] ft260_uart_port_get: [31693.304995] ft260_uart_install: [31693.305000] ft260_uart_open: [31693.305001] ft260_uart_port_activate: [31693.309842] ft260_uart_wakeup_workaraund_enable: activate wakeup workaround [31693.309847] ft260_uart_port_activate: configurd baudrate = 115200 [31698.132650] ft260_uart_start_wakeup: [31698.132809] ft260_uart_do_wakeup: [31698.132817] ft260_uart_wakeup: [31702.996905] ft260_uart_start_wakeup: [31702.996916] ft260_uart_do_wakeup: Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 56 ++++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index 7f3ef4f20075..6b172bfa4f98 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -90,7 +90,7 @@ enum { FT260_I2C_REPORT_MAX = 0xDE, FT260_GPIO = 0xB0, FT260_UART_INTERRUPT_STATUS = 0xB1, - FT260_UART_STATUS = 0xE0, + FT260_UART_SETTINGS = 0xE0, FT260_UART_RI_DCD_STATUS = 0xE1, FT260_UART_REPORT_MIN = 0xF0, FT260_UART_REPORT_MAX = 0xFE, @@ -190,6 +190,18 @@ struct ft260_get_i2c_status_report { u8 reserved; } __packed; +struct ft260_get_uart_settings_report { + u8 report; /* FT260_UART_SETTINGS */ + u8 flow_ctrl; /* 0 - OFF; 1 - RTS_CTS, 2 - DTR_DSR, */ + /* 3 - XON_XOFF, 4 - No flow control */ + /* The baudrate field is unaligned */ + __le32 baudrate; /* little endian, 9600 = 0x2580, 19200 = 0x4B00 */ + u8 data_bit; /* 7 or 8 */ + u8 parity; /* 0: no parity, 1: odd, 2: even, 3: high, 4: low */ + u8 stop_bit; /* 0: one stop bit, 2: 2 stop bits */ + u8 breaking; /* 0: no break */ +} __packed; + /* Feature Out reports */ struct ft260_set_system_clock_report { @@ -1050,6 +1062,21 @@ static LIST_HEAD(ft260_uart_device_list); static void ft260_uart_wakeup(struct ft260_device *dev); +static int ft260_get_uart_settings(struct hid_device *hdev, + struct ft260_get_uart_settings_report *cfg) +{ + int ret; + int len = sizeof(struct ft260_get_uart_settings_report); + + ret = ft260_hid_feature_report_get(hdev, FT260_UART_SETTINGS, + (u8 *)cfg, len); + if (ret < 0) { + hid_err(hdev, "failed to retrieve uart settings\n"); + return ret; + } + return 0; +} + static void ft260_uart_wakeup_workaraund_enable(struct ft260_device *port, bool enable) { @@ -1492,13 +1519,11 @@ static void ft260_uart_port_shutdown(struct tty_port *tport) static int ft260_uart_port_activate(struct tty_port *tport, struct tty_struct *tty) { - struct ft260_device *port = - container_of(tport, struct ft260_device, port); + int ret; + int baudrate; + struct ft260_get_uart_settings_report cfg; + struct ft260_device *port = container_of(tport, struct ft260_device, port); - /* - * Set the TTY IO error marker - we will only clear this - * once we have successfully opened the port. - */ set_bit(TTY_IO_ERROR, &tty->flags); spin_lock(&port->xmit_fifo_lock); @@ -1507,8 +1532,21 @@ static int ft260_uart_port_activate(struct tty_port *tport, struct tty_struct *t clear_bit(TTY_IO_ERROR, &tty->flags); - /* Wake up the chip as early as possible to not miss incoming data */ - ft260_uart_wakeup(port); + /* + * The port setting may remain intact after session termination. + * Then, when reopening the port without configuring the port + * setting, we need to retrieve the baud rate from the device to + * reactivate the wakeup workaround if needed. + */ + ret = ft260_get_uart_settings(port->hdev, &cfg); + if (ret) + return ret; + + baudrate = get_unaligned_le32(&cfg.baudrate); + if (baudrate > FT260_UART_EN_PW_SAVE_BAUD) + ft260_uart_wakeup_workaraund_enable(port, true); + + ft260_dbg("configurd baudrate = %d", baudrate); mod_timer(&port->wakeup_timer, jiffies + msecs_to_jiffies(FT260_WAKEUP_NEEDED_AFTER_MS)); From patchwork Sat Feb 10 21:51:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zaidman X-Patchwork-Id: 771637 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E25F612DE; Sat, 10 Feb 2024 21:53:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602035; cv=none; b=Znxb+DjdF+5rvXDJWy129mha3DhnXcVWAoSiL+3AlBSrf6DDpzSZvEY+hs8T+1hBMv3uwjh72eN6bBtS558o7nqe0MRqOx8mN1oWSNteNsy1IMoyRNkSMhGyM59lPQ6du23d4GpEFm4cHGcet/eQpqgLXLOMm2IeY8XgPLucClc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602035; c=relaxed/simple; bh=zEz90GX1NaC/1sawxLYuZ1ENoB1fBUSzM9OiDG4l96E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=k2edn0VN9/DAS4stB7NKgYCOaE2+vZEWp6IvQnSaEyd+9Dcyxuc7ssX85bLcBW4LtJ6xdGs9EfqR1R4gLr3Gt3Vh0Af79J9X+7khuFYWL4vB42+2se8wp1ZASdMWj84x8gy51d7DGeRo8SzLGyzL4uhpf0ZEFBbuwm5bmj3JvQQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=d7e7IEk3; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d7e7IEk3" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-51185c33626so499863e87.0; Sat, 10 Feb 2024 13:53:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707602031; x=1708206831; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ocRkW8hKMfnTmReIZpRDWQim1hibbGos+/oExgJFVwc=; b=d7e7IEk3Tb6vTzzFHVcmcu257aEaj9D4htLnGdvJ8Wvj+hBaW6B9nkJCmB3fTJCblO bzPj9HRcH9AubPJePPEeP7Y+9U3OoCLBeCXnwIGOnMEBJusvHinJkuzpWtPT9FGkoJ+b UNaKz+Dxrv9eG6PxY7orFc7A/pK7qyemwGE+7W6lqGZTQdN/CpQOjD5F7Yryr8F2jTfi Dm6G9RfZqaUSMB/36n/UW2gCMNVDkmPIGrXUhRE6sm5YtgD751jrsBeUnW/iRjF7Es2q aHuMGi12kmp3araHl3x4fAv1rH/NpnPyjlJMVtfTFcn2GuonxzqU9MVEZizjLhhHxGb/ 8+Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707602031; x=1708206831; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ocRkW8hKMfnTmReIZpRDWQim1hibbGos+/oExgJFVwc=; b=rOP8u/VJSXvI0piH4EUz1kxlbGrFnIhtZkHQ+yVdnmLvM6kojtbK3F3KNAGtwja0NV OJFTs6mLEOzmjPu9nJt9xxLG6yGidVsrQwJsipSmhnM8eCYlSRtoVaRSQ3cbUtOMLI6i +Rt58JHXaCTVG9Dm9i8vchErYo4tPKMBgcJ1Gusm/dl6HbPjAO8jwaLmTpAxpFwHScRY Mbxi/VJfuOfZ3uS+kdkD7JywfW4uFXUXxU9n/hdxEYD1dgj6wWkSsXoRgDr0oeJINZgQ 4xs7m92oNaky6PbtZEZKdvU19gFjMYD7dz0eArB6YiGrCcTwUGPg/i2iPu0AzhfuXjP6 a81w== X-Gm-Message-State: AOJu0Yw7QuFym8jw2Uga5SovWUz9Rpcuc5QkvLu7YUxmXC0kk7cu/Khn I9poc4mRanaPiCvlPuw77FegyiYSfqoRLanCxkwvSxqdMgxCa2ag X-Google-Smtp-Source: AGHT+IH1G/GPCEZMmOHd0W54r9eeSAOb6vsJTlqzPST2fHZ7c37qvEZmVXnaIVNWWqF8h/S48dUXvg== X-Received: by 2002:a05:6512:12c7:b0:511:483b:91c6 with SMTP id p7-20020a05651212c700b00511483b91c6mr2449033lfg.48.1707602031347; Sat, 10 Feb 2024 13:53:51 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVDCEPO8lOjIT51DzfX0Xk56jKN4j7BJTCDTbbgv/kjr9jS2Qb8UI5RVlegTY1z1aNzW5zhtij26w9ska0FnNIORTgrMFUhkdeU73HoaKq7E78ssCAL+TYVFwHZgiN2tkwDETrOtNfiZASzV5TsfqGlmnm1EkJAIjsHKpHCHEmFJSNTH3YJQTXaqVcFDZgmbiN8KAy/iJ0BBT20LsojD5/AOLKs6RjivygyScMKlIgadADWQc9bblL4g4K0DBj003uq/JH6n0S+JSJxlXYUQa4dd5haNHaAW6jh3o2LeAdv/ABrNbEKfIk2r0liYQ116ziFBB7QwyCAR28+Y/ui0jW3rBCijTBvcAh2S9dKS3uwn4FabEJMxQ== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.53.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:53:51 -0800 (PST) From: Michael Zaidman To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com, jikos@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com, johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net, michael.zaidman@gmail.com Subject: [PATCH v1 19/19] hid-ft260: uart: improve write performance Date: Sat, 10 Feb 2024 23:51:47 +0200 Message-Id: <20240210215147.77629-20-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Tx performance with the current buffer size of 256 bytes is lower when the data length exceeds the xmit buf size. [134331.147978] ft260_uart_write: count: 288, len: 256 [134331.157945] ft260_uart_write: count: 32, len: 32 [134331.159977] ft260_uart_write: count: 288, len: 256 [134331.169990] ft260_uart_write: count: 32, len: 32 1. Increase the xmit buffer size to page size as used in the serial core and other tty drivers. 2. Remove the xmit buffer fulness against the watermark checking and the tty_wakeup calling in the ft260_uart_transmit_chars routine. This code is taken from other drivers, but other drivers may call the routine from the interrupt context. In our case, this condition is always True since xmit buffer filling and emptying are serialized and done synchronously. Tested with picocom ASCII file transfer by 288-byte chunks at 921600 bauds rate with above 20% performance improvement. Before: 2821.7 Kbytes transferred at 47367 CPS... Done. After: 2821.7 Kbytes transferred at 57788 CPS... Done. Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index 6b172bfa4f98..1188b8e09938 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -308,8 +308,7 @@ enum { #define FT260_UART_EN_PW_SAVE_BAUD (4800) #define UART_COUNT_MAX (4) /* Number of supported UARTs */ -#define XMIT_FIFO_SIZE (256) -#define TTY_WAKEUP_WATERMARK (XMIT_FIFO_SIZE / 2) +#define XMIT_FIFO_SIZE (PAGE_SIZE) static const struct hid_device_id ft260_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_FUTURE_TECHNOLOGY, @@ -1211,7 +1210,7 @@ static int ft260_uart_transmit_chars(struct ft260_device *port) len = kfifo_out_spinlocked(xmit, rep->data, len, &port->xmit_fifo_lock); - ret = ft260_hid_output_report(hdev, (u8 *)rep, len + sizeof(*rep)); + ret = ft260_hid_output_report(hdev, (u8 *)rep, len + 2); if (ret < 0) goto tty_out; @@ -1219,10 +1218,6 @@ static int ft260_uart_transmit_chars(struct ft260_device *port) port->icount.tx += len; } while (data_len > 0); - len = kfifo_len(xmit); - if ((XMIT_FIFO_SIZE - len) > TTY_WAKEUP_WATERMARK) - tty_wakeup(tty); - ret = 0; tty_out: @@ -1546,7 +1541,7 @@ static int ft260_uart_port_activate(struct tty_port *tport, struct tty_struct *t if (baudrate > FT260_UART_EN_PW_SAVE_BAUD) ft260_uart_wakeup_workaraund_enable(port, true); - ft260_dbg("configurd baudrate = %d", baudrate); + ft260_dbg("configured baudrate = %d", baudrate); mod_timer(&port->wakeup_timer, jiffies + msecs_to_jiffies(FT260_WAKEUP_NEEDED_AFTER_MS));