media: ipu-bridge: Move graph checking to IPU bridge
authorSakari Ailus <sakari.ailus@linux.intel.com>
Tue, 13 Feb 2024 09:41:18 +0000 (11:41 +0200)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Fri, 23 Feb 2024 13:33:32 +0000 (14:33 +0100)
Move checking the graph to the IPU bridge. This way the caller won't need
to do it.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/pci/intel/ipu-bridge.c
drivers/media/pci/intel/ipu3/ipu3-cio2.c

index b2cf80d62ba24f7d5c0a84e0836e1798187866b5..735c62c37c22d9fdccb9da5d1dee3d59f4ace754 100644 (file)
@@ -2,6 +2,7 @@
 /* Author: Dan Scally <djrscally@gmail.com> */
 
 #include <linux/acpi.h>
+#include <linux/cleanup.h>
 #include <linux/device.h>
 #include <linux/i2c.h>
 #include <linux/mei_cl_bus.h>
@@ -749,6 +750,22 @@ static int ipu_bridge_ivsc_is_ready(void)
        return ready;
 }
 
+static int ipu_bridge_check_fwnode_graph(struct fwnode_handle *fwnode)
+{
+       struct fwnode_handle *endpoint;
+
+       if (IS_ERR_OR_NULL(fwnode))
+               return -EINVAL;
+
+       endpoint = fwnode_graph_get_next_endpoint(fwnode, NULL);
+       if (endpoint) {
+               fwnode_handle_put(endpoint);
+               return 0;
+       }
+
+       return ipu_bridge_check_fwnode_graph(fwnode->secondary);
+}
+
 int ipu_bridge_init(struct device *dev,
                    ipu_parse_sensor_fwnode_t parse_sensor_fwnode)
 {
@@ -757,6 +774,9 @@ int ipu_bridge_init(struct device *dev,
        unsigned int i;
        int ret;
 
+       if (!ipu_bridge_check_fwnode_graph(dev_fwnode(dev)))
+               return 0;
+
        if (!ipu_bridge_ivsc_is_ready())
                return -EPROBE_DEFER;
 
index 83e29c56fe33d7290148d3a8f0e662a993f52989..c42adc5a408db5470d45ca02900e3e8f4d34d297 100644 (file)
@@ -1667,29 +1667,12 @@ static void cio2_queues_exit(struct cio2_device *cio2)
                cio2_queue_exit(cio2, &cio2->queue[i]);
 }
 
-static int cio2_check_fwnode_graph(struct fwnode_handle *fwnode)
-{
-       struct fwnode_handle *endpoint;
-
-       if (IS_ERR_OR_NULL(fwnode))
-               return -EINVAL;
-
-       endpoint = fwnode_graph_get_next_endpoint(fwnode, NULL);
-       if (endpoint) {
-               fwnode_handle_put(endpoint);
-               return 0;
-       }
-
-       return cio2_check_fwnode_graph(fwnode->secondary);
-}
-
 /**************** PCI interface ****************/
 
 static int cio2_pci_probe(struct pci_dev *pci_dev,
                          const struct pci_device_id *id)
 {
        struct device *dev = &pci_dev->dev;
-       struct fwnode_handle *fwnode = dev_fwnode(dev);
        struct cio2_device *cio2;
        int r;
 
@@ -1698,17 +1681,9 @@ static int cio2_pci_probe(struct pci_dev *pci_dev,
         * if the device has no endpoints then we can try to build those as
         * software_nodes parsed from SSDB.
         */
-       r = cio2_check_fwnode_graph(fwnode);
-       if (r) {
-               if (fwnode && !IS_ERR_OR_NULL(fwnode->secondary)) {
-                       dev_err(dev, "fwnode graph has no endpoints connected\n");
-                       return -EINVAL;
-               }
-
-               r = ipu_bridge_init(dev, ipu_bridge_parse_ssdb);
-               if (r)
-                       return r;
-       }
+       r = ipu_bridge_init(dev, ipu_bridge_parse_ssdb);
+       if (r)
+               return r;
 
        cio2 = devm_kzalloc(dev, sizeof(*cio2), GFP_KERNEL);
        if (!cio2)