aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-scsi.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-scsi.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-scsi.c')
-rw-r--r--drivers/ata/libata-scsi.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 47c7afcb36f2..0b2e14f67655 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3229,12 +3229,12 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync)
3229 return; 3229 return;
3230 3230
3231 repeat: 3231 repeat:
3232 ata_port_for_each_link(link, ap) { 3232 ata_for_each_link(link, ap, EDGE) {
3233 ata_link_for_each_dev(dev, link) { 3233 ata_for_each_dev(dev, link, ENABLED) {
3234 struct scsi_device *sdev; 3234 struct scsi_device *sdev;
3235 int channel = 0, id = 0; 3235 int channel = 0, id = 0;
3236 3236
3237 if (!ata_dev_enabled(dev) || dev->sdev) 3237 if (dev->sdev)
3238 continue; 3238 continue;
3239 3239
3240 if (ata_is_host_link(link)) 3240 if (ata_is_host_link(link))
@@ -3255,9 +3255,9 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync)
3255 * failure occurred, scan would have failed silently. Check 3255 * failure occurred, scan would have failed silently. Check
3256 * whether all devices are attached. 3256 * whether all devices are attached.
3257 */ 3257 */
3258 ata_port_for_each_link(link, ap) { 3258 ata_for_each_link(link, ap, EDGE) {
3259 ata_link_for_each_dev(dev, link) { 3259 ata_for_each_dev(dev, link, ENABLED) {
3260 if (ata_dev_enabled(dev) && !dev->sdev) 3260 if (!dev->sdev)
3261 goto exit_loop; 3261 goto exit_loop;
3262 } 3262 }
3263 } 3263 }
@@ -3381,7 +3381,7 @@ static void ata_scsi_handle_link_detach(struct ata_link *link)
3381 struct ata_port *ap = link->ap; 3381 struct ata_port *ap = link->ap;
3382 struct ata_device *dev; 3382 struct ata_device *dev;
3383 3383
3384 ata_link_for_each_dev(dev, link) { 3384 ata_for_each_dev(dev, link, ALL) {
3385 unsigned long flags; 3385 unsigned long flags;
3386 3386
3387 if (!(dev->flags & ATA_DFLAG_DETACHED)) 3387 if (!(dev->flags & ATA_DFLAG_DETACHED))
@@ -3496,7 +3496,7 @@ static int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
3496 if (devno == SCAN_WILD_CARD) { 3496 if (devno == SCAN_WILD_CARD) {
3497 struct ata_link *link; 3497 struct ata_link *link;
3498 3498
3499 ata_port_for_each_link(link, ap) { 3499 ata_for_each_link(link, ap, EDGE) {
3500 struct ata_eh_info *ehi = &link->eh_info; 3500 struct ata_eh_info *ehi = &link->eh_info;
3501 ehi->probe_mask |= ATA_ALL_DEVICES; 3501 ehi->probe_mask |= ATA_ALL_DEVICES;
3502 ehi->action |= ATA_EH_RESET; 3502 ehi->action |= ATA_EH_RESET;
@@ -3544,11 +3544,11 @@ void ata_scsi_dev_rescan(struct work_struct *work)
3544 3544
3545 spin_lock_irqsave(ap->lock, flags); 3545 spin_lock_irqsave(ap->lock, flags);
3546 3546
3547 ata_port_for_each_link(link, ap) { 3547 ata_for_each_link(link, ap, EDGE) {
3548 ata_link_for_each_dev(dev, link) { 3548 ata_for_each_dev(dev, link, ENABLED) {
3549 struct scsi_device *sdev = dev->sdev; 3549 struct scsi_device *sdev = dev->sdev;
3550 3550
3551 if (!ata_dev_enabled(dev) || !sdev) 3551 if (!sdev)
3552 continue; 3552 continue;
3553 if (scsi_device_get(sdev)) 3553 if (scsi_device_get(sdev))
3554 continue; 3554 continue;