From patchwork Tue Aug 16 02:08:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 1069762 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7G25ib7021209 for ; Tue, 16 Aug 2011 02:08:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752758Ab1HPCIc (ORCPT ); Mon, 15 Aug 2011 22:08:32 -0400 Received: from kirsty.vergenet.net ([202.4.237.240]:36191 "EHLO kirsty.vergenet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751404Ab1HPCI3 (ORCPT ); Mon, 15 Aug 2011 22:08:29 -0400 Received: from joe.akashicho.tokyo.vergenet.net (joe.akashicho.tokyo.vergenet.net [IPv6:2001:470:f44f:403:1ec1:deff:fe98:754d]) by kirsty.vergenet.net (Postfix) with ESMTP id 134B7245A7; Tue, 16 Aug 2011 12:08:27 +1000 (EST) Received: by joe.akashicho.tokyo.vergenet.net (Postfix, from userid 7100) id 2A87D28A037; Tue, 16 Aug 2011 11:08:24 +0900 (JST) From: Simon Horman To: linux-sh@vger.kernel.org, linux-mmc@vger.kernel.org Cc: Chris Ball , Guennadi Liakhovetski , Magnus Damm , Paul Mundt , Simon Horman Subject: [PATCH 4/5] mmc: sdhi: Make use of per-source irq handlers Date: Tue, 16 Aug 2011 11:08:18 +0900 Message-Id: <1313460499-3377-5-git-send-email-horms@verge.net.au> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1313460499-3377-1-git-send-email-horms@verge.net.au> References: <1313460499-3377-1-git-send-email-horms@verge.net.au> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 16 Aug 2011 02:08:47 +0000 (UTC) Make use of per-source irq handles if the platform (data) has multiple irq sources. Cc: Guennadi Liakhovetski Cc: Magnus Damm Signed-off-by: Simon Horman --- drivers/mmc/host/sh_mobile_sdhi.c | 58 +++++++++++++++++++++++------------- 1 files changed, 37 insertions(+), 21 deletions(-) diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index 774f643..29dd0c8 100644 --- a/drivers/mmc/host/sh_mobile_sdhi.c +++ b/drivers/mmc/host/sh_mobile_sdhi.c @@ -96,7 +96,9 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) struct sh_mobile_sdhi_info *p = pdev->dev.platform_data; struct tmio_mmc_host *host; char clk_name[8]; - int i, irq, ret; + int irq, ret; + irqreturn_t (*f)(int irq, void *devid); + bool multi_irq = false; priv = kzalloc(sizeof(struct sh_mobile_sdhi), GFP_KERNEL); if (priv == NULL) { @@ -153,27 +155,33 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) if (ret < 0) goto eprobe; - for (i = 0; i < 3; i++) { - irq = platform_get_irq(pdev, i); - if (irq < 0) { - if (i) { - continue; - } else { - ret = irq; - goto eirq; - } - } - ret = request_irq(irq, tmio_mmc_irq, 0, + irq = platform_get_irq(pdev, SH_MOBILE_SDHI_IRQ_SDIO); + if (irq >= 0) { + multi_irq = true; + ret = request_irq(irq, tmio_mmc_sdio_irq, 0, dev_name(&pdev->dev), host); - if (ret) { - while (i--) { - irq = platform_get_irq(pdev, i); - if (irq >= 0) - free_irq(irq, host); - } - goto eirq; - } + if (ret) + goto eirq_sdio; } + + ret = irq = platform_get_irq(pdev, SH_MOBILE_SDHI_IRQ_CARD_DETECT); + if (irq >= 0) { + multi_irq = true; + ret = request_irq(irq, tmio_mmc_sdcard_irq, 0, + dev_name(&pdev->dev), host); + if (ret) + goto eirq_card_detect; + } else if (multi_irq) + goto eirq_card_detect; + + ret = irq = platform_get_irq(pdev, SH_MOBILE_SDHI_IRQ_SDCARD); + if (irq < 0) + goto eirq_sdcard; + f = multi_irq ? tmio_mmc_card_detect_irq : tmio_mmc_irq; + ret = request_irq(irq, f, 0, dev_name(&pdev->dev), host); + if (ret) + goto eirq_sdcard; + dev_info(&pdev->dev, "%s base at 0x%08lx clock rate %u MHz\n", mmc_hostname(host->mmc), (unsigned long) (platform_get_resource(pdev,IORESOURCE_MEM, 0)->start), @@ -181,7 +189,15 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) return ret; -eirq: +eirq_sdcard: + irq = platform_get_irq(pdev, SH_MOBILE_SDHI_IRQ_CARD_DETECT); + if (irq >= 0) + free_irq(irq, host); +eirq_card_detect: + irq = platform_get_irq(pdev, SH_MOBILE_SDHI_IRQ_SDIO); + if (irq >= 0) + free_irq(irq, host); +eirq_sdio: tmio_mmc_host_remove(host); eprobe: clk_disable(priv->clk);