drivers/edac: fix edac_mc sysfs completion code

This patch refactors the 'releasing' of kobjects for the edac_mc type of
device.  The correct pattern of kobject release is followed.

As internal kobjs are allocated they bump a ref count on the top level kobj.
It in turn has a module ref count on the edac_core module.  When internal
kobjects are released, they dec the ref count on the top level kobj.  When the
top level kobj reaches zero, it decrements the ref count on the edac_core
object, allow it to be unloaded, as all resources have all now been released.

Cc: Alan Cox alan@lxorguk.ukuu.org.uk
Signed-off-by: Doug Thompson <dougthompson@xmission.com>
Acked-by: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
diff --git a/drivers/edac/edac_module.c b/drivers/edac/edac_module.c
index 07bd165..fc32bbb 100644
--- a/drivers/edac/edac_module.c
+++ b/drivers/edac/edac_module.c
@@ -14,11 +14,11 @@
 #include "edac_core.h"
 #include "edac_module.h"
 
-#define EDAC_MC_VERSION "Ver: 2.0.4 " __DATE__
+#define EDAC_MC_VERSION "Ver: 2.0.5 " __DATE__
 
 #ifdef CONFIG_EDAC_DEBUG
 /* Values of 0 to 4 will generate output */
-int edac_debug_level = 1;
+int edac_debug_level = 2;
 EXPORT_SYMBOL_GPL(edac_debug_level);
 #endif
 
@@ -153,7 +153,7 @@
 	edac_pci_clear_parity_errors();
 
 	/*
-	 * perform the registration of the /sys/devices/system/edac object
+	 * perform the registration of the /sys/devices/system/edac class object
 	 */
 	if (edac_register_sysfs_edac_name()) {
 		edac_printk(KERN_ERR, EDAC_MC,
@@ -162,29 +162,29 @@
 		goto error;
 	}
 
-	/* Create the MC sysfs entries, must be first
+	/*
+	 * now set up the mc_kset under the edac class object
 	 */
-	if (edac_sysfs_memctrl_setup()) {
-		edac_printk(KERN_ERR, EDAC_MC,
-			"Error initializing sysfs code\n");
-		err = -ENODEV;
-		goto error_sysfs;
-	}
+	err = edac_sysfs_setup_mc_kset();
+	if (err)
+		goto sysfs_setup_fail;
 
-	/* Setup/Initialize the edac_device system */
+	/* Setup/Initialize the workq for this core */
 	err = edac_workqueue_setup();
 	if (err) {
 		edac_printk(KERN_ERR, EDAC_MC, "init WorkQueue failure\n");
-		goto error_mem;
+		goto workq_fail;
 	}
 
 	return 0;
 
 	/* Error teardown stack */
-error_mem:
-	edac_sysfs_memctrl_teardown();
-error_sysfs:
+workq_fail:
+	edac_sysfs_teardown_mc_kset();
+
+sysfs_setup_fail:
 	edac_unregister_sysfs_edac_name();
+
 error:
 	return err;
 }
@@ -199,7 +199,7 @@
 
 	/* tear down the various subsystems */
 	edac_workqueue_teardown();
-	edac_sysfs_memctrl_teardown();
+	edac_sysfs_teardown_mc_kset();
 	edac_unregister_sysfs_edac_name();
 }