Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2818822imm; Mon, 13 Aug 2018 00:37:47 -0700 (PDT) X-Google-Smtp-Source: AA+uWPy9FJDbF4POqz7B+zslRoudiJzL7EJYP9ki72upGny5lTslAu88Y8xflbyLt45ewu3yOnYl X-Received: by 2002:a17:902:82c7:: with SMTP id u7-v6mr15489843plz.83.1534145867315; Mon, 13 Aug 2018 00:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534145867; cv=none; d=google.com; s=arc-20160816; b=hhPAhRJZt45ePA61WT4cYj64ehGHXG24Sr4XRpXhbbUwTFBW6jzRvmvjUYtnTdcExz 4YYi3zrsLHP4S2qajKnXETJYF561L9rp/fE1eYkBrHxQamjJ6g5+rBxVE177m+NqIf5v 6tQC9tjGWkW+JHrHG6e8z9MqnVwLqHLVSUsALSduzbEuINPfa4e65xqTF4vXHU4ix5/m W78ZDWCvatc3UTihge7wJouNLe96/KVy7boaCBWrbuw1kpTzvrJU6Do6k78OdDgWzIUh QRtEEUbtphkYl6Req6w177E8qGtFLJfUT1O58FJ3vZwiXtlRxaC46CvA3xO2tAYzJmcw izPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=oUZFEjHIZ5iHuwgwIQBjNnTJ0Gl+h5Z8fTgktZWQHJA=; b=Lv0FjYdfrrS6hHIjTpZLuwCLKaVmbjjgxBgEZX+hMJjB+HYkMpwnNr+IirEP/XRLpZ v15d2S4AiyYZq4EVpYQtNotr0kFNcsE/twPoC8fLnWIDoyUkMfMCqde3nYmy+kI6fRN9 hwngOIZnT3a/k3f9EssoEfAwnyzv/o7ayUgBBdQQA/Qiyf4mWU9XOT073WfhuVyqy5pn Coiv/LqjyWiD2zlGxyGgKdWJy3jB6eebzGeFQ4jGFxF7bDM2Xqfpd/ImnBDLQNtSBNOa J4Bzl7N4+FOhOlJnqRujSES4EXikQl+kmHg/bDUDDxCJjni4T1aXPMY+9EQR+ouQVphx /sbQ== 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 y23-v6si16668676pgl.132.2018.08.13.00.37.32; Mon, 13 Aug 2018 00:37:47 -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 S1728508AbeHMKAh (ORCPT + 99 others); Mon, 13 Aug 2018 06:00:37 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:37225 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728474AbeHMKAh (ORCPT ); Mon, 13 Aug 2018 06:00:37 -0400 Received: from hsi-kbw-5-158-153-52.hsi19.kabel-badenwuerttemberg.de ([5.158.153.52] helo=kurt.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1fp78G-00012F-Bm; Mon, 13 Aug 2018 09:19:16 +0200 From: Kurt Kanzenbach To: Boris Brezillon , Miquel Raynal Cc: Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Kurt Kanzenbach , Masahiro Yamada , Wenyou Yang , Jagdish Gediya , Jane Wan , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] mtd: rawnand: fsl_ifc: check result of SRAM initialization Date: Mon, 13 Aug 2018 09:18:45 +0200 Message-Id: <20180813071846.9433-2-kurt@linutronix.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180813071846.9433-1-kurt@linutronix.de> References: <20180813071846.9433-1-kurt@linutronix.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The SRAM initialization might fail. If that happens further NAND operations won't be successful. Therefore, the chip init routine should fail if the SRAM initialization didn't work. Signed-off-by: Kurt Kanzenbach --- Changes since v1: - Subject drivers/mtd/nand/raw/fsl_ifc_nand.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/raw/fsl_ifc_nand.c b/drivers/mtd/nand/raw/fsl_ifc_nand.c index 24f59d0066af..e4f5792dc589 100644 --- a/drivers/mtd/nand/raw/fsl_ifc_nand.c +++ b/drivers/mtd/nand/raw/fsl_ifc_nand.c @@ -761,7 +761,7 @@ static const struct nand_controller_ops fsl_ifc_controller_ops = { .attach_chip = fsl_ifc_attach_chip, }; -static void fsl_ifc_sram_init(struct fsl_ifc_mtd *priv) +static int fsl_ifc_sram_init(struct fsl_ifc_mtd *priv) { struct fsl_ifc_ctrl *ctrl = priv->ctrl; struct fsl_ifc_runtime __iomem *ifc_runtime = ctrl->rregs; @@ -805,12 +805,16 @@ static void fsl_ifc_sram_init(struct fsl_ifc_mtd *priv) wait_event_timeout(ctrl->nand_wait, ctrl->nand_stat, msecs_to_jiffies(IFC_TIMEOUT_MSECS)); - if (ctrl->nand_stat != IFC_NAND_EVTER_STAT_OPC) + if (ctrl->nand_stat != IFC_NAND_EVTER_STAT_OPC) { pr_err("fsl-ifc: Failed to Initialise SRAM\n"); + return -ETIMEDOUT; + } /* Restore CSOR and CSOR_ext */ ifc_out32(csor, &ifc_global->csor_cs[cs].csor); ifc_out32(csor_ext, &ifc_global->csor_cs[cs].csor_ext); + + return 0; } static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) @@ -914,8 +918,13 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) chip->ecc.algo = NAND_ECC_HAMMING; } - if (ctrl->version >= FSL_IFC_VERSION_1_1_0) - fsl_ifc_sram_init(priv); + if (ctrl->version >= FSL_IFC_VERSION_1_1_0) { + int ret; + + ret = fsl_ifc_sram_init(priv); + if (ret) + return ret; + } /* * As IFC version 2.0.0 has 16KB of internal SRAM as compared to older -- 2.11.0