Skip to contentSkip to conversation

nvdimm: Use of_property_present() and of_property_read_bool()

PATCH In review Rob Herring (Arm) 3 participants 4 messages Jul 31, 2024 – Sep 4, 2024

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

PATCH 1/1 nvdimm: Use of_property_present() and of_property_read_bool()

Use of_property_present() and of_property_read_bool() to test property presence and read boolean properties rather than of_(find|get)_property(). This is part of a larger effort to remove callers of of_find_property() and similar functions. of_(find|get)_property() leak the DT struct property and data pointers which is a problem for dynamically allocated nodes which may be freed.

---
 drivers/nvdimm/of_pmem.c | 2 +-
 drivers/nvmem/layouts.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/nvdimm/of_pmem.c +1 -1
index 403384f25ce3..b4a1cf70e8b7 100644
@@ -47,7 +47,7 @@ static int of_pmem_region_probe(struct platform_device *pdev)
 	}
 	platform_set_drvdata(pdev, priv);
 
-	is_volatile = !!of_find_property(np, "volatile", NULL);
+	is_volatile = of_property_read_bool(np, "volatile");
 	dev_dbg(&pdev->dev, "Registering %s regions from %pOF\n",
 			is_volatile ? "volatile" : "non-volatile",  np);
 
drivers/nvmem/layouts.c +1 -1
index 77a4119efea8..65d39e19f6ec 100644
@@ -123,7 +123,7 @@ static int nvmem_layout_bus_populate(struct nvmem_device *nvmem,
 	int ret;
 
 	/* Make sure it has a compatible property */
-	if (!of_get_property(layout_dn, "compatible", NULL)) {
+	if (!of_property_present(layout_dn, "compatible")) {
 		pr_debug("%s() - skipping %pOF, no compatible prop\n",
 			 __func__, layout_dn);
 		return 0;
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Rob Herring (Arm)

Use of_property_present() and of_property_read_bool() to test property presence and read boolean properties rather than of_(find|get)_property(). This is part of a larger effort to remove callers of of_find_property() and similar functions. of_(find|get)_property() leak the DT struct property and data pointers which is a problem for dynamically allocated nodes which may be freed.

Quoted 31 lines
---
 drivers/nvdimm/of_pmem.c | 2 +-
 drivers/nvmem/layouts.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/nvdimm/of_pmem.c +1 -1
index 403384f25ce3..b4a1cf70e8b7 100644
@@ -47,7 +47,7 @@ static int of_pmem_region_probe(struct platform_device *pdev)
 	}
 	platform_set_drvdata(pdev, priv);
 
-	is_volatile = !!of_find_property(np, "volatile", NULL);
+	is_volatile = of_property_read_bool(np, "volatile");
 	dev_dbg(&pdev->dev, "Registering %s regions from %pOF\n",
 			is_volatile ? "volatile" : "non-volatile",  np);
 
drivers/nvmem/layouts.c +1 -1
index 77a4119efea8..65d39e19f6ec 100644
@@ -123,7 +123,7 @@ static int nvmem_layout_bus_populate(struct nvmem_device *nvmem,
 	int ret;
 
 	/* Make sure it has a compatible property */
-	if (!of_get_property(layout_dn, "compatible", NULL)) {
+	if (!of_property_present(layout_dn, "compatible")) {
 		pr_debug("%s() - skipping %pOF, no compatible prop\n",
 			 __func__, layout_dn);
 		return 0;
#2 lore raw
In reply to Rob Herring (Arm)
Quoted 8 lines · Rob Herring (Arm)

Use of_property_present() and of_property_read_bool() to test property presence and read boolean properties rather than of_(find|get)_property(). This is part of a larger effort to remove callers of of_find_property() and similar functions. of_(find|get)_property() leak the DT struct property and data pointers which is a problem for dynamically allocated nodes which may be freed.

Quoted 5 lines
---
 drivers/nvdimm/of_pmem.c | 2 +-
 drivers/nvmem/layouts.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Ping

Quoted 29 lines
drivers/nvdimm/of_pmem.c +1 -1
index 403384f25ce3..b4a1cf70e8b7 100644
@@ -47,7 +47,7 @@ static int of_pmem_region_probe(struct platform_device *pdev)
        }
        platform_set_drvdata(pdev, priv);
 
-       is_volatile = !!of_find_property(np, "volatile", NULL);
+       is_volatile = of_property_read_bool(np, "volatile");
        dev_dbg(&pdev->dev, "Registering %s regions from %pOF\n",
                        is_volatile ? "volatile" : "non-volatile",  np);
 
drivers/nvmem/layouts.c +1 -2
index 77a4119efea8..65d39e19f6ec 100644
@@ -123,7 +123,7 @@ static int nvmem_layout_bus_populate(struct nvmem_device *nvmem,
        int ret;
 
        /* Make sure it has a compatible property */
-       if (!of_get_property(layout_dn, "compatible", NULL)) {
+       if (!of_property_present(layout_dn, "compatible")) {
                pr_debug("%s() - skipping %pOF, no compatible prop\n",
                         __func__, layout_dn);
                return 0;
--

2.43.0

#3 lore raw
Quoted 9 lines · Rob Herring
Quoted 8 lines · Rob Herring (Arm)

Use of_property_present() and of_property_read_bool() to test property presence and read boolean properties rather than of_(find|get)_property(). This is part of a larger effort to remove callers of of_find_property() and similar functions. of_(find|get)_property() leak the DT struct property and data pointers which is a problem for dynamically allocated nodes which may be freed.

Quoted 7 lines
Quoted 5 lines
---
 drivers/nvdimm/of_pmem.c | 2 +-
 drivers/nvmem/layouts.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Ping

It is soaking for 6.12.

https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git/log/?h=libnvdimm-for-next

Thanks,
Ira

Quoted 30 lines
Quoted 30 lines
drivers/nvdimm/of_pmem.c +1 -1
index 403384f25ce3..b4a1cf70e8b7 100644
@@ -47,7 +47,7 @@ static int of_pmem_region_probe(struct platform_device *pdev)
        }
        platform_set_drvdata(pdev, priv);
 
-       is_volatile = !!of_find_property(np, "volatile", NULL);
+       is_volatile = of_property_read_bool(np, "volatile");
        dev_dbg(&pdev->dev, "Registering %s regions from %pOF\n",
                        is_volatile ? "volatile" : "non-volatile",  np);
 
drivers/nvmem/layouts.c +1 -2
index 77a4119efea8..65d39e19f6ec 100644
@@ -123,7 +123,7 @@ static int nvmem_layout_bus_populate(struct nvmem_device *nvmem,
        int ret;
 
        /* Make sure it has a compatible property */
-       if (!of_get_property(layout_dn, "compatible", NULL)) {
+       if (!of_property_present(layout_dn, "compatible")) {
                pr_debug("%s() - skipping %pOF, no compatible prop\n",
                         __func__, layout_dn);
                return 0;
--

2.43.0