]> err.no Git - linux-2.6/blobdiff - drivers/edac/edac_mc.c
[PATCH] EDAC: kobject_init/kobject_put fixes
[linux-2.6] / drivers / edac / edac_mc.c
index b10ee4698b1db95f8b3045fd7fd814648cedfed0..e6ecc7da38a5cb0fa9921de062b8cc10fac996d8 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/list.h>
 #include <linux/sysdev.h>
 #include <linux/ctype.h>
+#include <linux/kthread.h>
 
 #include <asm/uaccess.h>
 #include <asm/page.h>
 
 #include "edac_mc.h"
 
-#define        EDAC_MC_VERSION "edac_mc  Ver: 2.0.0 " __DATE__
+#define        EDAC_MC_VERSION "Ver: 2.0.0 " __DATE__
+
+/* For now, disable the EDAC sysfs code.  The sysfs interface that EDAC
+ * presents to user space needs more thought, and is likely to change
+ * substantially.
+ */
+#define DISABLE_EDAC_SYSFS
 
 #ifdef CONFIG_EDAC_DEBUG
 /* Values of 0 to 4 will generate output */
@@ -47,7 +54,7 @@ EXPORT_SYMBOL(edac_debug_level);
 /* EDAC Controls, setable by module parameter, and sysfs */
 static int log_ue = 1;
 static int log_ce = 1;
-static int panic_on_ue = 1;
+static int panic_on_ue;
 static int poll_msec = 1000;
 
 static int check_pci_parity = 0;       /* default YES check PCI parity */
@@ -58,6 +65,8 @@ static atomic_t pci_parity_count = ATOMIC_INIT(0);
 static DECLARE_MUTEX(mem_ctls_mutex);
 static struct list_head mc_devices = LIST_HEAD_INIT(mc_devices);
 
