From patchwork Wed May 27 08:01:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 6488081 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BB1E4C0020 for ; Wed, 27 May 2015 08:05:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CB902206E5 for ; Wed, 27 May 2015 08:05:06 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 071B8206CE for ; Wed, 27 May 2015 08:05:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YxWIE-0004WG-4J; Wed, 27 May 2015 08:02:26 +0000 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YxWI6-0004Jr-HN for linux-arm-kernel@lists.infradead.org; Wed, 27 May 2015 08:02:19 +0000 Received: by wizo1 with SMTP id o1so11782472wiz.1 for ; Wed, 27 May 2015 01:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=zX2ezD4mQ4GxgZWPpsCoqTWS54b7O4MwtbUlAEwGwGg=; b=ZdsxfVjnaOcCN2InmmrTKwCZbvKb/nu7W9+S69z3Cd3l6rg9xb+2IN91V8M0QbtfGm YAVaUrPdfjuK10sDOidvP5ILyx9FEFtv1dQcI0ddAltpxg+BV+xMNK7Jm4zSvRwF3Sm0 DZrhmj467bWg9/EKl0SQZa4Vcqd1wYH11AsOk01O+mgg2Iq5wn2di7+/KsL7Hg57PtZI 0SqzjjiFXRTrt5RbHm+EWM8SCvsf3AhToPedmTsJbhzCv8dDPCnQ+o7bSIsB66R/N8mq Ew4QENflEy/GlKS3NF6oEAIehg1hYNFv6IdVwcfOUGKwoSq2to4rc1Yx/osSTh0ajoCx gLew== X-Received: by 10.180.109.6 with SMTP id ho6mr48571305wib.58.1432713716530; Wed, 27 May 2015 01:01:56 -0700 (PDT) Received: from rric.localhost (f053086129.adsl.alicedsl.de. [78.53.86.129]) by mx.google.com with ESMTPSA id g11sm25532176wjr.25.2015.05.27.01.01.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 May 2015 01:01:55 -0700 (PDT) From: Robert Richter To: Tejun Heo Subject: [PATCH v3 1/3] ahci: Move interrupt enablement code to separate functions Date: Wed, 27 May 2015 10:01:31 +0200 Message-Id: <1432713693-4282-2-git-send-email-rric@kernel.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1432713693-4282-1-git-send-email-rric@kernel.org> References: <1432713693-4282-1-git-send-email-rric@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150527_010218_713789_5AD9A7D3 X-CRM114-Status: GOOD ( 13.37 ) X-Spam-Score: -0.7 (/) Cc: linux-kernel@vger.kernel.org, Robert Richter , linux-ide@vger.kernel.org, Sunil Goutham , Jiang Liu , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Robert Richter 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 --- 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;