aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
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 /drivers/ata
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 'drivers/ata')
-rw-r--r--drivers/ata/libata-core.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 825461a33abe..d156616f45f5 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -163,6 +163,35 @@ MODULE_LICENSE("GPL");
163MODULE_VERSION(DRV_VERSION); 163MODULE_VERSION(DRV_VERSION);
164 164
165 165
166/*
167 * Iterator helpers. Don't use directly.
168 *
169 * LOCKING:
170 * Host lock or EH context.
171 */
172struct ata_link *__ata_port_next_link(struct ata_port *ap,
173 struct ata_link *link, bool dev_only)
174{
175 /* NULL link indicates start of iteration */
176 if (!link) {
177 if (dev_only && sata_pmp_attached(ap))
178 return ap->pmp_link;
179 return &ap->link;
180 }
181
182 /* we just iterated over the host link, what's next? */
183 if (ata_is_host_link(link)) {
184 if (!sata_pmp_attached(ap))
185 return NULL;
186 return ap->pmp_link;
187 }
188
189 /* iterate to the next PMP link */
190 if (++link < ap->pmp_link + ap->nr_pmp_links)
191 return link;
192 return NULL;
193}
194
166/** 195/**
167 * ata_force_cbl - force cable type according to libata.force 196 * ata_force_cbl - force cable type according to libata.force
168 * @ap: ATA port of interest 197 * @ap: ATA port of interest
@@ -6255,6 +6284,7 @@ EXPORT_SYMBOL_GPL(ata_base_port_ops);
6255EXPORT_SYMBOL_GPL(sata_port_ops); 6284EXPORT_SYMBOL_GPL(sata_port_ops);
6256EXPORT_SYMBOL_GPL(ata_dummy_port_ops); 6285EXPORT_SYMBOL_GPL(ata_dummy_port_ops);
6257EXPORT_SYMBOL_GPL(ata_dummy_port_info); 6286EXPORT_SYMBOL_GPL(ata_dummy_port_info);
6287EXPORT_SYMBOL_GPL(__ata_port_next_link);
6258EXPORT_SYMBOL_GPL(ata_std_bios_param); 6288EXPORT_SYMBOL_GPL(ata_std_bios_param);
6259EXPORT_SYMBOL_GPL(ata_host_init); 6289EXPORT_SYMBOL_GPL(ata_host_init);
6260EXPORT_SYMBOL_GPL(ata_host_alloc); 6290EXPORT_SYMBOL_GPL(ata_host_alloc);