]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nvdimm: Use of_property_present() and of_property_read_bool()
authorRob Herring (Arm) <robh@kernel.org>
Wed, 31 Jul 2024 19:13:04 +0000 (13:13 -0600)
committerIra Weiny <ira.weiny@intel.com>
Wed, 21 Aug 2024 21:06:43 +0000 (16:06 -0500)
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>
Link: https://patch.msgid.link/20240731191312.1710417-26-robh@kernel.org
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
drivers/nvdimm/of_pmem.c
drivers/nvmem/layouts.c

index 403384f25ce3f112ce1304e5061942de3bce6aba..b4a1cf70e8b703c7b55bbf97ee9b200e03234751 100644 (file)
@@ -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);
 
index 77a4119efea8f867dffb5376486f000b95ba8b5a..65d39e19f6eca40f138f228653a8a48ab290caae 100644 (file)
@@ -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;