[PATCH 3/3] media: cadence: cdns-csi2rx: Use v4l2_async_pad_init_and_register_subdev() to simplify code

Frank Li posted 3 patches 1 month, 2 weeks ago
There is a newer version of this series
[PATCH 3/3] media: cadence: cdns-csi2rx: Use v4l2_async_pad_init_and_register_subdev() to simplify code
Posted by Frank Li 1 month, 2 weeks ago
Use v4l2_async_pad_init_and_register_subdev() to simplify the code.

No functional changes.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
build test only
---
 drivers/media/platform/cadence/cdns-csi2rx.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
index 8c19f125da3e50f55a0ae280b05e7918ce115101..1a18a9d0ea602c91c07a4bf4573ec0346edc7650 100644
--- a/drivers/media/platform/cadence/cdns-csi2rx.c
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -855,11 +855,6 @@ static int csi2rx_probe(struct platform_device *pdev)
 	csi2rx->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 	csi2rx->subdev.entity.ops = &csi2rx_media_ops;
 
-	ret = media_entity_pads_init(&csi2rx->subdev.entity, CSI2RX_PAD_MAX,
-				     csi2rx->pads);
-	if (ret)
-		goto err_cleanup;
-
 	csi2rx->error_irq = platform_get_irq_byname_optional(pdev, "error_irq");
 
 	if (csi2rx->error_irq < 0) {
@@ -875,13 +870,11 @@ static int csi2rx_probe(struct platform_device *pdev)
 		}
 	}
 
-	ret = v4l2_subdev_init_finalize(&csi2rx->subdev);
-	if (ret)
-		goto err_cleanup;
-
-	ret = v4l2_async_register_subdev(&csi2rx->subdev);
+	ret = v4l2_async_pad_init_and_register_subdev(&csi2rx->subdev,
+						      CSI2RX_PAD_MAX,
+						      csi2rx->pads);
 	if (ret < 0)
-		goto err_free_state;
+		goto err_cleanup;
 
 	dev_info(&pdev->dev,
 		 "Probed CSI2RX with %u/%u lanes, %u streams, %s D-PHY\n",
@@ -891,12 +884,9 @@ static int csi2rx_probe(struct platform_device *pdev)
 
 	return 0;
 
-err_free_state:
-	v4l2_subdev_cleanup(&csi2rx->subdev);
 err_cleanup:
 	v4l2_async_nf_unregister(&csi2rx->notifier);
 	v4l2_async_nf_cleanup(&csi2rx->notifier);
-	media_entity_cleanup(&csi2rx->subdev.entity);
 err_free_priv:
 	kfree(csi2rx);
 	return ret;

-- 
2.43.0