Skip to content

Commit

Permalink
dmatest: move src_off, dst_off, len inside loop
Browse files Browse the repository at this point in the history
The scope of those varsiables is in while-loop. This patch moves them there and
removes duplicate code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
  • Loading branch information
Andy Shevchenko authored and Vinod Koul committed Feb 5, 2015
1 parent a835bb8 commit ede23a5
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions drivers/dma/dmatest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++;
Expand All @@ -502,15 +502,21 @@ static int dmatest_func(void *data)
break;
}

if (params->noverify) {
if (params->noverify)
len = params->buf_size;
else
len = dmatest_random() % params->buf_size + 1;

len = (len >> align) << align;
if (!len)
len = 1 << align;

total_len += len;

if (params->noverify) {
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);

Expand All @@ -523,11 +529,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) {
Expand Down

0 comments on commit ede23a5

Please sign in to comment.