mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v6 0/1] spi: cadence-xspi: Fixes and ACPI changes
@ 2026-11-27 16:07 Paul Cercueil
  2026-11-27 16:07 ` [PATCH v6 1/1] spi: cadence-xspi: Rework resource discovery Paul Cercueil
  2026-11-27 16:09 ` [PATCH v6 0/1] spi: cadence-xspi: Fixes and ACPI changes Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Cercueil @ 2026-11-27 16:07 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-spi, linux-kernel, Thomas Petazzoni, Bharat Bhushan,
	Sunil Kovvuri Goutham, Tanmay Jagdale, Jisheng Zhang,
	George Cherian, Witold Sadowski, Paul Cercueil

Hi Mark,

This v6 fixes the remaining patch of my "Fixes and ACPI changes"
patchset [1].

Changes in v6:

[1/1]:
  - Properly handle errors of devm_platform_ioremap_resource() for the
    xfer base

Cheers,
-Paul

[1]: https://lore.kernel.org/linux-spi/20261120115925.173568-1-paul.cercueil@bootlin.com/T/

Tanmay Jagdale (1):
  spi: cadence-xspi: Rework resource discovery

 drivers/spi/spi-cadence-xspi.c | 61 +++++++++++++++++-----------------
 1 file changed, 31 insertions(+), 30 deletions(-)

-- 
2.47.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v6 1/1] spi: cadence-xspi: Rework resource discovery
  2026-11-27 16:07 [PATCH v6 0/1] spi: cadence-xspi: Fixes and ACPI changes Paul Cercueil
@ 2026-11-27 16:07 ` Paul Cercueil
  2026-11-27 16:09 ` [PATCH v6 0/1] spi: cadence-xspi: Fixes and ACPI changes Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Cercueil @ 2026-11-27 16:07 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-spi, linux-kernel, Thomas Petazzoni, Bharat Bhushan,
	Sunil Kovvuri Goutham, Tanmay Jagdale, Jisheng Zhang,
	George Cherian, Witold Sadowski, Paul Cercueil

From: Tanmay Jagdale <tanmay@marvell.com>

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)

We can avoid these warnings by first obtaining a pointer to the resource
with platform_get_resource_byname() and fallback to
platform_get_resource() if it fails, and then ioremap the resource using
devm_ioremap_resource().

Signed-off-by: Tanmay Jagdale <tanmay@marvell.com>
Co-developed-by: Paul Cercueil <paul.cercueil@bootlin.com>
Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>

---

v2: - Drop warnings. devm_ioremap_resource() already warns.

v3-v5: No change

v6: Properly handle errors of devm_platform_ioremap_resource() for the
    xfer base
---
 drivers/spi/spi-cadence-xspi.c | 61 +++++++++++++++++-----------------
 1 file changed, 31 insertions(+), 30 deletions(-)

diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
index 594b46304a6e..a42fab719b7a 100644
--- a/drivers/spi/spi-cadence-xspi.c
+++ b/drivers/spi/spi-cadence-xspi.c
@@ -1454,48 +1454,49 @@ static int cdns_xspi_probe(struct platform_device *pdev)
 	if (ret)
 		return -ENODEV;
 
