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/ahci.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/ahci.c')
-rw-r--r-- | drivers/ata/ahci.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index a67b8e7c712d..656448c7fef9 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -1119,14 +1119,14 @@ static void ahci_start_port(struct ata_port *ap) | |||
1119 | 1119 | ||
1120 | /* turn on LEDs */ | 1120 | /* turn on LEDs */ |
1121 | if (ap->flags & ATA_FLAG_EM) { | 1121 | if (ap->flags & ATA_FLAG_EM) { |
1122 | ata_port_for_each_link(link, ap) { | 1122 | ata_for_each_link(link, ap, EDGE) { |
1123 | emp = &pp->em_priv[link->pmp]; | 1123 | emp = &pp->em_priv[link->pmp]; |
1124 | ahci_transmit_led_message(ap, emp->led_state, 4); | 1124 | ahci_transmit_led_message(ap, emp->led_state, 4); |
1125 | } | 1125 | } |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | if (ap->flags & ATA_FLAG_SW_ACTIVITY) | 1128 | if (ap->flags & ATA_FLAG_SW_ACTIVITY) |
1129 | ata_port_for_each_link(link, ap) | 1129 | ata_for_each_link(link, ap, EDGE) |
1130 | ahci_init_sw_activity(link); | 1130 | ahci_init_sw_activity(link); |
1131 | 1131 | ||
1132 | } | 1132 | } |
@@ -1361,7 +1361,7 @@ static ssize_t ahci_led_show(struct ata_port *ap, char *buf) | |||
1361 | struct ahci_em_priv *emp; | 1361 | struct ahci_em_priv *emp; |
1362 | int rc = 0; | 1362 | int rc = 0; |
1363 | 1363 | ||
1364 | ata_port_for_each_link(link, ap) { | 1364 | ata_for_each_link(link, ap, EDGE) { |
1365 | emp = &pp->em_priv[link->pmp]; | 1365 | emp = &pp->em_priv[link->pmp]; |
1366 | rc += sprintf(buf, "%lx\n", emp->led_state); | 1366 | rc += sprintf(buf, "%lx\n", emp->led_state); |
1367 | } | 1367 | } |
@@ -1941,7 +1941,7 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat) | |||
1941 | u32 serror; | 1941 | u32 serror; |
1942 | 1942 | ||
1943 | /* determine active link */ | 1943 | /* determine active link */ |
1944 | ata_port_for_each_link(link, ap) | 1944 | ata_for_each_link(link, ap, EDGE) |
1945 | if (ata_link_active(link)) | 1945 | if (ata_link_active(link)) |
1946 | break; | 1946 | break; |
1947 | if (!link) | 1947 | if (!link) |