Skip to contentSkip to conversation

media: ipu3-cio2: Don't dereference fwnode handle

PATCH Superseded Andy Shevchenko 6 participants 16 messages Nov 18, 2022 – Nov 23, 2022

Subsystems (5)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Andy Shevchenko

author reviewer
#0 lore raw

PATCH 1/4 media: ipu3-cio2: Don't dereference fwnode handle

Use acpi_fwnode_handle() instead of dereferencing an fwnode handle directly, which is a better coding practice.

---
 drivers/media/pci/intel/ipu3/cio2-bridge.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +4 -2
index df6c94da2f6a..18974a72e94a 100644
@@ -263,7 +263,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
 				      struct cio2_bridge *bridge,
 				      struct pci_dev *cio2)
 {
-	struct fwnode_handle *fwnode;
+	struct fwnode_handle *fwnode, *primary;
 	struct cio2_sensor *sensor;
 	struct acpi_device *adev;
 	acpi_status status;
@@ -322,7 +322,9 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
 		}
 
 		sensor->adev = acpi_dev_get(adev);
-		adev->fwnode.secondary = fwnode;
+
+		primary = acpi_fwnode_handle(adev);
+		primary->secondary = fwnode;
 
 		cio2_bridge_instantiate_vcm_i2c_client(sensor);
 
Signature · 1 line
2.35.1
author reviewer
#1 lore raw

PATCH 2/4 media: ipu3-cio2: Convert to use software_node_register_node_group()

The currently used software_node_register_nodes() is going to be removed. Prepare driver by switchich to new API.

---
 drivers/media/pci/intel/ipu3/cio2-bridge.c | 21 ++++++++++++++++++---
 drivers/media/pci/intel/ipu3/cio2-bridge.h |  5 +++--
 2 files changed, 21 insertions(+), 5 deletions(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +18 -3
index 18974a72e94a..dfefe0d8aa95 100644
@@ -195,6 +195,19 @@ static void cio2_bridge_init_swnode_names(struct cio2_sensor *sensor)
 		 SWNODE_GRAPH_ENDPOINT_NAME_FMT, 0); /* And endpoint 0 */
 }
 
+static void cio2_bridge_init_swnode_group(struct cio2_sensor *sensor)
+{
+	struct software_node *nodes = sensor->swnodes;
+
+	sensor->group[SWNODE_SENSOR_HID] = &nodes[SWNODE_SENSOR_HID];
+	sensor->group[SWNODE_SENSOR_PORT] = &nodes[SWNODE_SENSOR_PORT];
+	sensor->group[SWNODE_SENSOR_ENDPOINT] = &nodes[SWNODE_SENSOR_ENDPOINT];
+	sensor->group[SWNODE_CIO2_PORT] = &nodes[SWNODE_CIO2_PORT];
+	sensor->group[SWNODE_CIO2_ENDPOINT] = &nodes[SWNODE_CIO2_ENDPOINT];
+	if (sensor->ssdb.vcmtype)
+		sensor->group[SWNODE_VCM] =  &nodes[SWNODE_VCM];
+}
+
 static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge,
 						  struct cio2_sensor *sensor)
 {
@@ -219,6 +232,8 @@ static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge,
 	if (sensor->ssdb.vcmtype)
 		nodes[SWNODE_VCM] =
 			NODE_VCM(cio2_vcm_types[sensor->ssdb.vcmtype - 1]);
+
+	cio2_bridge_init_swnode_group(sensor);
 }
 
 static void cio2_bridge_instantiate_vcm_i2c_client(struct cio2_sensor *sensor)
