#include <linux/module.h>
#include <linux/i2o.h>
-#include <linux/delay.h>
/* Exec OSM functions */
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);
if (!rc)
break;
- ssleep(1);
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule_timeout(HZ);
}
if (!rc)
* 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;
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;
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
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);