Skip to contentSkip to conversation

media: i2c: thp7312: Don't require node availability

PATCH In review Matti Vaittinen 2 participants 4 messages Mar 20, 2025 – Mar 21, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: i2c: thp7312: Don't require node availability

It appears that the concept of available firmware nodes is not really applicable to the scenarios where a specific name is required from a node.

As explained[1] by Sakari:
"OF only enumerates available nodes via the fwnode API, software nodes don't have the concept but on ACPI I guess you could have a difference in nodes where you have device sub-nodes that aren't available. Still, these ACPI device nodes don't have meaningful names in this context (they're 4-character object names) so you wouldn't use them like this anyway."

Use the fwnode_for_each_child_node() instead of the fwnode_for_each_available_child_node() In order to make it clearly visible that the 'availability' of the nodes does not need to be considered here. This will make it clearly visible that the code in this driver is suitable candidate to be converted to use the new fwnode_for_each_named_child_node()[2] when it gets merged.

[1]:
https://lore.kernel.org/all/[email protected]/
[2]:
https://lore.kernel.org/all/9c3880f74476436f39d796b5c10c540ae50b722c.1742225817.git.mazziesaccount@gmail.com/

---
NOTE: The change is compile tested only! Proper testing and reviewing is highly appreciated (as always).

---
 drivers/media/i2c/thp7312.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/thp7312.c +1 -1
index 8852c56431fe..4b66f64f8d65 100644
@@ -2067,7 +2067,7 @@ static int thp7312_parse_dt(struct thp7312_device *thp7312)
 		return -EINVAL;
 	}
 
-	fwnode_for_each_available_child_node(sensors, node) {
+	fwnode_for_each_child_node(sensors, node) {
 		if (fwnode_name_eq(node, "sensor")) {
 			if (!thp7312_sensor_parse_dt(thp7312, node))
 				num_sensors++;

base-commit: 7eb172143d5508b4da468ed59ee857c6e5e01da6

Signature · 1 line
2.48.1
maintainer
#1 lore raw

Hi Matti,

Quoted 12 lines · Matti Vaittinen

It appears that the concept of available firmware nodes is not really applicable to the scenarios where a specific name is required from a node.

As explained[1] by Sakari:
"OF only enumerates available nodes via the fwnode API, software nodes don't have the concept but on ACPI I guess you could have a difference in nodes where you have device sub-nodes that aren't available. Still, these ACPI device nodes don't have meaningful names in this context (they're 4-character object names) so you wouldn't use them like this anyway."

Quoted 4 lines

Use the fwnode_for_each_child_node() instead of the fwnode_for_each_available_child_node() In order to make it clearly visible that the 'availability' of the nodes does not need to be considered here.

Why not ? Node availability is a concept that exists in DT, and this driver has only been tested on DT-based systems. Why can't we keep the code as-is ?

Quoted 35 lines

This will make it clearly visible that the code in this driver is suitable candidate to be converted to use the new fwnode_for_each_named_child_node()[2] when it gets merged.

[1]:
https://lore.kernel.org/all/[email protected]/
[2]:
https://lore.kernel.org/all/9c3880f74476436f39d796b5c10c540ae50b722c.1742225817.git.mazziesaccount@gmail.com/

---
NOTE: The change is compile tested only! Proper testing and reviewing is highly appreciated (as always).

---
 drivers/media/i2c/thp7312.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/thp7312.c +1 -1
index 8852c56431fe..4b66f64f8d65 100644
@@ -2067,7 +2067,7 @@ static int thp7312_parse_dt(struct thp7312_device *thp7312)
 		return -EINVAL;
 	}
 
-	fwnode_for_each_available_child_node(sensors, node) {
+	fwnode_for_each_child_node(sensors, node) {
 		if (fwnode_name_eq(node, "sensor")) {
 			if (!thp7312_sensor_parse_dt(thp7312, node))
 				num_sensors++;

base-commit: 7eb172143d5508b4da468ed59ee857c6e5e01da6

Signature · 3 lines
Regards,

Laurent Pinchart
#2 lore raw

Hi dee Ho Laurent,

Quoted 15 lines · Laurent Pinchart

Hi Matti,

Quoted 12 lines · Matti Vaittinen

It appears that the concept of available firmware nodes is not really applicable to the scenarios where a specific name is required from a node.

As explained[1] by Sakari:
"OF only enumerates available nodes via the fwnode API, software nodes don't have the concept but on ACPI I guess you could have a difference in nodes where you have device sub-nodes that aren't available. Still, these ACPI device nodes don't have meaningful names in this context (they're 4-character object names) so you wouldn't use them like this anyway."

Quoted 7 lines
Quoted 4 lines

Use the fwnode_for_each_child_node() instead of the fwnode_for_each_available_child_node() In order to make it clearly visible that the 'availability' of the nodes does not need to be considered here.

Why not ? Node availability is a concept that exists in DT, and this driver has only been tested on DT-based systems.

I admit I need to study this then. I just took what Sakari said for granted, without taking any further look at this.

I mean following quote:
"OF only enumerates available nodes via the fwnode API".

I interpreted it as if, in the dt based systems, the nodes which aren't available, wouldn't be enumerated and available via the fwnode APIs. If this is not true, then we probably need to re-re-re-consider also the need for the fwnode_for_each_available_named_child_node().

Quoted 2 lines

Why can't we keep the
code as-is ?

If I am mistaken and the 'availability' has a meaning - then we can and should. If not, then this discussion should serve as a good example why the code should be changed ;)

I hope Sakari can share his view :)

Yours,
-- Matti

#3 lore raw
Quoted 23 lines · Matti Vaittinen

Hi dee Ho Laurent,

Quoted 20 lines · Laurent Pinchart

Hi Matti,

Quoted 16 lines · Matti Vaittinen

It appears that the concept of available firmware nodes is not really applicable to the scenarios where a specific name is required from a node.

As explained[1] by Sakari:
"OF only enumerates available nodes via the fwnode API, software nodes don't have the concept but on ACPI I guess you could have a difference in nodes where you have device sub-nodes that aren't available. Still, these ACPI device nodes don't have meaningful names in this context (they're 4-character object names) so you wouldn't use them like this anyway."

Use the fwnode_for_each_child_node() instead of the fwnode_for_each_available_child_node() In order to make it clearly visible that the 'availability' of the nodes does not need to be considered here.

Quoted 5 lines
Quoted 2 lines

Why not ? Node availability is a concept that exists in DT, and this driver has only been tested on DT-based systems.

I admit I need to study this then. I just took what Sakari said for granted, without taking any further look at this.

I took a peek in the 'availability' concept and found:
https://elixir.bootlin.com/linux/v6.14-rc6/source/drivers/of/base.c#L468

So, the availability indeed has a well defined meaning in the DT, boiling down to the value of the 'status' -property.

Then I took further look at the fwnode_for_each_child_node(), and if I'm not mistaken, it calls:

fwnode_for_each_child_node()

	fwnode_get_next_child_node()
		fwnode_call_ptr_op(fwnode, get_next_child_node, child);
			 of_fwnode_get_next_child_node() (dt-based)
				of_get_next_available_child() (dt-based)

where the of_get_next_available_child() skips all the disabled nodes.

So, in that regard I agree with Sakari. On DT based systems, the

fwnode_for_each_child_node() seems to equal the
fwnode_for_each_available_child_node().

And, since the 'thp7312' driver requires specific names for the nodes, it indeed seems to me that only the device-tree use-case needs to be considered.

After all this I'd say this patch is still valid - but the commit message is misleading. If no one objects I'll rewrite the commit msg and respin :)

Yours,
-- Matti