Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6553774imu; Mon, 21 Jan 2019 10:56:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN5IjcdlmbovZf2CiPKMfoyIQAEzyqZKw1ujhyCOPX5TPbBauyDj7RcLOwlnBMuFSOHhqrGW X-Received: by 2002:a63:d450:: with SMTP id i16mr28796599pgj.246.1548096988349; Mon, 21 Jan 2019 10:56:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548096988; cv=none; d=google.com; s=arc-20160816; b=xEq90G09IXqX+J0M4fd7PBlAcQf8ily1lEyvYW/4uNUt/BbE4RsKndnaVlGtNEPc5A PGFv+qiDhdJKmEzb3NW2HjJJqHpYcF8gXCzY3UCxpgBemr9bW8bhF9oi48fULcipo7q+ 2b5CHcNGHSzKRyZ5u1E7j2aoa4hnz6az2DHpIXJs1tBeX0At57xQp9Hl4tFkokIG/fIL CbpFLe2IRdX+HXa+Le0VURSaEJkawu1+HHFAOpiNcW+flA4u4Pva4EnPN0olTIA7J3IP GQ+Q5z5AY8BSMoIPMvV7h5m8lEz1GZbRkKRy/N8azYgIIoKz49i3wEzuUhOAYON8z2K3 +o5Q== 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 :dkim-signature; bh=H5wDacrnOv1vKPjdMmHcdpNNsiVa3Ni/AojZb/rxUM8=; b=L8mh3JZ+zDgENs4dV3E9CQQNfaHdS2kAxou/BTz2U2tqF+q/hNYFueBx8+mbGYBmeJ SquEieHTz0EU+mxQY7eYeCEuWIaUkTkUp5TpXTx3KQCif+gnP03mtUQs7d42aTA7IMF9 DwLVakt2tYg83V5H9DkAgbiYqWAeodPW7jQ6ZRjBSVyiFakWRG7MRNIhkATAyOStvIsp OTvpKZbSWjDQ48uJGAw3ApfsbEB3wKWeyRBm7SP0TlwZn0xsv/9CeK7QWaRrYwolspl6 yB0XEacT+UlW/2XrJPKAJIS2lK6SJ769SQwsu9zW3aneEk1jYeKE7/PsUHCDvtJL+gYC WrBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qpIyXnjt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t77si10781pgb.51.2019.01.21.10.56.12; Mon, 21 Jan 2019 10:56:28 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=qpIyXnjt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728239AbfAUSyG (ORCPT + 99 others); Mon, 21 Jan 2019 13:54:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:52344 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726575AbfAUSyG (ORCPT ); Mon, 21 Jan 2019 13:54:06 -0500 Received: from bbrezillon (91-160-177-164.subs.proxad.net [91.160.177.164]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3117C20861; Mon, 21 Jan 2019 18:54:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548096845; bh=hq+FdVIPwR3zOZB3uDNDr9SstA4vB1P6EsPzIIFlyPE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qpIyXnjtokVHLfibtrZIn4JYHUK+5nJ3SncSX+DtnA92E6HIUP+7pwaxeZNagpz+b APZVWwkNufJywCcbKgRkcfbeTWJatblH7dVtU4znfOdcGQH+EaDH/smYLB7WrPSP/w PFjkNHRmXOl8PXicW5whoRqsxI/ZWoP+ErGzqcYg= Date: Mon, 21 Jan 2019 19:53:54 +0100 From: Boris Brezillon To: Masahiro Yamada Cc: Marek Vasut , Richard Weinberger , Linux Kernel Mailing List , Boris Brezillon , linux-mtd , Miquel Raynal , Brian Norris , David Woodhouse Subject: Re: [PATCH] mtd: rawnand: check return code of nand_reset() and nand_readid_op() Message-ID: <20190121195354.788199f5@bbrezillon> In-Reply-To: References: <1548075934-19963-1-git-send-email-yamada.masahiro@socionext.com> <20190121141403.20f6107b@bbrezillon> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; 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 Tue, 22 Jan 2019 00:57:43 +0900 Masahiro Yamada wrote: > > Maybe, is the following better? Sounds good, even if the original commit message was fine too. I was just pointing out that nand_scan() should, when possible, be passed the real number of CS lines connected to the chip instead of the max number of CS lines supported by the controller. > > > ------------------>8----------------------- > nand_scan_ident() iterates over maxchips to find as many homogeneous > chips as possible. > > Since commit 2d472aba15ff ("mtd: nand: document the NAND controller/NAND > chip DT representation"), new drivers should pass in the exact number of > CS lines instead of possible max, but old platforms may still rely on > nand_scan_ident() to detect the actual number of connected CS lines. > > In that case, this loop bails out when manufacturer or device ID > unmatches. The reason of unmatch is most likely no chip is connected > to that CS line. If so, nand_reset() should already have failed, > and the following nand_readid_op() is pointless. > > Before ->exec_op hook was introduced, drivers had no way to tell > the failure of NAND_CMD_RESET to the framework because the legacy > ->cmdfunc() has void return type. Now drivers implementing ->exec_op > hook can return the error code. You can save nand_readid_op() by > checking the return value of nand_reset(). The return value of > nand_readid_op() should be checked as well. If it fails, probably > id[0] and id[1] are undefined values. > > Just for consistency, it should be sensible to check the return > code in nand_do_write_oob() as well.