Received: by 10.192.165.148 with SMTP id m20csp1780532imm; Thu, 3 May 2018 05:25:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr5egbQRYSf+YKPLysrAemlyYq9TXN8cG6wguB5pp8PbfEwXhjGCqOjRGVqjVKPT4uiW81Q X-Received: by 2002:a63:91c4:: with SMTP id l187-v6mr19036998pge.261.1525350328846; Thu, 03 May 2018 05:25:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525350328; cv=none; d=google.com; s=arc-20160816; b=LIKQqzfuGRkA5DLvJ78wOEsYwD9+qYkH3nkzJDnUwcLUuCGD3nUSG6IoRSXMZTwZEg GQsZInkirVgB0JQmv5YToC6aUNMwN7en7lDwb6mccOy08Cl+vMPDNlv81PdE1SXucMEN P8BSMPMfKstlcxwTXOplECCSdQawV6MIKkWYX0LQ2Y2BcpCgSoFCJr9qd838PYNZgsVq 8FUbDmTq2/obnAEWVfYzGUkOfbX3cfxScm5bszRAn5sXO5VC9wANQ10o8xuVYRFS8WUV LCjkwkaE394Fb7s4P7aEkDflR/gwBrzSqUeU8EGDwpFv0d3K7EcVraR73vl1jlNJETxx dbfg== 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:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=s6++cywB36zCK2ogZGDaTj5ELOZS7LeBEPWzsmXxnds=; b=hn0pN2XxqHwZ3xCQFQ63YUT8s+bgRl5LY0NOZ0V3LVatD/EhyXUAifRh8kkdl2A9Pq FwX0nKDPTOuG3IcSEYZdQFTn2HGtDmI7r6bMkSdK97nhA77TyFyRN0RsooFD8sTyjPg5 Nswpo5hNjDPs8qO4ZJRehNGgta/uSlPKm8zS+4Fpa0gf0QWF1BMp2N1IOL9xBbh3hsLk j6jDarbTMPyhG3yml93B+6QuFmtVvwrhgIzTGZIjhaohGSR/yvVhbR5Jt3lt8+BEIbGu NmRuGr/eHAmcVA1EosJCe6rW/HQgzSpSlGEy6PjoQhGLxoGI61Yae9d6Bqxj9gRI6UHt JGZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=NzVxyrhe; dkim=pass header.i=@codeaurora.org header.s=default header.b=FuXb3f9c; 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 k65si14076752pfg.38.2018.05.03.05.25.14; Thu, 03 May 2018 05:25:28 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=NzVxyrhe; dkim=pass header.i=@codeaurora.org header.s=default header.b=FuXb3f9c; 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 S1752235AbeECMY2 (ORCPT + 99 others); Thu, 3 May 2018 08:24:28 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:42316 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751342AbeECMVb (ORCPT ); Thu, 3 May 2018 08:21:31 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6950960C66; Thu, 3 May 2018 12:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525350091; bh=oCoDcGcQlZTC5XWDOx98OMLYgFLVhjxtdFp5pRvxULw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NzVxyrheLdYM6M0ssM4cpoTwS4ncB24vH53UQRTqUMsS6RdrAE+GHuxQ5uJuDhZvN LEEHzJCCQZH+mAH8EAnWBmCp2su59Pw+c36rLgIVb8dwySuJbBfPF+gVmVQj/1SNvt 8GjNrnioQUViqsKdtnxzNUqCzRJw4egQCriJSspk= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from absahu-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: absahu@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 85AFE60AF9; Thu, 3 May 2018 12:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525350090; bh=oCoDcGcQlZTC5XWDOx98OMLYgFLVhjxtdFp5pRvxULw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FuXb3f9c/6Qt16BKGzdldDwQyf4CIPMGuKU9DXm6xUG+JdsaaIyfE1lvBEmx0ikYX MVs/XUVAz7hc3xg1V1Yh+mN5syd4wt37F0zleAZA3MUQ3BBL+UiY5xSNjTCBXdzC+E aoCKTuMoJ10naDAQuZovHkodU/pQRhQmwSwGxGAE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 85AFE60AF9 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=absahu@codeaurora.org From: Abhishek Sahu To: Boris Brezillon Cc: David Woodhouse , Brian Norris , Marek Vasut , Richard Weinberger , Miquel Raynal , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Andy Gross , Archit Taneja , Abhishek Sahu Subject: [PATCH v2 08/14] mtd: rawnand: qcom: parse read errors for read oob also Date: Thu, 3 May 2018 17:50:35 +0530 Message-Id: <1525350041-22995-9-git-send-email-absahu@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1525350041-22995-1-git-send-email-absahu@codeaurora.org> References: <1525350041-22995-1-git-send-email-absahu@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org read_page and read_oob both calls the read_page_ecc function. The QCOM NAND controller protect the OOB available bytes with ECC so read errors should be checked for read_oob also. Now this patch moves the error checking code inside read_page_ecc so caller does not have to check explicitly for read errors. Signed-off-by: Abhishek Sahu Reviewed-by: Miquel Raynal --- * Changes from v1: 1. Minor code change for return early in case of error drivers/mtd/nand/raw/qcom_nandc.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c index fa38142..61d0e7d 100644 --- a/drivers/mtd/nand/raw/qcom_nandc.c +++ b/drivers/mtd/nand/raw/qcom_nandc.c @@ -1700,6 +1700,7 @@ static int read_page_ecc(struct qcom_nand_host *host, u8 *data_buf, struct nand_chip *chip = &host->chip; struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); struct nand_ecc_ctrl *ecc = &chip->ecc; + u8 *data_buf_start = data_buf, *oob_buf_start = oob_buf; int i, ret; config_nand_page_read(nandc); @@ -1760,12 +1761,14 @@ static int read_page_ecc(struct qcom_nand_host *host, u8 *data_buf, } ret = submit_descs(nandc); - if (ret) + free_descs(nandc); + + if (ret) { dev_err(nandc->dev, "failure to read page/oob\n"); + return ret; + } - free_descs(nandc); - - return ret; + return parse_read_errors(host, data_buf_start, oob_buf_start); } /* @@ -1810,20 +1813,14 @@ static int qcom_nandc_read_page(struct mtd_info *mtd, struct nand_chip *chip, struct qcom_nand_host *host = to_qcom_nand_host(chip); struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); u8 *data_buf, *oob_buf = NULL; - int ret; nand_read_page_op(chip, page, 0, NULL, 0); data_buf = buf; oob_buf = oob_required ? chip->oob_poi : NULL; clear_bam_transaction(nandc); - ret = read_page_ecc(host, data_buf, oob_buf); - if (ret) { - dev_err(nandc->dev, "failure to read page\n"); - return ret; - } - return parse_read_errors(host, data_buf, oob_buf); + return read_page_ecc(host, data_buf, oob_buf); } /* implements ecc->read_page_raw() */ @@ -1913,7 +1910,6 @@ static int qcom_nandc_read_oob(struct mtd_info *mtd, struct nand_chip *chip, struct qcom_nand_host *host = to_qcom_nand_host(chip); struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); struct nand_ecc_ctrl *ecc = &chip->ecc; - int ret; clear_read_regs(nandc); clear_bam_transaction(nandc); @@ -1922,11 +1918,7 @@ static int qcom_nandc_read_oob(struct mtd_info *mtd, struct nand_chip *chip, set_address(host, 0, page); update_rw_regs(host, ecc->steps, true); - ret = read_page_ecc(host, NULL, chip->oob_poi); - if (ret) - dev_err(nandc->dev, "failure to read oob\n"); - - return ret; + return read_page_ecc(host, NULL, chip->oob_poi); } /* implements ecc->write_page() */ -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation