Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1739537imm; Sat, 9 Jun 2018 00:19:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKSr+rcNnLTCxZKSmj76CcGtE8mUEzXTMj/pOcEndmNr+vZ1z1oEsorEX8vO0qgqejzKIfS X-Received: by 2002:a62:da59:: with SMTP id w25-v6mr9124428pfl.161.1528528761167; Sat, 09 Jun 2018 00:19:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528528761; cv=none; d=google.com; s=arc-20160816; b=h3mFo19fMsnXBLxUAenjEPIjzRNPQV51XaQxQjxLnQNWo6r0FhvFSM7k9+cXQ6qQqz W+pr00Bw/eYN9LrPmzdnUZh6Xs1sXhU9srnfB7r/PQciKLWXCilX5cEPOMLZ8ZCrCvX1 b6kMmSeCHmfHDs1nIJPbE4xlzMk+UL08H9WJnqxI77Pq1pqr0nc5VTl2Gi61/9m9Ih7E IxJHnK+yv8mii0bYa6EwKAxYvtXFlumU5Sh9oudSanO1el09XzU8fDlqD0G8HJsTO1a+ DQ19D2V0x8K+IGPLHinPIvtbaBMtFswXVdimyH0LCOsaLjSsg4N4ueVNzogd6AicSrDX Hj5g== 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=rkale4dDVL94shhMn0VYxPkAXHpATaCRJ28nHZIyO28=; b=07mqDrjE9LYk/eAQbwBxpnNHAZsj/qsZguvEsCQKgEfjDWBlE/V+hvODuMLYMGkW9F 7GcbwlyLscWMVyXvejr3qYnEjM5KSEDYIOQHah2COxMtKkZsICPgdUTmU6JH6lT/44bS 9r9ehgZai/LEZ9qOLB6RtKl0U+VpR12h2NyPEYSl3+E0sLm0b3sNcno92D4WQCB2Ozyq eZVtSw6rOqcJgDV1Dsu5pI6Xkhv4wHfGtaOGxtASzkaz7S5eXJFyNGKTQUxQZ2GIqnLF L6dPhgo66kxb+Tqt8nNWoRoER9lQVA/K8fsRj+boGeFYkuv0FdyR+dPGk/ykjWwJZFX9 k4Iw== 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 i186-v6si11210573pfb.90.2018.06.09.00.19.06; Sat, 09 Jun 2018 00:19:21 -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 S1753190AbeFIHSi (ORCPT + 99 others); Sat, 9 Jun 2018 03:18:38 -0400 Received: from mail.bootlin.com ([62.4.15.54]:50875 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753019AbeFIHSg (ORCPT ); Sat, 9 Jun 2018 03:18:36 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 4D16A207C0; Sat, 9 Jun 2018 09:18:34 +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 (91-160-177-164.subs.proxad.net [91.160.177.164]) by mail.bootlin.com (Postfix) with ESMTPSA id BD53C20702; Sat, 9 Jun 2018 09:18:33 +0200 (CEST) Date: Sat, 9 Jun 2018 09:18:33 +0200 From: Boris Brezillon To: Stefan Agner Cc: dwmw2@infradead.org, computersforpeace@gmail.com, marek.vasut@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com, thierry.reding@gmail.com, dev@lynxeye.de, miquel.raynal@bootlin.com, richard@nod.at, marcel@ziswiler.com, krzk@kernel.org, digetx@gmail.com, benjamin.lindqvist@endian.se, jonathanh@nvidia.com, pdeschrijver@nvidia.com, pgaikwad@nvidia.com, mirza.krak@gmail.com, linux-mtd@lists.infradead.org, linux-tegra@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 4/6] mtd: rawnand: add NVIDIA Tegra NAND Flash controller driver Message-ID: <20180609091833.1a20db07@bbrezillon> In-Reply-To: <20180531221637.6017-5-stefan@agner.ch> References: <20180531221637.6017-1-stefan@agner.ch> <20180531221637.6017-5-stefan@agner.ch> 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 Fri, 1 Jun 2018 00:16:35 +0200 Stefan Agner wrote: > + > +static int tegra_nand_chips_init(struct device *dev, > + struct tegra_nand_controller *ctrl) > +{ > + struct device_node *np = dev->of_node; > + struct device_node *np_nand; > + int nchips = of_get_child_count(np); > + struct tegra_nand_chip *nand; > + struct mtd_info *mtd; > + struct nand_chip *chip; > + unsigned long config, bch_config = 0; > + int bits_per_step; > + int ret; > + > + if (nchips != 1) { > + dev_err(dev, "Currently only one NAND chip supported\n"); > + return -EINVAL; > + } > + > + np_nand = of_get_next_child(np, NULL); > + > + nand = devm_kzalloc(dev, sizeof(*nand), GFP_KERNEL); > + if (!nand) > + return -ENOMEM; > + > + nand->wp_gpio = devm_gpiod_get_optional(dev, "wp", GPIOD_OUT_LOW); > + > + if (IS_ERR(nand->wp_gpio)) { > + ret = PTR_ERR(nand->wp_gpio); > + dev_err(dev, "Failed to request WP GPIO: %d\n", ret); > + return ret; > + } > + You should retrieve the value of reg and store it somewhere in tegra_nand_chip. ->select_chip() is passed a chip_CE id, and it has to be converted into a ctrl_CE id. Right now you're assuming that ctrl_CE0 always drives chip_CE0, but that's not necessarily the case. Also, you don't support multi-CE chips, so you should check the number of entries in reg and fail if it's not 1.