Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2d8ffbf5 authored by Martin Blumenstingl's avatar Martin Blumenstingl Committed by Miquel Raynal
Browse files

mtd: rawnand: meson: use of_property_count_elems_of_size helper



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: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Tested-by: default avatarLiang Yang <liang.yang@amlogic.com>
Acked-by: default avatarLiang Yang <liang.yang@amlogic.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent 5f73f240
Loading
Loading
Loading
Loading
+1 −4
Original line number Original line Diff line number Diff line
@@ -1233,10 +1233,7 @@ meson_nfc_nand_chip_init(struct device *dev,
	int ret, i;
	int ret, i;
	u32 tmp, nsels;
	u32 tmp, nsels;


	if (!of_get_property(np, "reg", &nsels))
	nsels = of_property_count_elems_of_size(np, "reg", sizeof(u32));
		return -EINVAL;

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