@@ -36,6 +36,7 @@ static const struct cio2_sensor_config cio2_supported_sensors[] = {
CIO2_SENSOR_CONFIG("INT3537", 1, 437000000),
/* Omnivision ov13b10 */
CIO2_SENSOR_CONFIG("OVTIDB10", 1, 560000000),
+ {}
};
static const struct cio2_property_names prop_names = {
@@ -393,9 +394,9 @@ static int cio2_bridge_connect_sensors(struct cio2_bridge *bridge)
unsigned int i;
int ret;
- for (i = 0; i < ARRAY_SIZE(cio2_supported_sensors); i++) {
+ for (i = 0; bridge->supported_sensors[i].hid; i++) {
const struct cio2_sensor_config *cfg =
- &cio2_supported_sensors[i];
+ &bridge->supported_sensors[i];
ret = cio2_bridge_connect_sensor(cfg, bridge);
if (ret)
@@ -421,15 +422,15 @@ static int cio2_bridge_connect_sensors(struct cio2_bridge *bridge)
* acpi_dev_ready_for_enumeration() helper, like the i2c-core-acpi code does
* for the sensors.
*/
-static int cio2_bridge_sensors_are_ready(void)
+static int cio2_bridge_sensors_are_ready(
+ const struct cio2_sensor_config *supported_sensors)
{
struct acpi_device *adev;
bool ready = true;
unsigned int i;
- for (i = 0; i < ARRAY_SIZE(cio2_supported_sensors); i++) {
- const struct cio2_sensor_config *cfg =
- &cio2_supported_sensors[i];
+ for (i = 0; supported_sensors[i].hid; i++) {
+ const struct cio2_sensor_config *cfg = &supported_sensors[i];
for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) {
if (!adev->status.enabled)
@@ -447,14 +448,15 @@ 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))
+ const struct cio2_sensor_config *cfg),
+ const struct cio2_sensor_config *supported_sensors)
{
struct fwnode_handle *fwnode;
struct cio2_bridge *bridge;
unsigned int i;
int ret;
- if (!cio2_bridge_sensors_are_ready())
+ if (!cio2_bridge_sensors_are_ready(supported_sensors))
return -EPROBE_DEFER;
bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
@@ -466,6 +468,7 @@ static int __cio2_bridge_init(
bridge->cio2_hid_node.name = bridge->cio2_node_name;
bridge->dev = dev;
bridge->parse_sensor_fwnode = parse_sensor_fwnode;
+ bridge->supported_sensors = supported_sensors;
ret = software_node_register(&bridge->cio2_hid_node);
if (ret < 0) {
@@ -512,5 +515,6 @@ static int __cio2_bridge_init(
int cio2_bridge_init(struct device *dev)
{
- return __cio2_bridge_init(dev, cio2_bridge_parse_sensor_fwnode);
+ return __cio2_bridge_init(dev, cio2_bridge_parse_sensor_fwnode,
+ cio2_supported_sensors);
}
@@ -145,6 +145,7 @@ struct cio2_bridge {
int (*parse_sensor_fwnode)(struct acpi_device *adev,
struct cio2_sensor *sensor,
const struct cio2_sensor_config *cfg);
+ const struct cio2_sensor_config *supported_sensors;
char cio2_node_name[ACPI_ID_LEN];
struct software_node cio2_hid_node;
u32 data_lanes[4];
Add a supported_sensors parameter to cio2_bridge_init(), so that cio2_bridge_init() can be used with other bridges which have been tested with / support a different set of sensors. 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> --- drivers/media/pci/intel/ipu3/cio2-bridge.c | 22 +++++++++++++--------- drivers/media/pci/intel/ipu3/cio2-bridge.h | 1 + 2 files changed, 14 insertions(+), 9 deletions(-)