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 <[email protected]>
---
drivers/remoteproc/imx_dsp_rproc.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
index a1c62d15f16c6..56a799cb8b363 100644
--- a/drivers/remoteproc/imx_dsp_rproc.c
+++ b/drivers/remoteproc/imx_dsp_rproc.c
@@ -1104,8 +1104,8 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
return ret;
}
- rproc = rproc_alloc(dev, "imx-dsp-rproc", &imx_dsp_rproc_ops, fw_name,
- sizeof(*priv));
+ rproc = devm_rproc_alloc(dev, "imx-dsp-rproc", &imx_dsp_rproc_ops,
+ fw_name, sizeof(*priv));
if (!rproc)
return -ENOMEM;
@@ -1125,14 +1125,14 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
ret = imx_dsp_rproc_detect_mode(priv);
if (ret) {
dev_err(dev, "failed on imx_dsp_rproc_detect_mode\n");
- goto err_put_rproc;
+ return ret;
}
/* There are multiple power domains required by DSP on some platform */
ret = imx_dsp_attach_pm_domains(priv);
if (ret) {
dev_err(dev, "failed on imx_dsp_attach_pm_domains\n");
- goto err_put_rproc;
+ return ret;
}
/* Get clocks */
ret = imx_dsp_rproc_clk_get(priv);
@@ -1155,8 +1155,6 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
err_detach_domains:
imx_dsp_detach_pm_domains(priv);
-err_put_rproc:
- rproc_free(rproc);
return ret;
}
@@ -1169,7 +1167,6 @@ static void imx_dsp_rproc_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
rproc_del(rproc);
imx_dsp_detach_pm_domains(priv);
- rproc_free(rproc);
}
/* pm runtime functions */
--
2.39.2
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 <[email protected]>
---
drivers/remoteproc/qcom_q6v5_adsp.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/remoteproc/qcom_q6v5_adsp.c b/drivers/remoteproc/qcom_q6v5_adsp.c
index 6c67514cc4931..34ac996a93b20 100644
--- a/drivers/remoteproc/qcom_q6v5_adsp.c
+++ b/drivers/remoteproc/qcom_q6v5_adsp.c
@@ -683,8 +683,8 @@ static int adsp_probe(struct platform_device *pdev)
return ret;
}
- rproc = rproc_alloc(&pdev->dev, pdev->name, &adsp_ops,
- firmware_name, sizeof(*adsp));
+ rproc = devm_rproc_alloc(&pdev->dev, pdev->name, &adsp_ops,
+ firmware_name, sizeof(*adsp));
if (!rproc) {
dev_err(&pdev->dev, "unable to allocate remoteproc\n");
return -ENOMEM;
@@ -709,17 +709,17 @@ static int adsp_probe(struct platform_device *pdev)
ret = adsp_alloc_memory_region(adsp);
if (ret)
- goto free_rproc;
+ return ret;
ret = adsp_init_clock(adsp, desc->clk_ids);
if (ret)
- goto free_rproc;
+ return ret;
ret = qcom_rproc_pds_attach(adsp->dev, adsp,
desc->proxy_pd_names);
if (ret < 0) {
dev_err(&pdev->dev, "Failed to attach proxy power domains\n");
- goto free_rproc;
+ return ret;
}
adsp->proxy_pd_count = ret;
@@ -755,9 +755,6 @@ static int adsp_probe(struct platform_device *pdev)
disable_pm:
qcom_rproc_pds_detach(adsp, adsp->proxy_pds, adsp->proxy_pd_count);
-free_rproc:
- rproc_free(rproc);
-
return ret;
}
@@ -772,7 +769,6 @@ static void adsp_remove(struct platform_device *pdev)
qcom_remove_sysmon_subdev(adsp->sysmon);
qcom_remove_ssr_subdev(adsp->rproc, &adsp->ssr_subdev);
qcom_rproc_pds_detach(adsp, adsp->proxy_pds, adsp->proxy_pd_count);
- rproc_free(adsp->rproc);
}
static const struct adsp_pil_data adsp_resource_init = {
--
2.39.2
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 <[email protected]>
---
drivers/remoteproc/qcom_wcnss.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c
index 90de22c81da97..a7bb9da27029d 100644
--- a/drivers/remoteproc/qcom_wcnss.c
+++ b/drivers/remoteproc/qcom_wcnss.c
@@ -555,8 +555,8 @@ static int wcnss_probe(struct platform_device *pdev)
if (ret < 0 && ret != -EINVAL)
return ret;
- rproc = rproc_alloc(&pdev->dev, pdev->name, &wcnss_ops,
- fw_name, sizeof(*wcnss));
+ rproc = devm_rproc_alloc(&pdev->dev, pdev->name, &wcnss_ops,
+ fw_name, sizeof(*wcnss));
if (!rproc) {
dev_err(&pdev->dev, "unable to allocate remoteproc\n");
return -ENOMEM;
@@ -574,14 +574,12 @@ static int wcnss_probe(struct platform_device *pdev)
mutex_init(&wcnss->iris_lock);
mmio = devm_platform_ioremap_resource_byname(pdev, "pmu");
- if (IS_ERR(mmio)) {
- ret = PTR_ERR(mmio);
- goto free_rproc;
- }
+ if (IS_ERR(mmio))
+ return PTR_ERR(mmio);
ret = wcnss_alloc_memory_region(wcnss);
if (ret)
- goto free_rproc;
+ return ret;
wcnss->pmu_cfg = mmio + data->pmu_offset;
wcnss->spare_out = mmio + data->spare_offset;
@@ -592,7 +590,7 @@ static int wcnss_probe(struct platform_device *pdev)
*/
ret = wcnss_init_pds(wcnss, data->pd_names);
if (ret && (ret != -ENODATA || !data->num_pd_vregs))
- goto free_rproc;
+ return ret;
ret = wcnss_init_regulators(wcnss, data->vregs, data->num_vregs,
data->num_pd_vregs);
@@ -656,8 +654,6 @@ static int wcnss_probe(struct platform_device *pdev)
qcom_iris_remove(wcnss->iris);
detach_pds:
wcnss_release_pds(wcnss);
-free_rproc:
- rproc_free(rproc);
return ret;
}
@@ -673,7 +669,6 @@ static void wcnss_remove(struct platform_device *pdev)
qcom_remove_sysmon_subdev(wcnss->sysmon);
qcom_remove_smd_subdev(wcnss->rproc, &wcnss->smd_subdev);
wcnss_release_pds(wcnss);
- rproc_free(wcnss->rproc);
}
static const struct of_device_id wcnss_of_match[] = {
--
2.39.2
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 <[email protected]>
---
drivers/remoteproc/st_remoteproc.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/remoteproc/st_remoteproc.c b/drivers/remoteproc/st_remoteproc.c
index cb163766c56d5..1340be9d01101 100644
--- a/drivers/remoteproc/st_remoteproc.c
+++ b/drivers/remoteproc/st_remoteproc.c
@@ -347,23 +347,21 @@ static int st_rproc_probe(struct platform_device *pdev)
int enabled;
int ret, i;
- 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;
rproc->has_iommu = false;
ddata = rproc->priv;
ddata->config = (struct st_rproc_config *)device_get_match_data(dev);
- if (!ddata->config) {
- ret = -ENODEV;
- goto free_rproc;
- }
+ if (!ddata->config)
+ return -ENODEV;
platform_set_drvdata(pdev, rproc);
ret = st_rproc_parse_dt(pdev);
if (ret)
- goto free_rproc;
+ return ret;
enabled = st_rproc_state(pdev);
if (enabled < 0) {
@@ -439,8 +437,7 @@ static int st_rproc_probe(struct platform_device *pdev)
mbox_free_channel(ddata->mbox_chan[i]);
free_clk:
clk_unprepare(ddata->clk);
-free_rproc:
- rproc_free(rproc);
+
return ret;
}
@@ -456,8 +453,6 @@ static void st_rproc_remove(struct platform_device *pdev)
for (i = 0; i < ST_RPROC_MAX_VRING * MBOX_MAX; i++)
mbox_free_channel(ddata->mbox_chan[i]);
-
- rproc_free(rproc);
}
static struct platform_driver st_rproc_driver = {
--
2.39.2
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 <[email protected]>
---
drivers/remoteproc/qcom_q6v5_mss.c | 28 ++++++++++++----------------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c
index 394b2c1cb5e21..1779fc890e102 100644
--- a/drivers/remoteproc/qcom_q6v5_mss.c
+++ b/drivers/remoteproc/qcom_q6v5_mss.c
@@ -1990,8 +1990,8 @@ static int q6v5_probe(struct platform_device *pdev)
return ret;
}
- rproc = rproc_alloc(&pdev->dev, pdev->name, &q6v5_ops,
- mba_image, sizeof(*qproc));
+ rproc = devm_rproc_alloc(&pdev->dev, pdev->name, &q6v5_ops,
+ mba_image, sizeof(*qproc));
if (!rproc) {
dev_err(&pdev->dev, "failed to allocate rproc\n");
return -ENOMEM;
@@ -2008,7 +2008,7 @@ static int q6v5_probe(struct platform_device *pdev)
1, &qproc->hexagon_mdt_image);
if (ret < 0 && ret != -EINVAL) {
dev_err(&pdev->dev, "unable to read mpss firmware-name\n");
- goto free_rproc;
+ return ret;
}
platform_set_drvdata(pdev, qproc);
@@ -2019,17 +2019,17 @@ static int q6v5_probe(struct platform_device *pdev)
qproc->has_spare_reg = desc->has_spare_reg;
ret = q6v5_init_mem(qproc, pdev);
if (ret)
- goto free_rproc;
+ return ret;
ret = q6v5_alloc_memory_region(qproc);
if (ret)
- goto free_rproc;
+ return ret;
ret = q6v5_init_clocks(&pdev->dev, qproc->proxy_clks,
desc->proxy_clk_names);
if (ret < 0) {
dev_err(&pdev->dev, "Failed to get proxy clocks.\n");
- goto free_rproc;
+ return ret;
}
qproc->proxy_clk_count = ret;
@@ -2037,7 +2037,7 @@ static int q6v5_probe(struct platform_device *pdev)
desc->reset_clk_names);
if (ret < 0) {
dev_err(&pdev->dev, "Failed to get reset clocks.\n");
- goto free_rproc;
+ return ret;
}
qproc->reset_clk_count = ret;
@@ -2045,7 +2045,7 @@ static int q6v5_probe(struct platform_device *pdev)
desc->active_clk_names);
if (ret < 0) {
dev_err(&pdev->dev, "Failed to get active clocks.\n");
- goto free_rproc;
+ return ret;
}
qproc->active_clk_count = ret;
@@ -2053,7 +2053,7 @@ static int q6v5_probe(struct platform_device *pdev)
desc->proxy_supply);
if (ret < 0) {
dev_err(&pdev->dev, "Failed to get proxy regulators.\n");
- goto free_rproc;
+ return ret;
}
qproc->proxy_reg_count = ret;
@@ -2061,7 +2061,7 @@ static int q6v5_probe(struct platform_device *pdev)
desc->active_supply);
if (ret < 0) {
dev_err(&pdev->dev, "Failed to get active regulators.\n");
- goto free_rproc;
+ return ret;
}
qproc->active_reg_count = ret;
@@ -2074,12 +2074,12 @@ static int q6v5_probe(struct platform_device *pdev)
desc->fallback_proxy_supply);
if (ret < 0) {
dev_err(&pdev->dev, "Failed to get fallback proxy regulators.\n");
- goto free_rproc;
+ return ret;
}
qproc->fallback_proxy_reg_count = ret;
} else if (ret < 0) {
dev_err(&pdev->dev, "Failed to init power domains\n");
- goto free_rproc;
+ return ret;
} else {
qproc->proxy_pd_count = ret;
}
@@ -2127,8 +2127,6 @@ static int q6v5_probe(struct platform_device *pdev)
qcom_remove_glink_subdev(rproc, &qproc->glink_subdev);
detach_proxy_pds:
q6v5_pds_detach(qproc, qproc->proxy_pds, qproc->proxy_pd_count);
-free_rproc:
- rproc_free(rproc);
return ret;
}
@@ -2149,8 +2147,6 @@ static void q6v5_remove(struct platform_device *pdev)
qcom_remove_glink_subdev(rproc, &qproc->glink_subdev);
q6v5_pds_detach(qproc, qproc->proxy_pds, qproc->proxy_pd_count);
-
- rproc_free(rproc);
}
static const struct rproc_hexagon_res sc7180_mss = {
--
2.39.2
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 <[email protected]>
---
drivers/remoteproc/imx_rproc.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 8bb293b9f327c..55ecce3ab5f75 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -1104,16 +1104,14 @@ static int imx_rproc_probe(struct platform_device *pdev)
int ret;
/* set some other name then imx */
- rproc = rproc_alloc(dev, "imx-rproc", &imx_rproc_ops,
- NULL, sizeof(*priv));
+ rproc = devm_rproc_alloc(dev, "imx-rproc", &imx_rproc_ops,
+ NULL, sizeof(*priv));
if (!rproc)
return -ENOMEM;
dcfg = of_device_get_match_data(dev);
- if (!dcfg) {
- ret = -EINVAL;
- goto err_put_rproc;
- }
+ if (!dcfg)
+ return -EINVAL;
priv = rproc->priv;
priv->rproc = rproc;
@@ -1124,8 +1122,7 @@ static int imx_rproc_probe(struct platform_device *pdev)
priv->workqueue = create_workqueue(dev_name(dev));
if (!priv->workqueue) {
dev_err(dev, "cannot create workqueue\n");
- ret = -ENOMEM;
- goto err_put_rproc;
+ return -ENOMEM;
}
ret = imx_rproc_xtr_mbox_init(rproc);
@@ -1167,8 +1164,6 @@ static int imx_rproc_probe(struct platform_device *pdev)
imx_rproc_free_mbox(rproc);
err_put_wkq:
destroy_workqueue(priv->workqueue);
-err_put_rproc:
- rproc_free(rproc);
return ret;
}
@@ -1183,7 +1178,6 @@ static void imx_rproc_remove(struct platform_device *pdev)
imx_rproc_put_scu(rproc);
imx_rproc_free_mbox(rproc);
destroy_workqueue(priv->workqueue);
- rproc_free(rproc);
}
static const struct of_device_id imx_rproc_of_match[] = {
--
2.39.2
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 <[email protected]>
---
drivers/remoteproc/stm32_rproc.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c
index 4f469f0bcf8b2..fed0866de1819 100644
--- a/drivers/remoteproc/stm32_rproc.c
+++ b/drivers/remoteproc/stm32_rproc.c
@@ -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 @@ static int stm32_rproc_probe(struct platform_device *pdev)
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)
--
2.39.2
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 <[email protected]>
---
drivers/remoteproc/qcom_q6v5_pas.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
index a9dd58608052c..60b0cd30c0592 100644
--- a/drivers/remoteproc/qcom_q6v5_pas.c
+++ b/drivers/remoteproc/qcom_q6v5_pas.c
@@ -678,7 +678,7 @@ static int adsp_probe(struct platform_device *pdev)
if (desc->minidump_id)
ops = &adsp_minidump_ops;
- rproc = rproc_alloc(&pdev->dev, pdev->name, ops, fw_name, sizeof(*adsp));
+ rproc = devm_rproc_alloc(&pdev->dev, pdev->name, ops, fw_name, sizeof(*adsp));
if (!rproc) {
dev_err(&pdev->dev, "unable to allocate remoteproc\n");
@@ -754,7 +754,6 @@ static int adsp_probe(struct platform_device *pdev)
adsp_pds_detach(adsp, adsp->proxy_pds, adsp->proxy_pd_count);
free_rproc:
device_init_wakeup(adsp->dev, false);
- rproc_free(rproc);
return ret;
}
@@ -773,7 +772,6 @@ static void adsp_remove(struct platform_device *pdev)
qcom_remove_ssr_subdev(adsp->rproc, &adsp->ssr_subdev);
adsp_pds_detach(adsp, adsp->proxy_pds, adsp->proxy_pd_count);
device_init_wakeup(adsp->dev, false);
- rproc_free(adsp->rproc);
}
static const struct adsp_data adsp_resource_init = {
--
2.39.2
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 <[email protected]>
---
drivers/remoteproc/qcom_q6v5_wcss.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/drivers/remoteproc/qcom_q6v5_wcss.c b/drivers/remoteproc/qcom_q6v5_wcss.c
index cff1fa07d1def..94f68c919ee62 100644
--- a/drivers/remoteproc/qcom_q6v5_wcss.c
+++ b/drivers/remoteproc/qcom_q6v5_wcss.c
@@ -1011,8 +1011,8 @@ static int q6v5_wcss_probe(struct platform_device *pdev)
if (!desc)
return -EINVAL;
- rproc = rproc_alloc(&pdev->dev, pdev->name, desc->ops,
- desc->firmware_name, sizeof(*wcss));
+ rproc = devm_rproc_alloc(&pdev->dev, pdev->name, desc->ops,
+ desc->firmware_name, sizeof(*wcss));
if (!rproc) {
dev_err(&pdev->dev, "failed to allocate rproc\n");
return -ENOMEM;
@@ -1027,29 +1027,29 @@ static int q6v5_wcss_probe(struct platform_device *pdev)
ret = q6v5_wcss_init_mmio(wcss, pdev);
if (ret)
- goto free_rproc;
+ return ret;
ret = q6v5_alloc_memory_region(wcss);
if (ret)
- goto free_rproc;
+ return ret;
if (wcss->version == WCSS_QCS404) {
ret = q6v5_wcss_init_clock(wcss);
if (ret)
- goto free_rproc;
+ return ret;
ret = q6v5_wcss_init_regulator(wcss);
if (ret)
- goto free_rproc;
+ return ret;
}
ret = q6v5_wcss_init_reset(wcss, desc);
if (ret)
- goto free_rproc;
+ return ret;
ret = qcom_q6v5_init(&wcss->q6v5, pdev, rproc, desc->crash_reason_smem, NULL, NULL);
if (ret)
- goto free_rproc;
+ return ret;
qcom_add_glink_subdev(rproc, &wcss->glink_subdev, "q6wcss");
qcom_add_ssr_subdev(rproc, &wcss->ssr_subdev, "q6wcss");
@@ -1061,16 +1061,11 @@ static int q6v5_wcss_probe(struct platform_device *pdev)
ret = rproc_add(rproc);
if (ret)
- goto free_rproc;
+ return ret;
platform_set_drvdata(pdev, rproc);
return 0;
-
-free_rproc:
- rproc_free(rproc);
-
- return ret;
}
static void q6v5_wcss_remove(struct platform_device *pdev)
@@ -1080,7 +1075,6 @@ static void q6v5_wcss_remove(struct platform_device *pdev)
qcom_q6v5_deinit(&wcss->q6v5);
rproc_del(rproc);
- rproc_free(rproc);
}
static const struct wcss_data wcss_ipq8074_res_init = {
--
2.39.2
On 1/23/2024 8:46 PM, Andrew Davis wrote:
> 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 <[email protected]>
Reviewed-by: Iuliana Prodan <[email protected]>
Thanks,
Iulia
> ---
> drivers/remoteproc/imx_rproc.c | 16 +++++-----------
> 1 file changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index 8bb293b9f327c..55ecce3ab5f75 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -1104,16 +1104,14 @@ static int imx_rproc_probe(struct platform_device *pdev)
> int ret;
>
> /* set some other name then imx */
> - rproc = rproc_alloc(dev, "imx-rproc", &imx_rproc_ops,
> - NULL, sizeof(*priv));
> + rproc = devm_rproc_alloc(dev, "imx-rproc", &imx_rproc_ops,
> + NULL, sizeof(*priv));
> if (!rproc)
> return -ENOMEM;
>
> dcfg = of_device_get_match_data(dev);
> - if (!dcfg) {
> - ret = -EINVAL;
> - goto err_put_rproc;
> - }
> + if (!dcfg)
> + return -EINVAL;
>
> priv = rproc->priv;
> priv->rproc = rproc;
> @@ -1124,8 +1122,7 @@ static int imx_rproc_probe(struct platform_device *pdev)
> priv->workqueue = create_workqueue(dev_name(dev));
> if (!priv->workqueue) {
> dev_err(dev, "cannot create workqueue\n");
> - ret = -ENOMEM;
> - goto err_put_rproc;
> + return -ENOMEM;
> }
>
> ret = imx_rproc_xtr_mbox_init(rproc);
> @@ -1167,8 +1164,6 @@ static int imx_rproc_probe(struct platform_device *pdev)
> imx_rproc_free_mbox(rproc);
> err_put_wkq:
> destroy_workqueue(priv->workqueue);
> -err_put_rproc:
> - rproc_free(rproc);
>
> return ret;
> }
> @@ -1183,7 +1178,6 @@ static void imx_rproc_remove(struct platform_device *pdev)
> imx_rproc_put_scu(rproc);
> imx_rproc_free_mbox(rproc);
> destroy_workqueue(priv->workqueue);
> - rproc_free(rproc);
> }
>
> static const struct of_device_id imx_rproc_of_match[] = {
On 1/23/2024 8:46 PM, Andrew Davis wrote:
> 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 <[email protected]>
Reviewed-by: Iuliana Prodan <[email protected]>
Thanks,
Iulia
> ---
> drivers/remoteproc/imx_dsp_rproc.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
> index a1c62d15f16c6..56a799cb8b363 100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -1104,8 +1104,8 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
> return ret;
> }
>
> - rproc = rproc_alloc(dev, "imx-dsp-rproc", &imx_dsp_rproc_ops, fw_name,
> - sizeof(*priv));
> + rproc = devm_rproc_alloc(dev, "imx-dsp-rproc", &imx_dsp_rproc_ops,
> + fw_name, sizeof(*priv));
> if (!rproc)
> return -ENOMEM;
>
> @@ -1125,14 +1125,14 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
> ret = imx_dsp_rproc_detect_mode(priv);
> if (ret) {
> dev_err(dev, "failed on imx_dsp_rproc_detect_mode\n");
> - goto err_put_rproc;
> + return ret;
> }
>
> /* There are multiple power domains required by DSP on some platform */
> ret = imx_dsp_attach_pm_domains(priv);
> if (ret) {
> dev_err(dev, "failed on imx_dsp_attach_pm_domains\n");
> - goto err_put_rproc;
> + return ret;
> }
> /* Get clocks */
> ret = imx_dsp_rproc_clk_get(priv);
> @@ -1155,8 +1155,6 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
>
> err_detach_domains:
> imx_dsp_detach_pm_domains(priv);
> -err_put_rproc:
> - rproc_free(rproc);
>
> return ret;
> }
> @@ -1169,7 +1167,6 @@ static void imx_dsp_rproc_remove(struct platform_device *pdev)
> pm_runtime_disable(&pdev->dev);
> rproc_del(rproc);
> imx_dsp_detach_pm_domains(priv);
> - rproc_free(rproc);
> }
>
> /* pm runtime functions */
On Tue, Jan 23, 2024 at 12:46:32PM -0600, Andrew Davis wrote:
> 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 <[email protected]>
> ---
> drivers/remoteproc/stm32_rproc.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c
> index 4f469f0bcf8b2..fed0866de1819 100644
> --- a/drivers/remoteproc/stm32_rproc.c
> +++ b/drivers/remoteproc/stm32_rproc.c
> @@ -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 @@ static int stm32_rproc_probe(struct platform_device *pdev)
> 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);
> }
I have applied patches 1, 2, 8 and 9 of this set. Bjorn handles the QCOM
peripherals and will take care of the remaining ones.
Thanks,
Mathieu
>
> static int stm32_rproc_suspend(struct device *dev)
> --
> 2.39.2
>
On 1/23/2024 10:46 AM, Andrew Davis wrote:
> 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 <[email protected]>
> ---
> drivers/remoteproc/qcom_q6v5_wcss.c | 24 +++++++++---------------
> 1 file changed, 9 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/remoteproc/qcom_q6v5_wcss.c b/drivers/remoteproc/qcom_q6v5_wcss.c
> index cff1fa07d1def..94f68c919ee62 100644
> --- a/drivers/remoteproc/qcom_q6v5_wcss.c
> +++ b/drivers/remoteproc/qcom_q6v5_wcss.c
> @@ -1011,8 +1011,8 @@ static int q6v5_wcss_probe(struct platform_device *pdev)
> if (!desc)
> return -EINVAL;
>
> - rproc = rproc_alloc(&pdev->dev, pdev->name, desc->ops,
> - desc->firmware_name, sizeof(*wcss));
> + rproc = devm_rproc_alloc(&pdev->dev, pdev->name, desc->ops,
> + desc->firmware_name, sizeof(*wcss));
> if (!rproc) {
> dev_err(&pdev->dev, "failed to allocate rproc\n");
> return -ENOMEM;
> @@ -1027,29 +1027,29 @@ static int q6v5_wcss_probe(struct platform_device *pdev)
>
> ret = q6v5_wcss_init_mmio(wcss, pdev);
> if (ret)
> - goto free_rproc;
> + return ret;
>
> ret = q6v5_alloc_memory_region(wcss);
> if (ret)
> - goto free_rproc;
> + return ret;
>
> if (wcss->version == WCSS_QCS404) {
> ret = q6v5_wcss_init_clock(wcss);
> if (ret)
> - goto free_rproc;
> + return ret;
>
> ret = q6v5_wcss_init_regulator(wcss);
> if (ret)
> - goto free_rproc;
> + return ret;
> }
>
> ret = q6v5_wcss_init_reset(wcss, desc);
> if (ret)
> - goto free_rproc;
> + return ret;
>
> ret = qcom_q6v5_init(&wcss->q6v5, pdev, rproc, desc->crash_reason_smem, NULL, NULL);
> if (ret)
> - goto free_rproc;
> + return ret;
>
> qcom_add_glink_subdev(rproc, &wcss->glink_subdev, "q6wcss");
> qcom_add_ssr_subdev(rproc, &wcss->ssr_subdev, "q6wcss");
> @@ -1061,16 +1061,11 @@ static int q6v5_wcss_probe(struct platform_device *pdev)
>
> ret = rproc_add(rproc);
> if (ret)
> - goto free_rproc;
> + return ret;
>
> platform_set_drvdata(pdev, rproc);
>
> return 0;
> -
> -free_rproc:
> - rproc_free(rproc);
> -
> - return ret;
This return statement should stay, right?
> }
>
> static void q6v5_wcss_remove(struct platform_device *pdev)
> @@ -1080,7 +1075,6 @@ static void q6v5_wcss_remove(struct platform_device *pdev)
>
> qcom_q6v5_deinit(&wcss->q6v5);
> rproc_del(rproc);
> - rproc_free(rproc);
> }
>
> static const struct wcss_data wcss_ipq8074_res_init = {
On 2/2/24 2:51 PM, Unnathi Chalicheemala wrote:
>
>
> On 1/23/2024 10:46 AM, Andrew Davis wrote:
>> 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 <[email protected]>
>> ---
>> drivers/remoteproc/qcom_q6v5_wcss.c | 24 +++++++++---------------
>> 1 file changed, 9 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/remoteproc/qcom_q6v5_wcss.c b/drivers/remoteproc/qcom_q6v5_wcss.c
>> index cff1fa07d1def..94f68c919ee62 100644
>> --- a/drivers/remoteproc/qcom_q6v5_wcss.c
>> +++ b/drivers/remoteproc/qcom_q6v5_wcss.c
>> @@ -1011,8 +1011,8 @@ static int q6v5_wcss_probe(struct platform_device *pdev)
>> if (!desc)
>> return -EINVAL;
>>
>> - rproc = rproc_alloc(&pdev->dev, pdev->name, desc->ops,
>> - desc->firmware_name, sizeof(*wcss));
>> + rproc = devm_rproc_alloc(&pdev->dev, pdev->name, desc->ops,
>> + desc->firmware_name, sizeof(*wcss));
>> if (!rproc) {
>> dev_err(&pdev->dev, "failed to allocate rproc\n");
>> return -ENOMEM;
>> @@ -1027,29 +1027,29 @@ static int q6v5_wcss_probe(struct platform_device *pdev)
>>
>> ret = q6v5_wcss_init_mmio(wcss, pdev);
>> if (ret)
>> - goto free_rproc;
>> + return ret;
>>
>> ret = q6v5_alloc_memory_region(wcss);
>> if (ret)
>> - goto free_rproc;
>> + return ret;
>>
>> if (wcss->version == WCSS_QCS404) {
>> ret = q6v5_wcss_init_clock(wcss);
>> if (ret)
>> - goto free_rproc;
>> + return ret;
>>
>> ret = q6v5_wcss_init_regulator(wcss);
>> if (ret)
>> - goto free_rproc;
>> + return ret;
>> }
>>
>> ret = q6v5_wcss_init_reset(wcss, desc);
>> if (ret)
>> - goto free_rproc;
>> + return ret;
>>
>> ret = qcom_q6v5_init(&wcss->q6v5, pdev, rproc, desc->crash_reason_smem, NULL, NULL);
>> if (ret)
>> - goto free_rproc;
>> + return ret;
>>
>> qcom_add_glink_subdev(rproc, &wcss->glink_subdev, "q6wcss");
>> qcom_add_ssr_subdev(rproc, &wcss->ssr_subdev, "q6wcss");
>> @@ -1061,16 +1061,11 @@ static int q6v5_wcss_probe(struct platform_device *pdev)
>>
>> ret = rproc_add(rproc);
>> if (ret)
>> - goto free_rproc;
>> + return ret;
>>
>> platform_set_drvdata(pdev, rproc);
>>
>> return 0;
>> -
>> -free_rproc:
>> - rproc_free(rproc);
>> -
>> - return ret;
>
> This return statement should stay, right?
>
No path goes to "free_rproc" anymore, so we always do the "return 0;"
above on non-error paths.
Andrew
>> }
>>
>> static void q6v5_wcss_remove(struct platform_device *pdev)
>> @@ -1080,7 +1075,6 @@ static void q6v5_wcss_remove(struct platform_device *pdev)
>>
>> qcom_q6v5_deinit(&wcss->q6v5);
>> rproc_del(rproc);
>> - rproc_free(rproc);
>> }
>>
>> static const struct wcss_data wcss_ipq8074_res_init = {
On 2/2/2024 1:14 PM, Andrew Davis wrote:
> On 2/2/24 2:51 PM, Unnathi Chalicheemala wrote:
>>
>>
>> On 1/23/2024 10:46 AM, Andrew Davis wrote:
>>> 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 <[email protected]>
>>> ---
>>> drivers/remoteproc/qcom_q6v5_wcss.c | 24 +++++++++---------------
>>> 1 file changed, 9 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/drivers/remoteproc/qcom_q6v5_wcss.c b/drivers/remoteproc/qcom_q6v5_wcss.c
>>> index cff1fa07d1def..94f68c919ee62 100644
>>> --- a/drivers/remoteproc/qcom_q6v5_wcss.c
>>> +++ b/drivers/remoteproc/qcom_q6v5_wcss.c
>>> @@ -1011,8 +1011,8 @@ static int q6v5_wcss_probe(struct platform_device *pdev)
>>> if (!desc)
>>> return -EINVAL;
>>> - rproc = rproc_alloc(&pdev->dev, pdev->name, desc->ops,
>>> - desc->firmware_name, sizeof(*wcss));
>>> + rproc = devm_rproc_alloc(&pdev->dev, pdev->name, desc->ops,
>>> + desc->firmware_name, sizeof(*wcss));
>>> if (!rproc) {
>>> dev_err(&pdev->dev, "failed to allocate rproc\n");
>>> return -ENOMEM;
>>> @@ -1027,29 +1027,29 @@ static int q6v5_wcss_probe(struct platform_device *pdev)
>>> ret = q6v5_wcss_init_mmio(wcss, pdev);
>>> if (ret)
>>> - goto free_rproc;
>>> + return ret;
>>> ret = q6v5_alloc_memory_region(wcss);
>>> if (ret)
>>> - goto free_rproc;
>>> + return ret;
>>> if (wcss->version == WCSS_QCS404) {
>>> ret = q6v5_wcss_init_clock(wcss);
>>> if (ret)
>>> - goto free_rproc;
>>> + return ret;
>>> ret = q6v5_wcss_init_regulator(wcss);
>>> if (ret)
>>> - goto free_rproc;
>>> + return ret;
>>> }
>>> ret = q6v5_wcss_init_reset(wcss, desc);
>>> if (ret)
>>> - goto free_rproc;
>>> + return ret;
>>> ret = qcom_q6v5_init(&wcss->q6v5, pdev, rproc, desc->crash_reason_smem, NULL, NULL);
>>> if (ret)
>>> - goto free_rproc;
>>> + return ret;
>>> qcom_add_glink_subdev(rproc, &wcss->glink_subdev, "q6wcss");
>>> qcom_add_ssr_subdev(rproc, &wcss->ssr_subdev, "q6wcss");
>>> @@ -1061,16 +1061,11 @@ static int q6v5_wcss_probe(struct platform_device *pdev)
>>> ret = rproc_add(rproc);
>>> if (ret)
>>> - goto free_rproc;
>>> + return ret;
>>> platform_set_drvdata(pdev, rproc);
>>> return 0;
>>> -
>>> -free_rproc:
>>> - rproc_free(rproc);
>>> -
>>> - return ret;
>>
>> This return statement should stay, right?
>>
>
> No path goes to "free_rproc" anymore, so we always do the "return 0;"
> above on non-error paths.
>
> Andrew
>
You're right, thanks all QCOM peripheral patches LGTM.
>>> }
>>> static void q6v5_wcss_remove(struct platform_device *pdev)
>>> @@ -1080,7 +1075,6 @@ static void q6v5_wcss_remove(struct platform_device *pdev)
>>> qcom_q6v5_deinit(&wcss->q6v5);
>>> rproc_del(rproc);
>>> - rproc_free(rproc);
>>> }
>>> static const struct wcss_data wcss_ipq8074_res_init = {