Linux-Serial Archive mirror
 help / color / mirror / Atom feed
From: Esa Laakso <fidelix.laakso@gmail.com>
To: gregkh@linuxfoundation.org, jirislaby@kernel.org,
	linux-serial@vger.kernel.org
Cc: kari.argillander@gmail.com, linux-kernel@vger.kernel.org,
	Esa Laakso <esa.laakso@fidelix.com>,
	Esa Laakso <fidelix.laakso@gmail.com>
Subject: [PATCH RFC] pty: Add parity enabling routine
Date: Thu, 18 Apr 2024 15:43:49 +0300	[thread overview]
Message-ID: <20240418124349.26289-1-esa.laakso@fidelix.com> (raw)

There are some cases where parity selection is required for passing
it forward to a virtualized terminal. In this sepcific use-case, we
want to use pty to send and receive serial data to a serial
multiplexer. By using a pty, we avoid writing a custom tty driver.

There is very little evidence on the reasoning on why this option is
hard-coded to be disabled. AFAIK it has been as such since 1996. With
the lack of information about why this is, and based on the fact there
are other similar fields that are not hard-coded, it is considered safe
to enable this option.

Still, in order not to be too intrusive about the change, add it only on
the condition that the termios flag `EXTPROC` is turned on. This way
there is very little chance it will cause any unintended problems in any
other implementation.

Signed-off-by: Esa Laakso <esa.laakso@fidelix.com>
Signed-off-by: Esa Laakso <fidelix.laakso@gmail.com>
---

We are looking for some assistance on this patch, or just a green light
to submit it, if it is good to go.

We would need to know if the change is valid in context of pty, as
there seems to be fairly little information about the reasoning behind
the hard-coded values.

Our guess is that they have been as such forever and nobody has had a
reason to change them. We have a reason to change them, and we would
like to know if it is safe to do so and possibly contribute in the
process. Either by just using the patch for ourselves or submitting
it here.

For the record, this is my first patch submitted upstream. Please let
me know if something is incorrect or missing.
---

 drivers/tty/pty.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 07394fdaf522..e2d9718dcea0 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -267,7 +267,9 @@ static void pty_set_termios(struct tty_struct *tty,
 		}
 	}
 
-	tty->termios.c_cflag &= ~(CSIZE | PARENB);
+	tty->termios.c_cflag &= ~(CSIZE);
+	if (!L_EXTPROC(tty))
+		tty->termios.c_cflag &= ~(PARENB);
 	tty->termios.c_cflag |= (CS8 | CREAD);
 }
 
-- 
2.35.3


             reply	other threads:[~2024-04-18 12:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-18 12:43 Esa Laakso [this message]
2024-04-18 12:53 ` [PATCH RFC] pty: Add parity enabling routine Greg KH
2024-04-18 13:46   ` Esa Laakso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240418124349.26289-1-esa.laakso@fidelix.com \
    --to=fidelix.laakso@gmail.com \
    --cc=esa.laakso@fidelix.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=kari.argillander@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).