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/libata-acpi.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/libata-acpi.c')
-rw-r--r-- | drivers/ata/libata-acpi.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index c012307d0ba6..ef02e488d468 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c | |||
@@ -89,7 +89,7 @@ void ata_acpi_associate_sata_port(struct ata_port *ap) | |||
89 | 89 | ||
90 | ap->link.device->acpi_handle = NULL; | 90 | ap->link.device->acpi_handle = NULL; |
91 | 91 | ||
92 | ata_port_for_each_link(link, ap) { | 92 | ata_for_each_link(link, ap, EDGE) { |
93 | acpi_integer adr = SATA_ADR(ap->port_no, link->pmp); | 93 | acpi_integer adr = SATA_ADR(ap->port_no, link->pmp); |
94 | 94 | ||
95 | link->device->acpi_handle = | 95 | link->device->acpi_handle = |
@@ -129,8 +129,8 @@ static void ata_acpi_detach_device(struct ata_port *ap, struct ata_device *dev) | |||
129 | struct ata_link *tlink; | 129 | struct ata_link *tlink; |
130 | struct ata_device *tdev; | 130 | struct ata_device *tdev; |
131 | 131 | ||
132 | ata_port_for_each_link(tlink, ap) | 132 | ata_for_each_link(tlink, ap, EDGE) |
133 | ata_link_for_each_dev(tdev, tlink) | 133 | ata_for_each_dev(tdev, tlink, ALL) |
134 | tdev->flags |= ATA_DFLAG_DETACH; | 134 | tdev->flags |= ATA_DFLAG_DETACH; |
135 | } | 135 | } |
136 | 136 | ||
@@ -588,12 +588,9 @@ int ata_acpi_cbl_80wire(struct ata_port *ap, const struct ata_acpi_gtm *gtm) | |||
588 | { | 588 | { |
589 | struct ata_device *dev; | 589 | struct ata_device *dev; |
590 | 590 | ||
591 | ata_link_for_each_dev(dev, &ap->link) { | 591 | ata_for_each_dev(dev, &ap->link, ENABLED) { |
592 | unsigned long xfer_mask, udma_mask; | 592 | unsigned long xfer_mask, udma_mask; |
593 | 593 | ||
594 | if (!ata_dev_enabled(dev)) | ||
595 | continue; | ||
596 | |||
597 | xfer_mask = ata_acpi_gtm_xfermask(dev, gtm); | 594 | xfer_mask = ata_acpi_gtm_xfermask(dev, gtm); |
598 | ata_unpack_xfermask(xfer_mask, NULL, NULL, &udma_mask); | 595 | ata_unpack_xfermask(xfer_mask, NULL, NULL, &udma_mask); |
599 | 596 | ||
@@ -893,7 +890,7 @@ void ata_acpi_on_resume(struct ata_port *ap) | |||
893 | * use values set by _STM. Cache _GTF result and | 890 | * use values set by _STM. Cache _GTF result and |
894 | * schedule _GTF. | 891 | * schedule _GTF. |
895 | */ | 892 | */ |
896 | ata_link_for_each_dev(dev, &ap->link) { | 893 | ata_for_each_dev(dev, &ap->link, ALL) { |
897 | ata_acpi_clear_gtf(dev); | 894 | ata_acpi_clear_gtf(dev); |
898 | if (ata_dev_enabled(dev) && | 895 | if (ata_dev_enabled(dev) && |
899 | ata_dev_get_GTF(dev, NULL) >= 0) | 896 | ata_dev_get_GTF(dev, NULL) >= 0) |
@@ -904,7 +901,7 @@ void ata_acpi_on_resume(struct ata_port *ap) | |||
904 | * there's no reason to evaluate IDE _GTF early | 901 | * there's no reason to evaluate IDE _GTF early |
905 | * without _STM. Clear cache and schedule _GTF. | 902 | * without _STM. Clear cache and schedule _GTF. |
906 | */ | 903 | */ |
907 | ata_link_for_each_dev(dev, &ap->link) { | 904 | ata_for_each_dev(dev, &ap->link, ALL) { |
908 | ata_acpi_clear_gtf(dev); | 905 | ata_acpi_clear_gtf(dev); |
909 | if (ata_dev_enabled(dev)) | 906 | if (ata_dev_enabled(dev)) |
910 | dev->flags |= ATA_DFLAG_ACPI_PENDING; | 907 | dev->flags |= ATA_DFLAG_ACPI_PENDING; |
@@ -932,8 +929,8 @@ void ata_acpi_set_state(struct ata_port *ap, pm_message_t state) | |||
932 | if (state.event == PM_EVENT_ON) | 929 | if (state.event == PM_EVENT_ON) |
933 | acpi_bus_set_power(ap->acpi_handle, ACPI_STATE_D0); | 930 | acpi_bus_set_power(ap->acpi_handle, ACPI_STATE_D0); |
934 | 931 | ||
935 | ata_link_for_each_dev(dev, &ap->link) { | 932 | ata_for_each_dev(dev, &ap->link, ENABLED) { |
936 | if (dev->acpi_handle && ata_dev_enabled(dev)) | 933 | if (dev->acpi_handle) |
937 | acpi_bus_set_power(dev->acpi_handle, | 934 | acpi_bus_set_power(dev->acpi_handle, |
938 | state.event == PM_EVENT_ON ? | 935 | state.event == PM_EVENT_ON ? |
939 | ACPI_STATE_D0 : ACPI_STATE_D3); | 936 | ACPI_STATE_D0 : ACPI_STATE_D3); |