Skip to content

Commit

Permalink
mtd: nand: complain loudly when chip->bits_per_cell is not correctly …
Browse files Browse the repository at this point in the history
…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.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
  • Loading branch information
Lothar Waßmann authored and Boris Brezillon committed Aug 29, 2017
1 parent 69fc012 commit 2d2a2b8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/linux/mtd/rawnand.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 2d2a2b8

Please sign in to comment.