[PATCH] gpu: ipu-pre: handle clock enable failures

Jiawen Liu <[email protected]>
Newsgroups gmane.linux.kernel,gmane.comp.video.dri.devel
Message-ID <[email protected]>
Check clock-enable failures after a manually managed allocation.

Release the earlier allocation and return the original clock error when
probe cannot enable the clock.

Signed-off-by: jiawen <[email protected]>
---
diff --git a/drivers/gpu/ipu-v3/ipu-pre.c b/drivers/gpu/ipu-v3/ipu-pre.c
--- a/drivers/gpu/ipu-v3/ipu-pre.c
+++ b/drivers/gpu/ipu-v3/ipu-pre.c
@@ -311,6 +311,7 @@
 {
 	struct device *dev = &pdev->dev;
 	struct ipu_pre *pre;
+	int ret;
 
 	pre = devm_kzalloc(dev, sizeof(*pre), GFP_KERNEL);
 	if (!pre)
@@ -339,7 +340,12 @@
 	if (!pre->buffer_virt)
 		return -ENOMEM;
 
-	clk_prepare_enable(pre->clk_axi);
+	ret = clk_prepare_enable(pre->clk_axi);
+	if (ret) {
+		gen_pool_free(pre->iram, (unsigned long)pre->buffer_virt,
+			      IPU_PRE_MAX_WIDTH * IPU_PRE_NUM_SCANLINES * 4);
+		return ret;
+	}
 
 	pre->dev = dev;
 	platform_set_drvdata(pdev, pre);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.