aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-pmp.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2008-11-03 06:03:17 -0500
committerJeff Garzik <jgarzik@redhat.com>2008-12-28 22:43:20 -0500
commit1eca4365be25c540650693e941bc06a66cf38f94 (patch)
treee3ed82850da00308180bf166118f9f9e69d92898 /drivers/ata/libata-pmp.c
parent3c92ec8ae91ecf59d88c798301833d7cf83f2179 (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-pmp.c')
-rw-r--r--drivers/ata/libata-pmp.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index b65db309c181..98ca07a2db87 100644
--- a/drivers/ata/libata-pmp.c
+++ b/drivers/ata/libata-pmp.c
@@ -321,7 +321,7 @@ static void sata_pmp_quirks(struct ata_port *ap)
321 321
322 if (vendor == 0x1095 && devid == 0x3726) { 322 if (vendor == 0x1095 && devid == 0x3726) {
323 /* sil3726 quirks */ 323 /* sil3726 quirks */
324 ata_port_for_each_link(link, ap) { 324 ata_for_each_link(link, ap, EDGE) {
325 /* Class code report is unreliable and SRST 325 /* Class code report is unreliable and SRST
326 * times out under certain configurations. 326 * times out under certain configurations.
327 */ 327 */
@@ -336,7 +336,7 @@ static void sata_pmp_quirks(struct ata_port *ap)
336 } 336 }
337 } else if (vendor == 0x1095 && devid == 0x4723) { 337 } else if (vendor == 0x1095 && devid == 0x4723) {
338 /* sil4723 quirks */ 338 /* sil4723 quirks */
339 ata_port_for_each_link(link, ap) { 339 ata_for_each_link(link, ap, EDGE) {
340 /* class code report is unreliable */ 340 /* class code report is unreliable */
341 if (link->pmp < 2) 341 if (link->pmp < 2)
342 link->flags |= ATA_LFLAG_ASSUME_ATA; 342 link->flags |= ATA_LFLAG_ASSUME_ATA;
@@ -348,7 +348,7 @@ static void sata_pmp_quirks(struct ata_port *ap)
348 } 348 }
349 } else if (vendor == 0x1095 && devid == 0x4726) { 349 } else if (vendor == 0x1095 && devid == 0x4726) {
350 /* sil4726 quirks */ 350 /* sil4726 quirks */
351 ata_port_for_each_link(link, ap) { 351 ata_for_each_link(link, ap, EDGE) {
352 /* Class code report is unreliable and SRST 352 /* Class code report is unreliable and SRST
353 * times out under certain configurations. 353 * times out under certain configurations.
354 * Config device can be at port 0 or 5 and 354 * Config device can be at port 0 or 5 and
@@ -450,7 +450,7 @@ int sata_pmp_attach(struct ata_device *dev)
450 if (ap->ops->pmp_attach) 450 if (ap->ops->pmp_attach)
451 ap->ops->pmp_attach(ap); 451 ap->ops->pmp_attach(ap);
452 452
453 ata_port_for_each_link(tlink, ap) 453 ata_for_each_link(tlink, ap, EDGE)
454 sata_link_init_spd(tlink); 454 sata_link_init_spd(tlink);
455 455
456 ata_acpi_associate_sata_port(ap); 456 ata_acpi_associate_sata_port(ap);
@@ -487,7 +487,7 @@ static void sata_pmp_detach(struct ata_device *dev)
487 if (ap->ops->pmp_detach) 487 if (ap->ops->pmp_detach)
488 ap->ops->pmp_detach(ap); 488 ap->ops->pmp_detach(ap);
489 489
490 ata_port_for_each_link(tlink, ap) 490 ata_for_each_link(tlink, ap, EDGE)
491 ata_eh_detach_dev(tlink->device); 491 ata_eh_detach_dev(tlink->device);
492 492
493 spin_lock_irqsave(ap->lock, flags); 493 spin_lock_irqsave(ap->lock, flags);
@@ -700,7 +700,7 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,
700 } 700 }
701 701
702 /* PMP is reset, SErrors cannot be trusted, scan all */ 702 /* PMP is reset, SErrors cannot be trusted, scan all */
703 ata_port_for_each_link(tlink, ap) { 703 ata_for_each_link(tlink, ap, EDGE) {
704 struct ata_eh_context *ehc = &tlink->eh_context; 704 struct ata_eh_context *ehc = &tlink->eh_context;
705 705
706 ehc->i.probe_mask |= ATA_ALL_DEVICES; 706 ehc->i.probe_mask |= ATA_ALL_DEVICES;
@@ -768,7 +768,7 @@ static int sata_pmp_eh_handle_disabled_links(struct ata_port *ap)
768 768
769 spin_lock_irqsave(ap->lock, flags); 769 spin_lock_irqsave(ap->lock, flags);
770 770
771 ata_port_for_each_link(link, ap) { 771 ata_for_each_link(link, ap, EDGE) {
772 if (!(link->flags & ATA_LFLAG_DISABLED)) 772 if (!(link->flags & ATA_LFLAG_DISABLED))
773 continue; 773 continue;
774 774
@@ -852,7 +852,7 @@ static int sata_pmp_eh_recover(struct ata_port *ap)
852 int cnt, rc; 852 int cnt, rc;
853 853
854 pmp_tries = ATA_EH_PMP_TRIES; 854 pmp_tries = ATA_EH_PMP_TRIES;
855 ata_port_for_each_link(link, ap) 855 ata_for_each_link(link, ap, EDGE)
856 link_tries[link->pmp] = ATA_EH_PMP_LINK_TRIES; 856 link_tries[link->pmp] = ATA_EH_PMP_LINK_TRIES;
857 857
858 retry: 858 retry:
@@ -861,7 +861,7 @@ static int sata_pmp_eh_recover(struct ata_port *ap)
861 rc = ata_eh_recover(ap, ops->prereset, ops->softreset, 861 rc = ata_eh_recover(ap, ops->prereset, ops->softreset,
862 ops->hardreset, ops->postreset, NULL); 862 ops->hardreset, ops->postreset, NULL);
863 if (rc) { 863 if (rc) {
864 ata_link_for_each_dev(dev, &ap->link) 864 ata_for_each_dev(dev, &ap->link, ALL)
865 ata_dev_disable(dev); 865 ata_dev_disable(dev);
866 return rc; 866 return rc;
867 } 867 }
@@ -870,7 +870,7 @@ static int sata_pmp_eh_recover(struct ata_port *ap)
870 return 0; 870 return 0;
871 871
872 /* new PMP online */ 872 /* new PMP online */
873 ata_port_for_each_link(link, ap) 873 ata_for_each_link(link, ap, EDGE)
874 link_tries[link->pmp] = ATA_EH_PMP_LINK_TRIES; 874 link_tries[link->pmp] = ATA_EH_PMP_LINK_TRIES;
875 875
876 /* fall through */ 876 /* fall through */
@@ -942,7 +942,7 @@ static int sata_pmp_eh_recover(struct ata_port *ap)
942 } 942 }
943 943
944 cnt = 0; 944 cnt = 0;
945 ata_port_for_each_link(link, ap) { 945 ata_for_each_link(link, ap, EDGE) {
946 if (!(gscr_error & (1 << link->pmp))) 946 if (!(gscr_error & (1 << link->pmp)))
947 continue; 947 continue;
948 948