From nobody Thu Dec 18 23:36:31 2025 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 02CBDC5ACB3 for ; Tue, 21 Nov 2023 09:23:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232209AbjKUJXO (ORCPT ); Tue, 21 Nov 2023 04:23:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231982AbjKUJXJ (ORCPT ); Tue, 21 Nov 2023 04:23:09 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7A14C1 for ; Tue, 21 Nov 2023 01:23:05 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DB03C433CA; Tue, 21 Nov 2023 09:23:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558585; bh=mTUBCg9Yy/6tTejWqtj99Kn79h3uid57bb+Gyj0JwX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YiCF7hYQDFJ7iZfFuIc0whqlPUrb5gJbYUxDcESqiskN1TNAL55wg+KmOhTb8VpUk /9zSCYWOyK7dKNuVCYzbuMKlBIpesIQ1wqDe0Ac5LaRPZZUNbP8ATRclwuvKseiO3h sr9wY7zH3J6s62Tng2++B0rSi8xfhhWQxw+IlCMxsng8k5fl9HEmc6mtCMODBipFUe d8uzTK8zPrYYH0nKfhzMQrMbMbBq58MxL0MhrbWEjvSxuVsJVFZgyoAgNlGeLPIdWO j/4tCayQOZttxL3FwOoKxfCGfZ456y4zkP0C77Sh+u4w3WFmJ0TdJdQZO7yp/0dyd4 b7ZbqzonWr9jA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Jan Kara Subject: [PATCH 01/17] tty: deprecate tty_write_message() Date: Tue, 21 Nov 2023 10:22:42 +0100 Message-ID: <20231121092258.9334-2-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" tty_write_message() has only one user: quotas. In particular, there the use depends on CONFIG_PRINT_QUOTA_WARNING. And that is deprecated and marked as BROKEN already too. So make tty_write_message() dependent on that very config option. This action in fact drops tty_write_message() from the vmlinux binary. Good riddance. Signed-off-by: Jiri Slaby (SUSE) Cc: Jan Kara Acked-by: Jan Kara --- drivers/tty/tty_io.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 06414e43e0b5..ee5a90f9adb5 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -1047,6 +1047,7 @@ static ssize_t iterate_tty_write(struct tty_ldisc *ld= , struct tty_struct *tty, return ret; } =20 +#ifdef CONFIG_PRINT_QUOTA_WARNING /** * tty_write_message - write a message to a certain tty, not just the cons= ole. * @tty: the destination tty_struct @@ -1057,6 +1058,8 @@ static ssize_t iterate_tty_write(struct tty_ldisc *ld= , struct tty_struct *tty, * needed. * * We must still hold the BTM and test the CLOSING flag for the moment. + * + * This function is DEPRECATED, do not use in new code. */ void tty_write_message(struct tty_struct *tty, char *msg) { @@ -1069,6 +1072,7 @@ void tty_write_message(struct tty_struct *tty, char *= msg) tty_write_unlock(tty); } } +#endif =20 static ssize_t file_tty_write(struct file *file, struct kiocb *iocb, struc= t iov_iter *from) { --=20 2.42.1 From nobody Thu Dec 18 23:36:31 2025 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 8F036C5ACB3 for ; Tue, 21 Nov 2023 09:23:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232362AbjKUJXS (ORCPT ); Tue, 21 Nov 2023 04:23:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231936AbjKUJXK (ORCPT ); Tue, 21 Nov 2023 04:23:10 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 576FE116 for ; Tue, 21 Nov 2023 01:23:07 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7DF2C433C8; Tue, 21 Nov 2023 09:23:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558587; bh=NJRodWQw+P7zL14JGGfRqGN5XnSMc52Tx2CPIuB6IKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tkyjypYt3IQbbl2DgXKlWlx+F+UoQfxwd8yzxqY0lHe6HGCuSS2oSFNfqX0nS0vfq k8B39ggdcyrEdbx3PbFrpLi2043eD+f4YrGXcroBXXw/mv86qoPx/L8OYvI32DH2it gTbTxLv/4+uDEvWTAN79xoW+KA0MdM68GsjAnc3iJtNw0CCeoWx9Dt7TSKnSSGIfwh 8IMnaus9PxGkEu3vMi9C7V7sMzUpBstBXg0xDPGzfG99gFRM4Hvhtmtd8jpRPIbKao UVYfeEuYQjaF6c5L/907W8wtaig9AKQbP1K7nJF99oQNhH2q1/4QLjyL0q2mF52PWu PQHM2ZbN5Dnfw== 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/17] tty: remove unneeded mbz from tiocsti() Date: Tue, 21 Nov 2023 10:22:43 +0100 Message-ID: <20231121092258.9334-3-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 'mbz' in tiocsti() is used only to pass TTY_NORMAL to tty_ldisc_ops::receive_buf(). But that can be achieved easier by simply passing NULL to ::receive_buf(). So drop this 'mbz'. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/tty_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index ee5a90f9adb5..005d91c63707 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -2280,7 +2280,7 @@ static bool tty_legacy_tiocsti __read_mostly =3D IS_E= NABLED(CONFIG_LEGACY_TIOCSTI) */ static int tiocsti(struct tty_struct *tty, char __user *p) { - char ch, mbz =3D 0; + char ch; struct tty_ldisc *ld; =20 if (!tty_legacy_tiocsti && !capable(CAP_SYS_ADMIN)) @@ -2296,7 +2296,7 @@ static int tiocsti(struct tty_struct *tty, char __use= r *p) return -EIO; tty_buffer_lock_exclusive(tty->port); if (ld->ops->receive_buf) - ld->ops->receive_buf(tty, &ch, &mbz, 1); + ld->ops->receive_buf(tty, &ch, NULL, 1); tty_buffer_unlock_exclusive(tty->port); tty_ldisc_deref(ld); return 0; --=20 2.42.1 From nobody Thu Dec 18 23:36:31 2025 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 F3C29C54FB9 for ; Tue, 21 Nov 2023 09:23:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232419AbjKUJXV (ORCPT ); Tue, 21 Nov 2023 04:23:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232066AbjKUJXM (ORCPT ); Tue, 21 Nov 2023 04:23:12 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0BB410E for ; Tue, 21 Nov 2023 01:23:08 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71B60C433C7; Tue, 21 Nov 2023 09:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558588; bh=+1z5LOwL5/wByoEwmaM4FneMWMS5WLPxn2QmVIRN2AY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bCwBVh4J1NFGdlP6wl50zfJ4zCDZKWSbOGRsniuiRrOdOSHf+WWf1affyoNnvUWe4 QgZg8OnVuY8re+gqb2uisjjqIp2nWJvggiAtLm4BwhxGhrxTgi3DqLnpCo2NOR0+5N LPUvTWUpWZa0dHh1BwIFOnXbI7Dq6RBomNXPsZ01OGqXEBpJepulMZ+Pwzz0J+Kaz9 DvErdNkiHwMxoex9xSshXdJTwommXeYo9pTghjyMDNlhUnXviHlXhkPtbc65nd+Zqt /NY5l9Y8M+SylNq3jF4i0RVW6uiQle2nltPBqAil7ksQQt96ltHknhDYXP2Mw5b233 X48R7mABHJ4RA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 03/17] tty: fix tty_operations types in documentation Date: Tue, 21 Nov 2023 10:22:44 +0100 Message-ID: <20231121092258.9334-4-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Commits 95713967ba52 ("tty: make tty_operations::write()'s count size_t") and dcaafbe6ee3b ("tty: propagate u8 data to tty_operations::put_char()") changed types of characters to u8, but omitted to fix the documentation. Fix the latter now. Signed-off-by: Jiri Slaby (SUSE) --- include/linux/tty_driver.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index 18beff0cec1a..f428c1b784a2 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -72,8 +72,7 @@ struct serial_struct; * is closed for the last time freeing up the resources. This is * actually the second part of shutdown for routines that might sleep. * - * @write: ``ssize_t ()(struct tty_struct *tty, const unsigned char *buf, - * size_t count)`` + * @write: ``ssize_t ()(struct tty_struct *tty, const u8 *buf, size_t coun= t)`` * * This routine is called by the kernel to write a series (@count) of * characters (@buf) to the @tty device. The characters may come from @@ -85,7 +84,7 @@ struct serial_struct; * * Optional: Required for writable devices. May not sleep. * - * @put_char: ``int ()(struct tty_struct *tty, unsigned char ch)`` + * @put_char: ``int ()(struct tty_struct *tty, u8 ch)`` * * This routine is called by the kernel to write a single character @ch to * the @tty device. If the kernel uses this routine, it must call the --=20 2.42.1 From nobody Thu Dec 18 23:36:31 2025 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 B2B9BC5ACB3 for ; Tue, 21 Nov 2023 09:23:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232287AbjKUJX0 (ORCPT ); Tue, 21 Nov 2023 04:23:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232235AbjKUJXO (ORCPT ); Tue, 21 Nov 2023 04:23:14 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AD87124 for ; Tue, 21 Nov 2023 01:23:10 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEFA3C433C9; Tue, 21 Nov 2023 09:23:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558590; bh=131jdbssfnDrqOL8OgWBRRcAPmpb2PV4AyWqcy2u3A4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eYppKh38XoX0kAAQw2WPG9pAy188CbWJOXxJ1ZtNdOPKvgwfuEy85TF2RZWr72FTU 4nRtAMeODipvZbRUv+HFTZWJ3kDlvitbs3xpatF0EcXEUss1NwVP6FfMKw0B64C5g7 rgSH7qnfp65Gl4/8DLS7OS0sFfuM7BS1eHOZcW5wq80B1k4dZNoo097XbAxxZHUlO/ ED+rg3jkIkuAcOkMR/q1iw3pZ58EIyDe6yC5fhXgvq6Z1euq2M5H440ssSGAp50MwD r45GjpPUmEAfTh13uP57RYKgJv32MhpMd5okdD9oHXewEcnbZ6cbHgrLxBdSVwgoZ2 8x8j14L0gGnOw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 04/17] tty: move locking docs out of Returns for functions in tty.h Date: Tue, 21 Nov 2023 10:22:45 +0100 Message-ID: <20231121092258.9334-5-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Both tty_kref_get() and tty_get_baud_rate() note about locking in their Return kernel-doc clause. Extract this info into a separate "Locking" paragraph -- the same as we do for other tty functions. Signed-off-by: Jiri Slaby (SUSE) Suggested-by: Ilpo J=C3=A4rvinen Reviewed-by: Ilpo J=C3=A4rvinen --- include/linux/tty.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/linux/tty.h b/include/linux/tty.h index 4b6340ac2af2..7625fc98fef3 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -393,8 +393,10 @@ extern const struct class tty_class; * tty_kref_get - get a tty reference * @tty: tty device * - * Returns: a new reference to a tty object. The caller must hold sufficie= nt - * locks/counts to ensure that their existing reference cannot go away + * Returns: a new reference to a tty object + * + * Locking: The caller must hold sufficient locks/counts to ensure that th= eir + * existing reference cannot go away. */ static inline struct tty_struct *tty_kref_get(struct tty_struct *tty) { @@ -436,10 +438,10 @@ void tty_encode_baud_rate(struct tty_struct *tty, spe= ed_t ibaud, * tty_get_baud_rate - get tty bit rates * @tty: tty to query * - * Returns: the baud rate as an integer for this terminal. The termios lock - * must be held by the caller and the terminal bit flags may be updated. + * Returns: the baud rate as an integer for this terminal * - * Locking: none + * Locking: The termios lock must be held by the caller and the terminal b= it + * flags may be updated. */ static inline speed_t tty_get_baud_rate(struct tty_struct *tty) { --=20 2.42.1 From nobody Thu Dec 18 23:36:31 2025 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 091B5C54FB9 for ; Tue, 21 Nov 2023 09:23:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232822AbjKUJX3 (ORCPT ); Tue, 21 Nov 2023 04:23:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232253AbjKUJXQ (ORCPT ); Tue, 21 Nov 2023 04:23:16 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 266FE184 for ; Tue, 21 Nov 2023 01:23:12 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5EF8C433CC; Tue, 21 Nov 2023 09:23:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558591; bh=Qlx9viffecoULgm507HOr5Qx31VBXtpcn9Bhu0b34Hw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bFn/ZE2n+WBA7LzQvXL2q7Gw+jjgjE6FrzYMD4rVEbwMWYrBxPRttH5nRe3UCpSHd C2lKTTJ9INTa+OueAOy/ivf9zQaB/8xWw+2b+cVZmw9xDKU9D4IvDmiaGi3XM9mkuB /YXvL1iYbUUxCqQFNZAq33TKIWGw161dxWdCt3PCTL5H9CQkyDlMivh1As723X0cN1 vDTjQ9VE84Vn5e3/2rV3GTcr+kPqvohyxr+izf7e+kwmu93pqFbkpB3GsdOmcV7BS+ mwlXNnndw+09YmvSx2Y1Oj1pU+IJv9PaNpUpeHilEJ+2rg9JTal6QfuquBrr4pjhCI KnZ3/mApPmwgA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 05/17] tty: amiserial: return from receive_chars() without goto Date: Tue, 21 Nov 2023 10:22:46 +0100 Message-ID: <20231121092258.9334-6-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The 'out' label is just before 'return'. So return immediately and drop both the label and the return. This makes the code more straightforward. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/amiserial.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index 785558c65ae8..b9580bb9afd3 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c @@ -230,7 +230,7 @@ static void receive_chars(struct serial_state *info) * should be ignored. */ if (status & info->ignore_status_mask) - goto out; + return; =20 status &=3D info->read_status_mask; =20 @@ -258,8 +258,6 @@ static void receive_chars(struct serial_state *info) if (oe =3D=3D 1) tty_insert_flip_char(&info->tport, 0, TTY_OVERRUN); tty_flip_buffer_push(&info->tport); -out: - return; } =20 static void transmit_chars(struct serial_state *info) --=20 2.42.1 From nobody Thu Dec 18 23:36:31 2025 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 D9F85C54FB9 for ; Tue, 21 Nov 2023 09:23:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233545AbjKUJXe (ORCPT ); Tue, 21 Nov 2023 04:23:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232465AbjKUJXT (ORCPT ); Tue, 21 Nov 2023 04:23:19 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7C26124 for ; Tue, 21 Nov 2023 01:23:13 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2ED9EC433C7; Tue, 21 Nov 2023 09:23:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558593; bh=diBYhCi9kUrJKVnjd9DDPQZOesiKDAPdnCFzVrk5K90=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P7pHbyN1kipEeAiP5eyb3QNVHhjVJF4v58x162jD4WQLSJpJoJdWhkVXwS/eqZDFm pkeLgM2theJsap7u7hBHAQfjM2gd01rkFbl7/52L6Oip9jzfbdAICc8Y9wC57tXDsa WgFvqB2CP16SRGTu4N1nfqbXjs55+8aV0y1OpyEFbnIr+UfZsz7BBGetIsx3sG7qR6 HVuhnSNBr4Nu7+7YzMkQXyOJMzuvywcxoeqn59A8t4tOZSdTO0yNOfDt8Iae2Rgc9h IhgI6fF+4xPjYCNI09CMuoGcpzu1GPynvo8l3MNuzFJQABnKWiRVPPsU1NVQ7EX5Fe e2tnZt1gM47Zg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 06/17] tty: amiserial: use bool and rename overrun flag in receive_chars() Date: Tue, 21 Nov 2023 10:22:47 +0100 Message-ID: <20231121092258.9334-7-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 'oe' is a yes-no flag, switch it to boolean. And rename to overrun. All for the code to be more obvious. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/amiserial.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index b9580bb9afd3..a80f059f77bf 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c @@ -180,7 +180,7 @@ static void receive_chars(struct serial_state *info) int serdatr; unsigned char ch, flag; struct async_icount *icount; - int oe =3D 0; + bool overrun =3D false; =20 icount =3D &info->icount; =20 @@ -251,11 +251,11 @@ static void receive_chars(struct serial_state *info) * reported immediately, and doesn't * affect the current character */ - oe =3D 1; + overrun =3D true; } } tty_insert_flip_char(&info->tport, ch, flag); - if (oe =3D=3D 1) + if (overrun) tty_insert_flip_char(&info->tport, 0, TTY_OVERRUN); tty_flip_buffer_push(&info->tport); } --=20 2.42.1 From nobody Thu Dec 18 23:36:31 2025 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 A8C1CC61D88 for ; Tue, 21 Nov 2023 09:23:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232429AbjKUJXg (ORCPT ); Tue, 21 Nov 2023 04:23:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232812AbjKUJXU (ORCPT ); Tue, 21 Nov 2023 04:23:20 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74870198 for ; Tue, 21 Nov 2023 01:23:15 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC1A6C433C8; Tue, 21 Nov 2023 09:23:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558595; bh=1ot3xOBoOP7h0U8F/4uFP8Qnn04pPCBCsYAQSIl1nS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XMaaAFxtaDDQ56o7fXs0QGyJcFgyPvsmGh4mwdScBGVHv6QbGWvjUyLtBXJ/f+KuA ES0RVOIH2egtSF87/OHQecYS33l9Spw874MqkkK61gISBS5zFMgvG9tTjmiWBAvPTB ATJPBITN4yxZB9bPfXrJfbnzHQp0FdmotvxpyqJW/ocA/UfrLslKHaIQbbAdaby4zp QwjGZqMr4CZ0qPCu/+NaBP2kBb4DFEHQZBwpcBaIN2IJ8SaG75NZWm/MJfKYBLjObi uCBIjbzCMh+ZNi5Z6jiBQQRevsVtxJ8GWrV4auGzSjcn5+SL6YORjtdCp56fcZ1ApB ockXOFliS6RKQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Laurentiu Tudor , linuxppc-dev@lists.ozlabs.org Subject: [PATCH 07/17] tty: ehv_bytecha: use memcpy_and_pad() in local_ev_byte_channel_send() Date: Tue, 21 Nov 2023 10:22:48 +0100 Message-ID: <20231121092258.9334-8-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There is a helper for memcpy(buffer)+memset(the_rest). Use it for simplicity. And add a comment why we are doing the copy in the first place. Signed-off-by: Jiri Slaby (SUSE) Cc: Laurentiu Tudor Cc: linuxppc-dev@lists.ozlabs.org --- drivers/tty/ehv_bytechan.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c index a067628e01c8..cc9f4338da60 100644 --- a/drivers/tty/ehv_bytechan.c +++ b/drivers/tty/ehv_bytechan.c @@ -143,9 +143,12 @@ static unsigned int local_ev_byte_channel_send(unsigne= d int handle, char buffer[EV_BYTE_CHANNEL_MAX_BYTES]; unsigned int c =3D *count; =20 + /* + * ev_byte_channel_send() expects at least EV_BYTE_CHANNEL_MAX_BYTES + * (16 B) in the buffer. Fake it using a local buffer if needed. + */ if (c < sizeof(buffer)) { - memcpy(buffer, p, c); - memset(&buffer[c], 0, sizeof(buffer) - c); + memcpy_and_pad(buffer, sizeof(buffer), p, c, 0); p =3D buffer; } return ev_byte_channel_send(handle, count, p); --=20 2.42.1 From nobody Thu Dec 18 23:36:31 2025 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 AF10BC5ACB3 for ; Tue, 21 Nov 2023 09:23:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232065AbjKUJXk (ORCPT ); Tue, 21 Nov 2023 04:23:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232964AbjKUJXV (ORCPT ); Tue, 21 Nov 2023 04:23:21 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 449081BC for ; Tue, 21 Nov 2023 01:23:17 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E493C433C7; Tue, 21 Nov 2023 09:23:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558596; bh=Y5i+1euxXI4UCUqQ8X+2VuZ/t15K0hpOycDIDgEeERI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IH+7wSj9QouOREWdasm6QA3mhk9WhQXzBt0Q8x2nYkUJMCp92n6GV3It3p5TDM9RP YRzbU4o3CIcfbsVm6Z65o4m6XtIPzBbIKIWDZfMDyE7zAqnEAkPdvp8iF9ic5Cbhqf aZKZGqZjt9j/W6KMV+S9+Q1++LngSBSOz9VZiysDM6KhCYJ2OgAUJGRsVWO/1EP4ch pwwPnTBJoiu2M+AnPBSuBUTGhM468rDQ/eqjns03GJAfokrz73XaYrYvX/gz2jl6/L QTNTA6kFDUwHUiabdwYcDj2t4MS4vU7sjigNDMUwlS+o2ugv4bTnbOG5UZQJmOb/b0 VbaBgCbr3yrtg== 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/17] tty: goldfish: drop unneeded temporary variables Date: Tue, 21 Nov 2023 10:22:49 +0100 Message-ID: <20231121092258.9334-9-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" We can pass 'buf' directly to goldfish_tty_rw() using simple (unsigned long) cast. There is no need to obfuscate the code by another variable with double casts. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/goldfish.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c index 4591f940b7a1..dccf6c6c69c6 100644 --- a/drivers/tty/goldfish.c +++ b/drivers/tty/goldfish.c @@ -128,16 +128,14 @@ static void goldfish_tty_rw(struct goldfish_tty *qtty, static void goldfish_tty_do_write(int line, const u8 *buf, unsigned int co= unt) { struct goldfish_tty *qtty =3D &goldfish_ttys[line]; - unsigned long address =3D (unsigned long)(void *)buf; =20 - goldfish_tty_rw(qtty, address, count, 1); + goldfish_tty_rw(qtty, (unsigned long)buf, count, 1); } =20 static irqreturn_t goldfish_tty_interrupt(int irq, void *dev_id) { struct goldfish_tty *qtty =3D dev_id; void __iomem *base =3D qtty->base; - unsigned long address; unsigned char *buf; u32 count; =20 @@ -147,8 +145,7 @@ static irqreturn_t goldfish_tty_interrupt(int irq, void= *dev_id) =20 count =3D tty_prepare_flip_string(&qtty->port, &buf, count); =20 - address =3D (unsigned long)(void *)buf; - goldfish_tty_rw(qtty, address, count, 0); + goldfish_tty_rw(qtty, (unsigned long)buf, count, 0); =20 tty_flip_buffer_push(&qtty->port); return IRQ_HANDLED; --=20 2.42.1 From nobody Thu Dec 18 23:36:31 2025 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 BC9B3C54FB9 for ; Tue, 21 Nov 2023 09:23:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233735AbjKUJXx (ORCPT ); Tue, 21 Nov 2023 04:23:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233271AbjKUJXZ (ORCPT ); Tue, 21 Nov 2023 04:23:25 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 211D412C for ; Tue, 21 Nov 2023 01:23:20 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18901C433CA; Tue, 21 Nov 2023 09:23:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558599; bh=9PpdhyBVsu45ZCI81VGErhQfiGGxB/f1DEh5vaZ3fm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EdBxAV7TZbxSuBj60zoJAneC4IgZRVvo2sHh/6D4pz5ADsXfKZA5QMskKPFDr2B21 oCKJ9/YwuqeOpqa83og/tUyjhUgQ9RgHZr3yuB7eG9hMig0QjfE0URzhU8WtjVkiVe KZHyJz/eH3hNcqfJSyBj9Y8XnN6uvO1RpyhN9Eg4kRSbhA/pmUM4/sGe7KRGmtbogo PmVVy5nHHmDbXaJgmjishZYFwYdirQmhuX1FArM1mQeLSOLt11wJV9VYxUlluFLwOk JIZ+KunqutGepha4LK3HN10iz7yCPOb6IJqMDNheXVqW9IHM7Ei4CfHFetByJn0AOW c1eoOhGTjT2gQ== 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 , linux-usb@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 09/17] tty: hso: don't emit load/unload info to the log Date: Tue, 21 Nov 2023 10:22:50 +0100 Message-ID: <20231121092258.9334-10-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It's preferred NOT to emit anything during the module load and unload (in case the un/load was successful). So drop these prints from hso along with global 'version'. It even contains no version after all. Signed-off-by: Jiri Slaby (SUSE) Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: linux-usb@vger.kernel.org Cc: netdev@vger.kernel.org Acked-by: Jakub Kicinski --- drivers/net/usb/hso.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index 83b8452220ec..48450fe861ad 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -363,7 +363,6 @@ static int disable_net; /* driver info */ static const char driver_name[] =3D "hso"; static const char tty_filename[] =3D "ttyHS"; -static const char *version =3D __FILE__ ": " MOD_AUTHOR; /* the usb driver itself (registered in hso_init) */ static struct usb_driver hso_driver; /* serial structures */ @@ -3231,9 +3230,6 @@ static int __init hso_init(void) int i; int result; =20 - /* put it in the log */ - pr_info("%s\n", version); - /* Initialise the serial table semaphore and table */ for (i =3D 0; i < HSO_SERIAL_TTY_MINORS; i++) serial_table[i] =3D NULL; @@ -3285,8 +3281,6 @@ static int __init hso_init(void) =20 static void __exit hso_exit(void) { - pr_info("unloaded\n"); - tty_unregister_driver(tty_drv); /* deregister the usb driver */ usb_deregister(&hso_driver); --=20 2.42.1 From nobody Thu Dec 18 23:36:31 2025 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 C7E04C54FB9 for ; Tue, 21 Nov 2023 09:23:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233166AbjKUJX4 (ORCPT ); Tue, 21 Nov 2023 04:23:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232253AbjKUJXc (ORCPT ); Tue, 21 Nov 2023 04:23:32 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81171185 for ; Tue, 21 Nov 2023 01:23:22 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AEBE8C433CD; Tue, 21 Nov 2023 09:23:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558601; bh=J9+0GAdeqi0Ihu8k/yKWMGuJLA+L/8D5q4AyXvnWFUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=joL4lNeeXdT8sgymVjfPxJdGEgdmJMXdx1lxwxLRpzs9JPGNAmnht0AnabfVbu479 1k/dvSQKu37gIQKySa8+yCQv4AO5mmQhV5b4sb6aSxTgWlDMoJwGSUUwUU1dN/kVGe wrRTKvMy8ZwK2sDFLF7bdedr8jBGVSU5t/USoo+hTzaDcVOraZJ2mSPXKio9X6Ksbz M/5DphpvnwANBpsAoI3OZoTNVz1kbiPX/Apb+tQP+cTpipXiCpTySfnOeAmTIc5qAE FOrggxWRY9i/kzp+EHW6TuOWdKfcWDxeQlgaKpBpfiERpVNGqxt+liG/CtpuSLRrq5 FRaTfyApDjMVQ== 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 , linux-usb@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 10/17] tty: hso: don't initialize global serial_table Date: Tue, 21 Nov 2023 10:22:51 +0100 Message-ID: <20231121092258.9334-11-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 'serial_table' is global, so there is no need to initialize it to NULLs at the module load. Drop this unneeded for loop. Signed-off-by: Jiri Slaby (SUSE) Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: linux-usb@vger.kernel.org Cc: netdev@vger.kernel.org Acked-by: Jakub Kicinski --- drivers/net/usb/hso.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index 48450fe861ad..f088ea2ba6f3 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -3227,13 +3227,8 @@ static struct usb_driver hso_driver =3D { =20 static int __init hso_init(void) { - int i; int result; =20 - /* Initialise the serial table semaphore and table */ - for (i =3D 0; i < HSO_SERIAL_TTY_MINORS; i++) - serial_table[i] =3D NULL; - /* allocate our driver using the proper amount of supported minors */ tty_drv =3D tty_alloc_driver(HSO_SERIAL_TTY_MINORS, TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV); --=20 2.42.1 From nobody Thu Dec 18 23:36:31 2025 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 50235C54FB9 for ; Tue, 21 Nov 2023 09:23:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233494AbjKUJX7 (ORCPT ); Tue, 21 Nov 2023 04:23:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233597AbjKUJXl (ORCPT ); Tue, 21 Nov 2023 04:23:41 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 263B510C0 for ; Tue, 21 Nov 2023 01:23:23 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50BFFC433BD; Tue, 21 Nov 2023 09:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558603; bh=+5n2mUpG4q3myzhvyd7KfFL/hxg0CFLJ/PmuTSTaY6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ljq1V0RC2KP6ws3XfIFi2ZR28B0v5Bfu38nZAOFsLytKLElqcxHwreJJQLxWZ+fri mWSMDDvPs64Aof9bEcPnM6TRuWBTy6YOzLt5yZUy3MqiUdh74Iyne4CQryja0MK6DC WW+HJ6KY+9qIRLpdDaiBqHyNQgxwzYbL+77WrZM2DtKVU824khjepG0Sfqt/9BCMb6 Up2caehfFcZlTOCyI9KomPdNrrUHfY9h8wDItDtRiHa/2GIAw5UGnOtwrcUJh4Q1+j u/WCFpblEnv7exzQktl2l7+Y04/Xlv/eIRTeaQsfQh8IoFf1+L9BdNJg/d1Pcljsn/ +rohHZM+ihVlg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , linuxppc-dev@lists.ozlabs.org Subject: [PATCH 11/17] tty: hvc_console: use flexible array for outbuf Date: Tue, 21 Nov 2023 10:22:52 +0100 Message-ID: <20231121092258.9334-12-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This means: * move outbuf to the end of struct hvc_struct and convert from pointer to flexible array (the structure is smaller now) * use struct_size() at the allocation site * align outbuf in the struct instead of ALIGN() at kzalloc() And apart from the above, use u8 instead of char (which are the same thanks to -funsigned-char). The former is now preferred over the latter. It makes the code easier to understand. Signed-off-by: Jiri Slaby (SUSE) Cc: linuxppc-dev@lists.ozlabs.org --- drivers/tty/hvc/hvc_console.c | 4 +--- drivers/tty/hvc/hvc_console.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c index 959fae54ca39..93b613e1f176 100644 --- a/drivers/tty/hvc/hvc_console.c +++ b/drivers/tty/hvc/hvc_console.c @@ -922,8 +922,7 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data, return ERR_PTR(err); } =20 - hp =3D kzalloc(ALIGN(sizeof(*hp), sizeof(long)) + outbuf_size, - GFP_KERNEL); + hp =3D kzalloc(struct_size(hp, outbuf, outbuf_size), GFP_KERNEL); if (!hp) return ERR_PTR(-ENOMEM); =20 @@ -931,7 +930,6 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data, hp->data =3D data; hp->ops =3D ops; hp->outbuf_size =3D outbuf_size; - hp->outbuf =3D &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))]; =20 tty_port_init(&hp->port); hp->port.ops =3D &hvc_port_ops; diff --git a/drivers/tty/hvc/hvc_console.h b/drivers/tty/hvc/hvc_console.h index 9668f821db01..b718714bf399 100644 --- a/drivers/tty/hvc/hvc_console.h +++ b/drivers/tty/hvc/hvc_console.h @@ -37,7 +37,6 @@ struct hvc_struct { spinlock_t lock; int index; int do_wakeup; - char *outbuf; int outbuf_size; int n_outbuf; uint32_t vtermno; @@ -48,6 +47,7 @@ struct hvc_struct { struct work_struct tty_resize; struct list_head next; unsigned long flags; + u8 outbuf[] __aligned(sizeof(long)); }; =20 /* implemented by a low level driver */ --=20 2.42.1 From nobody Thu Dec 18 23:36:31 2025 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 87480C54FB9 for ; Tue, 21 Nov 2023 09:24:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233748AbjKUJYF (ORCPT ); Tue, 21 Nov 2023 04:24:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233617AbjKUJXq (ORCPT ); Tue, 21 Nov 2023 04:23:46 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C20D511A for ; Tue, 21 Nov 2023 01:23:25 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06674C43391; Tue, 21 Nov 2023 09:23:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558605; bh=422VxiK87dzWUOJytz3EHqN1a+RdqnMf/xYBks1K7os=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WIeSXUZT5Zd5gFDKfkN2dEKBartK8soImgPbg3Uw3mVQJGUDkMXZjRr1FVhiWsEBf mI01vMF8t9qicENnYiI8BcFj0H5r9gHIPA6fM3DLtQTboflHR77aRN8HXEWwBiduvJ EwhIrWEMWNmKMAy476pHRxEUgq/PNfx3VwHRkuYdplHm7VmlqcCuGr6eJq8i6Mg9v3 XAPHv9sA7Gi7FqPgIusC9aKm3YX1piTyGc+IqlITUw3N3u4DGEBlNG15EUpkBsGS4j tP6mb8x8tSnUy84ZCeDHhxXkUFHFS0MV7FPHmCc9fb604bzuiQr998K6BHVcQiipxh cOAWxcm3u32cA== 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/17] tty: nozomi: remove unused debugging DUMP() Date: Tue, 21 Nov 2023 10:22:53 +0100 Message-ID: <20231121092258.9334-13-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" DUMP()'s only use is commented out. Remove the macro completely along with this unused use. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/nozomi.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c index 02cd40147b3a..b247341bd12f 100644 --- a/drivers/tty/nozomi.c +++ b/drivers/tty/nozomi.c @@ -65,24 +65,8 @@ do { \ #define DBG3(args...) DBG_(0x04, ##args) #define DBG4(args...) DBG_(0x08, ##args) =20 -/* TODO: rewrite to optimize macros... */ - #define TMP_BUF_MAX 256 =20 -#define DUMP(buf__, len__) \ - do { \ - char tbuf[TMP_BUF_MAX] =3D {0}; \ - if (len__ > 1) { \ - u32 data_len =3D min_t(u32, len__, TMP_BUF_MAX); \ - strscpy(tbuf, buf__, data_len); \ - if (tbuf[data_len - 2] =3D=3D '\r') \ - tbuf[data_len - 2] =3D 'r'; \ - DBG1("SENDING: '%s' (%d+n)", tbuf, len__); \ - } else { \ - DBG1("SENDING: '%s' (%d)", tbuf, len__); \ - } \ - } while (0) - /* Defines */ #define NOZOMI_NAME "nozomi" #define NOZOMI_NAME_TTY "nozomi_tty" @@ -754,8 +738,6 @@ static int send_data(enum port_type index, struct nozom= i *dc) return 0; } =20 - /* DUMP(buf, size); */ - /* Write length + data */ write_mem32(addr, (u32 *) &size, 4); write_mem32(addr + 4, (u32 *) dc->send_buf, size); --=20 2.42.1 From nobody Thu Dec 18 23:36:31 2025 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 6F2C6C54FB9 for ; Tue, 21 Nov 2023 09:24:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233651AbjKUJYK (ORCPT ); Tue, 21 Nov 2023 04:24:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233655AbjKUJXs (ORCPT ); Tue, 21 Nov 2023 04:23:48 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A96FB10E7 for ; Tue, 21 Nov 2023 01:23:27 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 841C4C433AB; Tue, 21 Nov 2023 09:23:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558607; bh=A+gwjfR1YZFEn//O7QquhnOOdPgWP51q1cNT1xEbGz8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PCcVQCueYuWyDY4P/DEB7ksJqQttXRDIPuOZ7d1S9t+TY1NrMTLU+chfM1S6vlv+p WBd57pcx7EOKaym2OQcNLU7UHsd+qb/aAAsDtIkFG6hIChg838AvK6hstPgL1gFiLN FiXQmY6zoCqEKQPuyPESrYNhXJ6NsQb1ojKzz50bJUjUKJxAXZW0fYqvLaFHkEjCBp LSTeR5/RUtifDRKwQmwM+896CIvlaUn8mg8TS0FPcDdLxOxd+K9Lo7jqqeytBxSkHY qaJn/aoW6NRZPIMKquDInl67DpFnQFfRKdSx15MeAGPSiwYZxY8lvB2AnsUOJ8XAyb +0Nmw/Pstmt6Q== 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 , linux-alpha@vger.kernel.org Subject: [PATCH 13/17] tty: srmcons: use 'buf' directly in srmcons_do_write() Date: Tue, 21 Nov 2023 10:22:54 +0100 Message-ID: <20231121092258.9334-14-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There is no need to have a separate iterator ('cur') through 'buf' in srmcons_do_write(). 'buf' can be used directly which simplifies the code a bit. Signed-off-by: Jiri Slaby (SUSE) Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: linux-alpha@vger.kernel.org Reviewed-by: Richard Henderson --- arch/alpha/kernel/srmcons.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c index d6139dbae4ac..b68c5af083cd 100644 --- a/arch/alpha/kernel/srmcons.c +++ b/arch/alpha/kernel/srmcons.c @@ -94,24 +94,23 @@ srmcons_do_write(struct tty_port *port, const char *buf= , int count) static char str_cr[1] =3D "\r"; long c, remaining =3D count; srmcons_result result; - char *cur; int need_cr; =20 - for (cur =3D (char *)buf; remaining > 0; ) { + while (remaining > 0) { need_cr =3D 0; /*=20 * Break it up into reasonable size chunks to allow a chance * for input to get in */ for (c =3D 0; c < min_t(long, 128L, remaining) && !need_cr; c++) - if (cur[c] =3D=3D '\n') + if (buf[c] =3D=3D '\n') need_cr =3D 1; =09 while (c > 0) { - result.as_long =3D callback_puts(0, cur, c); + result.as_long =3D callback_puts(0, buf, c); c -=3D result.bits.c; remaining -=3D result.bits.c; - cur +=3D result.bits.c; + buf +=3D result.bits.c; =20 /* * Check for pending input iff a tty port was provided --=20 2.42.1 From nobody Thu Dec 18 23:36:31 2025 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 071FFC5ACB3 for ; Tue, 21 Nov 2023 09:24:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233523AbjKUJYS (ORCPT ); Tue, 21 Nov 2023 04:24:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233700AbjKUJXu (ORCPT ); Tue, 21 Nov 2023 04:23:50 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EA031701 for ; Tue, 21 Nov 2023 01:23:30 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1B03C433A9; Tue, 21 Nov 2023 09:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558609; bh=yT8k5oROMwqMcM21ujTXVO6pmxLHQflyqFgQxsTik/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cz76iEMEWa2wZDM8a7P/JAxgC86aIOrdBrehYNup2d1+hTJGyIr97bk405j66mQNf Lc82FOLTgK3QmTisWpcx/FtuOrg+i38nQWH12pXlEveToSPpAZCc6hg2UZSPe6CeCc K+FRLykFfguYlWGgQ+hphLflfXsuYa1MQkckcOufp8t13ITwe+0ePlCH6fBcOkm5xJ 2ADFc9i2KtcVu2P740mGhe/XGTV6O3IAKVH3LODupbyNsXL835Vbjo1bcUD+eErE4V p8KnOjwTZdcjrZrgbuV7BZvxKs+1czEcHwsvsQMzFtE1KjNhsAwZy8HsejS4TfeX/N 1CXNNHV3YMy3A== 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 , linux-alpha@vger.kernel.org Subject: [PATCH 14/17] tty: srmcons: use 'count' directly in srmcons_do_write() Date: Tue, 21 Nov 2023 10:22:55 +0100 Message-ID: <20231121092258.9334-15-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Similarly to 'buf' in the previous patch, there is no need to have a separate counter ('remaining') in srmcons_do_write(). 'count' can be used directly which simplifies the code a bit. Note that the type of the current count ('c') is changed from 'long' to 'size_t' so that: 1) it is prepared for the upcoming change of 'count's type, and 2) is unsigned. Signed-off-by: Jiri Slaby (SUSE) Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: linux-alpha@vger.kernel.org Reviewed-by: Richard Henderson --- arch/alpha/kernel/srmcons.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c index b68c5af083cd..8025e2a882ed 100644 --- a/arch/alpha/kernel/srmcons.c +++ b/arch/alpha/kernel/srmcons.c @@ -92,24 +92,24 @@ static int srmcons_do_write(struct tty_port *port, const char *buf, int count) { static char str_cr[1] =3D "\r"; - long c, remaining =3D count; + size_t c; srmcons_result result; int need_cr; =20 - while (remaining > 0) { + while (count > 0) { need_cr =3D 0; /*=20 * Break it up into reasonable size chunks to allow a chance * for input to get in */ - for (c =3D 0; c < min_t(long, 128L, remaining) && !need_cr; c++) + for (c =3D 0; c < min_t(size_t, 128U, count) && !need_cr; c++) if (buf[c] =3D=3D '\n') need_cr =3D 1; =09 while (c > 0) { result.as_long =3D callback_puts(0, buf, c); c -=3D result.bits.c; - remaining -=3D result.bits.c; + count -=3D result.bits.c; buf +=3D result.bits.c; =20 /* --=20 2.42.1 From nobody Thu Dec 18 23:36:31 2025 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 DA94BC54FB9 for ; Tue, 21 Nov 2023 09:24:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233724AbjKUJYW (ORCPT ); Tue, 21 Nov 2023 04:24:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233723AbjKUJXw (ORCPT ); Tue, 21 Nov 2023 04:23:52 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E8FD1718 for ; Tue, 21 Nov 2023 01:23:32 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09AA5C433B6; Tue, 21 Nov 2023 09:23:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558611; bh=PA6BiikxG3uzO12jc1Xme6+JXf2R8R2PKRHIkH33CJw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lkgd3ALh6dk93dgNjaqw6JHJlFb0jSZb+q4FfSbAPgUgud1HxYBjbcmgKV/CDcpmt cjQzjlXKtWivtcuTnsTYYGZhAZnAXKN7KnexLfCnAIj5KOBH3l6jrSPilvG5OPG7xB g1AaPKRNUhn+kTxDy46JntHNCk/Uy90l+aiDPOKLD66fnPqVmKjxpKr3sJ9wpNru/8 P23MaZYg0z+UKBvB9ZRn/CAfdgYvjyhvjJgh/kr1rfyxUicCV92g6ulSC2MeT3cnnu /DEUeBCvb8rdnqdLMoTlnSXDJXWjiL8AqvxhsVaEA2zX512fmMyURtmqCt9KgKT1bS AJaC7XUVnWTKQ== 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 , linux-alpha@vger.kernel.org Subject: [PATCH 15/17] tty: srmcons: make srmcons_do_write() return void Date: Tue, 21 Nov 2023 10:22:56 +0100 Message-ID: <20231121092258.9334-16-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The return value of srmcons_do_write() is ignored as all characters are pushed. So make srmcons_do_write() to return void. Signed-off-by: Jiri Slaby (SUSE) Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: linux-alpha@vger.kernel.org Reviewed-by: Richard Henderson --- arch/alpha/kernel/srmcons.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c index 8025e2a882ed..32bc098de7da 100644 --- a/arch/alpha/kernel/srmcons.c +++ b/arch/alpha/kernel/srmcons.c @@ -88,7 +88,7 @@ srmcons_receive_chars(struct timer_list *t) } =20 /* called with callback_lock held */ -static int +static void srmcons_do_write(struct tty_port *port, const char *buf, int count) { static char str_cr[1] =3D "\r"; @@ -125,7 +125,6 @@ srmcons_do_write(struct tty_port *port, const char *buf= , int count) need_cr =3D 0; } } - return count; } =20 static ssize_t --=20 2.42.1 From nobody Thu Dec 18 23:36:31 2025 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 E43BAC54FB9 for ; Tue, 21 Nov 2023 09:24:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233201AbjKUJY1 (ORCPT ); Tue, 21 Nov 2023 04:24:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232964AbjKUJXx (ORCPT ); Tue, 21 Nov 2023 04:23:53 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67EE11723 for ; Tue, 21 Nov 2023 01:23:34 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4831DC433AD; Tue, 21 Nov 2023 09:23:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558614; bh=jNbLNG352qLl5DsDvu9XIk5DhjEuWNeT8bITasbQfSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PTApM2Yz3k5LHdAR4SR/rf/9Gl3mNc2Hvoyj2G8mZC5bTs6jO4B3AkehK6TERw/jE dDjyGKGTipA9BQhnJhEIGUb0+kIsTZIqdO4/YRRp7wqpBIBDT5nWmRyR06iLZtUSKj PDOnO6UOlVtXDmLVy3viFS3QM/97XIKizEL4wNWTLXpSBHU210Fpd8OAWEevVUsKLa xNthtXLGxffbib6PvfmVJ7prxCG1fHdQum+Nr6EtOd8/OGKIQK7sNrbXQFbHPG8xMx jwpECnt8xBCUm7KzirZOLUZKz9cVMN3Nr74msXOp1g5ULl3Ld8u5Vwn+QpaT1wLqc6 OHWaHpuGEE9Xg== 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 , linux-alpha@vger.kernel.org Subject: [PATCH 16/17] tty: srmcons: switch need_cr to bool Date: Tue, 21 Nov 2023 10:22:57 +0100 Message-ID: <20231121092258.9334-17-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 'need_cr' is a flag, so type it properly to be a 'bool'. Move the declaration into the loop too. That ensures the variable is initialized properly even if the code was moved somehow. Signed-off-by: Jiri Slaby (SUSE) Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: linux-alpha@vger.kernel.org Reviewed-by: Richard Henderson --- arch/alpha/kernel/srmcons.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c index 32bc098de7da..c6b821afbfd3 100644 --- a/arch/alpha/kernel/srmcons.c +++ b/arch/alpha/kernel/srmcons.c @@ -94,17 +94,16 @@ srmcons_do_write(struct tty_port *port, const char *buf= , int count) static char str_cr[1] =3D "\r"; size_t c; srmcons_result result; - int need_cr; =20 while (count > 0) { - need_cr =3D 0; + bool need_cr =3D false; /*=20 * Break it up into reasonable size chunks to allow a chance * for input to get in */ for (c =3D 0; c < min_t(size_t, 128U, count) && !need_cr; c++) if (buf[c] =3D=3D '\n') - need_cr =3D 1; + need_cr =3D true; =09 while (c > 0) { result.as_long =3D callback_puts(0, buf, c); @@ -122,7 +121,7 @@ srmcons_do_write(struct tty_port *port, const char *buf= , int count) while (need_cr) { result.as_long =3D callback_puts(0, str_cr, 1); if (result.bits.c > 0) - need_cr =3D 0; + need_cr =3D false; } } } --=20 2.42.1 From nobody Thu Dec 18 23:36:31 2025 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 4D241C54FB9 for ; Tue, 21 Nov 2023 09:24:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233655AbjKUJYd (ORCPT ); Tue, 21 Nov 2023 04:24:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233647AbjKUJYK (ORCPT ); Tue, 21 Nov 2023 04:24:10 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2944198C for ; Tue, 21 Nov 2023 01:23:37 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84493C43391; Tue, 21 Nov 2023 09:23:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558616; bh=1JqdGOcikIPraOhThJZ+ThwFEn9EMyadPHMefXFawKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GUk3Q4MvpshxkULe4lihbL6fp+6TMQE2/jtMr44SuJZ4LsOSpjitlpSNDxWxryXBy S4leJUUt9h8blyDWxlpADZz2Wa0wuUJ9jQgyrSGrVywVDWmEVOnkpshjg6JGNkjJHm mpS9NIvi0zMTNdFEKoE3pwQDZB0ALDHfKHvkCn+GfJMRcZL5KJCchRW4i/yQxfNU06 Y2E2OixT655d+J+FJ2V6EPCdHDqgbA0kE+Uz375JLkTXB1C8nlvuvqpsWdYfrV+NWM fGnS0Mar/blbmEdtbwmgaSi5clQ4DxA6E4GEV/V4WvTOKnfbYsgw4N+U9nY89rJ6Wc euopvwHEcIOJg== 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 , linux-alpha@vger.kernel.org Subject: [PATCH 17/17] tty: srmcons: make 'str_cr' const and non-array Date: Tue, 21 Nov 2023 10:22:58 +0100 Message-ID: <20231121092258.9334-18-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 'str_cr' contains a single character: \n. There is no need to declare it as array. Declare it as a variable, make it const and pass a pointer to it to callback_puts(). Signed-off-by: Jiri Slaby (SUSE) Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: linux-alpha@vger.kernel.org Reviewed-by: Ilpo J=C3=A4rvinen --- arch/alpha/kernel/srmcons.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c index c6b821afbfd3..a6cff61706b5 100644 --- a/arch/alpha/kernel/srmcons.c +++ b/arch/alpha/kernel/srmcons.c @@ -91,7 +91,7 @@ srmcons_receive_chars(struct timer_list *t) static void srmcons_do_write(struct tty_port *port, const char *buf, int count) { - static char str_cr[1] =3D "\r"; + static const char str_cr =3D '\r'; size_t c; srmcons_result result; =20 @@ -119,7 +119,7 @@ srmcons_do_write(struct tty_port *port, const char *buf= , int count) } =20 while (need_cr) { - result.as_long =3D callback_puts(0, str_cr, 1); + result.as_long =3D callback_puts(0, &str_cr, 1); if (result.bits.c > 0) need_cr =3D false; } --=20 2.42.1