@@ -252,7 +267,7 @@ static void cio2_bridge_unregister_sensors(struct cio2_bridge *bridge)
 
 	for (i = 0; i < bridge->n_sensors; i++) {
 		sensor = &bridge->sensors[i];
-		software_node_unregister_nodes(sensor->swnodes);
+		software_node_unregister_node_group(sensor->group);
 		ACPI_FREE(sensor->pld);
 		acpi_dev_put(sensor->adev);
 		i2c_unregister_device(sensor->vcm_i2c_client);
@@ -310,7 +325,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
 		cio2_bridge_create_fwnode_properties(sensor, bridge, cfg);
 		cio2_bridge_create_connection_swnodes(bridge, sensor);
 
-		ret = software_node_register_nodes(sensor->swnodes);
+		ret = software_node_register_node_group(sensor->group);
 		if (ret)
 			goto err_free_pld;
 
@@ -337,7 +352,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
 	return 0;
 
 err_free_swnodes:
-	software_node_unregister_nodes(sensor->swnodes);
+	software_node_unregister_node_group(sensor->group);
 err_free_pld:
 	ACPI_FREE(sensor->pld);
 err_put_adev:
drivers/media/pci/intel/ipu3/cio2-bridge.h +3 -2
index 4418cbd08208..b93b749c65bd 100644
@@ -117,8 +117,9 @@ struct cio2_sensor {
 	struct acpi_device *adev;
 	struct i2c_client *vcm_i2c_client;
 
-	/* SWNODE_COUNT + 1 for terminating empty node */
-	struct software_node swnodes[SWNODE_COUNT + 1];
+	/* SWNODE_COUNT + 1 for terminating NULL */
+	const struct software_node *group[SWNODE_COUNT + 1];
+	struct software_node swnodes[SWNODE_COUNT];
 	struct cio2_node_names node_names;
 
 	struct cio2_sensor_ssdb ssdb;
Signature · 1 line
2.35.1
maintainer Reviewed-by on v1 2/4
#2 lore raw

Re: [PATCH v1 2/4] media: ipu3-cio2: Convert to use software_node_register_node_group()

Hi Andy

Quoted 5 lines · Andy Shevchenko

The currently used software_node_register_nodes() is going to be removed. Prepare driver by switchich to new API.

---

Also looks good to me:

Quoted 80 lines
  drivers/media/pci/intel/ipu3/cio2-bridge.c | 21 ++++++++++++++++++---
  drivers/media/pci/intel/ipu3/cio2-bridge.h |  5 +++--
  2 files changed, 21 insertions(+), 5 deletions(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +18 -3
index 18974a72e94a..dfefe0d8aa95 100644
@@ -195,6 +195,19 @@ static void cio2_bridge_init_swnode_names(struct cio2_sensor *sensor)
  		 SWNODE_GRAPH_ENDPOINT_NAME_FMT, 0); /* And endpoint 0 */
  }
 
+static void cio2_bridge_init_swnode_group(struct cio2_sensor *sensor)
+{
+	struct software_node *nodes = sensor->swnodes;
+
+	sensor->group[SWNODE_SENSOR_HID] = &nodes[SWNODE_SENSOR_HID];
+	sensor->group[SWNODE_SENSOR_PORT] = &nodes[SWNODE_SENSOR_PORT];
+	sensor->group[SWNODE_SENSOR_ENDPOINT] = &nodes[SWNODE_SENSOR_ENDPOINT];
+	sensor->group[SWNODE_CIO2_PORT] = &nodes[SWNODE_CIO2_PORT];
+	sensor->group[SWNODE_CIO2_ENDPOINT] = &nodes[SWNODE_CIO2_ENDPOINT];
+	if (sensor->ssdb.vcmtype)
+		sensor->group[SWNODE_VCM] =  &nodes[SWNODE_VCM];
+}
+
  static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge,
  						  struct cio2_sensor *sensor)
  {
@@ -219,6 +232,8 @@ static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge,
  	if (sensor->ssdb.vcmtype)
  		nodes[SWNODE_VCM] =
  			NODE_VCM(cio2_vcm_types[sensor->ssdb.vcmtype - 1]);
+
+	cio2_bridge_init_swnode_group(sensor);
  }
 
  static void cio2_bridge_instantiate_vcm_i2c_client(struct cio2_sensor *sensor)
