media: ipu3-cio2: Further clean up async subdev link creation
authorSakari Ailus <sakari.ailus@linux.intel.com>
Thu, 25 May 2023 11:12:04 +0000 (14:12 +0300)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Mon, 22 Jan 2024 16:23:59 +0000 (17:23 +0100)
Use v4l2_create_fwnode_links_to_pad() to create links from async
sub-devices to the CSI-2 receiver subdevs.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/pci/intel/ipu3/ipu3-cio2.c

index ed08bf4178f08fe19954ef461e49cf49d4fadcc2..83e29c56fe33d7290148d3a8f0e662a993f52989 100644 (file)
@@ -28,6 +28,7 @@
 #include <media/v4l2-device.h>
 #include <media/v4l2-event.h>
 #include <media/v4l2-fwnode.h>
+#include <media/v4l2-mc.h>
 #include <media/v4l2-ioctl.h>
 #include <media/videobuf2-dma-sg.h>
 
@@ -1407,7 +1408,6 @@ static void cio2_notifier_unbind(struct v4l2_async_notifier *notifier,
 static int cio2_notifier_complete(struct v4l2_async_notifier *notifier)
 {
        struct cio2_device *cio2 = to_cio2_device(notifier);
-       struct device *dev = &cio2->pci_dev->dev;
        struct sensor_async_subdev *s_asd;
        struct v4l2_async_connection *asd;
        struct cio2_queue *q;
@@ -1417,23 +1417,10 @@ static int cio2_notifier_complete(struct v4l2_async_notifier *notifier)
                s_asd = to_sensor_asd(asd);
                q = &cio2->queue[s_asd->csi2.port];
 
-               ret = media_entity_get_fwnode_pad(&q->sensor->entity,
-                                                 s_asd->asd.match.fwnode,
-                                                 MEDIA_PAD_FL_SOURCE);
-               if (ret < 0) {
-                       dev_err(dev, "no pad for endpoint %pfw (%d)\n",
-                               s_asd->asd.match.fwnode, ret);
-                       return ret;
-               }
-
-               ret = media_create_pad_link(&q->sensor->entity, ret,
-                                           &q->subdev.entity, CIO2_PAD_SINK,
-                                           0);
-               if (ret) {
-                       dev_err(dev, "failed to create link for %s (endpoint %pfw, error %d)\n",
-                               q->sensor->name, s_asd->asd.match.fwnode, ret);
+               ret = v4l2_create_fwnode_links_to_pad(asd->sd,
+                                                     &q->subdev_pads[CIO2_PAD_SINK], 0);
+               if (ret)
                        return ret;
-               }
        }
 
        return v4l2_device_register_subdev_nodes(&cio2->v4l2_dev);
@@ -1572,6 +1559,7 @@ static int cio2_queue_init(struct cio2_device *cio2, struct cio2_queue *q)
        v4l2_subdev_init(subdev, &cio2_subdev_ops);
        subdev->flags = V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
        subdev->owner = THIS_MODULE;
+       subdev->dev = dev;
        snprintf(subdev->name, sizeof(subdev->name),
                 CIO2_ENTITY_NAME " %td", q - cio2->queue);
        subdev->entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;