
This is the bare set of fixes needed to get the memory class stuff to compile.

Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---

 memhotplug-dave/drivers/base/Makefile  |    4 +-
 memhotplug-dave/drivers/base/init.c    |    1 
 memhotplug-dave/drivers/base/memory.c  |   48 ++++++++++++++++++---------------
 memhotplug-dave/include/linux/memory.h |    9 ++++++
 memhotplug-dave/mm/memory_hotplug.c    |   14 +++++----
 memhotplug-dave/mm/page_alloc.c        |    2 -
 6 files changed, 47 insertions(+), 31 deletions(-)

diff -puN drivers/base/Makefile~M2-sysfs-memory-class-barefix drivers/base/Makefile
--- memhotplug/drivers/base/Makefile~M2-sysfs-memory-class-barefix	2005-01-04 13:49:54.000000000 -0800
+++ memhotplug-dave/drivers/base/Makefile	2005-01-04 13:49:55.000000000 -0800
@@ -2,11 +2,11 @@
 
 obj-y			:= core.o sys.o interface.o bus.o \
 			   driver.o class.o class_simple.o platform.o \
-			   cpu.o firmware.o init.o map.o dmapool.o \
-			   memory.o
+			   cpu.o firmware.o init.o map.o dmapool.o
 obj-y			+= power/
 obj-$(CONFIG_FW_LOADER)	+= firmware_class.o
 obj-$(CONFIG_NUMA)	+= node.o
+obj-$(CONFIG_MEMORY_HOTPLUG) += memory.o
 
 ifeq ($(CONFIG_DEBUG_DRIVER),y)
 EXTRA_CFLAGS += -DDEBUG
diff -puN drivers/base/init.c~M2-sysfs-memory-class-barefix drivers/base/init.c
--- memhotplug/drivers/base/init.c~M2-sysfs-memory-class-barefix	2005-01-04 13:49:54.000000000 -0800
+++ memhotplug-dave/drivers/base/init.c	2005-01-04 13:49:55.000000000 -0800
@@ -18,7 +18,6 @@ extern int firmware_init(void);
 extern int platform_bus_init(void);
 extern int system_bus_init(void);
 extern int cpu_dev_init(void);
-extern int memory_dev_init(void);
 
 /**
  *	driver_init - initialize driver model.
diff -puN drivers/base/memory.c~M2-sysfs-memory-class-barefix drivers/base/memory.c
--- memhotplug/drivers/base/memory.c~M2-sysfs-memory-class-barefix	2005-01-04 13:49:54.000000000 -0800
+++ memhotplug-dave/drivers/base/memory.c	2005-01-04 13:49:55.000000000 -0800
@@ -23,22 +23,19 @@ EXPORT_SYMBOL(memory_sysdev_class);
  */
 static int memory_hotplug_filter(struct kset *kset, struct kobject *kobj)
 {
-	struct kobj_type *ktype = get_ktype(kobj);
-	printk("Hit %s\n", __func__);
+/*	struct kobj_type *ktype = get_ktype(kobj); */
 	return 1;
 }
 
 static char *memory_hotplug_name(struct kset *kset, struct kobject *kobj)
 {
-	printk("Hit %s\n", __func__);
-	return "-no_name_implemented";
+        return "-no_name_implemented";
 }
 
 static int memory_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
 			int num_envp, char *buffer, int buffer_size)
 {
 	int retval = 0;
-	printk("Hit %s\n", __func__);
 
 	return retval;
 }
@@ -72,6 +69,18 @@ register_memory(struct memory_block *mem
 	return error;
 }
 
+void
+unregister_memory(struct memory_block *memory, unsigned int section,
+		struct node *root)
+{
+	BUG_ON(memory->sysdev.cls != &memory_sysdev_class);
+	BUG_ON(memory->sysdev.id != section);
+
+	sysdev_unregister(&memory->sysdev);
+	if (root)
+		sysfs_remove_link(&root->sysdev.kobj, kobject_name(&memory->sysdev.kobj));
+}
+
 /*
  * use this as the physical section index that this memsection
  * uses.
@@ -150,8 +159,6 @@ memory_probe_store(struct class *class, 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
 
-	printk("Hit %s!\n", __func__);
-
 	/* make call into arch code */
 	//static int num; /* hehe. no locking */
 
@@ -183,9 +190,7 @@ int add_memory_block(unsigned long node_
 {
 	size_t size = sizeof(struct memory_block);
 	struct memory_block *mem = kmalloc(size, GFP_KERNEL);
-	int ret0, ret1, ret2, ret3;
-
-	printk("Hit %s\n", __func__);
+	int ret = 0;
 
 	if (!mem)
 		return -ENOMEM;
@@ -204,27 +209,30 @@ int add_memory_block(unsigned long node_
 		callback(mem);
 #endif
 
-	ret0 = register_memory(mem, section, NULL);
-	ret1 = mem_create_simple_file(mem, phys_index);
-	ret2 = mem_create_simple_file(mem, state);
-	ret3 = mem_create_simple_file(mem, phys_device);
+	ret = register_memory(mem, section, NULL);
+	if (!ret)
+		ret = mem_create_simple_file(mem, phys_index);
+	if (!ret)
+		ret = mem_create_simple_file(mem, state);
+	if (!ret)
+		ret = mem_create_simple_file(mem, phys_device);
 
-	return 0;
+	return ret;
 }
 
-#define update_memdevice(...) 	(1)
+#define update_memdevice(...) 	do {} while(0)
+#define online_section(...) 	do {} while(0)
 
 static ssize_t
 online_store(struct class *class, const char *buf, size_t count)
 {
 	unsigned int section = simple_strtoul(buf, NULL, 10);
-	int i;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
 
 	if (mem_section[section].phys_section == INVALID_SECTION) {
-		printk("%s: Ummm.. this section is not currently mapped!\n",
+		printk(KERN_WARNING "%s: Ummm.. this section is not currently mapped!\n",
 			__func__);
 		return -EINVAL;
 	}
@@ -260,10 +268,8 @@ int register_new_memory(unsigned int sec
 {
 	unsigned int phys_index = mem_section[section].phys_section;
 
-	printk("Hit %s\n", __func__);
-
 	if (phys_index == INVALID_SECTION) {
-		printk("%s: phys_index 0x%x is BOGUS!\n", __func__, phys_index);
+		printk(KERN_WARNING "%s: phys_index 0x%x is BOGUS!\n", __func__, phys_index);
 		return -EINVAL;
 	}
 
diff -puN include/linux/memory.h~M2-sysfs-memory-class-barefix include/linux/memory.h
--- memhotplug/include/linux/memory.h~M2-sysfs-memory-class-barefix	2005-01-04 13:49:54.000000000 -0800
+++ memhotplug-dave/include/linux/memory.h	2005-01-04 13:49:55.000000000 -0800
@@ -23,6 +23,15 @@
 
 #include <asm/semaphore.h>
 
+#ifndef CONFIG_MEMORY_HOTPLUG
+static inline int memory_dev_init(void)
+{
+	return 0;
+}
+#else
+extern int memory_dev_init(void);
+#endif
+
 #ifndef CONFIG_NONLINEAR
 #define CONFIG_MEM_BLOCK_SIZE	(1<<27)
 #else /* tie this to nonlinear */
diff -puN mm/memory_hotplug.c~M2-sysfs-memory-class-barefix mm/memory_hotplug.c
--- memhotplug/mm/memory_hotplug.c~M2-sysfs-memory-class-barefix	2005-01-04 13:49:54.000000000 -0800
+++ memhotplug-dave/mm/memory_hotplug.c	2005-01-04 13:49:55.000000000 -0800
@@ -94,15 +94,17 @@ int __add_pages(struct zone *zone, unsig
 
 
 static int
-online_pages(unsigned long lpfn, unsigned long nr_pages)
+online_pages(unsigned long pfn, unsigned long nr_pages)
 {
 	int i;
 
-	printk("%s: onlining %lx pages starting from lpfn: 0x%lx\n",
-		__func__, nr_pages, lpfn);
+	printk(KERN_DEBUG "%s: onlining 0x%lx pages starting from pfn: 0x%lx\n",
+		__func__, nr_pages, pfn);
 
-	for (i = 0; i < nr_pages; i++, lpfn++)
-		online_page(lpfn_to_page(lpfn));
+	for (i = 0; i < nr_pages; i++)
+		online_page(pfn_to_page(pfn + i));
+
+	page_zone(pfn_to_page(pfn))->present_pages += nr_pages;
 
 	/* need error checking */
 	return 0;
@@ -133,7 +135,7 @@ __online_memory_block(struct memory_bloc
 		}
 	}
 
-	return online_pages(page_to_lpfn(mem_section[section].mem_map),
+	return online_pages(page_to_pfn(mem_section[section].mem_map),
 		PAGES_PER_SECTION);
 }
 #else
diff -puN mm/page_alloc.c~M2-sysfs-memory-class-barefix mm/page_alloc.c
--- memhotplug/mm/page_alloc.c~M2-sysfs-memory-class-barefix	2005-01-04 13:49:54.000000000 -0800
+++ memhotplug-dave/mm/page_alloc.c	2005-01-04 13:49:55.000000000 -0800
@@ -1826,7 +1826,7 @@ static void __init calculate_zone_totalp
  * up by free_all_bootmem() once the early boot process is
  * done. Non-atomic initialization, single-pass.
  */
-void __init memmap_init_zone(unsigned long size, int nid, unsigned long zone,
+void __devinit memmap_init_zone(unsigned long size, int nid, unsigned long zone,
 		unsigned long start_pfn)
 {
 	struct page *start = pfn_to_page(start_pfn);
_