@@ -252,7 +267,7 @@ static void cio2_bridge_unregister_sensors(struct cio2_bridge *bridge)
 
  	for (i = 0; i < bridge->n_sensors; i++) {
  		sensor = &bridge->sensors[i];
-		software_node_unregister_nodes(sensor->swnodes);
+		software_node_unregister_node_group(sensor->group);
  		ACPI_FREE(sensor->pld);
  		acpi_dev_put(sensor->adev);
  		i2c_unregister_device(sensor->vcm_i2c_client);
@@ -310,7 +325,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
  		cio2_bridge_create_fwnode_properties(sensor, bridge, cfg);
  		cio2_bridge_create_connection_swnodes(bridge, sensor);
 
-		ret = software_node_register_nodes(sensor->swnodes);
+		ret = software_node_register_node_group(sensor->group);
  		if (ret)
  			goto err_free_pld;
 
@@ -337,7 +352,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
  	return 0;
 
  err_free_swnodes:
-	software_node_unregister_nodes(sensor->swnodes);
+	software_node_unregister_node_group(sensor->group);
  err_free_pld:
  	ACPI_FREE(sensor->pld);
  err_put_adev:
drivers/media/pci/intel/ipu3/cio2-bridge.h +3 -2
index 4418cbd08208..b93b749c65bd 100644
@@ -117,8 +117,9 @@ struct cio2_sensor {
  	struct acpi_device *adev;
  	struct i2c_client *vcm_i2c_client;
 
-	/* SWNODE_COUNT + 1 for terminating empty node */
-	struct software_node swnodes[SWNODE_COUNT + 1];
+	/* SWNODE_COUNT + 1 for terminating NULL */
+	const struct software_node *group[SWNODE_COUNT + 1];
+	struct software_node swnodes[SWNODE_COUNT];
  	struct cio2_node_names node_names;
 
  	struct cio2_sensor_ssdb ssdb;
#3 lore raw

Re: [PATCH v1 2/4] media: ipu3-cio2: Convert to use software_node_register_node_group()

Hi Dan,

Quoted 6 lines · Dan Scally

Hi Andy

Quoted 3 lines · Andy Shevchenko

The currently used software_node_register_nodes() is going to be removed. Prepare driver by switchich to new API.

Quoted 7 lines
Quoted 2 lines

---

Also looks good to me:

Any chance you can also give this series a test run on an IPU3 device to ensure that it does not cause regressions ?

Regards,

Hans

Quoted 74 lines
Quoted 73 lines

  drivers/media/pci/intel/ipu3/cio2-bridge.c | 21 ++++++++++++++++++--- drivers/media/pci/intel/ipu3/cio2-bridge.h |  5 +++--

  2 files changed, 21 insertions(+), 5 deletions(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +0 -0
index 18974a72e94a..dfefe0d8aa95 100644
@@ -195,6 +195,19 @@ static void cio2_bridge_init_swnode_names(struct cio2_sensor *sensor)

           SWNODE_GRAPH_ENDPOINT_NAME_FMT, 0); /* And endpoint 0 */ }
  +static void cio2_bridge_init_swnode_group(struct cio2_sensor *sensor)

drivers/media/pci/intel/ipu3/cio2-bridge.c +12 -0
+{
+    struct software_node *nodes = sensor->swnodes;
+
+    sensor->group[SWNODE_SENSOR_HID] = &nodes[SWNODE_SENSOR_HID];
+    sensor->group[SWNODE_SENSOR_PORT] = &nodes[SWNODE_SENSOR_PORT];
+    sensor->group[SWNODE_SENSOR_ENDPOINT] = &nodes[SWNODE_SENSOR_ENDPOINT];
+    sensor->group[SWNODE_CIO2_PORT] = &nodes[SWNODE_CIO2_PORT];
+    sensor->group[SWNODE_CIO2_ENDPOINT] = &nodes[SWNODE_CIO2_ENDPOINT];
+    if (sensor->ssdb.vcmtype)
+        sensor->group[SWNODE_VCM] =  &nodes[SWNODE_VCM];
+}
+

  static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge, struct cio2_sensor *sensor)
  {

drivers/media/pci/intel/ipu3/cio2-bridge.c +0 -0
@@ -219,6 +232,8 @@ static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge,
       if (sensor->ssdb.vcmtype)

          nodes[SWNODE_VCM] = NODE_VCM(cio2_vcm_types[sensor->ssdb.vcmtype - 1]);
+
+    cio2_bridge_init_swnode_group(sensor);
  }
    static void cio2_bridge_instantiate_vcm_i2c_client(struct cio2_sensor *sensor)

