From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Alok Tiwari <alok.a.tiwari@oracle.com>,
thomas.petazzoni@bootlin.com, pali@kernel.org,
lpieralisi@kernel.org, kwilczynski@kernel.org, mani@kernel.org,
robh@kernel.org, bhelgaas@google.com, joyce.ooi@intel.com,
alyssa@rosenzweig.io, maz@kernel.org, jim2101024@gmail.com,
florian.fainelli@broadcom.com,
bcm-kernel-feedback-list@broadcom.com, rjui@broadcom.com,
sbranden@broadcom.com, ryder.lee@mediatek.com,
jianjun.wang@mediatek.com, sergio.paracuellos@gmail.com,
matthias.bgg@gmail.com, marek.vasut+renesas@gmail.com,
yoshihiro.shimoda.uh@renesas.com, geert+renesas@glider.be,
magnus.damm@gmail.com, shawn.lin@rock-chips.com, heiko@sntech.de,
michal.simek@amd.com, bharat.kumar.gogada@amd.com,
will@kernel.org, kys@microsoft.com, haiyangz@microsoft.com,
wei.liu@kernel.org, decui@microsoft.com,
linus.walleij@linaro.org, thierry.reding@gmail.com,
jonathanh@nvidia.com, rric@kernel.org,
nirmal.patel@linux.intel.com, toan@os.amperecomputing.com,
jonathan.derrick@linux.dev, linux-pci@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
linux-rpi-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
linux-renesas-soc@vger.kernel.org,
linux-rockchip@lists.infradead.org, linux-hyperv@vger.kernel.org,
linux-tegra@vger.kernel.org
Subject: Re: [PATCH RFC] PCI: Convert devm_pci_alloc_host_bridge() users to error-pointer returns
Date: Mon, 22 Sep 2025 12:55:14 +0200 [thread overview]
Message-ID: <e700cea3-cbe7-4ab5-94d8-a211051e2472@collabora.com> (raw)
In-Reply-To: <20250921161434.1561770-1-alok.a.tiwari@oracle.com>
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@oracle.com>
> ---
> 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(-)
>
prev parent reply other threads:[~2025-09-22 10:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-21 16:14 [PATCH RFC] PCI: Convert devm_pci_alloc_host_bridge() users to error-pointer returns Alok Tiwari
2025-09-21 17:19 ` Marc Zyngier
2025-09-22 10:55 ` AngeloGioacchino Del Regno [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e700cea3-cbe7-4ab5-94d8-a211051e2472@collabora.com \
--to=angelogioacchino.delregno@collabora.com \
--cc=alok.a.tiwari@oracle.com \
--cc=alyssa@rosenzweig.io \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bharat.kumar.gogada@amd.com \
--cc=bhelgaas@google.com \
--cc=decui@microsoft.com \
--cc=florian.fainelli@broadcom.com \
--cc=geert+renesas@glider.be \
--cc=haiyangz@microsoft.com \
--cc=heiko@sntech.de \
--cc=jianjun.wang@mediatek.com \
--cc=jim2101024@gmail.com \
--cc=jonathan.derrick@linux.dev \
--cc=jonathanh@nvidia.com \
--cc=joyce.ooi@intel.com \
--cc=kwilczynski@kernel.org \
--cc=kys@microsoft.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=linux-tegra@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=magnus.damm@gmail.com \
--cc=mani@kernel.org \
--cc=marek.vasut+renesas@gmail.com \
--cc=matthias.bgg@gmail.com \
--cc=maz@kernel.org \
--cc=michal.simek@amd.com \
--cc=nirmal.patel@linux.intel.com \
--cc=pali@kernel.org \
--cc=rjui@broadcom.com \
--cc=robh@kernel.org \
--cc=rric@kernel.org \
--cc=ryder.lee@mediatek.com \
--cc=sbranden@broadcom.com \
--cc=sergio.paracuellos@gmail.com \
--cc=shawn.lin@rock-chips.com \
--cc=thierry.reding@gmail.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=toan@os.amperecomputing.com \
--cc=wei.liu@kernel.org \
--cc=will@kernel.org \
--cc=yoshihiro.shimoda.uh@renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox