All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] serial: 8250: Add helper for clearing IER
@ 2022-08-16 12:07 Ilpo Järvinen
  2022-08-18  7:18 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Ilpo Järvinen @ 2022-08-16 12:07 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, linux-serial, linux-kernel
  Cc: Ilpo Järvinen

A number of places want to clear IER with the same CAP_UUE trick.
Create a helper for that.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/serial/8250/8250_port.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 39b35a61958c..25e4761e3c57 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -752,6 +752,14 @@ static void serial8250_set_sleep(struct uart_8250_port *p, int sleep)
 	serial8250_rpm_put(p);
 }
 
+static void serial8250_clear_IER(struct uart_8250_port *up)
+{
+	if (up->capabilities & UART_CAP_UUE)
+		serial_out(up, UART_IER, UART_IER_UUE);
+	else
+		serial_out(up, UART_IER, 0);
+}
+
 #ifdef CONFIG_SERIAL_8250_RSA
 /*
  * Attempts to turn on the RSA FIFO.  Returns zero on failure.
@@ -1329,10 +1337,7 @@ static void autoconfig(struct uart_8250_port *up)
 	serial8250_out_MCR(up, save_mcr);
 	serial8250_clear_fifos(up);
 	serial_in(up, UART_RX);
-	if (up->capabilities & UART_CAP_UUE)
-		serial_out(up, UART_IER, UART_IER_UUE);
-	else
-		serial_out(up, UART_IER, 0);
+	serial8250_clear_IER(up);
 
 out_unlock:
 	spin_unlock_irqrestore(&port->lock, flags);
@@ -2142,10 +2147,7 @@ static void serial8250_put_poll_char(struct uart_port *port,
 	 *	First save the IER then disable the interrupts
 	 */
 	ier = serial_port_in(port, UART_IER);
-	if (up->capabilities & UART_CAP_UUE)
-		serial_port_out(port, UART_IER, UART_IER_UUE);
-	else
-		serial_port_out(port, UART_IER, 0);
+	serial8250_clear_IER(up);
 
 	wait_for_xmitr(up, UART_LSR_BOTH_EMPTY);
 	/*
@@ -3383,11 +3385,7 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s,
 	 *	First save the IER then disable the interrupts
 	 */
 	ier = serial_port_in(port, UART_IER);
-
-	if (up->capabilities & UART_CAP_UUE)
-		serial_port_out(port, UART_IER, UART_IER_UUE);
-	else
-		serial_port_out(port, UART_IER, 0);
+	serial8250_clear_IER(up);
 
 	/* check scratch reg to see if port powered off during system sleep */
 	if (up->canary && (up->canary != serial_port_in(port, UART_SCR))) {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] serial: 8250: Add helper for clearing IER
  2022-08-16 12:07 [PATCH 1/1] serial: 8250: Add helper for clearing IER Ilpo Järvinen
@ 2022-08-18  7:18 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2022-08-18  7:18 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Greg Kroah-Hartman, Jiri Slaby, open list:SERIAL DRIVERS,
	Linux Kernel Mailing List

On Tue, Aug 16, 2022 at 3:14 PM Ilpo Järvinen
<ilpo.jarvinen@linux.intel.com> wrote:
>
> A number of places want to clear IER with the same CAP_UUE trick.
> Create a helper for that.

No objections,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
>  drivers/tty/serial/8250/8250_port.c | 24 +++++++++++-------------
>  1 file changed, 11 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
> index 39b35a61958c..25e4761e3c57 100644
> --- a/drivers/tty/serial/8250/8250_port.c
> +++ b/drivers/tty/serial/8250/8250_port.c
> @@ -752,6 +752,14 @@ static void serial8250_set_sleep(struct uart_8250_port *p, int sleep)
>         serial8250_rpm_put(p);
>  }
>
> +static void serial8250_clear_IER(struct uart_8250_port *up)
> +{
> +       if (up->capabilities & UART_CAP_UUE)
> +               serial_out(up, UART_IER, UART_IER_UUE);
> +       else
> +               serial_out(up, UART_IER, 0);
> +}
> +
>  #ifdef CONFIG_SERIAL_8250_RSA
>  /*
>   * Attempts to turn on the RSA FIFO.  Returns zero on failure.
> @@ -1329,10 +1337,7 @@ static void autoconfig(struct uart_8250_port *up)
>         serial8250_out_MCR(up, save_mcr);
>         serial8250_clear_fifos(up);
>         serial_in(up, UART_RX);
> -       if (up->capabilities & UART_CAP_UUE)
> -               serial_out(up, UART_IER, UART_IER_UUE);
> -       else
> -               serial_out(up, UART_IER, 0);
> +       serial8250_clear_IER(up);
>
>  out_unlock:
>         spin_unlock_irqrestore(&port->lock, flags);
> @@ -2142,10 +2147,7 @@ static void serial8250_put_poll_char(struct uart_port *port,
>          *      First save the IER then disable the interrupts
>          */
>         ier = serial_port_in(port, UART_IER);
> -       if (up->capabilities & UART_CAP_UUE)
> -               serial_port_out(port, UART_IER, UART_IER_UUE);
> -       else
> -               serial_port_out(port, UART_IER, 0);
> +       serial8250_clear_IER(up);
>
>         wait_for_xmitr(up, UART_LSR_BOTH_EMPTY);
>         /*
> @@ -3383,11 +3385,7 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s,
>          *      First save the IER then disable the interrupts
>          */
>         ier = serial_port_in(port, UART_IER);
> -
> -       if (up->capabilities & UART_CAP_UUE)
> -               serial_port_out(port, UART_IER, UART_IER_UUE);
> -       else
> -               serial_port_out(port, UART_IER, 0);
> +       serial8250_clear_IER(up);
>
>         /* check scratch reg to see if port powered off during system sleep */
>         if (up->canary && (up->canary != serial_port_in(port, UART_SCR))) {
> --
> 2.30.2
>


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-18  7:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-16 12:07 [PATCH 1/1] serial: 8250: Add helper for clearing IER Ilpo Järvinen
2022-08-18  7:18 ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.