From patchwork Tue Aug 29 10:17:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Lothar_Wa=C3=9Fmann?= X-Patchwork-Id: 807025 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WUqZjBeY"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xhPkb1Wfgz9sNc for ; Tue, 29 Aug 2017 20:19:19 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pzsPaKA/xATTklG6rP3RmIT25XKF/lsKimUVGVds3lk=; b=WUqZjBeY2uP4AQ jB8SSf3HiVnCf6YgCHT6DGBwe+ZDT+zLzyTI+/SEiaVYg1+gQ5Nw4kUel5XWOq5HzmXIESLysRc+K c0uh8UKAj9SR598aLKhOCFBYlpM91VaieOD6g3pvYJ42u+APq1phfrrQmoZQwgt350sPnvgeNmI9L ROhRx4SV/DodWWwixUVObQ8ncsPadI54UHCdrvbyVKxosasGIe0z8QKwGQfvhOOob8o4XiMBswm66 ShKt7dVWgJolNB/bsfZBgGMEm9YVyFTOonNm+QSwDF8nARn+sUxUsItUdrggts6QRazdtZkHRVx2A YqgvZNYUZL0tc0+hFl0Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dmdc4-0002pb-4k; Tue, 29 Aug 2017 10:19:16 +0000 Received: from smtprelay03.ispgateway.de ([80.67.31.41]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dmdas-00025r-Ow for linux-mtd@lists.infradead.org; Tue, 29 Aug 2017 10:18:10 +0000 Received: from [89.1.81.74] (helo=ipc1.ka-ro) by smtprelay03.ispgateway.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) (envelope-from ) id 1dmdaV-00078f-Kb; Tue, 29 Aug 2017 12:17:39 +0200 Received: from lothar by ipc1.ka-ro with local (Exim 4.84_2 #2 (Debian)) id 1dmdaV-0004in-6d; Tue, 29 Aug 2017 12:17:39 +0200 From: =?utf-8?q?Lothar_Wa=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 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 X-Df-Sender: bHdAa2Fyby1lbGVjdHJvbmljcy5kZQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170829_031803_374299_87169E76 X-CRM114-Status: UNSURE ( 9.31 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [80.67.31.41 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [80.67.31.41 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Lothar_Wa=C3=9Fmann?= Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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; }