From: rric@kernel.org (Robert Richter)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 1/3] ahci: Move interrupt enablement code to separate functions
Date: Wed, 27 May 2015 10:01:31 +0200 [thread overview]
Message-ID: <1432713693-4282-2-git-send-email-rric@kernel.org> (raw)
In-Reply-To: <1432713693-4282-1-git-send-email-rric@kernel.org>
From: Robert Richter <rrichter@cavium.com>
This patch refactors ahci_init_interrupts() and moves code to separate
functions for msi and intx. Needed since we add msix initialization in
a later patch. The initialization for msix is done after msi but
before intx.
Signed-off-by: Robert Richter <rrichter@cavium.com>
---
drivers/ata/ahci.c | 36 +++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 33bb06e006c9..c8aedd836dc9 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1201,17 +1201,17 @@ static inline void ahci_gtf_filter_workaround(struct ata_host *host)
{}
#endif
-static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
- struct ahci_host_priv *hpriv)
+static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports,
+ struct ahci_host_priv *hpriv)
{
int rc, nvec;
if (hpriv->flags & AHCI_HFLAG_NO_MSI)
- goto intx;
+ return -ENODEV;
nvec = pci_msi_vec_count(pdev);
if (nvec < 0)
- goto intx;
+ return nvec;
/*
* If number of MSIs is less than number of ports then Sharing Last
@@ -1224,8 +1224,8 @@ static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
rc = pci_enable_msi_exact(pdev, nvec);
if (rc == -ENOSPC)
goto single_msi;
- else if (rc < 0)
- goto intx;
+ if (rc < 0)
+ return rc;
/* fallback to single MSI mode if the controller enforced MRSM mode */
if (readl(hpriv->mmio + HOST_CTL) & HOST_MRSM) {
@@ -1240,15 +1240,33 @@ static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
return nvec;
single_msi:
- if (pci_enable_msi(pdev))
- goto intx;
+ rc = pci_enable_msi(pdev);
+ if (rc < 0)
+ return rc;
+
return 1;
+}
-intx:
+static int ahci_init_intx(struct pci_dev *pdev, unsigned int n_ports,
+ struct ahci_host_priv *hpriv)
+{
pci_intx(pdev, 1);
+
return 0;
}
+static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
+ struct ahci_host_priv *hpriv)
+{
+ int nvec;
+
+ nvec = ahci_init_msi(pdev, n_ports, hpriv);
+ if (nvec >= 0)
+ return nvec;
+
+ return ahci_init_intx(pdev, n_ports, hpriv);
+}
+
static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
unsigned int board_id = ent->driver_data;
--
2.1.1
next prev parent reply other threads:[~2015-05-27 8:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-27 8:01 [PATCH v3 0/3] AHCI: Add generic MSI-X interrupt support to SATA PCI driver Robert Richter
2015-05-27 8:01 ` Robert Richter [this message]
2015-05-27 18:09 ` [PATCH v3 1/3] ahci: Move interrupt enablement code to separate functions Tejun Heo
2015-05-27 8:01 ` [PATCH v3 2/3] ahci: Store irq number in struct ahci_host_priv Robert Richter
2015-05-27 16:16 ` [PATCH] " Robert Richter
2015-05-27 18:14 ` Tejun Heo
2015-05-27 8:01 ` [PATCH v3 3/3] AHCI: Add generic MSI-X interrupt support to SATA PCI driver Robert Richter
2015-05-27 14:32 ` [PATCH v3 0/3] " Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1432713693-4282-2-git-send-email-rric@kernel.org \
--to=rric@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).