Re: [PATCH 30/33] serial: 8250: invert serial8250_register_8250_port() CIR condition

From: Jiri Slaby
Date: Mon Jun 23 2025 - 03:05:57 EST


On 21. 06. 25, 21:08, Andy Shevchenko wrote:
Fri, Jun 20, 2025 at 11:48:09PM +0200, Maciej S. Szmigiero kirjoitti:
On 18.06.2025 07:48, Andy Shevchenko wrote:
On Wed, Jun 11, 2025 at 12:03:16PM +0200, Jiri Slaby (SUSE) wrote:

...

+ if (uart->port.type == PORT_8250_CIR) {
+ ret = -ENODEV;
+ goto unlock;
+ }

+ if (up->port.flags & UPF_FIXED_TYPE)
+ uart->port.type = up->port.type;

+ if (uart->port.type != PORT_8250_CIR) {

I admit that there tons of mysterious ways of UART initialisation, but can you
elaborate how this is not a always-true conditional?

Careful here, someone had an idea in the past that this is indeed
a dead code/branch and ended causing a regression [1].

Right, I was confused too, but then I noticed there is:
uart->port.type = up->port.type;
in between the tests.

It would definitely make sense to add a comment describing the code
flow there though as it proven to bewilder people.

Yes, this is my point between the lines. I left the code that may affect the
type change and the second check needs a comment explaining these cases, if any.
"If any" defines "always-true" or not conditional. W//o a comment this code
tends to be updated again and lead to a regression.

ACK, I will.

--
js
suse labs