From patchwork Sun Oct 22 15:34:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 10021727 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9FE8460224 for ; Sun, 22 Oct 2017 15:34:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 884752871F for ; Sun, 22 Oct 2017 15:34:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79E342874F; Sun, 22 Oct 2017 15:34:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D60D28740 for ; Sun, 22 Oct 2017 15:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751436AbdJVPep (ORCPT ); Sun, 22 Oct 2017 11:34:45 -0400 Received: from mout.web.de ([217.72.192.78]:64586 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751416AbdJVPeo (ORCPT ); Sun, 22 Oct 2017 11:34:44 -0400 Received: from [192.168.1.2] ([77.182.45.221]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LsQLM-1d4NzT3uXY-011yF7; Sun, 22 Oct 2017 17:34:32 +0200 To: dmaengine@vger.kernel.org, Arvind Yadav , Dan Williams , Dave Jiang , Geliang Tang , Krister Johansen , Pan Bian , Vinod Koul Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Subject: [PATCH] dmaengine: ioat: Use common error handling code in ioat_xor_val_self_test() Message-ID: Date: Sun, 22 Oct 2017 17:34:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:4VBnAu5DCgrXuwJJp9KoM/syDECzOFITOwL6fx9Yez4EwP7JS3O 4uKZZr1EYU6p/9DYoSRv3yNyWPgqDJSMDh5NOYH6a3lAVMxMlyZMtdNV0bwAwFUxDne67rK bdgGLqSghkV6FX16MMKwUCZuqtghhGXARRu41CGArHMi3yfm4qJFTqloCNeATo1ekXqv/Xm gfvxDCNHhhJy7DkmfIUiw== X-UI-Out-Filterresults: notjunk:1; V01:K0:26vZEED9THs=:+lRN6mKy6D+Cvv6HhL7ew6 zIEMy/Oz9qh4fcFz7sky5k3HeqsoOzbZM8xGTeDkLDArYqij+scoQmC0mI31HxPp1FGs5RTB2 b6gIC+uiDnGlD8jSDitpglMIBlDDw1AdqzJfaUI3FzeILk7p8QcNv04xRemnFvhyJne3oH5SR 1g813dAVLc9UNqXSjtfsIuKa8xCbT1LQcaY1LKcsYJZEvWfDJByiik9R3KeiUxYUT42gok8ZW DQ5YkMCdjQf76/FJP+CJ3EzAee/F3bXuK+Ph5q/DzMNacLbGHjtgYAfa2xkdR8ZXy2BzEQBSd eutP5vTYBqNuRh5yXTUmjeUU6cxo9+bKVbnv9yEXp6V6xmrCu0moGN0we3aSo+ORthRrBoZc6 PePcrsn7PcFJCtoa+Y/WKGfNmdzg9+CoJTqh0uGZFxUMLH86KsFhzqxmLyrqEWvipiSwt/CFZ wt9XmDXxBWeWqFB0OVGbpqe5Yl3UkIBI+Ls5woNEdrTUTXfSrHjZizVanE4bVF7Lf75giXOfi NllWtlNKoDYZtl1Kf/6FbxESX4/T1/GoFcdL1FIGXWjjFgJ1+E5HNNAw7/Q8ECCNNrm+M/XLY M29Nf4M/koxyWClq67Mapz/LMoBlPI0R3z7lEEyRM+NBxS00Wb2SBggmSYnA+HdvMjDtFGbss CcIPLOLLtgBeOmGgAWntGFeDjzPjwHmf6xcFAd08aja61rcsBiMNpwjUmTFOddXYdZMDR7NZp ABQWcYkJGDn2UQUWsnOyY5o+rhmCyzFeJqlvZvf+T9nXQVIwYVDyq19nuCh6ZxuBe5wUCY4eF DeG70nF2MB2rg7WdlkoSv1nrPx+lkwqgs/DDmFORh52rpdBprE= Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 22 Oct 2017 17:25:09 +0200 Add a jump target so that a specific error code assignment will be in the implementation mostly at the end of this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/dma/ioat/init.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c index 93e006c3441d..5bdd67940c81 100644 --- a/drivers/dma/ioat/init.c +++ b/drivers/dma/ioat/init.c @@ -853,8 +853,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *ioat_dma) if (!tx) { dev_err(dev, "Self-test xor prep failed\n"); - err = -ENODEV; - goto dma_unmap; + goto failure_indication; } async_tx_ack(tx); @@ -864,8 +863,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *ioat_dma) cookie = tx->tx_submit(tx); if (cookie < 0) { dev_err(dev, "Self-test xor setup failed\n"); - err = -ENODEV; - goto dma_unmap; + goto failure_indication; } dma->device_issue_pending(dma_chan); @@ -874,8 +872,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *ioat_dma) if (tmo == 0 || dma->device_tx_status(dma_chan, cookie, NULL) != DMA_COMPLETE) { dev_err(dev, "Self-test xor timed out\n"); - err = -ENODEV; - goto dma_unmap; + goto failure_indication; } for (i = 0; i < IOAT_NUM_SRC_TEST; i++) @@ -921,8 +918,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *ioat_dma) &xor_val_result, DMA_PREP_INTERRUPT); if (!tx) { dev_err(dev, "Self-test zero prep failed\n"); - err = -ENODEV; - goto dma_unmap; + goto failure_indication; } async_tx_ack(tx); @@ -932,8 +928,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *ioat_dma) cookie = tx->tx_submit(tx); if (cookie < 0) { dev_err(dev, "Self-test zero setup failed\n"); - err = -ENODEV; - goto dma_unmap; + goto failure_indication; } dma->device_issue_pending(dma_chan); @@ -942,8 +937,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *ioat_dma) if (tmo == 0 || dma->device_tx_status(dma_chan, cookie, NULL) != DMA_COMPLETE) { dev_err(dev, "Self-test validate timed out\n"); - err = -ENODEV; - goto dma_unmap; + goto failure_indication; } for (i = 0; i < IOAT_NUM_SRC_TEST + 1; i++) @@ -974,8 +968,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *ioat_dma) &xor_val_result, DMA_PREP_INTERRUPT); if (!tx) { dev_err(dev, "Self-test 2nd zero prep failed\n"); - err = -ENODEV; - goto dma_unmap; + goto failure_indication; } async_tx_ack(tx); @@ -985,8 +978,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *ioat_dma) cookie = tx->tx_submit(tx); if (cookie < 0) { dev_err(dev, "Self-test 2nd zero setup failed\n"); - err = -ENODEV; - goto dma_unmap; + goto failure_indication; } dma->device_issue_pending(dma_chan); @@ -995,20 +987,20 @@ static int ioat_xor_val_self_test(struct ioatdma_device *ioat_dma) if (tmo == 0 || dma->device_tx_status(dma_chan, cookie, NULL) != DMA_COMPLETE) { dev_err(dev, "Self-test 2nd validate timed out\n"); - err = -ENODEV; - goto dma_unmap; + goto failure_indication; } if (xor_val_result != SUM_CHECK_P_RESULT) { dev_err(dev, "Self-test validate failed compare\n"); - err = -ENODEV; - goto dma_unmap; + goto failure_indication; } for (i = 0; i < IOAT_NUM_SRC_TEST + 1; i++) dma_unmap_page(dev, dma_srcs[i], PAGE_SIZE, DMA_TO_DEVICE); goto free_resources; +failure_indication: + err = -ENODEV; dma_unmap: if (op == IOAT_OP_XOR) { while (--i >= 0)