Skip to content

Commit

Permalink
mtd: rawnand: meson: use of_property_count_elems_of_size helper
Browse files Browse the repository at this point in the history
Use the of_property_count_elems_of_size() helper instead of open-coding
it's logic. As a bonus this will now error out if the "reg" property
values use an incorrect size (anything other than sizeof(u32)).

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Tested-by:Liang Yang <liang.yang@amlogic.com>
Acked-by: Liang Yang <liang.yang@amlogic.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
  • Loading branch information
Martin Blumenstingl authored and Miquel Raynal committed Apr 18, 2019
1 parent 5f73f24 commit 2d8ffbf
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions drivers/mtd/nand/raw/meson_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -1233,10 +1233,7 @@ meson_nfc_nand_chip_init(struct device *dev,
int ret, i;
u32 tmp, nsels;

if (!of_get_property(np, "reg", &nsels))
return -EINVAL;

nsels /= sizeof(u32);
nsels = of_property_count_elems_of_size(np, "reg", sizeof(u32));
if (!nsels || nsels > MAX_CE_NUM) {
dev_err(dev, "invalid register property size\n");
return -EINVAL;
Expand Down

0 comments on commit 2d8ffbf

Please sign in to comment.