Commit f1e05cc1 authored by Andrew Davis's avatar Andrew Davis Committed by Mathieu Poirier

remoteproc: imx_rproc: Use devm_rproc_alloc() helper

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: default avatarAndrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20240123184632.725054-2-afd@ti.comSigned-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
parent 8f12de79
...@@ -1104,16 +1104,14 @@ static int imx_rproc_probe(struct platform_device *pdev) ...@@ -1104,16 +1104,14 @@ static int imx_rproc_probe(struct platform_device *pdev)
int ret; int ret;
/* set some other name then imx */ /* set some other name then imx */
rproc = rproc_alloc(dev, "imx-rproc", &imx_rproc_ops, rproc = devm_rproc_alloc(dev, "imx-rproc", &imx_rproc_ops,
NULL, sizeof(*priv)); NULL, sizeof(*priv));
if (!rproc) if (!rproc)
return -ENOMEM; return -ENOMEM;
dcfg = of_device_get_match_data(dev); dcfg = of_device_get_match_data(dev);
if (!dcfg) { if (!dcfg)
ret = -EINVAL; return -EINVAL;
goto err_put_rproc;
}
priv = rproc->priv; priv = rproc->priv;
priv->rproc = rproc; priv->rproc = rproc;
...@@ -1124,8 +1122,7 @@ static int imx_rproc_probe(struct platform_device *pdev) ...@@ -1124,8 +1122,7 @@ static int imx_rproc_probe(struct platform_device *pdev)
priv->workqueue = create_workqueue(dev_name(dev)); priv->workqueue = create_workqueue(dev_name(dev));
if (!priv->workqueue) { if (!priv->workqueue) {
dev_err(dev, "cannot create workqueue\n"); dev_err(dev, "cannot create workqueue\n");
ret = -ENOMEM; return -ENOMEM;
goto err_put_rproc;
} }
ret = imx_rproc_xtr_mbox_init(rproc); ret = imx_rproc_xtr_mbox_init(rproc);
...@@ -1167,8 +1164,6 @@ static int imx_rproc_probe(struct platform_device *pdev) ...@@ -1167,8 +1164,6 @@ static int imx_rproc_probe(struct platform_device *pdev)
imx_rproc_free_mbox(rproc); imx_rproc_free_mbox(rproc);
err_put_wkq: err_put_wkq:
destroy_workqueue(priv->workqueue); destroy_workqueue(priv->workqueue);
err_put_rproc:
rproc_free(rproc);
return ret; return ret;
} }
...@@ -1183,7 +1178,6 @@ static void imx_rproc_remove(struct platform_device *pdev) ...@@ -1183,7 +1178,6 @@ static void imx_rproc_remove(struct platform_device *pdev)
imx_rproc_put_scu(rproc); imx_rproc_put_scu(rproc);
imx_rproc_free_mbox(rproc); imx_rproc_free_mbox(rproc);
destroy_workqueue(priv->workqueue); destroy_workqueue(priv->workqueue);
rproc_free(rproc);
} }
static const struct of_device_id imx_rproc_of_match[] = { static const struct of_device_id imx_rproc_of_match[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment