Linux Renesas SOC kernel development
 help / color / mirror / Atom feed
* [PATCH] mailbox: test: really ignore optional memory resources
@ 2026-02-17 14:06 Wolfram Sang
  2026-02-17 19:39 ` Wolfram Sang
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfram Sang @ 2026-02-17 14:06 UTC (permalink / raw)
  To: linux-renesas-soc; +Cc: linux-kernel, Wolfram Sang, Jassi Brar

Memory resources are optional but if the resource is empty
devm_platform_get_and_ioremap_resource() prints an error nonetheless.
Refactor the code to check the resources locally first and process them
only if they are present.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mailbox/mailbox-test.c | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c
index 3a28ab5c42e5..98c2a2ed6dfc 100644
--- a/drivers/mailbox/mailbox-test.c
+++ b/drivers/mailbox/mailbox-test.c
@@ -367,22 +367,28 @@ static int mbox_test_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	/* It's okay for MMIO to be NULL */
-	tdev->tx_mmio = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
-	if (PTR_ERR(tdev->tx_mmio) == -EBUSY) {
-		/* if reserved area in SRAM, try just ioremap */
-		size = resource_size(res);
-		tdev->tx_mmio = devm_ioremap(&pdev->dev, res->start, size);
-	} else if (IS_ERR(tdev->tx_mmio)) {
-		tdev->tx_mmio = NULL;
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (res) {
+		tdev->tx_mmio = devm_ioremap_resource(&pdev->dev, res);
+		if (PTR_ERR(tdev->tx_mmio) == -EBUSY) {
+			/* if reserved area in SRAM, try just ioremap */
+			size = resource_size(res);
+			tdev->tx_mmio = devm_ioremap(&pdev->dev, res->start, size);
+		} else if (IS_ERR(tdev->tx_mmio)) {
+			tdev->tx_mmio = NULL;
+		}
 	}
 
 	/* If specified, second reg entry is Rx MMIO */
-	tdev->rx_mmio = devm_platform_get_and_ioremap_resource(pdev, 1, &res);
-	if (PTR_ERR(tdev->rx_mmio) == -EBUSY) {
-		size = resource_size(res);
-		tdev->rx_mmio = devm_ioremap(&pdev->dev, res->start, size);
-	} else if (IS_ERR(tdev->rx_mmio)) {
-		tdev->rx_mmio = tdev->tx_mmio;
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	if (res) {
+		tdev->rx_mmio = devm_ioremap_resource(&pdev->dev, res);
+		if (PTR_ERR(tdev->rx_mmio) == -EBUSY) {
+			size = resource_size(res);
+			tdev->rx_mmio = devm_ioremap(&pdev->dev, res->start, size);
+		} else if (IS_ERR(tdev->rx_mmio)) {
+			tdev->rx_mmio = tdev->tx_mmio;
+		}
 	}
 
 	tdev->tx_channel = mbox_test_request_channel(pdev, "tx");
-- 
2.47.3


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

* Re: [PATCH] mailbox: test: really ignore optional memory resources
  2026-02-17 14:06 [PATCH] mailbox: test: really ignore optional memory resources Wolfram Sang
@ 2026-02-17 19:39 ` Wolfram Sang
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2026-02-17 19:39 UTC (permalink / raw)
  To: linux-renesas-soc; +Cc: linux-kernel, Jassi Brar

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


> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);

This breaks using a single MMIO for TX and RX. I will work on a better
solution.

> +	if (res) {
> +		tdev->rx_mmio = devm_ioremap_resource(&pdev->dev, res);
> +		if (PTR_ERR(tdev->rx_mmio) == -EBUSY) {
> +			size = resource_size(res);
> +			tdev->rx_mmio = devm_ioremap(&pdev->dev, res->start, size);
> +		} else if (IS_ERR(tdev->rx_mmio)) {
> +			tdev->rx_mmio = tdev->tx_mmio;
> +		}

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

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

end of thread, other threads:[~2026-02-17 19:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-17 14:06 [PATCH] mailbox: test: really ignore optional memory resources Wolfram Sang
2026-02-17 19:39 ` Wolfram Sang

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