remoteproc: stm32: Use devm_rproc_alloc() helper
authorAndrew Davis <afd@ti.com>
Tue, 23 Jan 2024 18:46:32 +0000 (12:46 -0600)
committerMathieu Poirier <mathieu.poirier@linaro.org>
Fri, 2 Feb 2024 18:39:05 +0000 (11:39 -0700)
Use the device lifecycle managed allocation function. This helps prevent
mistakes like freeing out of order in cleanup functions and forgetting to
free on error paths.

Signed-off-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20240123184632.725054-9-afd@ti.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
drivers/remoteproc/stm32_rproc.c

index 10b442c6f6323266bd113b500919c7ab3c11a0b3..88623df7d0c35a0ab1971befbe076721f2316822 100644 (file)
@@ -843,7 +843,7 @@ static int stm32_rproc_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
-       rproc = rproc_alloc(dev, np->name, &st_rproc_ops, NULL, sizeof(*ddata));
+       rproc = devm_rproc_alloc(dev, np->name, &st_rproc_ops, NULL, sizeof(*ddata));
        if (!rproc)
                return -ENOMEM;
 
@@ -897,7 +897,6 @@ free_rproc:
                dev_pm_clear_wake_irq(dev);
                device_init_wakeup(dev, false);
        }
-       rproc_free(rproc);
        return ret;
 }
 
@@ -918,7 +917,6 @@ static void stm32_rproc_remove(struct platform_device *pdev)
                dev_pm_clear_wake_irq(dev);
                device_init_wakeup(dev, false);
        }
-       rproc_free(rproc);
 }
 
 static int stm32_rproc_suspend(struct device *dev)