drivers/media/pci/intel/ipu3/cio2-bridge.c +2 -1
@@ -252,7 +267,7 @@ static void cio2_bridge_unregister_sensors(struct cio2_bridge *bridge)
         for (i = 0; i < bridge->n_sensors; i++) {
           sensor = &bridge->sensors[i];
-        software_node_unregister_nodes(sensor->swnodes);
+        software_node_unregister_node_group(sensor->group);
           ACPI_FREE(sensor->pld);
           acpi_dev_put(sensor->adev);
           i2c_unregister_device(sensor->vcm_i2c_client);
@@ -310,7 +325,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
           cio2_bridge_create_fwnode_properties(sensor, bridge, cfg);
           cio2_bridge_create_connection_swnodes(bridge, sensor);
   -        ret = software_node_register_nodes(sensor->swnodes);
+        ret = software_node_register_node_group(sensor->group);
           if (ret)
               goto err_free_pld;
   @@ -337,7 +352,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,

      return 0;
    err_free_swnodes:
-    software_node_unregister_nodes(sensor->swnodes); +    software_node_unregister_node_group(sensor->group); err_free_pld:
      ACPI_FREE(sensor->pld);
  err_put_adev:

drivers/media/pci/intel/ipu3/cio2-bridge.h +0 -0
index 4418cbd08208..b93b749c65bd 100644
@@ -117,8 +117,9 @@ struct cio2_sensor {
       struct acpi_device *adev;
       struct i2c_client *vcm_i2c_client;

  -    /* SWNODE_COUNT + 1 for terminating empty node */ -    struct software_node swnodes[SWNODE_COUNT + 1]; +    /* SWNODE_COUNT + 1 for terminating NULL */ +    const struct software_node *group[SWNODE_COUNT + 1]; +    struct software_node swnodes[SWNODE_COUNT]; struct cio2_node_names node_names;
        struct cio2_sensor_ssdb ssdb;

reviewer
#4 lore raw

Re: [PATCH v1 2/4] media: ipu3-cio2: Convert to use software_node_register_node_group()

Morning

Quoted 9 lines · Hans de Goede

Hi Dan,

Quoted 6 lines · Dan Scally

Hi Andy

Quoted 3 lines · Andy Shevchenko

The currently used software_node_register_nodes() is going to be removed. Prepare driver by switchich to new API.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

---

Also looks good to me:

Any chance you can also give this series a test run on an IPU3 device to ensure that it does not cause regressions ?

Sure, wait please...

Quoted 79 lines

Regards,

Hans

Quoted 72 lines
Quoted 72 lines

  drivers/media/pci/intel/ipu3/cio2-bridge.c | 21 ++++++++++++++++++--- drivers/media/pci/intel/ipu3/cio2-bridge.h |  5 +++--

  2 files changed, 21 insertions(+), 5 deletions(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +0 -0
index 18974a72e94a..dfefe0d8aa95 100644
@@ -195,6 +195,19 @@ static void cio2_bridge_init_swnode_names(struct cio2_sensor *sensor)

           SWNODE_GRAPH_ENDPOINT_NAME_FMT, 0); /* And endpoint 0 */ }
  +static void cio2_bridge_init_swnode_group(struct cio2_sensor *sensor)

drivers/media/pci/intel/ipu3/cio2-bridge.c +12 -0
+{
+    struct software_node *nodes = sensor->swnodes;
+
+    sensor->group[SWNODE_SENSOR_HID] = &nodes[SWNODE_SENSOR_HID];
+    sensor->group[SWNODE_SENSOR_PORT] = &nodes[SWNODE_SENSOR_PORT];
+    sensor->group[SWNODE_SENSOR_ENDPOINT] = &nodes[SWNODE_SENSOR_ENDPOINT];
+    sensor->group[SWNODE_CIO2_PORT] = &nodes[SWNODE_CIO2_PORT];
+    sensor->group[SWNODE_CIO2_ENDPOINT] = &nodes[SWNODE_CIO2_ENDPOINT];
+    if (sensor->ssdb.vcmtype)
+        sensor->group[SWNODE_VCM] =  &nodes[SWNODE_VCM];
+}
+

  static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge, struct cio2_sensor *sensor)
  {

drivers/media/pci/intel/ipu3/cio2-bridge.c +0 -0
@@ -219,6 +232,8 @@ static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge,
       if (sensor->ssdb.vcmtype)

          nodes[SWNODE_VCM] = NODE_VCM(cio2_vcm_types[sensor->ssdb.vcmtype - 1]);
+
+    cio2_bridge_init_swnode_group(sensor);
  }
    static void cio2_bridge_instantiate_vcm_i2c_client(struct cio2_sensor *sensor)

drivers/media/pci/intel/ipu3/cio2-bridge.c +2 -1
@@ -252,7 +267,7 @@ static void cio2_bridge_unregister_sensors(struct cio2_bridge *bridge)
         for (i = 0; i < bridge->n_sensors; i++) {
           sensor = &bridge->sensors[i];
-        software_node_unregister_nodes(sensor->swnodes);
+        software_node_unregister_node_group(sensor->group);
           ACPI_FREE(sensor->pld);
           acpi_dev_put(sensor->adev);
           i2c_unregister_device(sensor->vcm_i2c_client);
@@ -310,7 +325,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
           cio2_bridge_create_fwnode_properties(sensor, bridge, cfg);
           cio2_bridge_create_connection_swnodes(bridge, sensor);
   -        ret = software_node_register_nodes(sensor->swnodes);
+        ret = software_node_register_node_group(sensor->group);
           if (ret)
               goto err_free_pld;
   @@ -337,7 +352,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,

      return 0;
    err_free_swnodes:
-    software_node_unregister_nodes(sensor->swnodes); +    software_node_unregister_node_group(sensor->group); err_free_pld:
      ACPI_FREE(sensor->pld);
  err_put_adev:

drivers/media/pci/intel/ipu3/cio2-bridge.h +0 -0
index 4418cbd08208..b93b749c65bd 100644
@@ -117,8 +117,9 @@ struct cio2_sensor {
       struct acpi_device *adev;
       struct i2c_client *vcm_i2c_client;

  -    /* SWNODE_COUNT + 1 for terminating empty node */ -    struct software_node swnodes[SWNODE_COUNT + 1]; +    /* SWNODE_COUNT + 1 for terminating NULL */ +    const struct software_node *group[SWNODE_COUNT + 1]; +    struct software_node swnodes[SWNODE_COUNT]; struct cio2_node_names node_names;
        struct cio2_sensor_ssdb ssdb;

author reviewer
#5 lore raw

Re: [PATCH v1 2/4] media: ipu3-cio2: Convert to use software_node_register_node_group()

In reply to Hans de Goede
Quoted 8 lines · Hans de Goede
Quoted 7 lines · Dan Scally
Quoted 2 lines · Andy Shevchenko

The currently used software_node_register_nodes() is going to be removed. Prepare driver by switchich to new API.

Also looks good to me:

Thank you!

Quoted 2 lines

Any chance you can also give this series a test run on an IPU3 device to ensure that it does not cause regressions ?

Yes, it would be really appreciated!

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Tested-by
#6 lore raw

Re: [PATCH v1 2/4] media: ipu3-cio2: Convert to use software_node_register_node_group()

Hi Andy and Hans

Quoted 5 lines · Andy Shevchenko
Quoted 4 lines · Hans de Goede
Quoted 3 lines · Dan Scally
Quoted 2 lines · Andy Shevchenko

The currently used software_node_register_nodes() is going to be removed. Prepare driver by switchich to new API.

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

Also looks good to me:

Thank you!

Quoted 2 lines

Any chance you can also give this series a test run on an IPU3 device to ensure that it does not cause regressions ?

Yes, it would be really appreciated!

All seems fine (including the kunit test) - you can add

to the series

#7 lore raw

Re: [PATCH v1 2/4] media: ipu3-cio2: Convert to use software_node_register_node_group()

Hi,

Quoted 13 lines · Dan Scally

Hi Andy and Hans

Quoted 10 lines · Andy Shevchenko
Quoted 7 lines · Hans de Goede
Quoted 6 lines · Dan Scally
Quoted 2 lines · Andy Shevchenko

The currently used software_node_register_nodes() is going to be removed. Prepare driver by switchich to new API.

Also looks good to me:

Thank you!

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

Any chance you can also give this series a test run on an IPU3 device to ensure that it does not cause regressions ?

Yes, it would be really appreciated!

All seems fine (including the kunit test) - you can add

Great, thank you!

Regards,

Hans

author reviewer
#8 lore raw

PATCH 3/4 software node: Switch property entry test to new API

In reply to Andy Shevchenko

Switch property entry test to use software_node_register_node_group() API. The current one is going to be removed soon.

---
 drivers/base/test/property-entry-test.c | 30 ++++++++++++-------------
 1 file changed, 14 insertions(+), 16 deletions(-)
drivers/base/test/property-entry-test.c +14 -16
index 6071d5bc128c..dd2b606d76a3 100644
@@ -405,20 +405,18 @@ static void pe_test_move_inline_str(struct kunit *test)
 /* Handling of reference properties */
 static void pe_test_reference(struct kunit *test)
 {
-	static const struct software_node nodes[] = {
-		{ .name = "1", },
-		{ .name = "2", },
-		{ }
-	};
+	static const struct software_node node1 = { .name = "1" };
+	static const struct software_node node2 = { .name = "2" };
+	static const struct software_node *group[] = { &node1, &node2, NULL };
 
 	static const struct software_node_ref_args refs[] = {
-		SOFTWARE_NODE_REFERENCE(&nodes[0]),
-		SOFTWARE_NODE_REFERENCE(&nodes[1], 3, 4),
+		SOFTWARE_NODE_REFERENCE(&node1),
+		SOFTWARE_NODE_REFERENCE(&node2, 3, 4),
 	};
 
 	const struct property_entry entries[] = {
-		PROPERTY_ENTRY_REF("ref-1", &nodes[0]),
-		PROPERTY_ENTRY_REF("ref-2", &nodes[1], 1, 2),
+		PROPERTY_ENTRY_REF("ref-1", &node1),
+		PROPERTY_ENTRY_REF("ref-2", &node2, 1, 2),
 		PROPERTY_ENTRY_REF_ARRAY("ref-3", refs),
 		{ }
 	};
@@ -427,7 +425,7 @@ static void pe_test_reference(struct kunit *test)
 	struct fwnode_reference_args ref;
 	int error;
 
-	error = software_node_register_nodes(nodes);
+	error = software_node_register_node_group(group);
 	KUNIT_ASSERT_EQ(test, error, 0);
 
 	node = fwnode_create_software_node(entries, NULL);
@@ -436,7 +434,7 @@ static void pe_test_reference(struct kunit *test)
 	error = fwnode_property_get_reference_args(node, "ref-1", NULL,
 						   0, 0, &ref);
 	KUNIT_ASSERT_EQ(test, error, 0);
-	KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &nodes[0]);
+	KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &node1);
 	KUNIT_EXPECT_EQ(test, ref.nargs, 0U);
 
 	/* wrong index */
@@ -447,7 +445,7 @@ static void pe_test_reference(struct kunit *test)
 	error = fwnode_property_get_reference_args(node, "ref-2", NULL,
 						   1, 0, &ref);
 	KUNIT_ASSERT_EQ(test, error, 0);
-	KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &nodes[1]);
+	KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &node2);
 	KUNIT_EXPECT_EQ(test, ref.nargs, 1U);
 	KUNIT_EXPECT_EQ(test, ref.args[0], 1LLU);
 
