Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752186AbdH2K31 (ORCPT ); Tue, 29 Aug 2017 06:29:27 -0400 Received: from smtprelay03.ispgateway.de ([80.67.31.41]:11670 "EHLO smtprelay03.ispgateway.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751324AbdH2K30 (ORCPT ); Tue, 29 Aug 2017 06:29:26 -0400 X-Greylist: delayed 703 seconds by postgrey-1.27 at vger.kernel.org; Tue, 29 Aug 2017 06:29:25 EDT From: =?UTF-8?q?Lothar=20Wa=C3=9Fmann?= To: Boris Brezillon , Brian Norris , Cyrille Pitchen , David Woodhouse , Marek Vasut , Richard Weinberger , linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Cc: =?UTF-8?q?Lothar=20Wa=C3=9Fmann?= Subject: [PATCH 2/2] mtd: nand: complain loudly when chip->bits_per_cell is not correctly initialized Date: Tue, 29 Aug 2017 12:17:13 +0200 Message-Id: <1504001833-18097-3-git-send-email-LW@KARO-electronics.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504001833-18097-1-git-send-email-LW@KARO-electronics.de> References: <1504001833-18097-1-git-send-email-LW@KARO-electronics.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Df-Sender: bHdAa2Fyby1lbGVjdHJvbmljcy5kZQ== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 781 Lines: 25 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 --- include/linux/mtd/rawnand.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 94feece..2b05f42 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -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; } -- 2.1.4