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_legacy.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_legacy.c')
-rw-r--r-- | drivers/ata/pata_legacy.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c index 930c2208640b..cbd98c16eea4 100644 --- a/drivers/ata/pata_legacy.c +++ b/drivers/ata/pata_legacy.c | |||
@@ -194,15 +194,12 @@ static int legacy_set_mode(struct ata_link *link, struct ata_device **unused) | |||
194 | { | 194 | { |
195 | struct ata_device *dev; | 195 | struct ata_device *dev; |
196 | 196 | ||
197 | ata_link_for_each_dev(dev, link) { | 197 | ata_for_each_dev(dev, link, ENABLED) { |
198 | if (ata_dev_enabled(dev)) { | 198 | ata_dev_printk(dev, KERN_INFO, "configured for PIO\n"); |
199 | ata_dev_printk(dev, KERN_INFO, | 199 | dev->pio_mode = XFER_PIO_0; |
200 | "configured for PIO\n"); | 200 | dev->xfer_mode = XFER_PIO_0; |
201 | dev->pio_mode = XFER_PIO_0; | 201 | dev->xfer_shift = ATA_SHIFT_PIO; |
202 | dev->xfer_mode = XFER_PIO_0; | 202 | dev->flags |= ATA_DFLAG_PIO; |
203 | dev->xfer_shift = ATA_SHIFT_PIO; | ||
204 | dev->flags |= ATA_DFLAG_PIO; | ||
205 | } | ||
206 | } | 203 | } |
207 | return 0; | 204 | return 0; |
208 | } | 205 | } |
@@ -1028,7 +1025,7 @@ static __init int legacy_init_one(struct legacy_probe *probe) | |||
1028 | /* Nothing found means we drop the port as its probably not there */ | 1025 | /* Nothing found means we drop the port as its probably not there */ |
1029 | 1026 | ||
1030 | ret = -ENODEV; | 1027 | ret = -ENODEV; |
1031 | ata_link_for_each_dev(dev, &ap->link) { | 1028 | ata_for_each_dev(dev, &ap->link, ALL) { |
1032 | if (!ata_dev_absent(dev)) { | 1029 | if (!ata_dev_absent(dev)) { |
1033 | legacy_host[probe->slot] = host; | 1030 | legacy_host[probe->slot] = host; |
1034 | ld->platform_dev = pdev; | 1031 | ld->platform_dev = pdev; |