From patchwork Thu Feb 20 11:15:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867072 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FFCB1F2BA4; Thu, 20 Feb 2025 11:16:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050175; cv=none; b=q/AUrOGlPdzBIYOjMzLi8pZioz1hY+aIleGjOKAsKHxVl0WDGnqRLPpotLolx8r4Qdf25XwrJHUvZ7/a7UU8ziVRSlkobRlwEPmQEyLPfR/CaTeX++Byjbafj/zC19gREDzlFQG99uswwfZngKYRYImzbD7MaSpbzoCUmSdQxP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050175; c=relaxed/simple; bh=UGUcZhh2uN5m2e5STrQhOWzZBbObdTYU/HLYBpoIjf0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hs+QKrifHMRJbEPXy8w28z4z9GxMypjFLmXfL1tMPCqsJC4rVdyuS0EVcoJlrVYUT/z4/0L/xKp7/nKSKo6mpdRRZu63rBMFDGNo64tchVIEodWEQIzAFN2Tog0EHqyXNXuEz5teN5HCRSVWnqvy5iD5Mgqgt0VvRrYO5NchgQk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CkxsvloC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CkxsvloC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84209C4CEDD; Thu, 20 Feb 2025 11:16:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050174; bh=UGUcZhh2uN5m2e5STrQhOWzZBbObdTYU/HLYBpoIjf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CkxsvloCLVEYCIdzMrcDLCc0pZu8PABLUaTOu6+J5rpGkZvViFEcvQKpj7FadD8If A9dV1ZYQkNT34jjCS4uqeDZM7LKAurWwkoHD5TM3CqoKPkdtpuzrquDz1DlbmsBx8w 735cFSqL1hlgWOzTI2e4bpNY5X1gve8YlCkOGfw3j+TFOLa94bQJBU4wUeVcyEIvOO htgU85v6t7aoeaL8Vhf9Q9af3lIVnB8ieTdfF09TL8rdoGeFEdlUgEIOlE4qR7WyOA qm2hfkcN/g1+thcefn2sWIZbQoK3vjddXfRsOd18Ect9qxA4Od28jV9YidfmdIVCRW iWLxTDogCp1wg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 01/29] tty: convert "TTY Struct Flags" to an enum Date: Thu, 20 Feb 2025 12:15:38 +0100 Message-ID: <20250220111606.138045-2-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert TTY_* macros (flags) to an enum. This allows for easier kernel-doc (the comment needed fine tuning), grouping of these nicely, and proper checking. Note that these are bit positions. So they are used such as test_bit(TTY_THROTTLED, ...). Given these are not the user API (only in-kernel API/ABI), the bit positions are NOT preserved in this patch. All are renumbered naturally using the enum-auto-numbering. Signed-off-by: Jiri Slaby (SUSE) --- Documentation/driver-api/tty/tty_struct.rst | 2 +- include/linux/tty.h | 52 +++++++++++---------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Documentation/driver-api/tty/tty_struct.rst b/Documentation/driver-api/tty/tty_struct.rst index c72f5a4293b2..29caf1c1ca5f 100644 --- a/Documentation/driver-api/tty/tty_struct.rst +++ b/Documentation/driver-api/tty/tty_struct.rst @@ -72,7 +72,7 @@ TTY Struct Flags ================ .. kernel-doc:: include/linux/tty.h - :doc: TTY Struct Flags + :identifiers: tty_struct_flags TTY Struct Reference ==================== diff --git a/include/linux/tty.h b/include/linux/tty.h index 2372f9357240..6bb4fb3845f0 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -251,7 +251,7 @@ struct tty_file_private { }; /** - * DOC: TTY Struct Flags + * enum tty_struct_flags - TTY Struct Flags * * These bits are used in the :c:member:`tty_struct.flags` field. * @@ -260,62 +260,64 @@ struct tty_file_private { * tty->write. Thus, you must use the inline functions set_bit() and * clear_bit() to make things atomic. * - * TTY_THROTTLED + * @TTY_THROTTLED: * Driver input is throttled. The ldisc should call * :c:member:`tty_driver.unthrottle()` in order to resume reception when * it is ready to process more data (at threshold min). * - * TTY_IO_ERROR + * @TTY_IO_ERROR: * If set, causes all subsequent userspace read/write calls on the tty to * fail, returning -%EIO. (May be no ldisc too.) * - * TTY_OTHER_CLOSED + * @TTY_OTHER_CLOSED: * Device is a pty and the other side has closed. * - * TTY_EXCLUSIVE + * @TTY_EXCLUSIVE: * Exclusive open mode (a single opener). * - * TTY_DO_WRITE_WAKEUP + * @TTY_DO_WRITE_WAKEUP: * If set, causes the driver to call the * :c:member:`tty_ldisc_ops.write_wakeup()` method in order to resume * transmission when it can accept more data to transmit. * - * TTY_LDISC_OPEN + * @TTY_LDISC_OPEN: * Indicates that a line discipline is open. For debugging purposes only. * - * TTY_PTY_LOCK + * @TTY_PTY_LOCK: * A flag private to pty code to implement %TIOCSPTLCK/%TIOCGPTLCK logic. * - * TTY_NO_WRITE_SPLIT + * @TTY_NO_WRITE_SPLIT: * Prevent driver from splitting up writes into smaller chunks (preserve * write boundaries to driver). * - * TTY_HUPPED + * @TTY_HUPPED: * The TTY was hung up. This is set post :c:member:`tty_driver.hangup()`. * - * TTY_HUPPING + * @TTY_HUPPING: * The TTY is in the process of hanging up to abort potential readers. * - * TTY_LDISC_CHANGING + * @TTY_LDISC_CHANGING: * Line discipline for this TTY is being changed. I/O should not block * when this is set. Use tty_io_nonblock() to check. * - * TTY_LDISC_HALTED + * @TTY_LDISC_HALTED: * Line discipline for this TTY was stopped. No work should be queued to * this ldisc. */ -#define TTY_THROTTLED 0 -#define TTY_IO_ERROR 1 -#define TTY_OTHER_CLOSED 2 -#define TTY_EXCLUSIVE 3 -#define TTY_DO_WRITE_WAKEUP 5 -#define TTY_LDISC_OPEN 11 -#define TTY_PTY_LOCK 16 -#define TTY_NO_WRITE_SPLIT 17 -#define TTY_HUPPED 18 -#define TTY_HUPPING 19 -#define TTY_LDISC_CHANGING 20 -#define TTY_LDISC_HALTED 22 +enum tty_struct_flags { + TTY_THROTTLED, + TTY_IO_ERROR, + TTY_OTHER_CLOSED, + TTY_EXCLUSIVE, + TTY_DO_WRITE_WAKEUP, + TTY_LDISC_OPEN, + TTY_PTY_LOCK, + TTY_NO_WRITE_SPLIT, + TTY_HUPPED, + TTY_HUPPING, + TTY_LDISC_CHANGING, + TTY_LDISC_HALTED, +}; static inline bool tty_io_nonblock(struct tty_struct *tty, struct file *file) { From patchwork Thu Feb 20 11:15:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867877 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB9901F4265; Thu, 20 Feb 2025 11:16:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050176; cv=none; b=MFCOvOaBi/sYaMGh2KkKrOeH2SMFJ4Oaa0jBD2wybLkFbEPk061B32wyQE84E0ODwq9HFdONt/aRnN8YHuFqWUxfGfezmWlqFew+B+M57HA2PW233sMURGp4jc4D3aipxIc8b6J3MJbhnGGu4h37xacQhEBlB23XQYt5QIjK1mI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050176; c=relaxed/simple; bh=O19YTMIm9L4XBACdObvLfyV9RoqxzulC5kKd2UrlfCo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dt/uUxpvZQncw0pJ5D9SQcTFzucoVkHubcxvVEd/iyWjgUdq0G8qJf/xMCALSnOshUnF+6q8drU8A0etwsLBjM8cEumagomlL5jPk+PHZlf7Fpso+iJgYRbGHUNjZCjFpBf5gH832/3a2mGFU6EJLWHd7pnO8l6CBwQFpSw4E9I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pP+I+EtN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pP+I+EtN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F2CFC4CEE4; Thu, 20 Feb 2025 11:16:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050176; bh=O19YTMIm9L4XBACdObvLfyV9RoqxzulC5kKd2UrlfCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pP+I+EtN56CYByyi2xlyXsXtrPWqCKSlJBrDPx2Jk2yux2mfEKYSto0eNSicz5a+E QGiAKx9JnkJDJjjTIzGCdmoizlnU45W1f1+AN5qOQ5y1WBPRpDeiKXQSYGXlOIlfFr anTRet/b8AG4Lv4/JcUsFnk8Ks0WzgLcJI5tea2yFHNT6aMCI9PR5vJnBTYaLDgTz+ 927tkxxgjuzbKuse4Rf8D32nC3HgBbw98mCiNsaAvRvVL1VDYw4oD3Ho6CHMHAV7l3 r77r4qCYnrq53oH31dLXXQjDfM0zajGGqlWs91jTL4ttRrMvuhvvxbTyp5bkOqYbrb hU+mRqxcrPLIA== 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/29] tty: audit: do not use N_TTY_BUF_SIZE Date: Thu, 20 Feb 2025 12:15:39 +0100 Message-ID: <20250220111606.138045-3-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 N_TTY_BUF_SIZE -- as the name suggests -- is the N_TTY's buffer size. There is no reason to couple that to audit's buffer size, so define an own TTY_AUDIT_BUF_SIZE macro (with the same size). N_TTY_BUF_SIZE is private and will be moved to n_tty.c later. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/tty_audit.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c index 1d81eeefb068..75542333c54a 100644 --- a/drivers/tty/tty_audit.c +++ b/drivers/tty/tty_audit.c @@ -12,12 +12,14 @@ #include #include "tty.h" +#define TTY_AUDIT_BUF_SIZE 4096 + struct tty_audit_buf { struct mutex mutex; /* Protects all data below */ dev_t dev; /* The TTY which the data is from */ bool icanon; size_t valid; - u8 *data; /* Allocated size N_TTY_BUF_SIZE */ + u8 *data; /* Allocated size TTY_AUDIT_BUF_SIZE */ }; static struct tty_audit_buf *tty_audit_buf_ref(void) @@ -37,7 +39,7 @@ static struct tty_audit_buf *tty_audit_buf_alloc(void) if (!buf) goto err; - buf->data = kmalloc(N_TTY_BUF_SIZE, GFP_KERNEL); + buf->data = kmalloc(TTY_AUDIT_BUF_SIZE, GFP_KERNEL); if (!buf->data) goto err_buf; @@ -235,14 +237,14 @@ void tty_audit_add_data(const struct tty_struct *tty, const void *data, do { size_t run; - run = N_TTY_BUF_SIZE - buf->valid; + run = TTY_AUDIT_BUF_SIZE - buf->valid; if (run > size) run = size; memcpy(buf->data + buf->valid, data, run); buf->valid += run; data += run; size -= run; - if (buf->valid == N_TTY_BUF_SIZE) + if (buf->valid == TTY_AUDIT_BUF_SIZE) tty_audit_buf_push(buf); } while (size != 0); mutex_unlock(&buf->mutex); From patchwork Thu Feb 20 11:15:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867071 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BB3B1F4703; Thu, 20 Feb 2025 11:16:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050179; cv=none; b=tYwmNvCTKuFp3Of3rUOifyUcRcC0prJDF52iQTEiNYyBjRg/xmgK33O45d+pUzlSiviYQHjgDlKRfZWpSKqaTYEdGAuyk8COKNM17b02RFUtxkW/jp9hjsbCGRhSG6mrR55bdkgrftc873H9J5gHeYj/Z/mNwCHNgl105KxACNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050179; c=relaxed/simple; bh=WbIbJP8V1uaYvMyiXLy9rg/qAp/4D3SlYH4GG3NpwO4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SkL9c3c9GfpSTNemyXHu6l8NMnD2pAumNe5tXa3drh8wAmbS5DJcs73QQUBZ/yyZtfbguiwcLQ0ZY1e3l2qTIVoPAQkqDEv8a5C2wHlawHfsrmJY0NdtmT4eZHABWhtUXmVC5V+2SobSF/Fp/b5rxWHu5ww4wlQWMlyDPvmSmvw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=q2yjMtzj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="q2yjMtzj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F49CC4CEE3; Thu, 20 Feb 2025 11:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050178; bh=WbIbJP8V1uaYvMyiXLy9rg/qAp/4D3SlYH4GG3NpwO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q2yjMtzjXSeVJC7h5fsIgqV1EUf5vIiYqndGU4VC/zqRISxdGNXUnyIBFqgSZlhbL dltiA0Iqs70r/w3SU7LnYOA+c/Z7ssyC71hBktYxAirrszteC+oIeW746Y+lDEyq/I oG4ZTigA0sl05+Q5oqNoi/DpWpGQkbwo+VDEN7lv61sGPVZbObYuB+4qLWdThggn+N uFamXbLqScpRtulGiCgFnak0PuWUpEuL+OtR+uHS7K/RmGAEDS7O4mJT+HdC0rwFn7 oNIthpYIt/di4XYOH+ZjgtB8vaKFpze2GB+A7zFsynxF9jWd92rrSNXypjs0Ht6J/A 8s1g/GIpnWU8A== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Subject: [PATCH 03/29] tty: caif: do not use N_TTY_BUF_SIZE Date: Thu, 20 Feb 2025 12:15:40 +0100 Message-ID: <20250220111606.138045-4-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 N_TTY_BUF_SIZE -- as the name suggests -- is the N_TTY's buffer size. There is no reason to couple that to caif's tty->receive_room. Use 4096 directly -- even though, it should be some sort of "SKB_MAX_ALLOC" or alike. But definitely not N_TTY_BUF_SIZE. N_TTY_BUF_SIZE is private and will be moved to n_tty.c later. Signed-off-by: Jiri Slaby (SUSE) Cc: Andrew Lunn Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: netdev@vger.kernel.org Acked-by: Jakub Kicinski --- drivers/net/caif/caif_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c index ed3a589def6b..e7d1b9301fde 100644 --- a/drivers/net/caif/caif_serial.c +++ b/drivers/net/caif/caif_serial.c @@ -344,7 +344,7 @@ static int ldisc_open(struct tty_struct *tty) ser->tty = tty_kref_get(tty); ser->dev = dev; debugfs_init(ser, tty); - tty->receive_room = N_TTY_BUF_SIZE; + tty->receive_room = 4096; tty->disc_data = ser; set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); rtnl_lock(); From patchwork Thu Feb 20 11:15:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867876 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6FDE1F4634; Thu, 20 Feb 2025 11:16:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050180; cv=none; b=BNuu257nxa3r0gAT6DNA6myTxt2ZJng4jxb9t8IT2pckRF+bFN9eDhQrf75MjLTYdw6SLxItx+VOQCD/uXQusHO0Yvc8XIp0ee16jttOOE1e0PhlOnJv0zPSFNdSp86k+LQGS5eu6HJVnqdgJottBGq4wQe1bgtnhIwE8CCmTgo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050180; c=relaxed/simple; bh=Btl4Wi7mK+kiPs2bUGrutftCJDQt5We7naJQDWbQjIg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ipSOBEPxH8Aw9MSw2XWcwYMEt1sZQ/V+43HtpUpA72ggWirYr16CU4SuPe6UgvreWdugnzyE2Ywa4YFcdrioUT4OQySBKiCaOmOMIyiwr1FoRqLizE0LvJxZ86A9oiWH9f/OG921gBSDdB+WfcKvlbcSm3FtSGSKK/QNforKKKY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=toRVaWyT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="toRVaWyT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35059C4CEE4; Thu, 20 Feb 2025 11:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050180; bh=Btl4Wi7mK+kiPs2bUGrutftCJDQt5We7naJQDWbQjIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=toRVaWyTR6X40q3FbwQq0DUyhVtsV1Wz3lz8RT9CmJcsmwGbfww4InppAWQfTVdW8 ToXu/Q55jo/0wUfQr48a63C/6ZAjVUtVAvfRKjBRB8r3/sf/+pVMOk7/bJBVa6XQG1 2Pz+4fdpdTtijIqIf0J2iIGelKqhvvWWW/sBt3wc13uRrH9lcQpJEEhDsFLinpEleq cyFsNH59WSV60LpdowW5N2oilopLsqCHGDqizRjwmeUXXVYtxoVNtJki4AfR/pF9Az fCe6FgkTYiSdoLnCp2D3YoB+zH8kHT7TNvUqBNLUKadAVMokInx+WNZ7HxSMO/CBhh mLmnAy6w/XGrA== 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/29] tty: move N_TTY_BUF_SIZE to n_tty Date: Thu, 20 Feb 2025 12:15:41 +0100 Message-ID: <20250220111606.138045-5-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 "N_TTY_BUF_SIZE" is private to n_tty and shall not be exposed to the world. Definitely not in tty.h somewhere in the middle of "struct tty_struct". This is a remnant of moving "read_flags" to "struct n_tty_data" in commit 3fe780b379fa ("TTY: move ldisc data from tty_struct: bitmaps"). But some cleanup was needed first (in previous patches). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/n_tty.c | 2 ++ include/linux/tty.h | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 5e9ca4376d68..2c5995019dd1 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -56,6 +56,8 @@ */ #define WAKEUP_CHARS 256 +#define N_TTY_BUF_SIZE 4096 + /* * This defines the low- and high-watermarks for throttling and * unthrottling the TTY driver. These watermarks are used for diff --git a/include/linux/tty.h b/include/linux/tty.h index 6bb4fb3845f0..0a46e4054dec 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -239,7 +239,6 @@ struct tty_struct { struct list_head tty_files; -#define N_TTY_BUF_SIZE 4096 struct work_struct SAK_work; } __randomize_layout; From patchwork Thu Feb 20 11:15:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867070 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E45401F76C0; Thu, 20 Feb 2025 11:16:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050182; cv=none; b=cFt2osVaDlJ5t/9kQUA4BYXxl6kWc0J+CrHlKO5MKk0HhAuEsVQRrZ/IuRhFSwhDZqZfrupw7CRf6j9gCbNz4SDkMsRaHuPsGhLwQEuPo2ZziqAZ2IWaQUWsEuMMh0oTaf4TG4xSYJsF7/S2T9oCEM6CFazcZuMW1nNt5Ye9RU8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050182; c=relaxed/simple; bh=g/xpmM3Fe7B6ZiGr/t3gDZeq/cT5LL/Gr4ylSKdLgr8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F3+aqsDTp6Ma36KlQWu3xpyXO9oGUNnlyLrCbL66WGMxyBGZDpF988XvB7BZNHs1Qbt4O1SmXRlNj4LxN8U2kvncOPTEDs1f3FEw1Qh349IVDUgL+a4KDa18z5NAkFqbYPkN6aNQm1pYNrkhlQ0kHQ2CdiNZpYUjxQvEUJRbeMc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KT/otRUl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KT/otRUl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4F23C4CED1; Thu, 20 Feb 2025 11:16:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050181; bh=g/xpmM3Fe7B6ZiGr/t3gDZeq/cT5LL/Gr4ylSKdLgr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KT/otRUl/OfpRsrrQHV4MVEVEi0K/zCSmd8s+ENW+ma6hkc3OELGlNlfEBsXYd6f/ 6XRaADo29YtodxbyewD23+55qxTQByf5+CkCz7H52wixB+TEhcsubhp9b8MtcnFfdj v+wEZ8IQcJn6+YmpD+1kNOzEZ0PALTvrH0Lh1BQnx6s8FCVVq3lgMC2cOnwGJ9BbKg 2RtBcvfEuE40wV2egx6okO9f4EuPWKeT/k1P3YjOdsyrzthH/jDC5UpbAblikckghe atVJiGKHYO5TAGQ9UY2OQaukG5ccxxHaOJg/tcklxZKEtjUIoyVIifpLQOeA2nMeDs AzyrJJruqeJWw== 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/29] tty: n_tty: use uint for space returned by tty_write_room() Date: Thu, 20 Feb 2025 12:15:42 +0100 Message-ID: <20250220111606.138045-6-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 tty_write_room() returns an "unsigned int". So in case some insane driver (like my tty test driver) returns (legitimate) UINT_MAX from its tty_operations::write_room(), n_tty is confused on several places. For example, in process_output_block(), the result of tty_write_room() is stored into (signed) "int". So this UINT_MAX suddenly becomes -1. And that is extended to ssize_t and returned from process_output_block(). This causes a write() to such a node to receive -EPERM (which is -1). Fix that by using proper "unsigned int" and proper "== 0" test. And return 0 constant directly in that "if", so that it is immediately clear what is returned ("space" equals to 0 at that point). Similarly for process_output() and __process_echoes(). Note this does not fix any in-tree driver as of now. If you want "Fixes: something", it would be commit 03b3b1a2405c ("tty: make tty_operations::write_room return uint"). I intentionally do not mark this patch by a real tag below. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/n_tty.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 2c5995019dd1..765d24268d75 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -488,7 +488,8 @@ static int do_output_char(u8 c, struct tty_struct *tty, int space) static int process_output(u8 c, struct tty_struct *tty) { struct n_tty_data *ldata = tty->disc_data; - int space, retval; + unsigned int space; + int retval; mutex_lock(&ldata->output_lock); @@ -524,16 +525,16 @@ static ssize_t process_output_block(struct tty_struct *tty, const u8 *buf, unsigned int nr) { struct n_tty_data *ldata = tty->disc_data; - int space; - int i; + unsigned int space; + int i; const u8 *cp; mutex_lock(&ldata->output_lock); space = tty_write_room(tty); - if (space <= 0) { + if (space == 0) { mutex_unlock(&ldata->output_lock); - return space; + return 0; } if (nr > space) nr = space; @@ -698,7 +699,7 @@ static int n_tty_process_echo_ops(struct tty_struct *tty, size_t *tail, static size_t __process_echoes(struct tty_struct *tty) { struct n_tty_data *ldata = tty->disc_data; - int space, old_space; + unsigned int space, old_space; size_t tail; u8 c; From patchwork Thu Feb 20 11:15:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867875 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7C0B1F8BAA; Thu, 20 Feb 2025 11:16:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050183; cv=none; b=kwi0/vISsMikIiCLJRyrTGnMWVkZeTVlwR3Y3AR/eK9hSS6KEWAyNSSsunijK3r1ETU7HKKGy1TbzmTrqeFPjSYO/m0Q/5XxiHePaD+1xccMY9auUB7+dqlNr81hren2dA++/awOJEt7PiFlrmIpMpW/Zz1QvVXfROBcKeixlu0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050183; c=relaxed/simple; bh=K2Db/pHk+bKaTjC1amufXYjBJpM1A4xCeqqAxJM/LNc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mxDnOONGpZVEtvD62/E5X+3RXvSq/f66TDekG2t8CuQ2bfN5aLULNq5akDz7FYNGxtRVnkR2ertTjyWDP1ReKyTLEjVYgNXH2uQ8Ohq5LXRW+tEFP7A5C45JzP9ze+m6YEExnJ5dqpNuhjscqVYhMjb4/m9CDFXlUcHDyqZ0W6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GlO8jT00; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GlO8jT00" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40D4AC4CED1; Thu, 20 Feb 2025 11:16:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050183; bh=K2Db/pHk+bKaTjC1amufXYjBJpM1A4xCeqqAxJM/LNc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GlO8jT00QstZA9Tna3hHRLgI+k2GsSSdOJjZAbzTU5Ap34skNZck9ORfB2c3JLFp8 0ezNEWRxaqbbxUyrb6FNimU+zZJTxoqc7qGzUh48VhV3YAwoK0Pvw9LsTMIow9ceJh E8keHIVV6sK3C17W9/PQWsnyE7rkIshfupiEByOQV76MyP/0sbm4VymY28THrq2Zu0 CkOic8nhyWEHGM1zHuVV85cW96vrSju1E7epO8D3wjFdFXO3JbO835SITzbHrOyS8z QesscyCDCxTfRKF0a5KV5/PoOV9WAHF2x1rNdt0t8pKBp/wvErYI2wHKODGotEqsOh /sw5fs3cZYHpQ== 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/29] tty: n_tty: simplify process_output() Date: Thu, 20 Feb 2025 12:15:43 +0100 Message-ID: <20250220111606.138045-7-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Using guard(mutex), the function can be written in a much more efficient way. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/n_tty.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 765d24268d75..df52aae5f71a 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -488,19 +488,13 @@ static int do_output_char(u8 c, struct tty_struct *tty, int space) static int process_output(u8 c, struct tty_struct *tty) { struct n_tty_data *ldata = tty->disc_data; - unsigned int space; - int retval; - mutex_lock(&ldata->output_lock); + guard(mutex)(&ldata->output_lock); - space = tty_write_room(tty); - retval = do_output_char(c, tty, space); - - mutex_unlock(&ldata->output_lock); - if (retval < 0) + if (do_output_char(c, tty, tty_write_room(tty)) < 0) return -1; - else - return 0; + + return 0; } /** From patchwork Thu Feb 20 11:15:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867069 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1957E1F9406; Thu, 20 Feb 2025 11:16:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050185; cv=none; b=WIBR5pEDH7aPQpreX72e1d6g6etrEIrxxTSHlB5p3KpOR4USq51BRhxlzbeownsKZAboYcXsvPiJoPbtv5veTOaLTwzuhDDLpu127heRsIaRqH45pLFjlSTOvpJT7LMp7saXL2Wk1t2vvascT524Wjc82NZ1i1VK2izTsvQxqoE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050185; c=relaxed/simple; bh=9R/axZV7gpmcyf96eMWRUh493VM9wPytpd/Af5AfIDg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b0RuWsxiICLvced/28jyLfsgIOkthENVCAPcJ693PzyG3zACU+w94+7fT0MPMQhjpNzRaA2Z3DvfBpWsHbyjYGwfKpjsj/2B8VOTlRTJ6bTpp291OpP0kWj+wlLgrffNGFRWQOEvVGNT0FK3Y62CHNf2MUipsaW5viWfutmlg2w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fluI+Scy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fluI+Scy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3EE0C4CEDD; Thu, 20 Feb 2025 11:16:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050184; bh=9R/axZV7gpmcyf96eMWRUh493VM9wPytpd/Af5AfIDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fluI+ScyyM2JROMH6Flyi2SllHZ4MQOJq/Ra0mHGuohHf0ISCUCwybxUkvWtbXVgB JF/+I/L40BPcTx0bVMM0qTCCD292f3vd84YyvoJEBQyMNbwcw4t4xqKz600EeDEC/4 DyqePSDnP2jMkgjexb3l9p/dwCn2aZei8LHp6vQDQo166r9fw19+3PTu6nm4a3ujuq dTXlTfVx8o1ByJ2ZwhLPtuFUTZ8zqr93XJnD2SZEE/RHF9rrRhGq5BR4HFn5aG2e0C B6x8akhXbklqGL5nXObEAIVzDimhMfot+uzBPOqpI7/NX5yoW7lKay2f5VZRA69aKA /4U7jOvhempFw== 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/29] tty: n_tty: clean up process_output_block() Date: Thu, 20 Feb 2025 12:15:44 +0100 Message-ID: <20250220111606.138045-8-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 * Use guard(mutex), which results in: - the function can return directly when "space == 0". - "i" can now be "unsigned" as it is no longer abused to hold a retval from tty->ops->write(). Note the compared-to "nr" is already "unsigned". * The end label is now dubbed "do_write" as that is what happens there. Unlike the uncertain "break_out" name. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/n_tty.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index df52aae5f71a..5d172edbb03c 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -519,17 +519,15 @@ static ssize_t process_output_block(struct tty_struct *tty, const u8 *buf, unsigned int nr) { struct n_tty_data *ldata = tty->disc_data; - unsigned int space; - int i; + unsigned int space, i; const u8 *cp; - mutex_lock(&ldata->output_lock); + guard(mutex)(&ldata->output_lock); space = tty_write_room(tty); - if (space == 0) { - mutex_unlock(&ldata->output_lock); + if (space == 0) return 0; - } + if (nr > space) nr = space; @@ -541,18 +539,18 @@ static ssize_t process_output_block(struct tty_struct *tty, if (O_ONLRET(tty)) ldata->column = 0; if (O_ONLCR(tty)) - goto break_out; + goto do_write; ldata->canon_column = ldata->column; break; case '\r': if (O_ONOCR(tty) && ldata->column == 0) - goto break_out; + goto do_write; if (O_OCRNL(tty)) - goto break_out; + goto do_write; ldata->canon_column = ldata->column = 0; break; case '\t': - goto break_out; + goto do_write; case '\b': if (ldata->column > 0) ldata->column--; @@ -560,18 +558,15 @@ static ssize_t process_output_block(struct tty_struct *tty, default: if (!iscntrl(c)) { if (O_OLCUC(tty)) - goto break_out; + goto do_write; if (!is_continuation(c, tty)) ldata->column++; } break; } } -break_out: - i = tty->ops->write(tty, buf, i); - - mutex_unlock(&ldata->output_lock); - return i; +do_write: + return tty->ops->write(tty, buf, i); } static int n_tty_process_echo_ops(struct tty_struct *tty, size_t *tail, From patchwork Thu Feb 20 11:15:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867874 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E64FC1FA272; Thu, 20 Feb 2025 11:16:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050187; cv=none; b=A3Py4MikxNi8U62wG28Wt21+9Mbr1/bmoBgJfZShCPAmuhD2/Fke9Fv+c/xd5PqupkYXsTlOXqnhJEh3YZ9COaqSR9+a1VGotQJt805RdCZo4Y357OE42FVOVRViufFnuZKh18wxogUo/PnJwMYA+VkrOQ1xP4V5NKA1Zfcr4Ms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050187; c=relaxed/simple; bh=AR0ChXBcbm1rSLBLYpCqwfLIevhh7gPejHqqQr6M9Tw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mdrgMEoKQdjcDcaxVkcJu6ghvk7KiSyTtAzZOOGNZIs80tiqYZqHk9Krk/nyH98U2JKfRvGh/pBA57N6eIV7K/cY0XEOCKvgMkYfXtY6z3LZVwxwAHMHXyp1HszQNtKm+lJvCRjmumtFSQEAUR8u2aiEzgbY6pM3UITI8qqiBH8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lAadFfb7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lAadFfb7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F778C4CEDD; Thu, 20 Feb 2025 11:16:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050186; bh=AR0ChXBcbm1rSLBLYpCqwfLIevhh7gPejHqqQr6M9Tw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lAadFfb7i+4FbrIClURZQiXrHSeAx6cAQKuXpmfs1X+YsPFIgSH6s+sWsdhh84ntg 5+8f8HmeTwIKnQ9V7vylNmsKRugbO9bxw1SpBUvI1rSXQ7FU0k+aY7WP78dZbmRfnt OIRH+8A/VFL1NUg2z9tjveS6zj6/CXcNPKm7maZcAcbl5kVd8h2zl8n45aRzhnnTKF I/0fJhEqThJuAnzkNQyFLh+TLa+Ger/iuiTdMVCD6XJ+1ZYEVhHdNzPKnotBvvuncR 0JjFz7g4rtzhfKwm+DcFjCGORtEHv4vd8geROXm3kh7PPWFCx3J2G7YNPVOmKqEv43 erbbCWU8sRpiw== 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/29] tty: n_tty: drop n_tty_trace() Date: Thu, 20 Feb 2025 12:15:45 +0100 Message-ID: <20250220111606.138045-9-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This n_tty_trace() is an always disabled debugging macro. It comes from commit 32f13521ca68 ("n_tty: Line copy to user buffer in canonical mode"). Drop it as it is dead for over a decade. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/n_tty.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 5d172edbb03c..43ba740792d9 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -81,14 +81,6 @@ #define ECHO_BLOCK 256 #define ECHO_DISCARD_WATERMARK N_TTY_BUF_SIZE - (ECHO_BLOCK + 32) - -#undef N_TTY_TRACE -#ifdef N_TTY_TRACE -# define n_tty_trace(f, args...) trace_printk(f, ##args) -#else -# define n_tty_trace(f, args...) no_printk(f, ##args) -#endif - struct n_tty_data { /* producer-published */ size_t read_head; @@ -2026,9 +2018,6 @@ static bool canon_copy_from_read_buf(const struct tty_struct *tty, u8 **kbp, tail = MASK(ldata->read_tail); size = min_t(size_t, tail + n, N_TTY_BUF_SIZE); - n_tty_trace("%s: nr:%zu tail:%zu n:%zu size:%zu\n", - __func__, *nr, tail, n, size); - eol = find_next_bit(ldata->read_flags, size, tail); more = n - (size - tail); if (eol == N_TTY_BUF_SIZE && more) { @@ -2046,9 +2035,6 @@ static bool canon_copy_from_read_buf(const struct tty_struct *tty, u8 **kbp, if (!found || read_buf(ldata, eol) != __DISABLED_CHAR) n = c; - n_tty_trace("%s: eol:%zu found:%d n:%zu c:%zu tail:%zu more:%zu\n", - __func__, eol, found, n, c, tail, more); - tty_copy(tty, *kbp, tail, n); *kbp += n; *nr -= n; From patchwork Thu Feb 20 11:15:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867068 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FFE21FAC4C; Thu, 20 Feb 2025 11:16:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050188; cv=none; b=N1UrA42KWO2mFMMlczVZgnckG0vSQRBvfqX8jkcnvJkg5+nGHQZ3H13b9V6bWqCQgbwBWjq3CiXo9ChvvQofARPAmFWrdu2gN7s1bCWXeI/EpUhNR7yo+w6NRe6ouJvDEG2kyS8J1cGLyaXDFe8UGevWxwP8a1Wcjx7X7O5CUOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050188; c=relaxed/simple; bh=qhyJ5nurd/KtDfxYFGukXboD8bJm+cxcpPMnMsiAeBs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JlTgaTp07BPL/zLTdRfqfurxZrXHnrnyobf/WoexmU1XRGEW8cbhjBbq1ZweAJWF5IAZsRXAzNVdbCTIQtx/J4fIdzT3pgCsQLGauJC1xMloltCTsKdeNX1C6qJdEdf3BIB7BL9GtXSE7hYJ35qFZiBMH3CzP8o0RmZwzDQoMas= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=q3L20lp/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="q3L20lp/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF68BC4CEE3; Thu, 20 Feb 2025 11:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050187; bh=qhyJ5nurd/KtDfxYFGukXboD8bJm+cxcpPMnMsiAeBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q3L20lp/DyVHCn3x9pgSw1hKsQqgbruu1gxEhQAU0SOUEvqGxA7hE8UFRgjZgSUyG td4V8ed9pn4UBpijGxO3aKNb5zpZxE5lqOVnTOJuBp73CtipZ7vVdM+SIbshhp+SZ6 qABzigljUvpjKt/MODuySnNdZWNym9ifNOWKheSbV42LfTLvI/bP65d0VMx9CgZkFl 5nZTkq/xO6TmwaQ6AtoVImlLY2Ees1vbMMVhpqipBcLsVY+b6A/oxCMEnmRG2q2WHc SUNG+5vv+1XrE2/i3/jJdESsaav4dYjLLE18iLCcut2cf7bG6anh+5wC8PiiaDOy00 KPimNJ+chGzfg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 09/29] tty: n_tty: extract n_tty_continue_cookie() from n_tty_read() Date: Thu, 20 Feb 2025 12:15:46 +0100 Message-ID: <20250220111606.138045-10-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 n_tty_read() is a very long function doing too much of different stuff. Extract the "cookie" (continuation read) handling to a separate function: n_tty_continue_cookie(). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/n_tty.c | 66 ++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 43ba740792d9..88aa5f9cbe5e 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -2111,6 +2111,39 @@ static int job_control(struct tty_struct *tty, struct file *file) return __tty_check_change(tty, SIGTTIN); } +/* + * We still hold the atomic_read_lock and the termios_rwsem, and can just + * continue to copy data. + */ +static ssize_t n_tty_continue_cookie(struct tty_struct *tty, u8 *kbuf, + size_t nr, void **cookie) +{ + struct n_tty_data *ldata = tty->disc_data; + u8 *kb = kbuf; + + if (ldata->icanon && !L_EXTPROC(tty)) { + /* + * If we have filled the user buffer, see if we should skip an + * EOF character before releasing the lock and returning done. + */ + if (!nr) + canon_skip_eof(ldata); + else if (canon_copy_from_read_buf(tty, &kb, &nr)) + return kb - kbuf; + } else { + if (copy_from_read_buf(tty, &kb, &nr)) + return kb - kbuf; + } + + /* No more data - release locks and stop retries */ + n_tty_kick_worker(tty); + n_tty_check_unthrottle(tty); + up_read(&tty->termios_rwsem); + mutex_unlock(&ldata->atomic_read_lock); + *cookie = NULL; + + return kb - kbuf; +} /** * n_tty_read - read function for tty @@ -2144,36 +2177,9 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, u8 *kbuf, bool packet; size_t old_tail; - /* - * Is this a continuation of a read started earler? - * - * If so, we still hold the atomic_read_lock and the - * termios_rwsem, and can just continue to copy data. - */ - if (*cookie) { - if (ldata->icanon && !L_EXTPROC(tty)) { - /* - * If we have filled the user buffer, see - * if we should skip an EOF character before - * releasing the lock and returning done. - */ - if (!nr) - canon_skip_eof(ldata); - else if (canon_copy_from_read_buf(tty, &kb, &nr)) - return kb - kbuf; - } else { - if (copy_from_read_buf(tty, &kb, &nr)) - return kb - kbuf; - } - - /* No more data - release locks and stop retries */ - n_tty_kick_worker(tty); - n_tty_check_unthrottle(tty); - up_read(&tty->termios_rwsem); - mutex_unlock(&ldata->atomic_read_lock); - *cookie = NULL; - return kb - kbuf; - } + /* Is this a continuation of a read started earlier? */ + if (*cookie) + return n_tty_continue_cookie(tty, kbuf, nr, cookie); retval = job_control(tty, file); if (retval < 0) From patchwork Thu Feb 20 11:15:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867873 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F33BB1FBE9E; Thu, 20 Feb 2025 11:16:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050190; cv=none; b=AXoIQB4UII3ADDobNGIdOwMs8oqP24QOxWfolT4+xrzMjeaBT0DQZpne0XlX+KchQfO+2B/j2BOWWP69swvzDL3P6AFKg6Kos8WVQBhmIXA83msr1mTuFsqblHQDhpnUzkRRmMFlCVlQpY/qhnxCAgh+COYbSc2iLAgpwkaFNHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050190; c=relaxed/simple; bh=/yZtA/QNRQ/5GBa14iNHXusxbG4H8sUecszu/ehL+T4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZJKGBs2YXLVFhz1KP+CxqMfn3N3AgqEHb/OIp5k4YI5lLNQOaC2GdrRlFftGT289EXTnequiv9pNBQHcxYbHUEwUtbYM9Tt2TjzJApbFX88O1YMCXZje7sSgZQALrFHyZXhNUzYCz/vgoMn2ZB+vJfhO5LPdVwB/VkfAOHZK3yI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GGukvWoi; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GGukvWoi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B6E3C4CEDD; Thu, 20 Feb 2025 11:16:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050189; bh=/yZtA/QNRQ/5GBa14iNHXusxbG4H8sUecszu/ehL+T4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GGukvWoiYugWuRsmcLH+mF1kGuceKy0hEkWzgif4kDKj9I8cwjVz5hPUF0kxTF61B LK2cRPfrUMtFy26wL1z3lmsr494xq2RdhOeKXEySP7IUw28x9VhCtfIt5Y/SqYHQb+ fLzTeBzoyStJWLpGnp+iAlKMAzC+g67FAxwp9YK8SRRYjOXH7Ua5ixQCO7ML41GM1Y g/AI2y9lTSnRW9XLWGoPLiuyMGk9aacsv3z4td2wybkT74ciu/QcZTwIomXmzMuVeM Qjf9AaVXjDmnF8hp4M5K1Wek7xoRqDZKXTi8SvQGiNaaYjhmjqno+QV2Qco/Y5JL32 5nQSxgrbKe5jA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 10/29] tty: n_tty: extract n_tty_wait_for_input() Date: Thu, 20 Feb 2025 12:15:47 +0100 Message-ID: <20250220111606.138045-11-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 n_tty_read() is a very long function doing too much of different stuff. Extract the "wait for input" to a separate function: n_tty_wait_for_input(). It returns an error (< 0), no input (0), or has potential input (1). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/n_tty.c | 57 ++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 88aa5f9cbe5e..0e3eb18490f0 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -2145,6 +2145,33 @@ static ssize_t n_tty_continue_cookie(struct tty_struct *tty, u8 *kbuf, return kb - kbuf; } +static int n_tty_wait_for_input(struct tty_struct *tty, struct file *file, + struct wait_queue_entry *wait, long *timeout) +{ + if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) + return -EIO; + if (tty_hung_up_p(file)) + return 0; + /* + * Abort readers for ttys which never actually get hung up. + * See __tty_hangup(). + */ + if (test_bit(TTY_HUPPING, &tty->flags)) + return 0; + if (!*timeout) + return 0; + if (tty_io_nonblock(tty, file)) + return -EAGAIN; + if (signal_pending(current)) + return -ERESTARTSYS; + + up_read(&tty->termios_rwsem); + *timeout = wait_woken(wait, TASK_INTERRUPTIBLE, *timeout); + down_read(&tty->termios_rwsem); + + return 1; +} + /** * n_tty_read - read function for tty * @tty: tty device @@ -2234,34 +2261,12 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, u8 *kbuf, tty_buffer_flush_work(tty->port); down_read(&tty->termios_rwsem); if (!input_available_p(tty, 0)) { - if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) { - retval = -EIO; + int ret = n_tty_wait_for_input(tty, file, &wait, + &timeout); + if (ret <= 0) { + retval = ret; break; } - if (tty_hung_up_p(file)) - break; - /* - * Abort readers for ttys which never actually - * get hung up. See __tty_hangup(). - */ - if (test_bit(TTY_HUPPING, &tty->flags)) - break; - if (!timeout) - break; - if (tty_io_nonblock(tty, file)) { - retval = -EAGAIN; - break; - } - if (signal_pending(current)) { - retval = -ERESTARTSYS; - break; - } - up_read(&tty->termios_rwsem); - - timeout = wait_woken(&wait, TASK_INTERRUPTIBLE, - timeout); - - down_read(&tty->termios_rwsem); continue; } } From patchwork Thu Feb 20 11:15:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867067 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7397C1FCD06; Thu, 20 Feb 2025 11:16:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050191; cv=none; b=pBnxc9gCSUQ1lReYsYncOUVCdrIpF2pcNlcRKW2L79pKCXvOSXr09KQ8ERJxXfLxAurKHJi1hUSj3MVQwDuX1C8n+8lR2vRHSXzW7anu+AqnNgrWRClImZL3yWuky6EujnjK5ZE7h+bVl/sib0KZrnt/TP20Ky6je2yjipPtDSo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050191; c=relaxed/simple; bh=eZR2IzG2EDLv4boMcni4nYVHvs/shsHiMBi5yS6eQcM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KMNaUo2Bloqb0c8HBQpG9kz1HbIKVkxeIDsAiCX7C8BuFY8SOEU2ilRKvepmHBx76XMYcaxGjG042QVWei7XGa/RY8WvYfb0PBOMT+9bOWAqgFb5A5UehFyQUvWpF4R1rYdfe8/nhwIAB3M7+hy06bqmDTkNjKxgiAsyExEzluU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=E3B1U8uD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="E3B1U8uD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA6E1C4CED1; Thu, 20 Feb 2025 11:16:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050191; bh=eZR2IzG2EDLv4boMcni4nYVHvs/shsHiMBi5yS6eQcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E3B1U8uDDGHLFJNG/zVu/sfqQOJrVA/t9h1RlntwMVx9EzM+2Rt7MhqUpqYYypfPZ hbg/M0LmAA2fKtaGFnEpVosywX4+PfaH3thdfN3R4ZRn9MJXJ/g8nKK8/wHF0/WPIb RikdIP5hvo199kzKpmIT1EGhIitVHsKdnllsCOWKKed1Q0QbJOHedBYrchLG4KqgDf JFYrQIk2d9fzwrcO5RQAlg8vvZqI9hfg752ry/Yjq6xYSN8ZR75C6E4wGyy34c6xQm iTYVYz3hw3f1X8V7QkfvZsiIs1Y8qJOJpBgSaAK7sj9k4qQxqCQOj0+7rgSXMTgksa tiKer8JtZmClw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 11/29] tty: n_tty: move more_to_be_read to the end of n_tty_read() Date: Thu, 20 Feb 2025 12:15:48 +0100 Message-ID: <20250220111606.138045-12-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 n_tty_read() contains "we need more data" handling deep in that function. And there is also a label (more_to_be_read) as we handle this situation from two places. It makes more sense to have all "return"s accumulated at the end of functions. And "goto" from multiple places there. Therefore, do this with the "more_to_be_read" label in n_tty_read(). After this and the previous changes, n_tty_read() is now much more easier to follow. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/n_tty.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 0e3eb18490f0..6af3f3a0b531 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -2281,21 +2281,8 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, u8 *kbuf, nr--; } - /* - * Copy data, and if there is more to be had - * and we have nothing more to wait for, then - * let's mark us for retries. - * - * NOTE! We return here with both the termios_sem - * and atomic_read_lock still held, the retries - * will release them when done. - */ - if (copy_from_read_buf(tty, &kb, &nr) && kb - kbuf >= minimum) { -more_to_be_read: - remove_wait_queue(&tty->read_wait, &wait); - *cookie = cookie; - return kb - kbuf; - } + if (copy_from_read_buf(tty, &kb, &nr) && kb - kbuf >= minimum) + goto more_to_be_read; } n_tty_check_unthrottle(tty); @@ -2322,6 +2309,18 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, u8 *kbuf, retval = kb - kbuf; return retval; +more_to_be_read: + /* + * There is more to be had and we have nothing more to wait for, so + * let's mark us for retries. + * + * NOTE! We return here with both the termios_sem and atomic_read_lock + * still held, the retries will release them when done. + */ + remove_wait_queue(&tty->read_wait, &wait); + *cookie = cookie; + + return kb - kbuf; } /** From patchwork Thu Feb 20 11:15:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867872 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB54B1FCFDA; Thu, 20 Feb 2025 11:16:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050193; cv=none; b=f9n9at/j27fDkZbh0upuK4KTked6jtWFSWO7RbgI9ELFmFheH6SsknmVMRMFnsvnCCw15kDWOoEIYhehjK4LKNPcgatgwiTocwuGyt0KBXzPFn0H/HK4dToQCGuiqQzi2csBgxcx5hA6eQY+0yKEKSMHnbITIJ3Meoik1zCYC/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050193; c=relaxed/simple; bh=0FMYyau3lU6OsZPeWKXYKIaiuxGFNc97kzzMytcgEUc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FgDlhtLafVhSut7keOTL3UetS1djfXnv/Yr9nwFkb+SzvC41dpnV5sjFe6MTcGHj2s5guCEcMomo5B33wEpV0PuaZpO4ueo9EUsaD/kiH78cLvplKAoDf6nvaEcn8AAwaSawmkPR4ByUPjVBHGN/aZDPLipJ5demuw4i0IgRU3Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LN+TOOV5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LN+TOOV5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65F06C4CEDD; Thu, 20 Feb 2025 11:16:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050192; bh=0FMYyau3lU6OsZPeWKXYKIaiuxGFNc97kzzMytcgEUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LN+TOOV5cYRQdT7ykSATcDjdN0DViHUnrWLUZ/h8ml7zqfwc4nKG3bWONVzbcJnG9 j7GeMrALbN+lv7cbJPWSdIvEITBy3dmoFczecd1to2Ix1T5ZZlgiVtv8oIKEnPCIt+ wnQ2y0erQUmO8RUZuyHEmIvKqCiwdEDv6Qz67SLyIvs/M0azZIpYZU0IV7OgzFODcG Edck/UhaRXbLt70UVzWo1V1qOAj9gS0x44Bgm92ITzieBlOxs3p49e8gkg0jyz4Tri wqwZBRNsvyS+eMFyluazhBAIpjHzDpc97tMYp06PZejyi+Kr+w6ar3NqcwfGKoB9vf 4FNDBdhmGW9Xw== 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/29] tty: tty_driver: move TTY macros to the top Date: Thu, 20 Feb 2025 12:15:49 +0100 Message-ID: <20250220111606.138045-13-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 So that they can be referenced in structs once converted to enums (in the next patches). Signed-off-by: Jiri Slaby (SUSE) --- include/linux/tty_driver.h | 156 ++++++++++++++++++------------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index d4cdc089f6c3..f3be6d56e9e5 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -16,6 +16,84 @@ struct tty_driver; struct serial_icounter_struct; struct serial_struct; +/** + * DOC: TTY Driver Flags + * + * TTY_DRIVER_RESET_TERMIOS + * Requests the tty layer to reset the termios setting when the last + * process has closed the device. Used for PTYs, in particular. + * + * TTY_DRIVER_REAL_RAW + * Indicates that the driver will guarantee not to set any special + * character handling flags if this is set for the tty: + * + * ``(IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || !INPCK)`` + * + * That is, if there is no reason for the driver to + * send notifications of parity and break characters up to the line + * driver, it won't do so. This allows the line driver to optimize for + * this case if this flag is set. (Note that there is also a promise, if + * the above case is true, not to signal overruns, either.) + * + * TTY_DRIVER_DYNAMIC_DEV + * The individual tty devices need to be registered with a call to + * tty_register_device() when the device is found in the system and + * unregistered with a call to tty_unregister_device() so the devices will + * be show up properly in sysfs. If not set, all &tty_driver.num entries + * will be created by the tty core in sysfs when tty_register_driver() is + * called. This is to be used by drivers that have tty devices that can + * appear and disappear while the main tty driver is registered with the + * tty core. + * + * TTY_DRIVER_DEVPTS_MEM + * Don't use the standard arrays (&tty_driver.ttys and + * &tty_driver.termios), instead use dynamic memory keyed through the + * devpts filesystem. This is only applicable to the PTY driver. + * + * TTY_DRIVER_HARDWARE_BREAK + * Hardware handles break signals. Pass the requested timeout to the + * &tty_operations.break_ctl instead of using a simple on/off interface. + * + * TTY_DRIVER_DYNAMIC_ALLOC + * Do not allocate structures which are needed per line for this driver + * (&tty_driver.ports) as it would waste memory. The driver will take + * care. This is only applicable to the PTY driver. + * + * TTY_DRIVER_UNNUMBERED_NODE + * Do not create numbered ``/dev`` nodes. For example, create + * ``/dev/ttyprintk`` and not ``/dev/ttyprintk0``. Applicable only when a + * driver for a single tty device is being allocated. + */ +#define TTY_DRIVER_INSTALLED 0x0001 +#define TTY_DRIVER_RESET_TERMIOS 0x0002 +#define TTY_DRIVER_REAL_RAW 0x0004 +#define TTY_DRIVER_DYNAMIC_DEV 0x0008 +#define TTY_DRIVER_DEVPTS_MEM 0x0010 +#define TTY_DRIVER_HARDWARE_BREAK 0x0020 +#define TTY_DRIVER_DYNAMIC_ALLOC 0x0040 +#define TTY_DRIVER_UNNUMBERED_NODE 0x0080 + +/* tty driver types */ +#define TTY_DRIVER_TYPE_SYSTEM 0x0001 +#define TTY_DRIVER_TYPE_CONSOLE 0x0002 +#define TTY_DRIVER_TYPE_SERIAL 0x0003 +#define TTY_DRIVER_TYPE_PTY 0x0004 +#define TTY_DRIVER_TYPE_SCC 0x0005 /* scc driver */ +#define TTY_DRIVER_TYPE_SYSCONS 0x0006 + +/* system subtypes (magic, used by tty_io.c) */ +#define SYSTEM_TYPE_TTY 0x0001 +#define SYSTEM_TYPE_CONSOLE 0x0002 +#define SYSTEM_TYPE_SYSCONS 0x0003 +#define SYSTEM_TYPE_SYSPTMX 0x0004 + +/* pty subtypes (magic, used by tty_io.c) */ +#define PTY_TYPE_MASTER 0x0001 +#define PTY_TYPE_SLAVE 0x0002 + +/* serial subtype definitions */ +#define SERIAL_TYPE_NORMAL 1 + /** * struct tty_operations -- interface between driver and tty * @@ -494,84 +572,6 @@ static inline void tty_set_operations(struct tty_driver *driver, driver->ops = op; } -/** - * DOC: TTY Driver Flags - * - * TTY_DRIVER_RESET_TERMIOS - * Requests the tty layer to reset the termios setting when the last - * process has closed the device. Used for PTYs, in particular. - * - * TTY_DRIVER_REAL_RAW - * Indicates that the driver will guarantee not to set any special - * character handling flags if this is set for the tty: - * - * ``(IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || !INPCK)`` - * - * That is, if there is no reason for the driver to - * send notifications of parity and break characters up to the line - * driver, it won't do so. This allows the line driver to optimize for - * this case if this flag is set. (Note that there is also a promise, if - * the above case is true, not to signal overruns, either.) - * - * TTY_DRIVER_DYNAMIC_DEV - * The individual tty devices need to be registered with a call to - * tty_register_device() when the device is found in the system and - * unregistered with a call to tty_unregister_device() so the devices will - * be show up properly in sysfs. If not set, all &tty_driver.num entries - * will be created by the tty core in sysfs when tty_register_driver() is - * called. This is to be used by drivers that have tty devices that can - * appear and disappear while the main tty driver is registered with the - * tty core. - * - * TTY_DRIVER_DEVPTS_MEM - * Don't use the standard arrays (&tty_driver.ttys and - * &tty_driver.termios), instead use dynamic memory keyed through the - * devpts filesystem. This is only applicable to the PTY driver. - * - * TTY_DRIVER_HARDWARE_BREAK - * Hardware handles break signals. Pass the requested timeout to the - * &tty_operations.break_ctl instead of using a simple on/off interface. - * - * TTY_DRIVER_DYNAMIC_ALLOC - * Do not allocate structures which are needed per line for this driver - * (&tty_driver.ports) as it would waste memory. The driver will take - * care. This is only applicable to the PTY driver. - * - * TTY_DRIVER_UNNUMBERED_NODE - * Do not create numbered ``/dev`` nodes. For example, create - * ``/dev/ttyprintk`` and not ``/dev/ttyprintk0``. Applicable only when a - * driver for a single tty device is being allocated. - */ -#define TTY_DRIVER_INSTALLED 0x0001 -#define TTY_DRIVER_RESET_TERMIOS 0x0002 -#define TTY_DRIVER_REAL_RAW 0x0004 -#define TTY_DRIVER_DYNAMIC_DEV 0x0008 -#define TTY_DRIVER_DEVPTS_MEM 0x0010 -#define TTY_DRIVER_HARDWARE_BREAK 0x0020 -#define TTY_DRIVER_DYNAMIC_ALLOC 0x0040 -#define TTY_DRIVER_UNNUMBERED_NODE 0x0080 - -/* tty driver types */ -#define TTY_DRIVER_TYPE_SYSTEM 0x0001 -#define TTY_DRIVER_TYPE_CONSOLE 0x0002 -#define TTY_DRIVER_TYPE_SERIAL 0x0003 -#define TTY_DRIVER_TYPE_PTY 0x0004 -#define TTY_DRIVER_TYPE_SCC 0x0005 /* scc driver */ -#define TTY_DRIVER_TYPE_SYSCONS 0x0006 - -/* system subtypes (magic, used by tty_io.c) */ -#define SYSTEM_TYPE_TTY 0x0001 -#define SYSTEM_TYPE_CONSOLE 0x0002 -#define SYSTEM_TYPE_SYSCONS 0x0003 -#define SYSTEM_TYPE_SYSPTMX 0x0004 - -/* pty subtypes (magic, used by tty_io.c) */ -#define PTY_TYPE_MASTER 0x0001 -#define PTY_TYPE_SLAVE 0x0002 - -/* serial subtype definitions */ -#define SERIAL_TYPE_NORMAL 1 - int tty_register_driver(struct tty_driver *driver); void tty_unregister_driver(struct tty_driver *driver); struct device *tty_register_device(struct tty_driver *driver, unsigned index, From patchwork Thu Feb 20 11:15:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867066 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 205A71FDA94; Thu, 20 Feb 2025 11:16:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050194; cv=none; b=kMbuhfp4v4mOVuxmXVmaoxKdbao7GY1mE3J06npJIsxmr31wq/oaT1rbQizE2kA9+KKqYf5DQjcZFiaxTdg3yUrhfLMNekIUBltJRY6zvlD3Q5MRP42TJFtcJcpvCuc/dthnfE+eKmCAxgR/H4Z16DrcRBrZir7ZiynNrnJ7kYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050194; c=relaxed/simple; bh=zOOO9DB53BwVwmkA70kTsG+ATH7ViZTlm6u+KsTETy4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cqgJWrJXfvAjWRychs7g2f6m7+q0mKpNfVhG2p3L+foXfmW5yVjH9BpWECXy991mj2oih/K2rhy37c6+VAYm76gdGT7d4KvoSAdOgXFVoS47YlpDrfEWscdS5dox3nSADjY3qlqS7amTCLcLHQlJUWd0AmcwCG12gnrx5vh6adU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f2p1F0OC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="f2p1F0OC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5A5BC4CEE4; Thu, 20 Feb 2025 11:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050194; bh=zOOO9DB53BwVwmkA70kTsG+ATH7ViZTlm6u+KsTETy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f2p1F0OC+O0qquknUbcikCULXrX3cNliYz4+9MvhEwf0S+VU0WfN5oFK0HK1efPx7 R4cKSkjvoWbcgLUzW+QvfVhqR6PDDz9qqP0qNrAiM4l2G5spc1XEj+mjvuMW0A+oX8 wcXd2sPqDBDAut7B2OSlh7wkfAskOwZjC64NH29wpBnlsjawC0znWWGieX++nT+pjV j33uclDGWqRQR/IwY40OOsMHyPQAZK+QkpVBBqW7UPhdxoMljaG3ffKOfGVy0EATwR tlWRHzbQrRbDONvjeBhg/OW5tXmcIs5Ot/m2TShFuP9Xys2bN2ldD67ahyeGC60jm3 HFGzl9RMsWrmw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 13/29] tty: tty_driver: convert "TTY Driver Flags" to an enum Date: Thu, 20 Feb 2025 12:15:50 +0100 Message-ID: <20250220111606.138045-14-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert TTY_DRIVER_* macros (flags) to an enum. This allows for easier kernel-doc (the comment needed fine tuning), grouping of these nicely, and proper checking. Given these are flags, define them using modern BIT() instead of hex constants. It turns out (thanks, kernel-doc checker) that internal TTY_DRIVER_INSTALLED was undocumented. Fix that too. Signed-off-by: Jiri Slaby (SUSE) --- Documentation/driver-api/tty/tty_driver.rst | 2 +- include/linux/tty_driver.h | 40 ++++++++++++--------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Documentation/driver-api/tty/tty_driver.rst b/Documentation/driver-api/tty/tty_driver.rst index cc529f863406..f6cbffdb6e01 100644 --- a/Documentation/driver-api/tty/tty_driver.rst +++ b/Documentation/driver-api/tty/tty_driver.rst @@ -35,7 +35,7 @@ Here comes the documentation of flags accepted by tty_alloc_driver() (or __tty_alloc_driver()): .. kernel-doc:: include/linux/tty_driver.h - :doc: TTY Driver Flags + :identifiers: tty_driver_flag ---- diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index f3be6d56e9e5..d0d940236580 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -17,13 +17,19 @@ struct serial_icounter_struct; struct serial_struct; /** - * DOC: TTY Driver Flags + * enum tty_driver_flag -- TTY Driver Flags * - * TTY_DRIVER_RESET_TERMIOS + * These are flags passed to tty_alloc_driver(). + * + * @TTY_DRIVER_INSTALLED: + * Whether this driver was succesfully installed. This is a tty internal + * flag. Do not touch. + * + * @TTY_DRIVER_RESET_TERMIOS: * Requests the tty layer to reset the termios setting when the last * process has closed the device. Used for PTYs, in particular. * - * TTY_DRIVER_REAL_RAW + * @TTY_DRIVER_REAL_RAW: * Indicates that the driver will guarantee not to set any special * character handling flags if this is set for the tty: * @@ -35,7 +41,7 @@ struct serial_struct; * this case if this flag is set. (Note that there is also a promise, if * the above case is true, not to signal overruns, either.) * - * TTY_DRIVER_DYNAMIC_DEV + * @TTY_DRIVER_DYNAMIC_DEV: * The individual tty devices need to be registered with a call to * tty_register_device() when the device is found in the system and * unregistered with a call to tty_unregister_device() so the devices will @@ -45,33 +51,35 @@ struct serial_struct; * appear and disappear while the main tty driver is registered with the * tty core. * - * TTY_DRIVER_DEVPTS_MEM + * @TTY_DRIVER_DEVPTS_MEM: * Don't use the standard arrays (&tty_driver.ttys and * &tty_driver.termios), instead use dynamic memory keyed through the * devpts filesystem. This is only applicable to the PTY driver. * - * TTY_DRIVER_HARDWARE_BREAK + * @TTY_DRIVER_HARDWARE_BREAK: * Hardware handles break signals. Pass the requested timeout to the * &tty_operations.break_ctl instead of using a simple on/off interface. * - * TTY_DRIVER_DYNAMIC_ALLOC + * @TTY_DRIVER_DYNAMIC_ALLOC: * Do not allocate structures which are needed per line for this driver * (&tty_driver.ports) as it would waste memory. The driver will take * care. This is only applicable to the PTY driver. * - * TTY_DRIVER_UNNUMBERED_NODE + * @TTY_DRIVER_UNNUMBERED_NODE: * Do not create numbered ``/dev`` nodes. For example, create * ``/dev/ttyprintk`` and not ``/dev/ttyprintk0``. Applicable only when a * driver for a single tty device is being allocated. */ -#define TTY_DRIVER_INSTALLED 0x0001 -#define TTY_DRIVER_RESET_TERMIOS 0x0002 -#define TTY_DRIVER_REAL_RAW 0x0004 -#define TTY_DRIVER_DYNAMIC_DEV 0x0008 -#define TTY_DRIVER_DEVPTS_MEM 0x0010 -#define TTY_DRIVER_HARDWARE_BREAK 0x0020 -#define TTY_DRIVER_DYNAMIC_ALLOC 0x0040 -#define TTY_DRIVER_UNNUMBERED_NODE 0x0080 +enum tty_driver_flag { + TTY_DRIVER_INSTALLED = BIT(0), + TTY_DRIVER_RESET_TERMIOS = BIT(1), + TTY_DRIVER_REAL_RAW = BIT(2), + TTY_DRIVER_DYNAMIC_DEV = BIT(3), + TTY_DRIVER_DEVPTS_MEM = BIT(4), + TTY_DRIVER_HARDWARE_BREAK = BIT(5), + TTY_DRIVER_DYNAMIC_ALLOC = BIT(6), + TTY_DRIVER_UNNUMBERED_NODE = BIT(7), +}; /* tty driver types */ #define TTY_DRIVER_TYPE_SYSTEM 0x0001 From patchwork Thu Feb 20 11:15:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867871 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E2031F2382; Thu, 20 Feb 2025 11:16:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050195; cv=none; b=EBZ0YdwTpmF4t0H7AQskllz9D5Y7jjRlPDooM1O91ms28lXizO1I+xcW6n5wuealSQbdYOc7UZ7f6vlttDrTcGcq4CxdXAfKKgasPSGBZOIghJj47Hgpe4V+Pite39LQaM9IKNCdNlZ0I6ZDw8KxX0JKTsCfV6UTV/f2aO8XXlM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050195; c=relaxed/simple; bh=Bl6yKET3mu+yr5UFjN4IPYvSxd4VgCuhhypyQxdUI4w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y7axDehc0yaMpR8m8XtuRu9zLM/Dv8seMnfqagoDjPFrWoS1gvUqrhSPZj/Ev4QA/gbcNOkXVBWA/z8eaUKqR15j97so5N8Y3tDAjZb9Qdi4Z2xXeNXk1Gv+U/I8M4sdt5gZhXv22wynKeQo71jMFch/mJ0RGCFivre/1ndoUBc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U6cLyFmW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="U6cLyFmW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7106DC4CED1; Thu, 20 Feb 2025 11:16:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050195; bh=Bl6yKET3mu+yr5UFjN4IPYvSxd4VgCuhhypyQxdUI4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U6cLyFmWDOMjVJzHPMWBkCmwJQhQFxQugTQilkUWS7Ffvj5t1SSRqrpd6RtxGFThr nOFuYkS07cI87dnV4RISYcQ3tV44Kt9gfrTvLd8R071SHgT1PFYpdB1UhzBKZtuN4B JqrTWrXyhgDlyESu+9KP4fYpGdu7NIatPnsyq5c1Md84M3I2sBcKC+gBGFR0wHWN8U LswZqUAD/nKGJDWDjdAsg2J97LAs/1MwTHN6ur9N4qhe5yyBw0d2tb2sk+lpm/aljo e/D+0XlzgWO2norAZ2kK1Ee04Ee1DwIbOR9WcY6spsZylVToV0ZNhmyKM+eqbwtMj4 miHom5GsHalxw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 14/29] tty: tty_driver: document both {, __}tty_alloc_driver() properly Date: Thu, 20 Feb 2025 12:15:51 +0100 Message-ID: <20250220111606.138045-15-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 __tty_alloc_driver()'s kernel-doc needed some care: describe the return value using the standard "Returns:", and use the new enum tty_driver_flag for @flags. Then, the tty_alloc_driver() macro was undocumented, but referenced many times in the docs. Copy the docs from the above (except the @owner parameter, obviously). Signed-off-by: Jiri Slaby (SUSE) --- Documentation/driver-api/tty/tty_driver.rst | 2 ++ drivers/tty/tty_io.c | 8 +++++--- include/linux/tty_driver.h | 8 +++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Documentation/driver-api/tty/tty_driver.rst b/Documentation/driver-api/tty/tty_driver.rst index f6cbffdb6e01..7138222a70f2 100644 --- a/Documentation/driver-api/tty/tty_driver.rst +++ b/Documentation/driver-api/tty/tty_driver.rst @@ -25,6 +25,8 @@ freed. For reference, both allocation and deallocation functions are explained here in detail: +.. kernel-doc:: include/linux/tty_driver.h + :identifiers: tty_alloc_driver .. kernel-doc:: drivers/tty/tty_io.c :identifiers: __tty_alloc_driver tty_driver_kref_put diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 449dbd216460..ca9b7d7bad2b 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -3329,10 +3329,12 @@ EXPORT_SYMBOL(tty_unregister_device); * __tty_alloc_driver - allocate tty driver * @lines: count of lines this driver can handle at most * @owner: module which is responsible for this driver - * @flags: some of %TTY_DRIVER_ flags, will be set in driver->flags + * @flags: some of enum tty_driver_flag, will be set in driver->flags * - * This should not be called directly, some of the provided macros should be - * used instead. Use IS_ERR() and friends on @retval. + * This should not be called directly, tty_alloc_driver() should be used + * instead. + * + * Returns: struct tty_driver or a PTR-encoded error (use IS_ERR() and friends). */ struct tty_driver *__tty_alloc_driver(unsigned int lines, struct module *owner, unsigned long flags) diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index d0d940236580..0fe38befa1b8 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -564,7 +564,13 @@ struct tty_driver *tty_find_polling_driver(char *name, int *line); void tty_driver_kref_put(struct tty_driver *driver); -/* Use TTY_DRIVER_* flags below */ +/** + * tty_alloc_driver - allocate tty driver + * @lines: count of lines this driver can handle at most + * @flags: some of enum tty_driver_flag, will be set in driver->flags + * + * Returns: struct tty_driver or a PTR-encoded error (use IS_ERR() and friends). + */ #define tty_alloc_driver(lines, flags) \ __tty_alloc_driver(lines, THIS_MODULE, flags) From patchwork Thu Feb 20 11:15:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867065 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A07C1FECD1; Thu, 20 Feb 2025 11:16:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050197; cv=none; b=TBzdJGeh3HPfMEMe8pHp053+6UXq7BzhbqOyUL2FQX1FVBotOVs2N2IAChUVEA5Ngc6IjcX9J+M9VzC9UTWRLnBdZgF/oyFGx7NJkMcytXv2u7K3M75zX36TQETSYLmt490AUNj5nPPqpG+gTekcsKzxTS5oNGL9ORvwMCQ4l84= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050197; c=relaxed/simple; bh=eym0iQyZ+wC53dbebkT2FnQUWTN2XX6Qz6fKjwQmFOQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RpLF3kq0bBvTLrHLnCXzChDDTP/ZouZl588TQTpTDTp6Na1ZUCT4/VrGkwCc4n4+mWdXaGTc7wkhEjL3eAI1c93KfDOQBLGlreD9yyrQp9SCnYG6kF0lFaRSm9rA4ncrU1eeiV3TEPT4VxrNRCz4ih7kYGYZamTZvwuersO7orU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uGLp12yw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uGLp12yw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F068FC4CED1; Thu, 20 Feb 2025 11:16:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050197; bh=eym0iQyZ+wC53dbebkT2FnQUWTN2XX6Qz6fKjwQmFOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uGLp12ywQpgZg5ui/tq14M64m7BPtmF4oidyguOsr2I2tOh/VQdmR5Z105lSCleDB e71P7Ye/HJ0FikeRAfheun9nEbjK+OgK0D3UUUKvtLoQ0dMW13CrfolDa9Woqa/Z4I /GsnBLMJ+Hh5p6ZBx4wdsk8WfRQkSirwwZBTE2rKE8/5irt7vQo7MwFAG3itRMlcY8 mdUTGVXAdJoQ9e2JUrM25NAncmKV+tvzAA9uKoyhwunpSXndV3pJQ7tVzUo9AOkRgy VXBFtvZ22UtNm3zIdrNuxfZWx32CUjUPIpMQgTabIyFGOR7c0gidiMdBm58cPw+7ol YgRZqU1GYxzhA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 15/29] tty: tty_driver: introduce TTY driver sub/types enums Date: Thu, 20 Feb 2025 12:15:52 +0100 Message-ID: <20250220111606.138045-16-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert TTY_DRIVER_TYPE_*, and subtype macros to two enums: tty_driver_type and tty_driver_subtype. This allows for easier kernel-doc (later), grouping of these nicely, and proper checking. The tty_driver's ::type and ::subtype now use these enums instead of bare "short". Signed-off-by: Jiri Slaby (SUSE) --- include/linux/tty_driver.h | 42 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index 0fe38befa1b8..188ee9b768eb 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -81,26 +81,26 @@ enum tty_driver_flag { TTY_DRIVER_UNNUMBERED_NODE = BIT(7), }; -/* tty driver types */ -#define TTY_DRIVER_TYPE_SYSTEM 0x0001 -#define TTY_DRIVER_TYPE_CONSOLE 0x0002 -#define TTY_DRIVER_TYPE_SERIAL 0x0003 -#define TTY_DRIVER_TYPE_PTY 0x0004 -#define TTY_DRIVER_TYPE_SCC 0x0005 /* scc driver */ -#define TTY_DRIVER_TYPE_SYSCONS 0x0006 +enum tty_driver_type { + TTY_DRIVER_TYPE_SYSTEM, + TTY_DRIVER_TYPE_CONSOLE, + TTY_DRIVER_TYPE_SERIAL, + TTY_DRIVER_TYPE_PTY, + TTY_DRIVER_TYPE_SCC, + TTY_DRIVER_TYPE_SYSCONS, +}; -/* system subtypes (magic, used by tty_io.c) */ -#define SYSTEM_TYPE_TTY 0x0001 -#define SYSTEM_TYPE_CONSOLE 0x0002 -#define SYSTEM_TYPE_SYSCONS 0x0003 -#define SYSTEM_TYPE_SYSPTMX 0x0004 +enum tty_driver_subtype { + SYSTEM_TYPE_TTY = 1, + SYSTEM_TYPE_CONSOLE, + SYSTEM_TYPE_SYSCONS, + SYSTEM_TYPE_SYSPTMX, -/* pty subtypes (magic, used by tty_io.c) */ -#define PTY_TYPE_MASTER 0x0001 -#define PTY_TYPE_SLAVE 0x0002 + PTY_TYPE_MASTER = 1, + PTY_TYPE_SLAVE, -/* serial subtype definitions */ -#define SERIAL_TYPE_NORMAL 1 + SERIAL_TYPE_NORMAL = 1, +}; /** * struct tty_operations -- interface between driver and tty @@ -500,8 +500,8 @@ struct tty_operations { * @major: major /dev device number (zero for autoassignment) * @minor_start: the first minor /dev device number * @num: number of devices allocated - * @type: type of tty driver (%TTY_DRIVER_TYPE_) - * @subtype: subtype of tty driver (%SYSTEM_TYPE_, %PTY_TYPE_, %SERIAL_TYPE_) + * @type: type of tty driver (enum tty_driver_type) + * @subtype: subtype of tty driver (enum tty_driver_subtype) * @init_termios: termios to set to each tty initially (e.g. %tty_std_termios) * @flags: tty driver flags (%TTY_DRIVER_) * @proc_entry: proc fs entry, used internally @@ -533,8 +533,8 @@ struct tty_driver { int major; int minor_start; unsigned int num; - short type; - short subtype; + enum tty_driver_type type; + enum tty_driver_subtype subtype; struct ktermios init_termios; unsigned long flags; struct proc_dir_entry *proc_entry; From patchwork Thu Feb 20 11:15:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867870 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6D761FECBD; Thu, 20 Feb 2025 11:16:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050198; cv=none; b=u4auPfNEnTkIAVa1UVLVXH/0CHhRqxpMbHQrh3W44Rdd3dpVhQAlbMp4OwAuTdBi+n3K3GEdsUel5Y5yrqc86EBWwCB33PGPoHwe51eqAA7aSGAeWt0LBC5Ugk+KUoPpho2zl9v/UHu2UHp07MI7okJfA9zVqVSET7PSjy5xA+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050198; c=relaxed/simple; bh=v9ZJnH1PsUDr1NccKynpEcSwY6coQ46/se9cdWYKWuc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DjX4ihk/MTrEL1wEt4t7swJ3JdP8fB+frwU3iSsjFk1eBJ2D5Zjl9n+h+fc/E24ObDi4ralV68PdHnilKnvrZts9uweEbUpnWbHJ+Y7iVS2DknIE3nWDXuZlMYrbzH5ryCfqrUIribh6jDtOCxL+bVqVgNLxqGLHvXulWSF1tE8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FtMMsps/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FtMMsps/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C3EBC4CEDD; Thu, 20 Feb 2025 11:16:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050198; bh=v9ZJnH1PsUDr1NccKynpEcSwY6coQ46/se9cdWYKWuc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FtMMsps/cdle9kWEzUF9k9kVUPu+8d/RZFRpDxDZOP9i3crjARvvHVyk5DeLqEeas ZRPLhZ1U9PU6ddeLv8BUwW59HDrJut6SvZzrXBJVUdGSpjs4J+uyu0Bl9q21sxPeR+ fN2mXbk2PnA8EqaOwV4yj3M2C1OGus1lv+0yosM9XrlyRLezwA/FM1Jwxw4wK1vEEM MPBXlXVDlUd4R/+6KZi2m2UeFUOwla6lFw6B/GVKRi4qpGDj2AzK/SXdUmoMwzWS1p EEZl+dt8cDSKN658kG7YTCU3C7mD8kpvRF6YHn2GK6m78ULOCcSxTuDrGBj6IQ5qE+ OKHu/Y98ZMBzA== 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 16/29] tty: serdev: drop serdev_controller_ops::write_room() Date: Thu, 20 Feb 2025 12:15:53 +0100 Message-ID: <20250220111606.138045-17-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In particular, serdev_device_write_room() is not called, so the whole serdev's write_room() can go. Signed-off-by: Jiri Slaby (SUSE) Cc: Rob Herring --- drivers/tty/serdev/core.c | 11 ----------- drivers/tty/serdev/serdev-ttyport.c | 9 --------- include/linux/serdev.h | 6 ------ 3 files changed, 26 deletions(-) diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index ebf0bbc2cff2..eb2a2e58fe78 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c @@ -316,17 +316,6 @@ void serdev_device_write_flush(struct serdev_device *serdev) } EXPORT_SYMBOL_GPL(serdev_device_write_flush); -int serdev_device_write_room(struct serdev_device *serdev) -{ - struct serdev_controller *ctrl = serdev->ctrl; - - if (!ctrl || !ctrl->ops->write_room) - return 0; - - return serdev->ctrl->ops->write_room(ctrl); -} -EXPORT_SYMBOL_GPL(serdev_device_write_room); - unsigned int serdev_device_set_baudrate(struct serdev_device *serdev, unsigned int speed) { struct serdev_controller *ctrl = serdev->ctrl; diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c index 3d7ae7fa5018..bab1b143b8a6 100644 --- a/drivers/tty/serdev/serdev-ttyport.c +++ b/drivers/tty/serdev/serdev-ttyport.c @@ -92,14 +92,6 @@ static void ttyport_write_flush(struct serdev_controller *ctrl) tty_driver_flush_buffer(tty); } -static int ttyport_write_room(struct serdev_controller *ctrl) -{ - struct serport *serport = serdev_controller_get_drvdata(ctrl); - struct tty_struct *tty = serport->tty; - - return tty_write_room(tty); -} - static int ttyport_open(struct serdev_controller *ctrl) { struct serport *serport = serdev_controller_get_drvdata(ctrl); @@ -259,7 +251,6 @@ static int ttyport_break_ctl(struct serdev_controller *ctrl, unsigned int break_ static const struct serdev_controller_ops ctrl_ops = { .write_buf = ttyport_write_buf, .write_flush = ttyport_write_flush, - .write_room = ttyport_write_room, .open = ttyport_open, .close = ttyport_close, .set_flow_control = ttyport_set_flow_control, diff --git a/include/linux/serdev.h b/include/linux/serdev.h index ff78efc1f60d..34562eb99931 100644 --- a/include/linux/serdev.h +++ b/include/linux/serdev.h @@ -84,7 +84,6 @@ enum serdev_parity { struct serdev_controller_ops { ssize_t (*write_buf)(struct serdev_controller *, const u8 *, size_t); void (*write_flush)(struct serdev_controller *); - int (*write_room)(struct serdev_controller *); int (*open)(struct serdev_controller *); void (*close)(struct serdev_controller *); void (*set_flow_control)(struct serdev_controller *, bool); @@ -212,7 +211,6 @@ int serdev_device_break_ctl(struct serdev_device *serdev, int break_state); void serdev_device_write_wakeup(struct serdev_device *); ssize_t serdev_device_write(struct serdev_device *, const u8 *, size_t, long); void serdev_device_write_flush(struct serdev_device *); -int serdev_device_write_room(struct serdev_device *); /* * serdev device driver functions @@ -273,10 +271,6 @@ static inline ssize_t serdev_device_write(struct serdev_device *sdev, return -ENODEV; } static inline void serdev_device_write_flush(struct serdev_device *sdev) {} -static inline int serdev_device_write_room(struct serdev_device *sdev) -{ - return 0; -} #define serdev_device_driver_register(x) #define serdev_device_driver_unregister(x) From patchwork Thu Feb 20 11:15:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867064 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65AAF1FFC4F; Thu, 20 Feb 2025 11:16:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050200; cv=none; b=p+btkPJw/uW7kdNZWVWedJMMeaa2vGBw0sPWJZkWhPys5nmGYcrYhgcurAayzUNgkR17X9OfFVgLRlA/lPion4LD8OcrkoAVAhesNjYdGB/C/VmqxBdO5+4vxAIgNQwoSuX8tYlXyxGkPS828XApPmx1nNARIll5iqZ/4pfHWn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050200; c=relaxed/simple; bh=NWefyehqTC8N6b5xJiLn3iRSos/mZcw/xFIo2yDlpOs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QyPqVo+fPnIZB4jv+ETcktUAo2NhEeS1/fMqodc31j2J/9+ue6PNpYyTMSTKIPTKe2wjezMeO4eT2hmqNZ+D3ePelPli4RWmUHfng6vTu88MVf67Jp3hW5TlMFvZ/RNDWxjQM4bdw7AEd9F2pOWU+SJvq5tJBR1rXZbUEDsqzwc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=d+AuI4q8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="d+AuI4q8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35A3AC4CEDD; Thu, 20 Feb 2025 11:16:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050200; bh=NWefyehqTC8N6b5xJiLn3iRSos/mZcw/xFIo2yDlpOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d+AuI4q89zRzHYvZKnA0A1KQUxLMHXe/CtY/lXvz7YbAfeL0TYbb25yrtC3DV07My MNW0ThwxC/pLdSl1Qdvv7XiXzRfpFDNK8tnh+ymnGizdJrRtSjClaae7RJaAYYbaXx wXMJkgn3btlNqiqCbgbcx3TS2Pf8cKomHeBKD3lckwEqyZ9OmAz9zZJUDPbkBjtDbM xVRkRj1idQ1fBGP4db56ITWK1YrU/qXVgldfXeatPMgaHC0C5qHpD1uc4uekBPRhcu Gw9qYQv02ZWcqiqxOjgYZ6q0s8lioubiF4cdijnGyHqO1T6xSHFai8d3GwCadIuc3A PPJTu/Eg/1EGg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 17/29] tty: moxa: drop version dump to logs Date: Thu, 20 Feb 2025 12:15:54 +0100 Message-ID: <20250220111606.138045-18-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The arbitrary MOXA_VERSION is dumped to the logs when the driver is loaded. Avoid this as a driver should be silent unless something breaks. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/moxa.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c index ebaada8db929..2b75ca12cbc9 100644 --- a/drivers/tty/moxa.c +++ b/drivers/tty/moxa.c @@ -347,8 +347,6 @@ #define MX_PARMARK 0xA0 #define MX_PARSPACE 0x20 -#define MOXA_VERSION "6.0k" - #define MOXA_FW_HDRLEN 32 #define MOXAMAJOR 172 @@ -1327,9 +1325,6 @@ static int __init moxa_init(void) struct moxa_board_conf *brd = moxa_boards; unsigned int i; - printk(KERN_INFO "MOXA Intellio family driver version %s\n", - MOXA_VERSION); - tty_port_init(&moxa_service_port); moxaDriver = tty_alloc_driver(MAX_PORTS + 1, From patchwork Thu Feb 20 11:15:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867869 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5319A204873; Thu, 20 Feb 2025 11:16:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050202; cv=none; b=svSq2OsY70o/aXOvi903j++Cy1zR7YQd+k1kkvOwxgKSjTQylfHBzCf0NWSbvIuxZL/7f6MC+yJgxkCDm2aRQDwUWGgu6XKp2lodtqzYGteJyAnqCIY/wMHoQgW5F9w2rKDp19KLyuswc/9Yh9J9zkvyncFmeuVhTzidMeQuYAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050202; c=relaxed/simple; bh=lIBBhNedCjS1DTo0sSionEJkaNLa/iBdIM0pbzS3DXY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KEsJwpJWHKMNmkdFxNou28dJVsbPEMdOotRyUObAQgtps3D9IYeDkJrgTJlvgDgdUkJ/cGBx1jdYKnxtDDNWYRPfHY5yRj6V4//Wz0ORHB6fTy6Rx92JIw76wRRqF/nQn04uCpk/hj0M689cuKdTnbx4FF5GRP10k6c5rdwNHt8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LkigBexw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LkigBexw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6563C4CEE3; Thu, 20 Feb 2025 11:16:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050201; bh=lIBBhNedCjS1DTo0sSionEJkaNLa/iBdIM0pbzS3DXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LkigBexwDIBFlUWr5Nk2WW60RGG3q6cQ3myM36RzmRfdYhZbSbvYTdz+L3/a8MB4P 95cst0OLDfn6l8GLNKCizEBuv/QsaSbzXz0XBd2dDCbYaOHn5Ocf6kOjnrjtevaZ4t 1vTVFC1eFBMNvtyRcoHPKwTX8/NmguiJEMvmG/qkw60WJScP9yHFdcoxJDNGYnotkz 3ECJSsE/zVFcXWCLT2j6363rhijRc1TryYRCtvSomGVpuXj9kT/nO2VhZjN2cLOayw /RGllz4VsLIhJ0PVygfU3VJEe5YZXvQW/Y5AodwAL7vcJc3w/plAg4oJf17z7sIkfX wIruBgg1WqSOQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 18/29] tty: moxa: drop ISA support Date: Thu, 20 Feb 2025 12:15:55 +0100 Message-ID: <20250220111606.138045-19-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 I doubt anyone actually uses this driver (unlike mxser.c and serial moxa driven devices). Even less there is anyone with a moxa ISA card. The newer mxser dropped the support for ISA in 2021. Let this moxa follow now. Good diet. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/Kconfig | 2 +- drivers/tty/moxa.c | 100 +++----------------------------------------- 2 files changed, 6 insertions(+), 96 deletions(-) diff --git a/drivers/tty/Kconfig b/drivers/tty/Kconfig index 63a494d36a1f..0f3f55372c11 100644 --- a/drivers/tty/Kconfig +++ b/drivers/tty/Kconfig @@ -210,7 +210,7 @@ config SERIAL_NONSTANDARD config MOXA_INTELLIO tristate "Moxa Intellio support" - depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI) + depends on SERIAL_NONSTANDARD && PCI select FW_LOADER help Say Y here if you have a Moxa Intellio multiport serial card. diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c index 2b75ca12cbc9..a753afcb53b5 100644 --- a/drivers/tty/moxa.c +++ b/drivers/tty/moxa.c @@ -355,33 +355,21 @@ #define MAX_PORTS_PER_BOARD 32 /* Don't change this value */ #define MAX_PORTS (MAX_BOARDS * MAX_PORTS_PER_BOARD) -#define MOXA_IS_320(brd) ((brd)->boardType == MOXA_BOARD_C320_ISA || \ - (brd)->boardType == MOXA_BOARD_C320_PCI) - -/* - * Define the Moxa PCI vendor and device IDs. - */ -#define MOXA_BUS_TYPE_ISA 0 -#define MOXA_BUS_TYPE_PCI 1 +#define MOXA_IS_320(brd) ((brd)->boardType == MOXA_BOARD_C320_PCI) enum { MOXA_BOARD_C218_PCI = 1, - MOXA_BOARD_C218_ISA, MOXA_BOARD_C320_PCI, - MOXA_BOARD_C320_ISA, MOXA_BOARD_CP204J, }; static char *moxa_brdname[] = { "C218 Turbo PCI series", - "C218 Turbo ISA series", "C320 Turbo PCI series", - "C320 Turbo ISA series", "CP-204J series", }; -#ifdef CONFIG_PCI static const struct pci_device_id moxa_pcibrds[] = { { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C218), .driver_data = MOXA_BOARD_C218_PCI }, @@ -392,14 +380,12 @@ static const struct pci_device_id moxa_pcibrds[] = { { 0 } }; MODULE_DEVICE_TABLE(pci, moxa_pcibrds); -#endif /* CONFIG_PCI */ struct moxa_port; static struct moxa_board_conf { int boardType; int numPorts; - int busType; unsigned int ready; @@ -459,9 +445,6 @@ static unsigned int moxaLowWaterChk; static DEFINE_MUTEX(moxa_openlock); static DEFINE_SPINLOCK(moxa_lock); -static unsigned long baseaddr[MAX_BOARDS]; -static unsigned int type[MAX_BOARDS]; -static unsigned int numports[MAX_BOARDS]; static struct tty_port moxa_service_port; MODULE_AUTHOR("William Chen"); @@ -471,13 +454,6 @@ MODULE_FIRMWARE("c218tunx.cod"); MODULE_FIRMWARE("cp204unx.cod"); MODULE_FIRMWARE("c320tunx.cod"); -module_param_array(type, uint, NULL, 0); -MODULE_PARM_DESC(type, "card type: C218=2, C320=4"); -module_param_hw_array(baseaddr, ulong, ioport, NULL, 0); -MODULE_PARM_DESC(baseaddr, "base address"); -module_param_array(numports, uint, NULL, 0); -MODULE_PARM_DESC(numports, "numports (ignored for C218)"); - module_param(ttymajor, int, 0); /* @@ -723,7 +699,6 @@ static DEFINE_TIMER(moxaTimer, moxa_poll); static int moxa_check_fw_model(struct moxa_board_conf *brd, u8 model) { switch (brd->boardType) { - case MOXA_BOARD_C218_ISA: case MOXA_BOARD_C218_PCI: if (model != 1) goto err; @@ -767,7 +742,6 @@ static int moxa_load_bios(struct moxa_board_conf *brd, const u8 *buf, msleep(2000); switch (brd->boardType) { - case MOXA_BOARD_C218_ISA: case MOXA_BOARD_C218_PCI: tmp = readw(baseAddr + C218_key); if (tmp != C218_KeyCode) @@ -831,7 +805,6 @@ static int moxa_real_load_code(struct moxa_board_conf *brd, const void *ptr, switch (brd->boardType) { case MOXA_BOARD_CP204J: - case MOXA_BOARD_C218_ISA: case MOXA_BOARD_C218_PCI: key = C218_key; loadbuf = C218_LoadBuf; @@ -896,15 +869,9 @@ static int moxa_real_load_code(struct moxa_board_conf *brd, const void *ptr, return -EIO; if (MOXA_IS_320(brd)) { - if (brd->busType == MOXA_BUS_TYPE_PCI) { /* ASIC board */ - writew(0x3800, baseAddr + TMS320_PORT1); - writew(0x3900, baseAddr + TMS320_PORT2); - writew(28499, baseAddr + TMS320_CLOCK); - } else { - writew(0x3200, baseAddr + TMS320_PORT1); - writew(0x3400, baseAddr + TMS320_PORT2); - writew(19999, baseAddr + TMS320_CLOCK); - } + writew(0x3800, baseAddr + TMS320_PORT1); + writew(0x3900, baseAddr + TMS320_PORT2); + writew(28499, baseAddr + TMS320_CLOCK); } writew(1, baseAddr + Disable_IRQ); writew(0, baseAddr + Magic_no); @@ -955,7 +922,6 @@ static int moxa_load_code(struct moxa_board_conf *brd, const void *ptr, return retval; switch (brd->boardType) { - case MOXA_BOARD_C218_ISA: case MOXA_BOARD_C218_PCI: case MOXA_BOARD_CP204J: port = brd->ports; @@ -1139,7 +1105,6 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev) } switch (brd->boardType) { - case MOXA_BOARD_C218_ISA: case MOXA_BOARD_C218_PCI: file = "c218tunx.cod"; break; @@ -1225,7 +1190,6 @@ static void moxa_board_deinit(struct moxa_board_conf *brd) kfree(brd->ports); } -#ifdef CONFIG_PCI static int moxa_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -1268,7 +1232,6 @@ static int moxa_pci_probe(struct pci_dev *pdev, board->boardType = board_type; switch (board_type) { - case MOXA_BOARD_C218_ISA: case MOXA_BOARD_C218_PCI: board->numPorts = 8; break; @@ -1280,7 +1243,6 @@ static int moxa_pci_probe(struct pci_dev *pdev, board->numPorts = 0; break; } - board->busType = MOXA_BUS_TYPE_PCI; retval = moxa_init_board(board, &pdev->dev); if (retval) @@ -1316,14 +1278,10 @@ static struct pci_driver moxa_pci_driver = { .probe = moxa_pci_probe, .remove = moxa_pci_remove }; -#endif /* CONFIG_PCI */ static int __init moxa_init(void) { - unsigned int isabrds = 0; int retval = 0; - struct moxa_board_conf *brd = moxa_boards; - unsigned int i; tty_port_init(&moxa_service_port); @@ -1352,64 +1310,16 @@ static int __init moxa_init(void) return -1; } - /* Find the boards defined from module args. */ - - for (i = 0; i < MAX_BOARDS; i++) { - if (!baseaddr[i]) - break; - if (type[i] == MOXA_BOARD_C218_ISA || - type[i] == MOXA_BOARD_C320_ISA) { - pr_debug("Moxa board %2d: %s board(baseAddr=%lx)\n", - isabrds + 1, moxa_brdname[type[i] - 1], - baseaddr[i]); - brd->boardType = type[i]; - brd->numPorts = type[i] == MOXA_BOARD_C218_ISA ? 8 : - numports[i]; - brd->busType = MOXA_BUS_TYPE_ISA; - brd->basemem = ioremap(baseaddr[i], 0x4000); - if (!brd->basemem) { - printk(KERN_ERR "MOXA: can't remap %lx\n", - baseaddr[i]); - continue; - } - if (moxa_init_board(brd, NULL)) { - iounmap(brd->basemem); - brd->basemem = NULL; - continue; - } - - printk(KERN_INFO "MOXA isa board found at 0x%.8lx and " - "ready (%u ports, firmware loaded)\n", - baseaddr[i], brd->numPorts); - - brd++; - isabrds++; - } - } - -#ifdef CONFIG_PCI retval = pci_register_driver(&moxa_pci_driver); - if (retval) { + if (retval) printk(KERN_ERR "Can't register MOXA pci driver!\n"); - if (isabrds) - retval = 0; - } -#endif return retval; } static void __exit moxa_exit(void) { - unsigned int i; - -#ifdef CONFIG_PCI pci_unregister_driver(&moxa_pci_driver); -#endif - - for (i = 0; i < MAX_BOARDS; i++) /* ISA boards */ - if (moxa_boards[i].ready) - moxa_board_deinit(&moxa_boards[i]); del_timer_sync(&moxaTimer); From patchwork Thu Feb 20 11:15:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867063 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 709341F3B8A; Thu, 20 Feb 2025 11:16:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050203; cv=none; b=DUR4eNa46qIW/9Ra8xI0WMCLwJobFetHpstowa9ThVu8QLk9eqzVgMP3BKePEsBdDxgXHI9031vY7KMn+daBbh5eM3dy6dOxUhfsaNCXFhHCFEIB4ytCl9y28BSHyI6EzCTntC4wEoaW7HTzgge8J50stV2PQHJZghRzlgm1I7A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050203; c=relaxed/simple; bh=Nzn39Gj0zDV8oO5kv9Dt85bKRYqHcU7BvP/2szVpfw8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YU7E9kEWWzhovbccETFCXpFxtU0ekKj1UdNblNxWmhHHLm3du0AzZaMMP4gwuGRjfS1trZ1tsuCJRYlaG52m2WlsEPn5ucWSnJDrB2RI+1ejrOw7THK5pi8clJF5bU/b8tN1JSpBdP+So9c/yrPwHN4uzer/dZkVbY89BoPPdK0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VTUW7V4F; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VTUW7V4F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41A5AC4CEE4; Thu, 20 Feb 2025 11:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050203; bh=Nzn39Gj0zDV8oO5kv9Dt85bKRYqHcU7BvP/2szVpfw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VTUW7V4F02DLH1GSJEnrerkTin2mCYVLJykjPHpW9UVOvJHtAc24pCQdUnYZb0MOc a+SwTuRo2B/mpZNh8XJedi+GsfrK3zSMx/m/vx7Le3qnxDIwpnY1P7WH3aKQQXxi+J hDYEAAVfGxCbN82yBKN16oG1hYVBkn5FMmMIQIvPyBs9An8w+BwuqIeVELzTNH+jGK 6XStAuxaHfcDKkv2xCrIB3SwcMZG7Hi1dlu1FRZz+DK5oS5CfFgQUpQFsbxF7B6EOy gp4QqJUOvjEoPPlVCTupyBwWfJnPN/CEnvmX3OmbSmJ3ll2TFODWmN5WSpFSadIlia 02ONDp9LjERRA== 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/29] tty: moxa: carve out special ioctls and extra tty_port Date: Thu, 20 Feb 2025 12:15:56 +0100 Message-ID: <20250220111606.138045-20-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 These ioctls are undocumented and not exposed -- they are defined locally. Given they need a special tty_port just for them, this is very ugly. So drop this whole functionality. It is barely used for something real. (And if it is, we'd need a common functionality to all drivers.) Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/moxa.c | 146 +-------------------------------------------- 1 file changed, 1 insertion(+), 145 deletions(-) diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c index a753afcb53b5..1348e2214b81 100644 --- a/drivers/tty/moxa.c +++ b/drivers/tty/moxa.c @@ -43,15 +43,6 @@ #include #include -#include - -#define MOXA 0x400 -#define MOXA_GET_IQUEUE (MOXA + 1) /* get input buffered count */ -#define MOXA_GET_OQUEUE (MOXA + 2) /* get output buffered count */ -#define MOXA_GETDATACOUNT (MOXA + 23) -#define MOXA_GET_IOQUEUE (MOXA + 27) -#define MOXA_FLUSH_QUEUE (MOXA + 28) -#define MOXA_GETMSTATUS (MOXA + 65) /* * System Configuration @@ -397,19 +388,6 @@ static struct moxa_board_conf { void __iomem *intTable; } moxa_boards[MAX_BOARDS]; -struct mxser_mstatus { - tcflag_t cflag; - int cts; - int dsr; - int ri; - int dcd; -}; - -struct moxaq_str { - int inq; - int outq; -}; - struct moxa_port { struct tty_port port; struct moxa_board_conf *board; @@ -424,12 +402,6 @@ struct moxa_port { u8 lowChkFlag; }; -struct mon_str { - int tick; - int rxcnt[MAX_PORTS]; - int txcnt[MAX_PORTS]; -}; - /* statusflags */ #define TXSTOPPED 1 #define LOWWAIT 2 @@ -439,14 +411,11 @@ struct mon_str { #define WAKEUP_CHARS 256 static int ttymajor = MOXAMAJOR; -static struct mon_str moxaLog; static unsigned int moxaFuncTout = HZ / 2; static unsigned int moxaLowWaterChk; static DEFINE_MUTEX(moxa_openlock); static DEFINE_SPINLOCK(moxa_lock); -static struct tty_port moxa_service_port; - MODULE_AUTHOR("William Chen"); MODULE_DESCRIPTION("MOXA Intellio Family Multiport Board Device Driver"); MODULE_LICENSE("GPL"); @@ -557,104 +526,6 @@ static void moxa_low_water_check(void __iomem *ofsAddr) * TTY operations */ -static int moxa_ioctl(struct tty_struct *tty, - unsigned int cmd, unsigned long arg) -{ - struct moxa_port *ch = tty->driver_data; - void __user *argp = (void __user *)arg; - int status, ret = 0; - - if (tty->index == MAX_PORTS) { - if (cmd != MOXA_GETDATACOUNT && cmd != MOXA_GET_IOQUEUE && - cmd != MOXA_GETMSTATUS) - return -EINVAL; - } else if (!ch) - return -ENODEV; - - switch (cmd) { - case MOXA_GETDATACOUNT: - moxaLog.tick = jiffies; - if (copy_to_user(argp, &moxaLog, sizeof(moxaLog))) - ret = -EFAULT; - break; - case MOXA_FLUSH_QUEUE: - MoxaPortFlushData(ch, arg); - break; - case MOXA_GET_IOQUEUE: { - struct moxaq_str __user *argm = argp; - struct moxaq_str tmp; - struct moxa_port *p; - unsigned int i, j; - - for (i = 0; i < MAX_BOARDS; i++) { - p = moxa_boards[i].ports; - for (j = 0; j < MAX_PORTS_PER_BOARD; j++, p++, argm++) { - memset(&tmp, 0, sizeof(tmp)); - spin_lock_bh(&moxa_lock); - if (moxa_boards[i].ready) { - tmp.inq = MoxaPortRxQueue(p); - tmp.outq = MoxaPortTxQueue(p); - } - spin_unlock_bh(&moxa_lock); - if (copy_to_user(argm, &tmp, sizeof(tmp))) - return -EFAULT; - } - } - break; - } case MOXA_GET_OQUEUE: - status = MoxaPortTxQueue(ch); - ret = put_user(status, (unsigned long __user *)argp); - break; - case MOXA_GET_IQUEUE: - status = MoxaPortRxQueue(ch); - ret = put_user(status, (unsigned long __user *)argp); - break; - case MOXA_GETMSTATUS: { - struct mxser_mstatus __user *argm = argp; - struct mxser_mstatus tmp; - struct moxa_port *p; - unsigned int i, j; - - for (i = 0; i < MAX_BOARDS; i++) { - p = moxa_boards[i].ports; - for (j = 0; j < MAX_PORTS_PER_BOARD; j++, p++, argm++) { - struct tty_struct *ttyp; - memset(&tmp, 0, sizeof(tmp)); - spin_lock_bh(&moxa_lock); - if (!moxa_boards[i].ready) { - spin_unlock_bh(&moxa_lock); - goto copy; - } - - status = MoxaPortLineStatus(p); - spin_unlock_bh(&moxa_lock); - - if (status & 1) - tmp.cts = 1; - if (status & 2) - tmp.dsr = 1; - if (status & 4) - tmp.dcd = 1; - - ttyp = tty_port_tty_get(&p->port); - if (!ttyp) - tmp.cflag = p->cflag; - else - tmp.cflag = ttyp->termios.c_cflag; - tty_kref_put(ttyp); -copy: - if (copy_to_user(argm, &tmp, sizeof(tmp))) - return -EFAULT; - } - } - break; - } - default: - ret = -ENOIOCTLCMD; - } - return ret; -} - static int moxa_break_ctl(struct tty_struct *tty, int state) { struct moxa_port *port = tty->driver_data; @@ -671,7 +542,6 @@ static const struct tty_operations moxa_ops = { .write_room = moxa_write_room, .flush_buffer = moxa_flush_buffer, .chars_in_buffer = moxa_chars_in_buffer, - .ioctl = moxa_ioctl, .set_termios = moxa_set_termios, .stop = moxa_stop, .start = moxa_start, @@ -1283,9 +1153,7 @@ static int __init moxa_init(void) { int retval = 0; - tty_port_init(&moxa_service_port); - - moxaDriver = tty_alloc_driver(MAX_PORTS + 1, + moxaDriver = tty_alloc_driver(MAX_PORTS, TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV); if (IS_ERR(moxaDriver)) @@ -1301,8 +1169,6 @@ static int __init moxa_init(void) moxaDriver->init_termios.c_ispeed = 9600; moxaDriver->init_termios.c_ospeed = 9600; tty_set_operations(moxaDriver, &moxa_ops); - /* Having one more port only for ioctls is ugly */ - tty_port_link_device(&moxa_service_port, moxaDriver, MAX_PORTS); if (tty_register_driver(moxaDriver)) { printk(KERN_ERR "can't register MOXA Smartio tty driver!\n"); @@ -1362,9 +1228,6 @@ static int moxa_open(struct tty_struct *tty, struct file *filp) int port; port = tty->index; - if (port == MAX_PORTS) { - return capable(CAP_SYS_ADMIN) ? 0 : -EPERM; - } if (mutex_lock_interruptible(&moxa_openlock)) return -ERESTARTSYS; brd = &moxa_boards[port / MAX_PORTS_PER_BOARD]; @@ -2087,7 +1950,6 @@ static ssize_t MoxaPortWriteData(struct tty_struct *tty, const u8 *buffer, c = (head > tail) ? (head - tail - 1) : (head - tail + tx_mask); if (c > len) c = len; - moxaLog.txcnt[port->port.tty->index] += c; total = c; if (spage == epage) { bufhead = readw(ofsAddr + Ofs_txb); @@ -2129,7 +1991,6 @@ static ssize_t MoxaPortWriteData(struct tty_struct *tty, const u8 *buffer, static int MoxaPortReadData(struct moxa_port *port) { - struct tty_struct *tty = port->port.tty; void __iomem *baseAddr, *ofsAddr, *ofs; u8 *dst; unsigned int count, len, total; @@ -2148,7 +2009,6 @@ static int MoxaPortReadData(struct moxa_port *port) return 0; total = count; - moxaLog.rxcnt[tty->index] += total; if (spage == epage) { bufhead = readw(ofsAddr + Ofs_rxb); writew(spage, baseAddr + Control_reg); @@ -2236,8 +2096,6 @@ static int moxa_get_serial_info(struct tty_struct *tty, { struct moxa_port *info = tty->driver_data; - if (tty->index == MAX_PORTS) - return -EINVAL; if (!info) return -ENODEV; mutex_lock(&info->port.mutex); @@ -2257,8 +2115,6 @@ static int moxa_set_serial_info(struct tty_struct *tty, struct moxa_port *info = tty->driver_data; unsigned int close_delay; - if (tty->index == MAX_PORTS) - return -EINVAL; if (!info) return -ENODEV; From patchwork Thu Feb 20 11:15:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867868 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81F3020CCD7; Thu, 20 Feb 2025 11:16:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050205; cv=none; b=vCtIabA0HoFwpJHOgVTn/Gj/vutWTGtVhXGeGIGuv1jKLClp4Bbz1iU2LR3SjAHpQ7xBcZz2KTUZOpZEPZ8qhcbh03X0iAYYe6TcCEKkBiWXevjvrvCirWCVAHBICKD87l2l6wmqaELWK8gLSiULkfX4OC6X6gKEjVOvyMTDh34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050205; c=relaxed/simple; bh=tPBF9LP8wAH3H57CScf2FsBy11Kw5FRN6WCAO0fbggk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FAqT5/fDI91ljJ7duA/2tocNIj91tJ+Lrbpnso9Jl8opw/oagGyIy7Pl7YTxIV4xAZxg8wlhJmTgxRipJ8y/o+iUVh80EK6bLDtmDRMYnolhKqHEpoKbepXSNy72eRCZUNCWC3Gcau8/c+6Zw309QOiZ/FEVF3USOZfh7Oi9ep0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lRohVHA0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lRohVHA0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C21C6C4CED1; Thu, 20 Feb 2025 11:16:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050205; bh=tPBF9LP8wAH3H57CScf2FsBy11Kw5FRN6WCAO0fbggk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lRohVHA0aA4Ema3KugqZoT7KSj2Hw/mvfiLf7yl+6nnDvhpBHjD4kWkkwRFmIBxbp 6vpS6JgCoyo/XzMZUnwAoErbN08kaO/9qRe0bZ6veWute3WwuHpkCzLEQMzLnj3dI4 Eq6L+Agy7Psg3GMy/Jb1Cq5J/YNIVm+CcyUmKA0DPUPCOfyKcuFOCvFuXSXEIqz0ok t1LflpFIjNgPdnsLb0JYIoR5JY/Fq5H056Oblbt99t9oTg8R3y6Il1JYGN8rd0gH7T TNop/1Bqy0zkK6rQ3ysLnjj63htPtYdvp3NQDvLxhgdM7bMPCT+Y2abIOuEb6bj96K 3v5CrVmN0OO3A== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Richard Henderson , Matt Turner , linux-alpha@vger.kernel.org Subject: [PATCH 20/29] tty: srmcons: fix retval from srmcons_init() Date: Thu, 20 Feb 2025 12:15:57 +0100 Message-ID: <20250220111606.138045-21-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The value returned from srmcons_init() was -ENODEV for over 2 decades. But it does not matter, given device_initcall() ignores retvals. But to be honest, return 0 in case the tty driver was registered properly. To do that, the condition is inverted and a short path taken in case of error. err_free_drv is introduced as it will be used from more places later. Signed-off-by: Jiri Slaby (SUSE) Cc: Richard Henderson Cc: Matt Turner Cc: linux-alpha@vger.kernel.org --- arch/alpha/kernel/srmcons.c | 62 ++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c index 3e61073f4b30..b9cd364e814e 100644 --- a/arch/alpha/kernel/srmcons.c +++ b/arch/alpha/kernel/srmcons.c @@ -196,40 +196,44 @@ static const struct tty_operations srmcons_ops = { static int __init srmcons_init(void) { + struct tty_driver *driver; + int err; + timer_setup(&srmcons_singleton.timer, srmcons_receive_chars, 0); - if (srm_is_registered_console) { - struct tty_driver *driver; - int err; - - driver = tty_alloc_driver(MAX_SRM_CONSOLE_DEVICES, 0); - if (IS_ERR(driver)) - return PTR_ERR(driver); - - tty_port_init(&srmcons_singleton.port); - - driver->driver_name = "srm"; - driver->name = "srm"; - driver->major = 0; /* dynamic */ - driver->minor_start = 0; - driver->type = TTY_DRIVER_TYPE_SYSTEM; - driver->subtype = SYSTEM_TYPE_SYSCONS; - driver->init_termios = tty_std_termios; - tty_set_operations(driver, &srmcons_ops); - tty_port_link_device(&srmcons_singleton.port, driver, 0); - err = tty_register_driver(driver); - if (err) { - tty_driver_kref_put(driver); - tty_port_destroy(&srmcons_singleton.port); - return err; - } - srmcons_driver = driver; - } - return -ENODEV; + if (!srm_is_registered_console) + return -ENODEV; + + driver = tty_alloc_driver(MAX_SRM_CONSOLE_DEVICES, 0); + if (IS_ERR(driver)) + return PTR_ERR(driver); + + tty_port_init(&srmcons_singleton.port); + + driver->driver_name = "srm"; + driver->name = "srm"; + driver->major = 0; /* dynamic */ + driver->minor_start = 0; + driver->type = TTY_DRIVER_TYPE_SYSTEM; + driver->subtype = SYSTEM_TYPE_SYSCONS; + driver->init_termios = tty_std_termios; + tty_set_operations(driver, &srmcons_ops); + tty_port_link_device(&srmcons_singleton.port, driver, 0); + err = tty_register_driver(driver); + if (err) + goto err_free_drv; + + srmcons_driver = driver; + + return 0; +err_free_drv: + tty_driver_kref_put(driver); + tty_port_destroy(&srmcons_singleton.port); + + return err; } device_initcall(srmcons_init); - /* * The console driver */ From patchwork Thu Feb 20 11:15:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867062 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F24D820F062; Thu, 20 Feb 2025 11:16:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050208; cv=none; b=XxzZkHDq7Bpala8lEV/kOpC4BVFdcCv4UlJCJFVnDH+HOlzFkNuVWUXdRuaLUif4p2324Y0wnfHKYzmIHLgoHfLrm6zMzN3fphCyI1xbPJoWC5lV5nd43YmwtOWSbhgshrbiE40b5x5+qStptHxGCilvghUzVByk0c6Oxmp3z+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050208; c=relaxed/simple; bh=q06lJb7Uuv9M4Jo7kpt4iRsXe9J/IElgAndhhLU6hCE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XsA5/cztFFGpgMSRlyws0m+3MwTl8uy8DKg1qvwQEUTEtagKZtV0LLr20d1tAD4F71/O7wgU55mfWXOdZarTgn4P5YST9TY85KD8dZ4dPi2szRBHu3uP3RNP7YYyujejg95Wg9B8oDF5V1cbTpwvDfOMPASiSaXlbUJUvGbQUjQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FM0Rx13S; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FM0Rx13S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D526CC4CED1; Thu, 20 Feb 2025 11:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050207; bh=q06lJb7Uuv9M4Jo7kpt4iRsXe9J/IElgAndhhLU6hCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FM0Rx13Sebhc81c+tBWlFkcUyYPtfPmHAmp4XIhZ/iYgkyeG00jU1KeE6mbfyMfp+ Km/Zr8WcQowsJzgD5se/uJwHXaOrWD5BjX+gK704D1Wj3MPdElMOxGXPW9LZsLIqUR yvAKnAyBSBMxbQN9DeQJ5YalzTsqKtotdRbul3sbrHRyOAs9wBZyDa8vAUe8LQbtvu 94yR16gUdBQe7viUwM+29ItuLcDdL0YvdC64Td/5OI4MF0o4VfrCI66Vvqdlg8bGsB TwX1dj5TwGj8tLnXx+Tg8RmldtZztA7gNGlk9gxvdztaNnn9TBya1HxsnBqNCo1Lsc qikW9AZaaB3yw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , David Lin , Johan Hovold , Alex Elder , greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev Subject: [PATCH 21/29] tty: staging/greybus: pass tty_driver flags to tty_alloc_driver() Date: Thu, 20 Feb 2025 12:15:58 +0100 Message-ID: <20250220111606.138045-22-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 tty_alloc_driver() is supposed to receive tty driver flags. Signed-off-by: Jiri Slaby (SUSE) Cc: David Lin Cc: Johan Hovold Cc: Alex Elder Cc: greybus-dev@lists.linaro.org Cc: linux-staging@lists.linux.dev Acked-by: Johan Hovold --- drivers/staging/greybus/uart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c index 8eab94cb06fa..308ed1ca9947 100644 --- a/drivers/staging/greybus/uart.c +++ b/drivers/staging/greybus/uart.c @@ -948,7 +948,8 @@ static int gb_tty_init(void) { int retval = 0; - gb_tty_driver = tty_alloc_driver(GB_NUM_MINORS, 0); + gb_tty_driver = tty_alloc_driver(GB_NUM_MINORS, TTY_DRIVER_REAL_RAW | + TTY_DRIVER_DYNAMIC_DEV); if (IS_ERR(gb_tty_driver)) { pr_err("Can not allocate tty driver\n"); retval = -ENOMEM; @@ -961,7 +962,6 @@ static int gb_tty_init(void) gb_tty_driver->minor_start = 0; gb_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; gb_tty_driver->subtype = SERIAL_TYPE_NORMAL; - gb_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; gb_tty_driver->init_termios = tty_std_termios; gb_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; From patchwork Thu Feb 20 11:15:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867867 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E130720E701; Thu, 20 Feb 2025 11:16:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050210; cv=none; b=o8vetRAfgamaQvrK/WhzL9EMKLIOwZwm4tIgwSyVAF6YFWLRfvefbLCQKRjxhVQgVqrCjR1WTfRvva2j5hqXO9gUj/R1X/d7v78HOSZplzfw/WNEnsNQX1z8rB1//rgH7etfAQwcsuKScz9I0Uao0vNotQG8xmNR/ezSxhuFkoA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050210; c=relaxed/simple; bh=xF2pboVZNt+td4+Dy01LGUHcPKXBqMj/gvCymMZ6Lbs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e+o0Dg1tCYrnB+6gZwMVNBN/aBaWEOJ+voAR6OdREGy4XaV/ydcgRBUn33cToq/uZx1MO96W8wuEEeEaGgHOLeCYJ1CGhmHTTub/DVpXNBQphSyk19PGOjc6ivSaN42bsfhW+IX743cwsrnFcqUDN04KIYFMnIXXQKAG3IVnvk0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fTlIDxRQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fTlIDxRQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FD11C4CED1; Thu, 20 Feb 2025 11:16:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050209; bh=xF2pboVZNt+td4+Dy01LGUHcPKXBqMj/gvCymMZ6Lbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fTlIDxRQ+nXhqKrHK6FcyCgcZzydM2ABBx5hYQCuCdNHvUBXho3nG44lSS/PAc6O4 /0K355s/vcMWjbMKBoCpYfbFXJthIycSQZ9nbHv1fvgqUXkL8ekxdHq7TltjiP35JI vAf55tA7SCYiN1rNkyzCkPsJmx/TKdN5fSTKCtbukqq7YSuQFns5zukn9KKTK1u1nk X+37EE+akZ+4vLKHOnMpkAdHI5IVKkS/sV9aQzMQpa/56V7eKjoypCQ3cuDDBs8kZn iCo0kgv71xdP/EMwYsD59NSwgUtVwbwHGguodZWf8kBDVXcd8oRqZVVUJSIuSQdFDH zfpwAfXxoUwkw== 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" , sparclinux@vger.kernel.org Subject: [PATCH 22/29] tty: sunsu: drop serial_{in,out}p() Date: Thu, 20 Feb 2025 12:15:59 +0100 Message-ID: <20250220111606.138045-23-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 They are simple wrappers around serial_{in/out}() without actually pausing the execution. Since ever. So drop these useless wrappers. Signed-off-by: Jiri Slaby (SUSE) Cc: "David S. Miller" Cc: sparclinux@vger.kernel.org --- drivers/tty/serial/sunsu.c | 164 +++++++++++++++++-------------------- 1 file changed, 77 insertions(+), 87 deletions(-) diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c index 7f0fef07e141..2dc68b3201a4 100644 --- a/drivers/tty/serial/sunsu.c +++ b/drivers/tty/serial/sunsu.c @@ -150,16 +150,6 @@ static void serial_out(struct uart_sunsu_port *up, int offset, int value) } } -/* - * We used to support using pause I/O for certain machines. We - * haven't supported this for a while, but just in case it's badly - * needed for certain old 386 machines, I've left these #define's - * in.... - */ -#define serial_inp(up, offset) serial_in(up, offset) -#define serial_outp(up, offset, value) serial_out(up, offset, value) - - /* * For the 16C950 */ @@ -193,12 +183,12 @@ static int __enable_rsa(struct uart_sunsu_port *up) unsigned char mode; int result; - mode = serial_inp(up, UART_RSA_MSR); + mode = serial_in(up, UART_RSA_MSR); result = mode & UART_RSA_MSR_FIFO; if (!result) { - serial_outp(up, UART_RSA_MSR, mode | UART_RSA_MSR_FIFO); - mode = serial_inp(up, UART_RSA_MSR); + serial_out(up, UART_RSA_MSR, mode | UART_RSA_MSR_FIFO); + mode = serial_in(up, UART_RSA_MSR); result = mode & UART_RSA_MSR_FIFO; } @@ -217,7 +207,7 @@ static void enable_rsa(struct uart_sunsu_port *up) uart_port_unlock_irq(&up->port); } if (up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) - serial_outp(up, UART_RSA_FRR, 0); + serial_out(up, UART_RSA_FRR, 0); } } @@ -236,12 +226,12 @@ static void disable_rsa(struct uart_sunsu_port *up) up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) { uart_port_lock_irq(&up->port); - mode = serial_inp(up, UART_RSA_MSR); + mode = serial_in(up, UART_RSA_MSR); result = !(mode & UART_RSA_MSR_FIFO); if (!result) { - serial_outp(up, UART_RSA_MSR, mode & ~UART_RSA_MSR_FIFO); - mode = serial_inp(up, UART_RSA_MSR); + serial_out(up, UART_RSA_MSR, mode & ~UART_RSA_MSR_FIFO); + mode = serial_in(up, UART_RSA_MSR); result = !(mode & UART_RSA_MSR_FIFO); } @@ -326,7 +316,7 @@ receive_chars(struct uart_sunsu_port *up, unsigned char *status) int saw_console_brk = 0; do { - ch = serial_inp(up, UART_RX); + ch = serial_in(up, UART_RX); flag = TTY_NORMAL; up->port.icount.rx++; @@ -387,7 +377,7 @@ receive_chars(struct uart_sunsu_port *up, unsigned char *status) */ tty_insert_flip_char(port, 0, TTY_OVERRUN); ignore_char: - *status = serial_inp(up, UART_LSR); + *status = serial_in(up, UART_LSR); } while ((*status & UART_LSR_DR) && (max_count-- > 0)); if (saw_console_brk) @@ -401,7 +391,7 @@ static void transmit_chars(struct uart_sunsu_port *up) int count; if (up->port.x_char) { - serial_outp(up, UART_TX, up->port.x_char); + serial_out(up, UART_TX, up->port.x_char); up->port.icount.tx++; up->port.x_char = 0; return; @@ -460,7 +450,7 @@ static irqreturn_t sunsu_serial_interrupt(int irq, void *dev_id) uart_port_lock_irqsave(&up->port, &flags); do { - status = serial_inp(up, UART_LSR); + status = serial_in(up, UART_LSR); if (status & UART_LSR_DR) receive_chars(up, &status); check_modem_status(up); @@ -498,7 +488,7 @@ static void sunsu_change_mouse_baud(struct uart_sunsu_port *up) static void receive_kbd_ms_chars(struct uart_sunsu_port *up, int is_break) { do { - unsigned char ch = serial_inp(up, UART_RX); + unsigned char ch = serial_in(up, UART_RX); /* Stop-A is handled by drivers/char/keyboard.c now. */ if (up->su_type == SU_PORT_KBD) { @@ -530,7 +520,7 @@ static irqreturn_t sunsu_kbd_ms_interrupt(int irq, void *dev_id) struct uart_sunsu_port *up = dev_id; if (!(serial_in(up, UART_IIR) & UART_IIR_NO_INT)) { - unsigned char status = serial_inp(up, UART_LSR); + unsigned char status = serial_in(up, UART_LSR); if ((status & UART_LSR_DR) || (status & UART_LSR_BI)) receive_kbd_ms_chars(up, (status & UART_LSR_BI) != 0); @@ -619,14 +609,14 @@ static int sunsu_startup(struct uart_port *port) if (up->port.type == PORT_16C950) { /* Wake up and initialize UART */ up->acr = 0; - serial_outp(up, UART_LCR, 0xBF); - serial_outp(up, UART_EFR, UART_EFR_ECB); - serial_outp(up, UART_IER, 0); - serial_outp(up, UART_LCR, 0); + serial_out(up, UART_LCR, 0xBF); + serial_out(up, UART_EFR, UART_EFR_ECB); + serial_out(up, UART_IER, 0); + serial_out(up, UART_LCR, 0); serial_icr_write(up, UART_CSR, 0); /* Reset the UART */ - serial_outp(up, UART_LCR, 0xBF); - serial_outp(up, UART_EFR, UART_EFR_ECB); - serial_outp(up, UART_LCR, 0); + serial_out(up, UART_LCR, 0xBF); + serial_out(up, UART_EFR, UART_EFR_ECB); + serial_out(up, UART_LCR, 0); } #ifdef CONFIG_SERIAL_8250_RSA @@ -642,19 +632,19 @@ static int sunsu_startup(struct uart_port *port) * (they will be reenabled in set_termios()) */ if (uart_config[up->port.type].flags & UART_CLEAR_FIFO) { - serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO); - serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO | + serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); + serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT); - serial_outp(up, UART_FCR, 0); + serial_out(up, UART_FCR, 0); } /* * Clear the interrupt registers. */ - (void) serial_inp(up, UART_LSR); - (void) serial_inp(up, UART_RX); - (void) serial_inp(up, UART_IIR); - (void) serial_inp(up, UART_MSR); + (void) serial_in(up, UART_LSR); + (void) serial_in(up, UART_RX); + (void) serial_in(up, UART_IIR); + (void) serial_in(up, UART_MSR); /* * At this point, there's no way the LSR could still be 0xff; @@ -662,7 +652,7 @@ static int sunsu_startup(struct uart_port *port) * here. */ if (!(up->port.flags & UPF_BUGGY_UART) && - (serial_inp(up, UART_LSR) == 0xff)) { + (serial_in(up, UART_LSR) == 0xff)) { printk("ttyS%d: LSR safety check engaged!\n", up->port.line); return -ENODEV; } @@ -682,7 +672,7 @@ static int sunsu_startup(struct uart_port *port) /* * Now, initialize the UART */ - serial_outp(up, UART_LCR, UART_LCR_WLEN8); + serial_out(up, UART_LCR, UART_LCR_WLEN8); uart_port_lock_irqsave(&up->port, &flags); @@ -697,7 +687,7 @@ static int sunsu_startup(struct uart_port *port) * anyway, so we don't enable them here. */ up->ier = UART_IER_RLSI | UART_IER_RDI; - serial_outp(up, UART_IER, up->ier); + serial_out(up, UART_IER, up->ier); if (up->port.flags & UPF_FOURPORT) { unsigned int icp; @@ -712,10 +702,10 @@ static int sunsu_startup(struct uart_port *port) /* * And clear the interrupt registers again for luck. */ - (void) serial_inp(up, UART_LSR); - (void) serial_inp(up, UART_RX); - (void) serial_inp(up, UART_IIR); - (void) serial_inp(up, UART_MSR); + (void) serial_in(up, UART_LSR); + (void) serial_in(up, UART_RX); + (void) serial_in(up, UART_IIR); + (void) serial_in(up, UART_MSR); return 0; } @@ -730,7 +720,7 @@ static void sunsu_shutdown(struct uart_port *port) * Disable interrupts from this port */ up->ier = 0; - serial_outp(up, UART_IER, 0); + serial_out(up, UART_IER, 0); uart_port_lock_irqsave(&up->port, &flags); if (up->port.flags & UPF_FOURPORT) { @@ -746,11 +736,11 @@ static void sunsu_shutdown(struct uart_port *port) /* * Disable break condition and FIFOs */ - serial_out(up, UART_LCR, serial_inp(up, UART_LCR) & ~UART_LCR_SBC); - serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO | + serial_out(up, UART_LCR, serial_in(up, UART_LCR) & ~UART_LCR_SBC); + serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT); - serial_outp(up, UART_FCR, 0); + serial_out(up, UART_FCR, 0); #ifdef CONFIG_SERIAL_8250_RSA /* @@ -872,22 +862,22 @@ sunsu_change_speed(struct uart_port *port, unsigned int cflag, serial_out(up, UART_IER, up->ier); if (uart_config[up->port.type].flags & UART_STARTECH) { - serial_outp(up, UART_LCR, 0xBF); - serial_outp(up, UART_EFR, cflag & CRTSCTS ? UART_EFR_CTS :0); + serial_out(up, UART_LCR, 0xBF); + serial_out(up, UART_EFR, cflag & CRTSCTS ? UART_EFR_CTS :0); } - serial_outp(up, UART_LCR, cval | UART_LCR_DLAB);/* set DLAB */ - serial_outp(up, UART_DLL, quot & 0xff); /* LS of divisor */ - serial_outp(up, UART_DLM, quot >> 8); /* MS of divisor */ + serial_out(up, UART_LCR, cval | UART_LCR_DLAB);/* set DLAB */ + serial_out(up, UART_DLL, quot & 0xff); /* LS of divisor */ + serial_out(up, UART_DLM, quot >> 8); /* MS of divisor */ if (up->port.type == PORT_16750) - serial_outp(up, UART_FCR, fcr); /* set fcr */ - serial_outp(up, UART_LCR, cval); /* reset DLAB */ + serial_out(up, UART_FCR, fcr); /* set fcr */ + serial_out(up, UART_LCR, cval); /* reset DLAB */ up->lcr = cval; /* Save LCR */ if (up->port.type != PORT_16750) { if (fcr & UART_FCR_ENABLE_FIFO) { /* emulated UARTs (Lucent Venus 167x) need two steps */ - serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO); + serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); } - serial_outp(up, UART_FCR, fcr); /* set fcr */ + serial_out(up, UART_FCR, fcr); /* set fcr */ } up->cflag = cflag; @@ -1051,18 +1041,18 @@ static void sunsu_autoconfig(struct uart_sunsu_port *up) * 0x80 is a non-existent port; which should be safe since * include/asm/io.h also makes this assumption. */ - scratch = serial_inp(up, UART_IER); - serial_outp(up, UART_IER, 0); + scratch = serial_in(up, UART_IER); + serial_out(up, UART_IER, 0); #ifdef __i386__ outb(0xff, 0x080); #endif - scratch2 = serial_inp(up, UART_IER); - serial_outp(up, UART_IER, 0x0f); + scratch2 = serial_in(up, UART_IER); + serial_out(up, UART_IER, 0x0f); #ifdef __i386__ outb(0, 0x080); #endif - scratch3 = serial_inp(up, UART_IER); - serial_outp(up, UART_IER, scratch); + scratch3 = serial_in(up, UART_IER); + serial_out(up, UART_IER, scratch); if (scratch2 != 0 || scratch3 != 0x0F) goto out; /* We failed; there's nothing here */ } @@ -1080,16 +1070,16 @@ static void sunsu_autoconfig(struct uart_sunsu_port *up) * that conflicts with COM 1-4 --- we hope! */ if (!(up->port.flags & UPF_SKIP_TEST)) { - serial_outp(up, UART_MCR, UART_MCR_LOOP | 0x0A); - status1 = serial_inp(up, UART_MSR) & 0xF0; - serial_outp(up, UART_MCR, save_mcr); + serial_out(up, UART_MCR, UART_MCR_LOOP | 0x0A); + status1 = serial_in(up, UART_MSR) & 0xF0; + serial_out(up, UART_MCR, save_mcr); if (status1 != 0x90) goto out; /* We failed loopback test */ } - serial_outp(up, UART_LCR, 0xBF); /* set up for StarTech test */ - serial_outp(up, UART_EFR, 0); /* EFR is the same as FCR */ - serial_outp(up, UART_LCR, 0); - serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO); + serial_out(up, UART_LCR, 0xBF); /* set up for StarTech test */ + serial_out(up, UART_EFR, 0); /* EFR is the same as FCR */ + serial_out(up, UART_LCR, 0); + serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); scratch = serial_in(up, UART_IIR) >> 6; switch (scratch) { case 0: @@ -1107,19 +1097,19 @@ static void sunsu_autoconfig(struct uart_sunsu_port *up) } if (up->port.type == PORT_16550A) { /* Check for Startech UART's */ - serial_outp(up, UART_LCR, UART_LCR_DLAB); + serial_out(up, UART_LCR, UART_LCR_DLAB); if (serial_in(up, UART_EFR) == 0) { up->port.type = PORT_16650; } else { - serial_outp(up, UART_LCR, 0xBF); + serial_out(up, UART_LCR, 0xBF); if (serial_in(up, UART_EFR) == 0) up->port.type = PORT_16650V2; } } if (up->port.type == PORT_16550A) { /* Check for TI 16750 */ - serial_outp(up, UART_LCR, save_lcr | UART_LCR_DLAB); - serial_outp(up, UART_FCR, + serial_out(up, UART_LCR, save_lcr | UART_LCR_DLAB); + serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); scratch = serial_in(up, UART_IIR) >> 5; if (scratch == 7) { @@ -1129,24 +1119,24 @@ static void sunsu_autoconfig(struct uart_sunsu_port *up) * mode if the UART_FCR7_64BYTE bit was set * while UART_LCR_DLAB was latched. */ - serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO); - serial_outp(up, UART_LCR, 0); - serial_outp(up, UART_FCR, + serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); + serial_out(up, UART_LCR, 0); + serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); scratch = serial_in(up, UART_IIR) >> 5; if (scratch == 6) up->port.type = PORT_16750; } - serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO); + serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); } - serial_outp(up, UART_LCR, save_lcr); + serial_out(up, UART_LCR, save_lcr); if (up->port.type == PORT_16450) { scratch = serial_in(up, UART_SCR); - serial_outp(up, UART_SCR, 0xa5); + serial_out(up, UART_SCR, 0xa5); status1 = serial_in(up, UART_SCR); - serial_outp(up, UART_SCR, 0x5a); + serial_out(up, UART_SCR, 0x5a); status2 = serial_in(up, UART_SCR); - serial_outp(up, UART_SCR, scratch); + serial_out(up, UART_SCR, scratch); if ((status1 != 0xa5) || (status2 != 0x5a)) up->port.type = PORT_8250; @@ -1163,15 +1153,15 @@ static void sunsu_autoconfig(struct uart_sunsu_port *up) */ #ifdef CONFIG_SERIAL_8250_RSA if (up->port.type == PORT_RSA) - serial_outp(up, UART_RSA_FRR, 0); + serial_out(up, UART_RSA_FRR, 0); #endif - serial_outp(up, UART_MCR, save_mcr); - serial_outp(up, UART_FCR, (UART_FCR_ENABLE_FIFO | + serial_out(up, UART_MCR, save_mcr); + serial_out(up, UART_FCR, (UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT)); - serial_outp(up, UART_FCR, 0); + serial_out(up, UART_FCR, 0); (void)serial_in(up, UART_RX); - serial_outp(up, UART_IER, 0); + serial_out(up, UART_IER, 0); out: uart_port_unlock_irqrestore(&up->port, flags); From patchwork Thu Feb 20 11:16:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867061 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEA5A212B1F; Thu, 20 Feb 2025 11:16:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050211; cv=none; b=BibDw9QCkduzOiVajUUhtcFSj3gIQKR0sIwxaDN23iZiCSXDeJCwRuImo1JTL2ALfGl7NFf/B+rLI8WMk6cvKayXhvOewQ+oLVcSskfJhhd8Ws401RYkqMJPkeTycN6kE92aWPq9qpMXwGPSJ8WgFSiDIFTvjX8AZWQU14TXsV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050211; c=relaxed/simple; bh=nZIkuJjMtnyrI9ew1aqrnJpKE9/wdKdxSn4kFieyw2c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y1UhE7kDcYQLTnm+7gbPU/qY6FsrfTdQOLgz8/FypPopHv6jMmOozkj5XaogzDqi2JTaaMJGK86/pT705BMWfd57PL1O7XQMTh/5GSHgimmv5pXICZm6k6YB4PTV/tb6DPCLe7PHwVsyO0XuhROMX1H6LSqlaRD9J+ZgmJNsVto= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VgQ/lWkG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VgQ/lWkG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 356C3C4CEE3; Thu, 20 Feb 2025 11:16:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050211; bh=nZIkuJjMtnyrI9ew1aqrnJpKE9/wdKdxSn4kFieyw2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VgQ/lWkG9sGpiuSDUa3pXetNFATsu9YPLjw/2n3/XmGguMe6CLUr3L/fKDTvWvGMY yO4ltLQy5OeltFDudR9z3wmQI+fPCEGqJyieyFm1YhjjGS9taegzyDoDe/4t3BJvYZ qLN4GEuYAuqYFb937mMt7q/OopIQvZVYIXB+RJ30fKctMoFVt7xGY/QVihU/6OR4Qt pvGS/LgNl2Cq6bPOYKtByz6n0Fpr9P8mwjnB7zbDIxHNYw+gq3w84f6y4sL8NAZw8P 921l+qaPrJNn7o95ABm09dSpOCU525WMx4IPd0icHMEkVbtT18JdngoEcC2ZoGzPUI Ey4EnaV1VRkQQ== 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" , sparclinux@vger.kernel.org Subject: [PATCH 23/29] tty: sunsu: remove unused serial_icr_read() Date: Thu, 20 Feb 2025 12:16:00 +0100 Message-ID: <20250220111606.138045-24-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It is commented and never used. Signed-off-by: Jiri Slaby (SUSE) Cc: "David S. Miller" Cc: sparclinux@vger.kernel.org --- drivers/tty/serial/sunsu.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c index 2dc68b3201a4..383141fe7ba0 100644 --- a/drivers/tty/serial/sunsu.c +++ b/drivers/tty/serial/sunsu.c @@ -159,20 +159,6 @@ static void serial_icr_write(struct uart_sunsu_port *up, int offset, int value) serial_out(up, UART_ICR, value); } -#if 0 /* Unused currently */ -static unsigned int serial_icr_read(struct uart_sunsu_port *up, int offset) -{ - unsigned int value; - - serial_icr_write(up, UART_ACR, up->acr | UART_ACR_ICRRD); - serial_out(up, UART_SCR, offset); - value = serial_in(up, UART_ICR); - serial_icr_write(up, UART_ACR, up->acr); - - return value; -} -#endif - #ifdef CONFIG_SERIAL_8250_RSA /* * Attempts to turn on the RSA FIFO. Returns zero on failure. From patchwork Thu Feb 20 11:16:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867866 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5173D213220; Thu, 20 Feb 2025 11:16:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050213; cv=none; b=E18V/4xTYr5mj2xf4cT2bPuqHuXeHxJJBAd2LPEl19SFajmAXS2We6gZbeUMFqXugSWD8RDt2nHgQf/7GIEwKvGwKXOw6g5o+Okx0y6mQrB9bOaw6ty/nEwkq/cK+GFJJb4XHZWTP2zSH5LoiBL4B4RhNiAGfTIZyX7ehHvziTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050213; c=relaxed/simple; bh=JJKCDyoUI49ul5goAoSRKGA9x8DCTFWq3J5//jDxDjQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fam0+Jpr1jWVPOJd7q9WVw3hErzg2fnw3JIHh494YMP1VoQ/SnPSs2YyG8hxoz+q2Jd39QK6/Refkm8MnukuYqZuMZ/9CokMoKLfAND0eqPModxDiQBVG1wD0cU2odfFlzNPzyskFM5DpkU7lbib0smUwfN7gE8BVsVpp/hThEQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UMdWy1gp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UMdWy1gp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C0FCC4CEDD; Thu, 20 Feb 2025 11:16:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050213; bh=JJKCDyoUI49ul5goAoSRKGA9x8DCTFWq3J5//jDxDjQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UMdWy1gpn32bSWxPGo3mySZvFZ2rRlzYQAJMQfSCLL9xKO/j//hBnlEMjwmKV2/Iq Lph/8bGB8TPXIrvVUt+rjQ0KZzQQa6Ubt9xHK5jNLvfHvmOg+S8/zeuI9NB3uHP8ua jXMCtWrUtSKUCK6nKfHkMXzkyLz7hQIjYrP1SLvcLFGQGyoSAxInrbUsSqSmggp2tQ W5acqCUgFiG7YsV2254jVzIpi5Q80yZEM6irvvqoVwbLs9wQ4JRiG/tLeOZU2l5Wwk wYc4EjLI0SZCDx8dgwBv5VgmCyRsm6yATkapcalI+Rr+fwxsa9qLnUUDKW7gMsZy9f Rh5CvRuH9cGzw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 24/29] serial: remove redundant tty_port_link_device() Date: Thu, 20 Feb 2025 12:16:01 +0100 Message-ID: <20250220111606.138045-25-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The linking is done implicitly by tty_port_register_device_attr_serdev() few lines below. So drop this explicit tty_port_link_device(). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/serial/serial_core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f24d8edf1bee..2a6453891801 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3156,7 +3156,6 @@ static int serial_core_add_one_port(struct uart_driver *drv, struct uart_port *u if (uport->cons && uport->dev) of_console_check(uport->dev->of_node, uport->cons->name, uport->line); - tty_port_link_device(port, drv->tty_driver, uport->line); uart_configure_port(drv, state, uport); port->console = uart_console(uport); From patchwork Thu Feb 20 11:16:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867060 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D38DD1F583B; Thu, 20 Feb 2025 11:16:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050214; cv=none; b=XHdQLHvtgMHOX7yrQYVmtj7NDDfLtpBwPNpQOs74df4UG/t1Q1d8aBkV5gWmcG5hkmEZgj69l6tcghwQYGstWx9mAyFZ8WFPGZLbzSUKC4QUi1qVAY/BwuHQHB0yKTFLhBUQC7F6+PZH2jQPWTzf8pUGQN342v1YyoWqANjN4+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050214; c=relaxed/simple; bh=0qLHAAL+353m1Ju7cnS1kMjUN4v4Ya2R2cFuwY/DLvU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ooaUW6NmpU/+x/totXUjpRkPWOxZ4qpmDwQFAlOkt8G/86NMlH71tLJG9IEryPLTW7rf9g47VyHACFEow3VTSg/rSP5ZlVxlyaEz5ltbbRnOZ4wu4xk0oqi7DrnfEqPyGfyCl/7t2DMDtr2JrzUu+1pjcSIHZEitZOfj+Rsf5wA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rRlYCPHD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rRlYCPHD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5DD2C4CED1; Thu, 20 Feb 2025 11:16:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050214; bh=0qLHAAL+353m1Ju7cnS1kMjUN4v4Ya2R2cFuwY/DLvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rRlYCPHDVmppWoly1Y0GQT5Ef5Agm6+dSC7J2/cvFqc4ZSxQ7+UiQVltohDS/Iezq pNxgCMDKQ2MjqMJ6gh1eVZ60jvav1vHiHUN5DCIFQhQeHKaXBMzH6LcL3eAXA/Rfet BnM//Shikh7GhiI1ILnZcweCNYqNk01ETET7RRxti/RP61DIwrySEzsH2LXjoH7Un4 /PaOHfXCvn4CiAXVXMyjy2HeIOB4cn5CaaXq/ALmOdc7IwUTGoLLNFZY+yvPJ8IuPY CjVlL/EnyT7LGwUmasPwAncK1dZusJqJo8PIQXIyJ2jeAQeeXA/c9bMeUr30FovUSd Z5r6Y0X7ObzTQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 25/29] serial: pass struct uart_state to uart_line_info() Date: Thu, 20 Feb 2025 12:16:02 +0100 Message-ID: <20250220111606.138045-26-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 uart_line_info() wants to work with struct uart_state. Do not pass a driver and an index. Pass the precomputed struct directly. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/serial/serial_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 2a6453891801..04eaa24ed153 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2013,9 +2013,8 @@ static const char *uart_type(struct uart_port *port) #ifdef CONFIG_PROC_FS -static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i) +static void uart_line_info(struct seq_file *m, struct uart_state *state) { - struct uart_state *state = drv->state + i; struct tty_port *port = &state->port; enum uart_pm_state pm_state; struct uart_port *uport; @@ -2100,7 +2099,7 @@ static int uart_proc_show(struct seq_file *m, void *v) seq_printf(m, "serinfo:1.0 driver%s%s revision:%s\n", "", "", ""); for (i = 0; i < drv->nr; i++) - uart_line_info(m, drv, i); + uart_line_info(m, drv->state + i); return 0; } #endif From patchwork Thu Feb 20 11:16:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867865 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8D9E213E62; Thu, 20 Feb 2025 11:16:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050216; cv=none; b=O9sDQhtGTeqwxQOUpHKIMgsT76F1Iuax2wW6zlbLfKhaUFYDR8OF4Y4yOZnuGN0mwTMSCKJAvO+FgTv5hSKgpW8w2HSvyPfziHfWTjylLSG9Hji/BLPZMto5yljxj6ffcPGu5gbX0Q5r0pxFYeWPPD+oP/Ai167lVTPowBXFhm0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050216; c=relaxed/simple; bh=/Eg4ergRjLpzswoDlZwSe78LJCFnUOArT/6Zkrq+FBw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CMhY4tdJ7cMI1RNGDSp7asTHrz1Vw0iTDDreXdVvK6vmDD//QlC5uX22lm6H63EXvKXsc2pIaixCch4cUAN40fgkE+lnxu07x+gHPZZknIAWIiKfj5RBdYqWhmCJ7aHJ0zjEHj4sXJ6truetadb4SfLwbde2b8sJ/rTW0+7X/2Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XF3VdaOE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XF3VdaOE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 316E0C4CEDD; Thu, 20 Feb 2025 11:16:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050216; bh=/Eg4ergRjLpzswoDlZwSe78LJCFnUOArT/6Zkrq+FBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XF3VdaOEtn5vXpbnnAtlHsyPYNOXFbs1MQbwUs5QptorQM3U+G9ZETRcwOoiIZzO6 keS8+OyUK4dmiBmDyT1VJKGxJgfLyXurbrgPk4jS9koVkDRglTEGnynwwRwLeEZsbO ZAXeyy6lxpv0YqXza90lF0BXkpClbOC7KXuEK+LD1KVusVYThGv4qmwd1iMRW7i2Ug 0UjL7ozzdfQsgmbDe660bDlxjbRCXE6K+T7Wy/ohOsrgBzTd2Pp50nywlKHpVxSAn4 H7L7kYg4tCgvD+whqk/EThndf0Nn3mY4Atwsg2/ogZCb29tC3VBbFsFqBMtfLeW0NG emk9ytb7Prh0Q== 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_J=C3=A4rvinen?= , Andy Shevchenko Subject: [PATCH 26/29] serial: 8250: use serial_in/out() helpers Date: Thu, 20 Feb 2025 12:16:03 +0100 Message-ID: <20250220111606.138045-27-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There are serial_in/out() helpers to be used instead of direct p->serial_in/out(). Use them in various 8250 drivers. Signed-off-by: Jiri Slaby (SUSE) Cc: "Ilpo Järvinen" Cc: Andy Shevchenko --- drivers/tty/serial/8250/8250_dw.c | 17 +++++++++-------- drivers/tty/serial/8250/8250_fsl.c | 8 ++++---- drivers/tty/serial/8250/8250_omap.c | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index af24ec25d976..d0abbdd630ac 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -120,16 +120,17 @@ static void dw8250_force_idle(struct uart_port *p) * enabled. */ if (up->fcr & UART_FCR_ENABLE_FIFO) { - lsr = p->serial_in(p, UART_LSR); + lsr = serial_in(up, UART_LSR); if (!(lsr & UART_LSR_DR)) return; } - (void)p->serial_in(p, UART_RX); + serial_in(up, UART_RX); } static void dw8250_check_lcr(struct uart_port *p, int offset, int value) { + struct uart_8250_port *up = up_to_u8250p(p); struct dw8250_data *d = to_dw8250_data(p->private_data); void __iomem *addr = p->membase + (offset << p->regshift); int tries = 1000; @@ -139,7 +140,7 @@ static void dw8250_check_lcr(struct uart_port *p, int offset, int value) /* Make sure LCR write wasn't ignored */ while (tries--) { - unsigned int lcr = p->serial_in(p, offset); + unsigned int lcr = serial_in(up, offset); if ((value & ~UART_LCR_SPAR) == (lcr & ~UART_LCR_SPAR)) return; @@ -260,7 +261,7 @@ static int dw8250_handle_irq(struct uart_port *p) { struct uart_8250_port *up = up_to_u8250p(p); struct dw8250_data *d = to_dw8250_data(p->private_data); - unsigned int iir = p->serial_in(p, UART_IIR); + unsigned int iir = serial_in(up, UART_IIR); bool rx_timeout = (iir & 0x3f) == UART_IIR_RX_TIMEOUT; unsigned int quirks = d->pdata->quirks; unsigned int status; @@ -281,7 +282,7 @@ static int dw8250_handle_irq(struct uart_port *p) status = serial_lsr_in(up); if (!(status & (UART_LSR_DR | UART_LSR_BI))) - (void) p->serial_in(p, UART_RX); + serial_in(up, UART_RX); uart_port_unlock_irqrestore(p, flags); } @@ -303,7 +304,7 @@ static int dw8250_handle_irq(struct uart_port *p) if ((iir & UART_IIR_BUSY) == UART_IIR_BUSY) { /* Clear the USR */ - (void)p->serial_in(p, d->pdata->usr_reg); + serial_in(up, d->pdata->usr_reg); return 1; } @@ -390,7 +391,7 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios, static void dw8250_set_ldisc(struct uart_port *p, struct ktermios *termios) { struct uart_8250_port *up = up_to_u8250p(p); - unsigned int mcr = p->serial_in(p, UART_MCR); + unsigned int mcr = serial_in(up, UART_MCR); if (up->capabilities & UART_CAP_IRDA) { if (termios->c_line == N_IRDA) @@ -398,7 +399,7 @@ static void dw8250_set_ldisc(struct uart_port *p, struct ktermios *termios) else mcr &= ~DW_UART_MCR_SIRE; - p->serial_out(p, UART_MCR, mcr); + serial_out(up, UART_MCR, mcr); } serial8250_do_set_ldisc(p, termios); } diff --git a/drivers/tty/serial/8250/8250_fsl.c b/drivers/tty/serial/8250/8250_fsl.c index 1b7bd55619c6..df8f846f3d54 100644 --- a/drivers/tty/serial/8250/8250_fsl.c +++ b/drivers/tty/serial/8250/8250_fsl.c @@ -32,7 +32,7 @@ int fsl8250_handle_irq(struct uart_port *port) uart_port_lock_irqsave(&up->port, &flags); - iir = port->serial_in(port, UART_IIR); + iir = serial_in(up, UART_IIR); if (iir & UART_IIR_NO_INT) { uart_port_unlock_irqrestore(&up->port, flags); return 0; @@ -54,12 +54,12 @@ int fsl8250_handle_irq(struct uart_port *port) if (unlikely((iir & UART_IIR_ID) == UART_IIR_RLSI && (up->lsr_saved_flags & UART_LSR_BI))) { up->lsr_saved_flags &= ~UART_LSR_BI; - port->serial_in(port, UART_RX); + serial_in(up, UART_RX); uart_port_unlock_irqrestore(&up->port, flags); return 1; } - lsr = orig_lsr = up->port.serial_in(&up->port, UART_LSR); + lsr = orig_lsr = serial_in(up, UART_LSR); /* Process incoming characters first */ if ((lsr & (UART_LSR_DR | UART_LSR_BI)) && @@ -71,7 +71,7 @@ int fsl8250_handle_irq(struct uart_port *port) if ((orig_lsr & UART_LSR_OE) && (up->overrun_backoff_time_ms > 0)) { unsigned long delay; - up->ier = port->serial_in(port, UART_IER); + up->ier = serial_in(up, UART_IER); if (up->ier & (UART_IER_RLSI | UART_IER_RDI)) { port->ops->stop_rx(port); } else { diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c index c2b75e3f106d..16610782258e 100644 --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -692,7 +692,7 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id) /* Synchronize UART_IER access against the console. */ uart_port_lock(port); - up->ier = port->serial_in(port, UART_IER); + up->ier = serial_in(up, UART_IER); if (up->ier & (UART_IER_RLSI | UART_IER_RDI)) { port->ops->stop_rx(port); } else { From patchwork Thu Feb 20 11:16:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867059 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 481FD213E7B; Thu, 20 Feb 2025 11:16:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050218; cv=none; b=IvkkcOgci+pi/1/X5tTLcJEVS34+Tf7HqlXZ6AmGMmEt7wMOIYazML57LO0hEGX7UXFkzia9RsEkxtUS8ZVhGuS+JeGD/jI2mVaMAVwW7Trm+Ygp6xiu86TYIvfXft6bDT6tIqc68yAHtQI3xV/9aojVtekPBam/o1YvjJQHPAo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050218; c=relaxed/simple; bh=IGzAUF8EE1dXcvd38v4OtwuOD4neh/Voi1jl6jZSCRM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nNw1MZ8JKrgp8qrLR9dTDxwZgkdWjyZ2MZ4AfDuQVbZN4yW5kObDx6UYZtACh22tAX0xhho7Cj9xd/rRj+mt6aQWAfru5q7BmE1Jd6ckkgflda0rjZgjT9fZXhGc5IZx47jj1J6bwYzEwC0cvD1yQAvesP/KjwxMSjQNkU5+mdE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ARkkX2GA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ARkkX2GA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17C89C4CEDD; Thu, 20 Feb 2025 11:16:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050218; bh=IGzAUF8EE1dXcvd38v4OtwuOD4neh/Voi1jl6jZSCRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ARkkX2GAACaWzLK4e5Du4JcoS2M1eAVSjvf4ctniB+H05B9ihhVKLDKItjKWFuDac 9lqOVyJLJCWUFz+5jGSB1kxOsJC6804TkHGWLpqkgHH74oG97vRM0HdNGk3Url6oKe +jOOPA1iF0Ojx/rdgUUV1a2p9vl0rl3AwhiZ155w7sugBzm5kqsD+ebPZrMkP60OjL VDO/foN1eBL/xoFsy9q7kDASkclpnc2aEgguNjeYWJN+LZPS5XMY738187JapMHRsM xOM14Q0NasC1fFwu8g2rIU9qcJi+Yy0w8uVqi8Il+5QgH5hviDsDfp8os8mzAmKsRO CSIz29ZxokmvA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 27/29] serial: 8250_rsa: simplify rsa8250_{request/release}_resource() Date: Thu, 20 Feb 2025 12:16:04 +0100 Message-ID: <20250220111606.138045-28-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 * Use already defined 'port' for fetching start/offset, and size. * Return from the switch immediately -- so it is clear what is returned and when. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/serial/8250/8250_rsa.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/8250/8250_rsa.c b/drivers/tty/serial/8250/8250_rsa.c index dfaa613e452d..82f2593b4c59 100644 --- a/drivers/tty/serial/8250/8250_rsa.c +++ b/drivers/tty/serial/8250/8250_rsa.c @@ -16,30 +16,27 @@ static unsigned int probe_rsa_count; static int rsa8250_request_resource(struct uart_8250_port *up) { - unsigned long start = UART_RSA_BASE << up->port.regshift; - unsigned int size = 8 << up->port.regshift; struct uart_port *port = &up->port; - int ret = -EINVAL; + unsigned long start = UART_RSA_BASE << port->regshift; + unsigned int size = 8 << port->regshift; switch (port->iotype) { case UPIO_HUB6: case UPIO_PORT: start += port->iobase; - if (request_region(start, size, "serial-rsa")) - ret = 0; - else - ret = -EBUSY; - break; + if (!request_region(start, size, "serial-rsa")) + return -EBUSY; + return 0; + default: + return -EINVAL; } - - return ret; } static void rsa8250_release_resource(struct uart_8250_port *up) { - unsigned long offset = UART_RSA_BASE << up->port.regshift; - unsigned int size = 8 << up->port.regshift; struct uart_port *port = &up->port; + unsigned long offset = UART_RSA_BASE << port->regshift; + unsigned int size = 8 << port->regshift; switch (port->iotype) { case UPIO_HUB6: From patchwork Thu Feb 20 11:16:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867864 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A7191F63C1; Thu, 20 Feb 2025 11:16:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050220; cv=none; b=IqxY1fC6R9YlSEZbBAh401lIIvvoXg2avPP8YKVyOGggkIPcTdwtg5vZGnCPJ7dY4tGz0onsChDVj8KQs53r+T7g7x7EoewktFVdntMCSUYvOGAE+UVpcVIVPxdDfMX0+mTldAdDIHUERA1HJKKUUYuy3wxUdxZBrWjDQtPs40c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050220; c=relaxed/simple; bh=cs498CI6MfOXxYxsHGXoAGXOl9jBzyPtxRhMChIkLog=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aM63PFkynGpOL+51DNetewnfQQI46iq6PO+LkSQHNYuX2pb9YKejE/DZU3PaFaT3wX1VaF1JSFRnDn9Ux4pu9Hk47Hr8jvd5StfCNtMsMy4uLhu4j5oZl16G7+gwzlj/fOHTOYqqjFM0ubWBB/SNktzAUSbR5agZyiO2WzZshwk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=G3oS2zol; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="G3oS2zol" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 985F2C4CEDD; Thu, 20 Feb 2025 11:16:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050219; bh=cs498CI6MfOXxYxsHGXoAGXOl9jBzyPtxRhMChIkLog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G3oS2zolXmJS0u9KZq/ubJtOXMJUbNJ5fRGlo0mG2h166Pb5uqvb4dasm+piTFRzu BksoG7hWN5gvW4217Z5pWO6l9PsniumWc3kNsDHcLho1szGsfkheQZjPGK5Hp9Abgq Z/VxdF1z5DnHKh5Scws04GoBQ/ZwvLYCulx3tp8hrgSGQ1EhnABiX5qxJ5c1XNhxE3 qRtJaES9MF0EK9olHxjxVEsPXjvapXpSnMdmSVcVLqPnHomZqVxY344A8rI96otfvH 78Xeii+/vAeg5o9ov2TSog4Vii7oiNFQtNF15iuT7eIzCtL9+nonT+hEkWeoXwpzTj pYRODblt9Uosg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 28/29] serial: 8250_port: do not use goto for UPQ_NO_TXEN_TEST code flow Date: Thu, 20 Feb 2025 12:16:05 +0100 Message-ID: <20250220111606.138045-29-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This is unnecessary here and makes the code harder to follow. Invert the condition and drop the goto+label. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/serial/8250/8250_port.c | 34 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index c57f44882abb..4ac5f16fc6ba 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -2406,28 +2406,26 @@ int serial8250_do_startup(struct uart_port *port) * test if we receive TX irq. This way, we'll never enable * UART_BUG_TXEN. */ - if (up->port.quirks & UPQ_NO_TXEN_TEST) - goto dont_test_tx_en; - - /* - * Do a quick test to see if we receive an interrupt when we enable - * the TX irq. - */ - serial_port_out(port, UART_IER, UART_IER_THRI); - lsr = serial_port_in(port, UART_LSR); - iir = serial_port_in(port, UART_IIR); - serial_port_out(port, UART_IER, 0); + if (!(up->port.quirks & UPQ_NO_TXEN_TEST)) { + /* + * Do a quick test to see if we receive an interrupt when we + * enable the TX irq. + */ + serial_port_out(port, UART_IER, UART_IER_THRI); + lsr = serial_port_in(port, UART_LSR); + iir = serial_port_in(port, UART_IIR); + serial_port_out(port, UART_IER, 0); - if (lsr & UART_LSR_TEMT && iir & UART_IIR_NO_INT) { - if (!(up->bugs & UART_BUG_TXEN)) { - up->bugs |= UART_BUG_TXEN; - dev_dbg(port->dev, "enabling bad tx status workarounds\n"); + if (lsr & UART_LSR_TEMT && iir & UART_IIR_NO_INT) { + if (!(up->bugs & UART_BUG_TXEN)) { + up->bugs |= UART_BUG_TXEN; + dev_dbg(port->dev, "enabling bad tx status workarounds\n"); + } + } else { + up->bugs &= ~UART_BUG_TXEN; } - } else { - up->bugs &= ~UART_BUG_TXEN; } -dont_test_tx_en: uart_port_unlock_irqrestore(port, flags); /* From patchwork Thu Feb 20 11:16:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 867058 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1C63214202; Thu, 20 Feb 2025 11:17:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050221; cv=none; b=AEdynTniCwSEz99zYD5e9tL3BVKMhAo4+22xs1NvIYnRB0ExUSM1Gz60W0RYR//teRJCP5O8wYbH9mYHYO0RQWlm6vFioaiofuP6AP3ki27C8p3Of3bJQk/q2IpQxqQTMGeKbn8xdYd2E7sYZ9p1fvSUWuVST1SV651hEMRm8Us= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740050221; c=relaxed/simple; bh=+OYhCfT+9b/1AYLBMmVjAFt2OwPjTFnmUdRU9VwqAXw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eP3nJKRlROhKcjVqa1PGknvpN+WakCwfNk2YyiGG4VcsI6ij385yDLj+Pfs79jf9Dt1TEabc07QHK9qLkvWT0bcjN2T+VkYRhuMYG+ip2d3pm1KAx4gz3HfkScKZnO0YGU1o5xIAFf/e1ClhpNTmW78NWwpRwjPy2rfET/aMWus= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k+hiskTP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="k+hiskTP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24F1EC4CEE3; Thu, 20 Feb 2025 11:16:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740050221; bh=+OYhCfT+9b/1AYLBMmVjAFt2OwPjTFnmUdRU9VwqAXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k+hiskTPjYfYeeAOzQOZRXmrokWo8ZeMM0WQJO2LQSwzPz7Hkwjn3YBZkr3FZ/NuM 5T0+nXBk5eOFcZCPq3Set7+HDM4kjsNVFQgjgnNpbOpSjfTAfMLTNZFynJ9ujubYc2 sKXNONRKGwSKCZiC4wIctLW/DENknqvuRiFIROYg3r3vR/gw3uE/RCfblhdMGSNjfj MM/aADyihIGnQNqmhJp1YYKQODw2zZjvg8jeHqAJJciR5XBvUU4R0eCx/EO4sDNTV8 FzzX5sLBxoXY/inNRR+F/oPRcJVdLaPoMopOPOWt+5SUJkNjiiwGgwWKlWV7+KpYT/ oV9e6Q1F21ShA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 29/29] serial: 8250_port: simplify serial8250_request_std_resource() Date: Thu, 20 Feb 2025 12:16:06 +0100 Message-ID: <20250220111606.138045-30-jirislaby@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org> References: <20250220111606.138045-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Return immediately from the error locations or switch-case ends. It is therefore easier to see the flow. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/serial/8250/8250_port.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 4ac5f16fc6ba..caf4e2ec74bd 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -2966,7 +2966,6 @@ static int serial8250_request_std_resource(struct uart_8250_port *up) { unsigned int size = serial8250_port_size(up); struct uart_port *port = &up->port; - int ret = 0; switch (port->iotype) { case UPIO_AU: @@ -2975,32 +2974,28 @@ static int serial8250_request_std_resource(struct uart_8250_port *up) case UPIO_MEM32BE: case UPIO_MEM16: case UPIO_MEM: - if (!port->mapbase) { - ret = -EINVAL; - break; - } + if (!port->mapbase) + return -EINVAL; - if (!request_mem_region(port->mapbase, size, "serial")) { - ret = -EBUSY; - break; - } + if (!request_mem_region(port->mapbase, size, "serial")) + return -EBUSY; if (port->flags & UPF_IOREMAP) { port->membase = ioremap(port->mapbase, size); if (!port->membase) { release_mem_region(port->mapbase, size); - ret = -ENOMEM; + return -ENOMEM; } } - break; - + return 0; case UPIO_HUB6: case UPIO_PORT: if (!request_region(port->iobase, size, "serial")) - ret = -EBUSY; - break; + return -EBUSY; + return 0; } - return ret; + + return 0; } static void serial8250_release_std_resource(struct uart_8250_port *up)