From patchwork Wed Aug 17 22:02:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 1082802 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 p7KI8BUn006159 for ; Sat, 20 Aug 2011 18:08:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754659Ab1HTSIG (ORCPT ); Sat, 20 Aug 2011 14:08:06 -0400 Received: from moutng.kundenserver.de ([212.227.126.186]:56969 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754865Ab1HTSID (ORCPT ); Sat, 20 Aug 2011 14:08:03 -0400 Received: from axis700.grange (dslb-178-001-136-054.pools.arcor-ip.net [178.1.136.54]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0LaJV0-1RYoXN3wvG-00lPio; Sat, 20 Aug 2011 20:07:48 +0200 Received: by axis700.grange (Postfix, from userid 1000) id B8C8018B074; Thu, 18 Aug 2011 00:02:06 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id B613918B071; Thu, 18 Aug 2011 00:02:06 +0200 (CEST) Date: Thu, 18 Aug 2011 00:02:06 +0200 (CEST) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: Simon Horman cc: linux-mmc@vger.kernel.org, linux-sh@vger.kernel.org, Chris Ball , Magnus Damm , Paul Mundt Subject: [PATCH 3/4 v7] mmc: sdhi: Make use of per-source irq handlers In-Reply-To: <20110817125728.GD13086@verge.net.au> Message-ID: References: <1313578756-10413-1-git-send-email-horms@verge.net.au> <1313578756-10413-4-git-send-email-horms@verge.net.au> <20110817114147.GA13086@verge.net.au> <20110817120748.GB13086@verge.net.au> <20110817125728.GD13086@verge.net.au> MIME-Version: 1.0 X-Provags-ID: V02:K0:b8AzWUBBOUXKddA4K3bj/O5xL0Z345Z6Hfbmj2QljL9 x1IkwNTppchYx+KahqmWjCoXUoJvWYeVFsNRa++8aMDreQ3OjT x+48sAULYW+R9mNdGatFDisnoCcVZH6i1qiBfpASyRPDDAPhHM FXhm6mjXI4+xr3KN3s2wvZTeOp4ABp08Bdt9IL84JFsWkhjhzA EWw108THkHE8pFq1jqe+V/qgvtNTwMnn7V9KqSLdtk= Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@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]); Sat, 20 Aug 2011 18:08:13 +0000 (UTC) From: Simon Horman Make use of per-source irq handles if the platform (data) has multiple irq sources. Also, as suggested by Guennadi Liakhovetski, add and use defines the index or irqs in platform data. Cc: Guennadi Liakhovetski Cc: Magnus Damm Signed-off-by: Simon Horman [g.liakhovetski@gmx.de: fixed IRQ requesting logic] Signed-off-by: Guennadi Liakhovetski --- No, your last version was wrong too. Please, give this a go and tell me if it works as expected. Thanks Guennadi drivers/mmc/host/sh_mobile_sdhi.c | 67 ++++++++++++++++++++++++------------ include/linux/mmc/sh_mobile_sdhi.h | 7 ++++ 2 files changed, 52 insertions(+), 22 deletions(-) diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index 774f643..2e3ec8b 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,40 @@ 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; } + + irq = platform_get_irq(pdev, SH_MOBILE_SDHI_IRQ_SDCARD); + if (irq >= 0) { + multi_irq = true; + ret = request_irq(irq, tmio_mmc_sdcard_irq, 0, + dev_name(&pdev->dev), host); + if (ret) + goto eirq_sdcard; + } else if (multi_irq) { + ret = irq; + goto eirq_sdcard; + } + + irq = platform_get_irq(pdev, SH_MOBILE_SDHI_IRQ_CARD_DETECT); + if (irq >= 0) { + 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_card_detect; + } else if (!multi_irq) { + ret = irq; + goto eirq_card_detect; + } else { + ret = 0; + } + 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 +196,15 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) return ret; -eirq: +eirq_card_detect: + irq = platform_get_irq(pdev, SH_MOBILE_SDHI_IRQ_SDCARD); + if (irq >= 0) + free_irq(irq, host); +eirq_sdcard: + 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); @@ -203,7 +226,7 @@ static int sh_mobile_sdhi_remove(struct platform_device *pdev) tmio_mmc_host_remove(host); - for (i = 0; i < 3; i++) { + for (i = 0; i < SH_MOBILE_SDHI_IRQ_MAX; i++) { irq = platform_get_irq(pdev, i); if (irq >= 0) free_irq(irq, host); diff --git a/include/linux/mmc/sh_mobile_sdhi.h b/include/linux/mmc/sh_mobile_sdhi.h index bd50b36..80d3629 100644 --- a/include/linux/mmc/sh_mobile_sdhi.h +++ b/include/linux/mmc/sh_mobile_sdhi.h @@ -3,6 +3,13 @@ #include +enum { + SH_MOBILE_SDHI_IRQ_CARD_DETECT = 0, + SH_MOBILE_SDHI_IRQ_SDCARD, + SH_MOBILE_SDHI_IRQ_SDIO, + SH_MOBILE_SDHI_IRQ_MAX +}; + struct platform_device; struct tmio_mmc_data;