From patchwork Sun Dec 29 22:47:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 305684 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DD4D2C00B6 for ; Mon, 30 Dec 2013 09:08:55 +1100 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VxOXK-0007O1-1R; Sun, 29 Dec 2013 22:08:42 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VxOXI-0005Ow-Bs; Sun, 29 Dec 2013 22:08:40 +0000 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VxOXG-0005Oc-0L for linux-mtd@lists.infradead.org; Sun, 29 Dec 2013 22:08:38 +0000 X-IronPort-AV: E=Sophos;i="4.95,570,1384297200"; d="scan'208";a="50832538" Received: from palace.lip6.fr (HELO localhost.localdomain) ([132.227.105.202]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 29 Dec 2013 22:51:35 +0100 From: Julia Lawall To: David Woodhouse Subject: [PATCH 18/25] mtd: nand: fix error return code Date: Sun, 29 Dec 2013 23:47:33 +0100 Message-Id: <1388357260-4843-19-git-send-email-Julia.Lawall@lip6.fr> X-Mailer: git-send-email 1.7.8.6 In-Reply-To: <1388357260-4843-1-git-send-email-Julia.Lawall@lip6.fr> References: <1388357260-4843-1-git-send-email-Julia.Lawall@lip6.fr> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131229_170838_291705_759207E7 X-CRM114-Status: GOOD ( 10.14 ) X-Spam-Score: -6.1 (------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-6.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [192.134.164.83 listed in list.dnswl.org] 0.8 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-mtd@lists.infradead.org, Brian Norris , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Julia Lawall Set the return variable to an error code as done elsewhere in the function. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // ( if@p1 (\(ret < 0\|ret != 0\)) { ... return ret; } | ret@p1 = 0 ) ... when != ret = e1 when != &ret *if(...) { ... when != ret = e2 when forall return ret; } // Signed-off-by: Julia Lawall --- Not tested. drivers/mtd/nand/fsmc_nand.c | 3 +++ drivers/mtd/tests/oobtest.c | 1 + drivers/mtd/tests/pagetest.c | 1 + drivers/mtd/tests/subpagetest.c | 1 + 4 files changed, 6 insertions(+) diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c index 8b27522..6f8c4f5 100644 --- a/drivers/mtd/nand/fsmc_nand.c +++ b/drivers/mtd/nand/fsmc_nand.c @@ -1040,12 +1040,15 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) pdata->read_dma_priv); if (!host->read_dma_chan) { dev_err(&pdev->dev, "Unable to get read dma channel\n"); + ret = -EBUSY; goto err_req_read_chnl; } host->write_dma_chan = dma_request_channel(mask, filter, pdata->write_dma_priv); if (!host->write_dma_chan) { dev_err(&pdev->dev, "Unable to get write dma channel\n"); + + ret = -EBUSY; goto err_req_write_chnl; } nand->read_buf = fsmc_read_buf_dma; diff --git a/drivers/mtd/tests/oobtest.c b/drivers/mtd/tests/oobtest.c index 2e9e2d1..26688e9 100644 --- a/drivers/mtd/tests/oobtest.c +++ b/drivers/mtd/tests/oobtest.c @@ -291,6 +291,7 @@ static int __init mtd_oobtest_init(void) if (!mtd_type_is_nand(mtd)) { pr_info("this test requires NAND flash\n"); + err = -ENODEV; goto out; } diff --git a/drivers/mtd/tests/pagetest.c b/drivers/mtd/tests/pagetest.c index ed2d3f6..9a84460 100644 --- a/drivers/mtd/tests/pagetest.c +++ b/drivers/mtd/tests/pagetest.c @@ -355,6 +355,7 @@ static int __init mtd_pagetest_init(void) if (!mtd_type_is_nand(mtd)) { pr_info("this test requires NAND flash\n"); + err = -ENODEV; goto out; } diff --git a/drivers/mtd/tests/subpagetest.c b/drivers/mtd/tests/subpagetest.c index a876371..2baa93d 100644 --- a/drivers/mtd/tests/subpagetest.c +++ b/drivers/mtd/tests/subpagetest.c @@ -301,6 +301,7 @@ static int __init mtd_subpagetest_init(void) if (!mtd_type_is_nand(mtd)) { pr_info("this test requires NAND flash\n"); + err = -ENODEV; goto out; }