include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / edac / edac_pci_sysfs.c
index 834eaa9..c39697d 100644 (file)
@@ -8,6 +8,7 @@
  */
 #include <linux/module.h>
 #include <linux/sysdev.h>
+#include <linux/slab.h>
 #include <linux/ctype.h>
 
 #include "edac_core.h"
@@ -28,7 +29,7 @@ static int edac_pci_poll_msec = 1000; /* one second workq period */
 static atomic_t pci_parity_count = ATOMIC_INIT(0);
 static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
 
-static struct kobject edac_pci_top_main_kobj;
+static struct kobject *edac_pci_top_main_kobj;
 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
 
 /* getter functions for the data variables */
@@ -37,17 +38,17 @@ int edac_pci_get_check_errors(void)
        return check_pci_errors;
 }
 
-int edac_pci_get_log_pe(void)
+static int edac_pci_get_log_pe(void)
 {
        return edac_pci_log_pe;
 }
 
-int edac_pci_get_log_npe(void)
+static int edac_pci_get_log_npe(void)
 {
        return edac_pci_log_npe;
 }
 
-int edac_pci_get_panic_on_pe(void)
+static int edac_pci_get_panic_on_pe(void)
 {
        return edac_pci_panic_on_pe;
 }
@@ -83,7 +84,7 @@ static void edac_pci_instance_release(struct kobject *kobj)
        pci = to_instance(kobj);
 
        /* decrement reference count on top main kobj */
-       kobject_put(&edac_pci_top_main_kobj);
+       kobject_put(edac_pci_top_main_kobj);
 
        kfree(pci);     /* Free the control struct */
 }
@@ -121,7 +122,7 @@ static ssize_t edac_pci_instance_store(struct kobject *kobj,
 }
 
 /* fs_ops table */
