Re: [PATCH v5 6/7] spi: cadence-xspi: Rework resource discovery

From: Mark Brown

Date: Thu Nov 26 2026 - 20:28:51 EST


> The previous code worked, but calling
> devm_platform_ioremap_resource_byname() on ACPI where resources aren't
> named causes warnings to be printed, one per call:
>
> cadence-xspi PRP0001:02: error -EINVAL: invalid resource (null)
> cadence-xspi PRP0001:02: error -EINVAL: invalid resource (null)
> cadence-xspi PRP0001:02: error -EINVAL: invalid resource (null)
> cadence-xspi PRP0001:02: error -EINVAL: invalid resource (null)

> #ifdef CONFIG_64BIT
> if (cdns_xspi->driver_data->mrvl_hw_overlay) {
> - cdns_xspi->xferbase = devm_platform_ioremap_resource_byname(pdev, "xfer");
> + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "xfer");
> + if (!res)
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
> +
> + cdns_xspi->xferbase = devm_ioremap_resource(dev, res);
> if (IS_ERR(cdns_xspi->xferbase)) {
> - cdns_xspi->xferbase = devm_platform_ioremap_resource(pdev, 3);
> - if (IS_ERR(cdns_xspi->xferbase)) {
> - dev_info(dev, "XFER register base not found, set it\n");
> - // For compatibility with older firmware
> - cdns_xspi->xferbase = cdns_xspi->iobase + 0x8000;
> - }
> + dev_info(dev, "XFER register base not found, set it\n");
> + // For compatibility with older firmware
> + cdns_xspi->xferbase = cdns_xspi->iobase + 0x8000;

Shouldn't we go directly here if res is NULL instead of trying to do the
ioremap, otherwise we'll continue to get errors? OTOH if we *do* have
the resource then we know we're supposed to use it instead of the legacy
one so we should propagate the error instead of guessing.

--
Mark Brown <broonie@xxxxxxxxxx>