Re: [PATCH 2.6.11-rc2 23/29] ide: map ide_task_ioctl() to ide_taskfile_ioctl()

Tejun Heo
2005-02-02T03:25:18Z

> 23_ide_taskfile_task_ioctl.patch
>
> ide_task_ioctl() modified to map to ide_taskfile_ioctl().
> This is the last user of REQ_DRIVE_TASK.

Signed-off-by: Tejun Heo <tj@home-tj.org>

Index: linux-ide-export/drivers/ide/ide-taskfile.c
===================================================================
--- linux-ide-export.orig/drivers/ide/ide-taskfile.c 2005-02-02 10:28:06.273027780 +0900
+++ linux-ide-export/drivers/ide/ide-taskfile.c 2005-02-02 10:28:06.751950074 +0900
@@ -778,30 +778,51 @@ abort:
return err;
}

-static int ide_wait_cmd_task(ide_drive_t *drive, u8 *buf)
-{
- struct request rq;
-
- ide_init_drive_cmd(&rq);
- rq.flags = REQ_DRIVE_TASK;
- rq.buffer = buf;
- return ide_do_drive_cmd(drive, &rq, ide_wait);
-}
-
-/*
- * FIXME : this needs to map into at taskfile. <andre@linux-ide.org>
- */
int ide_task_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
{
void __user *p = (void __user *)arg;
- int err = 0;
- u8 args[7], *argbuf = args;
- int argsize = 7;
+ u8 args[7];
+ ide_task_request_t task_req;
+ task_ioreg_t *io_ports;
+ mm_segment_t orig_fs;
+ int ret;

if (copy_from_user(args, p, 7))
return -EFAULT;
- err = ide_wait_cmd_task(drive, argbuf);
- if (copy_to_user(p, argbuf, argsize))
- err = -EFAULT;
- return err;
+
+ memset(&task_req, 0, sizeof(task_req));
+ task_req.out_flags.h.taskfile = IDE_TASKFILE_STD_OUT_FLAGS;
+ task_req.in_flags.h.taskfile = IDE_TASKFILE_STD_IN_FLAGS;
+
+ io_ports = task_req.io_ports;
+ io_ports[IDE_COMMAND_OFFSET] = args[0];
+ io_ports[IDE_FEATURE_OFFSET] = args[1];
+ io_ports[IDE_NSECTOR_OFFSET] = args[2];
+ io_ports[IDE_SECTOR_OFFSET] = args[3];
+ io_ports[IDE_LCYL_OFFSET] = args[4];
+ io_ports[IDE_HCYL_OFFSET] = args[5];
+ io_ports[IDE_SELECT_OFFSET] = args[6];
+
+ task_req.req_cmd = IDE_DRIVE_TASK_NO_DATA;
+ task_req.data_phase = TASKFILE_NO_DATA;
+
+ orig_fs = get_fs();
+ set_fs(KERNEL_DS);
+
+ ret = ide_taskfile_ioctl(drive, cmd, (unsigned long)&task_req);
+
+ set_fs(orig_fs);
+
+ args[0] = io_ports[IDE_COMMAND_OFFSET];
+ args[1] = io_ports[IDE_FEATURE_OFFSET];
+ args[2] = io_ports[IDE_NSECTOR_OFFSET];
+ args[3] = io_ports[IDE_SECTOR_OFFSET];
+ args[4] = io_ports[IDE_LCYL_OFFSET];
+ args[5] = io_ports[IDE_HCYL_OFFSET];
+ args[6] = io_ports[IDE_SELECT_OFFSET];
+
+ if (copy_to_user(p, args, 7))
+ ret = -EFAULT;
+
+ return ret;
}