aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-27 07:46:39 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-27 07:46:39 -0400
commit0dfb991c6943c810175376b58d1c29cfe532541b (patch)
treec7b82d2ea9159e94c40f8df1a178dab4d2590ed3 /drivers/ide
parent04d09b0e62f2180a7e3fa8578ed778eca0c454fd (diff)
ide: use ata_tf_protocols enums
* Add IDE_TFLAG_MULTI_PIO taskfile flag and set it for commands using multi-PIO protocol. * Use ata_tf_protocols enums instead of TASKFILE_* defines to denote command's protocol and then rename ->data_phase field to ->protocol. * Remove no longer needed <linux/hdreg.h> includes. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-disk.c34
-rw-r--r--drivers/ide/ide-disk_proc.c5
-rw-r--r--drivers/ide/ide-io.c11
-rw-r--r--drivers/ide/ide-ioctls.c2
-rw-r--r--drivers/ide/ide-park.c4
-rw-r--r--drivers/ide/ide-pm.c5
-rw-r--r--drivers/ide/ide-taskfile.c83
7 files changed, 56 insertions, 88 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index d00d807c0f53..dae9d988de10 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -28,7 +28,6 @@
28#include <linux/mutex.h> 28#include <linux/mutex.h>
29#include <linux/leds.h> 29#include <linux/leds.h>
30#include <linux/ide.h> 30#include <linux/ide.h>
31#include <linux/hdreg.h>
32 31
33#include <asm/byteorder.h> 32#include <asm/byteorder.h>
34#include <asm/irq.h> 33#include <asm/irq.h>
@@ -53,15 +52,6 @@ static const u8 ide_rw_cmds[] = {
53 ATA_CMD_WRITE_EXT, 52 ATA_CMD_WRITE_EXT,
54}; 53};
55 54
56static const u8 ide_data_phases[] = {
57 TASKFILE_MULTI_IN,
58 TASKFILE_MULTI_OUT,
59 TASKFILE_IN,
60 TASKFILE_OUT,
61 TASKFILE_IN_DMA,
62 TASKFILE_OUT_DMA,
63};
64
65static void ide_tf_set_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 dma) 55static void ide_tf_set_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 dma)
66{ 56{
67 u8 index, lba48, write; 57 u8 index, lba48, write;
@@ -69,17 +59,19 @@ static void ide_tf_set_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 dma)
69 lba48 = (cmd->tf_flags & IDE_TFLAG_LBA48) ? 2 : 0; 59 lba48 = (cmd->tf_flags & IDE_TFLAG_LBA48) ? 2 : 0;
70 write = (cmd->tf_flags & IDE_TFLAG_WRITE) ? 1 : 0; 60 write = (cmd->tf_flags & IDE_TFLAG_WRITE) ? 1 : 0;
71 61
72 if (dma) 62 if (dma) {
63 cmd->protocol = ATA_PROT_DMA;
73 index = 8; 64 index = 8;
74 else 65 } else {
75 index = drive->mult_count ? 0 : 4; 66 cmd->protocol = ATA_PROT_PIO;
67 if (drive->mult_count) {
68 cmd->tf_flags |= IDE_TFLAG_MULTI_PIO;
69 index = 0;
70 } else
71 index = 4;
72 }
76 73
77 cmd->tf.command = ide_rw_cmds[index + lba48 + write]; 74 cmd->tf.command = ide_rw_cmds[index + lba48 + write];
78
79 if (dma)
80 index = 8; /* fixup index */
81
82 cmd->data_phase = ide_data_phases[index / 2 + write];
83} 75}
84 76
85/* 77/*
@@ -401,9 +393,9 @@ static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
401 cmd->tf.command = ATA_CMD_FLUSH_EXT; 393 cmd->tf.command = ATA_CMD_FLUSH_EXT;
402 else 394 else
403 cmd->tf.command = ATA_CMD_FLUSH; 395 cmd->tf.command = ATA_CMD_FLUSH;
404 cmd->tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE | 396 cmd->tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE |
405 IDE_TFLAG_DYN; 397 IDE_TFLAG_DYN;
406 cmd->data_phase = TASKFILE_NO_DATA; 398 cmd->protocol = ATA_PROT_NODATA;
407 399
408 rq->cmd_type = REQ_TYPE_ATA_TASKFILE; 400 rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
409 rq->cmd_flags |= REQ_SOFTBARRIER; 401 rq->cmd_flags |= REQ_SOFTBARRIER;
diff --git a/drivers/ide/ide-disk_proc.c b/drivers/ide/ide-disk_proc.c
index afe4f47e9e19..eaea3bef2073 100644
--- a/drivers/ide/ide-disk_proc.c
+++ b/drivers/ide/ide-disk_proc.c
@@ -1,6 +1,5 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/ide.h> 2#include <linux/ide.h>
3#include <linux/hdreg.h>
4 3
5#include "ide-disk.h" 4#include "ide-disk.h"
6 5
@@ -30,8 +29,8 @@ static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd)
30 tf->lbam = ATA_SMART_LBAM_PASS; 29 tf->lbam = ATA_SMART_LBAM_PASS;
31 tf->lbah = ATA_SMART_LBAH_PASS; 30 tf->lbah = ATA_SMART_LBAH_PASS;
32 tf->command = ATA_CMD_SMART; 31 tf->command = ATA_CMD_SMART;
33 cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 32 cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
34 cmd.data_phase = TASKFILE_IN; 33 cmd.protocol = ATA_PROT_PIO;
35 34
36 return ide_raw_taskfile(drive, &cmd, buf, 1); 35 return ide_raw_taskfile(drive, &cmd, buf, 1);
37} 36}
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 7917fa09bf15..c27eaab1ffcf 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -40,7 +40,6 @@
40#include <linux/pci.h> 40#include <linux/pci.h>
41#include <linux/delay.h> 41#include <linux/delay.h>
42#include <linux/ide.h> 42#include <linux/ide.h>
43#include <linux/hdreg.h>
44#include <linux/completion.h> 43#include <linux/completion.h>
45#include <linux/reboot.h> 44#include <linux/reboot.h>
46#include <linux/cdrom.h> 45#include <linux/cdrom.h>
@@ -220,7 +219,7 @@ static ide_startstop_t ide_disk_special(ide_drive_t *drive)
220 struct ide_cmd cmd; 219 struct ide_cmd cmd;
221 220
222 memset(&cmd, 0, sizeof(cmd)); 221 memset(&cmd, 0, sizeof(cmd));
223 cmd.data_phase = TASKFILE_NO_DATA; 222 cmd.protocol = ATA_PROT_NODATA;
224 223
225 if (s->b.set_geometry) { 224 if (s->b.set_geometry) {
226 s->b.set_geometry = 0; 225 s->b.set_geometry = 0;
@@ -314,15 +313,9 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
314 struct ide_cmd *cmd = rq->special; 313 struct ide_cmd *cmd = rq->special;
315 314
316 if (cmd) { 315 if (cmd) {
317 switch (cmd->data_phase) { 316 if (cmd->protocol == ATA_PROT_PIO) {
318 case TASKFILE_MULTI_OUT:
319 case TASKFILE_OUT:
320 case TASKFILE_MULTI_IN:
321 case TASKFILE_IN:
322 ide_init_sg_cmd(cmd, rq->nr_sectors); 317 ide_init_sg_cmd(cmd, rq->nr_sectors);
323 ide_map_sg(drive, rq); 318 ide_map_sg(drive, rq);
324 default:
325 break;
326 } 319 }
327 320
328 return do_rw_taskfile(drive, cmd); 321 return do_rw_taskfile(drive, cmd);
diff --git a/drivers/ide/ide-ioctls.c b/drivers/ide/ide-ioctls.c
index 4953028a13d4..770142767437 100644
--- a/drivers/ide/ide-ioctls.c
+++ b/drivers/ide/ide-ioctls.c
@@ -148,7 +148,7 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg)
148 IDE_TFLAG_IN_NSECT; 148 IDE_TFLAG_IN_NSECT;
149 } 149 }
150 tf->command = args[0]; 150 tf->command = args[0];
151 cmd.data_phase = args[3] ? TASKFILE_IN : TASKFILE_NO_DATA; 151 cmd.protocol = args[3] ? ATA_PROT_PIO : ATA_PROT_NODATA;
152 152
153 if (args[3]) { 153 if (args[3]) {
154 cmd.tf_flags |= IDE_TFLAG_IO_16BIT; 154 cmd.tf_flags |= IDE_TFLAG_IO_16BIT;
diff --git a/drivers/ide/ide-park.c b/drivers/ide/ide-park.c
index 63c77f99a726..c575900d5596 100644
--- a/drivers/ide/ide-park.c
+++ b/drivers/ide/ide-park.c
@@ -1,6 +1,5 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/ide.h> 2#include <linux/ide.h>
3#include <linux/hdreg.h>
4#include <linux/jiffies.h> 3#include <linux/jiffies.h>
5#include <linux/blkdev.h> 4#include <linux/blkdev.h>
6 5
@@ -80,8 +79,9 @@ ide_startstop_t ide_do_park_unpark(ide_drive_t *drive, struct request *rq)
80 tf->command = ATA_CMD_CHK_POWER; 79 tf->command = ATA_CMD_CHK_POWER;
81 80
82 cmd.tf_flags |= IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 81 cmd.tf_flags |= IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
82 cmd.protocol = ATA_PROT_NODATA;
83
83 cmd.rq = rq; 84 cmd.rq = rq;
84 cmd.data_phase = TASKFILE_NO_DATA;
85 85
86 return do_rw_taskfile(drive, &cmd); 86 return do_rw_taskfile(drive, &cmd);
87} 87}
diff --git a/drivers/ide/ide-pm.c b/drivers/ide/ide-pm.c
index 5c9fc20f95b5..ebf2d21ebdcb 100644
--- a/drivers/ide/ide-pm.c
+++ b/drivers/ide/ide-pm.c
@@ -1,6 +1,5 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/ide.h> 2#include <linux/ide.h>
3#include <linux/hdreg.h>
4 3
5int generic_ide_suspend(struct device *dev, pm_message_t mesg) 4int generic_ide_suspend(struct device *dev, pm_message_t mesg)
6{ 5{
@@ -164,8 +163,8 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
164 return ide_stopped; 163 return ide_stopped;
165 164
166out_do_tf: 165out_do_tf:
167 cmd->tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 166 cmd->tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
168 cmd->data_phase = TASKFILE_NO_DATA; 167 cmd->protocol = ATA_PROT_NODATA;
169 168
170 return do_rw_taskfile(drive, cmd); 169 return do_rw_taskfile(drive, cmd);
171} 170}
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 647216c772d9..0c9d71485728 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -47,8 +47,8 @@ int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf)
47 cmd.tf.command = ATA_CMD_ID_ATA; 47 cmd.tf.command = ATA_CMD_ID_ATA;
48 else 48 else
49 cmd.tf.command = ATA_CMD_ID_ATAPI; 49 cmd.tf.command = ATA_CMD_ID_ATAPI;
50 cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 50 cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
51 cmd.data_phase = TASKFILE_IN; 51 cmd.protocol = ATA_PROT_PIO;
52 52
53 return ide_raw_taskfile(drive, &cmd, buf, 1); 53 return ide_raw_taskfile(drive, &cmd, buf, 1);
54} 54}
@@ -66,13 +66,11 @@ ide_startstop_t do_rw_taskfile(ide_drive_t *drive, struct ide_cmd *orig_cmd)
66 const struct ide_tp_ops *tp_ops = hwif->tp_ops; 66 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
67 const struct ide_dma_ops *dma_ops = hwif->dma_ops; 67 const struct ide_dma_ops *dma_ops = hwif->dma_ops;
68 68
69 if (orig_cmd->data_phase == TASKFILE_MULTI_IN || 69 if (orig_cmd->protocol == ATA_PROT_PIO &&
70 orig_cmd->data_phase == TASKFILE_MULTI_OUT) { 70 (orig_cmd->tf_flags & IDE_TFLAG_MULTI_PIO) &&
71 if (!drive->mult_count) { 71 drive->mult_count == 0) {
72 printk(KERN_ERR "%s: multimode not set!\n", 72 printk(KERN_ERR "%s: multimode not set!\n", drive->name);
73 drive->name); 73 return ide_stopped;
74 return ide_stopped;
75 }
76 } 74 }
77 75
78 if (orig_cmd->ftf_flags & IDE_FTFLAG_FLAGGED) 76 if (orig_cmd->ftf_flags & IDE_FTFLAG_FLAGGED)
@@ -87,17 +85,16 @@ ide_startstop_t do_rw_taskfile(ide_drive_t *drive, struct ide_cmd *orig_cmd)
87 tp_ops->tf_load(drive, cmd); 85 tp_ops->tf_load(drive, cmd);
88 } 86 }
89 87
90 switch (cmd->data_phase) { 88 switch (cmd->protocol) {
91 case TASKFILE_MULTI_OUT: 89 case ATA_PROT_PIO:
92 case TASKFILE_OUT: 90 if (cmd->tf_flags & IDE_TFLAG_WRITE) {
93 tp_ops->exec_command(hwif, tf->command); 91 tp_ops->exec_command(hwif, tf->command);
94 ndelay(400); /* FIXME */ 92 ndelay(400); /* FIXME */
95 return pre_task_out_intr(drive, cmd); 93 return pre_task_out_intr(drive, cmd);
96 case TASKFILE_MULTI_IN: 94 }
97 case TASKFILE_IN:
98 handler = task_in_intr; 95 handler = task_in_intr;
99 /* fall-through */ 96 /* fall-through */
100 case TASKFILE_NO_DATA: 97 case ATA_PROT_NODATA:
101 if (handler == NULL) 98 if (handler == NULL)
102 handler = task_no_data_intr; 99 handler = task_no_data_intr;
103 ide_execute_command(drive, tf->command, handler, 100 ide_execute_command(drive, tf->command, handler,
@@ -115,9 +112,6 @@ ide_startstop_t do_rw_taskfile(ide_drive_t *drive, struct ide_cmd *orig_cmd)
115} 112}
116EXPORT_SYMBOL_GPL(do_rw_taskfile); 113EXPORT_SYMBOL_GPL(do_rw_taskfile);
117 114
118/*
119 * Handler for commands without a data phase
120 */
121static ide_startstop_t task_no_data_intr(ide_drive_t *drive) 115static ide_startstop_t task_no_data_intr(ide_drive_t *drive)
122{ 116{
123 ide_hwif_t *hwif = drive->hwif; 117 ide_hwif_t *hwif = drive->hwif;
@@ -278,15 +272,10 @@ static void ide_pio_datablock(ide_drive_t *drive, struct ide_cmd *cmd,
278 272
279 touch_softlockup_watchdog(); 273 touch_softlockup_watchdog();
280 274
281 switch (cmd->data_phase) { 275 if (cmd->tf_flags & IDE_TFLAG_MULTI_PIO)
282 case TASKFILE_MULTI_IN:
283 case TASKFILE_MULTI_OUT:
284 ide_pio_multi(drive, cmd, write); 276 ide_pio_multi(drive, cmd, write);
285 break; 277 else
286 default:
287 ide_pio_sector(drive, cmd, write); 278 ide_pio_sector(drive, cmd, write);
288 break;
289 }
290 279
291 drive->io_32bit = saved_io_32bit; 280 drive->io_32bit = saved_io_32bit;
292} 281}
@@ -297,22 +286,12 @@ static ide_startstop_t task_error(ide_drive_t *drive, struct ide_cmd *cmd,
297 if (cmd->tf_flags & IDE_TFLAG_FS) { 286 if (cmd->tf_flags & IDE_TFLAG_FS) {
298 int sectors = cmd->nsect - cmd->nleft; 287 int sectors = cmd->nsect - cmd->nleft;
299 288
300 switch (cmd->data_phase) { 289 if (cmd->protocol == ATA_PROT_PIO &&
301 case TASKFILE_IN: 290 ((cmd->tf_flags & IDE_TFLAG_WRITE) || cmd->nleft == 0)) {
302 if (cmd->nleft) 291 if (cmd->tf_flags & IDE_TFLAG_MULTI_PIO)
303 break; 292 sectors -= drive->mult_count;
304 /* fall through */ 293 else
305 case TASKFILE_OUT: 294 sectors--;
306 sectors--;
307 break;
308 case TASKFILE_MULTI_IN:
309 if (cmd->nleft)
310 break;
311 /* fall through */
312 case TASKFILE_MULTI_OUT:
313 sectors -= drive->mult_count;
314 default:
315 break;
316 } 295 }
317 296
318 if (sectors > 0) 297 if (sectors > 0)
@@ -425,7 +404,7 @@ static ide_startstop_t pre_task_out_intr(ide_drive_t *drive,
425 drive->bad_wstat, WAIT_DRQ)) { 404 drive->bad_wstat, WAIT_DRQ)) {
426 printk(KERN_ERR "%s: no DRQ after issuing %sWRITE%s\n", 405 printk(KERN_ERR "%s: no DRQ after issuing %sWRITE%s\n",
427 drive->name, 406 drive->name,
428 cmd->data_phase == TASKFILE_MULTI_OUT ? "MULT" : "", 407 (cmd->tf_flags & IDE_TFLAG_MULTI_PIO) ? "MULT" : "",
429 (drive->dev_flags & IDE_DFLAG_LBA48) ? "_EXT" : ""); 408 (drive->dev_flags & IDE_DFLAG_LBA48) ? "_EXT" : "");
430 return startstop; 409 return startstop;
431 } 410 }
@@ -474,7 +453,7 @@ EXPORT_SYMBOL(ide_raw_taskfile);
474 453
475int ide_no_data_taskfile(ide_drive_t *drive, struct ide_cmd *cmd) 454int ide_no_data_taskfile(ide_drive_t *drive, struct ide_cmd *cmd)
476{ 455{
477 cmd->data_phase = TASKFILE_NO_DATA; 456 cmd->protocol = ATA_PROT_NODATA;
478 457
479 return ide_raw_taskfile(drive, cmd, NULL, 0); 458 return ide_raw_taskfile(drive, cmd, NULL, 0);
480} 459}
@@ -545,7 +524,6 @@ int ide_taskfile_ioctl(ide_drive_t *drive, unsigned long arg)
545 memcpy(&cmd.tf_array[6], req_task->io_ports, 524 memcpy(&cmd.tf_array[6], req_task->io_ports,
546 HDIO_DRIVE_TASK_HDR_SIZE); 525 HDIO_DRIVE_TASK_HDR_SIZE);
547 526
548 cmd.data_phase = req_task->data_phase;
549 cmd.tf_flags = IDE_TFLAG_IO_16BIT | IDE_TFLAG_DEVICE | 527 cmd.tf_flags = IDE_TFLAG_IO_16BIT | IDE_TFLAG_DEVICE |
550 IDE_TFLAG_IN_TF; 528 IDE_TFLAG_IN_TF;
551 529
@@ -590,10 +568,12 @@ int ide_taskfile_ioctl(ide_drive_t *drive, unsigned long arg)
590 /* fixup data phase if needed */ 568 /* fixup data phase if needed */
591 if (req_task->data_phase == TASKFILE_IN_DMAQ || 569 if (req_task->data_phase == TASKFILE_IN_DMAQ ||
592 req_task->data_phase == TASKFILE_IN_DMA) 570 req_task->data_phase == TASKFILE_IN_DMA)
593 cmd.data_phase = TASKFILE_OUT_DMA; 571 cmd.tf_flags |= IDE_TFLAG_WRITE;
594 } 572 }
595 573
596 switch (cmd.data_phase) { 574 cmd.protocol = ATA_PROT_DMA;
575
576 switch (req_task->data_phase) {
597 case TASKFILE_MULTI_OUT: 577 case TASKFILE_MULTI_OUT:
598 if (!drive->mult_count) { 578 if (!drive->mult_count) {
599 /* (hs): give up if multcount is not set */ 579 /* (hs): give up if multcount is not set */
@@ -603,8 +583,10 @@ int ide_taskfile_ioctl(ide_drive_t *drive, unsigned long arg)
603 err = -EPERM; 583 err = -EPERM;
604 goto abort; 584 goto abort;
605 } 585 }
586 cmd.tf_flags |= IDE_TFLAG_MULTI_PIO;
606 /* fall through */ 587 /* fall through */
607 case TASKFILE_OUT: 588 case TASKFILE_OUT:
589 cmd.protocol = ATA_PROT_PIO;
608 /* fall through */ 590 /* fall through */
609 case TASKFILE_OUT_DMAQ: 591 case TASKFILE_OUT_DMAQ:
610 case TASKFILE_OUT_DMA: 592 case TASKFILE_OUT_DMA:
@@ -621,8 +603,10 @@ int ide_taskfile_ioctl(ide_drive_t *drive, unsigned long arg)
621 err = -EPERM; 603 err = -EPERM;
622 goto abort; 604 goto abort;
623 } 605 }
606 cmd.tf_flags |= IDE_TFLAG_MULTI_PIO;
624 /* fall through */ 607 /* fall through */
625 case TASKFILE_IN: 608 case TASKFILE_IN:
609 cmd.protocol = ATA_PROT_PIO;
626 /* fall through */ 610 /* fall through */
627 case TASKFILE_IN_DMAQ: 611 case TASKFILE_IN_DMAQ:
628 case TASKFILE_IN_DMA: 612 case TASKFILE_IN_DMA:
@@ -630,6 +614,7 @@ int ide_taskfile_ioctl(ide_drive_t *drive, unsigned long arg)
630 data_buf = inbuf; 614 data_buf = inbuf;
631 break; 615 break;
632 case TASKFILE_NO_DATA: 616 case TASKFILE_NO_DATA:
617 cmd.protocol = ATA_PROT_NODATA;
633 break; 618 break;
634 default: 619 default:
635 err = -EFAULT; 620 err = -EFAULT;