spi: cadence-xspi: Fixes and ACPI changes
v6 cover spi: cadence-xspi: Fixes and ACPI changes
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/[email protected]/T/
Tanmay Jagdale (1):
spi: cadence-xspi: Rework resource discovery
drivers/spi/spi-cadence-xspi.c | 61 +++++++++++++++++----------------- 1 file changed, 31 insertions(+), 30 deletions(-)
Signature · 1 line
2.47.3
PATCH v6 1/1 spi: cadence-xspi: Rework resource discovery
From: Tanmay Jagdale <[email protected]>
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().
---
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(-)
drivers/spi/spi-cadence-xspi.c +31 -30
@@ -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
Signature · 1 line
2.47.3
Mark Brown
maintainerQuoted 4 lines · Paul Cercueil
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.