'if/else' should be used to handle the following conditions since those three command types are exclusive:
...
if (NON_NCQ_CMD_IN_PROGRESS(ahci_portp))
finished_tags = ahci_portp->ahciport_pending_tags &
~slot_status & AHCI_SLOT_MASK(ahci_ctlp);
if (NCQ_CMD_IN_PROGRESS(ahci_portp))
finished_tags = ahci_portp->ahciport_pending_ncq_tags &
~slot_status & AHCI_NCQ_SLOT_MASK(ahci_portp);
...
Moreover, ahci_log failed to log the driver instance information.