[printk,v2,10/38] tty: hvc: use console_is_enabled()

Message ID 20221019145600.1282823-11-john.ogness@linutronix.de
State New
Headers
Series reduce console_lock scope |

Commit Message

John Ogness Oct. 19, 2022, 2:55 p.m. UTC
  Replace (console->flags & CON_ENABLED) usage with console_is_enabled().

Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
 drivers/tty/hvc/hvc_console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Greg KH Oct. 19, 2022, 4:01 p.m. UTC | #1
On Wed, Oct 19, 2022 at 05:01:32PM +0206, John Ogness wrote:
> Replace (console->flags & CON_ENABLED) usage with console_is_enabled().
> 
> Signed-off-by: John Ogness <john.ogness@linutronix.de>

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  
Petr Mladek Oct. 21, 2022, 1:22 p.m. UTC | #2
On Wed 2022-10-19 17:01:32, John Ogness wrote:
> Replace (console->flags & CON_ENABLED) usage with console_is_enabled().
> 
> Signed-off-by: John Ogness <john.ogness@linutronix.de>
> ---
>  drivers/tty/hvc/hvc_console.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
> index 4802cfaa107f..6d1d7b72488c 100644
> --- a/drivers/tty/hvc/hvc_console.c
> +++ b/drivers/tty/hvc/hvc_console.c
> @@ -265,7 +265,7 @@ static void hvc_port_destruct(struct tty_port *port)
>  static void hvc_check_console(int index)
>  {
>  	/* Already enabled, bail out */
> -	if (hvc_console.flags & CON_ENABLED)
> +	if (console_is_enabled(&hvc_console))
>  		return;

The check is not reliable. The console might be disabled even when
it is already registered.

I would be nice to fix this. But it might be done later.
Feel free to use:

Reviewed-by: Petr Mladek <pmladek@suse.com>

>  
>   	/* If this index is what the user requested, then register

Best Regards,
Petr
  

Patch

diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 4802cfaa107f..6d1d7b72488c 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -265,7 +265,7 @@  static void hvc_port_destruct(struct tty_port *port)
 static void hvc_check_console(int index)
 {
 	/* Already enabled, bail out */
-	if (hvc_console.flags & CON_ENABLED)
+	if (console_is_enabled(&hvc_console))
 		return;
 
  	/* If this index is what the user requested, then register