Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3309463imm; Mon, 6 Aug 2018 02:23:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdVnY7SV23bvwBZo6F1oNciiv2B6wMejAoCaUZhI4/+t9GsqLNSxL5fRxmMK8ZlN/Z5Fmpz X-Received: by 2002:a62:455b:: with SMTP id s88-v6mr16236416pfa.203.1533547434717; Mon, 06 Aug 2018 02:23:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533547434; cv=none; d=google.com; s=arc-20160816; b=u2G1BcEZH5Tp+osLqKqc+HihqU+JHmxdupp51IU9TCg66TZ4U9KajZp+U5doatodL7 GG7pYDBYw4ueORNUwgqiSlOAIj2bnC9eh9CGDJMJp/kfNqoctz67PDpfxtejqEqUdGTd MiFif7vqKPlvzHunOk8f0UZnCsQfLQLY63IMXOgegHCIda8YEM1hjoS1+Aq0tsyziLNu 0cvdgzAS0e8AKsFRovoWzlLGpg4JTUwuDiTz36Z/3kAa6yZ5kxvCuuHVrEbVLXPcIgkw TuvxZeQIZ4MGXBLkU7wQSUSzZBcOg9Sl5L2a7KzxMSynkx7yAi6oWvm478KynGHoWtql 6kPw== 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=QOecfqDelReb1uX8efYQtQnrXihaZ9WyseD7gT5D9yI=; b=0WqJq+ikCNDwXUbm2qfSpk97Q/A3OVuDxOa4mlvDeL2DTv9wK174e/vyortIxdDzI2 dkcQTK6XC6/pG4L00zCfungSo0BKmSAiqtTL+E4LM2fSjM76E8KzVy35w+Mmque25kpq +Szon9WuxEYxyjrA1eCK+7X8z5WgLkd2idOYDVKLmIdqm9GywhSvOKKIZw0jFYUlBD2q lSuPY01doRgKWxxnVkB+rrjDA+NwJ9PeAktCXxcpuUS6bZh+b8gYFcj7KO1wMwsV0wiP xK+Lft9yzHI3B3nS5AGiuu7y8ulO9dGaCKxuxZwxHLwBn4L9+jWonSi0+ZVpdzddm4MC ioHg== 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 c27-v6si12524428pgc.11.2018.08.06.02.23.39; Mon, 06 Aug 2018 02:23:54 -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 S1729703AbeHFLa0 (ORCPT + 99 others); Mon, 6 Aug 2018 07:30:26 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:44770 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729600AbeHFLaZ (ORCPT ); Mon, 6 Aug 2018 07:30:25 -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 1fmbiA-0002UC-25; Mon, 06 Aug 2018 11:21:58 +0200 From: Kurt Kanzenbach To: Boris Brezillon Cc: Miquel Raynal , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Masahiro Yamada , Kurt Kanzenbach , Gregory CLEMENT , Jane Wan , Jagdish Gediya , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mtd: nand: fsl-ifc: check result of SRAM initialization Date: Mon, 6 Aug 2018 11:21:36 +0200 Message-Id: <20180806092137.9287-2-kurt@linutronix.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180806092137.9287-1-kurt@linutronix.de> References: <20180806092137.9287-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 --- 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