Skip to content

Commit

Permalink
libahci: Refactoring of ahci_single_irq_intr function.
Browse files Browse the repository at this point in the history
This patch refactors the ahci_single_irq_intr function and also rename
it to ahci_single_level_irq_intr as it handles a level triggered latch.

Signed-off-by: Suman tripathi <[email protected]>
Signed-off-by: Tejun Heo <[email protected]>
  • Loading branch information
suman-tripathi authored and htejun committed May 10, 2015
1 parent 4b9d64e commit a129db8
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions drivers/ata/libahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1826,27 +1826,9 @@ static irqreturn_t ahci_multi_irqs_intr(int irq, void *dev_instance)
return IRQ_WAKE_THREAD;
}

static irqreturn_t ahci_single_irq_intr(int irq, void *dev_instance)
static u32 ahci_handle_port_intr(struct ata_host *host, u32 irq_masked)
{
struct ata_host *host = dev_instance;
struct ahci_host_priv *hpriv;
unsigned int i, handled = 0;
void __iomem *mmio;
u32 irq_stat, irq_masked;

VPRINTK("ENTER\n");

hpriv = host->private_data;
mmio = hpriv->mmio;

/* sigh. 0xffffffff is a valid return from h/w */
irq_stat = readl(mmio + HOST_IRQ_STAT);
if (!irq_stat)
return IRQ_NONE;

irq_masked = irq_stat & hpriv->port_map;

spin_lock(&host->lock);

for (i = 0; i < host->n_ports; i++) {
struct ata_port *ap;
Expand All @@ -1868,6 +1850,33 @@ static irqreturn_t ahci_single_irq_intr(int irq, void *dev_instance)
handled = 1;
}

return handled;
}

static irqreturn_t ahci_single_level_irq_intr(int irq, void *dev_instance)
{
struct ata_host *host = dev_instance;
struct ahci_host_priv *hpriv;
unsigned int rc = 0;
void __iomem *mmio;
u32 irq_stat, irq_masked;

VPRINTK("ENTER\n");

hpriv = host->private_data;
mmio = hpriv->mmio;

/* sigh. 0xffffffff is a valid return from h/w */
irq_stat = readl(mmio + HOST_IRQ_STAT);
if (!irq_stat)
return IRQ_NONE;

irq_masked = irq_stat & hpriv->port_map;

spin_lock(&host->lock);

rc = ahci_handle_port_intr(host, irq_masked);

/* HOST_IRQ_STAT behaves as level triggered latch meaning that
* it should be cleared after all the port events are cleared;
* otherwise, it will raise a spurious interrupt after each
Expand All @@ -1883,7 +1892,7 @@ static irqreturn_t ahci_single_irq_intr(int irq, void *dev_instance)

VPRINTK("EXIT\n");

return IRQ_RETVAL(handled);
return IRQ_RETVAL(rc);
}

unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
Expand Down Expand Up @@ -2487,7 +2496,7 @@ int ahci_host_activate(struct ata_host *host, int irq,
if (hpriv->flags & AHCI_HFLAG_MULTI_MSI)
rc = ahci_host_activate_multi_irqs(host, irq, sht);
else
rc = ata_host_activate(host, irq, ahci_single_irq_intr,
rc = ata_host_activate(host, irq, ahci_single_level_irq_intr,
IRQF_SHARED, sht);
return rc;
}
Expand Down

0 comments on commit a129db8

Please sign in to comment.