]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
remoteproc: imx_rproc: Use devm_add_action_or_reset() for workqueue cleanup
authorPeng Fan <peng.fan@nxp.com>
Fri, 26 Sep 2025 12:33:16 +0000 (20:33 +0800)
committerMathieu Poirier <mathieu.poirier@linaro.org>
Tue, 14 Oct 2025 15:09:40 +0000 (09:09 -0600)
Replace manual destroy_workqueue() calls in error and remove paths with a
devm_add_action_or_reset() helper. Ensure the workqueue is properly
cleaned up with the device lifecycle, and simplify error handling in probe
by removing now-unnecessary labels and cleanup steps.

No functional changes.

Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/r/20250926-imx_rproc_v3-v3-2-4c0ec279cc5f@nxp.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
drivers/remoteproc/imx_rproc.c

index 8424e6ea5569b9ba6b07525643ce795faaeb2898..9c44ce56f1ab044ca5dccfeb0aaa0f7cd810aab1 100644 (file)
@@ -1046,6 +1046,13 @@ static int imx_rproc_sys_off_handler(struct sys_off_data *data)
        return NOTIFY_DONE;
 }
 
+static void imx_rproc_destroy_workqueue(void *data)
+{
+       struct workqueue_struct *workqueue = data;
+
+       destroy_workqueue(workqueue);
+}
+
 static int imx_rproc_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
@@ -1077,11 +1084,15 @@ static int imx_rproc_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
+       ret = devm_add_action_or_reset(dev, imx_rproc_destroy_workqueue, priv->workqueue);
+       if (ret)
+               return dev_err_probe(dev, ret, "Failed to add devm destroy workqueue action\n");
+
        INIT_WORK(&priv->rproc_work, imx_rproc_vq_work);
 
        ret = imx_rproc_xtr_mbox_init(rproc, true);
        if (ret)
-               goto err_put_wkq;
+               return ret;
 
        ret = imx_rproc_addr_init(priv, pdev);
        if (ret) {
@@ -1152,8 +1163,6 @@ err_put_scu:
        imx_rproc_put_scu(rproc);
 err_put_mbox:
        imx_rproc_free_mbox(rproc);
-err_put_wkq:
-       destroy_workqueue(priv->workqueue);
 
        return ret;
 }
@@ -1171,7 +1180,6 @@ static void imx_rproc_remove(struct platform_device *pdev)
        rproc_del(rproc);
        imx_rproc_put_scu(rproc);
        imx_rproc_free_mbox(rproc);
-       destroy_workqueue(priv->workqueue);
 }
 
 static const struct imx_rproc_plat_ops imx_rproc_ops_arm_smc = {