mtd: nand: complain loudly when chip->bits_per_cell is not correctly initialized
authorLothar Waßmann <LW@KARO-electronics.de>
Tue, 29 Aug 2017 10:17:13 +0000 (12:17 +0200)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Tue, 29 Aug 2017 16:23:50 +0000 (18:23 +0200)
chip->bits_per_cell which is used to determine the NAND cell type
(SLC/MLC) should always have a value != 0.
Complain loudly if the value is 0 in nand_is_slc() to catch use before
correct initialization.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
include/linux/mtd/rawnand.h

index 8fb488d586d625ca23240b8d60572e6073c3f613..c433f093766abe392bdd0f8492a02161d954d152 100644 (file)
@@ -1234,6 +1234,8 @@ int onfi_init_data_interface(struct nand_chip *chip,
  */
 static inline bool nand_is_slc(struct nand_chip *chip)
 {
+       WARN(chip->bits_per_cell == 0,
+            "chip->bits_per_cell is used uninitialized\n");
        return chip->bits_per_cell == 1;
 }