Skip to contentSkip to conversation

mips: Use of_property_read_bool() for boolean properties

PATCH Applied Rob Herring 4 participants 5 messages Mar 10, 2023 – Mar 14, 2023 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mips: Use of_property_read_bool() for boolean properties

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. Convert reading boolean properties to to of_property_read_bool().

---
 arch/mips/pci/pci-lantiq.c | 2 +-
 arch/mips/pci/pci-rt3883.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/mips/pci/pci-lantiq.c +1 -1
index d967e4c0cf24..79e29bf42a24 100644
@@ -118,7 +118,7 @@ static int ltq_pci_startup(struct platform_device *pdev)
 
 	/* and enable the clocks */
 	clk_enable(clk_pci);
-	if (of_find_property(node, "lantiq,external-clock", NULL))
+	if (of_property_read_bool(node, "lantiq,external-clock"))
 		clk_enable(clk_external);
 	else
 		clk_disable(clk_external);
arch/mips/pci/pci-rt3883.c +1 -1
index d59888aaed81..4ac68a534e4f 100644
@@ -419,7 +419,7 @@ static int rt3883_pci_probe(struct platform_device *pdev)
 
 	/* find the interrupt controller child node */
 	for_each_child_of_node(np, child) {
-		if (of_get_property(child, "interrupt-controller", NULL)) {
+		if (of_property_read_bool(child, "interrupt-controller")) {
 			rpc->intc_of_node = child;
 			break;
 		}
Signature · 1 line
2.39.2
#1 lore raw

Hi Rob,

Quoted 16 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. Convert reading boolean properties to to of_property_read_bool().

---
  arch/mips/pci/pci-lantiq.c | 2 +-
  arch/mips/pci/pci-rt3883.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
arch/mips/pci/pci-lantiq.c +0 -0
index d967e4c0cf24..79e29bf42a24 100644

arch/mips/pci/pci-lantiq.c static int ltq_pci_startup(struct platform_device *pdev) · line 121

Quoted 5 lines
arch/mips/pci/pci-lantiq.c +1 -1
@@ -118,7 +118,7 @@ static int ltq_pci_startup(struct platform_device *pdev)
 
  	/* and enable the clocks */
  	clk_enable(clk_pci);
-	if (of_find_property(node, "lantiq,external-clock", NULL))
+	if (of_property_read_bool(node, "lantiq,external-clock"))

Just curious, is this property correct? I can't find it and wonder if this is dead code (always disabling the clock)... I'm probably missing something obvious :/

Quoted 3 lines
arch/mips/pci/pci-lantiq.c +0 -0
  		clk_enable(clk_external);
  	else
  		clk_disable(clk_external);
#2 lore raw

Hi,

Quoted 21 lines · Philippe Mathieu-Daudé

Hi Rob,

Quoted 17 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. Convert reading boolean properties to to of_property_read_bool().

---
  arch/mips/pci/pci-lantiq.c | 2 +-
  arch/mips/pci/pci-rt3883.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
arch/mips/pci/pci-lantiq.c +0 -0
index d967e4c0cf24..79e29bf42a24 100644
@@ -118,7 +118,7 @@ static int ltq_pci_startup(struct platform_device *pdev)
 
Quoted 12 lines

arch/mips/pci/pci-lantiq.c static int ltq_pci_startup(struct platform_device *pdev) · line 121

Quoted 4 lines
arch/mips/pci/pci-lantiq.c +1 -1
      /* and enable the clocks */
      clk_enable(clk_pci);
-     if (of_find_property(node, "lantiq,external-clock", NULL))
+     if (of_property_read_bool(node, "lantiq,external-clock"))

Just curious, is this property correct? I can't find it and wonder if this is dead code (always disabling the clock)... I'm probably missing something obvious :/

Quoted 3 lines
arch/mips/pci/pci-lantiq.c +0 -0
              clk_enable(clk_external);
      else
              clk_disable(clk_external);

The (whole) binding does seem to be undocumented, at least a quick grep didn't find anything for "lantiq,pci-xway" in bindings :-/

The property itself is used in OpenWrt though, e.g.
https://github.com/openwrt/openwrt/blob/master/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube_arcadyan_arv7518pw.dts#L209

Regards
Jonas

#3 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 21 lines · Philippe Mathieu-Daudé

Hi Rob,

Quoted 17 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. Convert reading boolean properties to to of_property_read_bool().

---
  arch/mips/pci/pci-lantiq.c | 2 +-
  arch/mips/pci/pci-rt3883.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
arch/mips/pci/pci-lantiq.c +0 -0
index d967e4c0cf24..79e29bf42a24 100644
@@ -118,7 +118,7 @@ static int ltq_pci_startup(struct platform_device *pdev)
 
Quoted 6 lines

arch/mips/pci/pci-lantiq.c static int ltq_pci_startup(struct platform_device *pdev) · line 121

Quoted 4 lines
arch/mips/pci/pci-lantiq.c +1 -1
      /* and enable the clocks */
      clk_enable(clk_pci);
-     if (of_find_property(node, "lantiq,external-clock", NULL))
+     if (of_property_read_bool(node, "lantiq,external-clock"))

Just curious, is this property correct?

Shrug. I can only tell from how it is used here and because we have other similar properties used to select a clock.

Quoted 3 lines

I can't find it and wonder if
this is dead code (always disabling the clock)... I'm probably missing something obvious :/

If you don't use the external clock, then you disable it. Seems sensible to me.

Quoted 5 lines
Quoted 4 lines
arch/mips/pci/pci-lantiq.c +0 -0
              clk_enable(clk_external);
      else
              clk_disable(clk_external);
maintainer Applied
#4 lore raw
In reply to Rob Herring
Quoted 10 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. Convert reading boolean properties to to of_property_read_bool().

---
 arch/mips/pci/pci-lantiq.c | 2 +-
 arch/mips/pci/pci-rt3883.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]