mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
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>
This commit is contained in:
parent
82ef04fb4c
commit
aadffb682c
2 changed files with 38 additions and 25 deletions
|
@ -1265,34 +1265,17 @@ static inline int ata_link_active(struct ata_link *link)
|
|||
return ata_tag_valid(link->active_tag) || link->sactive;
|
||||
}
|
||||
|
||||
static inline struct ata_link *ata_port_first_link(struct ata_port *ap)
|
||||
{
|
||||
if (sata_pmp_attached(ap))
|
||||
return ap->pmp_link;
|
||||
return &ap->link;
|
||||
}
|
||||
extern struct ata_link *__ata_port_next_link(struct ata_port *ap,
|
||||
struct ata_link *link,
|
||||
bool dev_only);
|
||||
|
||||
static inline struct ata_link *ata_port_next_link(struct ata_link *link)
|
||||
{
|
||||
struct ata_port *ap = link->ap;
|
||||
|
||||
if (ata_is_host_link(link)) {
|
||||
if (!sata_pmp_attached(ap))
|
||||
return NULL;
|
||||
return ap->pmp_link;
|
||||
}
|
||||
|
||||
if (++link < ap->nr_pmp_links + ap->pmp_link)
|
||||
return link;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define __ata_port_for_each_link(lk, ap) \
|
||||
for ((lk) = &(ap)->link; (lk); (lk) = ata_port_next_link(lk))
|
||||
#define __ata_port_for_each_link(link, ap) \
|
||||
for ((link) = __ata_port_next_link((ap), NULL, false); (link); \
|
||||
(link) = __ata_port_next_link((ap), (link), false))
|
||||
|
||||
#define ata_port_for_each_link(link, ap) \
|
||||
for ((link) = ata_port_first_link(ap); (link); \
|
||||
(link) = ata_port_next_link(link))
|
||||
for ((link) = __ata_port_next_link((ap), NULL, true); (link); \
|
||||
(link) = __ata_port_next_link((ap), (link), true))
|
||||
|
||||
#define ata_link_for_each_dev(dev, link) \
|
||||
for ((dev) = (link)->device; \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue