aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2008-07-31 04:02:41 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-09-29 00:22:30 -0400
commitaadffb682cc5572f48cc24883681db65530bd284 (patch)
tree24ab92ec9b0cdd9e6f4c0bf7a8a4c04635be03db /include
parent82ef04fb4c82542b3eda81cca461f0594ce9cd0b (diff)
libata: reimplement link iterator
Implement __ata_port_next_link() and reimplement __ata_port_for_each_link() and ata_port_for_each_link() using it. This removes relatively large inlined code and makes iteration easier to extend. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/libata.h33
1 files changed, 8 insertions, 25 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h
index ffd622fa319c..3eaca347ce29 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1265,34 +1265,17 @@ static inline int ata_link_active(struct ata_link *link)
1265 return ata_tag_valid(link->active_tag) || link->sactive; 1265 return ata_tag_valid(link->active_tag) || link->sactive;
1266} 1266}
1267 1267
1268static inline struct ata_link *ata_port_first_link(struct ata_port *ap) 1268extern struct ata_link *__ata_port_next_link(struct ata_port *ap,
1269{ 1269 struct ata_link *link,
1270 if (sata_pmp_attached(ap)) 1270 bool dev_only);
1271 return ap->pmp_link;
1272 return &ap->link;
1273}
1274
1275static inline struct ata_link *ata_port_next_link(struct ata_link *link)
1276{
1277 struct ata_port *ap = link->ap;
1278
1279 if (ata_is_host_link(link)) {
1280 if (!sata_pmp_attached(ap))
1281 return NULL;
1282 return ap->pmp_link;
1283 }
1284
1285 if (++link < ap->nr_pmp_links + ap->pmp_link)
1286 return link;
1287 return NULL;
1288}
1289 1271
1290#define __ata_port_for_each_link(lk, ap) \ 1272#define __ata_port_for_each_link(link, ap) \
1291 for ((lk) = &(ap)->link; (lk); (lk) = ata_port_next_link(lk)) 1273 for ((link) = __ata_port_next_link((ap), NULL, false); (link); \
1274 (link) = __ata_port_next_link((ap), (link), false))
1292 1275
1293#define ata_port_for_each_link(link, ap) \ 1276#define ata_port_for_each_link(link, ap) \
1294 for ((link) = ata_port_first_link(ap); (link); \ 1277 for ((link) = __ata_port_next_link((ap), NULL, true); (link); \
1295 (link) = ata_port_next_link(link)) 1278 (link) = __ata_port_next_link((ap), (link), true))
1296 1279
1297#define ata_link_for_each_dev(dev, link) \ 1280#define ata_link_for_each_dev(dev, link) \
1298 for ((dev) = (link)->device; \ 1281 for ((dev) = (link)->device; \