+static struct task_struct *edac_thread;
+
 /* Structure of the whitelist and blacklist arrays */
 struct edac_pci_device_list {
        unsigned int  vendor;           /* Vendor ID */
@@ -77,6 +86,8 @@ static int pci_whitelist_count ;
 
 /*  START sysfs data and methods */
 
+#ifndef DISABLE_EDAC_SYSFS
+
 static const char *mem_types[] = {
        [MEM_EMPTY] = "Empty",
        [MEM_RESERVED] = "Reserved",
@@ -132,11 +143,13 @@ static struct kobject edac_pci_kobj;
  * /sys/devices/system/edac/mc;
  *     data structures and methods
  */
+#if 0
 static ssize_t memctrl_string_show(void *ptr, char *buffer)
 {
        char *value = (char*) ptr;
        return sprintf(buffer, "%s\n", value);
 }
+#endif
 
 static ssize_t memctrl_int_show(void *ptr, char *buffer)
 {
@@ -207,7 +220,9 @@ struct memctrl_dev_attribute attr_##_name = {                       \
 };
 
 /* cwrow<id> attribute f*/
+#if 0
 MEMCTRL_STRING_ATTR(mc_version,EDAC_MC_VERSION,S_IRUGO,memctrl_string_show,NULL);
+#endif
 
 /* csrow<id> control files */
 MEMCTRL_ATTR(panic_on_ue,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store);
@@ -222,14 +237,13 @@ static struct memctrl_dev_attribute *memctrl_attr[] = {
        &attr_log_ue,
        &attr_log_ce,
        &attr_poll_msec,
-       &attr_mc_version,
        NULL,
 };
 
 /* Main MC kobject release() function */
 static void edac_memctrl_master_release(struct kobject *kobj)
 {
-       debugf1("EDAC MC: " __FILE__ ": %s()\n", __func__);
+       debugf1("%s()\n", __func__);
 }
 
 static struct kobj_type ktype_memctrl = {
@@ -238,6 +252,7 @@ static struct kobj_type ktype_memctrl = {
        .default_attrs  = (struct attribute **) memctrl_attr,
 };
 
+#endif  /* DISABLE_EDAC_SYSFS */
 
 /* Initialize the main sysfs entries for edac:
  *   /sys/devices/system/edac
@@ -248,18 +263,21 @@ static struct kobj_type ktype_memctrl = {
  *         !0 FAILURE
  */
 static int edac_sysfs_memctrl_setup(void)
+#ifdef DISABLE_EDAC_SYSFS
+{
+       return 0;
+}
+#else
 {
        int err=0;
 
-       debugf1("MC: " __FILE__ ": %s()\n", __func__);
+       debugf1("%s()\n", __func__);
 
        /* create the /sys/devices/system/edac directory */
        err = sysdev_class_register(&edac_class);
        if (!err) {
                /* Init the MC's kobject */
                memset(&edac_memctrl_kobj, 0, sizeof (edac_memctrl_kobj));
-               kobject_init(&edac_memctrl_kobj);
-
                edac_memctrl_kobj.parent = &edac_class.kset.kobj;
                edac_memctrl_kobj.ktype = &ktype_memctrl;
 
@@ -275,11 +293,12 @@ static int edac_sysfs_memctrl_setup(void)
                        }
                }
        } else {
-               debugf1(KERN_WARNING "__FILE__ %s() error=%d\n", __func__,err);
+               debugf1("%s() error=%d\n", __func__, err);
        }
 
        return err;
 }
+#endif  /* DISABLE_EDAC_SYSFS */
 
 /*
  * MC teardown:
@@ -287,18 +306,19 @@ static int edac_sysfs_memctrl_setup(void)
  */
 static void edac_sysfs_memctrl_teardown(void)
 {
+#ifndef DISABLE_EDAC_SYSFS
        debugf0("MC: " __FILE__ ": %s()\n", __func__);
 
        /* Unregister the MC's kobject */
        kobject_unregister(&edac_memctrl_kobj);
 
-       /* release the master edac mc kobject */
-       kobject_put(&edac_memctrl_kobj);
-
        /* Unregister the 'edac' object */
        sysdev_class_unregister(&edac_class);
+#endif  /* DISABLE_EDAC_SYSFS */
 }
 
+#ifndef DISABLE_EDAC_SYSFS
+
 /*
  * /sys/devices/system/edac/pci;
  *     data structures and methods
@@ -309,6 +329,8 @@ struct list_control {
        int *count;
 };
 
+
+#if 0
 /* Output the list as:  vendor_id:device:id<,vendor_id:device_id> */
 static ssize_t edac_pci_list_string_show(void *ptr, char *buffer)
 {
@@ -430,6 +452,7 @@ static ssize_t edac_pci_list_string_store(void *ptr, const char *buffer,
        return count;
 }
 
+#endif
 static ssize_t edac_pci_int_show(void *ptr, char *buffer)
 {
        int *value = ptr;
@@ -498,6 +521,7 @@ struct edac_pci_dev_attribute edac_pci_attr_##_name = {             \
        .store  = _store,                                       \
 };
 
+#if 0
 static struct list_control pci_whitelist_control = {
        .list = pci_whitelist,
        .count = &pci_whitelist_count
@@ -520,6 +544,7 @@ EDAC_PCI_STRING_ATTR(pci_parity_blacklist,
        S_IRUGO|S_IWUSR,
        edac_pci_list_string_show,
        edac_pci_list_string_store);
+#endif
 
 /* PCI Parity control files */
 EDAC_PCI_ATTR(check_pci_parity,S_IRUGO|S_IWUSR,edac_pci_int_show,edac_pci_int_store);
@@ -531,15 +556,13 @@ static struct edac_pci_dev_attribute *edac_pci_attr[] = {
        &edac_pci_attr_check_pci_parity,
        &edac_pci_attr_panic_on_pci_parity,
        &edac_pci_attr_pci_parity_count,
-       &edac_pci_attr_pci_parity_whitelist,
-       &edac_pci_attr_pci_parity_blacklist,
        NULL,
 };
 
 /* No memory to release */
 static void edac_pci_release(struct kobject *kobj)
 {
-       debugf1("EDAC PCI: " __FILE__ ": %s()\n", __func__);
+       debugf1("%s()\n", __func__);
 }
 
 static struct kobj_type ktype_edac_pci = {
@@ -548,19 +571,24 @@ static struct kobj_type ktype_edac_pci = {
        .default_attrs  = (struct attribute **) edac_pci_attr,
 };
 
+#endif  /* DISABLE_EDAC_SYSFS */
+
 /**
  * edac_sysfs_pci_setup()
  *
  */
 static int edac_sysfs_pci_setup(void)
+#ifdef DISABLE_EDAC_SYSFS
+{
+       return 0;
+}
+#else
 {
        int err;
 
-       debugf1("MC: " __FILE__ ": %s()\n", __func__);
+       debugf1("%s()\n", __func__);
 
        memset(&edac_pci_kobj, 0, sizeof(edac_pci_kobj));
-
-       kobject_init(&edac_pci_kobj);
        edac_pci_kobj.parent = &edac_class.kset.kobj;
        edac_pci_kobj.ktype = &ktype_edac_pci;
 
@@ -576,16 +604,19 @@ static int edac_sysfs_pci_setup(void)
        }
        return err;
 }
-
+#endif  /* DISABLE_EDAC_SYSFS */
 
 static void edac_sysfs_pci_teardown(void)
 {
-       debugf0("MC: " __FILE__ ": %s()\n", __func__);
+#ifndef DISABLE_EDAC_SYSFS
+       debugf0("%s()\n", __func__);
 
        kobject_unregister(&edac_pci_kobj);
-       kobject_put(&edac_pci_kobj);
+#endif
 }
 
+#ifndef DISABLE_EDAC_SYSFS
+
 /* EDAC sysfs CSROW data structures and methods */
 
 /* Set of more detailed csrow<id> attribute show/store functions */
@@ -769,7 +800,7 @@ static struct csrowdev_attribute *csrow_attr[] = {
 /* No memory to release */
 static void edac_csrow_instance_release(struct kobject *kobj)
 {
-       debugf1("EDAC MC: " __FILE__ ": %s()\n", __func__);
+       debugf1("%s()\n", __func__);
 }
 
 static struct kobj_type ktype_csrow = {
@@ -784,13 +815,12 @@ static int edac_create_csrow_object(struct kobject *edac_mci_kobj,
 {
        int err = 0;
 
-       debugf0("MC: " __FILE__ ": %s()\n", __func__);
+       debugf0("%s()\n", __func__);
 
        memset(&csrow->kobj, 0, sizeof(csrow->kobj));
 
        /* generate ..../edac/mc/mc<id>/csrow<index>   */
 
-       kobject_init(&csrow->kobj);
        csrow->kobj.parent = edac_mci_kobj;
        csrow->kobj.ktype = &ktype_csrow;
 
@@ -1027,8 +1057,7 @@ static void edac_mci_instance_release(struct kobject *kobj)
        struct mem_ctl_info *mci;
        mci = container_of(kobj,struct mem_ctl_info,edac_mci_kobj);
 
-       debugf0("MC: " __FILE__ ": %s() idx=%d calling kfree\n",
-               __func__, mci->mc_idx);
+       debugf0("%s() idx=%d calling kfree\n", __func__, mci->mc_idx);
 
        kfree(mci);
 }
@@ -1039,6 +1068,8 @@ static struct kobj_type ktype_mci = {
        .default_attrs  = (struct attribute **) mci_attr,
 };
 
+#endif  /* DISABLE_EDAC_SYSFS */
+
 #define EDAC_DEVICE_SYMLINK    "device"
 
 /*
@@ -1050,16 +1081,20 @@ static struct kobj_type ktype_mci = {
  *     !0      Failure
  */
 static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
+#ifdef DISABLE_EDAC_SYSFS
+{
+       return 0;
+}
+#else
 {
        int i;
        int err;
        struct csrow_info *csrow;
        struct kobject *edac_mci_kobj=&mci->edac_mci_kobj;
 
-       debugf0("MC: " __FILE__ ": %s() idx=%d\n", __func__, mci->mc_idx);
+       debugf0("%s() idx=%d\n", __func__, mci->mc_idx);
 
        memset(edac_mci_kobj, 0, sizeof(*edac_mci_kobj));
-       kobject_init(edac_mci_kobj);
 
        /* set the name of the mc<id> object */
        err = kobject_set_name(edac_mci_kobj,"mc%d",mci->mc_idx);
@@ -1078,10 +1113,8 @@ static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
        /* create a symlink for the device */
        err = sysfs_create_link(edac_mci_kobj, &mci->pdev->dev.kobj,
                                EDAC_DEVICE_SYMLINK);
-       if (err) {
-               kobject_unregister(edac_mci_kobj);
-               return err;
-       }
+       if (err)
+               goto fail0;
 
        /* Make directories for each CSROW object
         * under the mc<id> kobject
@@ -1094,7 +1127,7 @@ static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
                if (csrow->nr_pages > 0) {
                        err = edac_create_csrow_object(edac_mci_kobj,csrow,i);
                        if (err)
-                               goto fail;
+                               goto fail1;
                }
        }
 
@@ -1105,41 +1138,39 @@ static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
 
 
        /* CSROW error: backout what has already been registered,  */
-fail:
+fail1:
        for ( i--; i >= 0; i--) {
-               if (csrow->nr_pages > 0) {
+               if (csrow->nr_pages > 0)
                        kobject_unregister(&mci->csrows[i].kobj);
-                       kobject_put(&mci->csrows[i].kobj);
-               }
        }
 
+fail0:
        kobject_unregister(edac_mci_kobj);
-       kobject_put(edac_mci_kobj);
 
        return err;
 }
+#endif  /* DISABLE_EDAC_SYSFS */
 
 /*
  * remove a Memory Controller instance
  */
 static void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci)
 {
+#ifndef DISABLE_EDAC_SYSFS
        int i;
 
-       debugf0("MC: " __FILE__ ": %s()\n", __func__);
+       debugf0("%s()\n", __func__);
 
        /* remove all csrow kobjects */
        for (i = 0; i < mci->nr_csrows; i++) {
-               if (mci->csrows[i].nr_pages > 0)  {
+               if (mci->csrows[i].nr_pages > 0)
                        kobject_unregister(&mci->csrows[i].kobj);
-                       kobject_put(&mci->csrows[i].kobj);
-               }
        }
 
        sysfs_remove_link(&mci->edac_mci_kobj, EDAC_DEVICE_SYMLINK);
 
        kobject_unregister(&mci->edac_mci_kobj);
-       kobject_put(&mci->edac_mci_kobj);
+#endif  /* DISABLE_EDAC_SYSFS */
 }
 
 /* END OF sysfs data and methods */
@@ -1347,7 +1378,7 @@ struct mem_ctl_info *edac_mc_find_mci_by_pdev(struct pci_dev *pdev)
        struct mem_ctl_info *mci;
        struct list_head *item;
 
-       debugf3("MC: " __FILE__ ": %s()\n", __func__);
+       debugf3("%s()\n", __func__);
 
        list_for_each(item, &mc_devices) {
                mci = list_entry(item, struct mem_ctl_info, link);
@@ -1370,10 +1401,11 @@ static int add_mc_to_global_list (struct mem_ctl_info *mci)
                insert_before = &mc_devices;
        } else {
                if (edac_mc_find_mci_by_pdev(mci->pdev)) {
-                       printk(KERN_WARNING
-                               "EDAC MC: %s (%s) %s %s already assigned %d\n",
-                               mci->pdev->dev.bus_id, pci_name(mci->pdev),
-                               mci->mod_name, mci->ctl_name, mci->mc_idx);
+                       edac_printk(KERN_WARNING, EDAC_MC,
+                               "%s (%s) %s %s already assigned %d\n",
+                               mci->pdev->dev.bus_id,
+                               pci_name(mci->pdev), mci->mod_name,
+                               mci->ctl_name, mci->mc_idx);
                        return 1;
                }
 
@@ -1402,6 +1434,24 @@ static int add_mc_to_global_list (struct mem_ctl_info *mci)
 }
 
 
+static void complete_mc_list_del (struct rcu_head *head)
+{
+       struct mem_ctl_info *mci;
+
+       mci = container_of(head, struct mem_ctl_info, rcu);
+       INIT_LIST_HEAD(&mci->link);
+       complete(&mci->complete);
+}
+
+
+static void del_mc_from_global_list (struct mem_ctl_info *mci)
+{
+       list_del_rcu(&mci->link);
+       init_completion(&mci->complete);
+       call_rcu(&mci->rcu, complete_mc_list_del);
+       wait_for_completion(&mci->complete);
+}
+
 
 EXPORT_SYMBOL(edac_mc_add_mc);
 
@@ -1417,9 +1467,7 @@ EXPORT_SYMBOL(edac_mc_add_mc);
 /* FIXME - should a warning be printed if no error detection? correction? */
 int edac_mc_add_mc(struct mem_ctl_info *mci)
 {
-       int rc = 1;
-
-       debugf0("MC: " __FILE__ ": %s()\n", __func__);
+       debugf0("%s()\n", __func__);
 #ifdef CONFIG_EDAC_DEBUG
        if (edac_debug_level >= 3)
                edac_mc_dump_mci(mci);
@@ -1438,51 +1486,32 @@ int edac_mc_add_mc(struct mem_ctl_info *mci)
        down(&mem_ctls_mutex);
 
        if (add_mc_to_global_list(mci))
-               goto finish;
+               goto fail0;
 
        /* set load time so that error rate can be tracked */
        mci->start_time = jiffies;
 
         if (edac_create_sysfs_mci_device(mci)) {
-                printk(KERN_WARNING
-                       "EDAC MC%d: failed to create sysfs device\n",
-                       mci->mc_idx);
-               /* FIXME - should there be an error code and unwind? */
-                goto finish;
+                edac_mc_printk(mci, KERN_WARNING,
+                       "failed to create sysfs device\n");
+                goto fail1;
         }
 
        /* Report action taken */
-       printk(KERN_INFO
-              "EDAC MC%d: Giving out device to %s %s: PCI %s\n",
-              mci->mc_idx, mci->mod_name, mci->ctl_name,
-              pci_name(mci->pdev));
+       edac_mc_printk(mci, KERN_INFO, "Giving out device to %s %s: PCI %s\n",
+               mci->mod_name, mci->ctl_name, pci_name(mci->pdev));
 
-
-       rc = 0;
-
-finish:
        up(&mem_ctls_mutex);
-       return rc;
-}
-
-
+       return 0;
 
-static void complete_mc_list_del (struct rcu_head *head)
-{
-       struct mem_ctl_info *mci;
+fail1:
+       del_mc_from_global_list(mci);
 
-       mci = container_of(head, struct mem_ctl_info, rcu);
-       INIT_LIST_HEAD(&mci->link);
-       complete(&mci->complete);
+fail0:
+       up(&mem_ctls_mutex);
+       return 1;
 }
 
-static void del_mc_from_global_list (struct mem_ctl_info *mci)
-{
-       list_del_rcu(&mci->link);
-       init_completion(&mci->complete);
-       call_rcu(&mci->rcu, complete_mc_list_del);
-       wait_for_completion(&mci->complete);
-}
 
 EXPORT_SYMBOL(edac_mc_del_mc);
 
@@ -1498,13 +1527,12 @@ int edac_mc_del_mc(struct mem_ctl_info *mci)
 {
        int rc = 1;
 
-       debugf0("MC%d: " __FILE__ ": %s()\n", mci->mc_idx, __func__);
+       debugf0("MC%d: %s()\n", mci->mc_idx, __func__);
        down(&mem_ctls_mutex);
        del_mc_from_global_list(mci);
-       printk(KERN_INFO
-              "EDAC MC%d: Removed device %d for %s %s: PCI %s\n",
-              mci->mc_idx, mci->mc_idx, mci->mod_name, mci->ctl_name,
-              pci_name(mci->pdev));
+       edac_printk(KERN_INFO, EDAC_MC,
+               "Removed device %d for %s %s: PCI %s\n", mci->mc_idx,
+               mci->mod_name, mci->ctl_name, pci_name(mci->pdev));
        rc = 0;
        up(&mem_ctls_mutex);
 
@@ -1521,7 +1549,7 @@ void edac_mc_scrub_block(unsigned long page, unsigned long offset,
        void *virt_addr;
        unsigned long flags = 0;
 
-       debugf3("MC: " __FILE__ ": %s()\n", __func__);
+       debugf3("%s()\n", __func__);
 
        /* ECC error page was not in our memory. Ignore it. */
        if(!pfn_valid(page))
@@ -1555,8 +1583,7 @@ int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci,
        struct csrow_info *csrows = mci->csrows;
        int row, i;
 
-       debugf1("MC%d: " __FILE__ ": %s(): 0x%lx\n", mci->mc_idx, __func__,
-               page);
+       debugf1("MC%d: %s(): 0x%lx\n", mci->mc_idx, __func__, page);
        row = -1;
 
        for (i = 0; i < mci->nr_csrows; i++) {
@@ -1565,11 +1592,10 @@ int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci,
                if (csrow->nr_pages == 0)
                        continue;
 
-               debugf3("MC%d: " __FILE__
-                       ": %s(): first(0x%lx) page(0x%lx)"
-                       " last(0x%lx) mask(0x%lx)\n", mci->mc_idx,
-                       __func__, csrow->first_page, page,
-                       csrow->last_page, csrow->page_mask);
+               debugf3("MC%d: %s(): first(0x%lx) page(0x%lx) last(0x%lx) "
+                       "mask(0x%lx)\n", mci->mc_idx, __func__,
+                       csrow->first_page, page, csrow->last_page,
+                       csrow->page_mask);
 
                if ((page >= csrow->first_page) &&
                    (page <= csrow->last_page) &&
@@ -1581,9 +1607,9 @@ int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci,
        }
 
        if (row == -1)
-               printk(KERN_ERR
-                      "EDAC MC%d: could not look up page error address %lx\n",
-                      mci->mc_idx, (unsigned long) page);
+               edac_mc_printk(mci, KERN_ERR,
+                       "could not look up page error address %lx\n",
+                       (unsigned long) page);
 
        return row;
 }
@@ -1601,36 +1627,35 @@ void edac_mc_handle_ce(struct mem_ctl_info *mci,
 {
        unsigned long remapped_page;
 
-       debugf3("MC%d: " __FILE__ ": %s()\n", mci->mc_idx, __func__);
+       debugf3("MC%d: %s()\n", mci->mc_idx, __func__);
 
        /* FIXME - maybe make panic on INTERNAL ERROR an option */
        if (row >= mci->nr_csrows || row < 0) {
                /* something is wrong */
-               printk(KERN_ERR
-                      "EDAC MC%d: INTERNAL ERROR: row out of range (%d >= %d)\n",
-                      mci->mc_idx, row, mci->nr_csrows);
+               edac_mc_printk(mci, KERN_ERR,
+                       "INTERNAL ERROR: row out of range "
+                       "(%d >= %d)\n", row, mci->nr_csrows);
                edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR");
                return;
        }
        if (channel >= mci->csrows[row].nr_channels || channel < 0) {
                /* something is wrong */
-               printk(KERN_ERR
-                      "EDAC MC%d: INTERNAL ERROR: channel out of range "
-                      "(%d >= %d)\n",
-                      mci->mc_idx, channel, mci->csrows[row].nr_channels);
+               edac_mc_printk(mci, KERN_ERR,
+                       "INTERNAL ERROR: channel out of range "
+                       "(%d >= %d)\n", channel,
+                       mci->csrows[row].nr_channels);
                edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR");
                return;
        }
 
        if (log_ce)
                /* FIXME - put in DIMM location */
-               printk(KERN_WARNING
-                      "EDAC MC%d: CE page 0x%lx, offset 0x%lx,"
-                      " grain %d, syndrome 0x%lx, row %d, channel %d,"
-                      " label \"%s\": %s\n", mci->mc_idx,
-                      page_frame_number, offset_in_page,
-                      mci->csrows[row].grain, syndrome, row, channel,
-                      mci->csrows[row].channels[channel].label, msg);
+               edac_mc_printk(mci, KERN_WARNING,
+                       "CE page 0x%lx, offset 0x%lx, grain %d, syndrome "
+                       "0x%lx, row %d, channel %d, label \"%s\": %s\n",
+                       page_frame_number, offset_in_page,
+                       mci->csrows[row].grain, syndrome, row, channel,
+                       mci->csrows[row].channels[channel].label, msg);
 
        mci->ce_count++;
        mci->csrows[row].ce_count++;
@@ -1662,9 +1687,8 @@ void edac_mc_handle_ce_no_info(struct mem_ctl_info *mci,
                                    const char *msg)
 {
        if (log_ce)
-               printk(KERN_WARNING
-                      "EDAC MC%d: CE - no information available: %s\n",
-                      mci->mc_idx, msg);
+               edac_mc_printk(mci, KERN_WARNING,
+                       "CE - no information available: %s\n", msg);
        mci->ce_noinfo_count++;
        mci->ce_count++;
 }
@@ -1683,14 +1707,14 @@ void edac_mc_handle_ue(struct mem_ctl_info *mci,
        int chan;
        int chars;
 
-       debugf3("MC%d: " __FILE__ ": %s()\n", mci->mc_idx, __func__);
+       debugf3("MC%d: %s()\n", mci->mc_idx, __func__);
 
        /* FIXME - maybe make panic on INTERNAL ERROR an option */
        if (row >= mci->nr_csrows || row < 0) {
                /* something is wrong */
-               printk(KERN_ERR
-                      "EDAC MC%d: INTERNAL ERROR: row out of range (%d >= %d)\n",
-                      mci->mc_idx, row, mci->nr_csrows);
+               edac_mc_printk(mci, KERN_ERR,
+                       "INTERNAL ERROR: row out of range "
+                       "(%d >= %d)\n", row, mci->nr_csrows);
                edac_mc_handle_ue_no_info(mci, "INTERNAL ERROR");
                return;
        }
@@ -1708,11 +1732,11 @@ void edac_mc_handle_ue(struct mem_ctl_info *mci,
        }
 
        if (log_ue)
-               printk(KERN_EMERG
-                      "EDAC MC%d: UE page 0x%lx, offset 0x%lx, grain %d, row %d,"
-                      " labels \"%s\": %s\n", mci->mc_idx,
-                      page_frame_number, offset_in_page,
-                      mci->csrows[row].grain, row, labels, msg);
+               edac_mc_printk(mci, KERN_EMERG,
+                       "UE page 0x%lx, offset 0x%lx, grain %d, row %d, "
+                       "labels \"%s\": %s\n", page_frame_number,
+                       offset_in_page, mci->csrows[row].grain, row, labels,
+                       msg);
 
        if (panic_on_ue)
                panic
@@ -1735,9 +1759,8 @@ void edac_mc_handle_ue_no_info(struct mem_ctl_info *mci,
                panic("EDAC MC%d: Uncorrected Error", mci->mc_idx);
 
        if (log_ue)
-               printk(KERN_WARNING
-                      "EDAC MC%d: UE - no information available: %s\n",
-                      mci->mc_idx, msg);
+               edac_mc_printk(mci, KERN_WARNING,
+                       "UE - no information available: %s\n", msg);
        mci->ue_noinfo_count++;
        mci->ue_count++;
 }
@@ -1807,25 +1830,22 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
        /* check the status reg for errors */
        if (status) {
                if (status & (PCI_STATUS_SIG_SYSTEM_ERROR))
-                       printk(KERN_CRIT
-                               "EDAC PCI- "
+                       edac_printk(KERN_CRIT, EDAC_PCI,
                                "Signaled System Error on %s\n",
-                               pci_name (dev));
+                               pci_name(dev));
 
                if (status & (PCI_STATUS_PARITY)) {
-                       printk(KERN_CRIT
-                               "EDAC PCI- "
+                       edac_printk(KERN_CRIT, EDAC_PCI,
                                "Master Data Parity Error on %s\n",
-                               pci_name (dev));
+                               pci_name(dev));
 
                        atomic_inc(&pci_parity_count);
                }
 
                if (status & (PCI_STATUS_DETECTED_PARITY)) {
-                       printk(KERN_CRIT
-                               "EDAC PCI- "
+                       edac_printk(KERN_CRIT, EDAC_PCI,
                                "Detected Parity Error on %s\n",
-                               pci_name (dev));
+                               pci_name(dev));
 
                        atomic_inc(&pci_parity_count);
                }
@@ -1846,25 +1866,22 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
                /* check the secondary status reg for errors */
                if (status) {
                        if (status & (PCI_STATUS_SIG_SYSTEM_ERROR))
-                               printk(KERN_CRIT
-                                       "EDAC PCI-Bridge- "
+                               edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
                                        "Signaled System Error on %s\n",
-                                       pci_name (dev));
+                                       pci_name(dev));
 
                        if (status & (PCI_STATUS_PARITY)) {
-                               printk(KERN_CRIT
-                                       "EDAC PCI-Bridge- "
-                                       "Master Data Parity Error on %s\n",
-                                       pci_name (dev));
+                               edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
+                                       "Master Data Parity Error on "
+                                       "%s\n", pci_name(dev));
 
                                atomic_inc(&pci_parity_count);
                        }
 
                        if (status & (PCI_STATUS_DETECTED_PARITY)) {
-                               printk(KERN_CRIT
-                                       "EDAC PCI-Bridge- "
+                               edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
                                        "Detected Parity Error on %s\n",
-                                       pci_name (dev));
+                                       pci_name(dev));
 
                                atomic_inc(&pci_parity_count);
                        }
@@ -1943,7 +1960,7 @@ static void do_pci_parity_check(void)
        unsigned long flags;
        int before_count;
 
-       debugf3("MC: " __FILE__ ": %s()\n", __func__);
+       debugf3("%s()\n", __func__);
 
        if (!check_pci_parity)
                return;
@@ -2001,7 +2018,7 @@ static inline void check_mc_devices (void)
        struct list_head *item;
        struct mem_ctl_info *mci;
 
-       debugf3("MC: " __FILE__ ": %s()\n", __func__);
+       debugf3("%s()\n", __func__);
 
        /* during poll, have interrupts off */
        local_irq_save(flags);
@@ -2027,70 +2044,21 @@ static inline void check_mc_devices (void)
  */
 static void do_edac_check(void)
 {
-
-       debugf3("MC: " __FILE__ ": %s()\n", __func__);
-
+       debugf3("%s()\n", __func__);
        check_mc_devices();
-
        do_pci_parity_check();
 }
 
-
-/*
- * EDAC thread state information
- */
-struct bs_thread_info
-{
-       struct task_struct *task;
-       struct completion *event;
-       char *name;
-       void (*run)(void);
-};
-
-static struct bs_thread_info bs_thread;
-
-/*
- *  edac_kernel_thread
- *      This the kernel thread that processes edac operations
- *      in a normal thread environment
- */
 static int edac_kernel_thread(void *arg)
 {
-       struct bs_thread_info *thread = (struct bs_thread_info *) arg;
-
-       /* detach thread */
-       daemonize(thread->name);
-
-       current->exit_signal = SIGCHLD;
-       allow_signal(SIGKILL);
-       thread->task = current;
-
-       /* indicate to starting task we have started */
-       complete(thread->event);
-
-       /* loop forever, until we are told to stop */
-       while(thread->run != NULL) {
-               void (*run)(void);
-
-               /* call the function to check the memory controllers */
-               run = thread->run;
-               if (run)
-                       run();
-
-               if (signal_pending(current))
-                       flush_signals(current);
-
-               /* ensure we are interruptable */
-               set_current_state(TASK_INTERRUPTIBLE);
+       while (!kthread_should_stop()) {
+               do_edac_check();
 
                /* goto sleep for the interval */
-               schedule_timeout((HZ * poll_msec) / 1000);
+               schedule_timeout_interruptible((HZ * poll_msec) / 1000);
                try_to_freeze();
        }
 
-       /* notify waiter that we are exiting */
-       complete(thread->event);
-
        return 0;
 }
 
@@ -2100,10 +2068,7 @@ static int edac_kernel_thread(void *arg)
  */
 static int __init edac_mc_init(void)
 {
-       int ret;
-       struct completion event;
-
-       printk(KERN_INFO "MC: " __FILE__ " version " EDAC_MC_VERSION "\n");
+       edac_printk(KERN_INFO, EDAC_MC, EDAC_MC_VERSION "\n");
 
        /*
         * Harvest and clear any boot/initialization PCI parity errors
@@ -2114,40 +2079,30 @@ static int __init edac_mc_init(void)
         */
        clear_pci_parity_errors();
 
-       /* perform check for first time to harvest boot leftovers */
-       do_edac_check();
-
        /* Create the MC sysfs entires */
        if (edac_sysfs_memctrl_setup()) {
-               printk(KERN_ERR "EDAC MC: Error initializing sysfs code\n");
+               edac_printk(KERN_ERR, EDAC_MC,
+                       "Error initializing sysfs code\n");
                return -ENODEV;
        }
 
        /* Create the PCI parity sysfs entries */
        if (edac_sysfs_pci_setup()) {
                edac_sysfs_memctrl_teardown();
-               printk(KERN_ERR "EDAC PCI: Error initializing sysfs code\n");
+               edac_printk(KERN_ERR, EDAC_MC,
+                       "EDAC PCI: Error initializing sysfs code\n");
                return -ENODEV;
        }
 
-       /* Create our kernel thread */
-       init_completion(&event);
-       bs_thread.event = &event;
-       bs_thread.name = "kedac";
-       bs_thread.run = do_edac_check;
-
        /* create our kernel thread */
-       ret = kernel_thread(edac_kernel_thread, &bs_thread, CLONE_KERNEL);
-       if (ret < 0) {
+       edac_thread = kthread_run(edac_kernel_thread, NULL, "kedac");
+       if (IS_ERR(edac_thread)) {
                /* remove the sysfs entries */
                edac_sysfs_memctrl_teardown();
                edac_sysfs_pci_teardown();
-               return -ENOMEM;
+               return PTR_ERR(edac_thread);
        }
 
-       /* wait for our kernel theard ack that it is up and running */
-       wait_for_completion(&event);
-
        return 0;
 }
 
@@ -2158,21 +2113,9 @@ static int __init edac_mc_init(void)
  */
 static void __exit edac_mc_exit(void)
 {
-       struct completion event;
-
-       debugf0("MC: " __FILE__ ": %s()\n", __func__);
-
-       init_completion(&event);
-       bs_thread.event = &event;
+       debugf0("%s()\n", __func__);
 
-       /* As soon as ->run is set to NULL, the task could disappear,
-        * so we need to hold tasklist_lock until we have sent the signal
-        */
-       read_lock(&tasklist_lock);
-       bs_thread.run = NULL;
-       send_sig(SIGKILL, bs_thread.task, 1);
-       read_unlock(&tasklist_lock);
-       wait_for_completion(&event);
+       kthread_stop(edac_thread);
 
         /* tear down the sysfs device */
        edac_sysfs_memctrl_teardown();