From patchwork Fri Aug 26 08:42:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 1101162 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7Q8guOf002605 for ; Fri, 26 Aug 2011 08:42:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753532Ab1HZIm4 (ORCPT ); Fri, 26 Aug 2011 04:42:56 -0400 Received: from moutng.kundenserver.de ([212.227.126.186]:65045 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753197Ab1HZImy (ORCPT ); Fri, 26 Aug 2011 04:42:54 -0400 Received: from axis700.grange (dslb-178-006-253-134.pools.arcor-ip.net [178.6.253.134]) by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis) id 0Lql1O-1RREwM0lec-00eMjo; Fri, 26 Aug 2011 10:42:40 +0200 Received: by axis700.grange (Postfix, from userid 1000) id CD491189F98; Fri, 26 Aug 2011 10:42:39 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id C4CC2189F95; Fri, 26 Aug 2011 10:42:39 +0200 (CEST) Date: Fri, 26 Aug 2011 10:42:39 +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 , Paul Mundt , Magnus Damm Subject: [PATCH 3/4 v9] mmc: sdhi: Allow named IRQs to use specific handlers In-Reply-To: <1314235648-8959-4-git-send-email-horms@verge.net.au> Message-ID: References: <1314235648-8959-1-git-send-email-horms@verge.net.au> <1314235648-8959-4-git-send-email-horms@verge.net.au> MIME-Version: 1.0 X-Provags-ID: V02:K0:+53kVwAA4HQ7VRqbt/f/B1U2ve4+Y/akKP1xmjay1Y9 tefOQ1lyunI3HDKzY4X1zpcoR1MZDVosKIdTqdxVZw92svhIgL G1t+IZUzcR0ilpUfzpsv86GXDODD9C+h+lXcwlkcTuHxRDAAdx Gukk074l9LVj16IEKuyAKVIoEhVaTJYZlf0RWESyPgt+nvMSSS dQ8tmMR4RFjczhXXioHh5jDeb2fn6h2OF7ifKnELlE= 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 (demeter2.kernel.org [140.211.167.43]); Fri, 26 Aug 2011 08:42:57 +0000 (UTC) From: Simon Horman Allow named IRQs to use corresponding specific handlers. If named IRQs are used, at least an "sdcard" IRQ has to be specified by the platform. If names are not used, an arbitrary number of IRQs can be provided by the platform, in which case the generic ISR will be used for each of them. Cc: Guennadi Liakhovetski Acked-by: Magnus Damm Signed-off-by: Simon Horman [g.liakhovetski@gmx.de: style and typo corrections, platform data check] Signed-off-by: Guennadi Liakhovetski --- Simon, this is what I propose to commit. I fixed a typo, wrong multi-line comment style and indentation spaces in your patch. Besides, I added a check to require the SDCARD IRQ if named IRQs are used. It is a common practice to verify platform data availability and at least some basic correctness and completeness. This check is trivial and adds extra robustness to the driver. Please, have a look, whether you agree with my version. -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index 774f643..d9013ad 100644 --- a/drivers/mmc/host/sh_mobile_sdhi.c +++ b/drivers/mmc/host/sh_mobile_sdhi.c @@ -96,7 +96,8 @@ 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, i = 0; + bool multiplexed_isr = true; priv = kzalloc(sizeof(struct sh_mobile_sdhi), GFP_KERNEL); if (priv == NULL) { @@ -153,27 +154,60 @@ 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, + /* + * Allow one or more specific (named) ISRs or + * one or more multiplexed (un-named) ISRs. + */ + + irq = platform_get_irq_byname(pdev, SH_MOBILE_SDHI_IRQ_CARD_DETECT); + if (irq >= 0) { + multiplexed_isr = false; + ret = request_irq(irq, tmio_mmc_card_detect_irq, 0, + dev_name(&pdev->dev), host); + if (ret) + goto eirq_card_detect; + } + + irq = platform_get_irq_byname(pdev, SH_MOBILE_SDHI_IRQ_SDIO); + if (irq >= 0) { + multiplexed_isr = false; + ret = request_irq(irq, tmio_mmc_sdio_irq, 0, + dev_name(&pdev->dev), host); + if (ret) + goto eirq_sdio; + } + + irq = platform_get_irq_byname(pdev, SH_MOBILE_SDHI_IRQ_SDCARD); + if (irq >= 0) { + multiplexed_isr = false; + ret = request_irq(irq, tmio_mmc_sdcard_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_sdcard; + } else if (!multiplexed_isr) { + dev_err(&pdev->dev, + "Principal SD-card IRQ is missing among named interrupts\n"); + ret = irq; + goto eirq_sdcard; + } + + if (multiplexed_isr) { + while (1) { + irq = platform_get_irq(pdev, i); + if (irq < 0) + break; + i++; + ret = request_irq(irq, tmio_mmc_irq, 0, + dev_name(&pdev->dev), host); + if (ret) + goto eirq_multiplexed; } + + /* There must be at least one IRQ source */ + if (!i) + goto eirq_multiplexed; } + 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 +215,20 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) return ret; -eirq: +eirq_multiplexed: + while (i--) { + irq = platform_get_irq(pdev, i); + free_irq(irq, host); + } +eirq_sdcard: + irq = platform_get_irq_byname(pdev, SH_MOBILE_SDHI_IRQ_SDIO); + if (irq >= 0) + free_irq(irq, host); +eirq_sdio: + irq = platform_get_irq_byname(pdev, SH_MOBILE_SDHI_IRQ_CARD_DETECT); + if (irq >= 0) + free_irq(irq, host); +eirq_card_detect: tmio_mmc_host_remove(host); eprobe: clk_disable(priv->clk); @@ -197,16 +244,17 @@ static int sh_mobile_sdhi_remove(struct platform_device *pdev) struct tmio_mmc_host *host = mmc_priv(mmc); struct sh_mobile_sdhi *priv = container_of(host->pdata, struct sh_mobile_sdhi, mmc_data); struct sh_mobile_sdhi_info *p = pdev->dev.platform_data; - int i, irq; + int i = 0, irq; p->pdata = NULL; tmio_mmc_host_remove(host); - for (i = 0; i < 3; i++) { - irq = platform_get_irq(pdev, i); - if (irq >= 0) - free_irq(irq, host); + while (1) { + irq = platform_get_irq(pdev, i++); + if (irq < 0) + break; + free_irq(irq, host); } clk_disable(priv->clk); diff --git a/include/linux/mmc/sh_mobile_sdhi.h b/include/linux/mmc/sh_mobile_sdhi.h index bd50b36..71b8054 100644 --- a/include/linux/mmc/sh_mobile_sdhi.h +++ b/include/linux/mmc/sh_mobile_sdhi.h @@ -6,6 +6,10 @@ struct platform_device; struct tmio_mmc_data; +#define SH_MOBILE_SDHI_IRQ_CARD_DETECT "card_detect" +#define SH_MOBILE_SDHI_IRQ_SDCARD "sdcard" +#define SH_MOBILE_SDHI_IRQ_SDIO "sdio" + struct sh_mobile_sdhi_info { int dma_slave_tx; int dma_slave_rx;