Re: [PATCH v2] mailbox: test: really ignore optional memory resources
From: Geert Uytterhoeven
Date: Tue Mar 03 2026 - 06:16:59 EST
Hi Wolfram,
On Mon, 23 Feb 2026 at 13:30, Wolfram Sang
<wsa+renesas@xxxxxxxxxxxxxxxxxxxx> wrote:
> 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 <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>
Thanks for your patch!
> --- a/drivers/mailbox/mailbox-test.c
> +++ b/drivers/mailbox/mailbox-test.c
> @@ -355,11 +355,30 @@ mbox_test_request_channel(struct platform_device *pdev, const char *name)
> return channel;
> }
>
> -static int mbox_test_probe(struct platform_device *pdev)
> +static void *mbox_test_ioremap(struct platform_device *pdev, unsigned int res_num)
> {
> - struct mbox_test_device *tdev;
> struct resource *res;
> resource_size_t size;
> + void *mmio = NULL;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, res_num);
> + if (res) {
if (!res)
return NULL;
> + mmio = devm_ioremap_resource(&pdev->dev, res);
> + if (PTR_ERR(mmio) == -EBUSY) {
> + dev_info(&pdev->dev, "trying workaround with plain ioremap\n");
> + size = resource_size(res);
With the reduced indentation, you don't need a temporary to avoid the
next line being too long.
> + mmio = devm_ioremap(&pdev->dev, res->start, size);
return devm_ioremap(...);
> + } else if (IS_ERR(mmio)) {
> + mmio = NULL;
> + }
> + }
> +
> + return mmio;
return IS_ERR(mmio) ? NULL : mmio;
> +}
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds