Skip to content

Commit 57150c4

Browse files
robherringmiquelraynal
authored andcommitted
mtd: 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(). 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
1 parent 75f32f4 commit 57150c4

6 files changed

Lines changed: 9 additions & 10 deletions

File tree

drivers/mtd/devices/spear_smi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,8 @@ static int spear_smi_probe_config_dt(struct platform_device *pdev,
820820
pdata->board_flash_info->mem_base = be32_to_cpup(&addr[0]);
821821
pdata->board_flash_info->size = be32_to_cpup(&addr[1]);
822822

823-
if (of_get_property(pp, "st,smi-fast-mode", NULL))
824-
pdata->board_flash_info->fast_mode = 1;
823+
pdata->board_flash_info->fast_mode =
824+
of_property_read_bool(pp, "st,smi-fast-mode");
825825

826826
i++;
827827
}

drivers/mtd/maps/sun_uflash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static int uflash_probe(struct platform_device *op)
112112
/* Flashprom must have the "user" property in order to
113113
* be used by this driver.
114114
*/
115-
if (!of_find_property(dp, "user", NULL))
115+
if (!of_property_read_bool(dp, "user"))
116116
return -ENODEV;
117117

118118
return uflash_devinit(op, dp);

drivers/mtd/mtdcore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ int add_mtd_device(struct mtd_info *mtd)
738738

739739
mutex_unlock(&mtd_table_mutex);
740740

741-
if (of_find_property(mtd_get_of_node(mtd), "linux,rootfs", NULL)) {
741+
if (of_property_read_bool(mtd_get_of_node(mtd), "linux,rootfs")) {
742742
if (IS_BUILTIN(CONFIG_MTD)) {
743743
pr_info("mtd: setting mtd%d (%s) as root device\n", mtd->index, mtd->name);
744744
ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index);

drivers/mtd/nand/raw/fsmc_nand.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ static int fsmc_nand_probe_config_dt(struct platform_device *pdev,
880880
}
881881
}
882882

883-
if (of_get_property(np, "nand-skip-bbtscan", NULL))
883+
if (of_property_read_bool(np, "nand-skip-bbtscan"))
884884
nand->options |= NAND_SKIP_BBTSCAN;
885885

886886
host->dev_timings = devm_kzalloc(&pdev->dev,

drivers/mtd/nand/raw/nand_macronix.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,13 @@ static void macronix_nand_onfi_init(struct nand_chip *chip)
9393
struct nand_parameters *p = &chip->parameters;
9494
struct nand_onfi_vendor_macronix *mxic;
9595
struct device_node *dn = nand_get_flash_node(chip);
96-
int rand_otp = 0;
96+
int rand_otp;
9797
int ret;
9898

9999
if (!p->onfi)
100100
return;
101101

102-
if (of_find_property(dn, "mxic,enable-randomizer-otp", NULL))
103-
rand_otp = 1;
102+
rand_otp = of_property_read_bool(dn, "mxic,enable-randomizer-otp");
104103

105104
mxic = (struct nand_onfi_vendor_macronix *)p->onfi->vendor;
106105
/* Subpage write is prohibited in randomizer operatoin */

drivers/mtd/spi-nor/controllers/nxp-spifi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,10 @@ static int nxp_spifi_setup_flash(struct nxp_spifi *spifi,
305305
}
306306
}
307307

308-
if (of_find_property(np, "spi-cpha", NULL))
308+
if (of_property_read_bool(np, "spi-cpha"))
309309
mode |= SPI_CPHA;
310310

311-
if (of_find_property(np, "spi-cpol", NULL))
311+
if (of_property_read_bool(np, "spi-cpol"))
312312
mode |= SPI_CPOL;
313313

314314
/* Setup control register defaults */

0 commit comments

Comments
 (0)