diff mbox series

[07/12] media: ipu3-cio2: Add a parse_sensor_fwnode callback to cio2_bridge_init()

Message ID 20230627175643.114778-8-hdegoede@redhat.com
State New
Headers show
Series None | expand

Commit Message

Hans de Goede June 27, 2023, 5:56 p.m. UTC
Add a parse_sensor_fwnode callback to cio2_bridge_init(), so that
cio2_bridge_init() can be used with other sensor fwnode parse functions
then just cio2_bridge_parse_sensor_fwnode.

This is a preparation patch for making the cio2-bridge code more generic
so that it can be shared with the atomisp driver.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Note to reviewers the wrapped __cio2_bridge_init() function goes away
(becomes a generic shared helper) later in this series
---
 drivers/media/pci/intel/ipu3/cio2-bridge.c | 17 ++++++++++++++---
 drivers/media/pci/intel/ipu3/cio2-bridge.h |  3 +++
 2 files changed, 17 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.c b/drivers/media/pci/intel/ipu3/cio2-bridge.c
index b189c2adf858..b799053f4934 100644
--- a/drivers/media/pci/intel/ipu3/cio2-bridge.c
+++ b/drivers/media/pci/intel/ipu3/cio2-bridge.c
@@ -150,7 +150,8 @@  cio2_bridge_get_orientation(struct acpi_device *adev)
 }
 
 static int cio2_bridge_parse_sensor_fwnode(struct acpi_device *adev,
-					   struct cio2_sensor *sensor)
+					   struct cio2_sensor *sensor,
+					   const struct cio2_sensor_config *cfg)
 {
 	struct cio2_sensor_ssdb ssdb = {};
 	int ret;
@@ -344,7 +345,7 @@  static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
 
 		sensor = &bridge->sensors[bridge->n_sensors];
 
-		ret = cio2_bridge_parse_sensor_fwnode(adev, sensor);
+		ret = bridge->parse_sensor_fwnode(adev, sensor, cfg);
 		if (ret)
 			goto err_put_adev;
 
@@ -442,7 +443,11 @@  static int cio2_bridge_sensors_are_ready(void)
 	return ready;
 }
 
-int cio2_bridge_init(struct device *dev)
+static int __cio2_bridge_init(
+	struct device *dev,
+	int (*parse_sensor_fwnode)(struct acpi_device *adev,
+				   struct cio2_sensor *sensor,
+				   const struct cio2_sensor_config *cfg))
 {
 	struct fwnode_handle *fwnode;
 	struct cio2_bridge *bridge;
@@ -460,6 +465,7 @@  int cio2_bridge_init(struct device *dev)
 		sizeof(bridge->cio2_node_name));
 	bridge->cio2_hid_node.name = bridge->cio2_node_name;
 	bridge->dev = dev;
+	bridge->parse_sensor_fwnode = parse_sensor_fwnode;
 
 	ret = software_node_register(&bridge->cio2_hid_node);
 	if (ret < 0) {
@@ -503,3 +509,8 @@  int cio2_bridge_init(struct device *dev)
 
 	return ret;
 }
+
+int cio2_bridge_init(struct device *dev)
+{
+	return __cio2_bridge_init(dev, cio2_bridge_parse_sensor_fwnode);
+}
diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.h b/drivers/media/pci/intel/ipu3/cio2-bridge.h
index d53ce0c78e83..b596fae2dc1b 100644
--- a/drivers/media/pci/intel/ipu3/cio2-bridge.h
+++ b/drivers/media/pci/intel/ipu3/cio2-bridge.h
@@ -142,6 +142,9 @@  struct cio2_sensor {
 
 struct cio2_bridge {
 	struct device *dev;
+	int (*parse_sensor_fwnode)(struct acpi_device *adev,
+				   struct cio2_sensor *sensor,
+				   const struct cio2_sensor_config *cfg);
 	char cio2_node_name[ACPI_ID_LEN];
 	struct software_node cio2_hid_node;
 	u32 data_lanes[4];