2 * I2O Configuration Interface Driver
4 * (C) Copyright 1999-2002 Red Hat
6 * Written by Alan Cox, Building Number Three Ltd
9 * Deepak Saxena (04/20/1999):
10 * Added basic ioctl() support
11 * Deepak Saxena (06/07/1999):
12 * Added software download ioctl (still testing)
13 * Auvo Häkkinen (09/10/1999):
14 * Changes to i2o_cfg_reply(), ioctl_parms()
15 * Added ioct_validate()
16 * Taneli Vähäkangas (09/30/1999):
18 * Taneli Vähäkangas (10/04/1999):
19 * Changed ioctl_swdl(), implemented ioctl_swul() and ioctl_swdel()
20 * Deepak Saxena (11/18/1999):
21 * Added event managmenet support
22 * Alan Cox <alan@redhat.com>:
23 * 2.4 rewrite ported to 2.5
24 * Markus Lidel <Markus.Lidel@shadowconnect.com>:
25 * Added pass-thru support for Adaptec's raidutils
27 * This program is free software; you can redistribute it and/or
28 * modify it under the terms of the GNU General Public License
29 * as published by the Free Software Foundation; either version
30 * 2 of the License, or (at your option) any later version.
33 #include <linux/miscdevice.h>
34 #include <linux/smp_lock.h>
35 #include <linux/compat.h>
37 #include <asm/uaccess.h>
39 extern int i2o_parm_issue(struct i2o_device *, int, void *, int, void *, int);
41 static int i2o_cfg_ioctl(struct inode *inode, struct file *fp, unsigned int cmd,
44 static spinlock_t i2o_config_lock;
46 #define MODINC(x,y) ((x) = ((x) + 1) % (y))
48 struct sg_simple_element {
55 struct fasync_struct *fasync;
56 struct i2o_evt_info event_q[I2O_EVT_Q_LEN];
57 u16 q_in; // Queue head index
58 u16 q_out; // Queue tail index
59 u16 q_len; // Queue length
60 u16 q_lost; // Number of lost events
61 ulong q_id; // Event queue ID...used as tx_context
62 struct i2o_cfg_info *next;
64 static struct i2o_cfg_info *open_files = NULL;
65 static ulong i2o_cfg_info_id = 0;
67 static int i2o_cfg_getiops(unsigned long arg)
69 struct i2o_controller *c;
70 u8 __user *user_iop_table = (void __user *)arg;
71 u8 tmp[MAX_I2O_CONTROLLERS];
74 memset(tmp, 0, MAX_I2O_CONTROLLERS);
76 list_for_each_entry(c, &i2o_controllers, list)
79 if (copy_to_user(user_iop_table, tmp, MAX_I2O_CONTROLLERS))
85 static int i2o_cfg_gethrt(unsigned long arg)
87 struct i2o_controller *c;
88 struct i2o_cmd_hrtlct __user *cmd = (struct i2o_cmd_hrtlct __user *)arg;
89 struct i2o_cmd_hrtlct kcmd;
95 if (copy_from_user(&kcmd, cmd, sizeof(struct i2o_cmd_hrtlct)))
98 if (get_user(reslen, kcmd.reslen) < 0)
101 if (kcmd.resbuf == NULL)
104 c = i2o_find_iop(kcmd.iop);
108 hrt = (i2o_hrt *) c->hrt.virt;
110 len = 8 + ((hrt->entry_len * hrt->num_entries) << 2);
112 /* We did a get user...so assuming mem is ok...is this bad? */
113 put_user(len, kcmd.reslen);
116 if (copy_to_user(kcmd.resbuf, (void *)hrt, len))
122 static int i2o_cfg_getlct(unsigned long arg)
124 struct i2o_controller *c;
125 struct i2o_cmd_hrtlct __user *cmd = (struct i2o_cmd_hrtlct __user *)arg;
126 struct i2o_cmd_hrtlct kcmd;
132 if (copy_from_user(&kcmd, cmd, sizeof(struct i2o_cmd_hrtlct)))
135 if (get_user(reslen, kcmd.reslen) < 0)
138 if (kcmd.resbuf == NULL)
141 c = i2o_find_iop(kcmd.iop);
145 lct = (i2o_lct *) c->lct;
147 len = (unsigned int)lct->table_size << 2;
148 put_user(len, kcmd.reslen);
151 else if (copy_to_user(kcmd.resbuf, lct, len))
157 static int i2o_cfg_parms(unsigned long arg, unsigned int type)
160 struct i2o_controller *c;
161 struct i2o_device *dev;
162 struct i2o_cmd_psetget __user *cmd =
163 (struct i2o_cmd_psetget __user *)arg;
164 struct i2o_cmd_psetget kcmd;
170 u32 i2o_cmd = (type == I2OPARMGET ?
171 I2O_CMD_UTIL_PARAMS_GET : I2O_CMD_UTIL_PARAMS_SET);
173 if (copy_from_user(&kcmd, cmd, sizeof(struct i2o_cmd_psetget)))
176 if (get_user(reslen, kcmd.reslen))
179 c = i2o_find_iop(kcmd.iop);
183 dev = i2o_iop_find_device(c, kcmd.tid);
187 ops = (u8 *) kmalloc(kcmd.oplen, GFP_KERNEL);
191 if (copy_from_user(ops, kcmd.opbuf, kcmd.oplen)) {
197 * It's possible to have a _very_ large table
198 * and that the user asks for all of it at once...
200 res = (u8 *) kmalloc(65536, GFP_KERNEL);
206 len = i2o_parm_issue(dev, i2o_cmd, ops, kcmd.oplen, res, 65536);
214 put_user(len, kcmd.reslen);
217 else if (copy_to_user(kcmd.resbuf, res, len))
225 static int i2o_cfg_swdl(unsigned long arg)
227 struct i2o_sw_xfer kxfer;
228 struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg;
229 unsigned char maxfrag = 0, curfrag = 1;
230 struct i2o_dma buffer;
231 struct i2o_message __iomem *msg;
233 unsigned int status = 0, swlen = 0, fragsize = 8192;
234 struct i2o_controller *c;
236 if (copy_from_user(&kxfer, pxfer, sizeof(struct i2o_sw_xfer)))
239 if (get_user(swlen, kxfer.swlen) < 0)
242 if (get_user(maxfrag, kxfer.maxfrag) < 0)
245 if (get_user(curfrag, kxfer.curfrag) < 0)
248 if (curfrag == maxfrag)
249 fragsize = swlen - (maxfrag - 1) * 8192;
251 if (!kxfer.buf || !access_ok(VERIFY_READ, kxfer.buf, fragsize))
254 c = i2o_find_iop(kxfer.iop);
258 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
259 if (m == I2O_QUEUE_EMPTY)
262 if (i2o_dma_alloc(&c->pdev->dev, &buffer, fragsize, GFP_KERNEL)) {
267 __copy_from_user(buffer.virt, kxfer.buf, fragsize);
269 writel(NINE_WORD_MSG_SIZE | SGL_OFFSET_7, &msg->u.head[0]);
270 writel(I2O_CMD_SW_DOWNLOAD << 24 | HOST_TID << 12 | ADAPTER_TID,
272 writel(i2o_config_driver.context, &msg->u.head[2]);
273 writel(0, &msg->u.head[3]);
274 writel((((u32) kxfer.flags) << 24) | (((u32) kxfer.sw_type) << 16) |
275 (((u32) maxfrag) << 8) | (((u32) curfrag)), &msg->body[0]);
276 writel(swlen, &msg->body[1]);
277 writel(kxfer.sw_id, &msg->body[2]);
278 writel(0xD0000000 | fragsize, &msg->body[3]);
279 writel(buffer.phys, &msg->body[4]);
281 osm_debug("swdl frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize);
282 status = i2o_msg_post_wait_mem(c, m, 60, &buffer);
284 if (status != -ETIMEDOUT)
285 i2o_dma_free(&c->pdev->dev, &buffer);
287 if (status != I2O_POST_WAIT_OK) {
288 // it fails if you try and send frags out of order
289 // and for some yet unknown reasons too
290 osm_info("swdl failed, DetailedStatus = %d\n", status);
297 static int i2o_cfg_swul(unsigned long arg)
299 struct i2o_sw_xfer kxfer;
300 struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg;
301 unsigned char maxfrag = 0, curfrag = 1;
302 struct i2o_dma buffer;
303 struct i2o_message __iomem *msg;
305 unsigned int status = 0, swlen = 0, fragsize = 8192;
306 struct i2o_controller *c;
309 if (copy_from_user(&kxfer, pxfer, sizeof(struct i2o_sw_xfer)))
312 if (get_user(swlen, kxfer.swlen) < 0)
315 if (get_user(maxfrag, kxfer.maxfrag) < 0)
318 if (get_user(curfrag, kxfer.curfrag) < 0)
321 if (curfrag == maxfrag)
322 fragsize = swlen - (maxfrag - 1) * 8192;
327 c = i2o_find_iop(kxfer.iop);
331 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
332 if (m == I2O_QUEUE_EMPTY)
335 if (i2o_dma_alloc(&c->pdev->dev, &buffer, fragsize, GFP_KERNEL)) {
340 writel(NINE_WORD_MSG_SIZE | SGL_OFFSET_7, &msg->u.head[0]);
341 writel(I2O_CMD_SW_UPLOAD << 24 | HOST_TID << 12 | ADAPTER_TID,
343 writel(i2o_config_driver.context, &msg->u.head[2]);
344 writel(0, &msg->u.head[3]);
345 writel((u32) kxfer.flags << 24 | (u32) kxfer.
346 sw_type << 16 | (u32) maxfrag << 8 | (u32) curfrag,
348 writel(swlen, &msg->body[1]);
349 writel(kxfer.sw_id, &msg->body[2]);
350 writel(0xD0000000 | fragsize, &msg->body[3]);
351 writel(buffer.phys, &msg->body[4]);
353 osm_debug("swul frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize);
354 status = i2o_msg_post_wait_mem(c, m, 60, &buffer);
356 if (status != I2O_POST_WAIT_OK) {
357 if (status != -ETIMEDOUT)
358 i2o_dma_free(&c->pdev->dev, &buffer);
360 osm_info("swul failed, DetailedStatus = %d\n", status);
364 if (copy_to_user(kxfer.buf, buffer.virt, fragsize))
367 i2o_dma_free(&c->pdev->dev, &buffer);
376 static int i2o_cfg_swdel(unsigned long arg)
378 struct i2o_controller *c;
379 struct i2o_sw_xfer kxfer;
380 struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg;
381 struct i2o_message __iomem *msg;
386 if (copy_from_user(&kxfer, pxfer, sizeof(struct i2o_sw_xfer)))
389 if (get_user(swlen, kxfer.swlen) < 0)
392 c = i2o_find_iop(kxfer.iop);
396 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
397 if (m == I2O_QUEUE_EMPTY)
400 writel(SEVEN_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
401 writel(I2O_CMD_SW_REMOVE << 24 | HOST_TID << 12 | ADAPTER_TID,
403 writel(i2o_config_driver.context, &msg->u.head[2]);
404 writel(0, &msg->u.head[3]);
405 writel((u32) kxfer.flags << 24 | (u32) kxfer.sw_type << 16,
407 writel(swlen, &msg->body[1]);
408 writel(kxfer.sw_id, &msg->body[2]);
410 token = i2o_msg_post_wait(c, m, 10);
412 if (token != I2O_POST_WAIT_OK) {
413 osm_info("swdel failed, DetailedStatus = %d\n", token);
420 static int i2o_cfg_validate(unsigned long arg)
424 struct i2o_message __iomem *msg;
426 struct i2o_controller *c;
428 c = i2o_find_iop(iop);
432 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
433 if (m == I2O_QUEUE_EMPTY)
436 writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
437 writel(I2O_CMD_CONFIG_VALIDATE << 24 | HOST_TID << 12 | iop,
439 writel(i2o_config_driver.context, &msg->u.head[2]);
440 writel(0, &msg->u.head[3]);
442 token = i2o_msg_post_wait(c, m, 10);
444 if (token != I2O_POST_WAIT_OK) {
445 osm_info("Can't validate configuration, ErrorStatus = %d\n",
453 static int i2o_cfg_evt_reg(unsigned long arg, struct file *fp)
455 struct i2o_message __iomem *msg;
457 struct i2o_evt_id __user *pdesc = (struct i2o_evt_id __user *)arg;
458 struct i2o_evt_id kdesc;
459 struct i2o_controller *c;
460 struct i2o_device *d;
462 if (copy_from_user(&kdesc, pdesc, sizeof(struct i2o_evt_id)))
466 c = i2o_find_iop(kdesc.iop);
471 d = i2o_iop_find_device(c, kdesc.tid);
475 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
476 if (m == I2O_QUEUE_EMPTY)
479 writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
480 writel(I2O_CMD_UTIL_EVT_REGISTER << 24 | HOST_TID << 12 | kdesc.tid,
482 writel(i2o_config_driver.context, &msg->u.head[2]);
483 writel(i2o_cntxt_list_add(c, fp->private_data), &msg->u.head[3]);
484 writel(kdesc.evt_mask, &msg->body[0]);
491 static int i2o_cfg_evt_get(unsigned long arg, struct file *fp)
493 struct i2o_cfg_info *p = NULL;
494 struct i2o_evt_get __user *uget = (struct i2o_evt_get __user *)arg;
495 struct i2o_evt_get kget;
498 for (p = open_files; p; p = p->next)
499 if (p->q_id == (ulong) fp->private_data)
505 memcpy(&kget.info, &p->event_q[p->q_out], sizeof(struct i2o_evt_info));
506 MODINC(p->q_out, I2O_EVT_Q_LEN);
507 spin_lock_irqsave(&i2o_config_lock, flags);
509 kget.pending = p->q_len;
510 kget.lost = p->q_lost;
511 spin_unlock_irqrestore(&i2o_config_lock, flags);
513 if (copy_to_user(uget, &kget, sizeof(struct i2o_evt_get)))
519 static int i2o_cfg_passthru32(struct file *file, unsigned cmnd, unsigned long arg)
521 struct i2o_cmd_passthru32 __user *cmd;
522 struct i2o_controller *c;
523 u32 __user *user_msg;
525 u32 __user *user_reply = NULL;
529 struct i2o_dma sg_list[SG_TABLESIZE];
534 i2o_status_block *sb;
535 struct i2o_message *msg;
539 cmd = (struct i2o_cmd_passthru32 __user *)arg;
541 if (get_user(iop, &cmd->iop) || get_user(i, &cmd->msg))
544 user_msg = compat_ptr(i);
546 c = i2o_find_iop(iop);
548 osm_debug("controller %d not found\n", iop);
552 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
554 sb = c->status_block.virt;
556 if (get_user(size, &user_msg[0])) {
557 osm_warn("unable to get size!\n");
562 if (size > sb->inbound_frame_size) {
563 osm_warn("size of message > inbound_frame_size");
567 user_reply = &user_msg[size];
569 size <<= 2; // Convert to bytes
571 /* Copy in the user's I2O command */
572 if (copy_from_user(msg, user_msg, size)) {
573 osm_warn("unable to copy user message\n");
576 i2o_dump_message(msg);
578 if (get_user(reply_size, &user_reply[0]) < 0)
584 reply = kmalloc(reply_size, GFP_KERNEL);
586 printk(KERN_WARNING "%s: Could not allocate reply buffer\n",
590 memset(reply, 0, reply_size);
592 sg_offset = (msg->u.head[0] >> 4) & 0x0f;
594 writel(i2o_config_driver.context, &msg->u.s.icntxt);
595 writel(i2o_cntxt_list_add(c, reply), &msg->u.s.tcntxt);
597 memset(sg_list, 0, sizeof(sg_list[0]) * SG_TABLESIZE);
599 struct sg_simple_element *sg;
601 if (sg_offset * 4 >= size) {
606 sg = (struct sg_simple_element *)((&msg->u.head[0]) +
609 (size - sg_offset * 4) / sizeof(struct sg_simple_element);
610 if (sg_count > SG_TABLESIZE) {
611 printk(KERN_DEBUG "%s:IOCTL SG List too large (%u)\n",
617 for (i = 0; i < sg_count; i++) {
621 if (!(sg[i].flag_count & 0x10000000
622 /*I2O_SGL_FLAGS_SIMPLE_ADDRESS_ELEMENT */ )) {
624 "%s:Bad SG element %d - not simple (%x)\n",
625 c->name, i, sg[i].flag_count);
629 sg_size = sg[i].flag_count & 0xffffff;
630 p = &(sg_list[sg_index++]);
631 /* Allocate memory for the transfer */
633 (&c->pdev->dev, p, sg_size,
634 PCI_DMA_BIDIRECTIONAL)) {
636 "%s: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
637 c->name, sg_size, i, sg_count);
639 goto sg_list_cleanup;
641 /* Copy in the user's SG buffer if necessary */
643 flag_count & 0x04000000 /*I2O_SGL_FLAGS_DIR */ ) {
646 (p->virt, (void __user *)(unsigned long)sg[i].addr_bus,
649 "%s: Could not copy SG buf %d FROM user\n",
652 goto sg_list_cleanup;
656 sg[i].addr_bus = (u32) p->phys;
660 rcode = i2o_msg_post_wait(c, m, 60);
662 goto sg_list_cleanup;
665 u32 msg[MSG_FRAME_SIZE];
666 /* Copy back the Scatter Gather buffers back to user space */
669 struct sg_simple_element *sg;
672 // re-acquire the original message to handle correctly the sg copy operation
673 memset(&msg, 0, MSG_FRAME_SIZE * 4);
674 // get user msg size in u32s
675 if (get_user(size, &user_msg[0])) {
677 goto sg_list_cleanup;
681 /* Copy in the user's I2O command */
682 if (copy_from_user(msg, user_msg, size)) {
684 goto sg_list_cleanup;
687 (size - sg_offset * 4) / sizeof(struct sg_simple_element);
690 sg = (struct sg_simple_element *)(msg + sg_offset);
691 for (j = 0; j < sg_count; j++) {
692 /* Copy out the SG list to user's buffer if necessary */
695 flag_count & 0x4000000 /*I2O_SGL_FLAGS_DIR */ )) {
696 sg_size = sg[j].flag_count & 0xffffff;
699 ((void __user *)(u64) sg[j].addr_bus,
700 sg_list[j].virt, sg_size)) {
702 "%s: Could not copy %p TO user %x\n",
703 c->name, sg_list[j].virt,
706 goto sg_list_cleanup;
712 /* Copy back the reply to user space */
714 // we wrote our own values for context - now restore the user supplied ones
715 if (copy_from_user(reply + 2, user_msg + 2, sizeof(u32) * 2)) {
717 "%s: Could not copy message context FROM user\n",
720 goto sg_list_cleanup;
722 if (copy_to_user(user_reply, reply, reply_size)) {
724 "%s: Could not copy reply TO user\n", c->name);
730 for (i = 0; i < sg_index; i++)
731 i2o_dma_free(&c->pdev->dev, &sg_list[i]);
738 static long i2o_cfg_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg)
744 ret = i2o_cfg_ioctl(NULL, file, cmd, arg);
747 ret = i2o_cfg_passthru32(file, cmd, arg);
759 static int i2o_cfg_passthru(unsigned long arg)
761 struct i2o_cmd_passthru __user *cmd =
762 (struct i2o_cmd_passthru __user *)arg;
763 struct i2o_controller *c;
764 u32 __user *user_msg;
766 u32 __user *user_reply = NULL;
770 void *sg_list[SG_TABLESIZE];
776 i2o_status_block *sb;
777 struct i2o_message __iomem *msg;
781 if (get_user(iop, &cmd->iop) || get_user(user_msg, &cmd->msg))
784 c = i2o_find_iop(iop);
786 osm_warn("controller %d not found\n", iop);
790 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
792 sb = c->status_block.virt;
794 if (get_user(size, &user_msg[0]))
798 if (size > sb->inbound_frame_size) {
799 osm_warn("size of message > inbound_frame_size");
803 user_reply = &user_msg[size];
805 size <<= 2; // Convert to bytes
807 /* Copy in the user's I2O command */
808 if (copy_from_user(msg, user_msg, size))
811 if (get_user(reply_size, &user_reply[0]) < 0)
817 reply = kmalloc(reply_size, GFP_KERNEL);
819 printk(KERN_WARNING "%s: Could not allocate reply buffer\n",
823 memset(reply, 0, reply_size);
825 sg_offset = (msg->u.head[0] >> 4) & 0x0f;
827 writel(i2o_config_driver.context, &msg->u.s.icntxt);
828 writel(i2o_cntxt_list_add(c, reply), &msg->u.s.tcntxt);
830 memset(sg_list, 0, sizeof(sg_list[0]) * SG_TABLESIZE);
832 struct sg_simple_element *sg;
834 if (sg_offset * 4 >= size) {
839 sg = (struct sg_simple_element *)((&msg->u.head[0]) +
842 (size - sg_offset * 4) / sizeof(struct sg_simple_element);
843 if (sg_count > SG_TABLESIZE) {
844 printk(KERN_DEBUG "%s:IOCTL SG List too large (%u)\n",
850 for (i = 0; i < sg_count; i++) {
853 if (!(sg[i].flag_count & 0x10000000
854 /*I2O_SGL_FLAGS_SIMPLE_ADDRESS_ELEMENT */ )) {
856 "%s:Bad SG element %d - not simple (%x)\n",
857 c->name, i, sg[i].flag_count);
859 goto sg_list_cleanup;
861 sg_size = sg[i].flag_count & 0xffffff;
862 /* Allocate memory for the transfer */
863 p = kmalloc(sg_size, GFP_KERNEL);
866 "%s: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
867 c->name, sg_size, i, sg_count);
869 goto sg_list_cleanup;
871 sg_list[sg_index++] = p; // sglist indexed with input frame, not our internal frame.
872 /* Copy in the user's SG buffer if necessary */
874 flag_count & 0x04000000 /*I2O_SGL_FLAGS_DIR */ ) {
877 (p, (void __user *)sg[i].addr_bus,
880 "%s: Could not copy SG buf %d FROM user\n",
883 goto sg_list_cleanup;
887 sg[i].addr_bus = virt_to_bus(p);
891 rcode = i2o_msg_post_wait(c, m, 60);
893 goto sg_list_cleanup;
897 /* Copy back the Scatter Gather buffers back to user space */
900 struct sg_simple_element *sg;
903 // re-acquire the original message to handle correctly the sg copy operation
904 memset(&msg, 0, MSG_FRAME_SIZE * 4);
905 // get user msg size in u32s
906 if (get_user(size, &user_msg[0])) {
908 goto sg_list_cleanup;
912 /* Copy in the user's I2O command */
913 if (copy_from_user(msg, user_msg, size)) {
915 goto sg_list_cleanup;
918 (size - sg_offset * 4) / sizeof(struct sg_simple_element);
921 sg = (struct sg_simple_element *)(msg + sg_offset);
922 for (j = 0; j < sg_count; j++) {
923 /* Copy out the SG list to user's buffer if necessary */
926 flag_count & 0x4000000 /*I2O_SGL_FLAGS_DIR */ )) {
927 sg_size = sg[j].flag_count & 0xffffff;
930 ((void __user *)sg[j].addr_bus, sg_list[j],
933 "%s: Could not copy %p TO user %x\n",
937 goto sg_list_cleanup;
943 /* Copy back the reply to user space */
945 // we wrote our own values for context - now restore the user supplied ones
946 if (copy_from_user(reply + 2, user_msg + 2, sizeof(u32) * 2)) {
948 "%s: Could not copy message context FROM user\n",
952 if (copy_to_user(user_reply, reply, reply_size)) {
954 "%s: Could not copy reply TO user\n", c->name);
960 for (i = 0; i < sg_index; i++)
971 static int i2o_cfg_ioctl(struct inode *inode, struct file *fp, unsigned int cmd,
978 ret = i2o_cfg_getiops(arg);
982 ret = i2o_cfg_gethrt(arg);
986 ret = i2o_cfg_getlct(arg);
990 ret = i2o_cfg_parms(arg, I2OPARMSET);
994 ret = i2o_cfg_parms(arg, I2OPARMGET);
998 ret = i2o_cfg_swdl(arg);
1002 ret = i2o_cfg_swul(arg);
1006 ret = i2o_cfg_swdel(arg);
1010 ret = i2o_cfg_validate(arg);
1014 ret = i2o_cfg_evt_reg(arg, fp);
1018 ret = i2o_cfg_evt_get(arg, fp);
1022 ret = i2o_cfg_passthru(arg);
1026 osm_debug("unknown ioctl called!\n");
1033 static int cfg_open(struct inode *inode, struct file *file)
1035 struct i2o_cfg_info *tmp =
1036 (struct i2o_cfg_info *)kmalloc(sizeof(struct i2o_cfg_info),
1038 unsigned long flags;
1043 file->private_data = (void *)(i2o_cfg_info_id++);
1046 tmp->q_id = (ulong) file->private_data;
1051 tmp->next = open_files;
1053 spin_lock_irqsave(&i2o_config_lock, flags);
1055 spin_unlock_irqrestore(&i2o_config_lock, flags);
1060 static int cfg_fasync(int fd, struct file *fp, int on)
1062 ulong id = (ulong) fp->private_data;
1063 struct i2o_cfg_info *p;
1065 for (p = open_files; p; p = p->next)
1072 return fasync_helper(fd, fp, on, &p->fasync);
1075 static int cfg_release(struct inode *inode, struct file *file)
1077 ulong id = (ulong) file->private_data;
1078 struct i2o_cfg_info *p1, *p2;
1079 unsigned long flags;
1084 spin_lock_irqsave(&i2o_config_lock, flags);
1085 for (p1 = open_files; p1;) {
1086 if (p1->q_id == id) {
1089 cfg_fasync(-1, file, 0);
1091 p2->next = p1->next;
1093 open_files = p1->next;
1101 spin_unlock_irqrestore(&i2o_config_lock, flags);
1107 static struct file_operations config_fops = {
1108 .owner = THIS_MODULE,
1109 .llseek = no_llseek,
1110 .ioctl = i2o_cfg_ioctl,
1111 #ifdef CONFIG_COMPAT
1112 .compat_ioctl = i2o_cfg_compat_ioctl,
1115 .release = cfg_release,
1116 .fasync = cfg_fasync,
1119 static struct miscdevice i2o_miscdev = {
1125 static int __init i2o_config_old_init(void)
1127 spin_lock_init(&i2o_config_lock);
1129 if (misc_register(&i2o_miscdev) < 0) {
1130 osm_err("can't register device.\n");
1136 static void i2o_config_old_exit(void)
1138 misc_deregister(&i2o_miscdev);
1141 MODULE_AUTHOR("Red Hat Software");