/* Given a shift value, try to populate memnodemap Returns : 1 if OK 0 if memnodmap too small (of shift too small) -1 if node overlap or lost ram (shift too big)  */
static int __init populate_memnodemap(const struct bootnode *nodes, int numnodes, int shift, int *nodeids)
/* Given a shift value, try to populate memnodemap Returns : 1 if OK 0 if memnodmap too small (of shift too small) -1 if node overlap or lost ram (shift too big)  */
static int __init populate_memnodemap(const struct bootnode *nodes, int numnodes, int shift, int *nodeids)
{
	unsigned long addr, end;
	int i, res = -1;
	memset(memnodemap, 0xff, sizeof(s16)*memnodemapsize);
	for (i = 0; i < numnodes; i++) {
		addr = nodes[i].start;
		end = nodes[i].end;
		if (addr >= end)
			continue;
		if ((end >> shift) >= memnodemapsize)
			return 0;
		do {
			if (memnodemap[addr >> shift] != NUMA_NO_NODE)
				return -1;
			if (!nodeids)
				memnodemap[addr >> shift] = i;
			else
				memnodemap[addr >> shift] = nodeids[i];
			addr += (1UL << shift);
		} while (addr < end);
		res = 1;
	}
	return res;
}