mtd: rawnand: meson: use of_property_count_elems_of_size helper
authorMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Thu, 11 Apr 2019 22:00:54 +0000 (00:00 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 18 Apr 2019 06:54:06 +0000 (08:54 +0200)
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>
drivers/mtd/nand/raw/meson_nand.c

index c1a6af5..9a60236 100644 (file)
@@ -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;