@@ -455,7 +453,7 @@ static void pe_test_reference(struct kunit *test)
 	error = fwnode_property_get_reference_args(node, "ref-2", NULL,
 						   3, 0, &ref);
 	KUNIT_ASSERT_EQ(test, error, 0);
-	KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &nodes[1]);
+	KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &node2);
 	KUNIT_EXPECT_EQ(test, ref.nargs, 3U);
 	KUNIT_EXPECT_EQ(test, ref.args[0], 1LLU);
 	KUNIT_EXPECT_EQ(test, ref.args[1], 2LLU);
@@ -470,14 +468,14 @@ static void pe_test_reference(struct kunit *test)
 	error = fwnode_property_get_reference_args(node, "ref-3", NULL,
 						   0, 0, &ref);
 	KUNIT_ASSERT_EQ(test, error, 0);
-	KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &nodes[0]);
+	KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &node1);
 	KUNIT_EXPECT_EQ(test, ref.nargs, 0U);
 
 	/* second reference in the array */
 	error = fwnode_property_get_reference_args(node, "ref-3", NULL,
 						   2, 1, &ref);
 	KUNIT_ASSERT_EQ(test, error, 0);
-	KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &nodes[1]);
+	KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &node2);
 	KUNIT_EXPECT_EQ(test, ref.nargs, 2U);
 	KUNIT_EXPECT_EQ(test, ref.args[0], 3LLU);
 	KUNIT_EXPECT_EQ(test, ref.args[1], 4LLU);
