Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
[safe/jmp/linux-2.6] / drivers / message / i2o / exec-osm.c
index 9e529d8..06c655c 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.
@@ -41,8 +41,6 @@
 
 struct i2o_driver i2o_exec_driver;
 
-static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind);
-
 /* global wait list for POST WAIT */
 static LIST_HEAD(i2o_exec_wait_list);
 
@@ -94,8 +92,8 @@ static struct i2o_exec_wait *i2o_exec_wait_alloc(void)
 };
 
 /**
- *     i2o_exec_wait_free - Free a i2o_exec_wait struct
- *     @i2o_exec_wait: I2O wait data which should be cleaned up
+ *     i2o_exec_wait_free - Free an i2o_exec_wait struct
+ *     @wait: I2O wait data which should be cleaned up
  */
 static void i2o_exec_wait_free(struct i2o_exec_wait *wait)
 {
@@ -105,7 +103,7 @@ static void i2o_exec_wait_free(struct i2o_exec_wait *wait)
 /**
  *     i2o_msg_post_wait_mem - Post and wait a message with DMA buffers
  *     @c: controller
- *     @m: message to post
+ *     @msg: message to post
  *     @timeout: time in seconds to wait
  *     @dma: i2o_dma struct of the DMA buffer to free on failure
  *
@@ -131,8 +129,10 @@ int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg,
        int rc = 0;
 
        wait = i2o_exec_wait_alloc();
-       if (!wait)
+       if (!wait) {
+               i2o_msg_nop(c, msg);
                return -ENOMEM;
+       }
 
        if (tcntxt == 0xffffffff)
                tcntxt = 0x80000000;
@@ -269,6 +269,7 @@ static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m,
 /**
  *     i2o_exec_show_vendor_id - Displays Vendor ID of controller
  *     @d: device of which the Vendor ID should be displayed
+ *     @attr: device_attribute to display
  *     @buf: buffer into which the Vendor ID should be printed
  *
  *     Returns number of bytes printed into buffer.
@@ -290,6 +291,7 @@ static ssize_t i2o_exec_show_vendor_id(struct device *d,
 /**
  *     i2o_exec_show_product_id - Displays Product ID of controller
  *     @d: device of which the Product ID should be displayed
+ *     @attr: device_attribute to display
  *     @buf: buffer into which the Product ID should be printed
  *
  *     Returns number of bytes printed into buffer.
@@ -335,6 +337,8 @@ static int i2o_exec_probe(struct device *dev)
        rc = device_create_file(dev, &dev_attr_product_id);
        if (rc) goto err_vid;
 
+       i2o_dev->iop->exec = i2o_dev;
+
        return 0;
 
 err_vid:
@@ -363,9 +367,56 @@ static int i2o_exec_remove(struct device *dev)
        return 0;
 };
 
+#ifdef CONFIG_I2O_LCT_NOTIFY_ON_CHANGES
+/**
+ *     i2o_exec_lct_notify - Send a asynchronus LCT NOTIFY request
+ *     @c: I2O controller to which the request should be send
+ *     @change_ind: change indicator
+ *
+ *     This function sends a LCT NOTIFY request to the I2O controller with
+ *     the change indicator change_ind. If the change_ind == 0 the controller
+ *     replies immediately after the request. If change_ind > 0 the reply is
+ *     send after change indicator of the LCT is > change_ind.
+ */
+static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind)
+{
+       i2o_status_block *sb = c->status_block.virt;
+       struct device *dev;
+       struct i2o_message *msg;
+
+       mutex_lock(&c->lct_lock);
+
+       dev = &c->pdev->dev;
+
+       if (i2o_dma_realloc(dev, &c->dlct,
+                                       le32_to_cpu(sb->expected_lct_size)))
+               return -ENOMEM;
+
+       msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
+       if (IS_ERR(msg))
+               return PTR_ERR(msg);
+
+       msg->u.head[0] = cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6);
+       msg->u.head[1] = cpu_to_le32(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 |
+                                    ADAPTER_TID);
+       msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context);
+       msg->u.s.tcntxt = cpu_to_le32(0x00000000);
+       msg->body[0] = cpu_to_le32(0xffffffff);
+       msg->body[1] = cpu_to_le32(change_ind);
+       msg->body[2] = cpu_to_le32(0xd0000000 | c->dlct.len);
+       msg->body[3] = cpu_to_le32(c->dlct.phys);
+
+       i2o_msg_post(c, msg);
+
+       mutex_unlock(&c->lct_lock);
+
+       return 0;
+}
+#endif
+
 /**
  *     i2o_exec_lct_modified - Called on LCT NOTIFY reply
- *     @c: I2O controller on which the LCT has modified
+ *     @_work: work struct for a specific controller
  *
  *     This function handles asynchronus LCT NOTIFY replies. It parses the
  *     new LCT and if the buffer for the LCT was to small sends a LCT NOTIFY
@@ -519,51 +570,6 @@ int i2o_exec_lct_get(struct i2o_controller *c)
        return rc;
 }
 
-/**
- *     i2o_exec_lct_notify - Send a asynchronus LCT NOTIFY request
- *     @c: I2O controller to which the request should be send
- *     @change_ind: change indicator
- *
- *     This function sends a LCT NOTIFY request to the I2O controller with
- *     the change indicator change_ind. If the change_ind == 0 the controller
- *     replies immediately after the request. If change_ind > 0 the reply is
- *     send after change indicator of the LCT is > change_ind.
- */
-static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind)
-{
-       i2o_status_block *sb = c->status_block.virt;
-       struct device *dev;
-       struct i2o_message *msg;
-
-       down(&c->lct_lock);
-
-       dev = &c->pdev->dev;
-
-       if (i2o_dma_realloc
-           (dev, &c->dlct, le32_to_cpu(sb->expected_lct_size), GFP_KERNEL))
-               return -ENOMEM;
-
-       msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
-       if (IS_ERR(msg))
-               return PTR_ERR(msg);
-
-       msg->u.head[0] = cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6);
-       msg->u.head[1] = cpu_to_le32(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 |
-                                    ADAPTER_TID);
-       msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context);
-       msg->u.s.tcntxt = cpu_to_le32(0x00000000);
-       msg->body[0] = cpu_to_le32(0xffffffff);
-       msg->body[1] = cpu_to_le32(change_ind);
-       msg->body[2] = cpu_to_le32(0xd0000000 | c->dlct.len);
-       msg->body[3] = cpu_to_le32(c->dlct.phys);
-
-       i2o_msg_post(c, msg);
-
-       up(&c->lct_lock);
-
-       return 0;
-};
-
 /* Exec OSM driver struct */
 struct i2o_driver i2o_exec_driver = {
        .name = OSM_NAME,
@@ -593,7 +599,7 @@ int __init i2o_exec_init(void)
  *
  *     Unregisters the Exec OSM from the I2O core.
  */
-void __exit i2o_exec_exit(void)
+void i2o_exec_exit(void)
 {
        i2o_driver_unregister(&i2o_exec_driver);
 };