From 47d2f3cc737ba183a27901faf4048f422aa7c010 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lothar=20Wa=C3=9Fmann?= Date: Tue, 29 Aug 2017 12:07:00 +0200 Subject: [PATCH 1/1] mtd: nand: complain loudly when chip->bits_per_cell is not correctly initialized 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. --- include/linux/mtd/nand.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 5216d2eb2289..14761eb01e56 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -1246,6 +1246,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; } -- 2.39.2