From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Subject: [PATCH 3/5] serial: fsl_lpuart: Remove custom frame size calculation
Date: Thu, 25 Aug 2022 11:58:08 +0300 [thread overview]
Message-ID: <20220825085810.7290-4-ilpo.jarvinen@linux.intel.com> (raw)
In-Reply-To: <20220825085810.7290-1-ilpo.jarvinen@linux.intel.com>
The number of bits can be calculated using tty_get_frame_size(), no
need for the driver to do it on its own.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/tty/serial/fsl_lpuart.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index f6c33cd228c8..926460f1dc08 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -1284,23 +1284,19 @@ static inline int lpuart_start_rx_dma(struct lpuart_port *sport)
struct dma_slave_config dma_rx_sconfig = {};
struct circ_buf *ring = &sport->rx_ring;
int ret, nent;
- int bits, baud;
+ int baud;
struct tty_port *port = &sport->port.state->port;
struct tty_struct *tty = port->tty;
struct ktermios *termios = &tty->termios;
struct dma_chan *chan = sport->dma_rx_chan;
baud = tty_get_baud_rate(tty);
-
- bits = (termios->c_cflag & CSIZE) == CS7 ? 9 : 10;
- if (termios->c_cflag & PARENB)
- bits++;
-
/*
* Calculate length of one DMA buffer size to keep latency below
* 10ms at any baud rate.
*/
- sport->rx_dma_rng_buf_len = (DMA_RX_TIMEOUT * baud / bits / 1000) * 2;
+ sport->rx_dma_rng_buf_len = (DMA_RX_TIMEOUT * baud / tty_get_frame_size(termios->c_cflag) /
+ 1000) * 2;
sport->rx_dma_rng_buf_len = (1 << (fls(sport->rx_dma_rng_buf_len) - 1));
if (sport->rx_dma_rng_buf_len < 16)
sport->rx_dma_rng_buf_len = 16;
--
2.30.2
next prev parent reply other threads:[~2022-08-25 8:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-25 8:58 [PATCH 0/5] serial: " Ilpo Järvinen
2022-08-25 8:58 ` [PATCH 1/5] serial: ucc_uart: " Ilpo Järvinen
2022-08-25 8:58 ` [PATCH 2/5] serial: cpm_uart: " Ilpo Järvinen
2022-08-26 15:53 ` Andy Shevchenko
2022-08-25 8:58 ` Ilpo Järvinen [this message]
2022-08-26 15:56 ` [PATCH 3/5] serial: fsl_lpuart: " Andy Shevchenko
2022-08-25 8:58 ` [PATCH 4/5] serial: sunsab: Remove frame size calculation dead-code Ilpo Järvinen
2022-08-25 8:58 ` [PATCH 5/5] serial: tegra: Remove custom frame size calculation Ilpo Järvinen
2022-08-26 15:58 ` [PATCH 0/5] serial: " Andy Shevchenko
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=20220825085810.7290-4-ilpo.jarvinen@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--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
all inboxes | Powered by JetHome®