remoteproc: imx_dsp_rproc: Use devm_rproc_alloc() helper
Subsystems (5)
PATCH 1/9 remoteproc: imx_dsp_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.
--- drivers/remoteproc/imx_dsp_rproc.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/remoteproc/imx_dsp_rproc.c +4 -7
@@ -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 */
Signature · 1 line
2.39.2
PATCH 2/9 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.
--- drivers/remoteproc/imx_rproc.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/remoteproc/imx_rproc.c +5 -11
@@ -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[] = {
Signature · 1 line
2.39.2
Re: [PATCH 2/9] remoteproc: imx_rproc: Use devm_rproc_alloc() helper
Quoted 5 lines · Andrew Davis
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]>
Thanks,
Iulia
Quoted 56 lines
--- drivers/remoteproc/imx_rproc.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)drivers/remoteproc/imx_rproc.c +5
-11@@ -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[] = {
PATCH 3/9 remoteproc: qcom_q6v5_adsp: Use devm_rproc_alloc() helper
In reply to Andrew DavisUse 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.
--- drivers/remoteproc/qcom_q6v5_adsp.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/remoteproc/qcom_q6v5_adsp.c +5 -9
@@ -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 = {
Signature · 1 line
2.39.2
PATCH 4/9 remoteproc: qcom_q6v5_mss: Use devm_rproc_alloc() helper
In reply to Andrew DavisUse 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.
--- drivers/remoteproc/qcom_q6v5_mss.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-)
drivers/remoteproc/qcom_q6v5_mss.c +12 -16
@@ -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 = {
Signature · 1 line
2.39.2
PATCH 5/9 remoteproc: qcom_q6v5_pas: Use devm_rproc_alloc() helper
In reply to Andrew DavisUse 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.
--- drivers/remoteproc/qcom_q6v5_pas.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/remoteproc/qcom_q6v5_pas.c +1 -3
@@ -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 = {
Signature · 1 line
2.39.2
PATCH 6/9 remoteproc: qcom_q6v5_wcss: Use devm_rproc_alloc() helper
In reply to Andrew DavisUse 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.
--- drivers/remoteproc/qcom_q6v5_wcss.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)
drivers/remoteproc/qcom_q6v5_wcss.c +9 -15
@@ -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 = {
Signature · 1 line
2.39.2
Re: [PATCH 6/9] remoteproc: qcom_q6v5_wcss: Use devm_rproc_alloc() helper
Quoted 65 lines · Andrew Davis
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(-)drivers/remoteproc/qcom_q6v5_wcss.c +8
-9@@ -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;
drivers/remoteproc/qcom_q6v5_wcss.c static int q6v5_wcss_probe(struct platform_device *pdev) · line 1073
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_wcss.c +1
-5+return ret;platform_set_drvdata (pdev, rproc);return 0 ; - -free_rproc: -rproc_free (rproc); - -return ret;
This return statement should stay, right?
Quoted 11 lines
drivers/remoteproc/qcom_q6v5_wcss.c +0
-1}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 = {
Re: [PATCH 6/9] remoteproc: qcom_q6v5_wcss: Use devm_rproc_alloc() helper
Quoted 72 lines · Unnathi Chalicheemala
Quoted 69 lines · Andrew Davis
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(-)drivers/remoteproc/qcom_q6v5_wcss.c +9
-9@@ -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);
Quoted 9 lines
drivers/remoteproc/qcom_q6v5_wcss.c static int q6v5_wcss_probe(struct platform_device *pdev) · line 1073
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_wcss.c +0
-5return 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
Quoted 11 lines
Quoted 11 lines
drivers/remoteproc/qcom_q6v5_wcss.c +0
-1}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 = {
Re: [PATCH 6/9] remoteproc: qcom_q6v5_wcss: Use devm_rproc_alloc() helper
Quoted 72 lines · Andrew Davis
Quoted 61 lines · Unnathi Chalicheemala
Quoted 58 lines · Andrew Davis
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(-)drivers/remoteproc/qcom_q6v5_wcss.c +9
-8@@ -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);Quoted 9 lines
drivers/remoteproc/qcom_q6v5_wcss.c static int q6v5_wcss_probe(struct platform_device *pdev) · line 1073
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_wcss.c +0
-5return 0; - -free_rproc: - rproc_free(rproc); - - return ret;This return statement should stay, right?
Quoted 5 lines
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.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_wcss.c +0
-1} 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 = {
PATCH 7/9 remoteproc: qcom_wcnss: Use devm_rproc_alloc() helper
In reply to Andrew DavisUse 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.
--- drivers/remoteproc/qcom_wcnss.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/remoteproc/qcom_wcnss.c +6 -11
@@ -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[] = {
Signature · 1 line
2.39.2
PATCH 8/9 remoteproc: st: Use devm_rproc_alloc() helper
In reply to Andrew DavisUse 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.
--- drivers/remoteproc/st_remoteproc.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/remoteproc/st_remoteproc.c +5 -10
@@ -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 = {
Signature · 1 line
2.39.2
PATCH 9/9 remoteproc: stm32: Use devm_rproc_alloc() helper
In reply to Andrew DavisUse 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.
--- drivers/remoteproc/stm32_rproc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/remoteproc/stm32_rproc.c +1 -3
@@ -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)
Signature · 1 line
2.39.2
Mathieu Poirier
maintainerRe: [PATCH 9/9] remoteproc: stm32: Use devm_rproc_alloc() helper
Quoted 31 lines · Andrew Davis
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(-)drivers/remoteproc/stm32_rproc.c +1
-2@@ -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; }
drivers/remoteproc/stm32_rproc.c static void stm32_rproc_remove(struct platform_device *pdev) · line 920
Quoted 5 lines
drivers/remoteproc/stm32_rproc.c +0
-1@@ -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
Quoted 5 lines
drivers/remoteproc/stm32_rproc.c +0
-0static int stm32_rproc_suspend (struct device *dev)Signature · 1 line
2.39.2
Quoted 5 lines · Andrew Davis
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]>
Thanks,
Iulia
Quoted 53 lines
--- drivers/remoteproc/imx_dsp_rproc.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)drivers/remoteproc/imx_dsp_rproc.c +4
-7@@ -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 */