* [PATCH] nvdimm: Use of_property_present() and of_property_read_bool()
@ 2024-07-31 19:13 Rob Herring (Arm)
2024-08-07 18:28 ` Dave Jiang
2024-09-03 19:17 ` Rob Herring
0 siblings, 2 replies; 4+ messages in thread
From: Rob Herring (Arm) @ 2024-07-31 19:13 UTC (permalink / raw)
To: Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny,
Oliver O'Halloran, Srinivas Kandagatla
Cc: nvdimm, linux-kernel
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.
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
drivers/nvdimm/of_pmem.c | 2 +-
drivers/nvmem/layouts.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c
index 403384f25ce3..b4a1cf70e8b7 100644
--- a/drivers/nvdimm/of_pmem.c
+++ b/drivers/nvdimm/of_pmem.c
@@ -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);
diff --git a/drivers/nvmem/layouts.c b/drivers/nvmem/layouts.c
index 77a4119efea8..65d39e19f6ec 100644
--- a/drivers/nvmem/layouts.c
+++ b/drivers/nvmem/layouts.c
@@ -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
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] nvdimm: Use of_property_present() and of_property_read_bool()
2024-07-31 19:13 [PATCH] nvdimm: Use of_property_present() and of_property_read_bool() Rob Herring (Arm)
@ 2024-08-07 18:28 ` Dave Jiang
2024-09-03 19:17 ` Rob Herring
1 sibling, 0 replies; 4+ messages in thread
From: Dave Jiang @ 2024-08-07 18:28 UTC (permalink / raw)
To: Rob Herring (Arm), Dan Williams, Vishal Verma, Ira Weiny,
Oliver O'Halloran, Srinivas Kandagatla
Cc: nvdimm, linux-kernel
On 7/31/24 12:13 PM, Rob Herring (Arm) wrote:
> 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.
>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> drivers/nvdimm/of_pmem.c | 2 +-
> drivers/nvmem/layouts.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c
> index 403384f25ce3..b4a1cf70e8b7 100644
> --- a/drivers/nvdimm/of_pmem.c
> +++ b/drivers/nvdimm/of_pmem.c
> @@ -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);
>
> diff --git a/drivers/nvmem/layouts.c b/drivers/nvmem/layouts.c
> index 77a4119efea8..65d39e19f6ec 100644
> --- a/drivers/nvmem/layouts.c
> +++ b/drivers/nvmem/layouts.c
> @@ -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;
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] nvdimm: Use of_property_present() and of_property_read_bool()
2024-07-31 19:13 [PATCH] nvdimm: Use of_property_present() and of_property_read_bool() Rob Herring (Arm)
2024-08-07 18:28 ` Dave Jiang
@ 2024-09-03 19:17 ` Rob Herring
2024-09-04 13:50 ` Ira Weiny
1 sibling, 1 reply; 4+ messages in thread
From: Rob Herring @ 2024-09-03 19:17 UTC (permalink / raw)
To: Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny,
Oliver O'Halloran, Srinivas Kandagatla
Cc: nvdimm, linux-kernel
On Wed, Jul 31, 2024 at 2:14 PM Rob Herring (Arm) <robh@kernel.org> wrote:
>
> 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.
>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
> drivers/nvdimm/of_pmem.c | 2 +-
> drivers/nvmem/layouts.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
Ping
> diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c
> index 403384f25ce3..b4a1cf70e8b7 100644
> --- a/drivers/nvdimm/of_pmem.c
> +++ b/drivers/nvdimm/of_pmem.c
> @@ -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);
>
> diff --git a/drivers/nvmem/layouts.c b/drivers/nvmem/layouts.c
> index 77a4119efea8..65d39e19f6ec 100644
> --- a/drivers/nvmem/layouts.c
> +++ b/drivers/nvmem/layouts.c
> @@ -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
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] nvdimm: Use of_property_present() and of_property_read_bool()
2024-09-03 19:17 ` Rob Herring
@ 2024-09-04 13:50 ` Ira Weiny
0 siblings, 0 replies; 4+ messages in thread
From: Ira Weiny @ 2024-09-04 13:50 UTC (permalink / raw)
To: Rob Herring, Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny,
Oliver O'Halloran, Srinivas Kandagatla
Cc: nvdimm, linux-kernel
Rob Herring wrote:
> On Wed, Jul 31, 2024 at 2:14 PM Rob Herring (Arm) <robh@kernel.org> wrote:
> >
> > 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.
> >
> > Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> > ---
> > 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
>
> > diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c
> > index 403384f25ce3..b4a1cf70e8b7 100644
> > --- a/drivers/nvdimm/of_pmem.c
> > +++ b/drivers/nvdimm/of_pmem.c
> > @@ -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);
> >
> > diff --git a/drivers/nvmem/layouts.c b/drivers/nvmem/layouts.c
> > index 77a4119efea8..65d39e19f6ec 100644
> > --- a/drivers/nvmem/layouts.c
> > +++ b/drivers/nvmem/layouts.c
> > @@ -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
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-09-04 13:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-31 19:13 [PATCH] nvdimm: Use of_property_present() and of_property_read_bool() Rob Herring (Arm)
2024-08-07 18:28 ` Dave Jiang
2024-09-03 19:17 ` Rob Herring
2024-09-04 13:50 ` Ira Weiny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox