From: Dave Hansen <haveblue@us.ibm.com>

A little helper that we use in the hotplug code.

Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 include/linux/mmzone.h |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+)

diff -puN include/linux/mmzone.h~memory-hotplug-prep-__section_nr-helper include/linux/mmzone.h
--- devel/include/linux/mmzone.h~memory-hotplug-prep-__section_nr-helper	2005-09-07 20:10:27.000000000 -0700
+++ devel-akpm/include/linux/mmzone.h	2005-09-07 20:10:27.000000000 -0700
@@ -513,6 +513,31 @@ static inline struct mem_section *__nr_t
 }
 
 /*
+ * Although written for the SPARSEMEM_EXTREME case, this happens
+ * to also work for the flat array case becase
+ * NR_SECTION_ROOTS==NR_MEM_SECTIONS.
+ */
+static inline int __section_nr(struct mem_section* ms)
+{
+	unsigned long root_nr;
+	struct mem_section* root;
+
+	for (root_nr = 0;
+	     root_nr < NR_MEM_SECTIONS;
+	     root_nr += SECTIONS_PER_ROOT) {
+		root = __nr_to_section(root_nr);
+
+		if (!root)
+			continue;
+
+		if ((ms >= root) && (ms < (root + SECTIONS_PER_ROOT)))
+		     break;
+	}
+
+	return (root_nr * SECTIONS_PER_ROOT) + (ms - root);
+}
+
+/*
  * We use the lower bits of the mem_map pointer to store
  * a little bit of information.  There should be at least
  * 3 bits here due to 32-bit alignment.
_