Re: [PATCH v2 3/4] PCI: dwc: Clean up iatu index usage in dw_pcie_iatu_setup()

Niklas Cassel
2026-01-22T22:48:04Z

On Thu, Jan 22, 2026 at 11:29:17PM +0100, Niklas Cassel wrote:

(snip)

> if (pp->use_atu_msg) {
> - if (pci->num_ob_windows > ++i) {
> - pp->msg_atu_index = i;
> + if (ob_iatu_index_to_use < pci->num_ob_windows) {
> + pp->msg_atu_index = ob_iatu_index_to_use;
> + ob_iatu_index_to_use++;
> } else {
> dev_err(pci->dev, "Cannot add outbound window for MSG TLP\n");
> return -ENOMEM;
> }
> }

To be even more consistent with the while loops,
this part should probably instead be written as:

if (pp->use_atu_msg) {
- if (ob_iatu_index_to_use < pci->num_ob_windows) {
- pp->msg_atu_index = ob_iatu_index_to_use;
- ob_iatu_index_to_use++;
- } else {
+ if (!(ob_iatu_index_to_use < pci->num_ob_windows)) {
dev_err(pci->dev, "Cannot add outbound window for MSG TLP\n");
return -ENOMEM;
}
+ pp->msg_atu_index = ob_iatu_index_to_use;
+ ob_iatu_index_to_use++;
}

Kind regards,
Niklas