On 2022-11-10, Petr Mladek <pmladek@xxxxxxxx> wrote: >>> -static inline bool uart_console_enabled(struct uart_port *port) >>> +/* Variant of uart_console_registered() when the console_list_lock is held. */ >>> +static inline bool uart_console_registered_locked(struct uart_port *port) >>> { >>> - return uart_console(port) && (port->cons->flags & CON_ENABLED); >>> + return uart_console(port) && console_is_registered_locked(port->cons); >>> +} >>> + >>> +static inline bool uart_console_registered(struct uart_port *port) >>> +{ >>> + bool ret; >>> + >>> + console_list_lock(); >>> + ret = uart_console_registered_locked(port); >>> + console_list_unlock(); >>> + return ret; >> >> Perhaps >> >> return uart_console(port) && console_is_registered(); >> >> to avoid locking the list when the first condition is not true? > > I do not have strong opinion on this. It is true that the code > duplication is trivial but it is a code duplication. Either > way would work for me. I will go with Geert's suggestion for v4. It is important that we reduce lock contention for non-console ports. > The reset of the code looks good. Feel free to use: > > Reviewed-by: Petr Mladek <pmladek@xxxxxxxx> Thanks. John