Re: [PATCH] usb: xhci: xhci_setup_port_arrays: early -ENODEV if maxports is 0.

From: Michał Pecio
Date: Fri Oct 04 2024 - 17:05:40 EST


> That is correct, the case is handled without panic, but the 0 value
> gets silently propagated until it eventually fails on line 2220:
> if (xhci->usb2_rhub.num_ports == 0 && xhci->usb3_rhub.num_ports == 0) {
> xhci_warn(xhci, "No ports on the roothubs?\n");
> return -ENODEV;
> }
> The benefits are only:
> - Reporting a more precise issue
> - Avoids iterating through the capability structures of the
> controller
> - failsafe if future changes

Well, simplifying things is not bad in principle, but in this case it
looks like this patch adds a branch and some 50 bytes of code/data for
the sake of optimizing something with no practical relevance (any such
hardware is useless, rejected by this driver, and violates the spec).

So, maybe just not worth the cost, no matter how small ;)

Regards,
Michal