[PATCH v3 4/4] soc: sunxi: sram: Only iterate over SRAM children

Samuel Holland posted 4 patches 3 years, 8 months ago
[PATCH v3 4/4] soc: sunxi: sram: Only iterate over SRAM children
Posted by Samuel Holland 3 years, 8 months ago
Now that a "regulators" child is accepted by the controller binding, the
debugfs show routine must be explicitly limited to "sram" children.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---

(no changes since v2)

Changes in v2:
 - New patch for v2

 drivers/soc/sunxi/sunxi_sram.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/soc/sunxi/sunxi_sram.c b/drivers/soc/sunxi/sunxi_sram.c
index 92f9186c1c42..6acaaeb65652 100644
--- a/drivers/soc/sunxi/sunxi_sram.c
+++ b/drivers/soc/sunxi/sunxi_sram.c
@@ -120,6 +120,9 @@ static int sunxi_sram_show(struct seq_file *s, void *data)
 	seq_puts(s, "--------------------\n\n");
 
 	for_each_child_of_node(sram_dev->of_node, sram_node) {
+		if (!of_node_name_eq(sram_node, "sram"))
+			continue;
+
 		sram_addr_p = of_get_address(sram_node, 0, NULL, NULL);
 
 		seq_printf(s, "sram@%08x\n",
-- 
2.35.1
Re: [PATCH v3 4/4] soc: sunxi: sram: Only iterate over SRAM children
Posted by Krzysztof Kozlowski 3 years, 8 months ago
On 15/08/2022 07:34, Samuel Holland wrote:
> Now that a "regulators" child is accepted by the controller binding, the
> debugfs show routine must be explicitly limited to "sram" children.
> 
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
> 
> (no changes since v2)
> 
> Changes in v2:
>  - New patch for v2
> 
>  drivers/soc/sunxi/sunxi_sram.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/soc/sunxi/sunxi_sram.c b/drivers/soc/sunxi/sunxi_sram.c
> index 92f9186c1c42..6acaaeb65652 100644
> --- a/drivers/soc/sunxi/sunxi_sram.c
> +++ b/drivers/soc/sunxi/sunxi_sram.c
> @@ -120,6 +120,9 @@ static int sunxi_sram_show(struct seq_file *s, void *data)
>  	seq_puts(s, "--------------------\n\n");
>  
>  	for_each_child_of_node(sram_dev->of_node, sram_node) {
> +		if (!of_node_name_eq(sram_node, "sram"))

You should not rely on node names. They can change in DTS. Why do you
need to test for the name?

Best regards,
Krzysztof
Re: [PATCH v3 4/4] soc: sunxi: sram: Only iterate over SRAM children
Posted by Krzysztof Kozlowski 3 years, 8 months ago
On 16/08/2022 13:01, Krzysztof Kozlowski wrote:
> On 15/08/2022 07:34, Samuel Holland wrote:
>> Now that a "regulators" child is accepted by the controller binding, the
>> debugfs show routine must be explicitly limited to "sram" children.
>>
>> Signed-off-by: Samuel Holland <samuel@sholland.org>
>> ---
>>
>> (no changes since v2)
>>
>> Changes in v2:
>>  - New patch for v2
>>
>>  drivers/soc/sunxi/sunxi_sram.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/soc/sunxi/sunxi_sram.c b/drivers/soc/sunxi/sunxi_sram.c
>> index 92f9186c1c42..6acaaeb65652 100644
>> --- a/drivers/soc/sunxi/sunxi_sram.c
>> +++ b/drivers/soc/sunxi/sunxi_sram.c
>> @@ -120,6 +120,9 @@ static int sunxi_sram_show(struct seq_file *s, void *data)
>>  	seq_puts(s, "--------------------\n\n");
>>  
>>  	for_each_child_of_node(sram_dev->of_node, sram_node) {
>> +		if (!of_node_name_eq(sram_node, "sram"))
> 
> You should not rely on node names. They can change in DTS. Why do you
> need to test for the name?
> 

Ah, it is not a device node but a child property, right? In such case,
it's of course fine.

The device node names could change and should not be considered ABI (at
least I hope should not...).

Best regards,
Krzysztof
Re: [PATCH v3 4/4] soc: sunxi: sram: Only iterate over SRAM children
Posted by Samuel Holland 3 years, 7 months ago
On 8/16/22 5:03 AM, Krzysztof Kozlowski wrote:
> On 16/08/2022 13:01, Krzysztof Kozlowski wrote:
>> On 15/08/2022 07:34, Samuel Holland wrote:
>>> Now that a "regulators" child is accepted by the controller binding, the
>>> debugfs show routine must be explicitly limited to "sram" children.
>>>
>>> Signed-off-by: Samuel Holland <samuel@sholland.org>
>>> ---
>>>
>>> (no changes since v2)
>>>
>>> Changes in v2:
>>>  - New patch for v2
>>>
>>>  drivers/soc/sunxi/sunxi_sram.c | 3 +++
>>>  1 file changed, 3 insertions(+)
>>>
>>> diff --git a/drivers/soc/sunxi/sunxi_sram.c b/drivers/soc/sunxi/sunxi_sram.c
>>> index 92f9186c1c42..6acaaeb65652 100644
>>> --- a/drivers/soc/sunxi/sunxi_sram.c
>>> +++ b/drivers/soc/sunxi/sunxi_sram.c
>>> @@ -120,6 +120,9 @@ static int sunxi_sram_show(struct seq_file *s, void *data)
>>>  	seq_puts(s, "--------------------\n\n");
>>>  
>>>  	for_each_child_of_node(sram_dev->of_node, sram_node) {
>>> +		if (!of_node_name_eq(sram_node, "sram"))
>>
>> You should not rely on node names. They can change in DTS. Why do you
>> need to test for the name?
>>
> 
> Ah, it is not a device node but a child property, right? In such case,
> it's of course fine.

It is a child node.

> The device node names could change and should not be considered ABI (at
> least I hope should not...).

The node names are limited by patternProperties in the controller binding. I can
check the child nodes for compatibility with "mmio-sram" if that is better.

Regards,
Samuel
Re: [PATCH v3 4/4] soc: sunxi: sram: Only iterate over SRAM children
Posted by Heiko Stübner 3 years, 8 months ago
Am Montag, 15. August 2022, 06:34:35 CEST schrieb Samuel Holland:
> Now that a "regulators" child is accepted by the controller binding, the
> debugfs show routine must be explicitly limited to "sram" children.
> 
> Signed-off-by: Samuel Holland <samuel@sholland.org>

Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Heiko Stuebner <heiko@sntech.de>