From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Jiri Slaby <jslaby@suse.cz>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
linux-serial <linux-serial@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
"Tobias Klauser" <tklauser@distanz.ch>,
"Richard Genoud" <richard.genoud@gmail.com>,
"Nicolas Ferre" <nicolas.ferre@microchip.com>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Claudiu Beznea" <claudiu.beznea@microchip.com>,
"Vladimir Zapolskiy" <vz@mleia.com>,
"Liviu Dudau" <liviu.dudau@arm.com>,
"Sudeep Holla" <sudeep.holla@arm.com>,
"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
"Shawn Guo" <shawnguo@kernel.org>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
"NXP Linux Team" <linux-imx@nxp.com>,
"Andreas Färber" <afaerber@suse.de>,
"Manivannan Sadhasivam" <mani@kernel.org>
Subject: Re: [PATCH v2 2/3] tty: serial: use DEFINE_UART_PORT_TX_HELPER()
Date: Fri, 2 Sep 2022 17:21:14 +0300 (EEST) [thread overview]
Message-ID: <89b44cd-6550-32b2-9bd-ae8dde6b48cd@linux.intel.com> (raw)
In-Reply-To: <20220901110657.3305-3-jslaby@suse.cz>
[-- Attachment #1: Type: text/plain, Size: 4882 bytes --]
On Thu, 1 Sep 2022, Jiri Slaby wrote:
> DEFINE_UART_PORT_TX_HELPER() is a new helper to send characters to the
> device. Use it in these drivers.
>
> Cc: Tobias Klauser <tklauser@distanz.ch>
> Cc: Richard Genoud <richard.genoud@gmail.com>
> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Claudiu Beznea <claudiu.beznea@microchip.com>
> Cc: Vladimir Zapolskiy <vz@mleia.com>
> Cc: Liviu Dudau <liviu.dudau@arm.com>
> Cc: Sudeep Holla <sudeep.holla@arm.com>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Shawn Guo <shawnguo@kernel.org>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: NXP Linux Team <linux-imx@nxp.com>
> Cc: "Andreas Färber" <afaerber@suse.de>
> Cc: Manivannan Sadhasivam <mani@kernel.org>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> ---
> diff --git a/drivers/tty/serial/mpc52xx_uart.c b/drivers/tty/serial/mpc52xx_uart.c
> index 3f1986c89694..944686a0d00d 100644
> --- a/drivers/tty/serial/mpc52xx_uart.c
> +++ b/drivers/tty/serial/mpc52xx_uart.c
> @@ -1338,7 +1338,6 @@ mpc52xx_uart_verify_port(struct uart_port *port, struct serial_struct *ser)
> return 0;
> }
>
> -
> static const struct uart_ops mpc52xx_uart_ops = {
> .tx_empty = mpc52xx_uart_tx_empty,
> .set_mctrl = mpc52xx_uart_set_mctrl,
Stray change.
> diff --git a/drivers/tty/serial/sa1100.c b/drivers/tty/serial/sa1100.c
> index e64e42a19d1a..738f4b20cb8e 100644
> --- a/drivers/tty/serial/sa1100.c
> +++ b/drivers/tty/serial/sa1100.c
> @@ -226,45 +226,34 @@ sa1100_rx_chars(struct sa1100_port *sport)
> tty_flip_buffer_push(&sport->port.state->port);
> }
>
> -static void sa1100_tx_chars(struct sa1100_port *sport)
> +static bool sa1100_tx_ready(struct uart_port *port)
> {
> - struct circ_buf *xmit = &sport->port.state->xmit;
> + struct sa1100_port *sport =
> + container_of(port, struct sa1100_port, port);
>
> - if (sport->port.x_char) {
> - UART_PUT_CHAR(sport, sport->port.x_char);
> - sport->port.icount.tx++;
> - sport->port.x_char = 0;
> - return;
> - }
> + return UART_GET_UTSR1(sport) & UTSR1_TNF;
> +}
> +
> +static void sa1100_put_char(struct uart_port *port, unsigned char ch)
> +{
> + struct sa1100_port *sport =
> + container_of(port, struct sa1100_port, port);
> +
> + UART_PUT_CHAR(sport, ch);
> +}
Perhaps not to add into this change itself, but I just point out these
would be useful in addition to what is changed:
- Get rid of UART_PUT_CHAR()
- sa1100_console_putchar() could use sa1100_tx_ready()
> diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c
> index 6f08136ce78a..ff430a1cc3a2 100644
> --- a/drivers/tty/serial/vt8500_serial.c
> +++ b/drivers/tty/serial/vt8500_serial.c
> @@ -187,37 +187,17 @@ static void handle_rx(struct uart_port *port)
> tty_flip_buffer_push(tport);
> }
>
> -static void handle_tx(struct uart_port *port)
> +static unsigned int vt8500_tx_empty(struct uart_port *port)
> {
> - struct circ_buf *xmit = &port->state->xmit;
> -
> - if (port->x_char) {
> - writeb(port->x_char, port->membase + VT8500_TXFIFO);
> - port->icount.tx++;
> - port->x_char = 0;
> - }
> - if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
> - vt8500_stop_tx(port);
> - return;
> - }
> + unsigned int idx = vt8500_read(port, VT8500_URFIDX) & 0x1f;
>
> - while ((vt8500_read(port, VT8500_URFIDX) & 0x1f) < 16) {
> - if (uart_circ_empty(xmit))
> - break;
> -
> - writeb(xmit->buf[xmit->tail], port->membase + VT8500_TXFIFO);
> -
> - xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
> - port->icount.tx++;
> - }
> -
> - if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
> - uart_write_wakeup(port);
> -
> - if (uart_circ_empty(xmit))
> - vt8500_stop_tx(port);
> + return idx < 16 ? TIOCSER_TEMT : 0;
> }
So there's just plain move and re-layouting of existing vt8500_tx_empty()
embedded here. Why not do it in a separate change beforehand?
I discovered this the hard way, that is, I started to look why tx on
earth "FIFO index" < 16 should be called "tx empty", if it would be a
separate change it would have been immediately obvious that it was a
pre-existing thing.
> +static DEFINE_UART_PORT_TX_HELPER(handle_tx, port, ch,
> + vt8500_tx_empty(port),
> + writeb(ch, port->membase + VT8500_TXFIFO));
> +
> static void vt8500_start_tx(struct uart_port *port)
> {
> struct vt8500_port *vt8500_port = container_of(port,
> @@ -260,12 +240,6 @@ static irqreturn_t vt8500_irq(int irq, void *dev_id)
> return IRQ_HANDLED;
> }
>
> -static unsigned int vt8500_tx_empty(struct uart_port *port)
> -{
> - return (vt8500_read(port, VT8500_URFIDX) & 0x1f) < 16 ?
> - TIOCSER_TEMT : 0;
> -}
> -
> static unsigned int vt8500_get_mctrl(struct uart_port *port)
> {
> unsigned int usr;
>
--
i.
next prev parent reply other threads:[~2022-09-02 14:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-01 11:06 [PATCH v2 0/3] tty: TX helpers Jiri Slaby
2022-09-01 11:06 ` [PATCH v2 1/3] tty: serial: introduce transmit helper generators Jiri Slaby
2022-09-01 12:25 ` Greg KH
2022-09-02 5:16 ` Jiri Slaby
2022-09-02 5:23 ` Greg KH
2022-09-02 8:02 ` Jiri Slaby
2022-09-02 10:22 ` Ilpo Järvinen
2022-09-02 10:24 ` Jiri Slaby
2022-09-01 11:06 ` [PATCH v2 2/3] tty: serial: use DEFINE_UART_PORT_TX_HELPER() Jiri Slaby
2022-09-02 14:21 ` Ilpo Järvinen [this message]
2022-09-06 10:50 ` Jiri Slaby
2022-09-01 11:06 ` [PATCH v2 3/3] tty: serial: use DEFINE_UART_PORT_TX_HELPER_LIMITED() Jiri Slaby
2022-09-02 14:56 ` Ilpo Järvinen
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=89b44cd-6550-32b2-9bd-ae8dde6b48cd@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=afaerber@suse.de \
--cc=alexandre.belloni@bootlin.com \
--cc=claudiu.beznea@microchip.com \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.cz \
--cc=kernel@pengutronix.de \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=lorenzo.pieralisi@arm.com \
--cc=mani@kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=richard.genoud@gmail.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=sudeep.holla@arm.com \
--cc=tklauser@distanz.ch \
--cc=vz@mleia.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;
as well as URLs for NNTP newsgroup(s).