public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: Lino Sanfilippo <LinoSanfilippo@gmx.de>,
	gregkh@linuxfoundation.org, u.kleine-koenig@pengutronix.de
Cc: linux-arm-kernel@lists.infradead.org,
	alexandre.belloni@bootlin.com, mcoquelin.stm32@gmail.com,
	richard.genoud@gmail.com, festevam@gmail.com,
	s.hauer@pengutronix.de, linux@armlinux.org.uk,
	alexandre.torgue@foss.st.com, ludovic.desroches@microchip.com,
	lukas@wunner.de, linux-imx@nxp.com, kernel@pengutronix.de,
	linux-serial@vger.kernel.org, shawnguo@kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-kernel@vger.kernel.org, p.rosenberger@kunbus.com
Subject: Re: [PATCH v3 1/9] serial: core: move RS485 configuration tasks from drivers into core
Date: Tue, 22 Feb 2022 07:51:39 +0100	[thread overview]
Message-ID: <e883ccb5-68ea-f802-e4fd-864672d8ad7b@kernel.org> (raw)
In-Reply-To: <20220222011433.8761-2-LinoSanfilippo@gmx.de>

On 22. 02. 22, 2:14, Lino Sanfilippo wrote:
> Several drivers that support setting the RS485 configuration via userspace
> implement one or more of the following tasks:
> 
> - in case of an invalid RTS configuration (both RTS after send and RTS on
>    send set or both unset) fall back to enable RTS on send and disable RTS
>    after send
> 
> - nullify the padding field of the returned serial_rs485 struct
> 
> - copy the configuration into the uart port struct
> 
> - limit RTS delays to 100 ms
> 
> Move these tasks into the serial core to make them generic and to provide
> a consistent behaviour among all drivers.
> 
> Signed-off-by: Lino Sanfilippo <LinoSanfilippo@gmx.de>
> ---
>   drivers/tty/serial/serial_core.c | 29 +++++++++++++++++++++++++++++
>   1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index 846192a7b4bf..2b3afe038c1c 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -42,6 +42,11 @@ static struct lock_class_key port_lock_key;
>   
>   #define HIGH_BITS_OFFSET	((sizeof(long)-sizeof(int))*8)
>   
> +/*
> + * Max time with active RTS before/after data is sent.
> + */
> +#define RS485_MAX_RTS_DELAY	100 /* msecs */
> +
>   static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
>   					struct ktermios *old_termios);
>   static void uart_wait_until_sent(struct tty_struct *tty, int timeout);
> @@ -1282,8 +1287,32 @@ static int uart_set_rs485_config(struct uart_port *port,
>   	if (copy_from_user(&rs485, rs485_user, sizeof(*rs485_user)))
>   		return -EFAULT;
>   
> +	/* pick sane settings if the user hasn't */
> +	if (!(rs485.flags & SER_RS485_RTS_ON_SEND) ==
> +	    !(rs485.flags & SER_RS485_RTS_AFTER_SEND)) {
> +		pr_warn("invalid RTS setting, using RTS_ON_SEND instead\n");

Can't we have a device prefix here, so that everyone knows what device 
is affected? Without that, it's not that useful. At least port->name & 
port->line could be printed. The uart core uses dev_* prints, but prints 
also line as uport->dev can be NULL sometimes.

Hm, we could introduce uart_print family (to print something like what 
is in uart_report_port).

thanks,
-- 
js
suse labs

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-02-22  6:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22  1:14 Move RS485 implementation from drivers to serial core (v3) Lino Sanfilippo
2022-02-22  1:14 ` [PATCH v3 1/9] serial: core: move RS485 configuration tasks from drivers into core Lino Sanfilippo
2022-02-22  6:51   ` Jiri Slaby [this message]
2022-02-22  6:52     ` Jiri Slaby
2022-02-25 10:16       ` Aw: " Lino Sanfilippo
2022-02-22  1:14 ` [PATCH v3 2/9] serial: amba-pl011: remove redundant code in rs485_config Lino Sanfilippo
2022-02-22  1:14 ` [PATCH v3 3/9] serial: stm32: " Lino Sanfilippo
2022-02-22  1:14 ` [PATCH v3 4/9] serial: sc16is7xx: remove redundant check " Lino Sanfilippo
2022-02-22  1:14 ` [PATCH v3 5/9] serial: omap: remove redundant code " Lino Sanfilippo
2022-02-22  1:14 ` [PATCH v3 6/9] serial: max310: remove redundant memset " Lino Sanfilippo
2022-02-22  1:14 ` [PATCH v3 7/9] serial: imx: remove redundant assignment " Lino Sanfilippo
2022-02-22  1:14 ` [PATCH v3 8/9] serial: fsl_lpuart: remove redundant code in rs485_config functions Lino Sanfilippo
2022-02-22  1:14 ` [PATCH v3 9/9] serial: atmel: remove redundant assignment in rs485_config Lino Sanfilippo

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=e883ccb5-68ea-f802-e4fd-864672d8ad7b@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=LinoSanfilippo@gmx.de \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=festevam@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux@armlinux.org.uk \
    --cc=ludovic.desroches@microchip.com \
    --cc=lukas@wunner.de \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=p.rosenberger@kunbus.com \
    --cc=richard.genoud@gmail.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /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