Commit c92ab8aa authored by Andrew Davis's avatar Andrew Davis Committed by Bjorn Andersson

remoteproc: qcom_wcnss: 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-7-afd@ti.comSigned-off-by: default avatarBjorn Andersson <andersson@kernel.org>
parent 41854ea9
...@@ -555,7 +555,7 @@ static int wcnss_probe(struct platform_device *pdev) ...@@ -555,7 +555,7 @@ static int wcnss_probe(struct platform_device *pdev)
if (ret < 0 && ret != -EINVAL) if (ret < 0 && ret != -EINVAL)
return ret; return ret;
rproc = rproc_alloc(&pdev->dev, pdev->name, &wcnss_ops, rproc = devm_rproc_alloc(&pdev->dev, pdev->name, &wcnss_ops,
fw_name, sizeof(*wcnss)); fw_name, sizeof(*wcnss));
if (!rproc) { if (!rproc) {
dev_err(&pdev->dev, "unable to allocate remoteproc\n"); dev_err(&pdev->dev, "unable to allocate remoteproc\n");
...@@ -574,14 +574,12 @@ static int wcnss_probe(struct platform_device *pdev) ...@@ -574,14 +574,12 @@ static int wcnss_probe(struct platform_device *pdev)
mutex_init(&wcnss->iris_lock); mutex_init(&wcnss->iris_lock);
mmio = devm_platform_ioremap_resource_byname(pdev, "pmu"); mmio = devm_platform_ioremap_resource_byname(pdev, "pmu");
if (IS_ERR(mmio)) { if (IS_ERR(mmio))
ret = PTR_ERR(mmio); return PTR_ERR(mmio);
goto free_rproc;
}
ret = wcnss_alloc_memory_region(wcnss); ret = wcnss_alloc_memory_region(wcnss);
if (ret) if (ret)
goto free_rproc; return ret;
wcnss->pmu_cfg = mmio + data->pmu_offset; wcnss->pmu_cfg = mmio + data->pmu_offset;
wcnss->spare_out = mmio + data->spare_offset; wcnss->spare_out = mmio + data->spare_offset;
...@@ -592,7 +590,7 @@ static int wcnss_probe(struct platform_device *pdev) ...@@ -592,7 +590,7 @@ static int wcnss_probe(struct platform_device *pdev)
*/ */
ret = wcnss_init_pds(wcnss, data->pd_names); ret = wcnss_init_pds(wcnss, data->pd_names);
if (ret && (ret != -ENODATA || !data->num_pd_vregs)) if (ret && (ret != -ENODATA || !data->num_pd_vregs))
goto free_rproc; return ret;
ret = wcnss_init_regulators(wcnss, data->vregs, data->num_vregs, ret = wcnss_init_regulators(wcnss, data->vregs, data->num_vregs,
data->num_pd_vregs); data->num_pd_vregs);
...@@ -656,8 +654,6 @@ static int wcnss_probe(struct platform_device *pdev) ...@@ -656,8 +654,6 @@ static int wcnss_probe(struct platform_device *pdev)
qcom_iris_remove(wcnss->iris); qcom_iris_remove(wcnss->iris);
detach_pds: detach_pds:
wcnss_release_pds(wcnss); wcnss_release_pds(wcnss);
free_rproc:
rproc_free(rproc);
return ret; return ret;
} }
...@@ -673,7 +669,6 @@ static void wcnss_remove(struct platform_device *pdev) ...@@ -673,7 +669,6 @@ static void wcnss_remove(struct platform_device *pdev)
qcom_remove_sysmon_subdev(wcnss->sysmon); qcom_remove_sysmon_subdev(wcnss->sysmon);
qcom_remove_smd_subdev(wcnss->rproc, &wcnss->smd_subdev); qcom_remove_smd_subdev(wcnss->rproc, &wcnss->smd_subdev);
wcnss_release_pds(wcnss); wcnss_release_pds(wcnss);
rproc_free(wcnss->rproc);
} }
static const struct of_device_id wcnss_of_match[] = { static const struct of_device_id wcnss_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