aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-08-06 05:36:23 -0400
committerJeff Garzik <jeff@garzik.org>2007-10-12 14:55:30 -0400
commitf58229f8060055b08b34008ea08f31de1e2f003c (patch)
tree6ca5ef546671cb975ef3632fb032c238eaf1bb4c /include/linux
parent9af5c9c97dc9d599281778864c72b385f0c63341 (diff)
libata-link: implement and use link/device iterators
Multiple links and different number of devices per link should be considered to iterate over links and devices. This patch implements and uses link and device iterators - ata_port_for_each_link() and ata_link_for_each_dev() - and ata_link_max_devices(). This change makes a lot of functions iterate over only possible devices instead of from dev 0 to dev ATA_MAX_DEVICES. All such changes have been examined and nothing should be broken. While at it, add a separating comment before device helpers to distinguish them better from link helpers and others. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/libata.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h
index ca4493125fa0..62fa8cf677a1 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1030,15 +1030,26 @@ static inline unsigned int ata_dev_absent(const struct ata_device *dev)
1030} 1030}
1031 1031
1032/* 1032/*
1033 * port helpers 1033 * link helpers
1034 */ 1034 */
1035static inline int ata_port_max_devices(const struct ata_port *ap) 1035static inline int ata_link_max_devices(const struct ata_link *link)
1036{ 1036{
1037 if (ap->flags & ATA_FLAG_SLAVE_POSS) 1037 if (link->ap->flags & ATA_FLAG_SLAVE_POSS)
1038 return 2; 1038 return 2;
1039 return 1; 1039 return 1;
1040} 1040}
1041 1041
1042#define ata_port_for_each_link(lk, ap) \
1043 for ((lk) = &(ap)->link; (lk); (lk) = NULL)
1044
1045#define ata_link_for_each_dev(dev, link) \
1046 for ((dev) = (link)->device; \
1047 (dev) < (link)->device + ata_link_max_devices(link) || ((dev) = NULL); \
1048 (dev)++)
1049
1050#define ata_link_for_each_dev_reverse(dev, link) \
1051 for ((dev) = (link)->device + ata_link_max_devices(link) - 1; \
1052 (dev) >= (link)->device || ((dev) = NULL); (dev)--)
1042 1053
1043static inline u8 ata_chk_status(struct ata_port *ap) 1054static inline u8 ata_chk_status(struct ata_port *ap)
1044{ 1055{