From patchwork Thu Aug 10 09:14:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 712553 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3790C001B0 for ; Thu, 10 Aug 2023 09:15:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230494AbjHJJPb (ORCPT ); Thu, 10 Aug 2023 05:15:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232117AbjHJJPT (ORCPT ); Thu, 10 Aug 2023 05:15:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 690352127; Thu, 10 Aug 2023 02:15:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E58BA612F0; Thu, 10 Aug 2023 09:15:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45835C433CB; Thu, 10 Aug 2023 09:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658917; bh=YhVm3D91GFk60mbhCwKIh8ODpcpzIPLgoAF+cMfYFa4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rUTW6o0exNR3VMnAmiAo1Ie6Z7i2rlGUwaOG2OKBzVaho2LsUHf4JccCny6xImN8P aQHh0YCVlaavKGdx5R5Wfk2nk3E03xT0PTBY8xppZ5vLk6BnTE5OFOqVpp38nkTwb4 FT6aSyrNysZPqUJflWlBFD+HOyGHbIiWd3o4vPlhUQlZ9Qj+dFjLT3h4mOW/wGyOWD K0ln82LYyuX7DynjO3HT0KyRBjBThvHQgkKxOEEYoSenOv/BxMPdrFD/3BkHmTy7O5 eUvRZWhakBFWaFQgwU9LhvamPAL9Tsuuq9xEqQV1lJHAh2oESfYNTetoJSy8FEXDSJ eoLMgym9ATVqw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 02/36] tty: ldisc: document that ldops are optional Date: Thu, 10 Aug 2023 11:14:36 +0200 Message-ID: <20230810091510.13006-3-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org There is no need to provide any hook in struct tty_ldisc_ops. Document that and write down that read/write return EIO in that case. The rest is simply ignored. Signed-off-by: Jiri Slaby (SUSE) --- include/linux/tty_ldisc.h | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h index 49dc172dedc7..62e089434995 100644 --- a/include/linux/tty_ldisc.h +++ b/include/linux/tty_ldisc.h @@ -71,7 +71,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass, * call to @receive_buf(). Returning an error will prevent the ldisc from * being attached. * - * Can sleep. + * Optional. Can sleep. * * @close: [TTY] ``void ()(struct tty_struct *tty)`` * @@ -80,7 +80,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass, * changed to use a new line discipline. At the point of execution no * further users will enter the ldisc code for this tty. * - * Can sleep. + * Optional. Can sleep. * * @flush_buffer: [TTY] ``void ()(struct tty_struct *tty)`` * @@ -88,6 +88,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass, * input characters it may have queued to be delivered to the user mode * process. It may be called at any point between open and close. * + * Optional. + * * @read: [TTY] ``ssize_t ()(struct tty_struct *tty, struct file *file, * unsigned char *buf, size_t nr)`` * @@ -97,7 +99,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass, * an %EIO error. Multiple read calls may occur in parallel and the ldisc * must deal with serialization issues. * - * Can sleep. + * Optional: %EIO unless provided. Can sleep. * * @write: [TTY] ``ssize_t ()(struct tty_struct *tty, struct file *file, * const unsigned char *buf, size_t nr)`` @@ -108,7 +110,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass, * characters first. If this function is not defined, the user will * receive an %EIO error. * - * Can sleep. + * Optional: %EIO unless provided. Can sleep. * * @ioctl: [TTY] ``int ()(struct tty_struct *tty, unsigned int cmd, * unsigned long arg)`` @@ -120,6 +122,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass, * discpline. So a low-level driver can "grab" an ioctl request before * the line discpline has a chance to see it. * + * Optional. + * * @compat_ioctl: [TTY] ``int ()(struct tty_struct *tty, unsigned int cmd, * unsigned long arg)`` * @@ -130,11 +134,15 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass, * a pointer to wordsize-sensitive structure belongs here, but most of * ldiscs will happily leave it %NULL. * + * Optional. + * * @set_termios: [TTY] ``void ()(struct tty_struct *tty, const struct ktermios *old)`` * * This function notifies the line discpline that a change has been made * to the termios structure. * + * Optional. + * * @poll: [TTY] ``int ()(struct tty_struct *tty, struct file *file, * struct poll_table_struct *wait)`` * @@ -142,6 +150,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass, * device. It is solely the responsibility of the line discipline to * handle poll requests. * + * Optional. + * * @hangup: [TTY] ``void ()(struct tty_struct *tty)`` * * Called on a hangup. Tells the discipline that it should cease I/O to @@ -149,7 +159,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass, * but should wait until any pending driver I/O is completed. No further * calls into the ldisc code will occur. * - * Can sleep. + * Optional. Can sleep. * * @receive_buf: [DRV] ``void ()(struct tty_struct *tty, * const unsigned char *cp, const char *fp, int count)`` @@ -161,6 +171,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass, * character was received with a parity error, etc. @fp may be %NULL to * indicate all data received is %TTY_NORMAL. * + * Optional. + * * @write_wakeup: [DRV] ``void ()(struct tty_struct *tty)`` * * This function is called by the low-level tty driver to signal that line @@ -170,11 +182,15 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass, * send, please arise a tasklet or workqueue to do the real data transfer. * Do not send data in this hook, it may lead to a deadlock. * + * Optional. + * * @dcd_change: [DRV] ``void ()(struct tty_struct *tty, bool active)`` * * Tells the discipline that the DCD pin has changed its status. Used * exclusively by the %N_PPS (Pulse-Per-Second) line discipline. * + * Optional. + * * @receive_buf2: [DRV] ``int ()(struct tty_struct *tty, * const unsigned char *cp, const char *fp, int count)`` * @@ -186,6 +202,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass, * indicate all data received is %TTY_NORMAL. If assigned, prefer this * function for automatic flow control. * + * Optional. + * * @lookahead_buf: [DRV] ``void ()(struct tty_struct *tty, * const unsigned char *cp, const char *fp, int count)`` * @@ -198,6 +216,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass, * same characters (e.g. by skipping the actions for high-priority * characters already handled by ->lookahead_buf()). * + * Optional. + * * @owner: module containting this ldisc (for reference counting) * * This structure defines the interface between the tty line discipline From patchwork Thu Aug 10 09:14:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 712552 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05675C001B0 for ; Thu, 10 Aug 2023 09:15:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234575AbjHJJPo (ORCPT ); Thu, 10 Aug 2023 05:15:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234446AbjHJJPX (ORCPT ); Thu, 10 Aug 2023 05:15:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E577B2686; Thu, 10 Aug 2023 02:15:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7C2E965495; Thu, 10 Aug 2023 09:15:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCDF4C433CB; Thu, 10 Aug 2023 09:15:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658921; bh=XKVIv2YmP+dmiMJ0SFDrOHmUqgvfBZbXL5ufVXNwvG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cOxn4Fx4TS4uskFH5mUnL54BEmuMh6VpgiFAzm96+N4yTDYfo5VWs2I9ZQtoOpY/e QLyDp9zp7dR7yiNAKqsFDfKIbB87QjGWT+NgvD3bKS7enA/BBPuV5QMkSuE0Xi+YOV DUvmDLP85kWSRdSkp9DuGDUVX3W86i/qm/dWbDTWI0Yw+NEugXhKOr5HkoNcTKikhX fcTFpF5Io47oXc6NOVmutvf8ZK+0x0LOEtlJrYiTHu1nH3v0MI7Icdp9UhGfbT+I4m Ziash61gLSHNRlMYL084iSmdDAy1Mm2y1GQuUcn6GEIoXMgWK7rlTMAoS8GwpD9rP9 lgRcYfJnhf6bA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 04/36] tty: n_null: remove optional ldops Date: Thu, 10 Aug 2023 11:14:38 +0200 Message-ID: <20230810091510.13006-5-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Only tty_ldisc_ops::read() and ::write() of n_null behave differently than the default ldops implementations. They return %EOPNOTSUPP instead of %EIO. So keep only those two and remove the rest ldops as they are superfluous. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/n_null.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/tty/n_null.c b/drivers/tty/n_null.c index f913b665af72..4a0d8bb2fb4c 100644 --- a/drivers/tty/n_null.c +++ b/drivers/tty/n_null.c @@ -10,15 +10,6 @@ * Copyright (C) Intel 2017 */ -static int n_null_open(struct tty_struct *tty) -{ - return 0; -} - -static void n_null_close(struct tty_struct *tty) -{ -} - static ssize_t n_null_read(struct tty_struct *tty, struct file *file, unsigned char *buf, size_t nr, void **cookie, unsigned long offset) @@ -32,21 +23,12 @@ static ssize_t n_null_write(struct tty_struct *tty, struct file *file, return -EOPNOTSUPP; } -static void n_null_receivebuf(struct tty_struct *tty, - const unsigned char *cp, const char *fp, - int cnt) -{ -} - static struct tty_ldisc_ops null_ldisc = { .owner = THIS_MODULE, .num = N_NULL, .name = "n_null", - .open = n_null_open, - .close = n_null_close, .read = n_null_read, .write = n_null_write, - .receive_buf = n_null_receivebuf }; static int __init n_null_init(void) From patchwork Thu Aug 10 09:14:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 712551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A85BBC001DE for ; Thu, 10 Aug 2023 09:15:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234721AbjHJJPx (ORCPT ); Thu, 10 Aug 2023 05:15:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234460AbjHJJP2 (ORCPT ); Thu, 10 Aug 2023 05:15:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 768C52700; Thu, 10 Aug 2023 02:15:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 14D20612F0; Thu, 10 Aug 2023 09:15:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68C2BC433C8; Thu, 10 Aug 2023 09:15:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658926; bh=zHa3PXKIEH54GgY+R1eXwduesS3j83ceqDEy55gq1po=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X4JDTjbZIY8YtcSnD9vNlkljLsDKWJ5A6kwyvYl92XcbxQvPUpsYwXdA/KhnGvU31 V9guFzglx2loNINCMRk9Yso+4v1OUUZ6mD8l6p8vn2C3jaeIlhu8GSTUN/4O/Fp4sB 9KNmlXfCszfwp7v/h1du1xYEBC9L45Pe5XcZqHjD+JRaGjQdjvMbmN8DdDzhTLCVlL VYM94cYNf2nJLaMW7iHT2c7TrYl3NkJX0iNiXwFRo684B7RhcmX1KGLr+k5P+7jxe+ j5ywTTBeuUwR3KXAw4MHYss+JX8gXWyoLIReYR3o1Bppa88jr2kfu4e3KmxLhR/nKH uZr3ElcZlvJ5w== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 07/36] tty: drop tty_debug_wait_until_sent() Date: Thu, 10 Aug 2023 11:14:41 +0200 Message-ID: <20230810091510.13006-8-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org It's a nop for everyone as TTY_DEBUG_WAIT_UNTIL_SENT is never set. Provided, we have better debugging/printout mechanisms nowadays, remove this mechanism. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/tty_ioctl.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c index e3e1318f53fd..f63e8b1b9e40 100644 --- a/drivers/tty/tty_ioctl.c +++ b/drivers/tty/tty_ioctl.c @@ -28,14 +28,6 @@ #include #include -#undef TTY_DEBUG_WAIT_UNTIL_SENT - -#ifdef TTY_DEBUG_WAIT_UNTIL_SENT -# define tty_debug_wait_until_sent(tty, f, args...) tty_debug(tty, f, ##args) -#else -# define tty_debug_wait_until_sent(tty, f, args...) do {} while (0) -#endif - #undef DEBUG /* @@ -198,8 +190,6 @@ int tty_unthrottle_safe(struct tty_struct *tty) void tty_wait_until_sent(struct tty_struct *tty, long timeout) { - tty_debug_wait_until_sent(tty, "wait until sent, timeout=%ld\n", timeout); - if (!timeout) timeout = MAX_SCHEDULE_TIMEOUT; From patchwork Thu Aug 10 09:14:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 712550 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51C1DC04FDF for ; Thu, 10 Aug 2023 09:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234447AbjHJJPy (ORCPT ); Thu, 10 Aug 2023 05:15:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231978AbjHJJP3 (ORCPT ); Thu, 10 Aug 2023 05:15:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F2FB2708; Thu, 10 Aug 2023 02:15:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 975EA612F0; Thu, 10 Aug 2023 09:15:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC5A6C433CA; Thu, 10 Aug 2023 09:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658928; bh=K6YO7sVv0MXgVvyircKmSovZ078//2lSihqsxTv3b5U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TWS/IPA6zqXrYy7DyfgbP/FmvLzOl92e+lkEn4kzAIKh0UXCKqCt1yOT5KB66jmlC eP4geP49vC2JmeSKMCanpf3lIDw0mdV2zNyk4Q/ZaGBW6v+qCgyrQkR1UdXi2BGdkY quMLjwS74SFnLdJ4jWSX3Sb1E7MHsXXnBgUxlCTQVpIe7pLWsd1KSFZYCcIwYF+d2v lRVnQ5C7j9ekZ4912qCrtSO3gL7MSBEiv5He6FHBHWGhjmR53kebVwAor8owG6Qp/B Q97YO7/ig7yts82RoeeHzSCN4kGxBMhVAPnV53kmsnK9f7KF6ElQp90BOzWTWu+HjF Kuz2rXPCBt70g== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 08/36] tty: make tty_change_softcar() more understandable Date: Thu, 10 Aug 2023 11:14:42 +0200 Message-ID: <20230810091510.13006-9-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org * rename 'arg' to 'enable' as that is what it means. * make 'bit' a tcflag_t, not int, as that is what cflags are. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/tty_ioctl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c index f63e8b1b9e40..7958bf6d27c4 100644 --- a/drivers/tty/tty_ioctl.c +++ b/drivers/tty/tty_ioctl.c @@ -737,17 +737,17 @@ static int set_ltchars(struct tty_struct *tty, struct ltchars __user *ltchars) /** * tty_change_softcar - carrier change ioctl helper * @tty: tty to update - * @arg: enable/disable CLOCAL + * @enable: enable/disable CLOCAL * * Perform a change to the CLOCAL state and call into the driver * layer to make it visible. All done with the termios rwsem */ -static int tty_change_softcar(struct tty_struct *tty, int arg) +static int tty_change_softcar(struct tty_struct *tty, bool enable) { int ret = 0; - int bit = arg ? CLOCAL : 0; struct ktermios old; + tcflag_t bit = enable ? CLOCAL : 0; down_write(&tty->termios_rwsem); old = tty->termios; From patchwork Thu Aug 10 09:14:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 712549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CE47C04A94 for ; Thu, 10 Aug 2023 09:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234752AbjHJJP4 (ORCPT ); Thu, 10 Aug 2023 05:15:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234477AbjHJJPb (ORCPT ); Thu, 10 Aug 2023 05:15:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B695A271C; Thu, 10 Aug 2023 02:15:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 514B560BEF; Thu, 10 Aug 2023 09:15:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79965C433CB; Thu, 10 Aug 2023 09:15:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658929; bh=xDwMYMe8HeseN+qdggjFBBvydlF7Iv9hfK/CmBpqWAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X2bBEfvBnTxgthuuR3wudqi9EKQl6CylSbnFle/QsLKgcj3wY4Vff8/o608x4CljK /kZohp4w54HTdc3idcnb+Iz9psT19tZs3SEkgZ4U61KS/bFVLMQdiXNH5HJW4/hhVb YsTEcoRUt4BDj5OgUaaf2INUPz0qhYyoGs8m7ExWncqBmbEp92WiqE86vmb3ifuRNp i5uy9SXtf2dyJlZuV/OBbStk6Ir8UdRtMZPjVaH6os4Gcu+BVfSILqMAyYV9B8lj/t hojUYeKosA6E75CoLVIMjLOnYMnvNOajEVu9zec+F72o1a7EbQVTc3s6XUrf6ylKra DT6U2Drc0t43Q== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Rob Herring Subject: [PATCH 09/36] tty: make tty_port_client_operations operate with u8 Date: Thu, 10 Aug 2023 11:14:43 +0200 Message-ID: <20230810091510.13006-10-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The parameters are already unsigned chars. So make them explicitly u8s, as the rest is going to be unified to u8 eventually too. Signed-off-by: Jiri Slaby (SUSE) Cc: Rob Herring --- drivers/tty/serdev/serdev-ttyport.c | 4 ++-- drivers/tty/tty_buffer.c | 4 ++-- drivers/tty/tty_port.c | 9 ++++----- include/linux/tty_port.h | 7 ++++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c index 8033ef19669c..f69ae27838e3 100644 --- a/drivers/tty/serdev/serdev-ttyport.c +++ b/drivers/tty/serdev/serdev-ttyport.c @@ -22,8 +22,8 @@ struct serport { * Callback functions from the tty port. */ -static int ttyport_receive_buf(struct tty_port *port, const unsigned char *cp, - const unsigned char *fp, size_t count) +static int ttyport_receive_buf(struct tty_port *port, const u8 *cp, + const u8 *fp, size_t count) { struct serdev_controller *ctrl = port->client_data; struct serport *serport = serdev_controller_get_drvdata(ctrl); diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 2df86ed90574..42464c37125a 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -505,8 +505,8 @@ static void lookahead_bufs(struct tty_port *port, struct tty_buffer *head) static int receive_buf(struct tty_port *port, struct tty_buffer *head, int count) { - unsigned char *p = char_buf_ptr(head, head->read); - const char *f = NULL; + u8 *p = char_buf_ptr(head, head->read); + const u8 *f = NULL; int n; if (head->flags) diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c index cda33dec73c3..6bf58980c81d 100644 --- a/drivers/tty/tty_port.c +++ b/drivers/tty/tty_port.c @@ -20,9 +20,8 @@ #include #include "tty.h" -static int tty_port_default_receive_buf(struct tty_port *port, - const unsigned char *p, - const unsigned char *f, size_t count) +static int tty_port_default_receive_buf(struct tty_port *port, const u8 *p, + const u8 *f, size_t count) { int ret; struct tty_struct *tty; @@ -43,8 +42,8 @@ static int tty_port_default_receive_buf(struct tty_port *port, return ret; } -static void tty_port_default_lookahead_buf(struct tty_port *port, const unsigned char *p, - const unsigned char *f, unsigned int count) +static void tty_port_default_lookahead_buf(struct tty_port *port, const u8 *p, + const u8 *f, unsigned int count) { struct tty_struct *tty; struct tty_ldisc *ld; diff --git a/include/linux/tty_port.h b/include/linux/tty_port.h index edf685a24f7c..726575743367 100644 --- a/include/linux/tty_port.h +++ b/include/linux/tty_port.h @@ -39,9 +39,10 @@ struct tty_port_operations { }; struct tty_port_client_operations { - int (*receive_buf)(struct tty_port *port, const unsigned char *, const unsigned char *, size_t); - void (*lookahead_buf)(struct tty_port *port, const unsigned char *cp, - const unsigned char *fp, unsigned int count); + int (*receive_buf)(struct tty_port *port, const u8 *cp, const u8 *fp, + size_t count); + void (*lookahead_buf)(struct tty_port *port, const u8 *cp, + const u8 *fp, unsigned int count); void (*write_wakeup)(struct tty_port *port); }; From patchwork Thu Aug 10 09:14:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 712548 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4834C04E69 for ; Thu, 10 Aug 2023 09:16:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233231AbjHJJQC (ORCPT ); Thu, 10 Aug 2023 05:16:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233253AbjHJJPg (ORCPT ); Thu, 10 Aug 2023 05:15:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BBFE2D63; Thu, 10 Aug 2023 02:15:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1AFD060BEF; Thu, 10 Aug 2023 09:15:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7346FC433CB; Thu, 10 Aug 2023 09:15:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658934; bh=ssoPI6gswdkKi9OGRHKTLnEGYWRZHoy8meC/8c63yRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MTYL49ifTxa6dq1iu8jISKzAX21Tt9qMZ8SfcFaDTwx3YAEV73ExyoTY96IVaZtQI esyOW7DNSBZcMWm/hkpd2+LRbAXuzI/jy1poJMRguq5fOwaRxO+ysXE49Q/RvvBpJ4 IjmUDcnv2qRKB8SE7KrN0PqKqy+rhBCdA/V7J7fBJ8USn6XXhQe89ifrutCODq7u7W VBcgEpvNq/gIgBgVdIIziiei/xJsrsJvm7mVcm9jZ0OVEAll6Affg5ynQj0YIi0Prd Fh77XHAMxFTkGyX+AZWjiBgTqqJfoiA2ch1NpGeFgGev1wWWE36+xwgxThePCUMvfI LME+TxzpUjesg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 12/36] tty: switch count in tty_ldisc_receive_buf() to size_t Date: Thu, 10 Aug 2023 11:14:46 +0200 Message-ID: <20230810091510.13006-13-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org It comes from both paste_selection() and tty_port_default_receive_buf() as unsigned (int and size_t respectively). Switch to size_t to converge to that eventually. Return the count as size_t too (the two callers above expect that). Switch paste_selection()'s type of 'count' too, so that the returned and passed type match. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/tty_buffer.c | 6 +++--- drivers/tty/vt/selection.c | 2 +- include/linux/tty_flip.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 7182dab60fac..56f5732ce47f 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -450,13 +450,13 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string); * * Returns: the number of bytes processed. */ -int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p, - const char *f, int count) +size_t tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p, + const char *f, size_t count) { if (ld->ops->receive_buf2) count = ld->ops->receive_buf2(ld->tty, p, f, count); else { - count = min_t(int, count, ld->tty->receive_room); + count = min_t(size_t, count, ld->tty->receive_room); if (count && ld->ops->receive_buf) ld->ops->receive_buf(ld->tty, p, f, count); } diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c index 6ef22f01cc51..8967c3a0d916 100644 --- a/drivers/tty/vt/selection.c +++ b/drivers/tty/vt/selection.c @@ -376,7 +376,7 @@ int paste_selection(struct tty_struct *tty) { struct vc_data *vc = tty->driver_data; int pasted = 0; - unsigned int count; + size_t count; struct tty_ldisc *ld; DECLARE_WAITQUEUE(wait, current); int ret = 0; diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h index bfaaeee61a05..09c4dbcd0025 100644 --- a/include/linux/tty_flip.h +++ b/include/linux/tty_flip.h @@ -41,8 +41,8 @@ static inline int tty_insert_flip_string(struct tty_port *port, return tty_insert_flip_string_fixed_flag(port, chars, TTY_NORMAL, size); } -int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p, - const char *f, int count); +size_t tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p, + const char *f, size_t count); void tty_buffer_lock_exclusive(struct tty_port *port); void tty_buffer_unlock_exclusive(struct tty_port *port); From patchwork Thu Aug 10 09:14:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 712547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0A15C001DE for ; Thu, 10 Aug 2023 09:16:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234294AbjHJJQR (ORCPT ); Thu, 10 Aug 2023 05:16:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234546AbjHJJPl (ORCPT ); Thu, 10 Aug 2023 05:15:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 874BA2D71; Thu, 10 Aug 2023 02:15:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 263A8654CD; Thu, 10 Aug 2023 09:15:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04BA6C433CC; Thu, 10 Aug 2023 09:15:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658940; bh=/6gBp59IIeAJu6gxv5VKOtBckU5nQfxa5DEsbTV9E6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HFwAREQpZ/lAxISpilmXwfEfwiUtf047Qrgajcf6NYSCE2Z57lCQmkCsdr1S7JA+o kckZFTcaZhxk8Mup8VpG8PZpzQuoJXimVvcH06NXH4jXMRPppi8jDftkrkhfNtXeCT jX5tiJugfgwWcGn07n1T+0IQ0C/Nl5fWrv4A1uvFDZ99Y2l9iLnfbBAKtvz05YTW36 X9zgHtoyDa7AD+mWmElBJ12FGQFBruDCy1YI7lkjqZmBc+xwmJv8nJ/BO8qZr00xUs vd/8phH85v3cwFLZE2XMyvJkGCeqy82qjDajro5YmIIwZDL9DTbmXu8hPr7Zhn7JQT wq0icwaUGgWhw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Max Staudt , Wolfgang Grandegger , Marc Kleine-Budde , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-can@vger.kernel.org Subject: [PATCH 14/36] tty: can327, move overflow test inside can327_ldisc_rx()'s loop Date: Thu, 10 Aug 2023 11:14:48 +0200 Message-ID: <20230810091510.13006-15-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The 'count' is going to be unsigned and the 'count >= 0' test would be always true then. Move the condition to the loop where this is easier to check. It looks as is easier to follow after all too. Signed-off-by: Jiri Slaby (SUSE) Cc: Max Staudt Cc: Wolfgang Grandegger Cc: Marc Kleine-Budde Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: linux-can@vger.kernel.org Reviewed-by: Max Staudt --- drivers/net/can/can327.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/net/can/can327.c b/drivers/net/can/can327.c index 05e9c035e8f6..4533dc00f215 100644 --- a/drivers/net/can/can327.c +++ b/drivers/net/can/can327.c @@ -901,7 +901,13 @@ static void can327_ldisc_rx(struct tty_struct *tty, const unsigned char *cp, */ first_new_char_idx = elm->rxfill; - while (count-- && elm->rxfill < CAN327_SIZE_RXBUF) { + while (count--) { + if (elm->rxfill >= CAN327_SIZE_RXBUF) { + netdev_err(elm->dev, + "Receive buffer overflowed. Bad chip or wiring? count = %i", + count); + goto uart_failure; + } if (fp && *fp++) { netdev_err(elm->dev, "Error in received character stream. Check your wiring."); @@ -930,13 +936,6 @@ static void can327_ldisc_rx(struct tty_struct *tty, const unsigned char *cp, cp++; } - if (count >= 0) { - netdev_err(elm->dev, - "Receive buffer overflowed. Bad chip or wiring? count = %i", - count); - goto uart_failure; - } - can327_parse_rxbuf(elm, first_new_char_idx); spin_unlock_bh(&elm->lock); From patchwork Thu Aug 10 09:14:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 712546 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95880C04A94 for ; Thu, 10 Aug 2023 09:17:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233284AbjHJJRN (ORCPT ); Thu, 10 Aug 2023 05:17:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234444AbjHJJQ0 (ORCPT ); Thu, 10 Aug 2023 05:16:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 663A73A97; Thu, 10 Aug 2023 02:16:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F1E18654E3; Thu, 10 Aug 2023 09:16:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28388C433C8; Thu, 10 Aug 2023 09:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658960; bh=bqk9imXFMSipriC6qFwCKZM/oCxujv3PCz30bPPeLV8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X9TrUe889m+8zZGNJJXXbox5ZqAlw10yTQERN++9tsUWflMJEiszPSIbU+pGtt9Av nS8XsWk8SQ0S2dlYFVVHKOiAxqs8p9CjZA+Ue7jroOgJSYLc8feyjfnnRYg0igk35K Id7ZxdXkfrWZ9QuFDzBSgDqOX3hqZ/3ryBRY7Jtbfd4XVru/uqKv3+bDkmMBGEGOSy o4cmnK7STBtIGtudm1mVFSCvfPD0ePWs1nzaZ8GbZQtO3atHBq/q4FpZ8MJcuGpyez lvq5c8uF9e0o5mkRDJEvoJHhaFrGqz93lR8C2bY0PAnEoRMbNPrFO8suiT/eog0PYO 6iER+9XHRLAEw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Arnd Bergmann Subject: [PATCH 18/36] misc: ti-st: make st_recv() conforming to tty_ldisc_ops::receive_buf() Date: Thu, 10 Aug 2023 11:14:52 +0200 Message-ID: <20230810091510.13006-19-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org That is change data type to u8 and count to unsigned int. And propagate to both hooks (st_kim_recv() and kim_int_recv()). Signed-off-by: Jiri Slaby (SUSE) Cc: Arnd Bergmann --- drivers/misc/ti-st/st_core.c | 7 +++---- drivers/misc/ti-st/st_kim.c | 6 +++--- include/linux/ti_wilink_st.h | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c index 4467c5b94ae8..c1a134bd8ba7 100644 --- a/drivers/misc/ti-st/st_core.c +++ b/drivers/misc/ti-st/st_core.c @@ -21,7 +21,7 @@ * st_kim_recv during registration to receive fw download responses * st_int_recv after registration to receive proto stack responses */ -static void (*st_recv) (void *, const unsigned char *, long); +static void (*st_recv)(void *disc_data, const u8 *ptr, size_t count); /********************************************************************/ static void add_channel_to_table(struct st_data_s *st_gdata, @@ -223,8 +223,7 @@ static inline void st_wakeup_ack(struct st_data_s *st_gdata, * HCI-Events, ACL, SCO, 4 types of HCI-LL PM packets * CH-8 packets from FM, CH-9 packets from GPS cores. */ -static void st_int_recv(void *disc_data, - const unsigned char *ptr, long count) +static void st_int_recv(void *disc_data, const u8 *ptr, size_t count) { struct st_proto_s *proto; unsigned short payload_len = 0; @@ -239,7 +238,7 @@ static void st_int_recv(void *disc_data, return; } - pr_debug("count %ld rx_state %ld" + pr_debug("count %zu rx_state %ld" "rx_count %ld", count, st_gdata->rx_state, st_gdata->rx_count); diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c index 5431a89924aa..fe682e0553b2 100644 --- a/drivers/misc/ti-st/st_kim.c +++ b/drivers/misc/ti-st/st_kim.c @@ -127,8 +127,8 @@ static inline int kim_check_data_len(struct kim_data_s *kim_gdata, int len) * have been observed to come in bursts of different * tty_receive and hence the logic */ -static void kim_int_recv(struct kim_data_s *kim_gdata, - const unsigned char *ptr, long count) +static void kim_int_recv(struct kim_data_s *kim_gdata, const u8 *ptr, + size_t count) { int len = 0; unsigned char *plen; @@ -417,7 +417,7 @@ static long download_firmware(struct kim_data_s *kim_gdata) * 1. response to read local version * 2. during send/recv's of firmware download */ -void st_kim_recv(void *disc_data, const unsigned char *data, long count) +void st_kim_recv(void *disc_data, const u8 *data, size_t count) { struct st_data_s *st_gdata = (struct st_data_s *)disc_data; struct kim_data_s *kim_gdata = st_gdata->kim_data; diff --git a/include/linux/ti_wilink_st.h b/include/linux/ti_wilink_st.h index 44a7f9169ac6..10642d4844f0 100644 --- a/include/linux/ti_wilink_st.h +++ b/include/linux/ti_wilink_st.h @@ -271,7 +271,7 @@ long st_kim_stop(void *); void st_kim_complete(void *); void kim_st_list_protocols(struct st_data_s *, void *); -void st_kim_recv(void *, const unsigned char *, long); +void st_kim_recv(void *disc_data, const u8 *data, size_t count); /* From patchwork Thu Aug 10 09:14:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 712544 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2E0CC001DE for ; Thu, 10 Aug 2023 09:17:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233876AbjHJJRO (ORCPT ); Thu, 10 Aug 2023 05:17:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234229AbjHJJQf (ORCPT ); Thu, 10 Aug 2023 05:16:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA9973AA0; Thu, 10 Aug 2023 02:16:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 82646654E4; Thu, 10 Aug 2023 09:16:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6CFFC433BB; Thu, 10 Aug 2023 09:16:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658962; bh=9QHODcZM6KKrgHiwTBHLES0drVEZoPScIy4Zc+1uY7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LV4M+mX17H/l62Y8F0htkILTVvHc8End0nfp4b6Da2Yv59kFUo6ruj+1jgNQDcPcL bEMUVjHoLQGmQV7WaF4RCa2IIkcseaWUE0c8b+hkKxgKilfqOVQLeuUZxr1F403lQ5 PIAWg4wpd/85K7c7aS0EDgIDJkLA7qollbgW/AGapkfJwmNrQDewzQHrMcegNbfOAG RIZ7+fRH0weBi8Blk9D1MvRb+rP4LFr8xPygL4RTyy5OtvGxC7k/attTUGRsgFnNf3 gehTGnIVTbaR0eaPFStVZnt1BCk/A0sJ9zKi1QJ1iCG/t0SumZFzLG3ZtccJBM+Mnw dheXEGy0ytwRw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 19/36] tty: make char_buf_ptr()/flag_buf_ptr()'s offset unsigned Date: Thu, 10 Aug 2023 11:14:53 +0200 Message-ID: <20230810091510.13006-20-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The offset is meant from the beginning of data, so unsigned. Make it as such for clarity. All struct tty_buffer's members should be unsigned too -- see the next patch. Signed-off-by: Jiri Slaby (SUSE) --- include/linux/tty_buffer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/tty_buffer.h b/include/linux/tty_buffer.h index b11cc8c749d2..391a875be20c 100644 --- a/include/linux/tty_buffer.h +++ b/include/linux/tty_buffer.h @@ -22,12 +22,12 @@ struct tty_buffer { unsigned long data[]; }; -static inline u8 *char_buf_ptr(struct tty_buffer *b, int ofs) +static inline u8 *char_buf_ptr(struct tty_buffer *b, unsigned int ofs) { return ((u8 *)b->data) + ofs; } -static inline u8 *flag_buf_ptr(struct tty_buffer *b, int ofs) +static inline u8 *flag_buf_ptr(struct tty_buffer *b, unsigned int ofs) { return char_buf_ptr(b, ofs) + b->size; } From patchwork Thu Aug 10 09:14:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 712545 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DBF4C41513 for ; Thu, 10 Aug 2023 09:17:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234050AbjHJJRO (ORCPT ); Thu, 10 Aug 2023 05:17:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234585AbjHJJQm (ORCPT ); Thu, 10 Aug 2023 05:16:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 742122D5D; Thu, 10 Aug 2023 02:16:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 13E68654D7; Thu, 10 Aug 2023 09:16:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6803AC433C7; Thu, 10 Aug 2023 09:16:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658963; bh=qhZ+8g/mVeww1/sDpRrBj/HZogkEpBzYC4tIKMW7d8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kQqjRSkffBAhnbZFGqB7ZOsl3VZvb6kihwWvFaB8wjTmp312MrusAY5mlUQy6zGiy tyuHfCmuiD/CInSjngxC/tDDmBOVDWCovm3s+nEurCW8xd1yIhaNV8tcGtY/kW4Zs6 lf5d+1jx3lsAKlTbJubMQZQxaX7Jg7jLTd/O/wZQAYruyc39Z/aFjtss0PCOBCAw9W CaFj8ZRYZQyjtV0ly7faDHT/C9T94ctI5E24ool518IMCczxEkAvhbPHNDdXhwXWh5 ynvslIIhPC/EbRT0MuKtJztLUxy45HuQMrwyMSnJ2SIlyHe9JsjQsfZzMJGRhsSOdj HhLE/o9VsR1oA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 20/36] tty: tty_buffer: make all offsets unsigned Date: Thu, 10 Aug 2023 11:14:54 +0200 Message-ID: <20230810091510.13006-21-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org All these are supposed/expected to be unsigned as they are either counts or offsets. So switch to unsigned for clarity. Signed-off-by: Jiri Slaby (SUSE) --- include/linux/tty_buffer.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/tty_buffer.h b/include/linux/tty_buffer.h index 391a875be20c..e45cba81d0e9 100644 --- a/include/linux/tty_buffer.h +++ b/include/linux/tty_buffer.h @@ -12,11 +12,11 @@ struct tty_buffer { struct tty_buffer *next; struct llist_node free; }; - int used; - int size; - int commit; - int lookahead; /* Lazy update on recv, can become less than "read" */ - int read; + unsigned int used; + unsigned int size; + unsigned int commit; + unsigned int lookahead; /* Lazy update on recv, can become less than "read" */ + unsigned int read; bool flags; /* Data points here */ unsigned long data[]; From patchwork Thu Aug 10 09:14:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 712543 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03324C04FE1 for ; Thu, 10 Aug 2023 09:17:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234460AbjHJJRQ (ORCPT ); Thu, 10 Aug 2023 05:17:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234698AbjHJJQz (ORCPT ); Thu, 10 Aug 2023 05:16:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC9DA3C2A; Thu, 10 Aug 2023 02:16:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A9BC5654E7; Thu, 10 Aug 2023 09:16:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0843EC433C9; Thu, 10 Aug 2023 09:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658968; bh=IB0hueHyK3s8u1ECn26OKi6iqqaceaJXgBWW7btEaaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mHZNMbwj1MnnCeLdtrTf2s66/O+j1ggY1IbheoYNwEcnUUm+JSEeKXMRteP92DE0Z LaY+LvVx3ezt3aEDnMZwQWGdLbS/fCzdqvz9r6Erh4uE+abQgpjNfE98FTjmc+CDYp TMHcQ83ltUAgE//QVPeBJ4G6ADWdVAxb9adOlRYC2ZYp+60oLS5TcVEi+ild20GZbK HGhSwPcKiePICG68ciE3i+YDeF/Deu9BtmccXrUkPQY14+keD1EcXkTtRoBybYzBPt 5Q28/mpbRyCLx+b8Leh2fxsTYc4+og4ipG/cIrKrF02bVdqcnrLrba3KtWZxEtqyrU erEVLq1ebyaXg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 23/36] tty: use min() in iterate_tty_write() Date: Thu, 10 Aug 2023 11:14:57 +0200 Message-ID: <20230810091510.13006-24-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org It simplifies the code. The "price" is we have to unify 'chunk' to be size_t the same as 'count' is. But that change is actually correct. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/tty_io.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 846460c02c58..0cf1277e260b 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -964,9 +964,8 @@ int tty_write_lock(struct tty_struct *tty, bool ndelay) static ssize_t iterate_tty_write(struct tty_ldisc *ld, struct tty_struct *tty, struct file *file, struct iov_iter *from) { - size_t count = iov_iter_count(from); + size_t chunk, count = iov_iter_count(from); ssize_t ret, written = 0; - unsigned int chunk; ret = tty_write_lock(tty, file->f_flags & O_NDELAY); if (ret < 0) @@ -1010,10 +1009,7 @@ static ssize_t iterate_tty_write(struct tty_ldisc *ld, struct tty_struct *tty, /* Do the write .. */ for (;;) { - size_t size = count; - - if (size > chunk) - size = chunk; + size_t size = min(chunk, count); ret = -EFAULT; if (copy_from_iter(tty->write_buf, size, from) != size) From patchwork Thu Aug 10 09:15:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 712542 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2804C04A94 for ; Thu, 10 Aug 2023 09:17:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234574AbjHJJRT (ORCPT ); Thu, 10 Aug 2023 05:17:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234851AbjHJJRA (ORCPT ); Thu, 10 Aug 2023 05:17:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B7B24223; Thu, 10 Aug 2023 02:16:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4E0426550A; Thu, 10 Aug 2023 09:16:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B400C433CA; Thu, 10 Aug 2023 09:16:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658972; bh=14gTPQx7XyzDqSWiJUFV6C/aJrHW2+ALhVNcSU3mPbQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KNFPxPS7MK3Hchuv55BVxmG7yaaf0nj8sRDWsSSkcD6FEOkMBIfHt1qIlMfYbLGTu nfC50KXzI9blYYWmOAxfucPu4FveHK6Wx3hPG7/gFdSlmbh+pSMlUTHt/R7RoYiTWv G8KxrtKZcL49/fGJACFQYkwEZ2xTyL/AwLv1pZ7hhqojM4WWu/3dQlkI1kbidh+GgX MEEjRHCL1Tj7NlxdOS9wvgtH2On+Bvr+HJwHMaKEKrusamCSUSrDeZ6cQ3pjW6xLBR gRFkOaTvN0319wHDb/1d9RpjcsFCWBATzRT8i9cDWcx3OhQpuwCLcIJip+hJEgr5Bf q5EGUQjZOqTfg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 26/36] tty: use min() for size computation in iterate_tty_read() Date: Thu, 10 Aug 2023 11:15:00 +0200 Message-ID: <20230810091510.13006-27-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The computation is more obvious with min(). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/tty_io.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 7cfa99fbbb62..4f21a21a1fd5 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -853,9 +853,8 @@ static ssize_t iterate_tty_read(struct tty_ldisc *ld, struct tty_struct *tty, size_t copied, count = iov_iter_count(to); do { - ssize_t size; + ssize_t size = min(count, sizeof(kernel_buf)); - size = count > sizeof(kernel_buf) ? sizeof(kernel_buf) : count; size = ld->ops->read(tty, file, kernel_buf, size, &cookie, offset); if (!size) break; From patchwork Thu Aug 10 09:15:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 712541 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8CAAC001B0 for ; Thu, 10 Aug 2023 09:18:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234900AbjHJJSF (ORCPT ); Thu, 10 Aug 2023 05:18:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234969AbjHJJRL (ORCPT ); Thu, 10 Aug 2023 05:17:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7DDE44AE; Thu, 10 Aug 2023 02:16:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 78AB265515; Thu, 10 Aug 2023 09:16:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3546FC433C8; Thu, 10 Aug 2023 09:16:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658981; bh=b0zy8crPJ9lcjI0vV8bmOYaKTP8nfAGhS/9pNHtLdJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ijyq8WAu+RuujvAS/zYzS5YHjbnrwtdYAxprPHutfb1NHMqUNJ0+lcdZzksTseuAr cQcJp+pRK6LBbJYxBdQ9HfxiPzAmGraqIh2s4pWIhQM/aM5HeSHaP8yLkM9SdZHxRU p67D0HnNZuI6VZmEwusX5WarodVia+vDDStOl7A4LRWAcWExjxpUswC7gyF2dCPpj2 hihcdgMwPD+XkIFeaDVxYie+W1fPC8P8grXbgH37UdNHFlobq57SYnoHmMp19FWkkO PAapauj1M9MbtK7kO7NCptEdjpvVBnfaB+E4IQ5fe5Udrds/b5RMEoEnIDDu8NVzbW jeuRkmxwMWrXQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Richard Henderson , Ivan Kokshaysky , Matt Turner , Geert Uytterhoeven , Richard Weinberger , Anton Ivanov , Johannes Berg , Chris Zankel , Max Filippov , Arnd Bergmann , Vaibhav Gupta , Jens Taprogge , Karsten Keil , Scott Branden , Ulf Hansson , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , David Lin , Johan Hovold , Alex Elder , Laurentiu Tudor , Jiri Kosina , David Sterba , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Arnaud Pouliquen , Oliver Neukum , Mathias Nyman , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Subject: [PATCH 27/36] tty: propagate u8 data to tty_operations::write() Date: Thu, 10 Aug 2023 11:15:01 +0200 Message-ID: <20230810091510.13006-28-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Data are now typed as u8. Propagate this change to tty_operations::write(). Signed-off-by: Jiri Slaby (SUSE) Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: Geert Uytterhoeven Cc: Richard Weinberger Cc: Anton Ivanov Cc: Johannes Berg Cc: Chris Zankel Cc: Max Filippov Cc: Arnd Bergmann Cc: Vaibhav Gupta Cc: Jens Taprogge Cc: Karsten Keil Cc: Scott Branden Cc: Ulf Hansson Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Alexander Gordeev Cc: Christian Borntraeger Cc: Sven Schnelle Cc: David Lin Cc: Johan Hovold Cc: Alex Elder Cc: Laurentiu Tudor Cc: Jiri Kosina Cc: David Sterba Cc: Shawn Guo Cc: Sascha Hauer Cc: Pengutronix Kernel Team Cc: Fabio Estevam Cc: NXP Linux Team Cc: Arnaud Pouliquen Cc: Oliver Neukum Cc: Mathias Nyman Cc: Marcel Holtmann Cc: Johan Hedberg Cc: Luiz Augusto von Dentz Reviewed-by: Geert Uytterhoeven # m68k Acked-by: Geert Uytterhoeven # m68k Acked-by: Alexander Gordeev --- arch/alpha/kernel/srmcons.c | 3 +-- arch/m68k/emu/nfcon.c | 3 +-- arch/um/drivers/line.c | 2 +- arch/um/drivers/line.h | 3 +-- arch/xtensa/platforms/iss/console.c | 3 +-- drivers/char/ttyprintk.c | 5 ++--- drivers/ipack/devices/ipoctal.c | 6 ++---- drivers/isdn/capi/capi.c | 3 +-- drivers/misc/bcm-vk/bcm_vk_tty.c | 4 +--- drivers/mmc/core/sdio_uart.c | 3 +-- drivers/net/usb/hso.c | 3 +-- drivers/s390/char/con3215.c | 3 +-- drivers/s390/char/con3270.c | 3 +-- drivers/s390/char/sclp_tty.c | 2 +- drivers/s390/char/sclp_vt220.c | 2 +- drivers/staging/gdm724x/gdm_tty.c | 3 +-- drivers/staging/greybus/uart.c | 3 +-- drivers/tty/amiserial.c | 2 +- drivers/tty/ehv_bytechan.c | 3 +-- drivers/tty/goldfish.c | 6 ++---- drivers/tty/hvc/hvc_console.c | 2 +- drivers/tty/hvc/hvcs.c | 3 +-- drivers/tty/hvc/hvsi.c | 3 +-- drivers/tty/ipwireless/hardware.c | 2 +- drivers/tty/ipwireless/tty.c | 3 +-- drivers/tty/mips_ejtag_fdc.c | 4 ++-- drivers/tty/moxa.c | 8 +++----- drivers/tty/mxser.c | 2 +- drivers/tty/n_gsm.c | 3 +-- drivers/tty/nozomi.c | 5 ++--- drivers/tty/pty.c | 2 +- drivers/tty/serial/kgdb_nmi.c | 2 +- drivers/tty/serial/serial_core.c | 3 +-- drivers/tty/synclink_gt.c | 7 +++---- drivers/tty/ttynull.c | 3 +-- drivers/tty/vcc.c | 3 +-- drivers/tty/vt/vt.c | 4 ++-- drivers/usb/class/cdc-acm.c | 3 +-- drivers/usb/gadget/function/u_serial.c | 2 +- drivers/usb/host/xhci-dbgtty.c | 4 +--- drivers/usb/serial/usb-serial.c | 3 +-- include/linux/tty_driver.h | 3 +-- net/bluetooth/rfcomm/tty.c | 2 +- 43 files changed, 53 insertions(+), 88 deletions(-) diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c index 6dc952b0df4a..dea39008d93e 100644 --- a/arch/alpha/kernel/srmcons.c +++ b/arch/alpha/kernel/srmcons.c @@ -130,8 +130,7 @@ srmcons_do_write(struct tty_port *port, const char *buf, int count) } static int -srmcons_write(struct tty_struct *tty, - const unsigned char *buf, int count) +srmcons_write(struct tty_struct *tty, const u8 *buf, int count) { unsigned long flags; diff --git a/arch/m68k/emu/nfcon.c b/arch/m68k/emu/nfcon.c index 6fdc13610565..e7a21234b481 100644 --- a/arch/m68k/emu/nfcon.c +++ b/arch/m68k/emu/nfcon.c @@ -70,8 +70,7 @@ static void nfcon_tty_close(struct tty_struct *tty, struct file *filp) { } -static int nfcon_tty_write(struct tty_struct *tty, const unsigned char *buf, - int count) +static int nfcon_tty_write(struct tty_struct *tty, const u8 *buf, int count) { nfputs(buf, count); return count; diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index 02b0befd6763..e5393b4ba9f8 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c @@ -184,7 +184,7 @@ void line_flush_chars(struct tty_struct *tty) line_flush_buffer(tty); } -int line_write(struct tty_struct *tty, const unsigned char *buf, int len) +int line_write(struct tty_struct *tty, const u8 *buf, int len) { struct line *line = tty->driver_data; unsigned long flags; diff --git a/arch/um/drivers/line.h b/arch/um/drivers/line.h index f15be75a3bf3..8354024b6b35 100644 --- a/arch/um/drivers/line.h +++ b/arch/um/drivers/line.h @@ -64,8 +64,7 @@ extern void line_cleanup(struct tty_struct *tty); extern void line_hangup(struct tty_struct *tty); extern int line_setup(char **conf, unsigned nlines, char **def, char *init, char *name); -extern int line_write(struct tty_struct *tty, const unsigned char *buf, - int len); +extern int line_write(struct tty_struct *tty, const u8 *buf, int len); extern unsigned int line_chars_in_buffer(struct tty_struct *tty); extern void line_flush_buffer(struct tty_struct *tty); extern void line_flush_chars(struct tty_struct *tty); diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c index b40b73809dd8..182ec57e2d5c 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -52,8 +52,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) } -static int rs_write(struct tty_struct * tty, - const unsigned char *buf, int count) +static int rs_write(struct tty_struct * tty, const u8 *buf, int count) { /* see drivers/char/serialX.c to reference original version */ diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c index ed45d04905c2..4f3dd93f1fd8 100644 --- a/drivers/char/ttyprintk.c +++ b/drivers/char/ttyprintk.c @@ -51,7 +51,7 @@ static void tpk_flush(void) } } -static int tpk_printk(const unsigned char *buf, int count) +static int tpk_printk(const u8 *buf, int count) { int i; @@ -103,8 +103,7 @@ static void tpk_close(struct tty_struct *tty, struct file *filp) /* * TTY operations write function. */ -static int tpk_write(struct tty_struct *tty, - const unsigned char *buf, int count) +static int tpk_write(struct tty_struct *tty, const u8 *buf, int count) { struct ttyprintk_port *tpkp = tty->driver_data; unsigned long flags; diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c index a01c15812b70..c3cf086e7e36 100644 --- a/drivers/ipack/devices/ipoctal.c +++ b/drivers/ipack/devices/ipoctal.c @@ -437,8 +437,7 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr, } static inline int ipoctal_copy_write_buffer(struct ipoctal_channel *channel, - const unsigned char *buf, - int count) + const u8 *buf, int count) { unsigned long flags; int i; @@ -459,8 +458,7 @@ static inline int ipoctal_copy_write_buffer(struct ipoctal_channel *channel, return i; } -static int ipoctal_write_tty(struct tty_struct *tty, - const unsigned char *buf, int count) +static int ipoctal_write_tty(struct tty_struct *tty, const u8 *buf, int count) { struct ipoctal_channel *channel = tty->driver_data; unsigned int char_copied; diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index 45a4043c5042..cf6daf79c1a2 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c @@ -1077,8 +1077,7 @@ static void capinc_tty_close(struct tty_struct *tty, struct file *filp) tty_port_close(&mp->port, tty, filp); } -static int capinc_tty_write(struct tty_struct *tty, - const unsigned char *buf, int count) +static int capinc_tty_write(struct tty_struct *tty, const u8 *buf, int count) { struct capiminor *mp = tty->driver_data; struct sk_buff *skb; diff --git a/drivers/misc/bcm-vk/bcm_vk_tty.c b/drivers/misc/bcm-vk/bcm_vk_tty.c index 6669625ba4c8..44851b607cce 100644 --- a/drivers/misc/bcm-vk/bcm_vk_tty.c +++ b/drivers/misc/bcm-vk/bcm_vk_tty.c @@ -186,9 +186,7 @@ static void bcm_vk_tty_doorbell(struct bcm_vk *vk, u32 db_val) VK_BAR0_REGSEG_DB_BASE + VK_BAR0_REGSEG_TTY_DB_OFFSET); } -static int bcm_vk_tty_write(struct tty_struct *tty, - const unsigned char *buffer, - int count) +static int bcm_vk_tty_write(struct tty_struct *tty, const u8 *buffer, int count) { int index; struct bcm_vk *vk; diff --git a/drivers/mmc/core/sdio_uart.c b/drivers/mmc/core/sdio_uart.c index aa659758563f..90d2fe00c0b9 100644 --- a/drivers/mmc/core/sdio_uart.c +++ b/drivers/mmc/core/sdio_uart.c @@ -760,8 +760,7 @@ static void sdio_uart_hangup(struct tty_struct *tty) tty_port_hangup(&port->port); } -static int sdio_uart_write(struct tty_struct *tty, const unsigned char *buf, - int count) +static int sdio_uart_write(struct tty_struct *tty, const u8 *buf, int count) { struct sdio_uart_port *port = tty->driver_data; int ret; diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index ce1f6081d582..014a9d29bab5 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -1322,8 +1322,7 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp) } /* close the requested serial port */ -static int hso_serial_write(struct tty_struct *tty, const unsigned char *buf, - int count) +static int hso_serial_write(struct tty_struct *tty, const u8 *buf, int count) { struct hso_serial *serial = tty->driver_data; int space, tx_bytes; diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c index a1fef666c9b0..16b6f430dfd3 100644 --- a/drivers/s390/char/con3215.c +++ b/drivers/s390/char/con3215.c @@ -1021,8 +1021,7 @@ static unsigned int tty3215_write_room(struct tty_struct *tty) /* * String write routine for 3215 ttys */ -static int tty3215_write(struct tty_struct *tty, - const unsigned char *buf, int count) +static int tty3215_write(struct tty_struct *tty, const u8 *buf, int count) { handle_write(tty->driver_data, buf, count); return count; diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c index d9983550062d..123524bff734 100644 --- a/drivers/s390/char/con3270.c +++ b/drivers/s390/char/con3270.c @@ -1803,8 +1803,7 @@ static void tty3270_do_write(struct tty3270 *tp, struct tty_struct *tty, /* * String write routine for 3270 ttys */ -static int tty3270_write(struct tty_struct *tty, - const unsigned char *buf, int count) +static int tty3270_write(struct tty_struct *tty, const u8 *buf, int count) { struct tty3270 *tp; diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c index 971fbb52740b..cc0f6a97124e 100644 --- a/drivers/s390/char/sclp_tty.c +++ b/drivers/s390/char/sclp_tty.c @@ -230,7 +230,7 @@ static int sclp_tty_write_string(const unsigned char *str, int count, int may_fa * routine will return the number of characters actually accepted for writing. */ static int -sclp_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) +sclp_tty_write(struct tty_struct *tty, const u8 *buf, int count) { if (sclp_tty_chars_count > 0) { sclp_tty_write_string(sclp_tty_chars, sclp_tty_chars_count, 0); diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c index a32f34a1c6d2..44974d801c1e 100644 --- a/drivers/s390/char/sclp_vt220.c +++ b/drivers/s390/char/sclp_vt220.c @@ -463,7 +463,7 @@ __sclp_vt220_write(const unsigned char *buf, int count, int do_schedule, * number of characters actually accepted for writing. */ static int -sclp_vt220_write(struct tty_struct *tty, const unsigned char *buf, int count) +sclp_vt220_write(struct tty_struct *tty, const u8 *buf, int count) { return __sclp_vt220_write(buf, count, 1, 0, 1); } diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c index e1a84d6020f4..ae9978b73d9b 100644 --- a/drivers/staging/gdm724x/gdm_tty.c +++ b/drivers/staging/gdm724x/gdm_tty.c @@ -149,8 +149,7 @@ static void gdm_tty_send_complete(void *arg) tty_port_tty_wakeup(&gdm->port); } -static int gdm_tty_write(struct tty_struct *tty, const unsigned char *buf, - int len) +static int gdm_tty_write(struct tty_struct *tty, const u8 *buf, int len) { struct gdm *gdm = tty->driver_data; int remain = len; diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c index 20a34599859f..97c7ddd0f53e 100644 --- a/drivers/staging/greybus/uart.c +++ b/drivers/staging/greybus/uart.c @@ -427,8 +427,7 @@ static void gb_tty_hangup(struct tty_struct *tty) tty_port_hangup(&gb_tty->port); } -static int gb_tty_write(struct tty_struct *tty, const unsigned char *buf, - int count) +static int gb_tty_write(struct tty_struct *tty, const u8 *buf, int count) { struct gb_tty *gb_tty = tty->driver_data; diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index c06ad0a0744b..1dd8b86f4a32 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c @@ -741,7 +741,7 @@ static void rs_flush_chars(struct tty_struct *tty) local_irq_restore(flags); } -static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count) +static int rs_write(struct tty_struct * tty, const u8 *buf, int count) { int c, ret = 0; struct serial_state *info = tty->driver_data; diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c index 8595483f4697..de36347e2145 100644 --- a/drivers/tty/ehv_bytechan.c +++ b/drivers/tty/ehv_bytechan.c @@ -466,8 +466,7 @@ static irqreturn_t ehv_bc_tty_tx_isr(int irq, void *data) * ehv_bc_tty_write_room() will never lie, so the tty layer will never send us * too much data. */ -static int ehv_bc_tty_write(struct tty_struct *ttys, const unsigned char *s, - int count) +static int ehv_bc_tty_write(struct tty_struct *ttys, const u8 *s, int count) { struct ehv_bc_data *bc = ttys->driver_data; unsigned long flags; diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c index d02de3f0326f..faa597ffbaf9 100644 --- a/drivers/tty/goldfish.c +++ b/drivers/tty/goldfish.c @@ -125,8 +125,7 @@ static void goldfish_tty_rw(struct goldfish_tty *qtty, } } -static void goldfish_tty_do_write(int line, const char *buf, - unsigned int count) +static void goldfish_tty_do_write(int line, const u8 *buf, unsigned int count) { struct goldfish_tty *qtty = &goldfish_ttys[line]; unsigned long address = (unsigned long)(void *)buf; @@ -186,8 +185,7 @@ static void goldfish_tty_hangup(struct tty_struct *tty) tty_port_hangup(tty->port); } -static int goldfish_tty_write(struct tty_struct *tty, const unsigned char *buf, - int count) +static int goldfish_tty_write(struct tty_struct *tty, const u8 *buf, int count) { goldfish_tty_do_write(tty->index, buf, count); return count; diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c index 10c10cfdf92a..4c60d15c7a6f 100644 --- a/drivers/tty/hvc/hvc_console.c +++ b/drivers/tty/hvc/hvc_console.c @@ -496,7 +496,7 @@ static int hvc_push(struct hvc_struct *hp) return n; } -static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count) +static int hvc_write(struct tty_struct *tty, const u8 *buf, int count) { struct hvc_struct *hp = tty->driver_data; unsigned long flags; diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c index 1de1a09bf82d..2465d61b4e76 100644 --- a/drivers/tty/hvc/hvcs.c +++ b/drivers/tty/hvc/hvcs.c @@ -1257,8 +1257,7 @@ static void hvcs_hangup(struct tty_struct * tty) * tty_hangup will allow hvcs_write time to complete execution before it * terminates our device. */ -static int hvcs_write(struct tty_struct *tty, - const unsigned char *buf, int count) +static int hvcs_write(struct tty_struct *tty, const u8 *buf, int count) { struct hvcs_struct *hvcsd = tty->driver_data; unsigned int unit_address; diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c index c1b8a4fd8b1e..46dd62df2442 100644 --- a/drivers/tty/hvc/hvsi.c +++ b/drivers/tty/hvc/hvsi.c @@ -904,8 +904,7 @@ static unsigned int hvsi_chars_in_buffer(struct tty_struct *tty) return hp->n_outbuf; } -static int hvsi_write(struct tty_struct *tty, - const unsigned char *source, int count) +static int hvsi_write(struct tty_struct *tty, const u8 *source, int count) { struct hvsi_struct *hp = tty->driver_data; unsigned long flags; diff --git a/drivers/tty/ipwireless/hardware.c b/drivers/tty/ipwireless/hardware.c index f5d3e68f5750..001ec318a918 100644 --- a/drivers/tty/ipwireless/hardware.c +++ b/drivers/tty/ipwireless/hardware.c @@ -1292,7 +1292,7 @@ static void *alloc_ctrl_packet(int header_size, } int ipwireless_send_packet(struct ipw_hardware *hw, unsigned int channel_idx, - const unsigned char *data, unsigned int length, + const u8 *data, unsigned int length, void (*callback) (void *cb, unsigned int length), void *callback_data) { diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c index 9edd5ae17580..cd43208c523c 100644 --- a/drivers/tty/ipwireless/tty.c +++ b/drivers/tty/ipwireless/tty.c @@ -186,8 +186,7 @@ static void ipw_write_packet_sent_callback(void *callback_data, tty->tx_bytes_queued -= packet_length; } -static int ipw_write(struct tty_struct *linux_tty, - const unsigned char *buf, int count) +static int ipw_write(struct tty_struct *linux_tty, const u8 *buf, int count) { struct ipw_tty *tty = linux_tty->driver_data; int room, ret; diff --git a/drivers/tty/mips_ejtag_fdc.c b/drivers/tty/mips_ejtag_fdc.c index e81701a66429..cf4ef0c38624 100644 --- a/drivers/tty/mips_ejtag_fdc.c +++ b/drivers/tty/mips_ejtag_fdc.c @@ -796,8 +796,8 @@ static void mips_ejtag_fdc_tty_hangup(struct tty_struct *tty) tty_port_hangup(tty->port); } -static int mips_ejtag_fdc_tty_write(struct tty_struct *tty, - const unsigned char *buf, int total) +static int mips_ejtag_fdc_tty_write(struct tty_struct *tty, const u8 *buf, + int total) { int count, block; struct mips_ejtag_fdc_tty_port *dport = tty->driver_data; diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c index 42fa4c878b2e..d94cf1be651b 100644 --- a/drivers/tty/moxa.c +++ b/drivers/tty/moxa.c @@ -487,7 +487,7 @@ module_param(ttymajor, int, 0); */ static int moxa_open(struct tty_struct *, struct file *); static void moxa_close(struct tty_struct *, struct file *); -static int moxa_write(struct tty_struct *, const unsigned char *, int); +static int moxa_write(struct tty_struct *, const u8 *, int); static unsigned int moxa_write_room(struct tty_struct *); static void moxa_flush_buffer(struct tty_struct *); static unsigned int moxa_chars_in_buffer(struct tty_struct *); @@ -1499,8 +1499,7 @@ static void moxa_close(struct tty_struct *tty, struct file *filp) tty_port_close(&ch->port, tty, filp); } -static int moxa_write(struct tty_struct *tty, - const unsigned char *buf, int count) +static int moxa_write(struct tty_struct *tty, const u8 *buf, int count) { struct moxa_port *ch = tty->driver_data; unsigned long flags; @@ -2164,8 +2163,7 @@ static int MoxaPortLineStatus(struct moxa_port *port) return val; } -static int MoxaPortWriteData(struct tty_struct *tty, - const unsigned char *buffer, int len) +static int MoxaPortWriteData(struct tty_struct *tty, const u8 *buffer, int len) { struct moxa_port *port = tty->driver_data; void __iomem *baseAddr, *ofsAddr, *ofs; diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index 10855e66fda1..8b4b8493fed5 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c @@ -901,7 +901,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) tty_port_close(tty->port, tty, filp); } -static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count) +static int mxser_write(struct tty_struct *tty, const u8 *buf, int count) { struct mxser_port *info = tty->driver_data; unsigned long flags; diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index a3bd1fc52aed..d167e36873fe 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -4256,8 +4256,7 @@ static void gsmtty_hangup(struct tty_struct *tty) gsm_dlci_begin_close(dlci); } -static int gsmtty_write(struct tty_struct *tty, const unsigned char *buf, - int len) +static int gsmtty_write(struct tty_struct *tty, const u8 *buf, int len) { int sent; struct gsm_dlci *dlci = tty->driver_data; diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c index 0454c78deee6..b3756402f5d9 100644 --- a/drivers/tty/nozomi.c +++ b/drivers/tty/nozomi.c @@ -1599,8 +1599,7 @@ static void ntty_hangup(struct tty_struct *tty) * called when the userspace process writes to the tty (/dev/noz*). * Data is inserted into a fifo, which is then read and transferred to the modem. */ -static int ntty_write(struct tty_struct *tty, const unsigned char *buffer, - int count) +static int ntty_write(struct tty_struct *tty, const u8 *buffer, int count) { int rval = -EINVAL; struct nozomi *dc = get_dc_by_tty(tty); @@ -1610,7 +1609,7 @@ static int ntty_write(struct tty_struct *tty, const unsigned char *buffer, if (!dc || !port) return -ENODEV; - rval = kfifo_in(&port->fifo_ul, (unsigned char *)buffer, count); + rval = kfifo_in(&port->fifo_ul, buffer, count); spin_lock_irqsave(&dc->spin_mutex, flags); /* CTS is only valid on the modem channel */ diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 2b1c8ab99dba..335f5744f320 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -108,7 +108,7 @@ static void pty_unthrottle(struct tty_struct *tty) * the other side of the pty/tty pair. */ -static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c) +static int pty_write(struct tty_struct *tty, const u8 *buf, int c) { struct tty_struct *to = tty->link; diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c index 55c3c9db7462..2a04d19d5ec0 100644 --- a/drivers/tty/serial/kgdb_nmi.c +++ b/drivers/tty/serial/kgdb_nmi.c @@ -304,7 +304,7 @@ static unsigned int kgdb_nmi_tty_write_room(struct tty_struct *tty) return 2048; } -static int kgdb_nmi_tty_write(struct tty_struct *tty, const unchar *buf, int c) +static int kgdb_nmi_tty_write(struct tty_struct *tty, const u8 *buf, int c) { int i; diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index e31c9b6bd8ab..33df5b08d992 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -580,8 +580,7 @@ static void uart_flush_chars(struct tty_struct *tty) uart_start(tty); } -static int uart_write(struct tty_struct *tty, - const unsigned char *buf, int count) +static int uart_write(struct tty_struct *tty, const u8 *buf, int count) { struct uart_state *state = tty->driver_data; struct uart_port *port; diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index 4c6366fe015c..c7cecea38ca8 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c @@ -431,7 +431,7 @@ static void tx_set_idle(struct slgt_info *info); static unsigned int tbuf_bytes(struct slgt_info *info); static void reset_tbufs(struct slgt_info *info); static void tdma_reset(struct slgt_info *info); -static bool tx_load(struct slgt_info *info, const char *buf, unsigned int count); +static bool tx_load(struct slgt_info *info, const u8 *buf, unsigned int count); static void get_gtsignals(struct slgt_info *info); static void set_gtsignals(struct slgt_info *info); @@ -745,8 +745,7 @@ static void update_tx_timer(struct slgt_info *info) } } -static int write(struct tty_struct *tty, - const unsigned char *buf, int count) +static int write(struct tty_struct *tty, const u8 *buf, int count) { int ret = 0; struct slgt_info *info = tty->driver_data; @@ -4767,7 +4766,7 @@ static unsigned int tbuf_bytes(struct slgt_info *info) * load data into transmit DMA buffer ring and start transmitter if needed * return true if data accepted, otherwise false (buffers full) */ -static bool tx_load(struct slgt_info *info, const char *buf, unsigned int size) +static bool tx_load(struct slgt_info *info, const u8 *buf, unsigned int size) { unsigned short count; unsigned int i; diff --git a/drivers/tty/ttynull.c b/drivers/tty/ttynull.c index 1d4438472442..6b74ebaa0f2d 100644 --- a/drivers/tty/ttynull.c +++ b/drivers/tty/ttynull.c @@ -29,8 +29,7 @@ static void ttynull_hangup(struct tty_struct *tty) tty_port_hangup(&ttynull_port); } -static int ttynull_write(struct tty_struct *tty, const unsigned char *buf, - int count) +static int ttynull_write(struct tty_struct *tty, const u8 *buf, int count) { return count; } diff --git a/drivers/tty/vcc.c b/drivers/tty/vcc.c index 34ba6e54789a..c223879039b8 100644 --- a/drivers/tty/vcc.c +++ b/drivers/tty/vcc.c @@ -804,8 +804,7 @@ static void vcc_hangup(struct tty_struct *tty) tty_port_hangup(tty->port); } -static int vcc_write(struct tty_struct *tty, const unsigned char *buf, - int count) +static int vcc_write(struct tty_struct *tty, const u8 *buf, int count) { struct vcc_port *port; struct vio_vcc *pkt; diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index cf77011a8f4e..2f28612aee91 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2845,7 +2845,7 @@ static int vc_con_write_normal(struct vc_data *vc, int tc, int c, } /* acquires console_lock */ -static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int count) +static int do_con_write(struct tty_struct *tty, const u8 *buf, int count) { struct vc_draw_region draw = { .x = -1, @@ -3238,7 +3238,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) * /dev/ttyN handling */ -static int con_write(struct tty_struct *tty, const unsigned char *buf, int count) +static int con_write(struct tty_struct *tty, const u8 *buf, int count) { int retval; diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 11da5fb284d0..913b07b30d33 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -789,8 +789,7 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp) tty_port_close(&acm->port, tty, filp); } -static int acm_tty_write(struct tty_struct *tty, - const unsigned char *buf, int count) +static int acm_tty_write(struct tty_struct *tty, const u8 *buf, int count) { struct acm *acm = tty->driver_data; int stat; diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c index 1115396b46a0..1d08a1d8d3cd 100644 --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c @@ -734,7 +734,7 @@ static void gs_close(struct tty_struct *tty, struct file *file) spin_unlock_irq(&port->port_lock); } -static int gs_write(struct tty_struct *tty, const unsigned char *buf, int count) +static int gs_write(struct tty_struct *tty, const u8 *buf, int count) { struct gs_port *port = tty->driver_data; unsigned long flags; diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c index d3acc0829ee5..f5f2d0e12e69 100644 --- a/drivers/usb/host/xhci-dbgtty.c +++ b/drivers/usb/host/xhci-dbgtty.c @@ -208,9 +208,7 @@ static void dbc_tty_close(struct tty_struct *tty, struct file *file) tty_port_close(&port->port, tty, file); } -static int dbc_tty_write(struct tty_struct *tty, - const unsigned char *buf, - int count) +static int dbc_tty_write(struct tty_struct *tty, const u8 *buf, int count) { struct dbc_port *port = tty->driver_data; unsigned long flags; diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 7b4805c1004d..51f738ea3f77 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -361,8 +361,7 @@ static void serial_cleanup(struct tty_struct *tty) module_put(owner); } -static int serial_write(struct tty_struct *tty, const unsigned char *buf, - int count) +static int serial_write(struct tty_struct *tty, const u8 *buf, int count) { struct usb_serial_port *port = tty->driver_data; int retval = -ENODEV; diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index e00034118c7b..a7bd8060ac96 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -356,8 +356,7 @@ struct tty_operations { void (*close)(struct tty_struct * tty, struct file * filp); void (*shutdown)(struct tty_struct *tty); void (*cleanup)(struct tty_struct *tty); - int (*write)(struct tty_struct * tty, - const unsigned char *buf, int count); + int (*write)(struct tty_struct *tty, const u8 *buf, int count); int (*put_char)(struct tty_struct *tty, unsigned char ch); void (*flush_chars)(struct tty_struct *tty); unsigned int (*write_room)(struct tty_struct *tty); diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index d73eec146529..3b5f8404dc84 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c @@ -779,7 +779,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp) tty_port_close(&dev->port, tty, filp); } -static int rfcomm_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) +static int rfcomm_tty_write(struct tty_struct *tty, const u8 *buf, int count) { struct rfcomm_dev *dev = tty->driver_data; struct rfcomm_dlc *dlc = dev->dlc; From patchwork Thu Aug 10 09:15:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 712540 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81B49C04A94 for ; Thu, 10 Aug 2023 09:18:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234791AbjHJJSW (ORCPT ); Thu, 10 Aug 2023 05:18:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234802AbjHJJRx (ORCPT ); Thu, 10 Aug 2023 05:17:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 029F54683; Thu, 10 Aug 2023 02:16:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 76496654D8; Thu, 10 Aug 2023 09:16:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDB11C433CA; Thu, 10 Aug 2023 09:16:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658988; bh=mVyIZxSUZFmJlHVQlPsIoDxqmnEnvFNf08lke1pNFls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MrYoPv9MeoxK/aq+w+EfBvuzqJ2nmenAAJIlpNu+Y6Ju6iXb9+iEQ5TrbiVdQVd+6 anx2OIM/ktLdpNjMZotpt9/4ofB6W5HwXsvJxJOId3OnkO2j8ivGwZtTP3AyN3Q9/y G37iMdZWXe48FHYNWKz+DS50wMm198fcCMbNoVmpQCdXv74ZDFgzhmIMc7/Y52Dxlq jyn71TVVT5iIqkiR+3Mq5Rw0mc39L3edjVu1T6tKnHqzibsrDqCANUdHlw7ee8OCby xI1WzxcpX0jHnnPWMjn2p8WoTgfC1cP+S6E5xr894NnJBIJvLnB+FEDe5WL9LcAX9f SNoiJO/2nfxWA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 30/36] tty: audit: unify to u8 Date: Thu, 10 Aug 2023 11:15:04 +0200 Message-ID: <20230810091510.13006-31-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Somewhere, we use 'char', somewhere 'unsigned char'. Unify to 'u8' as the rest of the tty layer does. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/tty.h | 4 ++-- drivers/tty/tty_audit.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/tty/tty.h b/drivers/tty/tty.h index e31cd9f281de..50862f98273e 100644 --- a/drivers/tty/tty.h +++ b/drivers/tty/tty.h @@ -101,13 +101,13 @@ extern int tty_ldisc_autoload; #ifdef CONFIG_AUDIT void tty_audit_add_data(const struct tty_struct *tty, const void *data, size_t size); -void tty_audit_tiocsti(const struct tty_struct *tty, char ch); +void tty_audit_tiocsti(const struct tty_struct *tty, u8 ch); #else static inline void tty_audit_add_data(const struct tty_struct *tty, const void *data, size_t size) { } -static inline void tty_audit_tiocsti(const struct tty_struct *tty, char ch) +static inline void tty_audit_tiocsti(const struct tty_struct *tty, u8 ch) { } #endif diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c index 24d010589379..1d81eeefb068 100644 --- a/drivers/tty/tty_audit.c +++ b/drivers/tty/tty_audit.c @@ -17,7 +17,7 @@ struct tty_audit_buf { dev_t dev; /* The TTY which the data is from */ bool icanon; size_t valid; - unsigned char *data; /* Allocated size N_TTY_BUF_SIZE */ + u8 *data; /* Allocated size N_TTY_BUF_SIZE */ }; static struct tty_audit_buf *tty_audit_buf_ref(void) @@ -59,7 +59,7 @@ static void tty_audit_buf_free(struct tty_audit_buf *buf) } static void tty_audit_log(const char *description, dev_t dev, - const unsigned char *data, size_t size) + const u8 *data, size_t size) { struct audit_buffer *ab; pid_t pid = task_pid_nr(current); @@ -134,7 +134,7 @@ void tty_audit_fork(struct signal_struct *sig) /* * tty_audit_tiocsti - Log TIOCSTI */ -void tty_audit_tiocsti(const struct tty_struct *tty, char ch) +void tty_audit_tiocsti(const struct tty_struct *tty, u8 ch) { dev_t dev; From patchwork Thu Aug 10 09:15:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 712539 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8764C001B0 for ; Thu, 10 Aug 2023 09:18:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234834AbjHJJSm (ORCPT ); Thu, 10 Aug 2023 05:18:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234838AbjHJJR7 (ORCPT ); Thu, 10 Aug 2023 05:17:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B9EA46B4; Thu, 10 Aug 2023 02:16:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BB6156551C; Thu, 10 Aug 2023 09:16:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BF34C433CB; Thu, 10 Aug 2023 09:16:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658992; bh=xUZ9/AL3u/qN9nyDCrwUn7AoTj5LSpl3Y8QSlJQ5kJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ulGxlS3c7KWGoE1YOx1kbAT5LQm7HNwJSumVO+Lu4ZulvGw6dGdjQqeBS/pNpCxVQ R9FkodnNUxn0I5wcqOMyirR+mlA7Hd9Mb8EyefnIAdlKjYJDSNaeiJ4afcI4AS+hW8 U6sUz5kYPekQMANvM4U06ryWVGk2AfCGz7zJnWX6yCJt+C/EZbaSm1YhbtxQrFcvYk Qs8CUOyOuPNYwY+RUc0O+BD1qKV8fLyh1dTUEjORjcSOEkGq/FA7uR7kuuna1cVucW r3+tzmlcogYv81Z37oLHwIs/F+E9z91Er4QeLUaCsMpjo0qVRHH/xFnh/Mm4GCWps3 7fzaP3+45+eAQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , Dmitry Torokhov , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Krzysztof Kozlowski Subject: [PATCH 31/36] tty: ldops: unify to u8 Date: Thu, 10 Aug 2023 11:15:05 +0200 Message-ID: <20230810091510.13006-32-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Some hooks in struct tty_ldisc_ops still reference buffers by 'unsigned char'. Unify to 'u8' as the rest of the tty layer does. Signed-off-by: Jiri Slaby (SUSE) Cc: Marcel Holtmann Cc: Johan Hedberg Cc: Luiz Augusto von Dentz Cc: Dmitry Torokhov Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Krzysztof Kozlowski --- drivers/bluetooth/hci_ldisc.c | 6 +++--- drivers/input/serio/serport.c | 4 ++-- drivers/net/ppp/ppp_async.c | 9 ++++----- drivers/net/ppp/ppp_synctty.c | 7 +++---- drivers/tty/n_gsm.c | 7 +++---- drivers/tty/n_hdlc.c | 6 +++--- drivers/tty/n_null.c | 7 +++---- drivers/tty/n_tty.c | 11 +++++------ include/linux/tty_ldisc.h | 13 ++++++------- net/nfc/nci/uart.c | 6 +++--- 10 files changed, 35 insertions(+), 41 deletions(-) diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 3e11fc06a932..a26367e9fb19 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -807,14 +807,14 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, unsigned int cmd, * We don't provide read/write/poll interface for user space. */ static ssize_t hci_uart_tty_read(struct tty_struct *tty, struct file *file, - unsigned char *buf, size_t nr, - void **cookie, unsigned long offset) + u8 *buf, size_t nr, void **cookie, + unsigned long offset) { return 0; } static ssize_t hci_uart_tty_write(struct tty_struct *tty, struct file *file, - const unsigned char *data, size_t count) + const u8 *data, size_t count) { return 0; } diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c index 5ce8d9f10f3e..1db3f30011c4 100644 --- a/drivers/input/serio/serport.c +++ b/drivers/input/serio/serport.c @@ -158,8 +158,8 @@ static void serport_ldisc_receive(struct tty_struct *tty, const u8 *cp, */ static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, - unsigned char *kbuf, size_t nr, - void **cookie, unsigned long offset) + u8 *kbuf, size_t nr, void **cookie, + unsigned long offset) { struct serport *serport = tty->disc_data; struct serio *serio; diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c index cfd5cb609d99..fbaaa8c102a1 100644 --- a/drivers/net/ppp/ppp_async.c +++ b/drivers/net/ppp/ppp_async.c @@ -257,9 +257,8 @@ static void ppp_asynctty_hangup(struct tty_struct *tty) * Pppd reads and writes packets via /dev/ppp instead. */ static ssize_t -ppp_asynctty_read(struct tty_struct *tty, struct file *file, - unsigned char *buf, size_t count, - void **cookie, unsigned long offset) +ppp_asynctty_read(struct tty_struct *tty, struct file *file, u8 *buf, + size_t count, void **cookie, unsigned long offset) { return -EAGAIN; } @@ -269,8 +268,8 @@ ppp_asynctty_read(struct tty_struct *tty, struct file *file, * from the ppp generic stuff. */ static ssize_t -ppp_asynctty_write(struct tty_struct *tty, struct file *file, - const unsigned char *buf, size_t count) +ppp_asynctty_write(struct tty_struct *tty, struct file *file, const u8 *buf, + size_t count) { return -EAGAIN; } diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c index 164c9053f73b..ebcdffdf4f0e 100644 --- a/drivers/net/ppp/ppp_synctty.c +++ b/drivers/net/ppp/ppp_synctty.c @@ -255,8 +255,7 @@ static void ppp_sync_hangup(struct tty_struct *tty) * Pppd reads and writes packets via /dev/ppp instead. */ static ssize_t -ppp_sync_read(struct tty_struct *tty, struct file *file, - unsigned char *buf, size_t count, +ppp_sync_read(struct tty_struct *tty, struct file *file, u8 *buf, size_t count, void **cookie, unsigned long offset) { return -EAGAIN; @@ -267,8 +266,8 @@ ppp_sync_read(struct tty_struct *tty, struct file *file, * from the ppp generic stuff. */ static ssize_t -ppp_sync_write(struct tty_struct *tty, struct file *file, - const unsigned char *buf, size_t count) +ppp_sync_write(struct tty_struct *tty, struct file *file, const u8 *buf, + size_t count) { return -EAGAIN; } diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 3e5cc30941a7..42759500b79e 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -3638,9 +3638,8 @@ static void gsmld_write_wakeup(struct tty_struct *tty) * This code must be sure never to sleep through a hangup. */ -static ssize_t gsmld_read(struct tty_struct *tty, struct file *file, - unsigned char *buf, size_t nr, - void **cookie, unsigned long offset) +static ssize_t gsmld_read(struct tty_struct *tty, struct file *file, u8 *buf, + size_t nr, void **cookie, unsigned long offset) { return -EOPNOTSUPP; } @@ -3660,7 +3659,7 @@ static ssize_t gsmld_read(struct tty_struct *tty, struct file *file, */ static ssize_t gsmld_write(struct tty_struct *tty, struct file *file, - const unsigned char *buf, size_t nr) + const u8 *buf, size_t nr) { struct gsm_mux *gsm = tty->disc_data; unsigned long flags; diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c index 9be0932d07e0..a670419efe79 100644 --- a/drivers/tty/n_hdlc.c +++ b/drivers/tty/n_hdlc.c @@ -425,8 +425,8 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const u8 *data, * Returns the number of bytes returned or error code. */ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file, - __u8 *kbuf, size_t nr, - void **cookie, unsigned long offset) + u8 *kbuf, size_t nr, void **cookie, + unsigned long offset) { struct n_hdlc *n_hdlc = tty->disc_data; int ret = 0; @@ -518,7 +518,7 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file, * Returns the number of bytes written (or error code). */ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file, - const unsigned char *data, size_t count) + const u8 *data, size_t count) { struct n_hdlc *n_hdlc = tty->disc_data; int error = 0; diff --git a/drivers/tty/n_null.c b/drivers/tty/n_null.c index 4a0d8bb2fb4c..5a429d923eb3 100644 --- a/drivers/tty/n_null.c +++ b/drivers/tty/n_null.c @@ -10,15 +10,14 @@ * Copyright (C) Intel 2017 */ -static ssize_t n_null_read(struct tty_struct *tty, struct file *file, - unsigned char *buf, size_t nr, - void **cookie, unsigned long offset) +static ssize_t n_null_read(struct tty_struct *tty, struct file *file, u8 *buf, + size_t nr, void **cookie, unsigned long offset) { return -EOPNOTSUPP; } static ssize_t n_null_write(struct tty_struct *tty, struct file *file, - const unsigned char *buf, size_t nr) + const u8 *buf, size_t nr) { return -EOPNOTSUPP; } diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 1053b2adb04c..f44f38bb412e 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -2128,12 +2128,11 @@ static int job_control(struct tty_struct *tty, struct file *file) * claims non-exclusive termios_rwsem; * publishes read_tail */ -static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, - unsigned char *kbuf, size_t nr, - void **cookie, unsigned long offset) +static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, u8 *kbuf, + size_t nr, void **cookie, unsigned long offset) { struct n_tty_data *ldata = tty->disc_data; - unsigned char *kb = kbuf; + u8 *kb = kbuf; DEFINE_WAIT_FUNC(wait, woken_wake_function); int c; int minimum, time; @@ -2332,9 +2331,9 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, */ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file, - const unsigned char *buf, size_t nr) + const u8 *buf, size_t nr) { - const unsigned char *b = buf; + const u8 *b = buf; DEFINE_WAIT_FUNC(wait, woken_wake_function); int c; ssize_t retval = 0; diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h index a661d7df5497..af01e89074b2 100644 --- a/include/linux/tty_ldisc.h +++ b/include/linux/tty_ldisc.h @@ -90,8 +90,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass, * * Optional. * - * @read: [TTY] ``ssize_t ()(struct tty_struct *tty, struct file *file, - * unsigned char *buf, size_t nr)`` + * @read: [TTY] ``ssize_t ()(struct tty_struct *tty, struct file *file, u8 *buf, + * size_t nr)`` * * This function is called when the user requests to read from the @tty. * The line discipline will return whatever characters it has buffered up @@ -102,7 +102,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass, * Optional: %EIO unless provided. Can sleep. * * @write: [TTY] ``ssize_t ()(struct tty_struct *tty, struct file *file, - * const unsigned char *buf, size_t nr)`` + * const u8 *buf, size_t nr)`` * * This function is called when the user requests to write to the @tty. * The line discipline will deliver the characters to the low-level tty @@ -238,11 +238,10 @@ struct tty_ldisc_ops { int (*open)(struct tty_struct *tty); void (*close)(struct tty_struct *tty); void (*flush_buffer)(struct tty_struct *tty); - ssize_t (*read)(struct tty_struct *tty, struct file *file, - unsigned char *buf, size_t nr, - void **cookie, unsigned long offset); + ssize_t (*read)(struct tty_struct *tty, struct file *file, u8 *buf, + size_t nr, void **cookie, unsigned long offset); ssize_t (*write)(struct tty_struct *tty, struct file *file, - const unsigned char *buf, size_t nr); + const u8 *buf, size_t nr); int (*ioctl)(struct tty_struct *tty, unsigned int cmd, unsigned long arg); int (*compat_ioctl)(struct tty_struct *tty, unsigned int cmd, diff --git a/net/nfc/nci/uart.c b/net/nfc/nci/uart.c index 93775c540287..ed1508a9e093 100644 --- a/net/nfc/nci/uart.c +++ b/net/nfc/nci/uart.c @@ -345,14 +345,14 @@ static int nci_uart_tty_ioctl(struct tty_struct *tty, unsigned int cmd, /* We don't provide read/write/poll interface for user space. */ static ssize_t nci_uart_tty_read(struct tty_struct *tty, struct file *file, - unsigned char *buf, size_t nr, - void **cookie, unsigned long offset) + u8 *buf, size_t nr, void **cookie, + unsigned long offset) { return 0; } static ssize_t nci_uart_tty_write(struct tty_struct *tty, struct file *file, - const unsigned char *data, size_t count) + const u8 *data, size_t count) { return 0; } From patchwork Thu Aug 10 09:15:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 712537 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06BC2C001B0 for ; Thu, 10 Aug 2023 09:19:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234718AbjHJJTF (ORCPT ); Thu, 10 Aug 2023 05:19:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234783AbjHJJSW (ORCPT ); Thu, 10 Aug 2023 05:18:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1F2F47EA; Thu, 10 Aug 2023 02:16:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1F9BD654DA; Thu, 10 Aug 2023 09:16:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1808C433C9; Thu, 10 Aug 2023 09:16:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691658999; bh=7m3JsfPMLiKgFfQV74GNsNXjJ2VCRfWCFVK3pJRiZ3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DG6xWzEwT7xF96/U2407avRLJMGIPoz80XMbZrmyx+9d5u3h3o8q4hXBs0ypGm2hn 79QEOuzO7vfVgAPlK3/AcLRrjafrRCGnzXgZdw+YnRzG2leCYCwX+KbRCEZRO2xNiC Wr911rl2+YUbqX7LNo5CzdJ0aV4fZiY+jZmTtugVhTV6l8FBoB0uTk7nE0TdGYcM8i zH0pz5WbQ0F+NLwWGYMFrDJDixTxGl1FI3yg15sjv5ye2HF8Sy2I196fgYylcM2IIY x7Z8RqPaRj7awBQZ3UjS7xxdKvxheIOPP3u9n1mO3SNe38RQBhI0jmWwBwSB1mFMfe wEduW9x+IblfA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH 35/36] tty: hso: simplify hso_serial_write() Date: Thu, 10 Aug 2023 11:15:09 +0200 Message-ID: <20230810091510.13006-36-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org There is no need for two more variables in hso_serial_write(). Switch to min_t() and eliminate those. Furthermore, the 'if-goto' is superfluous as memcpy() of zero count is a nop. So is addition of zero. So remove the 'if-goto' completely. Signed-off-by: Jiri Slaby (SUSE) Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni --- drivers/net/usb/hso.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index 3f424da87bf4..83b8452220ec 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -1326,7 +1326,6 @@ static ssize_t hso_serial_write(struct tty_struct *tty, const u8 *buf, size_t count) { struct hso_serial *serial = tty->driver_data; - int space, tx_bytes; unsigned long flags; /* sanity check */ @@ -1337,21 +1336,16 @@ static ssize_t hso_serial_write(struct tty_struct *tty, const u8 *buf, spin_lock_irqsave(&serial->serial_lock, flags); - space = serial->tx_data_length - serial->tx_buffer_count; - tx_bytes = (count < space) ? count : space; + count = min_t(size_t, serial->tx_data_length - serial->tx_buffer_count, + count); + memcpy(serial->tx_buffer + serial->tx_buffer_count, buf, count); + serial->tx_buffer_count += count; - if (!tx_bytes) - goto out; - - memcpy(serial->tx_buffer + serial->tx_buffer_count, buf, tx_bytes); - serial->tx_buffer_count += tx_bytes; - -out: spin_unlock_irqrestore(&serial->serial_lock, flags); hso_kick_transmit(serial); /* done */ - return tx_bytes; + return count; } /* how much room is there for writing */ From patchwork Thu Aug 10 09:15:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 712538 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8476C001B0 for ; Thu, 10 Aug 2023 09:18:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234893AbjHJJS6 (ORCPT ); Thu, 10 Aug 2023 05:18:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234907AbjHJJSG (ORCPT ); Thu, 10 Aug 2023 05:18:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2803A30DB; Thu, 10 Aug 2023 02:16:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 30A1B654F7; Thu, 10 Aug 2023 09:16:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0130FC433CB; Thu, 10 Aug 2023 09:16:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691659001; bh=EAzZvqV0DX/6MdQG6V3byUfhXhjqmaV2PFwGoLqDg8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gkoej6iSFauNlE7dWSTp1xK+Zil0fHVbrGDyfXRIZcijG+8mFqs2KZCGDVZk1BNIg 2BrkFE3DAyzqQBjSzwWnPHgT7lHoDPYh93Zvnvb2knmm72I3zNXWyiCbTQz7nRxzyc c1gn51OWjpJvxPhVY+qxUSfMoPktrsWQPxaJeYlQPVdxqw2ByFU7E2Zu2QFOOMsCqm iEJu0oUE+1M0zV7e5YclMNchhoe72pqshhn9Xg0meohMdAK6zy0R8a/OXG7OskOXcy eYLZGtok45f5+lS0LYVZXOCfiiDUzdgwarHg7S+zdd6Dqp+1PbS0iK6E3PkM99+et0 G0Qm8ToQVqDGA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Subject: [PATCH 36/36] tty: rfcomm: convert counts to size_t Date: Thu, 10 Aug 2023 11:15:10 +0200 Message-ID: <20230810091510.13006-37-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org> References: <20230810091510.13006-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Unify the type of tty_operations::write() counters with the 'count' parameter. I.e. use size_t for them. Signed-off-by: Jiri Slaby (SUSE) Cc: Marcel Holtmann Cc: Johan Hedberg Cc: Luiz Augusto von Dentz --- net/bluetooth/rfcomm/tty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index 33b135ed59c4..94ec913dfb76 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c @@ -785,12 +785,12 @@ static ssize_t rfcomm_tty_write(struct tty_struct *tty, const u8 *buf, struct rfcomm_dev *dev = tty->driver_data; struct rfcomm_dlc *dlc = dev->dlc; struct sk_buff *skb; - int sent = 0, size; + size_t sent = 0, size; BT_DBG("tty %p count %zu", tty, count); while (count) { - size = min_t(uint, count, dlc->mtu); + size = min_t(size_t, count, dlc->mtu); skb = rfcomm_wmalloc(dev, size + RFCOMM_SKB_RESERVE, GFP_ATOMIC); if (!skb)