Commit 64e17ec2 authored by Andrew Davis's avatar Andrew Davis Committed by Mathieu Poirier

remoteproc: k3-dsp: 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/20240123184913.725435-1-afd@ti.comSigned-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
parent c77b35ce
...@@ -690,8 +690,8 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) ...@@ -690,8 +690,8 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)
if (ret) if (ret)
return dev_err_probe(dev, ret, "failed to parse firmware-name property\n"); return dev_err_probe(dev, ret, "failed to parse firmware-name property\n");
rproc = rproc_alloc(dev, dev_name(dev), &k3_dsp_rproc_ops, fw_name, rproc = devm_rproc_alloc(dev, dev_name(dev), &k3_dsp_rproc_ops,
sizeof(*kproc)); fw_name, sizeof(*kproc));
if (!rproc) if (!rproc)
return -ENOMEM; return -ENOMEM;
...@@ -707,12 +707,9 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) ...@@ -707,12 +707,9 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)
kproc->data = data; kproc->data = data;
kproc->ti_sci = ti_sci_get_by_phandle(np, "ti,sci"); kproc->ti_sci = ti_sci_get_by_phandle(np, "ti,sci");
if (IS_ERR(kproc->ti_sci)) { if (IS_ERR(kproc->ti_sci))
ret = dev_err_probe(dev, PTR_ERR(kproc->ti_sci), return dev_err_probe(dev, PTR_ERR(kproc->ti_sci),
"failed to get ti-sci handle\n"); "failed to get ti-sci handle\n");
kproc->ti_sci = NULL;
goto free_rproc;
}
ret = of_property_read_u32(np, "ti,sci-dev-id", &kproc->ti_sci_id); ret = of_property_read_u32(np, "ti,sci-dev-id", &kproc->ti_sci_id);
if (ret) { if (ret) {
...@@ -810,8 +807,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) ...@@ -810,8 +807,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)
ret1 = ti_sci_put_handle(kproc->ti_sci); ret1 = ti_sci_put_handle(kproc->ti_sci);
if (ret1) if (ret1)
dev_err(dev, "failed to put ti_sci handle (%pe)\n", ERR_PTR(ret1)); dev_err(dev, "failed to put ti_sci handle (%pe)\n", ERR_PTR(ret1));
free_rproc:
rproc_free(rproc);
return ret; return ret;
} }
...@@ -844,7 +839,6 @@ static void k3_dsp_rproc_remove(struct platform_device *pdev) ...@@ -844,7 +839,6 @@ static void k3_dsp_rproc_remove(struct platform_device *pdev)
dev_err(dev, "failed to put ti_sci handle (%pe)\n", ERR_PTR(ret)); dev_err(dev, "failed to put ti_sci handle (%pe)\n", ERR_PTR(ret));
k3_dsp_reserved_mem_exit(kproc); k3_dsp_reserved_mem_exit(kproc);
rproc_free(kproc->rproc);
} }
static const struct k3_dsp_mem_data c66_mems[] = { static const struct k3_dsp_mem_data c66_mems[] = {
......
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