Skip to content

Commit

Permalink
[PATCH] swsusp: simpler calculation of number of pages in PBE list
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michal Schmidt authored and Linus Torvalds committed Sep 5, 2005
1 parent 46dacba commit 56057e1
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions kernel/power/swsusp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 56057e1

Please sign in to comment.