From patchwork Tue Apr 15 13:10:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 3992831 X-Patchwork-Delegate: vinod.koul@intel.com Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0DF43BFF02 for ; Tue, 15 Apr 2014 13:10:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 557F5201B4 for ; Tue, 15 Apr 2014 13:10:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 14ECA20253 for ; Tue, 15 Apr 2014 13:10:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752149AbaDONKt (ORCPT ); Tue, 15 Apr 2014 09:10:49 -0400 Received: from mga11.intel.com ([192.55.52.93]:40242 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751094AbaDONKr (ORCPT ); Tue, 15 Apr 2014 09:10:47 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 15 Apr 2014 06:10:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,864,1389772800"; d="scan'208";a="520910608" Received: from smile.fi.intel.com ([10.237.72.73]) by fmsmga002.fm.intel.com with ESMTP; 15 Apr 2014 06:10:07 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.82) (envelope-from ) id 1Wa37m-0001XR-Kk; Tue, 15 Apr 2014 16:10:06 +0300 From: Andy Shevchenko To: Dan Williams , dmaengine@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH 2/3] dmatest: move src_off, dst_off, len inside loop Date: Tue, 15 Apr 2014 16:10:04 +0300 Message-Id: <1397567405-5863-2-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1397567405-5863-1-git-send-email-andriy.shevchenko@linux.intel.com> References: <1397567405-5863-1-git-send-email-andriy.shevchenko@linux.intel.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The scope of those varsiables is in while-loop. This patch moves them there and removes duplicate code. Signed-off-by: Andy Shevchenko --- drivers/dma/dmatest.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index 877468b..0593baa 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -405,7 +405,6 @@ static int dmatest_func(void *data) struct dmatest_params *params; struct dma_chan *chan; struct dma_device *dev; - unsigned int src_off, dst_off, len; unsigned int error_count; unsigned int failed_tests = 0; unsigned int total_tests = 0; @@ -484,6 +483,7 @@ static int dmatest_func(void *data) struct dmaengine_unmap_data *um; dma_addr_t srcs[src_cnt]; dma_addr_t *dsts; + unsigned int src_off, dst_off, len; u8 align = 0; total_tests++; @@ -502,15 +502,18 @@ static int dmatest_func(void *data) break; } + len = params->noverify ? params->buf_size : + dmatest_random() % params->buf_size + 1; + + len = (len >> align) << align; + if (!len) + len = 1 << align; + total_len += len; + if (params->noverify) { - len = params->buf_size; src_off = 0; dst_off = 0; } else { - len = dmatest_random() % params->buf_size + 1; - len = (len >> align) << align; - if (!len) - len = 1 << align; src_off = dmatest_random() % (params->buf_size - len + 1); dst_off = dmatest_random() % (params->buf_size - len + 1); @@ -523,11 +526,6 @@ static int dmatest_func(void *data) params->buf_size); } - len = (len >> align) << align; - if (!len) - len = 1 << align; - total_len += len; - um = dmaengine_get_unmap_data(dev->dev, src_cnt+dst_cnt, GFP_KERNEL); if (!um) {