Skip to content

Commit e0251c2

Browse files
Sakari AilusHans Verkuil
authored andcommitted
media: ipu-bridge: Move graph checking to IPU bridge
Move checking the graph to the IPU bridge. This way the caller won't need to do it. Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent ec86a04 commit e0251c2

File tree

2 files changed

+23
-28
lines changed

2 files changed

+23
-28
lines changed

drivers/media/pci/intel/ipu-bridge.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* Author: Dan Scally <[email protected]> */
33

44
#include <linux/acpi.h>
5+
#include <linux/cleanup.h>
56
#include <linux/device.h>
67
#include <linux/i2c.h>
78
#include <linux/mei_cl_bus.h>
@@ -749,6 +750,22 @@ static int ipu_bridge_ivsc_is_ready(void)
749750
return ready;
750751
}
751752

753+
static int ipu_bridge_check_fwnode_graph(struct fwnode_handle *fwnode)
754+
{
755+
struct fwnode_handle *endpoint;
756+
757+
if (IS_ERR_OR_NULL(fwnode))
758+
return -EINVAL;
759+
760+
endpoint = fwnode_graph_get_next_endpoint(fwnode, NULL);
761+
if (endpoint) {
762+
fwnode_handle_put(endpoint);
763+
return 0;
764+
}
765+
766+
return ipu_bridge_check_fwnode_graph(fwnode->secondary);
767+
}
768+
752769
int ipu_bridge_init(struct device *dev,
753770
ipu_parse_sensor_fwnode_t parse_sensor_fwnode)
754771
{
@@ -757,6 +774,9 @@ int ipu_bridge_init(struct device *dev,
757774
unsigned int i;
758775
int ret;
759776

777+
if (!ipu_bridge_check_fwnode_graph(dev_fwnode(dev)))
778+
return 0;
779+
760780
if (!ipu_bridge_ivsc_is_ready())
761781
return -EPROBE_DEFER;
762782

drivers/media/pci/intel/ipu3/ipu3-cio2.c

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,29 +1667,12 @@ static void cio2_queues_exit(struct cio2_device *cio2)
16671667
cio2_queue_exit(cio2, &cio2->queue[i]);
16681668
}
16691669

1670-
static int cio2_check_fwnode_graph(struct fwnode_handle *fwnode)
1671-
{
1672-
struct fwnode_handle *endpoint;
1673-
1674-
if (IS_ERR_OR_NULL(fwnode))
1675-
return -EINVAL;
1676-
1677-
endpoint = fwnode_graph_get_next_endpoint(fwnode, NULL);
1678-
if (endpoint) {
1679-
fwnode_handle_put(endpoint);
1680-
return 0;
1681-
}
1682-
1683-
return cio2_check_fwnode_graph(fwnode->secondary);
1684-
}
1685-
16861670
/**************** PCI interface ****************/
16871671

16881672
static int cio2_pci_probe(struct pci_dev *pci_dev,
16891673
const struct pci_device_id *id)
16901674
{
16911675
struct device *dev = &pci_dev->dev;
1692-
struct fwnode_handle *fwnode = dev_fwnode(dev);
16931676
struct cio2_device *cio2;
16941677
int r;
16951678

@@ -1698,17 +1681,9 @@ static int cio2_pci_probe(struct pci_dev *pci_dev,
16981681
* if the device has no endpoints then we can try to build those as
16991682
* software_nodes parsed from SSDB.
17001683
*/
1701-
r = cio2_check_fwnode_graph(fwnode);
1702-
if (r) {
1703-
if (fwnode && !IS_ERR_OR_NULL(fwnode->secondary)) {
1704-
dev_err(dev, "fwnode graph has no endpoints connected\n");
1705-
return -EINVAL;
1706-
}
1707-
1708-
r = ipu_bridge_init(dev, ipu_bridge_parse_ssdb);
1709-
if (r)
1710-
return r;
1711-
}
1684+
r = ipu_bridge_init(dev, ipu_bridge_parse_ssdb);
1685+
if (r)
1686+
return r;
17121687

17131688
cio2 = devm_kzalloc(dev, sizeof(*cio2), GFP_KERNEL);
17141689
if (!cio2)

0 commit comments

Comments
 (0)