Re: [PATCH v2] serial: 8250: Clear CON_PRINTBUFFER on port re-registration

From: Fushuai Wang

Date: Fri May 22 2026 - 05:52:44 EST


>> >> --- a/drivers/tty/serial/8250/8250_core.c
>> >> +++ b/drivers/tty/serial/8250/8250_core.c
>> >> @@ -694,6 +694,7 @@ int serial8250_register_8250_port(const struct uart_8250_port *up)
>> >> {
>> >> struct uart_8250_port *uart;
>> >> int ret;
>> >> + bool was_removed = false;
>> >>
>>> >> if (up->port.uartclk == 0)
>> >> return -EINVAL;
>> >> @@ -716,8 +717,10 @@ int serial8250_register_8250_port(const struct uart_8250_port *up)
>> >> if (uart->port.type == PORT_8250_CIR)
>> >> return -ENODEV;
>> >>
>> >> - if (uart->port.dev)
>> >> + if (uart->port.dev) {
>> >> uart_remove_one_port(&serial8250_reg, &uart->port);
>> >> + was_removed = true;
>> >> + }
>> >>
>> >> uart->port.ctrl_id = up->port.ctrl_id;
>> >> uart->port.port_id = up->port.port_id;
>> >> @@ -819,6 +822,10 @@ int serial8250_register_8250_port(const struct uart_8250_port *up)
>> >> &uart->capabilities);
>> >>
>> >> serial8250_apply_quirks(uart);
>> >> +
>> >> + if (was_removed && uart_console(&uart->port))
>> >> + uart->port.cons->flags &= ~CON_PRINTBUFFER;
>> >
>> > Why not set the flag up above when you remove the port? Why down here?
>> >
>> > thanks,
>> >
>> > greg k-h
>>
>> Hi, Greg
>>
>> I just felt it's cleaner to clear it only when re-registration happens.
>> Do you think there is any problem with doing it right after the removal?
>
> If you do that, no flag is needed.

OK, I will send a v3 shortly.

--
Regards,
WANG