From: Michal Schmidt The function calc_nr uses an iterative algorithm to calculate the number of pages needed for the image and the pagedir. Exactly the same result can be obtained with a one-line expression. Note that this was even proved correct ;-). Signed-off-by: Michal Schmidt Signed-off-by: Pavel Machek Signed-off-by: Andrew Morton --- kernel/power/swsusp.c | 13 +------------ 1 files changed, 1 insertion(+), 12 deletions(-) diff -puN kernel/power/swsusp.c~swsusp-simpler-calculation-of-number-of-pages-in-pbe-list kernel/power/swsusp.c --- devel/kernel/power/swsusp.c~swsusp-simpler-calculation-of-number-of-pages-in-pbe-list 2005-07-30 10:53:17.000000000 -0700 +++ devel-akpm/kernel/power/swsusp.c 2005-07-30 10:53:17.000000000 -0700 @@ -737,18 +737,7 @@ static void copy_data_pages(void) static int calc_nr(int nr_copy) { - int extra = 0; - int mod = !!(nr_copy % PBES_PER_PAGE); - int diff = (nr_copy / PBES_PER_PAGE) + mod; - - do { - extra += diff; - nr_copy += diff; - mod = !!(nr_copy % PBES_PER_PAGE); - diff = (nr_copy / PBES_PER_PAGE) + mod - extra; - } while (diff > 0); - - return nr_copy; + return nr_copy + (nr_copy+PBES_PER_PAGE-2)/(PBES_PER_PAGE-1); } /** _