diff options
author | Tejun Heo <tj@kernel.org> | 2008-11-03 06:03:17 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-12-28 22:43:20 -0500 |
commit | 1eca4365be25c540650693e941bc06a66cf38f94 (patch) | |
tree | e3ed82850da00308180bf166118f9f9e69d92898 /drivers/ata/pata_pdc2027x.c | |
parent | 3c92ec8ae91ecf59d88c798301833d7cf83f2179 (diff) |
libata: beef up iterators
There currently are the following looping constructs.
* __ata_port_for_each_link() for all available links
* ata_port_for_each_link() for edge links
* ata_link_for_each_dev() for all devices
* ata_link_for_each_dev_reverse() for all devices in reverse order
Now there's a need for looping construct which is similar to
__ata_port_for_each_link() but iterates over PMP links before the host
link. Instead of adding another one with long name, do the following
cleanup.
* Implement and export ata_link_next() and ata_dev_next() which take
@mode parameter and can be used to build custom loop.
* Implement ata_for_each_link() and ata_for_each_dev() which take
looping mode explicitly.
The following iteration modes are implemented.
* ATA_LITER_EDGE : loop over edge links
* ATA_LITER_HOST_FIRST : loop over all links, host link first
* ATA_LITER_PMP_FIRST : loop over all links, PMP links first
* ATA_DITER_ENABLED : loop over enabled devices
* ATA_DITER_ENABLED_REVERSE : loop over enabled devices in reverse order
* ATA_DITER_ALL : loop over all devices
* ATA_DITER_ALL_REVERSE : loop over all devices in reverse order
This change removes exlicit device enabledness checks from many loops
and makes it clear which ones are iterated over in which direction.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata/pata_pdc2027x.c')
-rw-r--r-- | drivers/ata/pata_pdc2027x.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c index 0e1c2c1134d3..d43e8be96b88 100644 --- a/drivers/ata/pata_pdc2027x.c +++ b/drivers/ata/pata_pdc2027x.c | |||
@@ -406,23 +406,20 @@ static int pdc2027x_set_mode(struct ata_link *link, struct ata_device **r_failed | |||
406 | if (rc < 0) | 406 | if (rc < 0) |
407 | return rc; | 407 | return rc; |
408 | 408 | ||
409 | ata_link_for_each_dev(dev, link) { | 409 | ata_for_each_dev(dev, link, ENABLED) { |
410 | if (ata_dev_enabled(dev)) { | 410 | pdc2027x_set_piomode(ap, dev); |
411 | 411 | ||
412 | pdc2027x_set_piomode(ap, dev); | 412 | /* |
413 | 413 | * Enable prefetch if the device support PIO only. | |
414 | /* | 414 | */ |
415 | * Enable prefetch if the device support PIO only. | 415 | if (dev->xfer_shift == ATA_SHIFT_PIO) { |
416 | */ | 416 | u32 ctcr1 = ioread32(dev_mmio(ap, dev, PDC_CTCR1)); |
417 | if (dev->xfer_shift == ATA_SHIFT_PIO) { | 417 | ctcr1 |= (1 << 25); |
418 | u32 ctcr1 = ioread32(dev_mmio(ap, dev, PDC_CTCR1)); | 418 | iowrite32(ctcr1, dev_mmio(ap, dev, PDC_CTCR1)); |
419 | ctcr1 |= (1 << 25); | 419 | |
420 | iowrite32(ctcr1, dev_mmio(ap, dev, PDC_CTCR1)); | 420 | PDPRINTK("Turn on prefetch\n"); |
421 | 421 | } else { | |
422 | PDPRINTK("Turn on prefetch\n"); | 422 | pdc2027x_set_dmamode(ap, dev); |
423 | } else { | ||
424 | pdc2027x_set_dmamode(ap, dev); | ||
425 | } | ||
426 | } | 423 | } |
427 | } | 424 | } |
428 | return 0; | 425 | return 0; |