From nobody Thu Apr 9 12:08:15 2026 Received: from mail.zeus03.de (zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1167B366DD5 for ; Mon, 9 Mar 2026 07:39:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773041944; cv=none; b=YrXwPhTxavT+URultNLuM7ASC00W/tYRE1EgYaTOL/cxBkt4ZZQ+btjNGd/Ebqn6k92x35/NlfmREZKuwASgMQIttrNjTngQIALCYuilTgLYyRHYTBQqsYVNaqPvVrOZtX0a2B6fUyK532vBBWwS7v1QvjziWCUuaXVQLUPwHwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773041944; c=relaxed/simple; bh=yE3skMqFifN6pJ2zJQHVtLkHWCWQ0rUYIC2lLJHFEYs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=a3eeQd13ae5dg4ymDRxcBCR6ODLaiaGf/8/QJM7bp1gDv/1wYlK7d3SttGpOBOC/E0SI/siI+n5d9n7BO1fjmaSCZuDlap8HBLpnmo3e8pXWBjVUs8j/YhqKSWCKa+hdblljK+vV5ycsSt51As8xiS5Axu/gHTWiqS7p7tt+MVk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=SDJmmdfV; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="SDJmmdfV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; s=k1; bh=8Q8AJiAfw57l3F wfFbMcdm+a74vtF4BX1pgikU9ldik=; b=SDJmmdfVSlGFnzPHR5MBd8JE5qh6xM BIKsgvInTIqD31Unixn27VNcSJj3ymsyGwxNQDGdJnHmoy12lzWfOM+zhhXt1VT+ 0S9oIUxlT6bbpFX45Vaf2O53At4nuovQiRJNK97IxcEHkql9F4c4WXRDHr8FL+5h hCealkIqazEKnNEddJ12xKnQhdx3InyIi6qirY8SOmb2yFEMxmTvp1mftvjzxr2Q UHTvQaQCc/Zi3yGZh2J6Hal9AJuHEVx/zp9UYxtvPTbFfTgWJGpIsIkA6gZK8tc0 L3z5qxxl1X7fAcNtaceGp0InA+aLcGmrELOlMGiIX9YALFkT35cUByiQ== Received: (qmail 2668293 invoked from network); 9 Mar 2026 08:39:01 +0100 Received: by mail.zeus03.de with UTF8SMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 9 Mar 2026 08:39:01 +0100 X-UD-Smtp-Session: l3s3148p1@CaIQf5JMhp4ujnvm From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Jassi Brar Subject: [PATCH v4] mailbox: test: really ignore optional memory resources Date: Mon, 9 Mar 2026 08:37:50 +0100 Message-ID: <20260309073856.2209-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. The -EBUSY error message of ioremap_resource() is still kept because it is correct. The comment which explains that a plain ioremap() is tried as a workaround is turned into a info message. So, a user will be informed about it, too. Signed-off-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven --- Changes since v3: * fixed __iomem annotations (Thanks, sparse + buildbots) * rebased to 7.0-rc2 drivers/mailbox/mailbox-test.c | 37 +++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c index 3a28ab5c42e5..058c0fe4b9c2 100644 --- a/drivers/mailbox/mailbox-test.c +++ b/drivers/mailbox/mailbox-test.c @@ -355,11 +355,27 @@ mbox_test_request_channel(struct platform_device *pde= v, const char *name) return channel; } =20 +static void __iomem *mbox_test_ioremap(struct platform_device *pdev, unsig= ned int res_num) +{ + struct resource *res; + void __iomem *mmio; + + res =3D platform_get_resource(pdev, IORESOURCE_MEM, res_num); + if (!res) + return NULL; + + mmio =3D devm_ioremap_resource(&pdev->dev, res); + if (PTR_ERR(mmio) =3D=3D -EBUSY) { + dev_info(&pdev->dev, "trying workaround with plain ioremap\n"); + return devm_ioremap(&pdev->dev, res->start, resource_size(res)); + } + + return IS_ERR(mmio) ? NULL : mmio; +} + static int mbox_test_probe(struct platform_device *pdev) { struct mbox_test_device *tdev; - struct resource *res; - resource_size_t size; int ret; =20 tdev =3D devm_kzalloc(&pdev->dev, sizeof(*tdev), GFP_KERNEL); @@ -367,23 +383,12 @@ static int mbox_test_probe(struct platform_device *pd= ev) return -ENOMEM; =20 /* It's okay for MMIO to be NULL */ - tdev->tx_mmio =3D devm_platform_get_and_ioremap_resource(pdev, 0, &res); - if (PTR_ERR(tdev->tx_mmio) =3D=3D -EBUSY) { - /* if reserved area in SRAM, try just ioremap */ - size =3D resource_size(res); - tdev->tx_mmio =3D devm_ioremap(&pdev->dev, res->start, size); - } else if (IS_ERR(tdev->tx_mmio)) { - tdev->tx_mmio =3D NULL; - } + tdev->tx_mmio =3D mbox_test_ioremap(pdev, 0); =20 /* If specified, second reg entry is Rx MMIO */ - tdev->rx_mmio =3D devm_platform_get_and_ioremap_resource(pdev, 1, &res); - if (PTR_ERR(tdev->rx_mmio) =3D=3D -EBUSY) { - size =3D resource_size(res); - tdev->rx_mmio =3D devm_ioremap(&pdev->dev, res->start, size); - } else if (IS_ERR(tdev->rx_mmio)) { + tdev->rx_mmio =3D mbox_test_ioremap(pdev, 1); + if (!tdev->rx_mmio) tdev->rx_mmio =3D tdev->tx_mmio; - } =20 tdev->tx_channel =3D mbox_test_request_channel(pdev, "tx"); tdev->rx_channel =3D mbox_test_request_channel(pdev, "rx"); --=20 2.47.3