mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Martin Kepplinger <martin.kepplinger@ginzinger.com>,
	gregkh@linuxfoundation.org, robh+dt@kernel.org,
	mark.rutland@arm.com, jslaby@suse.com, corbet@lwn.net,
	richard.genoud@gmail.com, nicolas.ferre@microchip.com,
	alexandre.belloni@bootlin.com, ludovic.desroches@microchip.com,
	mcoquelin.stm32@gmail.com, alexandre.torgue@st.com,
	linux-serial@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-stm32@st-md-mailman.stormreply.com
Cc: linux-kernel@vger.kernel.org, kernel@pengutronix.de
Subject: Re: [PATCH v2 4/9] serial: 8250: add support for rs485 RTS delays in microseconds
Date: Fri, 29 Mar 2019 15:36:33 +0100	[thread overview]
Message-ID: <fbafc165-e637-8041-e88d-f4aabe690422@pengutronix.de> (raw)
In-Reply-To: <20190221171758.10322-4-martin.kepplinger@ginzinger.com>

On 21/2/19 18:17, Martin Kepplinger wrote:
> Read struct serial_rs485's flag SER_RS485_DELAY_IN_USEC and apply the delay
> accordingly.
> 
> Signed-off-by: Martin Kepplinger <martin.kepplinger@ginzinger.com>
> ---
>  drivers/tty/serial/8250/8250_omap.c | 13 +++++++++++--
>  drivers/tty/serial/8250/8250_port.c | 25 +++++++++++++++++++++----
>  2 files changed, 32 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
> index 0a8316632d75..cbce43ac60b1 100644
> --- a/drivers/tty/serial/8250/8250_omap.c
> +++ b/drivers/tty/serial/8250/8250_omap.c
> @@ -720,8 +720,17 @@ static int omap_8250_rs485_config(struct uart_port *port,
>  	struct uart_8250_port *up = up_to_u8250p(port);
>  
>  	/* Clamp the delays to [0, 100ms] */
> -	rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U);
> -	rs485->delay_rts_after_send  = min(rs485->delay_rts_after_send, 100U);
> +	if (rs485->flags & SER_RS485_DELAY_IN_USEC) {
> +		rs485->delay_rts_before_send = min(rs485->delay_rts_before_send,
> +						   100000U);
> +		rs485->delay_rts_after_send  = min(rs485->delay_rts_after_send,
> +						   100000U);
> +	} else {
> +		rs485->delay_rts_before_send = min(rs485->delay_rts_before_send,
> +						   100U);
> +		rs485->delay_rts_after_send  = min(rs485->delay_rts_after_send,
> +						   100U);
> +	}
>  
>  	port->rs485 = *rs485;
>  
> diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
> index d2f3310abe54..0cee4aa8323d 100644
> --- a/drivers/tty/serial/8250/8250_port.c
> +++ b/drivers/tty/serial/8250/8250_port.c
> @@ -1483,6 +1483,15 @@ static void start_hrtimer_ms(struct hrtimer *hrt, unsigned long msec)
>  	hrtimer_start(hrt, t, HRTIMER_MODE_REL);
>  }
>  
> +static void start_hrtimer_us(struct hrtimer *hrt, unsigned long usec)
> +{
> +	long sec = usec / 1000000;
> +	long nsec = (usec % 1000000) * 1000000000;

This 1e9 should be 1000 ("NSEC_PER_USEC").
While at it you might want to use USEC_PER_SEC (and MSEC_PER_SEC
above) to make the code more readable.

Cheers
Ahmad

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2019-03-29 14:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-21 17:17 [PATCH v2 1/9] serial: uapi: add SER_RS485_DELAY_IN_USEC flag to struct serial_rs485 Martin Kepplinger
2019-02-21 17:17 ` [PATCH v2 2/9] Documentation: serial-rs485: document SER_RS485_DELAY_IN_USEC flag Martin Kepplinger
2019-02-21 17:17 ` [PATCH v2 3/9] serial: core: add rs485-rts-delay-us devicetree property for RS485 Martin Kepplinger
2019-02-22 23:44   ` Rob Herring
2019-02-21 17:17 ` [PATCH v2 4/9] serial: 8250: add support for rs485 RTS delays in microseconds Martin Kepplinger
2019-03-29 14:36   ` Ahmad Fatoum [this message]
2019-02-21 17:17 ` [PATCH v2 5/9] serial: omap-serial: " Martin Kepplinger
2019-02-21 17:17 ` [PATCH v2 6/9] serial: sc16is7xx: " Martin Kepplinger
2019-02-21 17:17 ` [PATCH v2 7/9] serial: atmel_serial: set SER_RS485_DELAY_IN_USEC accordingly Martin Kepplinger
2019-02-21 17:17 ` [PATCH v2 8/9] serial: fsl_lpuart: " Martin Kepplinger
2019-02-21 17:17 ` [PATCH v2 9/9] serial: st32-usart: " Martin Kepplinger
2019-03-08  7:36 ` [PATCH v2 1/9] serial: uapi: add SER_RS485_DELAY_IN_USEC flag to struct serial_rs485 Martin Kepplinger

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=fbafc165-e637-8041-e88d-f4aabe690422@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alexandre.torgue@st.com \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=ludovic.desroches@microchip.com \
    --cc=mark.rutland@arm.com \
    --cc=martin.kepplinger@ginzinger.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=nicolas.ferre@microchip.com \
    --cc=richard.genoud@gmail.com \
    --cc=robh+dt@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

all inboxes | Powered by JetHome®