-	cdns_xspi->iobase = devm_platform_ioremap_resource_byname(pdev, "io");
-	if (IS_ERR(cdns_xspi->iobase)) {
-		cdns_xspi->iobase = devm_platform_ioremap_resource(pdev, 0);
-		if (IS_ERR(cdns_xspi->iobase)) {
-			dev_err(dev, "Failed to remap controller base address\n");
-			return PTR_ERR(cdns_xspi->iobase);
-		}
-	}
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "io");
+	if (!res)
+		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+	cdns_xspi->iobase = devm_ioremap_resource(dev, res);
+	if (IS_ERR(cdns_xspi->iobase))
+		return PTR_ERR(cdns_xspi->iobase);
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sdma");
-	cdns_xspi->sdmabase = devm_ioremap_resource(dev, res);
-	if (IS_ERR(cdns_xspi->sdmabase)) {
+	if (!res)
 		res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-		cdns_xspi->sdmabase = devm_ioremap_resource(dev, res);
-		if (IS_ERR(cdns_xspi->sdmabase))
-			return PTR_ERR(cdns_xspi->sdmabase);
-	}
+
+	cdns_xspi->sdmabase = devm_ioremap_resource(dev, res);
+	if (IS_ERR(cdns_xspi->sdmabase))
+		return PTR_ERR(cdns_xspi->sdmabase);
 	cdns_xspi->sdmasize = resource_size(res);
 
 	ret = cdns_xspi_dma_init(cdns_xspi, res->start);
 	if (ret)
 		return ret;
 
-	cdns_xspi->auxbase = devm_platform_ioremap_resource_byname(pdev, "aux");
-	if (IS_ERR(cdns_xspi->auxbase)) {
-		cdns_xspi->auxbase = devm_platform_ioremap_resource(pdev, 2);
-		if (IS_ERR(cdns_xspi->auxbase)) {
-			dev_err(dev, "Failed to remap AUX address\n");
-			return PTR_ERR(cdns_xspi->auxbase);
-		}
-	}
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "aux");
+	if (!res)
+		res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+
+	cdns_xspi->auxbase = devm_ioremap_resource(dev, res);
+	if (IS_ERR(cdns_xspi->auxbase))
+		return PTR_ERR(cdns_xspi->auxbase);
 
 #ifdef CONFIG_64BIT
 	if (cdns_xspi->driver_data->mrvl_hw_overlay) {
-		cdns_xspi->xferbase = devm_platform_ioremap_resource_byname(pdev, "xfer");
-		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;
-			}
+		res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "xfer");
+		if (!res)
+			res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
+
+		if (res) {
+			cdns_xspi->xferbase = devm_ioremap_resource(dev, res);
+			if (IS_ERR(cdns_xspi->xferbase))
+				return PTR_ERR(cdns_xspi->xferbase);
+		} else {
+			dev_info(dev, "XFER register base not found, set it\n");
+			// For compatibility with older firmware
+			cdns_xspi->xferbase = cdns_xspi->iobase + 0x8000;
 		}
 	}
 #endif
-- 
2.47.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v6 0/1] spi: cadence-xspi: Fixes and ACPI changes
  2026-11-27 16:07 [PATCH v6 0/1] spi: cadence-xspi: Fixes and ACPI changes Paul Cercueil
  2026-11-27 16:07 ` [PATCH v6 1/1] spi: cadence-xspi: Rework resource discovery Paul Cercueil
@ 2026-11-27 16:09 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-11-27 16:09 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: linux-spi, linux-kernel, Thomas Petazzoni, Bharat Bhushan,
	Sunil Kovvuri Goutham, Tanmay Jagdale, Jisheng Zhang,
	George Cherian, Witold Sadowski

[-- Attachment #1: Type: text/plain, Size: 471 bytes --]

On Fri, Nov 27, 2026 at 05:07:58PM +0100, Paul Cercueil wrote:
> Hi Mark,
> 
> This v6 fixes the remaining patch of my "Fixes and ACPI changes"
> patchset [1].

Please don't send cover letters for single patches, if there is anything
that needs saying put it in the changelog of the patch or after the ---
if it's administrative stuff.  This reduces mail volume and ensures that 
any important information is recorded in the changelog rather than being
lost. 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-27 16:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27 16:07 [PATCH v6 0/1] spi: cadence-xspi: Fixes and ACPI changes Paul Cercueil
2026-11-27 16:07 ` [PATCH v6 1/1] spi: cadence-xspi: Rework resource discovery Paul Cercueil
2026-11-27 16:09 ` [PATCH v6 0/1] spi: cadence-xspi: Fixes and ACPI changes Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®