mtd: nand: Add a helper returning the number of eraseblocks per target
authorBoris Brezillon <bbrezillon@kernel.org>
Mon, 29 Oct 2018 09:29:48 +0000 (10:29 +0100)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 8 Apr 2019 08:21:09 +0000 (10:21 +0200)
Some drivers in the raw NAND framework seems to need this helper, so
let's just add it instead of open-coding the logic.

Signed-off-by: Boris Brezillon <bbrezillon@kernel.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
include/linux/mtd/nand.h

index d32bb62..12d7540 100644 (file)
@@ -295,6 +295,18 @@ nanddev_eraseblocks_per_lun(const struct nand_device *nand)
 }
 
 /**
+ * nanddev_eraseblocks_per_target() - Get the number of eraseblocks per target
+ * @nand: NAND device
+ *
+ * Return: the number of eraseblocks per target.
+ */
+static inline unsigned int
+nanddev_eraseblocks_per_target(const struct nand_device *nand)
+{
+       return nand->memorg.eraseblocks_per_lun * nand->memorg.luns_per_target;
+}
+
+/**
  * nanddev_target_size() - Get the total size provided by a single target/die
  * @nand: NAND device
  *