Skip to contentSkip to conversation

cpuidle: Use of_property_present() for testing DT property presence

PATCH Applied Rob Herring 5 participants 5 messages Mar 10, 2023 – May 8, 2023

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

PATCH 1/1 cpuidle: Use of_property_present() for testing DT property presence

It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more.

---
 drivers/cpuidle/cpuidle-psci-domain.c | 2 +-
 drivers/cpuidle/cpuidle-riscv-sbi.c   | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/cpuidle/cpuidle-psci-domain.c +1 -1
index 6ad2954948a5..e875ddadc51b 100644
@@ -165,7 +165,7 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev)
 	 * initialize a genpd/genpd-of-provider pair when it's found.
 	 */
 	for_each_child_of_node(np, node) {
-		if (!of_find_property(node, "#power-domain-cells", NULL))
+		if (!of_property_present(node, "#power-domain-cells"))
 			continue;
 
 		ret = psci_pd_init(node, use_osi);
drivers/cpuidle/cpuidle-riscv-sbi.c +3 -3
index be383f4b6855..1fab1abc6eb6 100644
@@ -497,7 +497,7 @@ static int sbi_genpd_probe(struct device_node *np)
 	 * initialize a genpd/genpd-of-provider pair when it's found.
 	 */
 	for_each_child_of_node(np, node) {
-		if (!of_find_property(node, "#power-domain-cells", NULL))
+		if (!of_property_present(node, "#power-domain-cells"))
 			continue;
 
 		ret = sbi_pd_init(node);
@@ -548,8 +548,8 @@ static int sbi_cpuidle_probe(struct platform_device *pdev)
 	for_each_possible_cpu(cpu) {
 		np = of_cpu_device_node_get(cpu);
 		if (np &&
-		    of_find_property(np, "power-domains", NULL) &&
-		    of_find_property(np, "power-domain-names", NULL)) {
+		    of_property_present(np, "power-domains") &&
+		    of_property_present(np, "power-domain-names")) {
 			continue;
 		} else {
 			sbi_cpuidle_use_osi = false;
Signature · 1 line
2.39.2
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Rob Herring

It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more.

Rafael, can you please pick this via your tree.

Kind regards
Uffe

Quoted 43 lines
---
 drivers/cpuidle/cpuidle-psci-domain.c | 2 +-
 drivers/cpuidle/cpuidle-riscv-sbi.c   | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/cpuidle/cpuidle-psci-domain.c +1 -1
index 6ad2954948a5..e875ddadc51b 100644
@@ -165,7 +165,7 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev)
         * initialize a genpd/genpd-of-provider pair when it's found.
         */
        for_each_child_of_node(np, node) {
-               if (!of_find_property(node, "#power-domain-cells", NULL))
+               if (!of_property_present(node, "#power-domain-cells"))
                        continue;
 
                ret = psci_pd_init(node, use_osi);
drivers/cpuidle/cpuidle-riscv-sbi.c +3 -4
index be383f4b6855..1fab1abc6eb6 100644
@@ -497,7 +497,7 @@ static int sbi_genpd_probe(struct device_node *np)
         * initialize a genpd/genpd-of-provider pair when it's found.
         */
        for_each_child_of_node(np, node) {
-               if (!of_find_property(node, "#power-domain-cells", NULL))
+               if (!of_property_present(node, "#power-domain-cells"))
                        continue;
 
                ret = sbi_pd_init(node);
@@ -548,8 +548,8 @@ static int sbi_cpuidle_probe(struct platform_device *pdev)
        for_each_possible_cpu(cpu) {
                np = of_cpu_device_node_get(cpu);
                if (np &&
-                   of_find_property(np, "power-domains", NULL) &&
-                   of_find_property(np, "power-domain-names", NULL)) {
+                   of_property_present(np, "power-domains") &&
+                   of_property_present(np, "power-domain-names")) {
                        continue;
                } else {
                        sbi_cpuidle_use_osi = false;
--
Quoted 2 lines

2.39.2

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#2 lore raw
Quoted 10 lines · Ulf Hansson
Quoted 8 lines · Rob Herring

It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more.

Quoted 5 lines
Quoted 1 line

Rafael, can you please pick this via your tree.

Done (queued up for 6.4), thanks!

Quoted 30 lines
Quoted 30 lines
---
 drivers/cpuidle/cpuidle-psci-domain.c | 2 +-
 drivers/cpuidle/cpuidle-riscv-sbi.c   | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/cpuidle/cpuidle-psci-domain.c +1 -1
index 6ad2954948a5..e875ddadc51b 100644
@@ -165,7 +165,7 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev)
         * initialize a genpd/genpd-of-provider pair when it's found.
         */
        for_each_child_of_node(np, node) {
-               if (!of_find_property(node, "#power-domain-cells", NULL))
+               if (!of_property_present(node, "#power-domain-cells"))
                        continue;
 
                ret = psci_pd_init(node, use_osi);
drivers/cpuidle/cpuidle-riscv-sbi.c +1 -1
index be383f4b6855..1fab1abc6eb6 100644
@@ -497,7 +497,7 @@ static int sbi_genpd_probe(struct device_node *np)
         * initialize a genpd/genpd-of-provider pair when it's found.
         */
        for_each_child_of_node(np, node) {
-               if (!of_find_property(node, "#power-domain-cells", NULL))
+               if (!of_property_present(node, "#power-domain-cells"))
                        continue;
 
Quoted 15 lines
Quoted 13 lines
drivers/cpuidle/cpuidle-riscv-sbi.c +2 -3
                ret = sbi_pd_init(node);
@@ -548,8 +548,8 @@ static int sbi_cpuidle_probe(struct platform_device *pdev)
        for_each_possible_cpu(cpu) {
                np = of_cpu_device_node_get(cpu);
                if (np &&
-                   of_find_property(np, "power-domains", NULL) &&
-                   of_find_property(np, "power-domain-names", NULL)) {
+                   of_property_present(np, "power-domains") &&
+                   of_property_present(np, "power-domain-names")) {
                        continue;
                } else {
                        sbi_cpuidle_use_osi = false;
--
Quoted 2 lines

2.39.2

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Rob Herring
Quoted 9 lines · Rob Herring

It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more.

For cpuidle-riscv-sbi:

Thanks,
Anup

Quoted 45 lines
---
 drivers/cpuidle/cpuidle-psci-domain.c | 2 +-
 drivers/cpuidle/cpuidle-riscv-sbi.c   | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/cpuidle/cpuidle-psci-domain.c +1 -1
index 6ad2954948a5..e875ddadc51b 100644
@@ -165,7 +165,7 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev)
         * initialize a genpd/genpd-of-provider pair when it's found.
         */
        for_each_child_of_node(np, node) {
-               if (!of_find_property(node, "#power-domain-cells", NULL))
+               if (!of_property_present(node, "#power-domain-cells"))
                        continue;
 
                ret = psci_pd_init(node, use_osi);
drivers/cpuidle/cpuidle-riscv-sbi.c +3 -4
index be383f4b6855..1fab1abc6eb6 100644
@@ -497,7 +497,7 @@ static int sbi_genpd_probe(struct device_node *np)
         * initialize a genpd/genpd-of-provider pair when it's found.
         */
        for_each_child_of_node(np, node) {
-               if (!of_find_property(node, "#power-domain-cells", NULL))
+               if (!of_property_present(node, "#power-domain-cells"))
                        continue;
 
                ret = sbi_pd_init(node);
@@ -548,8 +548,8 @@ static int sbi_cpuidle_probe(struct platform_device *pdev)
        for_each_possible_cpu(cpu) {
                np = of_cpu_device_node_get(cpu);
                if (np &&
-                   of_find_property(np, "power-domains", NULL) &&
-                   of_find_property(np, "power-domain-names", NULL)) {
+                   of_property_present(np, "power-domains") &&
+                   of_property_present(np, "power-domain-names")) {
                        continue;
                } else {
                        sbi_cpuidle_use_osi = false;
--

2.39.2

#4 lore raw
In reply to Rob Herring
This patch was applied to riscv/linux.git (fixes) by Rafael J. Wysocki <[email protected]>:

Hello:

This patch was applied to riscv/linux.git (fixes) by Rafael J. Wysocki <[email protected]>:

Quoted 8 lines · On Fri, 10 Mar 2023 08:47:03 -0600 you wrote:

It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more.

[...]

Here is the summary with links:
- cpuidle: Use of_property_present() for testing DT property presence

    https://git.kernel.org/riscv/c/f914bfdd7f84

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html