Re: [PATCH RFC] PCI: Convert devm_pci_alloc_host_bridge() users to error-pointer returns

From: AngeloGioacchino Del Regno

Date: Mon Sep 22 2025 - 06:55:18 EST


Il 21/09/25 18:14, Alok Tiwari ha scritto:
devm_pci_alloc_host_bridge() and pci_alloc_host_bridge() previously
returned NULL on failure, forcing callers to special-case NULL handling
and often hardcode -ENOMEM as the error.

This series updates devm_pci_alloc_host_bridge() to consistently return
error pointers (ERR_PTR) with the actual error code, instead of NULL.
All callers across PCI host controller drivers are updated to use
IS_ERR_OR_NULL()/PTR_ERR() instead of NULL checks and hardcoded -ENOMEM.

Benefits:
- Standardizes error handling with Linux kernel ERR_PTR()/PTR_ERR()
conventions.
- Ensures that the actual error code from lower-level helpers is
propagated back to the caller.
- Removes ambiguity between NULL and error pointer returns.

Touched drivers include:
cadence (J721E, cadence-plat)
dwc (designware, qcom)
mobiveil (layerscape-gen4, mobiveil-plat)
aardvark, ftpci100, ixp4xx, loongson, mvebu, rcar, tegra, v3-semi,
versatile, xgene, altera, brcmstb, iproc, mediatek, mt7621, xilinx,
plda, and others

This patch updates error handling across these host controller drivers
so that callers consistently receive ERR_PTR() instead of NULL.


I think that's a nice improvement - propagating the right error code looks good.

The only thing is - you have to make sure that it never returns NULL, so that
in the controller drivers you always check for `if (IS_ERR(x))` - otherwise with
the current IS_ERR_OR_NULL(x) most of the error paths are wrong.

Cheers,
Angelo

Signed-off-by: Alok Tiwari <alok.a.tiwari@xxxxxxxxxx>
---
arch/mips/pci/pci-xtalk-bridge.c | 4 ++--
drivers/pci/controller/cadence/pci-j721e.c | 4 ++--
drivers/pci/controller/cadence/pcie-cadence-plat.c | 4 ++--
drivers/pci/controller/dwc/pcie-designware-host.c | 4 ++--
drivers/pci/controller/dwc/pcie-qcom.c | 4 ++--
drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c | 4 ++--
drivers/pci/controller/mobiveil/pcie-mobiveil-plat.c | 4 ++--
drivers/pci/controller/pci-aardvark.c | 4 ++--
drivers/pci/controller/pci-ftpci100.c | 4 ++--
drivers/pci/controller/pci-host-common.c | 4 ++--
drivers/pci/controller/pci-hyperv.c | 4 ++--
drivers/pci/controller/pci-ixp4xx.c | 4 ++--
drivers/pci/controller/pci-loongson.c | 4 ++--
drivers/pci/controller/pci-mvebu.c | 4 ++--
drivers/pci/controller/pci-rcar-gen2.c | 4 ++--
drivers/pci/controller/pci-tegra.c | 4 ++--
drivers/pci/controller/pci-v3-semi.c | 4 ++--
drivers/pci/controller/pci-versatile.c | 4 ++--
drivers/pci/controller/pci-xgene.c | 4 ++--
drivers/pci/controller/pcie-altera.c | 4 ++--
drivers/pci/controller/pcie-brcmstb.c | 4 ++--
drivers/pci/controller/pcie-iproc-bcma.c | 4 ++--
drivers/pci/controller/pcie-iproc-platform.c | 4 ++--
drivers/pci/controller/pcie-mediatek-gen3.c | 4 ++--
drivers/pci/controller/pcie-mediatek.c | 4 ++--
drivers/pci/controller/pcie-mt7621.c | 4 ++--
drivers/pci/controller/pcie-rcar-host.c | 4 ++--
drivers/pci/controller/pcie-rockchip-host.c | 4 ++--
drivers/pci/controller/pcie-xilinx-cpm.c | 4 ++--
drivers/pci/controller/pcie-xilinx-dma-pl.c | 4 ++--
drivers/pci/controller/pcie-xilinx-nwl.c | 4 ++--
drivers/pci/controller/pcie-xilinx.c | 4 ++--
drivers/pci/controller/plda/pcie-plda-host.c | 4 ++--
drivers/pci/probe.c | 8 ++++----
34 files changed, 70 insertions(+), 70 deletions(-)