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

From: Maciej S. Szmigiero
Date: Fri Jun 20 2025 - 18:30:25 EST


On 18.06.2025 07:48, Andy Shevchenko wrote:
On Wed, Jun 11, 2025 at 12:03:16PM +0200, Jiri Slaby (SUSE) wrote:
There is no point in a long 'if' in serial8250_register_8250_port() to
just return ENOSPC for PORT_8250_CIR ports. Invert the condition and
return immediately.

'gpios' variable was moved to its set location.

And return ENODEV instead of ENOSPC. The latter is a leftover from the
previous find-uart 'if'. The former makes a lot more sense in this case.

...

+ 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].

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

Thanks,
Maciej

[1]: https://lore.kernel.org/lkml/c599065a-60f5-070e-c1e3-12b3ab2cbf0a@xxxxxxxx/