/* memory_bm_find_bit - find the bit in the bitmap @bm that corresponds to given pfn. The cur_zone_bm member of @bm and the cur_block member of @bm->cur_zone_bm are updated.  */
static int memory_bm_find_bit(struct memory_bitmap *bm, unsigned long pfn, void **addr, unsigned int *bit_nr)
/* memory_bm_find_bit - find the bit in the bitmap @bm that corresponds to given pfn. The cur_zone_bm member of @bm and the cur_block member of @bm->cur_zone_bm are updated.  */
static int memory_bm_find_bit(struct memory_bitmap *bm, unsigned long pfn, void **addr, unsigned int *bit_nr)
{
	struct bm_block *bb;
	bb = bm->cur.block;
	if (pfn < bb->start_pfn)
		list_for_each_entry_continue_reverse(bb, &bm->blocks, hook)
			if (pfn >= bb->start_pfn)
				break;
	if (pfn >= bb->end_pfn)
		list_for_each_entry_continue(bb, &bm->blocks, hook)
			if (pfn >= bb->start_pfn && pfn < bb->end_pfn)
				break;
	if (&bb->hook == &bm->blocks)
		return -EFAULT;
	bm->cur.block = bb;
	pfn -= bb->start_pfn;
	bm->cur.bit = pfn + 1;
	*bit_nr = pfn;
	*addr = bb->data;
	return 0;
}