mtd: Use of_property_read_bool() for boolean properties
authorRob Herring <robh@kernel.org>
Fri, 10 Mar 2023 14:47:15 +0000 (08:47 -0600)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 22 Mar 2023 16:02:17 +0000 (17:02 +0100)
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().

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230310144716.1543995-1-robh@kernel.org
drivers/mtd/devices/spear_smi.c
drivers/mtd/maps/sun_uflash.c
drivers/mtd/mtdcore.c
drivers/mtd/nand/raw/fsmc_nand.c
drivers/mtd/nand/raw/nand_macronix.c
drivers/mtd/spi-nor/controllers/nxp-spifi.c

index f58742486d3de37a9a4f04cb2034921906e0e159..cc17133be2972aab47c09a4222c680537939ebf3 100644 (file)
@@ -820,8 +820,8 @@ static int spear_smi_probe_config_dt(struct platform_device *pdev,
                pdata->board_flash_info->mem_base = be32_to_cpup(&addr[0]);
                pdata->board_flash_info->size = be32_to_cpup(&addr[1]);
 
-               if (of_get_property(pp, "st,smi-fast-mode", NULL))
-                       pdata->board_flash_info->fast_mode = 1;
+               pdata->board_flash_info->fast_mode =
+                       of_property_read_bool(pp, "st,smi-fast-mode");
 
                i++;
        }
index 6c0c91bfec058d6b7f532ee325d8c3b3cd763af4..860b19f77090277343e9b59e5a0ca9b2318e1652 100644 (file)
@@ -112,7 +112,7 @@ static int uflash_probe(struct platform_device *op)
        /* Flashprom must have the "user" property in order to
         * be used by this driver.
         */
-       if (!of_find_property(dp, "user", NULL))
+       if (!of_property_read_bool(dp, "user"))
                return -ENODEV;
 
        return uflash_devinit(op, dp);
index c78f9f4d522cf68f6974c1283cc5f4cf47501c1a..a1a08c2b6f77b358defb8d1042bd288a1b9dd9ec 100644 (file)
@@ -738,7 +738,7 @@ int add_mtd_device(struct mtd_info *mtd)
 
        mutex_unlock(&mtd_table_mutex);
 
-       if (of_find_property(mtd_get_of_node(mtd), "linux,rootfs", NULL)) {
+       if (of_property_read_bool(mtd_get_of_node(mtd), "linux,rootfs")) {
                if (IS_BUILTIN(CONFIG_MTD)) {
                        pr_info("mtd: setting mtd%d (%s) as root device\n", mtd->index, mtd->name);
                        ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
index 6b2bda815b880c969c239d9dc6336d2392dcbb42..0d34d433b732e372ed2a0ef8f412784a98ee1879 100644 (file)
@@ -880,7 +880,7 @@ static int fsmc_nand_probe_config_dt(struct platform_device *pdev,
                }
        }
 
-       if (of_get_property(np, "nand-skip-bbtscan", NULL))
+       if (of_property_read_bool(np, "nand-skip-bbtscan"))
                nand->options |= NAND_SKIP_BBTSCAN;
 
        host->dev_timings = devm_kzalloc(&pdev->dev,
index 1472f925f3868ed2bdae0fc0889a22deae098fdf..385957eb676211a058a9c482d1b47ecdab3a9f72 100644 (file)
@@ -93,14 +93,13 @@ static void macronix_nand_onfi_init(struct nand_chip *chip)
        struct nand_parameters *p = &chip->parameters;
        struct nand_onfi_vendor_macronix *mxic;
        struct device_node *dn = nand_get_flash_node(chip);
-       int rand_otp = 0;
+       int rand_otp;
        int ret;
 
        if (!p->onfi)
                return;
 
-       if (of_find_property(dn, "mxic,enable-randomizer-otp", NULL))
-               rand_otp = 1;
+       rand_otp = of_property_read_bool(dn, "mxic,enable-randomizer-otp");
 
        mxic = (struct nand_onfi_vendor_macronix *)p->onfi->vendor;
        /* Subpage write is prohibited in randomizer operatoin */
index ab3990e6ac25da648b77bb25ff52cda09dd3532c..794c7b7d5c92b2b5ea0491fd92764d23c6e63a03 100644 (file)
@@ -305,10 +305,10 @@ static int nxp_spifi_setup_flash(struct nxp_spifi *spifi,
                }
        }
 
-       if (of_find_property(np, "spi-cpha", NULL))
+       if (of_property_read_bool(np, "spi-cpha"))
                mode |= SPI_CPHA;
 
-       if (of_find_property(np, "spi-cpol", NULL))
+       if (of_property_read_bool(np, "spi-cpol"))
                mode |= SPI_CPOL;
 
        /* Setup control register defaults */