@@ -488,7 +486,7 @@ static void pe_test_reference(struct kunit *test)
 	KUNIT_EXPECT_NE(test, error, 0);
 
 	fwnode_remove_software_node(node);
-	software_node_unregister_nodes(nodes);
+	software_node_unregister_node_group(group);
 }
 
 static struct kunit_case property_entry_test_cases[] = {
Signature · 1 line
2.35.1
maintainer Acked-by on v1 3/4
#9 lore raw

Re: [PATCH v1 3/4] software node: Switch property entry test to new API

Quoted 7 lines · Andy Shevchenko

Switch property entry test to use software_node_register_node_group() API. The current one is going to be removed soon.

---
 drivers/base/test/property-entry-test.c | 30 ++++++++++++-------------
 1 file changed, 14 insertions(+), 16 deletions(-)
author reviewer
#10 lore raw

Re: [PATCH v1 3/4] software node: Switch property entry test to new API

Quoted 5 lines · Greg Kroah-Hartman
Quoted 2 lines · Andy Shevchenko

Switch property entry test to use software_node_register_node_group() API. The current one is going to be removed soon.

Thank you! I hope this stays for v2 (which had been on mailing lists for a few days).

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#11 lore raw

Re: [PATCH v1 3/4] software node: Switch property entry test to new API

Quoted 9 lines · Andy Shevchenko
Quoted 5 lines · Greg Kroah-Hartman
Quoted 2 lines · Andy Shevchenko

Switch property entry test to use software_node_register_node_group() API. The current one is going to be removed soon.

Thank you! I hope this stays for v2 (which had been on mailing lists for a few days).

Yes, sorry, that's the same there, so it holds for there too.

author reviewer
#12 lore raw

PATCH 4/4 software node: Remove unused APIs

In reply to Andy Shevchenko

There are no more users of software_node_register_nodes() and software_node_unregister_nodes(). Remove them.

---
 drivers/base/swnode.c    | 61 ----------------------------------------
 include/linux/property.h |  3 --
 2 files changed, 64 deletions(-)
drivers/base/swnode.c +0 -61
index 0a482212c7e8..da3c1c2cb9a8 100644
@@ -819,67 +819,6 @@ swnode_register(const struct software_node *node, struct swnode *parent,
 	return &swnode->fwnode;
 }
 
-/**
- * software_node_register_nodes - Register an array of software nodes
- * @nodes: Zero terminated array of software nodes to be registered
- *
- * Register multiple software nodes at once. If any node in the array
- * has its .parent pointer set (which can only be to another software_node),
- * then its parent **must** have been registered before it is; either outside
- * of this function or by ordering the array such that parent comes before
- * child.
- */
-int software_node_register_nodes(const struct software_node *nodes)
-{
-	int ret;
-	int i;
-
-	for (i = 0; nodes[i].name; i++) {
-		const struct software_node *parent = nodes[i].parent;
-
-		if (parent && !software_node_to_swnode(parent)) {
-			ret = -EINVAL;
-			goto err_unregister_nodes;
-		}
-
-		ret = software_node_register(&nodes[i]);
-		if (ret)
-			goto err_unregister_nodes;
-	}
-
-	return 0;
-
-err_unregister_nodes:
-	software_node_unregister_nodes(nodes);
-	return ret;
-}
-EXPORT_SYMBOL_GPL(software_node_register_nodes);
-
-/**
- * software_node_unregister_nodes - Unregister an array of software nodes
- * @nodes: Zero terminated array of software nodes to be unregistered
- *
- * Unregister multiple software nodes at once. If parent pointers are set up
- * in any of the software nodes then the array **must** be ordered such that
- * parents come before their children.
- *
- * NOTE: If you are uncertain whether the array is ordered such that
- * parents will be unregistered before their children, it is wiser to
- * remove the nodes individually, in the correct order (child before
- * parent).
- */
-void software_node_unregister_nodes(const struct software_node *nodes)
-{
-	unsigned int i = 0;
-
-	while (nodes[i].name)
-		i++;
-
-	while (i--)
-		software_node_unregister(&nodes[i]);
-}
-EXPORT_SYMBOL_GPL(software_node_unregister_nodes);
-
 /**
  * software_node_register_node_group - Register a group of software nodes
  * @node_group: NULL terminated array of software node pointers to be registered
include/linux/property.h +0 -3
index 5d840299146d..6870abe12dc5 100644
@@ -492,9 +492,6 @@ const struct software_node *
 software_node_find_by_name(const struct software_node *parent,
 			   const char *name);
 
-int software_node_register_nodes(const struct software_node *nodes);
-void software_node_unregister_nodes(const struct software_node *nodes);
-
 int software_node_register_node_group(const struct software_node **node_group);
 void software_node_unregister_node_group(const struct software_node **node_group);
 
Signature · 1 line
2.35.1
reviewer Acked-by on v1 1/4
#14 lore raw
In reply to Andy Shevchenko
Quoted 22 lines · Andy Shevchenko

Use acpi_fwnode_handle() instead of dereferencing an fwnode handle directly, which is a better coding practice.

---
 drivers/media/pci/intel/ipu3/cio2-bridge.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +1 -1
index df6c94da2f6a..18974a72e94a 100644
@@ -263,7 +263,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
 				      struct cio2_bridge *bridge,
 				      struct pci_dev *cio2)
 {
-	struct fwnode_handle *fwnode;
+	struct fwnode_handle *fwnode, *primary;
 	struct cio2_sensor *sensor;
 	struct acpi_device *adev;
 	acpi_status status;

drivers/media/pci/intel/ipu3/cio2-bridge.c static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg, · line 330

Quoted 10 lines
drivers/media/pci/intel/ipu3/cio2-bridge.c +3 -1
@@ -322,7 +322,9 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
 		}
 
 		sensor->adev = acpi_dev_get(adev);
-		adev->fwnode.secondary = fwnode;
+
+		primary = acpi_fwnode_handle(adev);
+		primary->secondary = fwnode;
 
 		cio2_bridge_instantiate_vcm_i2c_client(sensor);
 

This and also the others look good to me. FWIW, for the series:

thanks,

Signature · 1 line
heikki
maintainer
#15 lore raw
In reply to Andy Shevchenko

Hi Andy, sorry for the delay

Quoted 22 lines · Andy Shevchenko

Use acpi_fwnode_handle() instead of dereferencing an fwnode handle directly, which is a better coding practice.

---
  drivers/media/pci/intel/ipu3/cio2-bridge.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +1 -1
index df6c94da2f6a..18974a72e94a 100644
@@ -263,7 +263,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
  				      struct cio2_bridge *bridge,
  				      struct pci_dev *cio2)
  {
-	struct fwnode_handle *fwnode;
+	struct fwnode_handle *fwnode, *primary;
  	struct cio2_sensor *sensor;
  	struct acpi_device *adev;
  	acpi_status status;

drivers/media/pci/intel/ipu3/cio2-bridge.c static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg, · line 330

Quoted 10 lines
drivers/media/pci/intel/ipu3/cio2-bridge.c +3 -1
@@ -322,7 +322,9 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
  		}
 
  		sensor->adev = acpi_dev_get(adev);
-		adev->fwnode.secondary = fwnode;
+
+		primary = acpi_fwnode_handle(adev);
+		primary->secondary = fwnode;
 
  		cio2_bridge_instantiate_vcm_i2c_client(sensor);
 

LGTM: Reviewed-by: Daniel Scally <[email protected]>