include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / message / i2o / iop.c
index f86abb4..090d2a3 100644 (file)
  *
  *     Fixes/additions:
  *             Philipp Rumpf
- *             Juha Sievänen <Juha.Sievanen@cs.Helsinki.FI>
- *             Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI>
+ *             Juha Sievänen <Juha.Sievanen@cs.Helsinki.FI>
+ *             Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI>
  *             Deepak Saxena <deepak@plexity.net>
  *             Boji T Kannanthanam <boji.t.kannanthanam@intel.com>
- *             Alan Cox <alan@redhat.com>:
+ *             Alan Cox <alan@lxorguk.ukuu.org.uk>:
  *                     Ported to Linux 2.5.
  *             Markus Lidel <Markus.Lidel@shadowconnect.com>:
  *                     Minor fixes for 2.6.
 #include <linux/i2o.h>
 #include <linux/delay.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include "core.h"
 
 #define OSM_NAME       "i2o"
-#define OSM_VERSION    "1.288"
+#define OSM_VERSION    "1.325"
 #define OSM_DESCRIPTION        "I2O subsystem"
 
 /* global I2O controller list */
@@ -49,7 +50,6 @@ static int i2o_hrt_get(struct i2o_controller *c);
 /**
  *     i2o_msg_get_wait - obtain an I2O message from the IOP
  *     @c: I2O controller
- *     @msg: pointer to a I2O message pointer
  *     @wait: how long to wait until timeout
  *
  *     This function waits up to wait seconds for a message slot to be
@@ -133,7 +133,7 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
  *     Removes a previously added pointer from the context list and returns
  *     the matching context id.
  *
- *     Returns context id on succes or 0 on failure.
+ *     Returns context id on success or 0 on failure.
  */
 u32 i2o_cntxt_list_remove(struct i2o_controller * c, void *ptr)
 {
@@ -199,7 +199,7 @@ void *i2o_cntxt_list_get(struct i2o_controller *c, u32 context)
  *     @c: controller to which the context list belong
  *     @ptr: pointer to which the context id should be fetched
  *
- *     Returns context id which matches to the pointer on succes or 0 on
+ *     Returns context id which matches to the pointer on success or 0 on
  *     failure.
  */
 u32 i2o_cntxt_list_get_ptr(struct i2o_controller * c, void *ptr)
@@ -540,7 +540,7 @@ static int i2o_iop_reset(struct i2o_controller *c)
                 * which is indeterminate. We need to wait until the IOP has
                 * rebooted before we can let the system talk to it. We read
                 * the inbound Free_List until a message is available. If we
-                * can't read one in the given ammount of time, we assume the
+                * can't read one in the given amount of time, we assume the
                 * IOP could not reboot properly.
                 */
                osm_debug("%s: Reset in progress, waiting for reboot...\n",
@@ -683,9 +683,10 @@ static int i2o_iop_systab_set(struct i2o_controller *c)
                        c->mem_alloc = 1;
                        sb->current_mem_size = 1 + res->end - res->start;
                        sb->current_mem_base = res->start;
-                       osm_info("%s: allocated %ld bytes of PCI memory at "
-                                "0x%08lX.\n", c->name,
-                                1 + res->end - res->start, res->start);
+                       osm_info("%s: allocated %llu bytes of PCI memory at "
+                               "0x%016llX.\n", c->name,
+                               (unsigned long long)(1 + res->end - res->start),
+                               (unsigned long long)res->start);
                }
        }
 
@@ -704,9 +705,10 @@ static int i2o_iop_systab_set(struct i2o_controller *c)
                        c->io_alloc = 1;
                        sb->current_io_size = 1 + res->end - res->start;
                        sb->current_mem_base = res->start;
-                       osm_info("%s: allocated %ld bytes of PCI I/O at 0x%08lX"
-                                ".\n", c->name, 1 + res->end - res->start,
-                                res->start);
+                       osm_info("%s: allocated %llu bytes of PCI I/O at "
+                               "0x%016llX.\n", c->name,
+                               (unsigned long long)(1 + res->end - res->start),
+                               (unsigned long long)res->start);
                }
        }
 
@@ -730,10 +732,6 @@ static int i2o_iop_systab_set(struct i2o_controller *c)
         * Provide three SGL-elements:
         * System table (SysTab), Private memory space declaration and
         * Private i/o space declaration
