aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@nokia.com>2010-09-23 07:51:29 -0400
committerChris Ball <cjb@laptop.org>2010-10-23 09:11:13 -0400
commit3d203be833068c0f633878743d0c08d6acd24b58 (patch)
tree9871b437744ea824bad935969859e432754b21e5 /drivers/mmc
parent130067ed15f6e8a1209898646878f5bc0a17d3dd (diff)
mmc_test: fix memory allocation segment limits
Correctly allocate memory to meet the host controller driver's maximum segment size and count limits. Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/card/mmc_test.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index 6580af7b7cb8..5874040b3702 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -318,8 +318,8 @@ static struct mmc_test_mem *mmc_test_alloc_mem(unsigned long min_sz,
318 318
319 if (max_page_cnt > limit) 319 if (max_page_cnt > limit)
320 max_page_cnt = limit; 320 max_page_cnt = limit;
321 if (max_page_cnt < min_page_cnt) 321 if (min_page_cnt > max_page_cnt)
322 max_page_cnt = min_page_cnt; 322 min_page_cnt = max_page_cnt;
323 323
324 if (max_seg_page_cnt > max_page_cnt) 324 if (max_seg_page_cnt > max_page_cnt)
325 max_seg_page_cnt = max_page_cnt; 325 max_seg_page_cnt = max_page_cnt;
@@ -359,13 +359,13 @@ static struct mmc_test_mem *mmc_test_alloc_mem(unsigned long min_sz,
359 mem->cnt += 1; 359 mem->cnt += 1;
360 if (max_page_cnt <= (1UL << order)) 360 if (max_page_cnt <= (1UL << order))
361 break; 361 break;
362 max_page_cnt -= 1UL << order;
363 page_cnt += 1UL << order;
362 if (mem->cnt >= max_segs) { 364 if (mem->cnt >= max_segs) {
363 if (page_cnt < min_page_cnt) 365 if (page_cnt < min_page_cnt)
364 goto out_free; 366 goto out_free;
365 break; 367 break;
366 } 368 }
367 max_page_cnt -= 1UL << order;
368 page_cnt += 1UL << order;
369 } 369 }
370 370
371 return mem; 371 return mem;
@@ -1470,12 +1470,12 @@ static int mmc_test_area_init(struct mmc_test_card *test, int erase, int fill)
1470 t->max_tfr = t->max_segs * t->max_seg_sz; 1470 t->max_tfr = t->max_segs * t->max_seg_sz;
1471 1471
1472 /* 1472 /*
1473 * Try to allocate enough memory for the whole area. Less is OK 1473 * Try to allocate enough memory for a max. sized transfer. Less is OK
1474 * because the same memory can be mapped into the scatterlist more than 1474 * because the same memory can be mapped into the scatterlist more than
1475 * once. Also, take into account the limits imposed on scatterlist 1475 * once. Also, take into account the limits imposed on scatterlist
1476 * segments by the host driver. 1476 * segments by the host driver.
1477 */ 1477 */
1478 t->mem = mmc_test_alloc_mem(min_sz, t->max_sz, t->max_segs, 1478 t->mem = mmc_test_alloc_mem(min_sz, t->max_tfr, t->max_segs,
1479 t->max_seg_sz); 1479 t->max_seg_sz);
1480 if (!t->mem) 1480 if (!t->mem)
1481 return -ENOMEM; 1481 return -ENOMEM;