All of lore.kernel.org
 help / color / mirror / Atom feed
From: nyushchenko@dev.rtsoft.ru
To: Grant Likely <grant.likely@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, lugovskoy@dev.rtsoft.ru,
	Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
Subject: [PATCH 02/21] ata: use devm_irq_of_parse_and_map() where appropriate
Date: Wed,  4 Jun 2014 15:13:02 +0400	[thread overview]
Message-ID: <1401880402-30091-3-git-send-email-nyushchenko@dev.rtsoft.ru> (raw)
In-Reply-To: <1401880402-30091-1-git-send-email-nyushchenko@dev.rtsoft.ru>

From: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>

This avoids leak of IRQ mapping on error paths, and makes it possible
to use devm_request_irq() without facing unmap-while-handler-installed
issues.

pata_mpc52xx's task_irq is special case since it is managed by betstcomm
DMA driver. Do not use devres for it.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/ata/pata_mpc52xx.c |   24 ++++++++++--------------
 drivers/ata/sata_mv.c      |    5 ++++-
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c
index 0024ced..fc14d7f 100644
--- a/drivers/ata/pata_mpc52xx.c
+++ b/drivers/ata/pata_mpc52xx.c
@@ -729,18 +729,17 @@ static int mpc52xx_ata_probe(struct platform_device *op)
 	if ((prop) && (proplen >= 4))
 		udma_mask = ATA_UDMA2 & ((1 << (*prop + 1)) - 1);
 
-	ata_irq = irq_of_parse_and_map(op->dev.of_node, 0);
-	if (ata_irq == NO_IRQ) {
+	ata_irq = devm_irq_of_parse_and_map(&op->dev, op->dev.of_node, 0);
+	if (ata_irq <= 0) {
 		dev_err(&op->dev, "error mapping irq\n");
-		return -EINVAL;
+		return ata_irq ? ata_irq : -EINVAL;
 	}
 
 	/* Prepare our private structure */
 	priv = devm_kzalloc(&op->dev, sizeof(*priv), GFP_ATOMIC);
 	if (!priv) {
 		dev_err(&op->dev, "error allocating private structure\n");
-		rv = -ENOMEM;
-		goto err1;
+		return -ENOMEM;
 	}
 
 	priv->ipb_period = 1000000000 / (ipb_freq / 1000);
@@ -762,16 +761,14 @@ static int mpc52xx_ata_probe(struct platform_device *op)
 	dmatsk = bcom_ata_init(MAX_DMA_BUFFERS, MAX_DMA_BUFFER_SIZE);
 	if (!dmatsk) {
 		dev_err(&op->dev, "bestcomm initialization failed\n");
-		rv = -ENOMEM;
-		goto err1;
+		return -ENOMEM;
 	}
 
 	task_irq = bcom_get_task_irq(dmatsk);
-	rv = devm_request_irq(&op->dev, task_irq, &mpc52xx_ata_task_irq, 0,
-				"ATA task", priv);
+	rv = request_irq(task_irq, &mpc52xx_ata_task_irq, 0, "ATA task", priv);
 	if (rv) {
 		dev_err(&op->dev, "error requesting DMA IRQ\n");
-		goto err2;
+		goto err1;
 	}
 	priv->dmatsk = dmatsk;
 
@@ -793,10 +790,10 @@ static int mpc52xx_ata_probe(struct platform_device *op)
 	return 0;
 
  err2:
-	irq_dispose_mapping(task_irq);
+	free_irq(task_irq, priv);
+ err1:
 	bcom_ata_release(dmatsk);
  err1:
-	irq_dispose_mapping(ata_irq);
 	return rv;
 }
 
@@ -812,9 +809,8 @@ mpc52xx_ata_remove(struct platform_device *op)
 
 	/* Clean up DMA */
 	task_irq = bcom_get_task_irq(priv->dmatsk);
-	irq_dispose_mapping(task_irq);
+	free_irq(task_irq, priv);
 	bcom_ata_release(priv->dmatsk);
