Linux Serial subsystem development
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Sean Anderson <sean.anderson@seco.com>
Cc: Peter Korsgaard <peter.korsgaard@barco.com>,
	Peter Korsgaard <peter@korsgaard.com>,
	linux-serial@vger.kernel.org,
	Alexander Sverdlin <alexander.sverdlin@nokia.com>,
	Michal Simek <michal.simek@xilinx.com>
Subject: Re: [PATCH 5/5] tty: serial: uartlite: Prevent changing fixed parameters
Date: Thu, 29 Jul 2021 17:01:52 +0200	[thread overview]
Message-ID: <YQLC4L2Z3T4SuryE@kroah.com> (raw)
In-Reply-To: <20210723223152.648326-6-sean.anderson@seco.com>

On Fri, Jul 23, 2021 at 06:31:51PM -0400, Sean Anderson wrote:
> This device does not support changing baud, parity, data bits, stop
> bits, or detecting breaks. Disable "changing" these settings to prevent
> their termios from diverging from the actual state of the uart. To inform
> users of these limitations, warn if the new termios change these
> parameters. We only do this once to avoid spamming the log. These
> warnings are inspired by those in the sifive driver.
> 
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
> 
>  drivers/tty/serial/uartlite.c | 52 +++++++++++++++++++++++++++++++++--
>  1 file changed, 49 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
> index 39c17ab206ca..0aed70039f46 100644
> --- a/drivers/tty/serial/uartlite.c
> +++ b/drivers/tty/serial/uartlite.c
> @@ -314,7 +314,54 @@ static void ulite_set_termios(struct uart_port *port, struct ktermios *termios,
>  			      struct ktermios *old)
>  {
>  	unsigned long flags;
> -	unsigned int baud;
> +	struct uartlite_data *pdata = port->private_data;
> +	tcflag_t old_cflag;
> +
> +	if (termios->c_iflag & BRKINT)
> +		dev_err_once(port->dev, "BREAK detection not supported\n");
> +	termios->c_iflag &= ~BRKINT;
> +
> +	if (termios->c_cflag & CSTOPB)
> +		dev_err_once(port->dev, "only one stop bit supported\n");
> +	termios->c_cflag &= ~CSTOPB;
> +
> +	old_cflag = termios->c_cflag;
> +	termios->c_cflag &= ~(PARENB | PARODD);
> +	if (pdata->parity == 'e')
> +		termios->c_cflag |= PARENB;
> +	else if (pdata->parity == 'o')
> +		termios->c_cflag |= PARENB | PARODD;
> +
> +	if (termios->c_cflag != old_cflag)
> +		dev_err_once(port->dev, "only '%c' parity supported\n",
> +			     pdata->parity);

Through all of this, you are warning that nothing is supported, yet you
are continuing on as if all of this worked just fine.

That feels odd, why is this needed at all?  If you really do not support
any changes here, why even fake it?

thanks,

greg k-h

  reply	other threads:[~2021-07-29 15:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-23 22:31 [PATCH 0/5] tty: serial: uartlite: Disable changing fixed parameters Sean Anderson
2021-07-23 22:31 ` [PATCH 1/5] dt-bindings: serial: uartlite: Convert to json-schema Sean Anderson
2021-07-23 22:31 ` [PATCH 2/5] dt-bindings: serial: uartlite: Add properties for synthesis-time parameters Sean Anderson
2021-07-26 12:30   ` Michal Simek
2021-07-26 15:16     ` Sean Anderson
2021-07-23 22:31 ` [PATCH 3/5] sh: j2: Update uartlite binding with data and parity properties Sean Anderson
2021-07-23 22:31 ` [PATCH 4/5] tty: serial: uartlite: Initialize termios with fixed synthesis parameters Sean Anderson
2021-07-26 20:53   ` Sean Anderson
2021-07-29 15:02     ` Greg Kroah-Hartman
2021-07-23 22:31 ` [PATCH 5/5] tty: serial: uartlite: Prevent changing fixed parameters Sean Anderson
2021-07-29 15:01   ` Greg Kroah-Hartman [this message]
2021-07-29 15:26     ` Sean Anderson
2021-07-29 15:32       ` Greg Kroah-Hartman
2021-07-29 15:43         ` Sean Anderson
2021-07-30  5:25           ` Greg Kroah-Hartman
2021-07-30 15:33             ` Sean Anderson
2021-08-09  8:58             ` Maarten Brock
2021-07-26 14:19 ` [PATCH 0/5] tty: serial: uartlite: Disable " Michal Simek

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=YQLC4L2Z3T4SuryE@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=alexander.sverdlin@nokia.com \
    --cc=linux-serial@vger.kernel.org \
    --cc=michal.simek@xilinx.com \
    --cc=peter.korsgaard@barco.com \
    --cc=peter@korsgaard.com \
    --cc=sean.anderson@seco.com \
    /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