media: omap3isp: Move link creation to bound callback
authorSakari Ailus <sakari.ailus@linux.intel.com>
Fri, 19 May 2023 11:56:33 +0000 (13:56 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 28 Jul 2023 08:35:38 +0000 (10:35 +0200)
Move the creation of the links between external sub-devices and ISP
sub-devices to the bound callback. This way we can also remove the need to
access the sub-device's notifier field that will soon be removed.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/ti/omap3isp/isp.c

index 2f9c7d6..b01d70d 100644 (file)
@@ -2022,35 +2022,34 @@ enum isp_of_phy {
        ISP_OF_PHY_CSIPHY2,
 };
 
-static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async)
+static int isp_subdev_notifier_bound(struct v4l2_async_notifier *async,
+                                    struct v4l2_subdev *sd,
+                                    struct v4l2_async_subdev *asd)
 {
        struct isp_device *isp = container_of(async, struct isp_device,
                                              notifier);
-       struct v4l2_device *v4l2_dev = &isp->v4l2_dev;
-       struct v4l2_subdev *sd;
+       struct isp_bus_cfg *bus_cfg =
+               &container_of(asd, struct isp_async_subdev, asd)->bus;
        int ret;
 
        mutex_lock(&isp->media_dev.graph_mutex);
+       ret = isp_link_entity(isp, &sd->entity, bus_cfg->interface);
+       mutex_unlock(&isp->media_dev.graph_mutex);
 
-       ret = media_entity_enum_init(&isp->crashed, &isp->media_dev);
-       if (ret) {
-               mutex_unlock(&isp->media_dev.graph_mutex);
-               return ret;
-       }
-
-       list_for_each_entry(sd, &v4l2_dev->subdevs, list) {
-               if (sd->notifier != &isp->notifier)
-                       continue;
+       return ret;
+}
 
-               ret = isp_link_entity(isp, &sd->entity,
-                                     v4l2_subdev_to_bus_cfg(sd)->interface);
-               if (ret < 0) {
-                       mutex_unlock(&isp->media_dev.graph_mutex);
-                       return ret;
-               }
-       }
+static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async)
+{
+       struct isp_device *isp = container_of(async, struct isp_device,
+                                             notifier);
+       int ret;
 
+       mutex_lock(&isp->media_dev.graph_mutex);
+       ret = media_entity_enum_init(&isp->crashed, &isp->media_dev);
        mutex_unlock(&isp->media_dev.graph_mutex);
+       if (ret)
+               return ret;
 
        ret = v4l2_device_register_subdev_nodes(&isp->v4l2_dev);
        if (ret < 0)
@@ -2240,6 +2239,7 @@ static int isp_parse_of_endpoints(struct isp_device *isp)
 }
 
 static const struct v4l2_async_notifier_operations isp_subdev_notifier_ops = {
+       .bound = isp_subdev_notifier_bound,
        .complete = isp_subdev_notifier_complete,
 };