diff options
author | Sergei Shtylyov <sshtylyov@ru.mvista.com> | 2009-04-08 08:13:03 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-04-08 08:13:03 -0400 |
commit | c9ff9e7b64138d87023b733e618f29a1d58543f7 (patch) | |
tree | e0697999409235309c578d3c8a7ecc031be2eda0 /drivers/ide | |
parent | 30881b9ac91e7c23e0ceb8414ab7de1961809bdd (diff) |
ide: refactor tf_load() method
Simplify tf_load() method, making it deal only with 'struct ide_taskfile' and
the validity flags that the upper layer passes, and moving the code that deals
with the high order bytes into the only function interested, do_rw_taskfile().
This should stop the needless code duplication in this method and so make
it about twice smaller than it was; along with simplifying the setup for the
method call, this should save both time and space...
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide-io-std.c | 18 | ||||
-rw-r--r-- | drivers/ide/ide-iops.c | 11 | ||||
-rw-r--r-- | drivers/ide/ide-probe.c | 8 | ||||
-rw-r--r-- | drivers/ide/ide-taskfile.c | 3 | ||||
-rw-r--r-- | drivers/ide/scc_pata.c | 18 | ||||
-rw-r--r-- | drivers/ide/tx4939ide.c | 7 |
6 files changed, 16 insertions, 49 deletions
diff --git a/drivers/ide/ide-io-std.c b/drivers/ide/ide-io-std.c index 66c27768e85b..481e221b233d 100644 --- a/drivers/ide/ide-io-std.c +++ b/drivers/ide/ide-io-std.c | |||
@@ -85,13 +85,11 @@ void ide_dev_select(ide_drive_t *drive) | |||
85 | } | 85 | } |
86 | EXPORT_SYMBOL_GPL(ide_dev_select); | 86 | EXPORT_SYMBOL_GPL(ide_dev_select); |
87 | 87 | ||
88 | void ide_tf_load(ide_drive_t *drive, struct ide_cmd *cmd) | 88 | void ide_tf_load(ide_drive_t *drive, struct ide_taskfile *tf, u8 valid) |
89 | { | 89 | { |
90 | ide_hwif_t *hwif = drive->hwif; | 90 | ide_hwif_t *hwif = drive->hwif; |
91 | struct ide_io_ports *io_ports = &hwif->io_ports; | 91 | struct ide_io_ports *io_ports = &hwif->io_ports; |
92 | struct ide_taskfile *tf = &cmd->hob; | ||
93 | void (*tf_outb)(u8 addr, unsigned long port); | 92 | void (*tf_outb)(u8 addr, unsigned long port); |
94 | u8 valid = cmd->valid.out.hob; | ||
95 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; | 93 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; |
96 | 94 | ||
97 | if (mmio) | 95 | if (mmio) |
@@ -109,20 +107,6 @@ void ide_tf_load(ide_drive_t *drive, struct ide_cmd *cmd) | |||
109 | tf_outb(tf->lbam, io_ports->lbam_addr); | 107 | tf_outb(tf->lbam, io_ports->lbam_addr); |
110 | if (valid & IDE_VALID_LBAH) | 108 | if (valid & IDE_VALID_LBAH) |
111 | tf_outb(tf->lbah, io_ports->lbah_addr); | 109 | tf_outb(tf->lbah, io_ports->lbah_addr); |
112 | |||
113 | tf = &cmd->tf; | ||
114 | valid = cmd->valid.out.tf; | ||
115 | |||
116 | if (valid & IDE_VALID_FEATURE) | ||
117 | tf_outb(tf->feature, io_ports->feature_addr); | ||
118 | if (valid & IDE_VALID_NSECT) | ||
119 | tf_outb(tf->nsect, io_ports->nsect_addr); | ||
120 | if (valid & IDE_VALID_LBAL) | ||
121 | tf_outb(tf->lbal, io_ports->lbal_addr); | ||
122 | if (valid & IDE_VALID_LBAM) | ||
123 | tf_outb(tf->lbam, io_ports->lbam_addr); | ||
124 | if (valid & IDE_VALID_LBAH) | ||
125 | tf_outb(tf->lbah, io_ports->lbah_addr); | ||
126 | if (valid & IDE_VALID_DEVICE) | 110 | if (valid & IDE_VALID_DEVICE) |
127 | tf_outb(tf->device, io_ports->device_addr); | 111 | tf_outb(tf->device, io_ports->device_addr); |
128 | } | 112 | } |
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 0fdf0dfb5743..6f1ed427a484 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -312,10 +312,10 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
312 | { | 312 | { |
313 | ide_hwif_t *hwif = drive->hwif; | 313 | ide_hwif_t *hwif = drive->hwif; |
314 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 314 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
315 | struct ide_taskfile tf; | ||
315 | u16 *id = drive->id, i; | 316 | u16 *id = drive->id, i; |
316 | int error = 0; | 317 | int error = 0; |
317 | u8 stat; | 318 | u8 stat; |
318 | struct ide_cmd cmd; | ||
319 | 319 | ||
320 | #ifdef CONFIG_BLK_DEV_IDEDMA | 320 | #ifdef CONFIG_BLK_DEV_IDEDMA |
321 | if (hwif->dma_ops) /* check if host supports DMA */ | 321 | if (hwif->dma_ops) /* check if host supports DMA */ |
@@ -347,12 +347,11 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
347 | udelay(1); | 347 | udelay(1); |
348 | tp_ops->write_devctl(hwif, ATA_NIEN | ATA_DEVCTL_OBS); | 348 | tp_ops->write_devctl(hwif, ATA_NIEN | ATA_DEVCTL_OBS); |
349 | 349 | ||
350 | memset(&cmd, 0, sizeof(cmd)); | 350 | memset(&tf, 0, sizeof(tf)); |
351 | cmd.valid.out.tf = IDE_VALID_FEATURE | IDE_VALID_NSECT; | 351 | tf.feature = SETFEATURES_XFER; |
352 | cmd.tf.feature = SETFEATURES_XFER; | 352 | tf.nsect = speed; |
353 | cmd.tf.nsect = speed; | ||
354 | 353 | ||
355 | tp_ops->tf_load(drive, &cmd); | 354 | tp_ops->tf_load(drive, &tf, IDE_VALID_FEATURE | IDE_VALID_NSECT); |
356 | 355 | ||
357 | tp_ops->exec_command(hwif, ATA_CMD_SET_FEATURES); | 356 | tp_ops->exec_command(hwif, ATA_CMD_SET_FEATURES); |
358 | 357 | ||
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 6a98d7c1681a..44d7816c1fe9 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -283,13 +283,11 @@ int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id) | |||
283 | * identify command to be sure of reply | 283 | * identify command to be sure of reply |
284 | */ | 284 | */ |
285 | if (cmd == ATA_CMD_ID_ATAPI) { | 285 | if (cmd == ATA_CMD_ID_ATAPI) { |
286 | struct ide_cmd cmd; | 286 | struct ide_taskfile tf; |
287 | 287 | ||
288 | memset(&cmd, 0, sizeof(cmd)); | 288 | memset(&tf, 0, sizeof(tf)); |
289 | /* disable DMA & overlap */ | 289 | /* disable DMA & overlap */ |
290 | cmd.valid.out.tf = IDE_VALID_FEATURE; | 290 | tp_ops->tf_load(drive, &tf, IDE_VALID_FEATURE); |
291 | |||
292 | tp_ops->tf_load(drive, &cmd); | ||
293 | } | 291 | } |
294 | 292 | ||
295 | /* ask drive for ID */ | 293 | /* ask drive for ID */ |
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 0318a4cb09de..b1806ed46175 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c | |||
@@ -98,7 +98,8 @@ ide_startstop_t do_rw_taskfile(ide_drive_t *drive, struct ide_cmd *orig_cmd) | |||
98 | cmd->tf.device |= drive->select; | 98 | cmd->tf.device |= drive->select; |
99 | } | 99 | } |
100 | 100 | ||
101 | tp_ops->tf_load(drive, cmd); | 101 | tp_ops->tf_load(drive, &cmd->hob, cmd->valid.out.hob); |
102 | tp_ops->tf_load(drive, &cmd->tf, cmd->valid.out.tf); | ||
102 | } | 103 | } |
103 | 104 | ||
104 | switch (cmd->protocol) { | 105 | switch (cmd->protocol) { |
diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c index feabf5487049..5ecb70cf29dc 100644 --- a/drivers/ide/scc_pata.c +++ b/drivers/ide/scc_pata.c | |||
@@ -645,25 +645,9 @@ static int __devinit init_setup_scc(struct pci_dev *dev, | |||
645 | return rc; | 645 | return rc; |
646 | } | 646 | } |
647 | 647 | ||
648 | static void scc_tf_load(ide_drive_t *drive, struct ide_cmd *cmd) | 648 | static void scc_tf_load(ide_drive_t *drive, struct ide_taskfile *tf, u8 valid) |
649 | { | 649 | { |
650 | struct ide_io_ports *io_ports = &drive->hwif->io_ports; | 650 | struct ide_io_ports *io_ports = &drive->hwif->io_ports; |
651 | struct ide_taskfile *tf = &cmd->hob; | ||
652 | u8 valid = cmd->valid.out.hob; | ||
653 | |||
654 | if (valid & IDE_VALID_FEATURE) | ||
655 | scc_ide_outb(tf->feature, io_ports->feature_addr); | ||
656 | if (valid & IDE_VALID_NSECT) | ||
657 | scc_ide_outb(tf->nsect, io_ports->nsect_addr); | ||
658 | if (valid & IDE_VALID_LBAL) | ||
659 | scc_ide_outb(tf->lbal, io_ports->lbal_addr); | ||
660 | if (valid & IDE_VALID_LBAM) | ||
661 | scc_ide_outb(tf->lbam, io_ports->lbam_addr); | ||
662 | if (valid & IDE_VALID_LBAH) | ||
663 | scc_ide_outb(tf->lbah, io_ports->lbah_addr); | ||
664 | |||
665 | tf = &cmd->tf; | ||
666 | valid = cmd->valid.out.tf; | ||
667 | 651 | ||
668 | if (valid & IDE_VALID_FEATURE) | 652 | if (valid & IDE_VALID_FEATURE) |
669 | scc_ide_outb(tf->feature, io_ports->feature_addr); | 653 | scc_ide_outb(tf->feature, io_ports->feature_addr); |
diff --git a/drivers/ide/tx4939ide.c b/drivers/ide/tx4939ide.c index af8b0f68d5cf..564422d23976 100644 --- a/drivers/ide/tx4939ide.c +++ b/drivers/ide/tx4939ide.c | |||
@@ -434,11 +434,12 @@ static void tx4939ide_tf_load_fixup(ide_drive_t *drive) | |||
434 | tx4939ide_writew(sysctl, base, TX4939IDE_Sys_Ctl); | 434 | tx4939ide_writew(sysctl, base, TX4939IDE_Sys_Ctl); |
435 | } | 435 | } |
436 | 436 | ||
437 | static void tx4939ide_tf_load(ide_drive_t *drive, struct ide_cmd *cmd) | 437 | static void tx4939ide_tf_load(ide_drive_t *drive, struct ide_taskfile *tf, |
438 | u8 valid) | ||
438 | { | 439 | { |
439 | ide_tf_load(drive, cmd); | 440 | ide_tf_load(drive, tf, valid); |
440 | 441 | ||
441 | if (cmd->valid.out.tf & IDE_VALID_DEVICE) | 442 | if (valid & IDE_VALID_DEVICE) |
442 | tx4939ide_tf_load_fixup(drive); | 443 | tx4939ide_tf_load_fixup(drive); |
443 | } | 444 | } |
444 | 445 | ||