/* walk_memory_resource() needs to make sure there is no holes in a given memory range. PPC64 does not maintain the memory layout in /proc/iomem. Instead it maintains it in lmb.memory structures. Walk through the memory regions, find holes and callback for contiguous regions.  */
int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, void *arg, int(*func)(unsigned long, unsigned long, void *))
/* walk_memory_resource() needs to make sure there is no holes in a given memory range. PPC64 does not maintain the memory layout in /proc/iomem. Instead it maintains it in lmb.memory structures. Walk through the memory regions, find holes and callback for contiguous regions.  */
int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, void *arg, int(*func)(unsigned long, unsigned long, void *))
{
	struct lmb_property res;
	unsigned long pfn, len;
	u64 end;
	int ret = -1;
	res.base = (u64) start_pfn << PAGE_SHIFT;
	res.size = (u64) nr_pages << PAGE_SHIFT;
	end = res.base + res.size - 1;
	while ((res.base < end) && (lmb_find(&res) >= 0)) {
		pfn = (unsigned long)(res.base >> PAGE_SHIFT);
		len = (unsigned long)(res.size >> PAGE_SHIFT);
		ret = (*func)(pfn, len, arg);
		if (ret)
			break;
		res.base += (res.size + 1);
		res.size = (end - res.base + 1);
	}
	return ret;
}