Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5600347imm; Mon, 27 Aug 2018 00:25:14 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZd+abcjRvmhBVC6i6Q4s+q0KcB6ypseZ9H4/x+N5q+uhBdjVusyaIxKCZD9LJq4Z34E3Ix X-Received: by 2002:a17:902:8ec7:: with SMTP id x7-v6mr12167908plo.336.1535354714008; Mon, 27 Aug 2018 00:25:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535354713; cv=none; d=google.com; s=arc-20160816; b=xTIEKLDXaDdG4RNUnh2r6yEn+QFkfn7QPH+9aybgvSX1fZqs7IvdXHzeoqWTdpkrpk EoQzqyRuH/itKhv3o8EYFcFOLWzPay2U5JJkdS2tq99Ftaz9y5CWn7RjnhO2X7/UQspe I8u9H+f2pNE6i8Ol/Ls2kORlFBrwtxrY1l0mR1WdE3RYzbZC2lWrcIZFA7xb6MfAcJvg tR7Y6RQWa4dmq5F5/fwvX3wUDXKBclHh0PKlJSlsovCRELbrn+sAQqKeAeKCjI59KaxR x+b7MXUnHJuRMruGpFS00J+SKt3tGsN61X7hMGUsjb8CqHupwYI69RIxoDrO5wUcB+qi bExQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=e4OIdULGJjNq5EYQJjbwiHoQ7ER/nTYzWEz0FIXdOPs=; b=HWbgcSGKMXfwo1KekmAdj9XlPIlzQ+qFlES7mRz09sEidKYQiUTx7KniJkj3HjNLCY /x+eyLrIJxPF4ydEJsUPCpEV1P/8vLzfkvQ/T9G/eO0oF9VVkmWEqqSEikDAr0KcOSnv 3w3kcriPGzTGwjCkdmfaQuKsIJdZcn2FHzMvbYD33IK+pSy6JZeDEgA8e1GBfetsgnSo cgsyOJyg5cutp+sdTbRNjOR9mWUYZ8rIDAHDbgqYzyj8vns1t1eLvVT7YByJsW6Uq9TE Mn+drPcPMnH7LHDW9Nt/M204EzMku9VTcapVeJBKJMn3D92ZNG40PlZ0QD/RbZ5jpvBS KiIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l1-v6si13349987pld.184.2018.08.27.00.24.58; Mon, 27 Aug 2018 00:25:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727144AbeH0LJS (ORCPT + 99 others); Mon, 27 Aug 2018 07:09:18 -0400 Received: from mail.bootlin.com ([62.4.15.54]:58284 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726882AbeH0LJS (ORCPT ); Mon, 27 Aug 2018 07:09:18 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 5C99120795; Mon, 27 Aug 2018 09:23:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (AAubervilliers-681-1-53-19.w90-88.abo.wanadoo.fr [90.88.170.19]) by mail.bootlin.com (Postfix) with ESMTPSA id 1CCD2206DE; Mon, 27 Aug 2018 09:23:43 +0200 (CEST) Date: Mon, 27 Aug 2018 09:23:41 +0200 From: Boris Brezillon To: Masahiro Yamada Cc: linux-mtd@lists.infradead.org, Miquel Raynal , linux-kernel@vger.kernel.org, Marek Vasut , Brian Norris , Richard Weinberger , David Woodhouse Subject: Re: [PATCH v2] mtd: rawnand: denali: do not pass zero maxchips to nand_scan() Message-ID: <20180827092341.1385ea7d@bbrezillon> In-Reply-To: <1535353301-1727-1-git-send-email-yamada.masahiro@socionext.com> References: <1535353301-1727-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 27 Aug 2018 16:01:41 +0900 Masahiro Yamada wrote: > Commit 49aa76b16676 ("mtd: rawnand: do not execute nand_scan_ident() > if maxchips is zero") gave a new meaning for calling nand_scan_ident() > with maxchips=0. > > It is a special usage for some drivers such as docg4, but actually > the Denali driver may pass maxchips=0 to nand_scan() when the driver > is enabled but no NAND chip is found on the board for some reasons. > > If nand_scan_with_ids() is called with maxchips=0, nand_scan_ident() > is skipped, then nand_set_defaults() is skipped as well. Thus, the > driver must set chip->controller beforehand. Otherwise, nand_attach() > causes NULL pointer dereference. > > In fact, the Denali controller knows the number of connected chips > before calling nand_scan_ident(); if DEVICE_RESET fails, there is no > chip in that chip select. Then, denali_reset_banks() sets the maxchips > to the number of detected chips. If no chip is found, maxchips is zero. > > In this case, there is no point for calling nand_scan() because we know > it will fail for sure. Let's make the probe function fail immediately. > > Signed-off-by: Masahiro Yamada Looks good to me. I'm waiting for Miquel's ack and I'll queue it to mtd/fixes. Thanks, Boris