Skip to content

Commit 209dd85

Browse files
glneomathieupoirier
authored andcommitted
remoteproc: keystone: 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: Andrew Davis <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mathieu Poirier <[email protected]>
1 parent d32e716 commit 209dd85

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

drivers/remoteproc/keystone_remoteproc.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ static int keystone_rproc_probe(struct platform_device *pdev)
384384
if (!fw_name)
385385
return -ENOMEM;
386386

387-
rproc = rproc_alloc(dev, dev_name(dev), &keystone_rproc_ops, fw_name,
388-
sizeof(*ksproc));
387+
rproc = devm_rproc_alloc(dev, dev_name(dev), &keystone_rproc_ops,
388+
fw_name, sizeof(*ksproc));
389389
if (!rproc)
390390
return -ENOMEM;
391391

@@ -396,13 +396,11 @@ static int keystone_rproc_probe(struct platform_device *pdev)
396396

397397
ret = keystone_rproc_of_get_dev_syscon(pdev, ksproc);
398398
if (ret)
399-
goto free_rproc;
399+
return ret;
400400

401401
ksproc->reset = devm_reset_control_get_exclusive(dev, NULL);
402-
if (IS_ERR(ksproc->reset)) {
403-
ret = PTR_ERR(ksproc->reset);
404-
goto free_rproc;
405-
}
402+
if (IS_ERR(ksproc->reset))
403+
return PTR_ERR(ksproc->reset);
406404

407405
/* enable clock for accessing DSP internal memories */
408406
pm_runtime_enable(dev);
@@ -467,8 +465,6 @@ static int keystone_rproc_probe(struct platform_device *pdev)
467465
pm_runtime_put_sync(dev);
468466
disable_rpm:
469467
pm_runtime_disable(dev);
470-
free_rproc:
471-
rproc_free(rproc);
472468
return ret;
473469
}
474470

@@ -480,7 +476,6 @@ static void keystone_rproc_remove(struct platform_device *pdev)
480476
gpiod_put(ksproc->kick_gpio);
481477
pm_runtime_put_sync(&pdev->dev);
482478
pm_runtime_disable(&pdev->dev);
483-
rproc_free(ksproc->rproc);
484479
of_reserved_mem_device_release(&pdev->dev);
485480
}
486481

0 commit comments

Comments
 (0)