diff mbox series

[-next] media: mtk-jpegdec: add missing destroy_workqueue()

Message ID 20221110150559.390448-1-yangyingliang@huawei.com
State Accepted
Commit 9b358183b405651bc917c70975c17754da574c03
Headers show
Series [-next] media: mtk-jpegdec: add missing destroy_workqueue() | expand

Commit Message

Yang Yingliang Nov. 10, 2022, 3:05 p.m. UTC
destroy_workqueue() needs be called to when driver is
unloading, fix it by using devm_add_action_or_reset()
to make workqueuedevice-managed.

Fixes: dedc21500334 ("media: mtk-jpegdec: add jpeg decode worker interface")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c
index d98f4cdfeea9..8c07fa02fd9a 100644
--- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c
+++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c
@@ -580,6 +580,11 @@  static int mtk_jpegdec_hw_init_irq(struct mtk_jpegdec_comp_dev *dev)
 	return 0;
 }
 
+static void mtk_jpegdec_destroy_workqueue(void *data)
+{
+	destroy_workqueue(data);
+}
+
 static int mtk_jpegdec_hw_probe(struct platform_device *pdev)
 {
 	struct mtk_jpegdec_clk *jpegdec_clk;
@@ -614,6 +619,11 @@  static int mtk_jpegdec_hw_probe(struct platform_device *pdev)
 								| WQ_FREEZABLE);
 		if (!master_dev->workqueue)
 			return -EINVAL;
+
+		ret = devm_add_action_or_reset(&pdev->dev, mtk_jpegdec_destroy_workqueue,
+					       master_dev->workqueue);
+		if (ret)
+			return ret;
 	}
 
 	atomic_set(&master_dev->dechw_rdy, MTK_JPEGDEC_HW_MAX);