-	irq_dispose_mapping(priv->ata_irq);
 
 	return 0;
 }
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 05c8a44..9b48e91 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -4081,7 +4081,10 @@ static int mv_platform_probe(struct platform_device *pdev)
 	/* allocate host */
 	if (pdev->dev.of_node) {
 		of_property_read_u32(pdev->dev.of_node, "nr-ports", &n_ports);
-		irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
+		irq = devm_irq_of_parse_and_map(&pdev->dev,
+				pdev->dev.of_node, 0);
+		if (irq <= 0)
+			return -EINVAL;
 	} else {
 		mv_platform_data = dev_get_platdata(&pdev->dev);
 		n_ports = mv_platform_data->n_ports;
-- 
1.7.10.4


  parent reply	other threads:[~2014-06-04 11:13 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-04 11:13 [PATCH 00/21] add and use devm_irq_of_parse_and_map() nyushchenko
2014-06-04 11:13 ` [PATCH 01/21] irq: add devres version of OF IRQ mapping routines nyushchenko
2014-06-04 13:39   ` Thomas Gleixner
2014-06-04 13:39     ` Thomas Gleixner
2014-06-04 11:13 ` nyushchenko [this message]
2014-06-04 11:13 ` [PATCH 03/21] exynos5440-cpufreq: use devm_irq_of_parse_and_map() nyushchenko
2014-06-04 11:13 ` [PATCH 04/21] omap-sham: " nyushchenko
2014-06-04 11:13 ` [PATCH 05/21] dma: use devm_irq_of_parse_and_map() where appropriate nyushchenko
2014-06-04 11:13 ` [PATCH 06/21] mpc85xx_edac: use devm_irq_of_parse_and_map() nyushchenko
2014-06-04 11:13 ` [PATCH 07/21] gpio: use devm_irq_of_parse_and_map() where appropriate nyushchenko
2014-06-04 11:13 ` [PATCH 08/21] i2c: " nyushchenko
2014-06-04 11:13 ` [PATCH 09/21] apbps2: use devm_irq_of_parse_and_map() nyushchenko
2014-06-04 11:13 ` [PATCH 10/21] media: use devm_irq_of_parse_and_map() where appropriate nyushchenko
2014-06-04 11:13 ` [PATCH 11/21] mfd: " nyushchenko
2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
2014-06-17 15:12   ` Lee Jones
2014-06-17 15:36     ` Nikita Yushchenko
2014-06-17 15:36       ` Nikita Yushchenko
2014-06-18  8:48       ` Lee Jones
2014-06-18 11:31         ` Nikita Yushchenko
2014-06-18 11:31           ` Nikita Yushchenko
2014-06-18 12:20           ` Lee Jones
2014-06-04 11:13 ` [PATCH 12/21] mpc5121_nfc: use devm_irq_of_parse_and_map() nyushchenko
2014-06-04 11:13 ` [PATCH 13/21] net/can: use devm_irq_of_parse_and_map() where appropriate nyushchenko
2014-06-04 11:13 ` [PATCH 14/21] net/ethernet: " nyushchenko
2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
2014-06-04 11:13 ` [PATCH 15/21] pinctrl: " nyushchenko
2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
2014-06-04 11:13 ` [PATCH 16/21] bq24190_charger: use devm_irq_of_parse_and_map() nyushchenko
2014-06-04 11:13 ` [PATCH 17/21] rtc-mpc5121: " nyushchenko
2014-06-04 11:13 ` [PATCH 18/21] spi: use devm_irq_of_parse_and_map() where appropriate nyushchenko
2014-06-04 11:13 ` [PATCH 19/21] exynos_tmu: use devm_irq_of_parse_and_map() nyushchenko
2014-06-04 11:13 ` [PATCH 20/21] usb: use devm_irq_of_parse_and_map() where appropriate nyushchenko
2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
2014-06-16  9:35   ` Andreas Larsson
2014-06-16  9:35     ` Andreas Larsson
2014-06-16  9:44     ` Nikita Yushchenko
2014-06-16  9:44       ` Nikita Yushchenko
2014-06-16  9:54       ` Andreas Larsson
2014-06-16  9:54         ` Andreas Larsson
2014-06-04 11:13 ` [PATCH 21/21] at91sam9_wdt: use devm_irq_of_parse_and_map() nyushchenko
2014-06-12 10:03 ` [PATCH 00/21] add and " Andreas Larsson
2014-06-12 10:03   ` Andreas Larsson
     [not found]   ` <5399AE1B.1080301@gaisler.com>
2014-06-12 19:02     ` Nikita Yushchenko
2014-06-12 19:02       ` Nikita Yushchenko
2014-06-16  8:23       ` Andreas Larsson
2014-06-16  8:23         ` Andreas Larsson
2014-06-16  8:36         ` Nikita Yushchenko
2014-06-16  8:36           ` Nikita Yushchenko
2014-06-16  8:36           ` Nikita Yushchenko
2014-06-16  9:29           ` Andreas Larsson
2014-06-16  9:29             ` Andreas Larsson

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=1401880402-30091-3-git-send-email-nyushchenko@dev.rtsoft.ru \
    --to=nyushchenko@dev.rtsoft.ru \
    --cc=benh@kernel.crashing.org \
    --cc=devicetree@vger.kernel.org \
    --cc=grant.likely@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lugovskoy@dev.rtsoft.ru \
    --cc=robh+dt@kernel.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.