aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power
diff options
context:
space:
mode:
authorMichal Schmidt <xschmi00@stud.feec.vutbr.cz>2005-09-03 18:57:02 -0400
committerLinus Torvalds <torvalds@evo.osdl.org>2005-09-05 03:06:17 -0400
commit56057e1a128a9aab516350500e5b154e70577929 (patch)
tree68f323a6e919d96dad59471decb3bea3ec6a36fc /kernel/power
parent46dacba52a19d1414ba249499a48382c16242d99 (diff)
[PATCH] swsusp: simpler calculation of number of pages in PBE list
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 <xschmi00@stud.feec.vutbr.cz> Signed-off-by: Pavel Machek <pavel@suse.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/power')
-rw-r--r--kernel/power/swsusp.c13
1 files changed, 1 insertions, 12 deletions
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index b041cea2e878..1681e8a3fe51 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -737,18 +737,7 @@ static void copy_data_pages(void)
737 737
738static int calc_nr(int nr_copy) 738static int calc_nr(int nr_copy)
739{ 739{
740 int extra = 0; 740 return nr_copy + (nr_copy+PBES_PER_PAGE-2)/(PBES_PER_PAGE-1);
741 int mod = !!(nr_copy % PBES_PER_PAGE);
742 int diff = (nr_copy / PBES_PER_PAGE) + mod;
743
744 do {
745 extra += diff;
746 nr_copy += diff;
747 mod = !!(nr_copy % PBES_PER_PAGE);
748 diff = (nr_copy / PBES_PER_PAGE) + mod - extra;
749 } while (diff > 0);
750
751 return nr_copy;
752} 741}
753 742
754/** 743/**