Switch to devm_of_reserved_mem_device_init() so the reserved memory
region is released automatically on probe failure or device removal.
Remove the four explicit of_reserved_mem_device_release() calls and
collapse the now-empty err_release_mem label into err_free.

Signed-off-by: Mukesh Ojha <[email protected]>
---
 drivers/media/platform/nuvoton/npcm-video.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/nuvoton/npcm-video.c 
b/drivers/media/platform/nuvoton/npcm-video.c
index 52505af35c08..6786736c8f07 100644
--- a/drivers/media/platform/nuvoton/npcm-video.c
+++ b/drivers/media/platform/nuvoton/npcm-video.c
@@ -1715,17 +1715,15 @@ static int npcm_video_init(struct npcm_video *video)
                return rc;
        }
 
-       of_reserved_mem_device_init(dev);
+       devm_of_reserved_mem_device_init(dev);
        rc = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
        if (rc) {
                dev_err(dev, "Failed to set DMA mask\n");
-               of_reserved_mem_device_release(dev);
                return rc;
        }
 
        rc = npcm_video_ece_init(video);
        if (rc) {
-               of_reserved_mem_device_release(dev);
                dev_err(dev, "Failed to initialize ECE\n");
                return rc;
        }
@@ -1789,13 +1787,11 @@ static int npcm_video_probe(struct platform_device 
*pdev)
 
        rc = npcm_video_setup_video(video);
        if (rc)
-               goto err_release_mem;
+               goto err_free;
 
        dev_info(video->dev, "NPCM video driver probed\n");
        return 0;
 
-err_release_mem:
-       of_reserved_mem_device_release(&pdev->dev);
 err_free:
        kfree(video);
        return rc;
@@ -1814,7 +1810,6 @@ static void npcm_video_remove(struct platform_device 
*pdev)
        if (video->ece.enable)
                npcm_video_ece_stop(video);
        kfree(video);
-       of_reserved_mem_device_release(dev);
 }
 
 static const struct of_device_id npcm_video_match[] = {
-- 
2.53.0


Reply via email to