This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / drivers / message / i2o / device.c
index e4f9235..ff4822e 100644 (file)
@@ -15,7 +15,6 @@
 
 #include <linux/module.h>
 #include <linux/i2o.h>
-#include <linux/delay.h>
 
 /* Exec OSM functions */
 extern struct bus_type i2o_bus_type;
@@ -35,7 +34,7 @@ extern struct bus_type i2o_bus_type;
 static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd,
                                         u32 type)
 {
-       struct i2o_message __iomem *msg;
+       struct i2o_message *msg;
        u32 m;
 
        m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET);
@@ -107,7 +106,8 @@ int i2o_device_claim_release(struct i2o_device *dev)
                if (!rc)
                        break;
 
-               ssleep(1);
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(HZ);
        }
 
        if (!rc)
@@ -211,8 +211,8 @@ static struct i2o_device *i2o_device_alloc(void)
  *     Returns a pointer to the I2O device on success or negative error code
  *     on failure.
  */
-static struct i2o_device *i2o_device_add(struct i2o_controller *c,
-                                        i2o_lct_entry * entry)
+struct i2o_device *i2o_device_add(struct i2o_controller *c,
+                                 i2o_lct_entry * entry)
 {
        struct i2o_device *dev;
 
@@ -446,7 +446,7 @@ static struct class_interface i2o_device_class_interface = {
 int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist,
                   int oplen, void *reslist, int reslen)
 {
-       struct i2o_message __iomem *msg;
+       struct i2o_message *msg;
        u32 m;
        u32 *res32 = (u32 *) reslist;
        u32 *restmp = (u32 *) reslist;
@@ -546,6 +546,47 @@ int i2o_parm_field_get(struct i2o_device *i2o_dev, int group, int field,
        return size;
 }
 
+/*
+ *     Set a scalar group value or a whole group.
+ */
+int i2o_parm_field_set(struct i2o_device *i2o_dev, int group, int field,
+                      void *buf, int buflen)
+{
+       u16 *opblk;
+       u8 resblk[8 + buflen];  /* 8 bytes for header */
+       int size;
+
+       opblk = kmalloc(buflen + 64, GFP_KERNEL);
+       if (opblk == NULL) {
+               printk(KERN_ERR "i2o: no memory for operation buffer.\n");
+               return -ENOMEM;
+       }
+
+       opblk[0] = 1;           /* operation count */
+       opblk[1] = 0;           /* pad */
+       opblk[2] = I2O_PARAMS_FIELD_SET;
+       opblk[3] = group;
+
+       if (field == -1) {      /* whole group */
+               opblk[4] = -1;
+               memcpy(opblk + 5, buf, buflen);
+       } else {                /* single field */
+
+               opblk[4] = 1;
+               opblk[5] = field;
+               memcpy(opblk + 6, buf, buflen);
+       }
+
+       size = i2o_parm_issue(i2o_dev, I2O_CMD_UTIL_PARAMS_SET, opblk,
+                             12 + buflen, resblk, sizeof(resblk));
+
+       kfree(opblk);
+       if (size > buflen)
+               return buflen;
+
+       return size;
+}
+
 /*
  *     if oper == I2O_PARAMS_TABLE_GET, get from all rows
  *             if fieldcount == -1 return all fields
@@ -628,5 +669,6 @@ void i2o_device_exit(void)
 EXPORT_SYMBOL(i2o_device_claim);
 EXPORT_SYMBOL(i2o_device_claim_release);
 EXPORT_SYMBOL(i2o_parm_field_get);
+EXPORT_SYMBOL(i2o_parm_field_set);
 EXPORT_SYMBOL(i2o_parm_table_get);
 EXPORT_SYMBOL(i2o_parm_issue);