Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mailbox: test: really ignore optional memory resources

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@sang-engineering.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>

authored by

Wolfram Sang and committed by
Jassi Brar
9efbbf81 8a19c5aa

+21 -16
+21 -16
drivers/mailbox/mailbox-test.c
··· 355 355 return channel; 356 356 } 357 357 358 + static void __iomem *mbox_test_ioremap(struct platform_device *pdev, unsigned int res_num) 359 + { 360 + struct resource *res; 361 + void __iomem *mmio; 362 + 363 + res = platform_get_resource(pdev, IORESOURCE_MEM, res_num); 364 + if (!res) 365 + return NULL; 366 + 367 + mmio = devm_ioremap_resource(&pdev->dev, res); 368 + if (PTR_ERR(mmio) == -EBUSY) { 369 + dev_info(&pdev->dev, "trying workaround with plain ioremap\n"); 370 + return devm_ioremap(&pdev->dev, res->start, resource_size(res)); 371 + } 372 + 373 + return IS_ERR(mmio) ? NULL : mmio; 374 + } 375 + 358 376 static int mbox_test_probe(struct platform_device *pdev) 359 377 { 360 378 struct mbox_test_device *tdev; 361 - struct resource *res; 362 - resource_size_t size; 363 379 int ret; 364 380 365 381 tdev = devm_kzalloc(&pdev->dev, sizeof(*tdev), GFP_KERNEL); ··· 383 367 return -ENOMEM; 384 368 385 369 /* It's okay for MMIO to be NULL */ 386 - tdev->tx_mmio = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 387 - if (PTR_ERR(tdev->tx_mmio) == -EBUSY) { 388 - /* if reserved area in SRAM, try just ioremap */ 389 - size = resource_size(res); 390 - tdev->tx_mmio = devm_ioremap(&pdev->dev, res->start, size); 391 - } else if (IS_ERR(tdev->tx_mmio)) { 392 - tdev->tx_mmio = NULL; 393 - } 370 + tdev->tx_mmio = mbox_test_ioremap(pdev, 0); 394 371 395 372 /* If specified, second reg entry is Rx MMIO */ 396 - tdev->rx_mmio = devm_platform_get_and_ioremap_resource(pdev, 1, &res); 397 - if (PTR_ERR(tdev->rx_mmio) == -EBUSY) { 398 - size = resource_size(res); 399 - tdev->rx_mmio = devm_ioremap(&pdev->dev, res->start, size); 400 - } else if (IS_ERR(tdev->rx_mmio)) { 373 + tdev->rx_mmio = mbox_test_ioremap(pdev, 1); 374 + if (!tdev->rx_mmio) 401 375 tdev->rx_mmio = tdev->tx_mmio; 402 - } 403 376 404 377 tdev->tx_channel = mbox_test_request_channel(pdev, "tx"); 405 378 tdev->rx_channel = mbox_test_request_channel(pdev, "rx");