diff mbox series

[01/50] staging: media: imx: imx7-media-csi: Initialize locks early on

Message ID 20220510115859.19777-2-laurent.pinchart@ideasonboard.com
State Accepted
Commit 34d868e862e7c4aa4b284e8c95ea8e37d475c62c
Headers show
Series [01/50] staging: media: imx: imx7-media-csi: Initialize locks early on | expand

Commit Message

Laurent Pinchart May 10, 2022, 11:58 a.m. UTC
Group all the direct initialization of imx7_csi fields at the beginning
of the imx7_csi_probe() function instead of spreading them around.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/staging/media/imx/imx7-media-csi.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c
index 8467a1491048..893620e8fc03 100644
--- a/drivers/staging/media/imx/imx7-media-csi.c
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -1188,27 +1188,32 @@  static int imx7_csi_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	csi->dev = dev;
+	platform_set_drvdata(pdev, &csi->sd);
+
+	spin_lock_init(&csi->irqlock);
+	mutex_init(&csi->lock);
 
 	csi->mclk = devm_clk_get(&pdev->dev, "mclk");
 	if (IS_ERR(csi->mclk)) {
 		ret = PTR_ERR(csi->mclk);
 		dev_err(dev, "Failed to get mclk: %d", ret);
-		return ret;
+		goto destroy_mutex;
 	}
 
 	csi->irq = platform_get_irq(pdev, 0);
-	if (csi->irq < 0)
-		return csi->irq;
+	if (csi->irq < 0) {
+		ret = csi->irq;
+		goto destroy_mutex;
+	}
 
 	csi->regbase = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(csi->regbase))
-		return PTR_ERR(csi->regbase);
+	if (IS_ERR(csi->regbase)) {
+		ret = PTR_ERR(csi->regbase);
+		goto destroy_mutex;
+	}
 
 	csi->model = (enum imx_csi_model)(uintptr_t)of_device_get_match_data(&pdev->dev);
 
-	spin_lock_init(&csi->irqlock);
-	mutex_init(&csi->lock);
-
 	/* install interrupt handler */
 	ret = devm_request_irq(dev, csi->irq, imx7_csi_irq_handler, 0, "csi",
 			       (void *)csi);
@@ -1223,7 +1228,6 @@  static int imx7_csi_probe(struct platform_device *pdev)
 		ret = PTR_ERR(imxmd);
 		goto destroy_mutex;
 	}
-	platform_set_drvdata(pdev, &csi->sd);
 
 	ret = imx_media_of_add_csi(imxmd, node);
 	if (ret < 0 && ret != -ENODEV && ret != -EEXIST)