mtd: rawnand: meson: use struct_size macro
authorMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Thu, 11 Apr 2019 22:00:53 +0000 (00:00 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 18 Apr 2019 06:54:06 +0000 (08:54 +0200)
Use the recently introduced struct_size macro instead of open-coding
it's logic.
No functional changes.

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 cb0b03e36a354eef9be2d9004c3ee5054b60b14d..c1a6af57dab5052b56bdf8fe36357fc821c42043 100644 (file)
@@ -1242,8 +1242,7 @@ meson_nfc_nand_chip_init(struct device *dev,
                return -EINVAL;
        }
 
-       meson_chip = devm_kzalloc(dev,
-                                 sizeof(*meson_chip) + (nsels * sizeof(u8)),
+       meson_chip = devm_kzalloc(dev, struct_size(meson_chip, sels, nsels),
                                  GFP_KERNEL);
        if (!meson_chip)
                return -ENOMEM;