-static struct sysfs_ops pci_instance_ops = {
+static const struct sysfs_ops pci_instance_ops = {
        .show = edac_pci_instance_show,
        .store = edac_pci_instance_store
 };
@@ -166,7 +167,7 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
         * track the number of PCI instances we have, and thus nest
         * properly on keeping the module loaded
         */
-       main_kobj = kobject_get(&edac_pci_top_main_kobj);
+       main_kobj = kobject_get(edac_pci_top_main_kobj);
        if (!main_kobj) {
                err = -ENODEV;
                goto error_out;
@@ -174,11 +175,11 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
 
        /* And now register this new kobject under the main kobj */
        err = kobject_init_and_add(&pci->kobj, &ktype_pci_instance,
-                                  &edac_pci_top_main_kobj, "pci%d", idx);
+                                  edac_pci_top_main_kobj, "pci%d", idx);
        if (err != 0) {
                debugf2("%s() failed to register instance pci%d\n",
                        __func__, idx);
-               kobject_put(&edac_pci_top_main_kobj);
+               kobject_put(edac_pci_top_main_kobj);
                goto error_out;
        }
 
@@ -197,7 +198,8 @@ error_out:
  *
  *     unregister the kobj for the EDAC PCI instance
  */
-void edac_pci_unregister_sysfs_instance_kobj(struct edac_pci_ctl_info *pci)
+static void edac_pci_unregister_sysfs_instance_kobj(
+                       struct edac_pci_ctl_info *pci)
 {
        debugf0("%s()\n", __func__);
 
@@ -205,7 +207,7 @@ void edac_pci_unregister_sysfs_instance_kobj(struct edac_pci_ctl_info *pci)
         * function release the main reference count and then
         * kfree the memory
         */
-       kobject_unregister(&pci->kobj);
+       kobject_put(&pci->kobj);
 }
 
 /***************************** EDAC PCI sysfs root **********************/
@@ -260,7 +262,7 @@ static ssize_t edac_pci_dev_store(struct kobject *kobj,
        return -EIO;
 }
 
-static struct sysfs_ops edac_pci_sysfs_ops = {
+static const struct sysfs_ops edac_pci_sysfs_ops = {
        .show = edac_pci_dev_show,
        .store = edac_pci_dev_store
 };
@@ -315,9 +317,10 @@ static struct edac_pci_dev_attribute *edac_pci_attr[] = {
  */
 static void edac_pci_release_main_kobj(struct kobject *kobj)
 {
-
        debugf0("%s() here to module_put(THIS_MODULE)\n", __func__);
 
+       kfree(kobj);
+
        /* last reference to top EDAC PCI kobject has been removed,
         * NOW release our ref count on the core module
         */
@@ -337,7 +340,7 @@ static struct kobj_type ktype_edac_pci_main_kobj = {
  *     setup the sysfs for EDAC PCI attributes
  *     assumes edac_class has already been initialized
  */
-int edac_pci_main_kobj_setup(void)
+static int edac_pci_main_kobj_setup(void)
 {
        int err;
        struct sysdev_class *edac_class;
@@ -368,8 +371,16 @@ int edac_pci_main_kobj_setup(void)
                goto decrement_count_fail;
        }
 
+       edac_pci_top_main_kobj = kzalloc(sizeof(struct kobject), GFP_KERNEL);
+       if (!edac_pci_top_main_kobj) {
+               debugf1("Failed to allocate\n");
+               err = -ENOMEM;
+               goto kzalloc_fail;
+       }
+
        /* Instanstiate the pci object */
-       err = kobject_init_and_add(&edac_pci_top_main_kobj, &ktype_edac_pci_main_kobj,
+       err = kobject_init_and_add(edac_pci_top_main_kobj,
+                                  &ktype_edac_pci_main_kobj,
                                   &edac_class->kset.kobj, "pci");
        if (err) {
                debugf1("Failed to register '.../edac/pci'\n");
@@ -380,13 +391,16 @@ int edac_pci_main_kobj_setup(void)
         * for EDAC PCI, then edac_pci_main_kobj_teardown()
         * must be used, for resources to be cleaned up properly
         */
-       kobject_uevent(&edac_pci_top_main_kobj, KOBJ_ADD);
+       kobject_uevent(edac_pci_top_main_kobj, KOBJ_ADD);
        debugf1("Registered '.../edac/pci' kobject\n");
 
        return 0;
 
        /* Error unwind statck */
 kobject_init_and_add_fail:
+       kfree(edac_pci_top_main_kobj);
+
+kzalloc_fail:
        module_put(THIS_MODULE);
 
 decrement_count_fail:
@@ -411,9 +425,9 @@ static void edac_pci_main_kobj_teardown(void)
         * main kobj
         */
        if (atomic_dec_return(&edac_pci_sysfs_refcount) == 0) {
-               debugf0("%s() called kobject_unregister on main kobj\n",
+               debugf0("%s() called kobject_put on main kobj\n",
                        __func__);
-               kobject_unregister(&edac_pci_top_main_kobj);
+               kobject_put(edac_pci_top_main_kobj);
        }
 }
 
@@ -521,8 +535,6 @@ static void edac_pci_dev_parity_clear(struct pci_dev *dev)
 {
        u8 header_type;
 
-       debugf0("%s()\n", __func__);
-
        get_pci_parity_status(dev, 0);
 
        /* read the device TYPE, looking for bridges */
@@ -556,10 +568,12 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
 
        local_irq_restore(flags);
 
-       debugf4("PCI STATUS= 0x%04x %s\n", status, dev->dev.bus_id);
+       debugf4("PCI STATUS= 0x%04x %s\n", status, dev_name(&dev->dev));
 
-       /* check the status reg for errors */
-       if (status) {
+       /* check the status reg for errors on boards NOT marked as broken
+        * if broken, we cannot trust any of the status bits
+        */
+       if (status && !dev->broken_parity_status) {
                if (status & (PCI_STATUS_SIG_SYSTEM_ERROR)) {
                        edac_printk(KERN_CRIT, EDAC_PCI,
                                "Signaled System Error on %s\n",
@@ -585,16 +599,18 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
        }
 
 
-       debugf4("PCI HEADER TYPE= 0x%02x %s\n", header_type, dev->dev.bus_id);
+       debugf4("PCI HEADER TYPE= 0x%02x %s\n", header_type, dev_name(&dev->dev));
 
        if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
                /* On bridges, need to examine secondary status register  */
                status = get_pci_parity_status(dev, 1);
 
-               debugf4("PCI SEC_STATUS= 0x%04x %s\n", status, dev->dev.bus_id);
+               debugf4("PCI SEC_STATUS= 0x%04x %s\n", status, dev_name(&dev->dev));
 
-               /* check the secondary status reg for errors */
-               if (status) {
+               /* check the secondary status reg for errors,
+                * on NOT broken boards
+                */
+               if (status && !dev->broken_parity_status) {
                        if (status & (PCI_STATUS_SIG_SYSTEM_ERROR)) {
                                edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
                                        "Signaled System Error on %s\n",