-        *
-        * FIXME: is this still true?
-        * Nasty one here. We can't use dma_alloc_coherent to send the
-        * same table to everyone. We have to go remap it for them all
         */
 
        msg->body[0] = cpu_to_le32(c->unit + 2);
@@ -756,8 +754,6 @@ static int i2o_iop_systab_set(struct i2o_controller *c)
        else
                osm_debug("%s: SysTab set.\n", c->name);
 
-       i2o_status_get(c);      // Entered READY state
-
        return rc;
 }
 
@@ -767,7 +763,7 @@ static int i2o_iop_systab_set(struct i2o_controller *c)
  *
  *     Send the system table and enable the I2O controller.
  *
- *     Returns 0 on success or negativer error code on failure.
+ *     Returns 0 on success or negative error code on failure.
  */
 static int i2o_iop_online(struct i2o_controller *c)
 {
@@ -806,13 +802,10 @@ void i2o_iop_remove(struct i2o_controller *c)
        list_for_each_entry_safe(dev, tmp, &c->devices, list)
            i2o_device_remove(dev);
 
-       class_device_unregister(c->classdev);
        device_del(&c->device);
 
        /* Ask the IOP to switch to RESET state */
        i2o_iop_reset(c);
-
-       put_device(&c->device);
 }
 
 /**
@@ -845,12 +838,11 @@ static int i2o_systab_build(void)
        i2o_systab.len = sizeof(struct i2o_sys_tbl) + num_controllers *
            sizeof(struct i2o_sys_tbl_entry);
 
-       systab = i2o_systab.virt = kmalloc(i2o_systab.len, GFP_KERNEL);
+       systab = i2o_systab.virt = kzalloc(i2o_systab.len, GFP_KERNEL);
        if (!systab) {
                osm_err("unable to allocate memory for System Table\n");
                return -ENOMEM;
        }
-       memset(systab, 0, i2o_systab.len);
 
        systab->version = I2OVERSION;
        systab->change_ind = change_ind + 1;
@@ -924,7 +916,7 @@ static int i2o_parse_hrt(struct i2o_controller *c)
  *     status block. The status block could then be accessed through
  *     c->status_block.
  *
- *     Returns 0 on sucess or negative error code on failure.
+ *     Returns 0 on success or negative error code on failure.
  */
 int i2o_status_get(struct i2o_controller *c)
 {
@@ -978,7 +970,7 @@ int i2o_status_get(struct i2o_controller *c)
  *     The HRT contains information about possible hidden devices but is
  *     mostly useless to us.
  *
- *     Returns 0 on success or negativer error code on failure.
+ *     Returns 0 on success or negative error code on failure.
  */
 static int i2o_hrt_get(struct i2o_controller *c)
 {
@@ -1012,7 +1004,7 @@ static int i2o_hrt_get(struct i2o_controller *c)
 
                size = hrt->num_entries * hrt->entry_len << 2;
                if (size > c->hrt.len) {
-                       if (i2o_dma_realloc(dev, &c->hrt, size, GFP_KERNEL))
+                       if (i2o_dma_realloc(dev, &c->hrt, size))
                                return -ENOMEM;
                        else
                                hrt = c->hrt.virt;
@@ -1027,16 +1019,6 @@ static int i2o_hrt_get(struct i2o_controller *c)
 }
 
 /**
- *     i2o_iop_free - Free the i2o_controller struct
- *     @c: I2O controller to free
- */
-void i2o_iop_free(struct i2o_controller *c)
-{
-       i2o_pool_free(&c->in_msg);
-       kfree(c);
-};
-
-/**
  *     i2o_iop_release - release the memory for a I2O controller
  *     @dev: I2O controller which should be released
  *
@@ -1050,9 +1032,6 @@ static void i2o_iop_release(struct device *dev)
        i2o_iop_free(c);
 };
 
-/* I2O controller class */
-static struct class *i2o_controller_class;
-
 /**
  *     i2o_iop_alloc - Allocate and initialize a i2o_controller struct
  *
@@ -1068,20 +1047,19 @@ struct i2o_controller *i2o_iop_alloc(void)
        struct i2o_controller *c;
        char poolname[32];
 
-       c = kmalloc(sizeof(*c), GFP_KERNEL);
+       c = kzalloc(sizeof(*c), GFP_KERNEL);
        if (!c) {
                osm_err("i2o: Insufficient memory to allocate a I2O controller."
                        "\n");
                return ERR_PTR(-ENOMEM);
        }
-       memset(c, 0, sizeof(*c));
 
        c->unit = unit++;
        sprintf(c->name, "iop%d", c->unit);
 
        snprintf(poolname, sizeof(poolname), "i2o_%s_msg_inpool", c->name);
        if (i2o_pool_alloc
-           (&c->in_msg, poolname, I2O_INBOUND_MSG_FRAME_SIZE * 4,
+           (&c->in_msg, poolname, I2O_INBOUND_MSG_FRAME_SIZE * 4 + sizeof(u32),
             I2O_MSG_INPOOL_MIN)) {
                kfree(c);
                return ERR_PTR(-ENOMEM);
@@ -1089,13 +1067,13 @@ struct i2o_controller *i2o_iop_alloc(void)
 
        INIT_LIST_HEAD(&c->devices);
        spin_lock_init(&c->lock);
-       init_MUTEX(&c->lct_lock);
+       mutex_init(&c->lct_lock);
 
        device_initialize(&c->device);
 
        c->device.release = &i2o_iop_release;
 
-       snprintf(c->device.bus_id, BUS_ID_SIZE, "iop%d", c->unit);
+       dev_set_name(&c->device, "iop%d", c->unit);
 
 #if BITS_PER_LONG == 64
        spin_lock_init(&c->context_list_lock);
@@ -1124,36 +1102,29 @@ int i2o_iop_add(struct i2o_controller *c)
                goto iop_reset;
        }
 
-       c->classdev = class_device_create(i2o_controller_class, NULL, MKDEV(0,0),
-                       &c->device, "iop%d", c->unit);
-       if (IS_ERR(c->classdev)) {
-               osm_err("%s: could not add controller class\n", c->name);
-               goto device_del;
-       }
-
        osm_info("%s: Activating I2O controller...\n", c->name);
        osm_info("%s: This may take a few minutes if there are many devices\n",
                 c->name);
 
        if ((rc = i2o_iop_activate(c))) {
                osm_err("%s: could not activate controller\n", c->name);
-               goto class_del;
+               goto device_del;
        }
 
        osm_debug("%s: building sys table...\n", c->name);
 
        if ((rc = i2o_systab_build()))
-               goto class_del;
+               goto device_del;
 
        osm_debug("%s: online controller...\n", c->name);
 
        if ((rc = i2o_iop_online(c)))
-               goto class_del;
+               goto device_del;
 
        osm_debug("%s: getting LCT...\n", c->name);
 
        if ((rc = i2o_exec_lct_get(c)))
-               goto class_del;
+               goto device_del;
 
        list_add(&c->list, &i2o_controllers);
 
@@ -1163,9 +1134,6 @@ int i2o_iop_add(struct i2o_controller *c)
 
        return 0;
 
-      class_del:
-       class_device_unregister(c->classdev);
-
       device_del:
        device_del(&c->device);
 
@@ -1225,14 +1193,8 @@ static int __init i2o_iop_init(void)
 
        printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
 
-       i2o_controller_class = class_create(THIS_MODULE, "i2o_controller");
-       if (IS_ERR(i2o_controller_class)) {
-               osm_err("can't register class i2o_controller\n");
-               goto exit;
-       }
-
        if ((rc = i2o_driver_init()))
-               goto class_exit;
+               goto exit;
 
        if ((rc = i2o_exec_init()))
                goto driver_exit;
@@ -1248,9 +1210,6 @@ static int __init i2o_iop_init(void)
       driver_exit:
        i2o_driver_exit();
 
-      class_exit:
-       class_destroy(i2o_controller_class);
-
       exit:
        return rc;
 }
@@ -1265,7 +1224,6 @@ static void __exit i2o_iop_exit(void)
        i2o_pci_exit();
        i2o_exec_exit();
        i2o_driver_exit();
-       class_destroy(i2o_controller_class);
 };
 
 module_init(i2o_iop_init);
@@ -1283,7 +1241,6 @@ EXPORT_SYMBOL(i2o_cntxt_list_remove);
 EXPORT_SYMBOL(i2o_cntxt_list_get_ptr);
 #endif
 EXPORT_SYMBOL(i2o_msg_get_wait);
-EXPORT_SYMBOL(i2o_msg_nop);
 EXPORT_SYMBOL(i2o_find_iop);
 EXPORT_SYMBOL(i2o_iop_find_device);
 EXPORT_SYMBOL(i2o_event_register);