From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: Tejun Heo <tj@home-tj.org>
Cc: linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org
Subject: Re: [PATCH 2.6.11-rc2 26/29] ide: map ide_cmd_ioctl() to ide_taskfile_ioctl()
Date: Thu, 3 Feb 2005 18:54:05 +0100 [thread overview]
Message-ID: <58cb370e050203095417fed306@mail.gmail.com> (raw)
In-Reply-To: <20050202031037.GK1187@htj.dyndns.org>
On Wed, 2 Feb 2005 12:10:37 +0900, Tejun Heo <tj@home-tj.org> wrote:
> > 26_ide_taskfile_cmd_ioctl.patch
> >
> > ide_cmd_ioctl() converted to use ide_taskfile_ioctl(). This
> > is the last user of REQ_DRIVE_CMD.
ide_cmd_ioctl() needs to map to taskfile transport not ide_taskfile_ioctl()
> Index: linux-ide-export/drivers/ide/ide-iops.c
> ===================================================================
> --- linux-ide-export.orig/drivers/ide/ide-iops.c 2005-02-02 10:28:04.466320918 +0900
> +++ linux-ide-export/drivers/ide/ide-iops.c 2005-02-02 10:28:07.406843817 +0900
> @@ -648,11 +648,11 @@ u8 eighty_ninty_three (ide_drive_t *driv
>
> EXPORT_SYMBOL(eighty_ninty_three);
>
> -int ide_ata66_check (ide_drive_t *drive, ide_task_t *args)
> +int ide_ata66_check (ide_drive_t *drive, task_ioreg_t *regs)
nitpick: int ide_ata66_check()
> {
> - if ((args->tfRegister[IDE_COMMAND_OFFSET] == WIN_SETFEATURES) &&
> - (args->tfRegister[IDE_SECTOR_OFFSET] > XFER_UDMA_2) &&
> - (args->tfRegister[IDE_FEATURE_OFFSET] == SETFEATURES_XFER)) {
> + if ((regs[IDE_COMMAND_OFFSET] == WIN_SETFEATURES) &&
> + (regs[IDE_SECTOR_OFFSET] > XFER_UDMA_2) &&
> + (regs[IDE_FEATURE_OFFSET] == SETFEATURES_XFER)) {
nitpick: please drop brackets
> #ifndef CONFIG_IDEDMA_IVB
> if ((drive->id->hw_config & 0x6000) == 0) {
> #else /* !CONFIG_IDEDMA_IVB */
> @@ -678,11 +678,11 @@ int ide_ata66_check (ide_drive_t *drive,
> * 1 : Safe to update drive->id DMA registers.
> * 0 : OOPs not allowed.
> */
> -int set_transfer (ide_drive_t *drive, ide_task_t *args)
> +int set_transfer (ide_drive_t *drive, task_ioreg_t *regs)
nitpick: int set_transfer()
> {
> - if ((args->tfRegister[IDE_COMMAND_OFFSET] == WIN_SETFEATURES) &&
> - (args->tfRegister[IDE_SECTOR_OFFSET] >= XFER_SW_DMA_0) &&
> - (args->tfRegister[IDE_FEATURE_OFFSET] == SETFEATURES_XFER) &&
> + if ((regs[IDE_COMMAND_OFFSET] == WIN_SETFEATURES) &&
> + (regs[IDE_SECTOR_OFFSET] >= XFER_SW_DMA_0) &&
> + (regs[IDE_FEATURE_OFFSET] == SETFEATURES_XFER) &&
nitpick: brackets
> (drive->id->dma_ultra ||
> drive->id->dma_mword ||
> drive->id->dma_1word))
> Index: linux-ide-export/drivers/ide/ide-taskfile.c
> ===================================================================
> --- linux-ide-export.orig/drivers/ide/ide-taskfile.c 2005-02-02 10:28:06.751950074 +0900
> +++ linux-ide-export/drivers/ide/ide-taskfile.c 2005-02-02 10:28:07.407843655 +0900
> @@ -704,78 +704,90 @@ abort:
> return err;
> }
>
> -int ide_wait_cmd (ide_drive_t *drive, u8 cmd, u8 nsect, u8 feature, u8 sectors, u8 *buf)
> -{
> - struct request rq;
> - u8 buffer[4];
> -
> - if (!buf)
> - buf = buffer;
> - memset(buf, 0, 4 + SECTOR_WORDS * 4 * sectors);
> - ide_init_drive_cmd(&rq);
> - rq.buffer = buf;
> - *buf++ = cmd;
> - *buf++ = nsect;
> - *buf++ = feature;
> - *buf++ = sectors;
> - return ide_do_drive_cmd(drive, &rq, ide_wait);
> -}
> -
> -/*
> - * FIXME : this needs to map into at taskfile. <andre@linux-ide.org>
> - */
> int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
> {
> - int err = 0;
> - u8 args[4], *argbuf = args;
> + u8 args[4];
> + ide_task_request_t *task_req;
> + task_ioreg_t *io_ports;
> u8 xfer_rate = 0;
> - int argsize = 4;
> - ide_task_t tfargs;
> + mm_segment_t orig_fs;
> + int in_size, ret;
>
> - if (NULL == (void *) arg) {
> + if ((void *)arg == NULL) {
> struct request rq;
> ide_init_drive_cmd(&rq);
> + rq.flags = REQ_DRIVE_TASKFILE;
> return ide_do_drive_cmd(drive, &rq, ide_wait);
> }
>
> if (copy_from_user(args, (void __user *)arg, 4))
> return -EFAULT;
>
> - memset(&tfargs, 0, sizeof(ide_task_t));
> - tfargs.tfRegister[IDE_FEATURE_OFFSET] = args[2];
> - tfargs.tfRegister[IDE_NSECTOR_OFFSET] = args[3];
> - tfargs.tfRegister[IDE_SECTOR_OFFSET] = args[1];
> - tfargs.tfRegister[IDE_LCYL_OFFSET] = 0x00;
> - tfargs.tfRegister[IDE_HCYL_OFFSET] = 0x00;
> - tfargs.tfRegister[IDE_SELECT_OFFSET] = 0x00;
> - tfargs.tfRegister[IDE_COMMAND_OFFSET] = args[0];
> -
> - if (args[3]) {
> - argsize = 4 + (SECTOR_WORDS * 4 * args[3]);
> - argbuf = kmalloc(argsize, GFP_KERNEL);
> - if (argbuf == NULL)
> - return -ENOMEM;
> - memcpy(argbuf, args, 4);
> + in_size = 4 * SECTOR_WORDS * args[3];
> +
> + task_req = kmalloc(sizeof(*task_req) + in_size, GFP_KERNEL);
> + if (task_req == NULL)
> + return -ENOMEM;
> +
> + memset(task_req, 0, sizeof(*task_req) + in_size);
> +
> + task_req->out_flags.b.status_command = 1;
> + task_req->out_flags.b.sector = 1;
> + task_req->out_flags.b.error_feature = 1;
> + task_req->out_flags.b.nsector = 1;
> +
> + task_req->in_flags.b.status_command = 1;
> + task_req->in_flags.b.error_feature = 1;
> + task_req->in_flags.b.nsector = 1;
> +
> + io_ports = task_req->io_ports;
> + io_ports[IDE_COMMAND_OFFSET] = args[0];
> + io_ports[IDE_SECTOR_OFFSET] = args[1];
> + io_ports[IDE_FEATURE_OFFSET] = args[2];
> + io_ports[IDE_NSECTOR_OFFSET] = args[3];
Please handle WIN_SMART hack here (see execute_drive_cmd()),
your next patch just kills it - it can break legacy applications.
> + if (in_size) {
> + task_req->req_cmd = IDE_DRIVE_TASK_IN;
> + task_req->data_phase = TASKFILE_IN;
> + task_req->in_size = in_size;
> + } else {
> + task_req->req_cmd = IDE_DRIVE_TASK_NO_DATA;
> + task_req->data_phase = TASKFILE_NO_DATA;
> }
> - if (set_transfer(drive, &tfargs)) {
> +
> + if (set_transfer(drive, io_ports)) {
> xfer_rate = args[1];
> - if (ide_ata66_check(drive, &tfargs))
> + if (ide_ata66_check(drive, io_ports)) {
> + ret = -EIO;
> goto abort;
> + }
> }
>
> - err = ide_wait_cmd(drive, args[0], args[1], args[2], args[3], argbuf);
> + orig_fs = get_fs();
> + set_fs(KERNEL_DS);
>
> - if (!err && xfer_rate) {
> + ret = ide_taskfile_ioctl(drive, cmd, (unsigned long)task_req);
> +
> + set_fs(orig_fs);
as ide_cmd_ioctl() only handles no-data and PIO-in protocols it should
be easy to add missing bits here and get rid of calling ide_taskfile_ioctl()
> + if (!ret && xfer_rate) {
> /* active-retuning-calls future */
> ide_set_xfer_rate(drive, xfer_rate);
> ide_driveid_update(drive);
> }
> +
> + args[0] = io_ports[IDE_STATUS_OFFSET];
> + args[1] = io_ports[IDE_ERROR_OFFSET];
> + args[2] = io_ports[IDE_NSECTOR_OFFSET];
> + args[3] = 0;
> +
> + if (copy_to_user((void __user *)arg, args, 4) ||
> + copy_to_user((void __user *)arg + 4,
> + (void *)task_req + sizeof(*task_req), in_size))
> + ret = -EFAULT;
> abort:
> - if (copy_to_user((void __user *)arg, argbuf, argsize))
> - err = -EFAULT;
> - if (argsize > 4)
> - kfree(argbuf);
> - return err;
> + kfree(task_req);
> + return ret;
> }
>
> int ide_task_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
> Index: linux-ide-export/include/linux/ide.h
> ===================================================================
> --- linux-ide-export.orig/include/linux/ide.h 2005-02-02 10:28:06.529986088 +0900
> +++ linux-ide-export/include/linux/ide.h 2005-02-02 10:28:07.408843493 +0900
> @@ -1289,14 +1289,6 @@ extern int ide_do_drive_cmd(ide_drive_t
> */
> extern void ide_end_drive_cmd(ide_drive_t *, u8, u8);
>
> -/*
> - * Issue ATA command and wait for completion.
> - * Use for implementing commands in kernel
> - *
> - * (ide_drive_t *drive, u8 cmd, u8 nsect, u8 feature, u8 sectors, u8 *buf)
> - */
> -extern int ide_wait_cmd(ide_drive_t *, u8, u8, u8, u8, u8 *);
> -
> extern u32 ide_read_24(ide_drive_t *);
>
> extern void SELECT_DRIVE(ide_drive_t *);
> @@ -1334,10 +1326,10 @@ int ide_task_ioctl(ide_drive_t *, unsign
> extern int system_bus_clock(void);
>
> extern int ide_driveid_update(ide_drive_t *);
> -extern int ide_ata66_check(ide_drive_t *, ide_task_t *);
> +extern int ide_ata66_check(ide_drive_t *, task_ioreg_t *);
> extern int ide_config_drive_speed(ide_drive_t *, u8);
> extern u8 eighty_ninty_three (ide_drive_t *);
> -extern int set_transfer(ide_drive_t *, ide_task_t *);
> +extern int set_transfer(ide_drive_t *, task_ioreg_t *);
> extern int taskfile_lib_get_identify(ide_drive_t *drive, u8 *);
extern-s are not needed
> extern int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout);
next prev parent reply other threads:[~2005-02-04 4:47 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-02 2:40 [PATCH 2.6.11-rc2 0/29] ide: driver updates Tejun Heo
2005-02-02 2:43 ` [PATCH 2.6.11-rc2 01/29] ide: remove adma100 Tejun Heo
2005-02-02 23:43 ` Bartlomiej Zolnierkiewicz
2005-02-02 2:44 ` [PATCH 2.6.11-rc2 02/29] ide: cleanup it8172 Tejun Heo
2005-02-03 0:00 ` Bartlomiej Zolnierkiewicz
2005-02-02 2:45 ` [PATCH 2.6.11-rc2 03/29] ide: cleanup opti621 Tejun Heo
2005-02-03 0:05 ` Bartlomiej Zolnierkiewicz
2005-02-02 2:46 ` [PATCH 2.6.11-rc2 04/29] ide: cleanup piix Tejun Heo
2005-02-03 0:20 ` Bartlomiej Zolnierkiewicz
2005-02-02 2:47 ` [PATCH 2.6.11-rc2 05/29] ide: merge pci driver .h's into .c's Tejun Heo
2005-02-04 2:00 ` Bartlomiej Zolnierkiewicz
2005-02-02 2:48 ` [PATCH 2.6.11-rc2 06/29] ide: IDE_CONTROL_REG cleanup Tejun Heo
2005-02-03 0:23 ` Bartlomiej Zolnierkiewicz
2005-02-02 2:49 ` [PATCH 2.6.11-rc2 07/29] ide: ide_reg_valid_t endian fix Tejun Heo
2005-02-02 2:50 ` [PATCH 2.6.11-rc2 8/29] ide: driver updates Tejun Heo
2005-02-02 3:14 ` [PATCH 2.6.11-rc2 08/29] ide: do_identify() string termination fix Tejun Heo
2005-02-02 2:51 ` [PATCH 2.6.11-rc2 09/29] ide: __ide_do_rw_disk() lba48 dma check fix Tejun Heo
2005-02-03 0:33 ` Bartlomiej Zolnierkiewicz
2005-02-02 2:52 ` [PATCH 2.6.11-rc2 10/29] ide: __ide_do_rw_disk() return value fix Tejun Heo
2005-02-03 0:36 ` Bartlomiej Zolnierkiewicz
2005-02-02 2:54 ` [PATCH 2.6.11-rc2 11/29] ide: add ide_drive_t.sleeping Tejun Heo
2005-02-03 0:47 ` Bartlomiej Zolnierkiewicz
2005-02-03 11:37 ` Jens Axboe
2005-02-03 13:30 ` Bartlomiej Zolnierkiewicz
2005-02-03 13:32 ` Jens Axboe
2005-02-03 13:35 ` Bartlomiej Zolnierkiewicz
2005-02-03 22:20 ` Tejun Heo
2005-02-04 8:39 ` Jens Axboe
2005-02-03 14:13 ` Bartlomiej Zolnierkiewicz
2005-02-02 2:55 ` [PATCH 2.6.11-rc2 12/29] ide: add ide_hwgroup_t.polling Tejun Heo
2005-02-03 0:42 ` Bartlomiej Zolnierkiewicz
2005-02-03 14:20 ` Bartlomiej Zolnierkiewicz
2005-02-02 2:56 ` [PATCH 2.6.11-rc2 13/29] ide: use time_after() macro Tejun Heo
2005-02-03 1:07 ` Bartlomiej Zolnierkiewicz
2005-02-02 2:57 ` [PATCH 2.6.11-rc2 14/29] ide: remove NULL checking in ide_error() Tejun Heo
2005-02-03 1:14 ` Bartlomiej Zolnierkiewicz
2005-02-02 2:58 ` [PATCH 2.6.11-rc2 15/29] ide: flagged_taskfile() data byte order fix Tejun Heo
2005-02-02 3:00 ` [PATCH 2.6.11-rc2 16/29] ide: flagged_taskfile select register dev bit masking Tejun Heo
2005-02-02 3:01 ` [PATCH 2.6.11-rc2 17/29] ide: flagged_taskfile() tf_out_flags.b.select check Tejun Heo
2005-02-02 3:02 ` [PATCH 2.6.11-rc2 18/29] ide: comment fixes Tejun Heo
2005-02-03 1:17 ` Bartlomiej Zolnierkiewicz
2005-02-02 3:03 ` [PATCH 2.6.11-rc2 19/29] ide: ide_diag_taskfile() rq initialization fix Tejun Heo
2005-02-02 3:05 ` [PATCH 2.6.11-rc2 20/29] ide: task_end_request() fix Tejun Heo
2005-02-02 3:06 ` [PATCH 2.6.11-rc2 21/29] ide: Merge do_rw_taskfile() and flagged_taskfile() Tejun Heo
2005-02-03 18:39 ` Bartlomiej Zolnierkiewicz
2005-02-04 0:30 ` Tejun Heo
2005-02-02 3:07 ` [PATCH 2.6.11-rc2 22/29] ide: convert REQ_DRIVE_TASK to REQ_DRIVE_TASKFILE Tejun Heo
2005-02-03 17:30 ` Bartlomiej Zolnierkiewicz
2005-02-04 0:54 ` Tejun Heo
2005-02-04 1:50 ` Bartlomiej Zolnierkiewicz
2005-02-02 3:08 ` [PATCH 2.6.11-rc2 23/29] ide: map ide_task_ioctl() to ide_taskfile_ioctl() Tejun Heo
2005-02-03 17:37 ` Bartlomiej Zolnierkiewicz
2005-02-03 17:38 ` Bartlomiej Zolnierkiewicz
2005-02-02 3:08 ` [PATCH 2.6.11-rc2 24/29] ide: remove REQ_DRIVE_TASK handling Tejun Heo
2005-02-02 3:10 ` [PATCH 2.6.11-rc2 26/29] ide: map ide_cmd_ioctl() to ide_taskfile_ioctl() Tejun Heo
2005-02-03 17:54 ` Bartlomiej Zolnierkiewicz [this message]
2005-02-04 2:11 ` Tejun Heo
2005-02-04 2:22 ` Bartlomiej Zolnierkiewicz
2005-02-02 3:11 ` [PATCH 2.6.11-rc2 27/29] ide: remove REQ_DRIVE_CMD handling Tejun Heo
2005-02-02 3:11 ` [PATCH 2.6.11-rc2 28/29] ide: ide_init_drive_cmd() now defaults to REQ_DRIVE_TASKFILE Tejun Heo
2005-02-02 3:12 ` [PATCH 2.6.11-rc2 29/29] ide: make data_phase explicit in NO_DATA cases Tejun Heo
2005-02-03 17:43 ` Bartlomiej Zolnierkiewicz
2005-02-04 0:59 ` Tejun Heo
2005-02-04 1:37 ` Bartlomiej Zolnierkiewicz
2005-02-02 3:15 ` [PATCH 2.6.11-rc2 25/29] ide: convert REQ_DRIVE_CMD to REQ_DRIVE_TASKFILE Tejun Heo
2005-02-03 17:46 ` Bartlomiej Zolnierkiewicz
2005-02-04 1:06 ` Tejun Heo
2005-02-04 1:40 ` Bartlomiej Zolnierkiewicz
2005-02-02 8:31 ` [PATCH 2.6.11-rc2 0/29] ide: driver updates Jeff Garzik
2005-02-03 10:03 ` Alan Cox
2005-02-03 1:03 ` Bartlomiej Zolnierkiewicz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=58cb370e050203095417fed306@mail.gmail.com \
--to=bzolnier@gmail.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@home-tj.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).