All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] tty/serial: atmel: Use uart_console() helper
@ 2020-03-10 13:30 Andy Shevchenko
  2020-03-10 16:40 ` Richard Genoud
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2020-03-10 13:30 UTC (permalink / raw)
  To: Richard Genoud, linux-serial, Greg Kroah-Hartman; +Cc: Andy Shevchenko

Use uart_console() helper in instead of open coded variant.

Note, SERIAL_CORE_CONSOLE is selected by SERIAL_ATMEL_CONSOLE,
thus no functional changes expected.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/atmel_serial.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 187987a5b707..53b1d135f53b 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -2640,18 +2640,8 @@ static struct console atmel_console = {
 
 #define ATMEL_CONSOLE_DEVICE	(&atmel_console)
 
-static inline bool atmel_is_console_port(struct uart_port *port)
-{
-	return port->cons && port->cons->index == port->line;
-}
-
 #else
 #define ATMEL_CONSOLE_DEVICE	NULL
-
-static inline bool atmel_is_console_port(struct uart_port *port)
-{
-	return false;
-}
 #endif
 
 static struct uart_driver atmel_uart = {
@@ -2680,14 +2670,14 @@ static int atmel_serial_suspend(struct platform_device *pdev,
 	struct uart_port *port = platform_get_drvdata(pdev);
 	struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
 
-	if (atmel_is_console_port(port) && console_suspend_enabled) {
+	if (uart_console(port) && console_suspend_enabled) {
 		/* Drain the TX shifter */
 		while (!(atmel_uart_readl(port, ATMEL_US_CSR) &
 			 ATMEL_US_TXEMPTY))
 			cpu_relax();
 	}
 
-	if (atmel_is_console_port(port) && !console_suspend_enabled) {
+	if (uart_console(port) && !console_suspend_enabled) {
 		/* Cache register values as we won't get a full shutdown/startup
 		 * cycle
 		 */
@@ -2723,7 +2713,7 @@ static int atmel_serial_resume(struct platform_device *pdev)
 	struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
 	unsigned long flags;
 
-	if (atmel_is_console_port(port) && !console_suspend_enabled) {
+	if (uart_console(port) && !console_suspend_enabled) {
 		atmel_uart_writel(port, ATMEL_US_MR, atmel_port->cache.mr);
 		atmel_uart_writel(port, ATMEL_US_IER, atmel_port->cache.imr);
 		atmel_uart_writel(port, ATMEL_US_BRGR, atmel_port->cache.brgr);
@@ -2877,7 +2867,7 @@ static int atmel_serial_probe(struct platform_device *pdev)
 		goto err_add_port;
 
 #ifdef CONFIG_SERIAL_ATMEL_CONSOLE
-	if (atmel_is_console_port(&atmel_port->uart)
+	if (uart_console(&atmel_port->uart)
 			&& ATMEL_CONSOLE_DEVICE->flags & CON_ENABLED) {
 		/*
 		 * The serial core enabled the clock for us, so undo
@@ -2920,7 +2910,7 @@ static int atmel_serial_probe(struct platform_device *pdev)
 	kfree(atmel_port->rx_ring.buf);
 	atmel_port->rx_ring.buf = NULL;
 err_alloc_ring:
-	if (!atmel_is_console_port(&atmel_port->uart)) {
+	if (!uart_console(&atmel_port->uart)) {
 		clk_put(atmel_port->clk);
 		atmel_port->clk = NULL;
 	}
-- 
2.25.1


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

* Re: [PATCH v1] tty/serial: atmel: Use uart_console() helper
  2020-03-10 13:30 [PATCH v1] tty/serial: atmel: Use uart_console() helper Andy Shevchenko
@ 2020-03-10 16:40 ` Richard Genoud
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Genoud @ 2020-03-10 16:40 UTC (permalink / raw)
  To: Andy Shevchenko, linux-serial, Greg Kroah-Hartman

Le 10/03/2020 à 14:30, Andy Shevchenko a écrit :
> Use uart_console() helper in instead of open coded variant.
> 
> Note, SERIAL_CORE_CONSOLE is selected by SERIAL_ATMEL_CONSOLE,
> thus no functional changes expected.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Richard Genoud <richard.genoud@gmail.com>

> ---
>  drivers/tty/serial/atmel_serial.c | 20 +++++---------------
>  1 file changed, 5 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index 187987a5b707..53b1d135f53b 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -2640,18 +2640,8 @@ static struct console atmel_console = {
>  
>  #define ATMEL_CONSOLE_DEVICE	(&atmel_console)
>  
> -static inline bool atmel_is_console_port(struct uart_port *port)
> -{
> -	return port->cons && port->cons->index == port->line;
> -}
> -
>  #else
>  #define ATMEL_CONSOLE_DEVICE	NULL
> -
> -static inline bool atmel_is_console_port(struct uart_port *port)
> -{
> -	return false;
> -}
>  #endif
>  
>  static struct uart_driver atmel_uart = {
> @@ -2680,14 +2670,14 @@ static int atmel_serial_suspend(struct platform_device *pdev,
>  	struct uart_port *port = platform_get_drvdata(pdev);
>  	struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
>  
> -	if (atmel_is_console_port(port) && console_suspend_enabled) {
> +	if (uart_console(port) && console_suspend_enabled) {
>  		/* Drain the TX shifter */
>  		while (!(atmel_uart_readl(port, ATMEL_US_CSR) &
>  			 ATMEL_US_TXEMPTY))
>  			cpu_relax();
>  	}
>  
> -	if (atmel_is_console_port(port) && !console_suspend_enabled) {
> +	if (uart_console(port) && !console_suspend_enabled) {
>  		/* Cache register values as we won't get a full shutdown/startup
>  		 * cycle
>  		 */
> @@ -2723,7 +2713,7 @@ static int atmel_serial_resume(struct platform_device *pdev)
>  	struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
>  	unsigned long flags;
>  
> -	if (atmel_is_console_port(port) && !console_suspend_enabled) {
> +	if (uart_console(port) && !console_suspend_enabled) {
>  		atmel_uart_writel(port, ATMEL_US_MR, atmel_port->cache.mr);
>  		atmel_uart_writel(port, ATMEL_US_IER, atmel_port->cache.imr);
>  		atmel_uart_writel(port, ATMEL_US_BRGR, atmel_port->cache.brgr);
> @@ -2877,7 +2867,7 @@ static int atmel_serial_probe(struct platform_device *pdev)
>  		goto err_add_port;
>  
>  #ifdef CONFIG_SERIAL_ATMEL_CONSOLE
> -	if (atmel_is_console_port(&atmel_port->uart)
> +	if (uart_console(&atmel_port->uart)
>  			&& ATMEL_CONSOLE_DEVICE->flags & CON_ENABLED) {
>  		/*
>  		 * The serial core enabled the clock for us, so undo
> @@ -2920,7 +2910,7 @@ static int atmel_serial_probe(struct platform_device *pdev)
>  	kfree(atmel_port->rx_ring.buf);
>  	atmel_port->rx_ring.buf = NULL;
>  err_alloc_ring:
> -	if (!atmel_is_console_port(&atmel_port->uart)) {
> +	if (!uart_console(&atmel_port->uart)) {
>  		clk_put(atmel_port->clk);
>  		atmel_port->clk = NULL;
>  	}
> 

Thanks !

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

end of thread, other threads:[~2020-03-10 16:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-10 13:30 [PATCH v1] tty/serial: atmel: Use uart_console() helper Andy Shevchenko
2020-03-10 16:40 ` Richard Genoud

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.