diff options
author | Adrian Hunter <adrian.hunter@nokia.com> | 2010-09-23 14:51:29 +0300 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2010-10-23 21:11:13 +0800 |
commit | 3d203be833068c0f633878743d0c08d6acd24b58 (patch) | |
tree | 9871b437744ea824bad935969859e432754b21e5 /drivers/mmc/card | |
parent | 130067ed15f6e8a1209898646878f5bc0a17d3dd (diff) | |
download | blackbird-op-linux-3d203be833068c0f633878743d0c08d6acd24b58.tar.gz blackbird-op-linux-3d203be833068c0f633878743d0c08d6acd24b58.zip |
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/card')
-rw-r--r-- | drivers/mmc/card/mmc_test.c | 12 |
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, if (max_page_cnt > limit) max_page_cnt = limit; - if (max_page_cnt < min_page_cnt) - max_page_cnt = min_page_cnt; + if (min_page_cnt > max_page_cnt) + min_page_cnt = max_page_cnt; if (max_seg_page_cnt > max_page_cnt) max_seg_page_cnt = max_page_cnt; @@ -359,13 +359,13 @@ static struct mmc_test_mem *mmc_test_alloc_mem(unsigned long min_sz, mem->cnt += 1; if (max_page_cnt <= (1UL << order)) break; + max_page_cnt -= 1UL << order; + page_cnt += 1UL << order; if (mem->cnt >= max_segs) { if (page_cnt < min_page_cnt) goto out_free; break; } - max_page_cnt -= 1UL << order; - page_cnt += 1UL << order; } return mem; @@ -1470,12 +1470,12 @@ static int mmc_test_area_init(struct mmc_test_card *test, int erase, int fill) t->max_tfr = t->max_segs * t->max_seg_sz; /* - * Try to allocate enough memory for the whole area. Less is OK + * Try to allocate enough memory for a max. sized transfer. Less is OK * because the same memory can be mapped into the scatterlist more than * once. Also, take into account the limits imposed on scatterlist * segments by the host driver. */ - t->mem = mmc_test_alloc_mem(min_sz, t->max_sz, t->max_segs, + t->mem = mmc_test_alloc_mem(min_sz, t->max_tfr, t->max_segs, t->max_seg_sz); if (!t->mem) return -ENOMEM; |