Received: by 10.223.176.5 with SMTP id f5csp2954437wra; Mon, 29 Jan 2018 06:45:42 -0800 (PST) X-Google-Smtp-Source: AH8x224BIZrXnPBtWn8OKf9o9QEgJVyIRSMj0ta0lqwA0zKIFacxxqnIfO5W1kCYRnUb4prF//9y X-Received: by 10.99.6.14 with SMTP id 14mr21526803pgg.8.1517237142419; Mon, 29 Jan 2018 06:45:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517237142; cv=none; d=google.com; s=arc-20160816; b=OT2Q72IFokS5V+mDyRKzVlDY51IJhwh2qfXYGTRLWzLh/GJIGyqPcg060jdnUS15kA up9xdT8mPx5awd5vqcyMzivKrdFhzYCbtgTGOUt4nMAfzkUFaeqp0y+tclOrZaf1Z3Jd gpiFuRngtd9geluHUrmyFEWYdRdDFDjEaUFepJU0UMmr84j4DoTMBBqM3g0siRWlJJ08 Uk2Zn3BqawXN+QocBzC48ECPAjTR30uD2PPuGZ78SIJSWFudiLDSPhLD6OyafywjiLJ2 X7nGfYZZT3mT2arqIr9dyS6h6kYcOw2soFZatfVV5yWFSCunlH5isl3gDGZhgm6h+Kff mQZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:message-id:date:subject:cc :to:from:arc-authentication-results; bh=EqfdzPkz+cZqxLwzvnRfcO+uPx/AO4StXBBoXcFZMXI=; b=XkxHHBDkPNkV2Tr9l8BHvU2QAG/+IAtJNOPl7+U/YjxaeZdf56BGI3Vbb/cw3FkObn wWT8OOipqiJHVlMQ6sesc9M8aDeI3zCvsz1wqnYp/kVhQ3hf1hcudlMhhD8W7KQRUKch S2nLsgAIdarvTwiQBH2tRfe2A3XlsCUAsENshZJ1lIgRcL2YQdU3lMzv9URro1udOO4D 5vrpVdoAAVrYxxdyjtlTOol3mtQEgQuIrcZG/DGs4Vs677J/ayYBy8syadnUvnuDV6kx NpyjdrqQHDgxm3AMNnPJnHayTXckYSS9ycvdzH53zd6iOtR9NySl5rO/y6b+LuVa4dzr dWIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=cXpmeifK; 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 p85si17897pfd.218.2018.01.29.06.45.27; Mon, 29 Jan 2018 06:45:42 -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=@agner.ch header.s=dkim header.b=cXpmeifK; 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 S1751981AbeA2Oor (ORCPT + 99 others); Mon, 29 Jan 2018 09:44:47 -0500 Received: from mail.kmu-office.ch ([178.209.48.109]:52732 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751337AbeA2Ooq (ORCPT ); Mon, 29 Jan 2018 09:44:46 -0500 Received: from trochilidae.toradex.int (unknown [46.140.72.82]) by mail.kmu-office.ch (Postfix) with ESMTPSA id C2F8E5C37E6; Mon, 29 Jan 2018 15:37:34 +0100 (CET) From: Stefan Agner To: han.xu@nxp.com, boris.brezillon@free-electrons.com Cc: marek.vasut@gmail.com, richard@nod.at, dwmw2@infradead.org, cyrille.pitchen@wedev4u.fr, max.oss.09@gmail.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Stefan Agner Subject: [PATCH] mtd: nand: gpmi: fall back to legacy mode if no ECC information present Date: Mon, 29 Jan 2018 15:44:40 +0100 Message-Id: <20180129144440.13648-1-stefan@agner.ch> X-Mailer: git-send-email 2.16.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1517236655; bh=EqfdzPkz+cZqxLwzvnRfcO+uPx/AO4StXBBoXcFZMXI=; h=From:To:Cc:Subject:Date:Message-Id; b=cXpmeifKOklowxVb5RRKcNw+OLpR0xpmj7t8HE7LsgYnlSUs1S0WqOtAj+B8vSSDLUVLsI+SRX8Y0U7Zh5X61eJmk2is0jLQGaDCn9sdf3Jdf/V3CcWz31zjOMtCD/2VoXYA6E4kquKIpaI4XVLXwIqukk4/SlHNnAla+RJs1HI= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case fsl,use-minimum-ecc is set, the driver tries to determine ECC layout by using the ECC information provided by the MTD stack. However, in case the NAND chip does not provide any information, the driver currently fails with: nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1 nand: Macronix NAND 128MiB 3,3V 8-bit nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 gpmi-nand 1806000.gpmi-nand: Error setting BCH geometry : 1 gpmi-nand: probe of 1806000.gpmi-nand failed with error 1 Fall back to implementation specific default mode if no ECC information are provided by the NAND chip and fsl,use-minimum-ecc is specified. This is more in line with what the device tree binding documentation promises: "However, note that if this strength is not discoverable or this property is not enabled, the software may chooses an implementation-defined ECC scheme." Signed-off-by: Stefan Agner --- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c index 50f8d4a1b983..7b8e8c629081 100644 --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c @@ -206,7 +206,7 @@ static int set_geometry_by_ecc_info(struct gpmi_nand_data *this) unsigned int block_mark_bit_offset; if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0)) - return -EINVAL; + return -ENOTSUPP; switch (chip->ecc_step_ds) { case SZ_512: @@ -423,11 +423,15 @@ static int legacy_set_geometry(struct gpmi_nand_data *this) int common_nfc_set_geometry(struct gpmi_nand_data *this) { - if ((of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc")) - || legacy_set_geometry(this)) - return set_geometry_by_ecc_info(this); + int ret = -ENOTSUPP; - return 0; + if (of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc")) + ret = set_geometry_by_ecc_info(this); + + if (ret == -ENOTSUPP) + return legacy_set_geometry(this); + + return ret; } struct dma_chan *get_dma_chan(struct gpmi_nand_data *this) -- 2.16.1