All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/21] add and use devm_irq_of_parse_and_map()
@ 2014-06-04 11:13 nyushchenko
  2014-06-04 11:13 ` [PATCH 01/21] irq: add devres version of OF IRQ mapping routines nyushchenko
                   ` (21 more replies)
  0 siblings, 22 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy

Currently many device tree aware drivers use irq_of_parse_and_map() to get
IRQ number and then devm_request_irq() to set up IRQ handler.

This causes a problem for exit path and for error paths: undo action for
irq_of_parse_and_map() is irq_dispose_mapping() that must not be called
while IRQ handler is defined, but devres moves free_irq() out of driver
so driver does not have safe place to call irq_dispose_mapping().

So many drivers do not call irq_dispose_mapping() at all, others call it
while IRQ handler is defined (which is incorrect and causes error messages
in logs), even others refuse to use devres for managing IRQ handlers.

This patchset adds devres version of irq_of_parse_and_map(), and updates
in-tree users of both devres and irq_of_parse_and_map() to use
devm_irq_of_parse_and_map() instead.

[PATCH 01/21] irq: add devres version of OF IRQ mapping routines
[PATCH 02/21] ata: use devm_irq_of_parse_and_map() where appropriate
[PATCH 03/21] exynos5440-cpufreq: use devm_irq_of_parse_and_map()
[PATCH 04/21] omap-sham: use devm_irq_of_parse_and_map()
[PATCH 05/21] dma: use devm_irq_of_parse_and_map() where appropriate
[PATCH 06/21] mpc85xx_edac: use devm_irq_of_parse_and_map()
[PATCH 07/21] gpio: use devm_irq_of_parse_and_map() where
[PATCH 08/21] i2c: use devm_irq_of_parse_and_map() where appropriate
[PATCH 09/21] apbps2: use devm_irq_of_parse_and_map()
[PATCH 10/21] media: use devm_irq_of_parse_and_map() where
[PATCH 11/21] mfd: use devm_irq_of_parse_and_map() where appropriate
[PATCH 12/21] mpc5121_nfc: use devm_irq_of_parse_and_map()
[PATCH 13/21] net/can: use devm_irq_of_parse_and_map() where
[PATCH 14/21] net/ethernet: use devm_irq_of_parse_and_map() where
[PATCH 15/21] pinctrl: use devm_irq_of_parse_and_map() where
[PATCH 16/21] bq24190_charger: use devm_irq_of_parse_and_map()
[PATCH 17/21] rtc-mpc5121: use devm_irq_of_parse_and_map()
[PATCH 18/21] spi: use devm_irq_of_parse_and_map() where appropriate
[PATCH 19/21] exynos_tmu: use devm_irq_of_parse_and_map()
[PATCH 20/21] usb: use devm_irq_of_parse_and_map() where appropriate
[PATCH 21/21] at91sam9_wdt: use devm_irq_of_parse_and_map()

 drivers/ata/pata_mpc52xx.c                         |   24 +++++-----
 drivers/ata/sata_mv.c                              |    5 ++-
 drivers/cpufreq/exynos5440-cpufreq.c               |    4 +-
 drivers/crypto/omap-sham.c                         |    4 +-
 drivers/dma/moxart-dma.c                           |    4 +-
 drivers/dma/mpc512x_dma.c                          |   14 ++----
 drivers/dma/mv_xor.c                               |   18 +++-----
 drivers/dma/sirf-dma.c                             |   23 ++++------
 drivers/edac/mpc85xx_edac.c                        |   41 ++++++++++++-----
 drivers/gpio/gpio-adnp.c                           |    4 +-
 drivers/gpio/gpio-mcp23s08.c                       |    5 ++-
 drivers/i2c/busses/i2c-mpc.c                       |   12 ++---
 drivers/i2c/busses/i2c-mv64xxx.c                   |    2 +-
 drivers/i2c/busses/i2c-st.c                        |    6 +--
 drivers/i2c/busses/i2c-wmt.c                       |    6 +--
 drivers/input/serio/apbps2.c                       |    6 ++-
 drivers/media/platform/exynos4-is/fimc-is.c        |   14 +++---
 drivers/media/platform/fsl-viu.c                   |   25 ++++-------
 drivers/mfd/max8997.c                              |    4 +-
 drivers/mfd/max8998.c                              |    4 +-
 drivers/mtd/nand/mpc5121_nfc.c                     |    6 +--
 drivers/net/can/grcan.c                            |   11 ++---
 drivers/net/can/mscan/mpc5xxx_can.c                |   11 ++---
 drivers/net/can/sja1000/sja1000_platform.c         |    2 +-
 drivers/net/ethernet/allwinner/sun4i-emac.c        |    6 +--
 drivers/net/ethernet/arc/emac_main.c               |    6 +--
 drivers/net/ethernet/marvell/mvneta.c              |   15 +++----
 drivers/net/ethernet/moxa/moxart_ether.c           |    4 +-
 .../net/ethernet/samsung/sxgbe/sxgbe_platform.c    |   24 ++++------
 drivers/of/irq.c                                   |   24 ++++++++++
 drivers/pinctrl/pinctrl-bcm2835.c                  |    6 ++-
 drivers/pinctrl/pinctrl-exynos.c                   |   11 ++---
 drivers/pinctrl/pinctrl-exynos5440.c               |    2 +-
 drivers/pinctrl/pinctrl-rockchip.c                 |    6 ++-
 drivers/pinctrl/pinctrl-s3c24xx.c                  |    6 +--
 drivers/pinctrl/pinctrl-s3c64xx.c                  |    6 +--
 drivers/pinctrl/pinctrl-single.c                   |    6 ++-
 drivers/pinctrl/pinctrl-sunxi.c                    |    6 +--
 drivers/power/bq24190_charger.c                    |    2 +-
 drivers/rtc/rtc-mpc5121.c                          |   38 ++++++++--------
 drivers/spi/spi-bcm2835.c                          |    2 +-
 drivers/spi/spi-mpc512x-psc.c                      |    9 +++-
 drivers/spi/spi.c                                  |    8 +++-
 drivers/thermal/samsung/exynos_tmu.c               |    2 +-
 drivers/usb/gadget/gr_udc.c                        |   17 ++++---
 drivers/usb/host/ehci-grlib.c                      |   11 ++---
 drivers/usb/host/ehci-orion.c                      |    3 +-
 drivers/usb/host/ehci-ppc-of.c                     |   11 ++---
 drivers/usb/host/ehci-xilinx-of.c                  |    8 ++--
 drivers/usb/host/ohci-ppc-of.c                     |    7 +--
 drivers/watchdog/at91sam9_wdt.c                    |   12 ++---
 include/linux/irqdomain.h                          |    3 ++
 include/linux/of_irq.h                             |   12 +++++
 kernel/irq/irqdomain.c                             |   47 ++++++++++++++++++++



^ permalink raw reply	[flat|nested] 52+ messages in thread

* [PATCH 01/21] irq: add devres version of OF IRQ mapping routines
  2014-06-04 11:13 [PATCH 00/21] add and use devm_irq_of_parse_and_map() nyushchenko
@ 2014-06-04 11:13 ` nyushchenko
  2014-06-04 13:39     ` Thomas Gleixner
  2014-06-04 11:13 ` [PATCH 02/21] ata: use devm_irq_of_parse_and_map() where appropriate nyushchenko
                   ` (20 subsequent siblings)
  21 siblings, 1 reply; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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

Many drivers use devres to manage their resources, and at the same time
use irq_of_parse_and_map() / irq_dispose_mapping(). This creates problem
on driver unload paths and on error paths:
- it is invalid to call irq_dispose_mapping() while IRQ handler is still
  installed,
- devres moves removal of IRQ handler out of driver,
- without explicit devres support for IRQ mapping, irq_dispose_mapping()
  stays in driver and thus gets called while IRQ handler is still
  installed.

This patch adds devm_irq_create_of_mapping() and devm_irq_of_parse_and_map()
routines to be used by drivers for correct release of resources.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/of/irq.c          |   24 +++++++++++++++++++++++
 include/linux/irqdomain.h |    3 +++
 include/linux/of_irq.h    |   12 ++++++++++++
 kernel/irq/irqdomain.c    |   47 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 86 insertions(+)

diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 5aeb894..30b5010 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -46,6 +46,30 @@ unsigned int irq_of_parse_and_map(struct device_node *dev, int index)
 EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
 
 /**
+ * devm_irq_of_parse_and_map - Parse and map an interrupt into linux virq space
+ * @dev: Device interrupt will be used for
+ * @dn: Device node of the device whose interrupt is to be mapped
+ * @index: Index of the interrupt to map
+ *
+ * This function does the same as irq_of_parse_and_map(), but ensures that
+ * irq_dispose_mapping() will be called automatically at driver detatch.
+ *
+ * If IRQ mapping created by this function needs to be removed manually,
+ * devm_irq_dispose_mapping() must be called instead of irq_dispose_mapping().
+ */
+int devm_irq_of_parse_and_map(struct device *dev, struct device_node *dn,
+		int index)
+{
+	struct of_phandle_args oirq;
+
+	if (of_irq_parse_one(dn, index, &oirq))
+		return 0;
+
+	return devm_irq_create_of_mapping(dev, &oirq);
+}
+EXPORT_SYMBOL_GPL(devm_irq_of_parse_and_map);
+
+/**
  * of_irq_find_parent - Given a device node, find its interrupt parent node
  * @child: pointer to device node
  *
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index c983ed1..44e6261 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -176,6 +176,7 @@ extern void irq_domain_associate_many(struct irq_domain *domain,
 extern unsigned int irq_create_mapping(struct irq_domain *host,
 				       irq_hw_number_t hwirq);
 extern void irq_dispose_mapping(unsigned int virq);
+extern void devm_irq_dispose_mapping(struct device *dev, unsigned int virq);
 
 /**
  * irq_linear_revmap() - Find a linux irq from a hw irq number.
@@ -220,6 +221,8 @@ int irq_domain_xlate_onetwocell(struct irq_domain *d, struct device_node *ctrlr,
 
 #else /* CONFIG_IRQ_DOMAIN */
 static inline void irq_dispose_mapping(unsigned int virq) { }
+static inline void devm_irq_dispose_mapping(struct device *dev,
+		unsigned int virq) { }
 #endif /* !CONFIG_IRQ_DOMAIN */
 
 #endif /* _LINUX_IRQDOMAIN_H */
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
index 6404253..4ac7138 100644
--- a/include/linux/of_irq.h
+++ b/include/linux/of_irq.h
@@ -35,6 +35,8 @@ extern int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq)
 extern int of_irq_parse_one(struct device_node *device, int index,
 			  struct of_phandle_args *out_irq);
 extern unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data);
+extern int devm_irq_create_of_mapping(struct device *dev,
+		struct of_phandle_args *irq_data);
 extern int of_irq_to_resource(struct device_node *dev, int index,
 			      struct resource *r);
 extern int of_irq_to_resource_table(struct device_node *dev,
@@ -63,6 +65,9 @@ static inline int of_irq_get(struct device_node *dev, int index)
  * so declare it here regardless of the CONFIG_OF_IRQ setting.
  */
 extern unsigned int irq_of_parse_and_map(struct device_node *node, int index);
+extern int devm_irq_of_parse_and_map(struct device *dev,
+				     struct device_node *node,
+				     int index);
 extern struct device_node *of_irq_find_parent(struct device_node *child);
 
 #else /* !CONFIG_OF */
@@ -72,6 +77,13 @@ static inline unsigned int irq_of_parse_and_map(struct device_node *dev,
 	return 0;
 }
 
+static inline int devm_irq_of_parse_and_map(struct device *dev,
+					    struct device_node *node,
+					    int index)
+{
+	return 0;
+}
+
 static inline void *of_irq_find_parent(struct device_node *child)
 {
 	return NULL;
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index f140337..c8705de 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -16,6 +16,7 @@
 #include <linux/slab.h>
 #include <linux/smp.h>
 #include <linux/fs.h>
+#include <linux/device.h>
 
 static LIST_HEAD(irq_domain_list);
 static DEFINE_MUTEX(irq_domain_mutex);
@@ -502,6 +503,34 @@ unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data)
 }
 EXPORT_SYMBOL_GPL(irq_create_of_mapping);
 
+static void devm_release_irq_mapping(void *p)
+{
+	unsigned int virq = (unsigned int)((unsigned long)p);
+
+	if (virq)
+		irq_dispose_mapping(virq);
+}
+
+int devm_irq_create_of_mapping(struct device *dev,
+		struct of_phandle_args *irq_data)
+{
+	unsigned int virq;
+	int ret;
+
+	virq = irq_create_of_mapping(irq_data);
+	if (virq) {
+		ret = devm_add_action(dev, devm_release_irq_mapping,
+				(void *)((unsigned long)virq));
+		if (ret) {
+			irq_dispose_mapping(virq);
+			return ret;
+		}
+	}
+
+	return virq;
+}
+EXPORT_SYMBOL_GPL(devm_irq_create_of_mapping);
+
 /**
  * irq_dispose_mapping() - Unmap an interrupt
  * @virq: linux irq number of the interrupt to unmap
@@ -524,6 +553,24 @@ void irq_dispose_mapping(unsigned int virq)
 EXPORT_SYMBOL_GPL(irq_dispose_mapping);
 
 /**
+ * devm_irq_dispose_mapping() - Unmap an interrupt
+ * @dev: device irq was used for
+ * @virq: linux irq number of the interrupt to unmap
+ *
+ * This should be used instead of irq_dispose_mapping() if mapping was created
+ * with devm_irq_create_of_mapping()
+ */
+void devm_irq_dispose_mapping(struct device *dev, unsigned int virq)
+{
+	if (virq) {
+		devm_remove_action(dev, devm_release_irq_mapping,
+				(void *)((unsigned long)virq));
+		irq_dispose_mapping(virq);
+	}
+}
+EXPORT_SYMBOL_GPL(devm_irq_dispose_mapping);
+
+/**
  * irq_find_mapping() - Find a linux irq from an hw irq number.
  * @domain: domain owning this hardware interrupt
  * @hwirq: hardware irq number in that domain space
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 02/21] ata: use devm_irq_of_parse_and_map() where appropriate
  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 11:13 ` nyushchenko
  2014-06-04 11:13 ` [PATCH 03/21] exynos5440-cpufreq: use devm_irq_of_parse_and_map() nyushchenko
                   ` (19 subsequent siblings)
  21 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 03/21] exynos5440-cpufreq: use devm_irq_of_parse_and_map()
  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 11:13 ` [PATCH 02/21] ata: use devm_irq_of_parse_and_map() where appropriate nyushchenko
@ 2014-06-04 11:13 ` nyushchenko
  2014-06-04 11:13 ` [PATCH 04/21] omap-sham: " nyushchenko
                   ` (18 subsequent siblings)
  21 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/cpufreq/exynos5440-cpufreq.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
index a6b8214..a0b7121 100644
--- a/drivers/cpufreq/exynos5440-cpufreq.c
+++ b/drivers/cpufreq/exynos5440-cpufreq.c
@@ -353,8 +353,8 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
 		goto err_put_node;
 	}
 
-	dvfs_info->irq = irq_of_parse_and_map(np, 0);
-	if (!dvfs_info->irq) {
+	dvfs_info->irq = devm_irq_of_parse_and_map(dvfs_info->dev, np, 0);
+	if (dvfs_info->irq <= 0) {
 		dev_err(dvfs_info->dev, "No cpufreq irq found\n");
 		ret = -ENODEV;
 		goto err_put_node;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 04/21] omap-sham: use devm_irq_of_parse_and_map()
  2014-06-04 11:13 [PATCH 00/21] add and use devm_irq_of_parse_and_map() nyushchenko
                   ` (2 preceding siblings ...)
  2014-06-04 11:13 ` [PATCH 03/21] exynos5440-cpufreq: use devm_irq_of_parse_and_map() nyushchenko
@ 2014-06-04 11:13 ` nyushchenko
  2014-06-04 11:13 ` [PATCH 05/21] dma: use devm_irq_of_parse_and_map() where appropriate nyushchenko
                   ` (17 subsequent siblings)
  21 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/crypto/omap-sham.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
index 710d863..2975f61 100644
--- a/drivers/crypto/omap-sham.c
+++ b/drivers/crypto/omap-sham.c
@@ -1830,8 +1830,8 @@ static int omap_sham_get_res_of(struct omap_sham_dev *dd,
 		goto err;
 	}
 
-	dd->irq = irq_of_parse_and_map(node, 0);
-	if (!dd->irq) {
+	dd->irq = devm_irq_of_parse_and_map(dev, node, 0);
+	if (dd->irq <= 0) {
 		dev_err(dev, "can't translate OF irq value\n");
 		err = -EINVAL;
 		goto err;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 05/21] dma: use devm_irq_of_parse_and_map() where appropriate
  2014-06-04 11:13 [PATCH 00/21] add and use devm_irq_of_parse_and_map() nyushchenko
                   ` (3 preceding siblings ...)
  2014-06-04 11:13 ` [PATCH 04/21] omap-sham: " nyushchenko
@ 2014-06-04 11:13 ` nyushchenko
  2014-06-04 11:13 ` [PATCH 06/21] mpc85xx_edac: use devm_irq_of_parse_and_map() nyushchenko
                   ` (16 subsequent siblings)
  21 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/dma/moxart-dma.c  |    4 ++--
 drivers/dma/mpc512x_dma.c |   14 ++++----------
 drivers/dma/mv_xor.c      |   18 +++++++-----------
 drivers/dma/sirf-dma.c    |   23 ++++++++---------------
 4 files changed, 21 insertions(+), 38 deletions(-)

diff --git a/drivers/dma/moxart-dma.c b/drivers/dma/moxart-dma.c
index 3258e48..30a8261 100644
--- a/drivers/dma/moxart-dma.c
+++ b/drivers/dma/moxart-dma.c
@@ -598,8 +598,8 @@ static int moxart_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	irq = irq_of_parse_and_map(node, 0);
-	if (irq == NO_IRQ) {
+	irq = devm_irq_of_parse_and_map(dev, node, 0);
+	if (irq <= 0) {
 		dev_err(dev, "no IRQ resource\n");
 		return -EINVAL;
 	}
diff --git a/drivers/dma/mpc512x_dma.c b/drivers/dma/mpc512x_dma.c
index 448750d..c603492 100644
--- a/drivers/dma/mpc512x_dma.c
+++ b/drivers/dma/mpc512x_dma.c
@@ -652,16 +652,16 @@ static int mpc_dma_probe(struct platform_device *op)
 		return -ENOMEM;
 	}
 
-	mdma->irq = irq_of_parse_and_map(dn, 0);
-	if (mdma->irq == NO_IRQ) {
+	mdma->irq = devm_irq_of_parse_and_map(dev, dn, 0);
+	if (mdma->irq <= 0) {
 		dev_err(dev, "Error mapping IRQ!\n");
 		return -EINVAL;
 	}
 
 	if (of_device_is_compatible(dn, "fsl,mpc8308-dma")) {
 		mdma->is_mpc8308 = 1;
-		mdma->irq2 = irq_of_parse_and_map(dn, 1);
-		if (mdma->irq2 == NO_IRQ) {
+		mdma->irq2 = devm_irq_of_parse_and_map(dev, dn, 1);
+		if (mdma->irq2 <= 0) {
 			dev_err(dev, "Error mapping IRQ!\n");
 			return -EINVAL;
 		}
@@ -785,10 +785,6 @@ static int mpc_dma_probe(struct platform_device *op)
 	/* Register DMA engine */
 	dev_set_drvdata(dev, mdma);
 	retval = dma_async_device_register(dma);
-	if (retval) {
-		devm_free_irq(dev, mdma->irq, mdma);
-		irq_dispose_mapping(mdma->irq);
-	}
 
 	return retval;
 }
@@ -799,8 +795,6 @@ static int mpc_dma_remove(struct platform_device *op)
 	struct mpc_dma *mdma = dev_get_drvdata(dev);
 
 	dma_async_device_unregister(&mdma->dma);
-	devm_free_irq(dev, mdma->irq, mdma);
-	irq_dispose_mapping(mdma->irq);
 
 	return 0;
 }
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index 394cbc5..63410db 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -1063,8 +1063,9 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
 	/* clear errors before enabling interrupts */
 	mv_xor_device_clear_err_status(mv_chan);
 
-	ret = request_irq(mv_chan->irq, mv_xor_interrupt_handler,
-			  0, dev_name(&pdev->dev), mv_chan);
+	ret = devm_request_irq(&pdev->dev, mv_chan->irq,
+			       mv_xor_interrupt_handler,
+			       0, dev_name(&pdev->dev), mv_chan);
 	if (ret)
 		goto err_free_dma;
 
@@ -1085,14 +1086,14 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
 		ret = mv_xor_memcpy_self_test(mv_chan);
 		dev_dbg(&pdev->dev, "memcpy self test returned %d\n", ret);
 		if (ret)
-			goto err_free_irq;
+			goto err_free_dma;
 	}
 
 	if (dma_has_cap(DMA_XOR, dma_dev->cap_mask)) {
 		ret = mv_xor_xor_self_test(mv_chan);
 		dev_dbg(&pdev->dev, "xor self test returned %d\n", ret);
 		if (ret)
-			goto err_free_irq;
+			goto err_free_dma;
 	}
 
 	dev_info(&pdev->dev, "Marvell XOR: ( %s%s%s)\n",
@@ -1103,8 +1104,6 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
 	dma_async_device_register(dma_dev);
 	return mv_chan;
 
-err_free_irq:
-	free_irq(mv_chan->irq, mv_chan);
  err_free_dma:
 	dma_free_coherent(&pdev->dev, MV_XOR_POOL_SIZE,
 			  mv_chan->dma_desc_pool_virt, mv_chan->dma_desc_pool);
@@ -1209,8 +1208,8 @@ static int mv_xor_probe(struct platform_device *pdev)
 			if (of_property_read_bool(np, "dmacap,interrupt"))
 				dma_cap_set(DMA_INTERRUPT, cap_mask);
 
-			irq = irq_of_parse_and_map(np, 0);
-			if (!irq) {
+			irq = devm_irq_of_parse_and_map(&pdev->dev, np, 0);
+			if (irq <= 0) {
 				ret = -ENODEV;
 				goto err_channel_add;
 			}
@@ -1219,7 +1218,6 @@ static int mv_xor_probe(struct platform_device *pdev)
 						  cap_mask, irq);
 			if (IS_ERR(chan)) {
 				ret = PTR_ERR(chan);
-				irq_dispose_mapping(irq);
 				goto err_channel_add;
 			}
 
@@ -1261,8 +1259,6 @@ err_channel_add:
 	for (i = 0; i < MV_XOR_MAX_CHANNELS; i++)
 		if (xordev->channels[i]) {
 			mv_xor_channel_remove(xordev->channels[i]);
-			if (pdev->dev.of_node)
-				irq_dispose_mapping(xordev->channels[i]->irq);
 		}
 
 	if (!IS_ERR(xordev->clk)) {
diff --git a/drivers/dma/sirf-dma.c b/drivers/dma/sirf-dma.c
index 03f7820..95af51d 100644
--- a/drivers/dma/sirf-dma.c
+++ b/drivers/dma/sirf-dma.c
@@ -698,8 +698,8 @@ static int sirfsoc_dma_probe(struct platform_device *op)
 		return -ENODEV;
 	}
 
-	sdma->irq = irq_of_parse_and_map(dn, 0);
-	if (sdma->irq == NO_IRQ) {
+	sdma->irq = devm_irq_of_parse_and_map(dev, dn, 0);
+	if (sdma->irq <= 0) {
 		dev_err(dev, "Error mapping IRQ!\n");
 		return -EINVAL;
 	}
@@ -713,7 +713,7 @@ static int sirfsoc_dma_probe(struct platform_device *op)
 	ret = of_address_to_resource(dn, 0, &res);
 	if (ret) {
 		dev_err(dev, "Error parsing memory region!\n");
-		goto irq_dispose;
+		return ret;
 	}
 
 	regs_start = res.start;
@@ -722,15 +722,14 @@ static int sirfsoc_dma_probe(struct platform_device *op)
 	sdma->base = devm_ioremap(dev, regs_start, regs_size);
 	if (!sdma->base) {
 		dev_err(dev, "Error mapping memory region!\n");
-		ret = -ENOMEM;
-		goto irq_dispose;
+		return -ENOMEM;
 	}
 
-	ret = request_irq(sdma->irq, &sirfsoc_dma_irq, 0, DRV_NAME, sdma);
+	ret = devm_request_irq(dev, sdma->irq, &sirfsoc_dma_irq, 0, DRV_NAME,
+			sdma);
 	if (ret) {
 		dev_err(dev, "Error requesting IRQ!\n");
-		ret = -EINVAL;
-		goto irq_dispose;
+		return -EINVAL;
 	}
 
 	dma = &sdma->dma;
@@ -775,7 +774,7 @@ static int sirfsoc_dma_probe(struct platform_device *op)
 
 	ret = dma_async_device_register(dma);
 	if (ret)
-		goto free_irq;
+		return ret;
 
 	/* Device-tree DMA controller registration */
 	ret = of_dma_controller_register(dn, of_dma_sirfsoc_xlate, sdma);
@@ -791,10 +790,6 @@ static int sirfsoc_dma_probe(struct platform_device *op)
 
 unreg_dma_dev:
 	dma_async_device_unregister(dma);
-free_irq:
-	free_irq(sdma->irq, sdma);
-irq_dispose:
-	irq_dispose_mapping(sdma->irq);
 	return ret;
 }
 
@@ -805,8 +800,6 @@ static int sirfsoc_dma_remove(struct platform_device *op)
 
 	of_dma_controller_free(op->dev.of_node);
 	dma_async_device_unregister(&sdma->dma);
-	free_irq(sdma->irq, sdma);
-	irq_dispose_mapping(sdma->irq);
 	pm_runtime_disable(&op->dev);
 	if (!pm_runtime_status_suspended(&op->dev))
 		sirfsoc_dma_runtime_suspend(&op->dev);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 06/21] mpc85xx_edac: use devm_irq_of_parse_and_map()
  2014-06-04 11:13 [PATCH 00/21] add and use devm_irq_of_parse_and_map() nyushchenko
                   ` (4 preceding siblings ...)
  2014-06-04 11:13 ` [PATCH 05/21] dma: use devm_irq_of_parse_and_map() where appropriate nyushchenko
@ 2014-06-04 11:13 ` nyushchenko
  2014-06-04 11:13 ` [PATCH 07/21] gpio: use devm_irq_of_parse_and_map() where appropriate nyushchenko
                   ` (15 subsequent siblings)
  21 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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

This avoids calls to irq_dispose_mapping() while IRQ handler is still
installed.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/edac/mpc85xx_edac.c |   41 +++++++++++++++++++++++++++++------------
 1 file changed, 29 insertions(+), 12 deletions(-)

diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
index f4aec2e..a8b78d2 100644
--- a/drivers/edac/mpc85xx_edac.c
+++ b/drivers/edac/mpc85xx_edac.c
@@ -354,7 +354,15 @@ int mpc85xx_pci_err_probe(struct platform_device *op)
 	}
 
 	if (edac_op_state == EDAC_OPSTATE_INT) {
-		pdata->irq = irq_of_parse_and_map(op->dev.of_node, 0);
+		pdata->irq = devm_irq_of_parse_and_map(&op->dev,
+				op->dev.of_node, 0);
+		if (pdata->irq <= 0) {
+			printk(KERN_ERR
+			       "%s: Unable to locate irq for MPC85xx PCI err\n",
+			       __func__);
+			res = -ENODEV;
+			goto err2;
+		}
 		res = devm_request_irq(&op->dev, pdata->irq,
 				       mpc85xx_pci_isr,
 				       IRQF_SHARED,
@@ -363,7 +371,6 @@ int mpc85xx_pci_err_probe(struct platform_device *op)
 			printk(KERN_ERR
 			       "%s: Unable to request irq %d for "
 			       "MPC85xx PCI err\n", __func__, pdata->irq);
-			irq_dispose_mapping(pdata->irq);
 			res = -ENODEV;
 			goto err2;
 		}
@@ -631,7 +638,15 @@ static int mpc85xx_l2_err_probe(struct platform_device *op)
 	}
 
 	if (edac_op_state == EDAC_OPSTATE_INT) {
-		pdata->irq = irq_of_parse_and_map(op->dev.of_node, 0);
+		pdata->irq = devm_irq_of_parse_and_map(&op->dev,
+				op->dev.of_node, 0);
+		if (pdata->irq <= 0) {
+			printk(KERN_ERR
+			       "%s: Unable to locate irq for MPC85xx L2 err\n",
+			       __func__);
+			res = -ENODEV;
+			goto err2;
+		}
 		res = devm_request_irq(&op->dev, pdata->irq,
 				       mpc85xx_l2_isr, 0,
 				       "[EDAC] L2 err", edac_dev);
@@ -639,7 +654,6 @@ static int mpc85xx_l2_err_probe(struct platform_device *op)
 			printk(KERN_ERR
 			       "%s: Unable to request irq %d for "
 			       "MPC85xx L2 err\n", __func__, pdata->irq);
-			irq_dispose_mapping(pdata->irq);
 			res = -ENODEV;
 			goto err2;
 		}
@@ -674,10 +688,8 @@ static int mpc85xx_l2_err_remove(struct platform_device *op)
 
 	edac_dbg(0, "\n");
 
-	if (edac_op_state == EDAC_OPSTATE_INT) {
+	if (edac_op_state == EDAC_OPSTATE_INT)
 		out_be32(pdata->l2_vbase + MPC85XX_L2_ERRINTEN, 0);
-		irq_dispose_mapping(pdata->irq);
-	}
 
 	out_be32(pdata->l2_vbase + MPC85XX_L2_ERRDIS, orig_l2_err_disable);
 	edac_device_del_device(&op->dev);
@@ -1130,7 +1142,15 @@ static int mpc85xx_mc_err_probe(struct platform_device *op)
 		out_be32(pdata->mc_vbase + MPC85XX_MC_ERR_SBE, 0x10000);
 
 		/* register interrupts */
-		pdata->irq = irq_of_parse_and_map(op->dev.of_node, 0);
+		pdata->irq = devm_irq_of_parse_and_map(&op->dev,
+				op->dev.of_node, 0);
+		if (pdata->irq <= 0) {
+			printk(KERN_ERR
+			       "%s: Unable to locate irq for MPC85xx DRAM ERR\n",
+			       __func__);
+			res = -ENODEV;
+			goto err2;
+		}
 		res = devm_request_irq(&op->dev, pdata->irq,
 				       mpc85xx_mc_isr,
 				       IRQF_SHARED,
@@ -1138,7 +1158,6 @@ static int mpc85xx_mc_err_probe(struct platform_device *op)
 		if (res < 0) {
 			printk(KERN_ERR "%s: Unable to request irq %d for "
 			       "MPC85xx DRAM ERR\n", __func__, pdata->irq);
-			irq_dispose_mapping(pdata->irq);
 			res = -ENODEV;
 			goto err2;
 		}
@@ -1168,10 +1187,8 @@ static int mpc85xx_mc_err_remove(struct platform_device *op)
 
 	edac_dbg(0, "\n");
 
-	if (edac_op_state == EDAC_OPSTATE_INT) {
+	if (edac_op_state == EDAC_OPSTATE_INT)
 		out_be32(pdata->mc_vbase + MPC85XX_MC_ERR_INT_EN, 0);
-		irq_dispose_mapping(pdata->irq);
-	}
 
 	out_be32(pdata->mc_vbase + MPC85XX_MC_ERR_DISABLE,
 		 orig_ddr_err_disable);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 07/21] gpio: use devm_irq_of_parse_and_map() where appropriate
  2014-06-04 11:13 [PATCH 00/21] add and use devm_irq_of_parse_and_map() nyushchenko
                   ` (5 preceding siblings ...)
  2014-06-04 11:13 ` [PATCH 06/21] mpc85xx_edac: use devm_irq_of_parse_and_map() nyushchenko
@ 2014-06-04 11:13 ` nyushchenko
  2014-06-04 11:13 ` [PATCH 08/21] i2c: " nyushchenko
                   ` (14 subsequent siblings)
  21 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/gpio/gpio-adnp.c     |    4 ++--
 drivers/gpio/gpio-mcp23s08.c |    5 ++++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c
index b2239d6..c10e224 100644
--- a/drivers/gpio/gpio-adnp.c
+++ b/drivers/gpio/gpio-adnp.c
@@ -546,8 +546,8 @@ static int adnp_i2c_probe(struct i2c_client *client,
 	if (err < 0)
 		return err;
 
-	client->irq = irq_of_parse_and_map(np, 0);
-	if (!client->irq)
+	client->irq = devm_irq_of_parse_and_map(&client->dev, np, 0);
+	if (client->irq <= 0)
 		return -EPROBE_DEFER;
 
 	adnp = devm_kzalloc(&client->dev, sizeof(*adnp), GFP_KERNEL);
diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
index 3d53fd6..b6f4217 100644
--- a/drivers/gpio/gpio-mcp23s08.c
+++ b/drivers/gpio/gpio-mcp23s08.c
@@ -779,7 +779,10 @@ static int mcp230xx_probe(struct i2c_client *client,
 	if (match || !pdata) {
 		base = -1;
 		pullups = 0;
-		client->irq = irq_of_parse_and_map(client->dev.of_node, 0);
+		client->irq = devm_irq_of_parse_and_map(&client->dev,
+				client->dev.of_node, 0);
+		if (client->irq < 0)
+			return client->irq;
 	} else {
 		if (!gpio_is_valid(pdata->base)) {
 			dev_dbg(&client->dev, "invalid platform data\n");
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 08/21] i2c: use devm_irq_of_parse_and_map() where appropriate
  2014-06-04 11:13 [PATCH 00/21] add and use devm_irq_of_parse_and_map() nyushchenko
                   ` (6 preceding siblings ...)
  2014-06-04 11:13 ` [PATCH 07/21] gpio: use devm_irq_of_parse_and_map() where appropriate nyushchenko
@ 2014-06-04 11:13 ` nyushchenko
  2014-06-04 11:13 ` [PATCH 09/21] apbps2: use devm_irq_of_parse_and_map() nyushchenko
                   ` (13 subsequent siblings)
  21 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/i2c/busses/i2c-mpc.c     |   12 ++++--------
 drivers/i2c/busses/i2c-mv64xxx.c |    2 +-
 drivers/i2c/busses/i2c-st.c      |    6 +++---
 drivers/i2c/busses/i2c-wmt.c     |    6 +++---
 4 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index f539163..f8e45a6 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -647,9 +647,11 @@ static int fsl_i2c_probe(struct platform_device *op)
 		goto fail_map;
 	}
 
-	i2c->irq = irq_of_parse_and_map(op->dev.of_node, 0);
+	i2c->irq = devm_irq_of_parse_and_map(&op->dev, op->dev.of_node, 0);
+	if (i2c->irq < 0)
+		return i2c->irq;
 	if (i2c->irq) { /* no i2c->irq implies polling */
-		result = request_irq(i2c->irq, mpc_i2c_isr,
+		result = devm_request_irq(&op->dev, i2c->irq, mpc_i2c_isr,
 				     IRQF_SHARED, "i2c-mpc", i2c);
 		if (result < 0) {
 			dev_err(i2c->dev, "failed to attach interrupt\n");
@@ -719,9 +721,7 @@ static int fsl_i2c_probe(struct platform_device *op)
  fail_add:
 	if (i2c->clk_per)
 		clk_disable_unprepare(i2c->clk_per);
-	free_irq(i2c->irq, i2c);
  fail_request:
-	irq_dispose_mapping(i2c->irq);
 	iounmap(i2c->base);
  fail_map:
 	kfree(i2c);
@@ -737,10 +737,6 @@ static int fsl_i2c_remove(struct platform_device *op)
 	if (i2c->clk_per)
 		clk_disable_unprepare(i2c->clk_per);
 
-	if (i2c->irq)
-		free_irq(i2c->irq, i2c);
-
-	irq_dispose_mapping(i2c->irq);
 	iounmap(i2c->base);
 	kfree(i2c);
 	return 0;
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index 540ea69..65f95d0 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -755,7 +755,7 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,
 		rc = -EINVAL;
 		goto out;
 	}
-	drv_data->irq = irq_of_parse_and_map(np, 0);
+	drv_data->irq = devm_irq_of_parse_and_map(dev, np, 0);
 
 	drv_data->rstc = devm_reset_control_get_optional(dev, NULL);
 	if (IS_ERR(drv_data->rstc)) {
diff --git a/drivers/i2c/busses/i2c-st.c b/drivers/i2c/busses/i2c-st.c
index 8720161..f2d0017 100644
--- a/drivers/i2c/busses/i2c-st.c
+++ b/drivers/i2c/busses/i2c-st.c
@@ -778,10 +778,10 @@ static int st_i2c_probe(struct platform_device *pdev)
 	if (IS_ERR(i2c_dev->base))
 		return PTR_ERR(i2c_dev->base);
 
-	i2c_dev->irq = irq_of_parse_and_map(np, 0);
-	if (!i2c_dev->irq) {
+	i2c_dev->irq = devm_irq_of_parse_and_map(&pdev->dev, np, 0);
+	if (i2c_dev->irq <= 0) {
 		dev_err(&pdev->dev, "IRQ missing or invalid\n");
-		return -EINVAL;
+		return i2c_dev->irq ? i2c_dev->irq : -EINVAL;
 	}
 
 	i2c_dev->clk = of_clk_get_by_name(np, "ssc");
diff --git a/drivers/i2c/busses/i2c-wmt.c b/drivers/i2c/busses/i2c-wmt.c
index 2c8a3e4..6082b93 100644
--- a/drivers/i2c/busses/i2c-wmt.c
+++ b/drivers/i2c/busses/i2c-wmt.c
@@ -389,10 +389,10 @@ static int wmt_i2c_probe(struct platform_device *pdev)
 	if (IS_ERR(i2c_dev->base))
 		return PTR_ERR(i2c_dev->base);
 
-	i2c_dev->irq = irq_of_parse_and_map(np, 0);
-	if (!i2c_dev->irq) {
+	i2c_dev->irq = devm_irq_of_parse_and_map(&pdev->dev, np, 0);
+	if (i2c_dev->irq <= 0) {
 		dev_err(&pdev->dev, "irq missing or invalid\n");
-		return -EINVAL;
+		return i2c_dev->irq ? i2c_dev->irq : -EINVAL;
 	}
 
 	i2c_dev->clk = of_clk_get(np, 0);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 09/21] apbps2: use devm_irq_of_parse_and_map()
  2014-06-04 11:13 [PATCH 00/21] add and use devm_irq_of_parse_and_map() nyushchenko
                   ` (7 preceding siblings ...)
  2014-06-04 11:13 ` [PATCH 08/21] i2c: " nyushchenko
@ 2014-06-04 11:13 ` nyushchenko
  2014-06-04 11:13 ` [PATCH 10/21] media: use devm_irq_of_parse_and_map() where appropriate nyushchenko
                   ` (12 subsequent siblings)
  21 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/input/serio/apbps2.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/input/serio/apbps2.c b/drivers/input/serio/apbps2.c
index 17e01a8..e8d0b8e 100644
--- a/drivers/input/serio/apbps2.c
+++ b/drivers/input/serio/apbps2.c
@@ -155,7 +155,11 @@ static int apbps2_of_probe(struct platform_device *ofdev)
 	iowrite32be(0, &priv->regs->ctrl);
 
 	/* IRQ */
-	irq = irq_of_parse_and_map(ofdev->dev.of_node, 0);
+	irq = devm_irq_of_parse_and_map(&ofdev->dev, ofdev->dev.of_node, 0);
+	if (irq <= 0) {
+		dev_err(&ofdev->dev, "unable to locate IRQ\n");
+		return irq ? irq  : -EINVAL;
+	}
 	err = devm_request_irq(&ofdev->dev, irq, apbps2_isr,
 				IRQF_SHARED, "apbps2", priv);
 	if (err) {
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 10/21] media: use devm_irq_of_parse_and_map() where appropriate
  2014-06-04 11:13 [PATCH 00/21] add and use devm_irq_of_parse_and_map() nyushchenko
                   ` (8 preceding siblings ...)
  2014-06-04 11:13 ` [PATCH 09/21] apbps2: use devm_irq_of_parse_and_map() nyushchenko
@ 2014-06-04 11:13 ` nyushchenko
  2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
                   ` (11 subsequent siblings)
  21 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/media/platform/exynos4-is/fimc-is.c |   14 ++++++--------
 drivers/media/platform/fsl-viu.c            |   25 +++++++++----------------
 2 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c
index 128b73b..b90b9c1 100644
--- a/drivers/media/platform/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/exynos4-is/fimc-is.c
@@ -810,10 +810,10 @@ static int fimc_is_probe(struct platform_device *pdev)
 	if (!is->pmu_regs)
 		return -ENOMEM;
 
-	is->irq = irq_of_parse_and_map(dev->of_node, 0);
-	if (is->irq < 0) {
+	is->irq = devm_irq_of_parse_and_map(dev, dev->of_node, 0);
+	if (is->irq <= 0) {
 		dev_err(dev, "no irq found\n");
-		return is->irq;
+		return is->irq ? is->irq : -EINVAL;
 	}
 
 	ret = fimc_is_get_clocks(is);
@@ -822,7 +822,8 @@ static int fimc_is_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, is);
 
-	ret = request_irq(is->irq, fimc_is_irq_handler, 0, dev_name(dev), is);
+	ret = devm_request_irq(dev, is->irq, fimc_is_irq_handler, 0,
+			dev_name(dev), is);
 	if (ret < 0) {
 		dev_err(dev, "irq request failed\n");
 		goto err_clk;
@@ -832,7 +833,7 @@ static int fimc_is_probe(struct platform_device *pdev)
 	if (!pm_runtime_enabled(dev)) {
 		ret = fimc_is_runtime_resume(dev);
 		if (ret < 0)
-			goto err_irq;
+			goto err_clk;
 	}
 
 	ret = pm_runtime_get_sync(dev);
@@ -874,8 +875,6 @@ err_vb:
 err_pm:
 	if (!pm_runtime_enabled(dev))
 		fimc_is_runtime_suspend(dev);
-err_irq:
-	free_irq(is->irq, is);
 err_clk:
 	fimc_is_put_clocks(is);
 	return ret;
@@ -929,7 +928,6 @@ static int fimc_is_remove(struct platform_device *pdev)
 	pm_runtime_set_suspended(dev);
 	if (!pm_runtime_status_suspended(dev))
 		fimc_is_runtime_suspend(dev);
-	free_irq(is->irq, is);
 	fimc_is_unregister_subdevs(is);
 	vb2_dma_contig_cleanup_ctx(is->alloc_ctx);
 	fimc_is_put_clocks(is);
diff --git a/drivers/media/platform/fsl-viu.c b/drivers/media/platform/fsl-viu.c
index dbf0ce3..ca9c04f 100644
--- a/drivers/media/platform/fsl-viu.c
+++ b/drivers/media/platform/fsl-viu.c
@@ -1495,34 +1495,31 @@ static int viu_of_probe(struct platform_device *op)
 		return -ENODEV;
 	}
 
-	viu_irq = irq_of_parse_and_map(op->dev.of_node, 0);
-	if (viu_irq == NO_IRQ) {
+	viu_irq = devm_irq_of_parse_and_map(&op->dev, op->dev.of_node, 0);
+	if (viu_irq <= 0) {
 		dev_err(&op->dev, "Error while mapping the irq\n");
-		return -EINVAL;
+		return viu_irq ? viu_irq : -EINVAL;
 	}
 
 	/* request mem region */
 	if (!devm_request_mem_region(&op->dev, r.start,
 				     sizeof(struct viu_reg), DRV_NAME)) {
 		dev_err(&op->dev, "Error while requesting mem region\n");
-		ret = -EBUSY;
-		goto err;
+		return -EBUSY;
 	}
 
 	/* remap registers */
 	viu_regs = devm_ioremap(&op->dev, r.start, sizeof(struct viu_reg));
 	if (!viu_regs) {
 		dev_err(&op->dev, "Can't map register set\n");
-		ret = -ENOMEM;
-		goto err;
+		return -ENOMEM;
 	}
 
 	/* Prepare our private structure */
 	viu_dev = devm_kzalloc(&op->dev, sizeof(struct viu_dev), GFP_ATOMIC);
 	if (!viu_dev) {
 		dev_err(&op->dev, "Can't allocate private structure\n");
-		ret = -ENOMEM;
-		goto err;
+		return -ENOMEM;
 	}
 
 	viu_dev->vr = viu_regs;
@@ -1538,7 +1535,7 @@ static int viu_of_probe(struct platform_device *op)
 	ret = v4l2_device_register(viu_dev->dev, &viu_dev->v4l2_dev);
 	if (ret < 0) {
 		dev_err(&op->dev, "v4l2_device_register() failed: %d\n", ret);
-		goto err;
+		return ret;
 	}
 
 	ad = i2c_get_adapter(0);
@@ -1597,7 +1594,8 @@ static int viu_of_probe(struct platform_device *op)
 	viu_reset(viu_dev->vr);
 
 	/* install interrupt handler */
-	if (request_irq(viu_dev->irq, viu_intr, 0, "viu", (void *)viu_dev)) {
+	if (devm_request_irq(&op->dev, viu_dev->irq, viu_intr, 0, "viu",
+				(void *)viu_dev)) {
 		dev_err(&op->dev, "Request VIU IRQ failed.\n");
 		ret = -ENODEV;
 		goto err_irq;
@@ -1616,8 +1614,6 @@ err_vdev:
 	mutex_unlock(&viu_dev->lock);
 	i2c_put_adapter(ad);
 	v4l2_device_unregister(&viu_dev->v4l2_dev);
-err:
-	irq_dispose_mapping(viu_irq);
 	return ret;
 }
 
@@ -1629,9 +1625,6 @@ static int viu_of_remove(struct platform_device *op)
 					      struct v4l2_subdev, list);
 	struct i2c_client *client = v4l2_get_subdevdata(sdev);
 
-	free_irq(dev->irq, (void *)dev);
-	irq_dispose_mapping(dev->irq);
-
 	clk_disable_unprepare(dev->clk);
 
 	video_unregister_device(dev->vdev);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 11/21] mfd: use devm_irq_of_parse_and_map() where appropriate
@ 2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
  0 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/mfd/max8997.c |    4 +++-
 drivers/mfd/max8998.c |    4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index 8cf7a01..6ae0786 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -153,7 +153,9 @@ static struct max8997_platform_data *max8997_i2c_parse_dt_pdata(
 		return ERR_PTR(-ENOMEM);
 	}
 
-	pd->ono = irq_of_parse_and_map(dev->of_node, 1);
+	pd->ono = devm_irq_of_parse_and_map(dev, dev->of_node, 1);
+	if (pd->ono < 0)
+		return ERR_PTR(pd->ono);
 
 	/*
 	 * ToDo: the 'wakeup' member in the platform data is more of a linux
diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c
index 592db06..6b62dd7 100644
--- a/drivers/mfd/max8998.c
+++ b/drivers/mfd/max8998.c
@@ -159,7 +159,9 @@ static struct max8998_platform_data *max8998_i2c_parse_dt_pdata(
 	if (!pd)
 		return ERR_PTR(-ENOMEM);
 
-	pd->ono = irq_of_parse_and_map(dev->of_node, 1);
+	pd->ono = devm_irq_of_parse_and_map(dev, dev->of_node, 1);
+	if (pd->ono < 0)
+		return ERR_PTR(pd->ono);
 
 	/*
 	 * ToDo: the 'wakeup' member in the platform data is more of a linux
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 11/21] mfd: use devm_irq_of_parse_and_map() where appropriate
@ 2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
  0 siblings, 0 replies; 52+ messages in thread
From: nyushchenko-jFhMxQ4mL6a2X5qOxWx28w @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	lugovskoy-jFhMxQ4mL6a2X5qOxWx28w, Nikita Yushchenko

From: Nikita Yushchenko <nyushchenko-jFhMxQ4mL6a2X5qOxWx28w@public.gmane.org>

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.

Signed-off-by: Nikita Yushchenko <nyushchenko-jFhMxQ4mL6a2X5qOxWx28w@public.gmane.org>
---
 drivers/mfd/max8997.c |    4 +++-
 drivers/mfd/max8998.c |    4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index 8cf7a01..6ae0786 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -153,7 +153,9 @@ static struct max8997_platform_data *max8997_i2c_parse_dt_pdata(
 		return ERR_PTR(-ENOMEM);
 	}
 
-	pd->ono = irq_of_parse_and_map(dev->of_node, 1);
+	pd->ono = devm_irq_of_parse_and_map(dev, dev->of_node, 1);
+	if (pd->ono < 0)
+		return ERR_PTR(pd->ono);
 
 	/*
 	 * ToDo: the 'wakeup' member in the platform data is more of a linux
diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c
index 592db06..6b62dd7 100644
--- a/drivers/mfd/max8998.c
+++ b/drivers/mfd/max8998.c
@@ -159,7 +159,9 @@ static struct max8998_platform_data *max8998_i2c_parse_dt_pdata(
 	if (!pd)
 		return ERR_PTR(-ENOMEM);
 
-	pd->ono = irq_of_parse_and_map(dev->of_node, 1);
+	pd->ono = devm_irq_of_parse_and_map(dev, dev->of_node, 1);
+	if (pd->ono < 0)
+		return ERR_PTR(pd->ono);
 
 	/*
 	 * ToDo: the 'wakeup' member in the platform data is more of a linux
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 12/21] mpc5121_nfc: use devm_irq_of_parse_and_map()
  2014-06-04 11:13 [PATCH 00/21] add and use devm_irq_of_parse_and_map() nyushchenko
                   ` (10 preceding siblings ...)
  2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
@ 2014-06-04 11:13 ` nyushchenko
  2014-06-04 11:13 ` [PATCH 13/21] net/can: use devm_irq_of_parse_and_map() where appropriate nyushchenko
                   ` (9 subsequent siblings)
  21 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/mtd/nand/mpc5121_nfc.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/mpc5121_nfc.c b/drivers/mtd/nand/mpc5121_nfc.c
index e78841a..b710168 100644
--- a/drivers/mtd/nand/mpc5121_nfc.c
+++ b/drivers/mtd/nand/mpc5121_nfc.c
@@ -669,10 +669,10 @@ static int mpc5121_nfc_probe(struct platform_device *op)
 		return retval;
 	}
 
-	prv->irq = irq_of_parse_and_map(dn, 0);
-	if (prv->irq == NO_IRQ) {
+	prv->irq = devm_irq_of_parse_and_map(dev, dn, 0);
+	if (prv->irq <= 0) {
 		dev_err(dev, "Error mapping IRQ!\n");
-		return -EINVAL;
+		return prv->irq ? prv->irq : -EINVAL;
 	}
 
 	retval = of_address_to_resource(dn, 0, &res);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 13/21] net/can: use devm_irq_of_parse_and_map() where appropriate
  2014-06-04 11:13 [PATCH 00/21] add and use devm_irq_of_parse_and_map() nyushchenko
                   ` (11 preceding siblings ...)
  2014-06-04 11:13 ` [PATCH 12/21] mpc5121_nfc: use devm_irq_of_parse_and_map() nyushchenko
@ 2014-06-04 11:13 ` nyushchenko
  2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
                   ` (8 subsequent siblings)
  21 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/net/can/grcan.c                    |   11 ++++-------
 drivers/net/can/mscan/mpc5xxx_can.c        |   11 ++++-------
 drivers/net/can/sja1000/sja1000_platform.c |    2 +-
 3 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c
index 3fd9fd9..695932f 100644
--- a/drivers/net/can/grcan.c
+++ b/drivers/net/can/grcan.c
@@ -1687,10 +1687,10 @@ static int grcan_probe(struct platform_device *ofdev)
 		goto exit_error;
 	}
 
-	irq = irq_of_parse_and_map(np, GRCAN_IRQIX_IRQ);
-	if (!irq) {
+	irq = devm_irq_of_parse_and_map(&ofdev->dev, np, GRCAN_IRQIX_IRQ);
+	if (irq <= 0) {
 		dev_err(&ofdev->dev, "no irq found\n");
-		err = -ENODEV;
+		err = irq ? irq : -ENODEV;
 		goto exit_error;
 	}
 
@@ -1698,12 +1698,10 @@ static int grcan_probe(struct platform_device *ofdev)
 
 	err = grcan_setup_netdev(ofdev, base, irq, ambafreq, txbug);
 	if (err)
-		goto exit_dispose_irq;
+		goto exit_error;
 
 	return 0;
 
-exit_dispose_irq:
-	irq_dispose_mapping(irq);
 exit_error:
 	dev_err(&ofdev->dev,
 		"%s socket CAN driver initialization failed with error %d\n",
@@ -1718,7 +1716,6 @@ static int grcan_remove(struct platform_device *ofdev)
 
 	unregister_candev(dev); /* Will in turn call grcan_close */
 
-	irq_dispose_mapping(dev->irq);
 	netif_napi_del(&priv->napi);
 	free_candev(dev);
 
diff --git a/drivers/net/can/mscan/mpc5xxx_can.c b/drivers/net/can/mscan/mpc5xxx_can.c
index 4472529..b59ef67 100644
--- a/drivers/net/can/mscan/mpc5xxx_can.c
+++ b/drivers/net/can/mscan/mpc5xxx_can.c
@@ -306,16 +306,16 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev)
 		return err;
 	}
 
-	irq = irq_of_parse_and_map(np, 0);
-	if (!irq) {
+	irq = devm_irq_of_parse_and_map(&ofdev->dev, np, 0);
+	if (irq <= 0) {
 		dev_err(&ofdev->dev, "no irq found\n");
-		err = -ENODEV;
+		err = irq ? irq : -ENODEV;
 		goto exit_unmap_mem;
 	}
 
 	dev = alloc_mscandev();
 	if (!dev)
-		goto exit_dispose_irq;
+		goto exit_unmap_mem;
 	platform_set_drvdata(ofdev, dev);
 	SET_NETDEV_DEV(dev, &ofdev->dev);
 
@@ -348,8 +348,6 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev)
 
 exit_free_mscan:
 	free_candev(dev);
-exit_dispose_irq:
-	irq_dispose_mapping(irq);
 exit_unmap_mem:
 	iounmap(base);
 
@@ -370,7 +368,6 @@ static int mpc5xxx_can_remove(struct platform_device *ofdev)
 	if (data && data->put_clock)
 		data->put_clock(ofdev);
 	iounmap(priv->reg_base);
-	irq_dispose_mapping(dev->irq);
 	free_candev(dev);
 
 	return 0;
diff --git a/drivers/net/can/sja1000/sja1000_platform.c b/drivers/net/can/sja1000/sja1000_platform.c
index 95a844a..36c8525 100644
--- a/drivers/net/can/sja1000/sja1000_platform.c
+++ b/drivers/net/can/sja1000/sja1000_platform.c
@@ -184,7 +184,7 @@ static int sp_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	if (of)
-		irq = irq_of_parse_and_map(of, 0);
+		irq = devm_irq_of_parse_and_map(&pdev->dev, of, 0);
 	else
 		res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 14/21] net/ethernet: use devm_irq_of_parse_and_map() where appropriate
@ 2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
  0 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/net/ethernet/allwinner/sun4i-emac.c        |    6 ++---
 drivers/net/ethernet/arc/emac_main.c               |    6 ++---
 drivers/net/ethernet/marvell/mvneta.c              |   15 +++++-------
 drivers/net/ethernet/moxa/moxart_ether.c           |    4 ++--
 .../net/ethernet/samsung/sxgbe/sxgbe_platform.c    |   24 ++++++++------------
 5 files changed, 23 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index 2846067..9c2d0d7 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -839,10 +839,10 @@ static int emac_probe(struct platform_device *pdev)
 
 	/* fill in parameters for net-dev structure */
 	ndev->base_addr = (unsigned long)db->membase;
-	ndev->irq = irq_of_parse_and_map(np, 0);
-	if (ndev->irq == -ENXIO) {
+	ndev->irq = devm_irq_of_parse_and_map(&pdev->dev, np, 0);
+	if (ndev->irq <= 0) {
 		netdev_err(ndev, "No irq resource\n");
-		ret = ndev->irq;
+		ret = ndev->irq ? ndev->irq : -EINVAL;
 		goto out;
 	}
 
diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c
index d647a7d..4de428d 100644
--- a/drivers/net/ethernet/arc/emac_main.c
+++ b/drivers/net/ethernet/arc/emac_main.c
@@ -650,10 +650,10 @@ static int arc_emac_probe(struct platform_device *pdev)
 	}
 
 	/* Get IRQ from device tree */
-	irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
-	if (!irq) {
+	irq = devm_irq_of_parse_and_map(&pdev->dev, pdev->dev.of_node, 0);
+	if (irq <= 0) {
 		dev_err(&pdev->dev, "failed to retrieve <irq> value from device tree\n");
-		return -ENODEV;
+		return irq ? irq : -ENODEV;
 	}
 
 	ndev = alloc_etherdev(sizeof(struct arc_emac_priv));
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 14786c8..42043f2 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -2789,9 +2789,9 @@ static int mvneta_probe(struct platform_device *pdev)
 	if (!dev)
 		return -ENOMEM;
 
-	dev->irq = irq_of_parse_and_map(dn, 0);
-	if (dev->irq == 0) {
-		err = -EINVAL;
+	dev->irq = devm_irq_of_parse_and_map(&pdev->dev, dn, 0);
+	if (dev->irq <= 0) {
+		err = dev->irq ? dev->irq : -EINVAL;
 		goto err_free_netdev;
 	}
 
@@ -2799,14 +2799,14 @@ static int mvneta_probe(struct platform_device *pdev)
 	if (!phy_node) {
 		dev_err(&pdev->dev, "no associated PHY\n");
 		err = -ENODEV;
-		goto err_free_irq;
+		goto err_free_netdev;
 	}
 
 	phy_mode = of_get_phy_mode(dn);
 	if (phy_mode < 0) {
 		dev_err(&pdev->dev, "incorrect phy-mode\n");
 		err = -EINVAL;
-		goto err_free_irq;
+		goto err_free_netdev;
 	}
 
 	dev->tx_queue_len = MVNETA_MAX_TXD;
@@ -2824,7 +2824,7 @@ static int mvneta_probe(struct platform_device *pdev)
 	pp->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(pp->clk)) {
 		err = PTR_ERR(pp->clk);
-		goto err_free_irq;
+		goto err_free_netdev;
 	}
 
 	clk_prepare_enable(pp->clk);
@@ -2906,8 +2906,6 @@ err_free_stats:
 	free_percpu(pp->stats);
 err_clk:
 	clk_disable_unprepare(pp->clk);
-err_free_irq:
-	irq_dispose_mapping(dev->irq);
 err_free_netdev:
 	free_netdev(dev);
 	return err;
@@ -2923,7 +2921,6 @@ static int mvneta_remove(struct platform_device *pdev)
 	mvneta_deinit(pp);
 	clk_disable_unprepare(pp->clk);
 	free_percpu(pp->stats);
-	irq_dispose_mapping(dev->irq);
 	free_netdev(dev);
 
 	return 0;
diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c
index 5020fd4..b4de432 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -443,10 +443,10 @@ static int moxart_mac_probe(struct platform_device *pdev)
 	if (!ndev)
 		return -ENOMEM;
 
-	irq = irq_of_parse_and_map(node, 0);
+	irq = devm_irq_of_parse_and_map(p_dev, node, 0);
 	if (irq <= 0) {
 		netdev_err(ndev, "irq_of_parse_and_map failed\n");
-		ret = -EINVAL;
+		ret = irq ? irq : -EINVAL;
 		goto irq_map_fail;
 	}
 
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
index b147d46..9118905 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
@@ -122,7 +122,7 @@ static int sxgbe_platform_probe(struct platform_device *pdev)
 	}
 
 	/* Get the SXGBE common INT information */
-	priv->irq  = irq_of_parse_and_map(node, 0);
+	priv->irq = devm_irq_of_parse_and_map(dev, node, 0);
 	if (priv->irq <= 0) {
 		dev_err(dev, "sxgbe common irq parsing failed\n");
 		goto err_drv_remove;
@@ -130,25 +130,27 @@ static int sxgbe_platform_probe(struct platform_device *pdev)
 
 	/* Get the TX/RX IRQ numbers */
 	for (i = 0, chan = 1; i < SXGBE_TX_QUEUES; i++) {
-		priv->txq[i]->irq_no = irq_of_parse_and_map(node, chan++);
+		priv->txq[i]->irq_no = devm_irq_of_parse_and_map(dev,
+				node, chan++);
 		if (priv->txq[i]->irq_no <= 0) {
 			dev_err(dev, "sxgbe tx irq parsing failed\n");
-			goto err_tx_irq_unmap;
+			goto err_drv_remove;
 		}
 	}
 
 	for (i = 0; i < SXGBE_RX_QUEUES; i++) {
-		priv->rxq[i]->irq_no = irq_of_parse_and_map(node, chan++);
+		priv->rxq[i]->irq_no = devm_irq_of_parse_and_map(dev,
+				node, chan++);
 		if (priv->rxq[i]->irq_no <= 0) {
 			dev_err(dev, "sxgbe rx irq parsing failed\n");
-			goto err_rx_irq_unmap;
+			goto err_drv_remove;
 		}
 	}
 
-	priv->lpi_irq = irq_of_parse_and_map(node, chan);
+	priv->lpi_irq = devm_irq_of_parse_and_map(dev, node, chan);
 	if (priv->lpi_irq <= 0) {
 		dev_err(dev, "sxgbe lpi irq parsing failed\n");
-		goto err_rx_irq_unmap;
+		goto err_drv_remove;
 	}
 
 	platform_set_drvdata(pdev, priv->dev);
@@ -157,14 +159,6 @@ static int sxgbe_platform_probe(struct platform_device *pdev)
 
 	return 0;
 
-err_rx_irq_unmap:
-	while (--i)
-		irq_dispose_mapping(priv->rxq[i]->irq_no);
-	i = SXGBE_TX_QUEUES;
-err_tx_irq_unmap:
-	while (--i)
-		irq_dispose_mapping(priv->txq[i]->irq_no);
-	irq_dispose_mapping(priv->irq);
 err_drv_remove:
 	sxgbe_drv_remove(ndev);
 err_out:
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 14/21] net/ethernet: use devm_irq_of_parse_and_map() where appropriate
@ 2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
  0 siblings, 0 replies; 52+ messages in thread
From: nyushchenko-jFhMxQ4mL6a2X5qOxWx28w @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	lugovskoy-jFhMxQ4mL6a2X5qOxWx28w, Nikita Yushchenko

From: Nikita Yushchenko <nyushchenko-jFhMxQ4mL6a2X5qOxWx28w@public.gmane.org>

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.

Signed-off-by: Nikita Yushchenko <nyushchenko-jFhMxQ4mL6a2X5qOxWx28w@public.gmane.org>
---
 drivers/net/ethernet/allwinner/sun4i-emac.c        |    6 ++---
 drivers/net/ethernet/arc/emac_main.c               |    6 ++---
 drivers/net/ethernet/marvell/mvneta.c              |   15 +++++-------
 drivers/net/ethernet/moxa/moxart_ether.c           |    4 ++--
 .../net/ethernet/samsung/sxgbe/sxgbe_platform.c    |   24 ++++++++------------
 5 files changed, 23 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index 2846067..9c2d0d7 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -839,10 +839,10 @@ static int emac_probe(struct platform_device *pdev)
 
 	/* fill in parameters for net-dev structure */
 	ndev->base_addr = (unsigned long)db->membase;
-	ndev->irq = irq_of_parse_and_map(np, 0);
-	if (ndev->irq == -ENXIO) {
+	ndev->irq = devm_irq_of_parse_and_map(&pdev->dev, np, 0);
+	if (ndev->irq <= 0) {
 		netdev_err(ndev, "No irq resource\n");
-		ret = ndev->irq;
+		ret = ndev->irq ? ndev->irq : -EINVAL;
 		goto out;
 	}
 
diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c
index d647a7d..4de428d 100644
--- a/drivers/net/ethernet/arc/emac_main.c
+++ b/drivers/net/ethernet/arc/emac_main.c
@@ -650,10 +650,10 @@ static int arc_emac_probe(struct platform_device *pdev)
 	}
 
 	/* Get IRQ from device tree */
-	irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
-	if (!irq) {
+	irq = devm_irq_of_parse_and_map(&pdev->dev, pdev->dev.of_node, 0);
+	if (irq <= 0) {
 		dev_err(&pdev->dev, "failed to retrieve <irq> value from device tree\n");
-		return -ENODEV;
+		return irq ? irq : -ENODEV;
 	}
 
 	ndev = alloc_etherdev(sizeof(struct arc_emac_priv));
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 14786c8..42043f2 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -2789,9 +2789,9 @@ static int mvneta_probe(struct platform_device *pdev)
 	if (!dev)
 		return -ENOMEM;
 
-	dev->irq = irq_of_parse_and_map(dn, 0);
-	if (dev->irq == 0) {
-		err = -EINVAL;
+	dev->irq = devm_irq_of_parse_and_map(&pdev->dev, dn, 0);
+	if (dev->irq <= 0) {
+		err = dev->irq ? dev->irq : -EINVAL;
 		goto err_free_netdev;
 	}
 
@@ -2799,14 +2799,14 @@ static int mvneta_probe(struct platform_device *pdev)
 	if (!phy_node) {
 		dev_err(&pdev->dev, "no associated PHY\n");
 		err = -ENODEV;
-		goto err_free_irq;
+		goto err_free_netdev;
 	}
 
 	phy_mode = of_get_phy_mode(dn);
 	if (phy_mode < 0) {
 		dev_err(&pdev->dev, "incorrect phy-mode\n");
 		err = -EINVAL;
-		goto err_free_irq;
+		goto err_free_netdev;
 	}
 
 	dev->tx_queue_len = MVNETA_MAX_TXD;
@@ -2824,7 +2824,7 @@ static int mvneta_probe(struct platform_device *pdev)
 	pp->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(pp->clk)) {
 		err = PTR_ERR(pp->clk);
-		goto err_free_irq;
+		goto err_free_netdev;
 	}
 
 	clk_prepare_enable(pp->clk);
@@ -2906,8 +2906,6 @@ err_free_stats:
 	free_percpu(pp->stats);
 err_clk:
 	clk_disable_unprepare(pp->clk);
-err_free_irq:
-	irq_dispose_mapping(dev->irq);
 err_free_netdev:
 	free_netdev(dev);
 	return err;
@@ -2923,7 +2921,6 @@ static int mvneta_remove(struct platform_device *pdev)
 	mvneta_deinit(pp);
 	clk_disable_unprepare(pp->clk);
 	free_percpu(pp->stats);
-	irq_dispose_mapping(dev->irq);
 	free_netdev(dev);
 
 	return 0;
diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c
index 5020fd4..b4de432 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -443,10 +443,10 @@ static int moxart_mac_probe(struct platform_device *pdev)
 	if (!ndev)
 		return -ENOMEM;
 
-	irq = irq_of_parse_and_map(node, 0);
+	irq = devm_irq_of_parse_and_map(p_dev, node, 0);
 	if (irq <= 0) {
 		netdev_err(ndev, "irq_of_parse_and_map failed\n");
-		ret = -EINVAL;
+		ret = irq ? irq : -EINVAL;
 		goto irq_map_fail;
 	}
 
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
index b147d46..9118905 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
@@ -122,7 +122,7 @@ static int sxgbe_platform_probe(struct platform_device *pdev)
 	}
 
 	/* Get the SXGBE common INT information */
-	priv->irq  = irq_of_parse_and_map(node, 0);
+	priv->irq = devm_irq_of_parse_and_map(dev, node, 0);
 	if (priv->irq <= 0) {
 		dev_err(dev, "sxgbe common irq parsing failed\n");
 		goto err_drv_remove;
@@ -130,25 +130,27 @@ static int sxgbe_platform_probe(struct platform_device *pdev)
 
 	/* Get the TX/RX IRQ numbers */
 	for (i = 0, chan = 1; i < SXGBE_TX_QUEUES; i++) {
-		priv->txq[i]->irq_no = irq_of_parse_and_map(node, chan++);
+		priv->txq[i]->irq_no = devm_irq_of_parse_and_map(dev,
+				node, chan++);
 		if (priv->txq[i]->irq_no <= 0) {
 			dev_err(dev, "sxgbe tx irq parsing failed\n");
-			goto err_tx_irq_unmap;
+			goto err_drv_remove;
 		}
 	}
 
 	for (i = 0; i < SXGBE_RX_QUEUES; i++) {
-		priv->rxq[i]->irq_no = irq_of_parse_and_map(node, chan++);
+		priv->rxq[i]->irq_no = devm_irq_of_parse_and_map(dev,
+				node, chan++);
 		if (priv->rxq[i]->irq_no <= 0) {
 			dev_err(dev, "sxgbe rx irq parsing failed\n");
-			goto err_rx_irq_unmap;
+			goto err_drv_remove;
 		}
 	}
 
-	priv->lpi_irq = irq_of_parse_and_map(node, chan);
+	priv->lpi_irq = devm_irq_of_parse_and_map(dev, node, chan);
 	if (priv->lpi_irq <= 0) {
 		dev_err(dev, "sxgbe lpi irq parsing failed\n");
-		goto err_rx_irq_unmap;
+		goto err_drv_remove;
 	}
 
 	platform_set_drvdata(pdev, priv->dev);
@@ -157,14 +159,6 @@ static int sxgbe_platform_probe(struct platform_device *pdev)
 
 	return 0;
 
-err_rx_irq_unmap:
-	while (--i)
-		irq_dispose_mapping(priv->rxq[i]->irq_no);
-	i = SXGBE_TX_QUEUES;
-err_tx_irq_unmap:
-	while (--i)
-		irq_dispose_mapping(priv->txq[i]->irq_no);
-	irq_dispose_mapping(priv->irq);
 err_drv_remove:
 	sxgbe_drv_remove(ndev);
 err_out:
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 15/21] pinctrl: use devm_irq_of_parse_and_map() where appropriate
@ 2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
  0 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/pinctrl/pinctrl-bcm2835.c    |    6 +++++-
 drivers/pinctrl/pinctrl-exynos.c     |   11 ++++++-----
 drivers/pinctrl/pinctrl-exynos5440.c |    2 +-
 drivers/pinctrl/pinctrl-rockchip.c   |    6 +++++-
 drivers/pinctrl/pinctrl-s3c24xx.c    |    6 +++---
 drivers/pinctrl/pinctrl-s3c64xx.c    |    6 +++---
 drivers/pinctrl/pinctrl-single.c     |    6 +++++-
 drivers/pinctrl/pinctrl-sunxi.c      |    6 +++---
 8 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-bcm2835.c b/drivers/pinctrl/pinctrl-bcm2835.c
index 3d907de..320dcf4 100644
--- a/drivers/pinctrl/pinctrl-bcm2835.c
+++ b/drivers/pinctrl/pinctrl-bcm2835.c
@@ -1012,7 +1012,11 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
 		for_each_set_bit(offset, &events, 32)
 			bcm2835_gpio_wr(pc, GPEDS0 + i * 4, BIT(offset));
 
-		pc->irq[i] = irq_of_parse_and_map(np, i);
+		pc->irq[i] = devm_irq_of_parse_and_map(dev, np, i);
+		if (pc->irq[i] <= 0) {
+			dev_err(dev, "unable to locate IRQ for bank %d\n", i);
+			return pc->irq[i] ? pc->irq[i] : -EINVAL;
+		}
 		pc->irq_data[i].pc = pc;
 		pc->irq_data[i].bank = i;
 		spin_lock_init(&pc->irq_lock[i]);
diff --git a/drivers/pinctrl/pinctrl-exynos.c b/drivers/pinctrl/pinctrl-exynos.c
index 07c8130..128af30 100644
--- a/drivers/pinctrl/pinctrl-exynos.c
+++ b/drivers/pinctrl/pinctrl-exynos.c
@@ -549,8 +549,9 @@ static int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 		}
 
 		for (idx = 0; idx < bank->nr_pins; ++idx) {
-			irq = irq_of_parse_and_map(bank->of_node, idx);
-			if (!irq) {
+			irq = devm_irq_of_parse_and_map(dev, bank->of_node,
+					idx);
+			if (irq <= 0) {
 				dev_err(dev, "irq number for eint-%s-%d not found\n",
 							bank->name, idx);
 				continue;
@@ -565,10 +566,10 @@ static int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 	if (!muxed_banks)
 		return 0;
 
-	irq = irq_of_parse_and_map(wkup_np, 0);
-	if (!irq) {
+	irq = devm_irq_of_parse_and_map(dev, wkup_np, 0);
+	if (irq <= 0) {
 		dev_err(dev, "irq number for muxed EINTs not found\n");
-		return 0;
+		return irq ? irq : -EINVAL;
 	}
 
 	muxed_data = devm_kzalloc(dev, sizeof(*muxed_data)
diff --git a/drivers/pinctrl/pinctrl-exynos5440.c b/drivers/pinctrl/pinctrl-exynos5440.c
index 8fe2ab0..efb1e8d 100644
--- a/drivers/pinctrl/pinctrl-exynos5440.c
+++ b/drivers/pinctrl/pinctrl-exynos5440.c
@@ -966,7 +966,7 @@ static int exynos5440_gpio_irq_init(struct platform_device *pdev,
 	}
 
 	for (i = 0; i < EXYNOS5440_MAX_GPIO_INT; i++) {
-		irq = irq_of_parse_and_map(dev->of_node, i);
+		irq = devm_irq_of_parse_and_map(dev, dev->of_node, i);
 		if (irq <= 0) {
 			dev_err(dev, "irq parsing failed\n");
 			return -EINVAL;
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 96c60d2..622a130 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -1398,7 +1398,11 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank,
 		bank->bank_type = COMMON_BANK;
 	}
 
-	bank->irq = irq_of_parse_and_map(bank->of_node, 0);
+	bank->irq = devm_irq_of_parse_and_map(dev, bank->of_node, 0);
+	if (bank->irq < 0) {
+		dev_err(dev, "cannot find IRQ for bank\n");
+		return bank->irq;
+	}
 
 	bank->clk = of_clk_get(bank->of_node, 0);
 	if (IS_ERR(bank->clk))
diff --git a/drivers/pinctrl/pinctrl-s3c24xx.c b/drivers/pinctrl/pinctrl-s3c24xx.c
index ad3eaad..93d8e2f 100644
--- a/drivers/pinctrl/pinctrl-s3c24xx.c
+++ b/drivers/pinctrl/pinctrl-s3c24xx.c
@@ -507,10 +507,10 @@ static int s3c24xx_eint_init(struct samsung_pinctrl_drv_data *d)
 	for (i = 0; i < NUM_EINT_IRQ; ++i) {
 		unsigned int irq;
 
-		irq = irq_of_parse_and_map(eint_np, i);
-		if (!irq) {
+		irq = devm_irq_of_parse_and_map(dev, eint_np, i);
+		if (irq <= 0) {
 			dev_err(dev, "failed to get wakeup EINT IRQ %d\n", i);
-			return -ENXIO;
+			return irq ? irq : -ENXIO;
 		}
 
 		eint_data->parents[i] = irq;
diff --git a/drivers/pinctrl/pinctrl-s3c64xx.c b/drivers/pinctrl/pinctrl-s3c64xx.c
index 89143c9..f0c9188 100644
--- a/drivers/pinctrl/pinctrl-s3c64xx.c
+++ b/drivers/pinctrl/pinctrl-s3c64xx.c
@@ -725,10 +725,10 @@ static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
 	for (i = 0; i < NUM_EINT0_IRQ; ++i) {
 		unsigned int irq;
 
-		irq = irq_of_parse_and_map(eint0_np, i);
-		if (!irq) {
+		irq = devm_irq_of_parse_and_map(dev, eint0_np, i);
+		if (irq <= 0) {
 			dev_err(dev, "failed to get wakeup EINT IRQ %d\n", i);
-			return -ENXIO;
+			return irq ? irq : -ENXIO;
 		}
 
 		irq_set_chained_handler(irq, s3c64xx_eint0_handlers[i]);
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 2960557..0b9b017 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1988,7 +1988,11 @@ static int pcs_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto free;
 
-	pcs->socdata.irq = irq_of_parse_and_map(np, 0);
+	pcs->socdata.irq = devm_irq_of_parse_and_map(&pdev->dev, np, 0);
+	if (pcs->socdata.irq < 0) {
+		ret = pcs->socdata.irq;
+		goto free;
+	}
 	if (pcs->socdata.irq)
 		pcs->flags |= PCS_FEAT_IRQ;
 
diff --git a/drivers/pinctrl/pinctrl-sunxi.c b/drivers/pinctrl/pinctrl-sunxi.c
index f9fabe9..e0759e2 100644
--- a/drivers/pinctrl/pinctrl-sunxi.c
+++ b/drivers/pinctrl/pinctrl-sunxi.c
@@ -886,9 +886,9 @@ static int sunxi_pinctrl_probe(struct platform_device *pdev)
 
 	clk_prepare_enable(clk);
 
-	pctl->irq = irq_of_parse_and_map(node, 0);
-	if (!pctl->irq) {
-		ret = -EINVAL;
+	pctl->irq = devm_irq_of_parse_and_map(&pdev->dev, node, 0);
+	if (pctl->irq <= 0) {
+		ret = pctl->irq ? pctl->irq : -EINVAL;
 		goto gpiochip_error;
 	}
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 15/21] pinctrl: use devm_irq_of_parse_and_map() where appropriate
@ 2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
  0 siblings, 0 replies; 52+ messages in thread
From: nyushchenko-jFhMxQ4mL6a2X5qOxWx28w @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	lugovskoy-jFhMxQ4mL6a2X5qOxWx28w, Nikita Yushchenko

From: Nikita Yushchenko <nyushchenko-jFhMxQ4mL6a2X5qOxWx28w@public.gmane.org>

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.

Signed-off-by: Nikita Yushchenko <nyushchenko-jFhMxQ4mL6a2X5qOxWx28w@public.gmane.org>
---
 drivers/pinctrl/pinctrl-bcm2835.c    |    6 +++++-
 drivers/pinctrl/pinctrl-exynos.c     |   11 ++++++-----
 drivers/pinctrl/pinctrl-exynos5440.c |    2 +-
 drivers/pinctrl/pinctrl-rockchip.c   |    6 +++++-
 drivers/pinctrl/pinctrl-s3c24xx.c    |    6 +++---
 drivers/pinctrl/pinctrl-s3c64xx.c    |    6 +++---
 drivers/pinctrl/pinctrl-single.c     |    6 +++++-
 drivers/pinctrl/pinctrl-sunxi.c      |    6 +++---
 8 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-bcm2835.c b/drivers/pinctrl/pinctrl-bcm2835.c
index 3d907de..320dcf4 100644
--- a/drivers/pinctrl/pinctrl-bcm2835.c
+++ b/drivers/pinctrl/pinctrl-bcm2835.c
@@ -1012,7 +1012,11 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
 		for_each_set_bit(offset, &events, 32)
 			bcm2835_gpio_wr(pc, GPEDS0 + i * 4, BIT(offset));
 
-		pc->irq[i] = irq_of_parse_and_map(np, i);
+		pc->irq[i] = devm_irq_of_parse_and_map(dev, np, i);
+		if (pc->irq[i] <= 0) {
+			dev_err(dev, "unable to locate IRQ for bank %d\n", i);
+			return pc->irq[i] ? pc->irq[i] : -EINVAL;
+		}
 		pc->irq_data[i].pc = pc;
 		pc->irq_data[i].bank = i;
 		spin_lock_init(&pc->irq_lock[i]);
diff --git a/drivers/pinctrl/pinctrl-exynos.c b/drivers/pinctrl/pinctrl-exynos.c
index 07c8130..128af30 100644
--- a/drivers/pinctrl/pinctrl-exynos.c
+++ b/drivers/pinctrl/pinctrl-exynos.c
@@ -549,8 +549,9 @@ static int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 		}
 
 		for (idx = 0; idx < bank->nr_pins; ++idx) {
-			irq = irq_of_parse_and_map(bank->of_node, idx);
-			if (!irq) {
+			irq = devm_irq_of_parse_and_map(dev, bank->of_node,
+					idx);
+			if (irq <= 0) {
 				dev_err(dev, "irq number for eint-%s-%d not found\n",
 							bank->name, idx);
 				continue;
@@ -565,10 +566,10 @@ static int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 	if (!muxed_banks)
 		return 0;
 
-	irq = irq_of_parse_and_map(wkup_np, 0);
-	if (!irq) {
+	irq = devm_irq_of_parse_and_map(dev, wkup_np, 0);
+	if (irq <= 0) {
 		dev_err(dev, "irq number for muxed EINTs not found\n");
-		return 0;
+		return irq ? irq : -EINVAL;
 	}
 
 	muxed_data = devm_kzalloc(dev, sizeof(*muxed_data)
diff --git a/drivers/pinctrl/pinctrl-exynos5440.c b/drivers/pinctrl/pinctrl-exynos5440.c
index 8fe2ab0..efb1e8d 100644
--- a/drivers/pinctrl/pinctrl-exynos5440.c
+++ b/drivers/pinctrl/pinctrl-exynos5440.c
@@ -966,7 +966,7 @@ static int exynos5440_gpio_irq_init(struct platform_device *pdev,
 	}
 
 	for (i = 0; i < EXYNOS5440_MAX_GPIO_INT; i++) {
-		irq = irq_of_parse_and_map(dev->of_node, i);
+		irq = devm_irq_of_parse_and_map(dev, dev->of_node, i);
 		if (irq <= 0) {
 			dev_err(dev, "irq parsing failed\n");
 			return -EINVAL;
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 96c60d2..622a130 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -1398,7 +1398,11 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank,
 		bank->bank_type = COMMON_BANK;
 	}
 
-	bank->irq = irq_of_parse_and_map(bank->of_node, 0);
+	bank->irq = devm_irq_of_parse_and_map(dev, bank->of_node, 0);
+	if (bank->irq < 0) {
+		dev_err(dev, "cannot find IRQ for bank\n");
+		return bank->irq;
+	}
 
 	bank->clk = of_clk_get(bank->of_node, 0);
 	if (IS_ERR(bank->clk))
diff --git a/drivers/pinctrl/pinctrl-s3c24xx.c b/drivers/pinctrl/pinctrl-s3c24xx.c
index ad3eaad..93d8e2f 100644
--- a/drivers/pinctrl/pinctrl-s3c24xx.c
+++ b/drivers/pinctrl/pinctrl-s3c24xx.c
@@ -507,10 +507,10 @@ static int s3c24xx_eint_init(struct samsung_pinctrl_drv_data *d)
 	for (i = 0; i < NUM_EINT_IRQ; ++i) {
 		unsigned int irq;
 
-		irq = irq_of_parse_and_map(eint_np, i);
-		if (!irq) {
+		irq = devm_irq_of_parse_and_map(dev, eint_np, i);
+		if (irq <= 0) {
 			dev_err(dev, "failed to get wakeup EINT IRQ %d\n", i);
-			return -ENXIO;
+			return irq ? irq : -ENXIO;
 		}
 
 		eint_data->parents[i] = irq;
diff --git a/drivers/pinctrl/pinctrl-s3c64xx.c b/drivers/pinctrl/pinctrl-s3c64xx.c
index 89143c9..f0c9188 100644
--- a/drivers/pinctrl/pinctrl-s3c64xx.c
+++ b/drivers/pinctrl/pinctrl-s3c64xx.c
@@ -725,10 +725,10 @@ static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
 	for (i = 0; i < NUM_EINT0_IRQ; ++i) {
 		unsigned int irq;
 
-		irq = irq_of_parse_and_map(eint0_np, i);
-		if (!irq) {
+		irq = devm_irq_of_parse_and_map(dev, eint0_np, i);
+		if (irq <= 0) {
 			dev_err(dev, "failed to get wakeup EINT IRQ %d\n", i);
-			return -ENXIO;
+			return irq ? irq : -ENXIO;
 		}
 
 		irq_set_chained_handler(irq, s3c64xx_eint0_handlers[i]);
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 2960557..0b9b017 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1988,7 +1988,11 @@ static int pcs_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto free;
 
-	pcs->socdata.irq = irq_of_parse_and_map(np, 0);
+	pcs->socdata.irq = devm_irq_of_parse_and_map(&pdev->dev, np, 0);
+	if (pcs->socdata.irq < 0) {
+		ret = pcs->socdata.irq;
+		goto free;
+	}
 	if (pcs->socdata.irq)
 		pcs->flags |= PCS_FEAT_IRQ;
 
diff --git a/drivers/pinctrl/pinctrl-sunxi.c b/drivers/pinctrl/pinctrl-sunxi.c
index f9fabe9..e0759e2 100644
--- a/drivers/pinctrl/pinctrl-sunxi.c
+++ b/drivers/pinctrl/pinctrl-sunxi.c
@@ -886,9 +886,9 @@ static int sunxi_pinctrl_probe(struct platform_device *pdev)
 
 	clk_prepare_enable(clk);
 
-	pctl->irq = irq_of_parse_and_map(node, 0);
-	if (!pctl->irq) {
-		ret = -EINVAL;
+	pctl->irq = devm_irq_of_parse_and_map(&pdev->dev, node, 0);
+	if (pctl->irq <= 0) {
+		ret = pctl->irq ? pctl->irq : -EINVAL;
 		goto gpiochip_error;
 	}
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 16/21] bq24190_charger: use devm_irq_of_parse_and_map()
  2014-06-04 11:13 [PATCH 00/21] add and use devm_irq_of_parse_and_map() nyushchenko
                   ` (14 preceding siblings ...)
  2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
@ 2014-06-04 11:13 ` nyushchenko
  2014-06-04 11:13 ` [PATCH 17/21] rtc-mpc5121: " nyushchenko
                   ` (5 subsequent siblings)
  21 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/power/bq24190_charger.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/bq24190_charger.c b/drivers/power/bq24190_charger.c
index ad3ff8f..7ba8c03 100644
--- a/drivers/power/bq24190_charger.c
+++ b/drivers/power/bq24190_charger.c
@@ -1315,7 +1315,7 @@ out:
 #ifdef CONFIG_OF
 static int bq24190_setup_dt(struct bq24190_dev_info *bdi)
 {
-	bdi->irq = irq_of_parse_and_map(bdi->dev->of_node, 0);
+	bdi->irq = devm_irq_of_parse_and_map(bdi->dev, bdi->dev->of_node, 0);
 	if (bdi->irq <= 0)
 		return -1;
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 17/21] rtc-mpc5121: use devm_irq_of_parse_and_map()
  2014-06-04 11:13 [PATCH 00/21] add and use devm_irq_of_parse_and_map() nyushchenko
                   ` (15 preceding siblings ...)
  2014-06-04 11:13 ` [PATCH 16/21] bq24190_charger: use devm_irq_of_parse_and_map() nyushchenko
@ 2014-06-04 11:13 ` nyushchenko
  2014-06-04 11:13 ` [PATCH 18/21] spi: use devm_irq_of_parse_and_map() where appropriate nyushchenko
                   ` (4 subsequent siblings)
  21 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/rtc/rtc-mpc5121.c |   38 ++++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/rtc/rtc-mpc5121.c b/drivers/rtc/rtc-mpc5121.c
index dc4f142..c62e5eb 100644
--- a/drivers/rtc/rtc-mpc5121.c
+++ b/drivers/rtc/rtc-mpc5121.c
@@ -328,22 +328,34 @@ static int mpc5121_rtc_probe(struct platform_device *op)
 
 	platform_set_drvdata(op, rtc);
 
-	rtc->irq = irq_of_parse_and_map(op->dev.of_node, 1);
-	err = request_irq(rtc->irq, mpc5121_rtc_handler, 0,
+	rtc->irq = devm_irq_of_parse_and_map(&op->dev, op->dev.of_node, 1);
+	if (rtc->irq <= 0) {
+		dev_err(&op->dev, "%s: could not locate irq\n", __func__);
+		err = rtc->irq ? rtc->irq : -EINVAL;
+		goto out;
+	}
+	err = devm_request_irq(&op->dev, rtc->irq, mpc5121_rtc_handler, 0,
 						"mpc5121-rtc", &op->dev);
 	if (err) {
 		dev_err(&op->dev, "%s: could not request irq: %i\n",
 							__func__, rtc->irq);
-		goto out_dispose;
+		goto out;
 	}
 
-	rtc->irq_periodic = irq_of_parse_and_map(op->dev.of_node, 0);
-	err = request_irq(rtc->irq_periodic, mpc5121_rtc_handler_upd,
+	rtc->irq_periodic = devm_irq_of_parse_and_map(&op->dev,
+				op->dev.of_node, 0);
+	if (rtc->irq_periodic <= 0) {
+		dev_err(&op->dev, "%s: could not locate irq\n", __func__);
+		err = rtc->irq_periodic ? rtc->irq_periodic : -EINVAL;
+		goto out;
+	}
+	err = devm_request_irq(&op->dev, rtc->irq_periodic,
+				mpc5121_rtc_handler_upd,
 				0, "mpc5121-rtc_upd", &op->dev);
 	if (err) {
 		dev_err(&op->dev, "%s: could not request irq: %i\n",
 						__func__, rtc->irq_periodic);
-		goto out_dispose2;
+		goto out;
 	}
 
 	if (of_device_is_compatible(op->dev.of_node, "fsl,mpc5121-rtc")) {
@@ -364,19 +376,13 @@ static int mpc5121_rtc_probe(struct platform_device *op)
 
 	if (IS_ERR(rtc->rtc)) {
 		err = PTR_ERR(rtc->rtc);
-		goto out_free_irq;
+		goto out;
 	}
 	rtc->rtc->uie_unsupported = 1;
 
 	return 0;
 
-out_free_irq:
-	free_irq(rtc->irq_periodic, &op->dev);
-out_dispose2:
-	irq_dispose_mapping(rtc->irq_periodic);
-	free_irq(rtc->irq, &op->dev);
-out_dispose:
-	irq_dispose_mapping(rtc->irq);
+out:
 	iounmap(rtc->regs);
 
 	return err;
@@ -392,10 +398,6 @@ static int mpc5121_rtc_remove(struct platform_device *op)
 	out_8(&regs->int_enable, in_8(&regs->int_enable) & ~0x1);
 
 	iounmap(rtc->regs);
-	free_irq(rtc->irq, &op->dev);
-	free_irq(rtc->irq_periodic, &op->dev);
-	irq_dispose_mapping(rtc->irq);
-	irq_dispose_mapping(rtc->irq_periodic);
 
 	return 0;
 }
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 18/21] spi: use devm_irq_of_parse_and_map() where appropriate
  2014-06-04 11:13 [PATCH 00/21] add and use devm_irq_of_parse_and_map() nyushchenko
                   ` (16 preceding siblings ...)
  2014-06-04 11:13 ` [PATCH 17/21] rtc-mpc5121: " nyushchenko
@ 2014-06-04 11:13 ` nyushchenko
  2014-06-04 11:13 ` [PATCH 19/21] exynos_tmu: use devm_irq_of_parse_and_map() nyushchenko
                   ` (3 subsequent siblings)
  21 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/spi/spi-bcm2835.c     |    2 +-
 drivers/spi/spi-mpc512x-psc.c |    9 ++++++++-
 drivers/spi/spi.c             |    8 +++++++-
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index 6916745..93c0aec 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -337,7 +337,7 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
 		goto out_master_put;
 	}
 
-	bs->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
+	bs->irq = devm_irq_of_parse_and_map(&pdev->dev, pdev->dev.of_node, 0);
 	if (bs->irq <= 0) {
 		dev_err(&pdev->dev, "could not get IRQ: %d\n", bs->irq);
 		err = bs->irq ? bs->irq : -ENODEV;
diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c
index 577d23a..8256317 100644
--- a/drivers/spi/spi-mpc512x-psc.c
+++ b/drivers/spi/spi-mpc512x-psc.c
@@ -571,6 +571,7 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *op)
 {
 	const u32 *regaddr_p;
 	u64 regaddr64, size64;
+	int irq;
 
 	regaddr_p = of_get_address(op->dev.of_node, 0, &size64, NULL);
 	if (!regaddr_p) {
@@ -579,8 +580,14 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *op)
 	}
 	regaddr64 = of_translate_address(op->dev.of_node, regaddr_p);
 
+	irq = devm_irq_of_parse_and_map(&op->dev, op->dev.of_node, 0);
+	if (irq <= 0) {
+		dev_err(&op->dev, "could not locate irq\n");
+		return irq ? irq : -EINVAL;
+	}
+
 	return mpc512x_psc_spi_do_probe(&op->dev, (u32) regaddr64, (u32) size64,
-				irq_of_parse_and_map(op->dev.of_node, 0));
+				irq);
 }
 
 static int mpc512x_psc_spi_of_remove(struct platform_device *op)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 939edf4..0baf00e 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1306,7 +1306,13 @@ static void of_register_spi_devices(struct spi_master *master)
 		spi->max_speed_hz = value;
 
 		/* IRQ */
-		spi->irq = irq_of_parse_and_map(nc, 0);
+		spi->irq = devm_irq_of_parse_and_map(&master->dev, nc, 0);
+		if (spi->irq < 0) {
+			dev_err(&master->dev, "could not locate irq for %s (%d)\n",
+					nc->full_name, spi->irq);
+			spi_dev_put(spi);
+			continue;
+		}
 
 		/* Store a pointer to the node in the device structure */
 		of_node_get(nc);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 19/21] exynos_tmu: use devm_irq_of_parse_and_map()
  2014-06-04 11:13 [PATCH 00/21] add and use devm_irq_of_parse_and_map() nyushchenko
                   ` (17 preceding siblings ...)
  2014-06-04 11:13 ` [PATCH 18/21] spi: use devm_irq_of_parse_and_map() where appropriate nyushchenko
@ 2014-06-04 11:13 ` nyushchenko
  2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
                   ` (2 subsequent siblings)
  21 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/thermal/samsung/exynos_tmu.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 0d96a51..eb1adb3 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -553,7 +553,7 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 	if (data->id < 0)
 		data->id = 0;
 
-	data->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
+	data->irq = devm_irq_of_parse_and_map(&pdev->dev, pdev->dev.of_node, 0);
 	if (data->irq <= 0) {
 		dev_err(&pdev->dev, "failed to get IRQ\n");
 		return -ENODEV;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 20/21] usb: use devm_irq_of_parse_and_map() where appropriate
@ 2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
  0 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/usb/gadget/gr_udc.c       |   17 +++++++++++------
 drivers/usb/host/ehci-grlib.c     |   11 ++++-------
 drivers/usb/host/ehci-orion.c     |    3 ++-
 drivers/usb/host/ehci-ppc-of.c    |   11 ++++-------
 drivers/usb/host/ehci-xilinx-of.c |    8 ++++----
 drivers/usb/host/ohci-ppc-of.c    |    7 ++-----
 6 files changed, 27 insertions(+), 30 deletions(-)

diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
index f984ee7..0a3e586 100644
--- a/drivers/usb/gadget/gr_udc.c
+++ b/drivers/usb/gadget/gr_udc.c
@@ -2108,19 +2108,24 @@ static int gr_probe(struct platform_device *ofdev)
 	if (IS_ERR(regs))
 		return PTR_ERR(regs);
 
-	dev->irq = irq_of_parse_and_map(dev->dev->of_node, 0);
-	if (!dev->irq) {
+	dev->irq = devm_irq_of_parse_and_map(dev->dev, dev->dev->of_node, 0);
+	if (dev->irq <= 0) {
 		dev_err(dev->dev, "No irq found\n");
 		return -ENODEV;
 	}
 
 	/* Some core configurations has separate irqs for IN and OUT events */
-	dev->irqi = irq_of_parse_and_map(dev->dev->of_node, 1);
+	dev->irqi = devm_irq_of_parse_and_map(dev->dev, dev->dev->of_node, 1);
+	if (dev->irqi < 0) {
+		dev_err(dev->dev, "could not locate irq\n");
+		return dev->irqi;
+	}
 	if (dev->irqi) {
-		dev->irqo = irq_of_parse_and_map(dev->dev->of_node, 2);
-		if (!dev->irqo) {
+		dev->irqo = devm_irq_of_parse_and_map(dev->dev,
+				dev->dev->of_node, 2);
+		if (dev->irqo <= 0) {
 			dev_err(dev->dev, "Found irqi but not irqo\n");
-			return -ENODEV;
+			return dev->irqo ? dev->irqo : -ENODEV;
 		}
 	}
 
diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c
index 495b6fb..666c03e 100644
--- a/drivers/usb/host/ehci-grlib.c
+++ b/drivers/usb/host/ehci-grlib.c
@@ -111,11 +111,11 @@ static int ehci_hcd_grlib_probe(struct platform_device *op)
 	hcd->rsrc_start = res.start;
 	hcd->rsrc_len = resource_size(&res);
 
-	irq = irq_of_parse_and_map(dn, 0);
-	if (irq == NO_IRQ) {
-		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
+	irq = devm_irq_of_parse_and_map(&op->dev, dn, 0);
+	if (irq <= 0) {
+		dev_err(&op->dev, "%s: devm_irq_of_parse_and_map failed\n",
 			__FILE__);
-		rv = -EBUSY;
+		rv = irq ? irq : -EINVAL;
 		goto err_irq;
 	}
 
@@ -145,7 +145,6 @@ static int ehci_hcd_grlib_probe(struct platform_device *op)
 	return 0;
 
 err_ioremap:
-	irq_dispose_mapping(irq);
 err_irq:
 	usb_put_hcd(hcd);
 
@@ -161,8 +160,6 @@ static int ehci_hcd_grlib_remove(struct platform_device *op)
 
 	usb_remove_hcd(hcd);
 
-	irq_dispose_mapping(hcd->irq);
-
 	usb_put_hcd(hcd);
 
 	return 0;
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 30d35e5..c88177b 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -155,7 +155,8 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
 	pr_debug("Initializing Orion-SoC USB Host Controller\n");
 
 	if (pdev->dev.of_node)
-		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);
 	else
 		irq = platform_get_irq(pdev, 0);
 	if (irq <= 0) {
diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c
index 5479247..cc64210 100644
--- a/drivers/usb/host/ehci-ppc-of.c
+++ b/drivers/usb/host/ehci-ppc-of.c
@@ -117,11 +117,11 @@ static int ehci_hcd_ppc_of_probe(struct platform_device *op)
 	hcd->rsrc_start = res.start;
 	hcd->rsrc_len = resource_size(&res);
 
-	irq = irq_of_parse_and_map(dn, 0);
-	if (irq == NO_IRQ) {
-		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
+	irq = devm_irq_of_parse_and_map(&op->dev, dn, 0);
+	if (irq <= 0) {
+		dev_err(&op->dev, "%s: devm_irq_of_parse_and_map failed\n",
 			__FILE__);
-		rv = -EBUSY;
+		rv = irq ? irq : -EINVAL;
 		goto err_irq;
 	}
 
@@ -174,7 +174,6 @@ static int ehci_hcd_ppc_of_probe(struct platform_device *op)
 	return 0;
 
 err_ioremap:
-	irq_dispose_mapping(irq);
 err_irq:
 	usb_put_hcd(hcd);
 
@@ -194,8 +193,6 @@ static int ehci_hcd_ppc_of_remove(struct platform_device *op)
 
 	usb_remove_hcd(hcd);
 
-	irq_dispose_mapping(hcd->irq);
-
 	/* use request_mem_region to test if the ohci driver is loaded.  if so
 	 * ensure the ohci core is operational.
 	 */
diff --git a/drivers/usb/host/ehci-xilinx-of.c b/drivers/usb/host/ehci-xilinx-of.c
index fe57710..6c6f8c7 100644
--- a/drivers/usb/host/ehci-xilinx-of.c
+++ b/drivers/usb/host/ehci-xilinx-of.c
@@ -153,11 +153,11 @@ static int ehci_hcd_xilinx_of_probe(struct platform_device *op)
 	hcd->rsrc_start = res.start;
 	hcd->rsrc_len = resource_size(&res);
 
-	irq = irq_of_parse_and_map(dn, 0);
-	if (!irq) {
-		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
+	irq = devm_irq_of_parse_and_map(&op->dev, dn, 0);
+	if (irq <= 0) {
+		dev_err(&op->dev, "%s: devm_irq_of_parse_and_map failed\n",
 			__FILE__);
-		rv = -EBUSY;
+		rv = irq ? irq : -EINVAL;
 		goto err_irq;
 	}
 
diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c
index 965e3e9..fcdd23a 100644
--- a/drivers/usb/host/ohci-ppc-of.c
+++ b/drivers/usb/host/ohci-ppc-of.c
@@ -121,11 +121,11 @@ static int ohci_hcd_ppc_of_probe(struct platform_device *op)
 		goto err_rmr;
 	}
 
-	irq = irq_of_parse_and_map(dn, 0);
+	irq = devm_irq_of_parse_and_map(*op->dev, dn, 0);
 	if (irq == NO_IRQ) {
 		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
 			__FILE__);
-		rv = -EBUSY;
+		rv = irq ? irq : -EINVAL;
 		goto err_rmr;
 	}
 
@@ -170,7 +170,6 @@ static int ohci_hcd_ppc_of_probe(struct platform_device *op)
 			pr_debug("%s: cannot get ehci offset from fdt\n", __FILE__);
 	}
 
-	irq_dispose_mapping(irq);
 err_rmr:
  	usb_put_hcd(hcd);
 
@@ -185,8 +184,6 @@ static int ohci_hcd_ppc_of_remove(struct platform_device *op)
 
 	usb_remove_hcd(hcd);
 
-	irq_dispose_mapping(hcd->irq);
-
 	usb_put_hcd(hcd);
 
 	return 0;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 20/21] usb: use devm_irq_of_parse_and_map() where appropriate
@ 2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
  0 siblings, 0 replies; 52+ messages in thread
From: nyushchenko-jFhMxQ4mL6a2X5qOxWx28w @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	lugovskoy-jFhMxQ4mL6a2X5qOxWx28w, Nikita Yushchenko

From: Nikita Yushchenko <nyushchenko-jFhMxQ4mL6a2X5qOxWx28w@public.gmane.org>

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.

Signed-off-by: Nikita Yushchenko <nyushchenko-jFhMxQ4mL6a2X5qOxWx28w@public.gmane.org>
---
 drivers/usb/gadget/gr_udc.c       |   17 +++++++++++------
 drivers/usb/host/ehci-grlib.c     |   11 ++++-------
 drivers/usb/host/ehci-orion.c     |    3 ++-
 drivers/usb/host/ehci-ppc-of.c    |   11 ++++-------
 drivers/usb/host/ehci-xilinx-of.c |    8 ++++----
 drivers/usb/host/ohci-ppc-of.c    |    7 ++-----
 6 files changed, 27 insertions(+), 30 deletions(-)

diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
index f984ee7..0a3e586 100644
--- a/drivers/usb/gadget/gr_udc.c
+++ b/drivers/usb/gadget/gr_udc.c
@@ -2108,19 +2108,24 @@ static int gr_probe(struct platform_device *ofdev)
 	if (IS_ERR(regs))
 		return PTR_ERR(regs);
 
-	dev->irq = irq_of_parse_and_map(dev->dev->of_node, 0);
-	if (!dev->irq) {
+	dev->irq = devm_irq_of_parse_and_map(dev->dev, dev->dev->of_node, 0);
+	if (dev->irq <= 0) {
 		dev_err(dev->dev, "No irq found\n");
 		return -ENODEV;
 	}
 
 	/* Some core configurations has separate irqs for IN and OUT events */
-	dev->irqi = irq_of_parse_and_map(dev->dev->of_node, 1);
+	dev->irqi = devm_irq_of_parse_and_map(dev->dev, dev->dev->of_node, 1);
+	if (dev->irqi < 0) {
+		dev_err(dev->dev, "could not locate irq\n");
+		return dev->irqi;
+	}
 	if (dev->irqi) {
-		dev->irqo = irq_of_parse_and_map(dev->dev->of_node, 2);
-		if (!dev->irqo) {
+		dev->irqo = devm_irq_of_parse_and_map(dev->dev,
+				dev->dev->of_node, 2);
+		if (dev->irqo <= 0) {
 			dev_err(dev->dev, "Found irqi but not irqo\n");
-			return -ENODEV;
+			return dev->irqo ? dev->irqo : -ENODEV;
 		}
 	}
 
diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c
index 495b6fb..666c03e 100644
--- a/drivers/usb/host/ehci-grlib.c
+++ b/drivers/usb/host/ehci-grlib.c
@@ -111,11 +111,11 @@ static int ehci_hcd_grlib_probe(struct platform_device *op)
 	hcd->rsrc_start = res.start;
 	hcd->rsrc_len = resource_size(&res);
 
-	irq = irq_of_parse_and_map(dn, 0);
-	if (irq == NO_IRQ) {
-		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
+	irq = devm_irq_of_parse_and_map(&op->dev, dn, 0);
+	if (irq <= 0) {
+		dev_err(&op->dev, "%s: devm_irq_of_parse_and_map failed\n",
 			__FILE__);
-		rv = -EBUSY;
+		rv = irq ? irq : -EINVAL;
 		goto err_irq;
 	}
 
@@ -145,7 +145,6 @@ static int ehci_hcd_grlib_probe(struct platform_device *op)
 	return 0;
 
 err_ioremap:
-	irq_dispose_mapping(irq);
 err_irq:
 	usb_put_hcd(hcd);
 
@@ -161,8 +160,6 @@ static int ehci_hcd_grlib_remove(struct platform_device *op)
 
 	usb_remove_hcd(hcd);
 
-	irq_dispose_mapping(hcd->irq);
-
 	usb_put_hcd(hcd);
 
 	return 0;
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 30d35e5..c88177b 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -155,7 +155,8 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
 	pr_debug("Initializing Orion-SoC USB Host Controller\n");
 
 	if (pdev->dev.of_node)
-		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);
 	else
 		irq = platform_get_irq(pdev, 0);
 	if (irq <= 0) {
diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c
index 5479247..cc64210 100644
--- a/drivers/usb/host/ehci-ppc-of.c
+++ b/drivers/usb/host/ehci-ppc-of.c
@@ -117,11 +117,11 @@ static int ehci_hcd_ppc_of_probe(struct platform_device *op)
 	hcd->rsrc_start = res.start;
 	hcd->rsrc_len = resource_size(&res);
 
-	irq = irq_of_parse_and_map(dn, 0);
-	if (irq == NO_IRQ) {
-		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
+	irq = devm_irq_of_parse_and_map(&op->dev, dn, 0);
+	if (irq <= 0) {
+		dev_err(&op->dev, "%s: devm_irq_of_parse_and_map failed\n",
 			__FILE__);
-		rv = -EBUSY;
+		rv = irq ? irq : -EINVAL;
 		goto err_irq;
 	}
 
@@ -174,7 +174,6 @@ static int ehci_hcd_ppc_of_probe(struct platform_device *op)
 	return 0;
 
 err_ioremap:
-	irq_dispose_mapping(irq);
 err_irq:
 	usb_put_hcd(hcd);
 
@@ -194,8 +193,6 @@ static int ehci_hcd_ppc_of_remove(struct platform_device *op)
 
 	usb_remove_hcd(hcd);
 
-	irq_dispose_mapping(hcd->irq);
-
 	/* use request_mem_region to test if the ohci driver is loaded.  if so
 	 * ensure the ohci core is operational.
 	 */
diff --git a/drivers/usb/host/ehci-xilinx-of.c b/drivers/usb/host/ehci-xilinx-of.c
index fe57710..6c6f8c7 100644
--- a/drivers/usb/host/ehci-xilinx-of.c
+++ b/drivers/usb/host/ehci-xilinx-of.c
@@ -153,11 +153,11 @@ static int ehci_hcd_xilinx_of_probe(struct platform_device *op)
 	hcd->rsrc_start = res.start;
 	hcd->rsrc_len = resource_size(&res);
 
-	irq = irq_of_parse_and_map(dn, 0);
-	if (!irq) {
-		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
+	irq = devm_irq_of_parse_and_map(&op->dev, dn, 0);
+	if (irq <= 0) {
+		dev_err(&op->dev, "%s: devm_irq_of_parse_and_map failed\n",
 			__FILE__);
-		rv = -EBUSY;
+		rv = irq ? irq : -EINVAL;
 		goto err_irq;
 	}
 
diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c
index 965e3e9..fcdd23a 100644
--- a/drivers/usb/host/ohci-ppc-of.c
+++ b/drivers/usb/host/ohci-ppc-of.c
@@ -121,11 +121,11 @@ static int ohci_hcd_ppc_of_probe(struct platform_device *op)
 		goto err_rmr;
 	}
 
-	irq = irq_of_parse_and_map(dn, 0);
+	irq = devm_irq_of_parse_and_map(*op->dev, dn, 0);
 	if (irq == NO_IRQ) {
 		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
 			__FILE__);
-		rv = -EBUSY;
+		rv = irq ? irq : -EINVAL;
 		goto err_rmr;
 	}
 
@@ -170,7 +170,6 @@ static int ohci_hcd_ppc_of_probe(struct platform_device *op)
 			pr_debug("%s: cannot get ehci offset from fdt\n", __FILE__);
 	}
 
-	irq_dispose_mapping(irq);
 err_rmr:
  	usb_put_hcd(hcd);
 
@@ -185,8 +184,6 @@ static int ohci_hcd_ppc_of_remove(struct platform_device *op)
 
 	usb_remove_hcd(hcd);
 
-	irq_dispose_mapping(hcd->irq);
-
 	usb_put_hcd(hcd);
 
 	return 0;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 21/21] at91sam9_wdt: use devm_irq_of_parse_and_map()
  2014-06-04 11:13 [PATCH 00/21] add and use devm_irq_of_parse_and_map() nyushchenko
                   ` (19 preceding siblings ...)
  2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
@ 2014-06-04 11:13 ` nyushchenko
  2014-06-12 10:03   ` Andreas Larsson
  21 siblings, 0 replies; 52+ messages in thread
From: nyushchenko @ 2014-06-04 11:13 UTC (permalink / raw)
  To: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, Nikita Yushchenko

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.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 drivers/watchdog/at91sam9_wdt.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
index 489729b..11ebe54 100644
--- a/drivers/watchdog/at91sam9_wdt.c
+++ b/drivers/watchdog/at91sam9_wdt.c
@@ -207,9 +207,9 @@ static int at91_wdt_init(struct platform_device *pdev, struct at91wdt *wdt)
 			 "min heartbeat and max heartbeat might be too close for the system to handle it correctly\n");
 
 	if ((tmp & AT91_WDT_WDFIEN) && wdt->irq) {
-		err = request_irq(wdt->irq, wdt_interrupt,
-				  IRQF_SHARED | IRQF_IRQPOLL,
-				  pdev->name, wdt);
+		err = devm_request_irq(dev, wdt->irq, wdt_interrupt,
+				       IRQF_SHARED | IRQF_IRQPOLL,
+				       pdev->name, wdt);
 		if (err)
 			return err;
 	}
@@ -270,9 +270,11 @@ static int of_at91wdt_init(struct device_node *np, struct at91wdt *wdt)
 	const char *tmp;
 
 	/* Get the interrupts property */
-	wdt->irq = irq_of_parse_and_map(np, 0);
-	if (!wdt->irq)
+	wdt->irq = devm_irq_of_parse_and_map(wdt->wdd.parent, np, 0);
+	if (wdt->irq <= 0) {
 		dev_warn(wdt->wdd.parent, "failed to get IRQ from DT\n");
+		wdt->irq = NO_IRQ;
+	}
 
 	if (!of_property_read_u32_index(np, "atmel,max-heartbeat-sec", 0,
 					&max)) {
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH 01/21] irq: add devres version of OF IRQ mapping routines
@ 2014-06-04 13:39     ` Thomas Gleixner
  0 siblings, 0 replies; 52+ messages in thread
From: Thomas Gleixner @ 2014-06-04 13:39 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: Grant Likely, Rob Herring, Benjamin Herrenschmidt, devicetree,
	linux-kernel, lugovskoy

On Wed, 4 Jun 2014, nyushchenko@dev.rtsoft.ru wrote:

> From: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
> 
> Many drivers use devres to manage their resources, and at the same time
> use irq_of_parse_and_map() / irq_dispose_mapping(). This creates problem
> on driver unload paths and on error paths:
> - it is invalid to call irq_dispose_mapping() while IRQ handler is still
>   installed,
> - devres moves removal of IRQ handler out of driver,
> - without explicit devres support for IRQ mapping, irq_dispose_mapping()
>   stays in driver and thus gets called while IRQ handler is still
>   installed.
> 
> This patch adds devm_irq_create_of_mapping() and devm_irq_of_parse_and_map()
> routines to be used by drivers for correct release of resources.
> 
> Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 01/21] irq: add devres version of OF IRQ mapping routines
@ 2014-06-04 13:39     ` Thomas Gleixner
  0 siblings, 0 replies; 52+ messages in thread
From: Thomas Gleixner @ 2014-06-04 13:39 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	lugovskoy-jFhMxQ4mL6a2X5qOxWx28w

On Wed, 4 Jun 2014, nyushchenko-jFhMxQ4mL6a2X5qOxWx28w@public.gmane.org wrote:

> From: Nikita Yushchenko <nyushchenko-jFhMxQ4mL6a2X5qOxWx28w@public.gmane.org>
> 
> Many drivers use devres to manage their resources, and at the same time
> use irq_of_parse_and_map() / irq_dispose_mapping(). This creates problem
> on driver unload paths and on error paths:
> - it is invalid to call irq_dispose_mapping() while IRQ handler is still
>   installed,
> - devres moves removal of IRQ handler out of driver,
> - without explicit devres support for IRQ mapping, irq_dispose_mapping()
>   stays in driver and thus gets called while IRQ handler is still
>   installed.
> 
> This patch adds devm_irq_create_of_mapping() and devm_irq_of_parse_and_map()
> routines to be used by drivers for correct release of resources.
> 
> Signed-off-by: Nikita Yushchenko <nyushchenko-jFhMxQ4mL6a2X5qOxWx28w@public.gmane.org>

Reviewed-by: Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 00/21] add and use devm_irq_of_parse_and_map()
  2014-06-04 11:13 [PATCH 00/21] add and use devm_irq_of_parse_and_map() nyushchenko
@ 2014-06-12 10:03   ` Andreas Larsson
  2014-06-04 11:13 ` [PATCH 02/21] ata: use devm_irq_of_parse_and_map() where appropriate nyushchenko
                     ` (20 subsequent siblings)
  21 siblings, 0 replies; 52+ messages in thread
From: Andreas Larsson @ 2014-06-12 10:03 UTC (permalink / raw)
  To: nyushchenko, Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, sparclinux, davem

On 2014-06-04 13:13, nyushchenko@dev.rtsoft.ru wrote:
> Currently many device tree aware drivers use irq_of_parse_and_map() to get
> IRQ number and then devm_request_irq() to set up IRQ handler.
>
> This causes a problem for exit path and for error paths: undo action for
> irq_of_parse_and_map() is irq_dispose_mapping() that must not be called
> while IRQ handler is defined, but devres moves free_irq() out of driver
> so driver does not have safe place to call irq_dispose_mapping().
>
> So many drivers do not call irq_dispose_mapping() at all, others call it
> while IRQ handler is defined (which is incorrect and causes error messages
> in logs), even others refuse to use devres for managing IRQ handlers.
>
> This patchset adds devres version of irq_of_parse_and_map(), and updates
> in-tree users of both devres and irq_of_parse_and_map() to use
> devm_irq_of_parse_and_map() instead.


SPARC does not use OF_IRQ and has a different implementation of 
irq_of_parse_and_map than the one in drivers/of/irq.c. All code 
converted from irq_of_parse_and_map to devm_irq_of_parse_and_map in this 
patch set will be unlinkable for SPARC. This includes SPI in general and 
many drivers that are used for SPARC (of which several are currently 
only used on SPARC platforms).

Best regards,
Andreas Larsson

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 00/21] add and use devm_irq_of_parse_and_map()
@ 2014-06-12 10:03   ` Andreas Larsson
  0 siblings, 0 replies; 52+ messages in thread
From: Andreas Larsson @ 2014-06-12 10:03 UTC (permalink / raw)
  To: nyushchenko, Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy, sparclinux, davem

On 2014-06-04 13:13, nyushchenko@dev.rtsoft.ru wrote:
> Currently many device tree aware drivers use irq_of_parse_and_map() to get
> IRQ number and then devm_request_irq() to set up IRQ handler.
>
> This causes a problem for exit path and for error paths: undo action for
> irq_of_parse_and_map() is irq_dispose_mapping() that must not be called
> while IRQ handler is defined, but devres moves free_irq() out of driver
> so driver does not have safe place to call irq_dispose_mapping().
>
> So many drivers do not call irq_dispose_mapping() at all, others call it
> while IRQ handler is defined (which is incorrect and causes error messages
> in logs), even others refuse to use devres for managing IRQ handlers.
>
> This patchset adds devres version of irq_of_parse_and_map(), and updates
> in-tree users of both devres and irq_of_parse_and_map() to use
> devm_irq_of_parse_and_map() instead.


SPARC does not use OF_IRQ and has a different implementation of 
irq_of_parse_and_map than the one in drivers/of/irq.c. All code 
converted from irq_of_parse_and_map to devm_irq_of_parse_and_map in this 
patch set will be unlinkable for SPARC. This includes SPI in general and 
many drivers that are used for SPARC (of which several are currently 
only used on SPARC platforms).

Best regards,
Andreas Larsson

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 00/21] add and use devm_irq_of_parse_and_map()
       [not found]   ` <5399AE1B.1080301@gaisler.com>
@ 2014-06-12 19:02       ` Nikita Yushchenko
  0 siblings, 0 replies; 52+ messages in thread
From: Nikita Yushchenko @ 2014-06-12 19:02 UTC (permalink / raw)
  To: Andreas Larsson
  Cc: lugovskoy, Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree, linux-kernel, sparclinux, davem

>> Currently many device tree aware drivers use irq_of_parse_and_map() to
>> get
>> IRQ number and then devm_request_irq() to set up IRQ handler.
>>
>> This causes a problem for exit path and for error paths: undo action for
>> irq_of_parse_and_map() is irq_dispose_mapping() that must not be called
>> while IRQ handler is defined, but devres moves free_irq() out of driver
>> so driver does not have safe place to call irq_dispose_mapping().
>>
>> So many drivers do not call irq_dispose_mapping() at all, others call it
>> while IRQ handler is defined (which is incorrect and causes error
>> messages
>> in logs), even others refuse to use devres for managing IRQ handlers.
>>
>> This patchset adds devres version of irq_of_parse_and_map(), and updates
>> in-tree users of both devres and irq_of_parse_and_map() to use
>> devm_irq_of_parse_and_map() instead.
> 
> 
> SPARC does not use OF_IRQ and has a different implementation of
> irq_of_parse_and_map than the one in drivers/of/irq.c. All code
> converted from irq_of_parse_and_map to devm_irq_of_parse_and_map in this
> patch set will be unlinkable for SPARC. This includes SPI in general and
> many drivers that are used for SPARC (of which several are currently
> only used on SPARC platforms).

Can this be fixed by adding a copy of devm_irq_of_parse_and_map() to
arch/sparc/kernel/of_device_common.c ?

Or there are some deep reasons why irq_of_parse_and_map() can't be
devm'd for sparc at all?

Nikita


^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 00/21] add and use devm_irq_of_parse_and_map()
@ 2014-06-12 19:02       ` Nikita Yushchenko
  0 siblings, 0 replies; 52+ messages in thread
From: Nikita Yushchenko @ 2014-06-12 19:02 UTC (permalink / raw)
  To: Andreas Larsson
  Cc: lugovskoy, Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree, linux-kernel, sparclinux, davem

>> Currently many device tree aware drivers use irq_of_parse_and_map() to
>> get
>> IRQ number and then devm_request_irq() to set up IRQ handler.
>>
>> This causes a problem for exit path and for error paths: undo action for
>> irq_of_parse_and_map() is irq_dispose_mapping() that must not be called
>> while IRQ handler is defined, but devres moves free_irq() out of driver
>> so driver does not have safe place to call irq_dispose_mapping().
>>
>> So many drivers do not call irq_dispose_mapping() at all, others call it
>> while IRQ handler is defined (which is incorrect and causes error
>> messages
>> in logs), even others refuse to use devres for managing IRQ handlers.
>>
>> This patchset adds devres version of irq_of_parse_and_map(), and updates
>> in-tree users of both devres and irq_of_parse_and_map() to use
>> devm_irq_of_parse_and_map() instead.
> 
> 
> SPARC does not use OF_IRQ and has a different implementation of
> irq_of_parse_and_map than the one in drivers/of/irq.c. All code
> converted from irq_of_parse_and_map to devm_irq_of_parse_and_map in this
> patch set will be unlinkable for SPARC. This includes SPI in general and
> many drivers that are used for SPARC (of which several are currently
> only used on SPARC platforms).

Can this be fixed by adding a copy of devm_irq_of_parse_and_map() to
arch/sparc/kernel/of_device_common.c ?

Or there are some deep reasons why irq_of_parse_and_map() can't be
devm'd for sparc at all?

Nikita


^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 00/21] add and use devm_irq_of_parse_and_map()
  2014-06-12 19:02       ` Nikita Yushchenko
@ 2014-06-16  8:23         ` Andreas Larsson
  -1 siblings, 0 replies; 52+ messages in thread
From: Andreas Larsson @ 2014-06-16  8:23 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: lugovskoy, Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree, linux-kernel, sparclinux, davem

On 2014-06-12 21:02, Nikita Yushchenko wrote:
>>> Currently many device tree aware drivers use irq_of_parse_and_map() to
>>> get
>>> IRQ number and then devm_request_irq() to set up IRQ handler.
>>>
>>> This causes a problem for exit path and for error paths: undo action for
>>> irq_of_parse_and_map() is irq_dispose_mapping() that must not be called
>>> while IRQ handler is defined, but devres moves free_irq() out of driver
>>> so driver does not have safe place to call irq_dispose_mapping().
>>>
>>> So many drivers do not call irq_dispose_mapping() at all, others call it
>>> while IRQ handler is defined (which is incorrect and causes error
>>> messages
>>> in logs), even others refuse to use devres for managing IRQ handlers.
>>>
>>> This patchset adds devres version of irq_of_parse_and_map(), and updates
>>> in-tree users of both devres and irq_of_parse_and_map() to use
>>> devm_irq_of_parse_and_map() instead.
>>
>>
>> SPARC does not use OF_IRQ and has a different implementation of
>> irq_of_parse_and_map than the one in drivers/of/irq.c. All code
>> converted from irq_of_parse_and_map to devm_irq_of_parse_and_map in this
>> patch set will be unlinkable for SPARC. This includes SPI in general and
>> many drivers that are used for SPARC (of which several are currently
>> only used on SPARC platforms).
>
> Can this be fixed by adding a copy of devm_irq_of_parse_and_map() to
> arch/sparc/kernel/of_device_common.c ?

Not a copy of the version in irq.c no. On SPARC, IRQ_DOMAIN is not 
selected in general.

However, there is no technical problem that I can see with having a 
SPARC version of devm_irq_of_parse_and_map that just calls 
irq_of_parse_and_map as there are no mappings that needs to be disposed 
of. (The empty dummy for irq_dispose_mapping is used if any 
irq_dispose_mapping calls are made from drivers).

Best regards,
Andreas Larsson

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 00/21] add and use devm_irq_of_parse_and_map()
@ 2014-06-16  8:23         ` Andreas Larsson
  0 siblings, 0 replies; 52+ messages in thread
From: Andreas Larsson @ 2014-06-16  8:23 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: lugovskoy, Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree, linux-kernel, sparclinux, davem

On 2014-06-12 21:02, Nikita Yushchenko wrote:
>>> Currently many device tree aware drivers use irq_of_parse_and_map() to
>>> get
>>> IRQ number and then devm_request_irq() to set up IRQ handler.
>>>
>>> This causes a problem for exit path and for error paths: undo action for
>>> irq_of_parse_and_map() is irq_dispose_mapping() that must not be called
>>> while IRQ handler is defined, but devres moves free_irq() out of driver
>>> so driver does not have safe place to call irq_dispose_mapping().
>>>
>>> So many drivers do not call irq_dispose_mapping() at all, others call it
>>> while IRQ handler is defined (which is incorrect and causes error
>>> messages
>>> in logs), even others refuse to use devres for managing IRQ handlers.
>>>
>>> This patchset adds devres version of irq_of_parse_and_map(), and updates
>>> in-tree users of both devres and irq_of_parse_and_map() to use
>>> devm_irq_of_parse_and_map() instead.
>>
>>
>> SPARC does not use OF_IRQ and has a different implementation of
>> irq_of_parse_and_map than the one in drivers/of/irq.c. All code
>> converted from irq_of_parse_and_map to devm_irq_of_parse_and_map in this
>> patch set will be unlinkable for SPARC. This includes SPI in general and
>> many drivers that are used for SPARC (of which several are currently
>> only used on SPARC platforms).
>
> Can this be fixed by adding a copy of devm_irq_of_parse_and_map() to
> arch/sparc/kernel/of_device_common.c ?

Not a copy of the version in irq.c no. On SPARC, IRQ_DOMAIN is not 
selected in general.

However, there is no technical problem that I can see with having a 
SPARC version of devm_irq_of_parse_and_map that just calls 
irq_of_parse_and_map as there are no mappings that needs to be disposed 
of. (The empty dummy for irq_dispose_mapping is used if any 
irq_dispose_mapping calls are made from drivers).

Best regards,
Andreas Larsson

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 00/21] add and use devm_irq_of_parse_and_map()
@ 2014-06-16  8:36           ` Nikita Yushchenko
  0 siblings, 0 replies; 52+ messages in thread
From: Nikita Yushchenko @ 2014-06-16  8:36 UTC (permalink / raw)
  To: Andreas Larsson
  Cc: lugovskoy, Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree, linux-kernel, sparclinux, davem

>>> SPARC does not use OF_IRQ and has a different implementation of
>>> irq_of_parse_and_map than the one in drivers/of/irq.c. All code
>>> converted from irq_of_parse_and_map to devm_irq_of_parse_and_map in this
>>> patch set will be unlinkable for SPARC. This includes SPI in general and
>>> many drivers that are used for SPARC (of which several are currently
>>> only used on SPARC platforms).
>>
>> Can this be fixed by adding a copy of devm_irq_of_parse_and_map() to
>> arch/sparc/kernel/of_device_common.c ?
> 
> Not a copy of the version in irq.c no. On SPARC, IRQ_DOMAIN is not
> selected in general.
> 
> However, there is no technical problem that I can see with having a
> SPARC version of devm_irq_of_parse_and_map that just calls
> irq_of_parse_and_map as there are no mappings that needs to be disposed
> of. (The empty dummy for irq_dispose_mapping is used if any
> irq_dispose_mapping calls are made from drivers).

Ok, I will post an updated patchset that adds sparc
devm_irq_of_parse_and_map() that just calls irq_of_parse_and_map(), and
devm_irq_dispose_mapping() that does nothing.

Also, you mentioned that some drivers that my original patchset touches
are sparc-only?  Then, maybe better not convert these to devm_? Could
you please give a list of such drivers?

Nikita


^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 00/21] add and use devm_irq_of_parse_and_map()
@ 2014-06-16  8:36           ` Nikita Yushchenko
  0 siblings, 0 replies; 52+ messages in thread
From: Nikita Yushchenko @ 2014-06-16  8:36 UTC (permalink / raw)
  To: Andreas Larsson
  Cc: lugovskoy-jFhMxQ4mL6a2X5qOxWx28w, Grant Likely, Rob Herring,
	Benjamin Herrenschmidt, Thomas Gleixner,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	sparclinux-u79uwXL29TY76Z2rM5mHXA, davem-fT/PcQaiUtIeIZ0/mPfg9Q

>>> SPARC does not use OF_IRQ and has a different implementation of
>>> irq_of_parse_and_map than the one in drivers/of/irq.c. All code
>>> converted from irq_of_parse_and_map to devm_irq_of_parse_and_map in this
>>> patch set will be unlinkable for SPARC. This includes SPI in general and
>>> many drivers that are used for SPARC (of which several are currently
>>> only used on SPARC platforms).
>>
>> Can this be fixed by adding a copy of devm_irq_of_parse_and_map() to
>> arch/sparc/kernel/of_device_common.c ?
> 
> Not a copy of the version in irq.c no. On SPARC, IRQ_DOMAIN is not
> selected in general.
> 
> However, there is no technical problem that I can see with having a
> SPARC version of devm_irq_of_parse_and_map that just calls
> irq_of_parse_and_map as there are no mappings that needs to be disposed
> of. (The empty dummy for irq_dispose_mapping is used if any
> irq_dispose_mapping calls are made from drivers).

Ok, I will post an updated patchset that adds sparc
devm_irq_of_parse_and_map() that just calls irq_of_parse_and_map(), and
devm_irq_dispose_mapping() that does nothing.

Also, you mentioned that some drivers that my original patchset touches
are sparc-only?  Then, maybe better not convert these to devm_? Could
you please give a list of such drivers?

Nikita

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 00/21] add and use devm_irq_of_parse_and_map()
@ 2014-06-16  8:36           ` Nikita Yushchenko
  0 siblings, 0 replies; 52+ messages in thread
From: Nikita Yushchenko @ 2014-06-16  8:36 UTC (permalink / raw)
  To: Andreas Larsson
  Cc: lugovskoy-jFhMxQ4mL6a2X5qOxWx28w, Grant Likely, Rob Herring,
	Benjamin Herrenschmidt, Thomas Gleixner,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	sparclinux-u79uwXL29TY76Z2rM5mHXA, davem-fT/PcQaiUtIeIZ0/mPfg9Q

>>> SPARC does not use OF_IRQ and has a different implementation of
>>> irq_of_parse_and_map than the one in drivers/of/irq.c. All code
>>> converted from irq_of_parse_and_map to devm_irq_of_parse_and_map in this
>>> patch set will be unlinkable for SPARC. This includes SPI in general and
>>> many drivers that are used for SPARC (of which several are currently
>>> only used on SPARC platforms).
>>
>> Can this be fixed by adding a copy of devm_irq_of_parse_and_map() to
>> arch/sparc/kernel/of_device_common.c ?
> 
> Not a copy of the version in irq.c no. On SPARC, IRQ_DOMAIN is not
> selected in general.
> 
> However, there is no technical problem that I can see with having a
> SPARC version of devm_irq_of_parse_and_map that just calls
> irq_of_parse_and_map as there are no mappings that needs to be disposed
> of. (The empty dummy for irq_dispose_mapping is used if any
> irq_dispose_mapping calls are made from drivers).

Ok, I will post an updated patchset that adds sparc
devm_irq_of_parse_and_map() that just calls irq_of_parse_and_map(), and
devm_irq_dispose_mapping() that does nothing.

Also, you mentioned that some drivers that my original patchset touches
are sparc-only?  Then, maybe better not convert these to devm_? Could
you please give a list of such drivers?

Nikita


^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 00/21] add and use devm_irq_of_parse_and_map()
  2014-06-16  8:36           ` Nikita Yushchenko
@ 2014-06-16  9:29             ` Andreas Larsson
  -1 siblings, 0 replies; 52+ messages in thread
From: Andreas Larsson @ 2014-06-16  9:29 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: lugovskoy, Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree, linux-kernel, sparclinux, davem

On 2014-06-16 10:36, Nikita Yushchenko wrote:
>>>> SPARC does not use OF_IRQ and has a different implementation of
>>>> irq_of_parse_and_map than the one in drivers/of/irq.c. All code
>>>> converted from irq_of_parse_and_map to devm_irq_of_parse_and_map in this
>>>> patch set will be unlinkable for SPARC. This includes SPI in general and
>>>> many drivers that are used for SPARC (of which several are currently
>>>> only used on SPARC platforms).
>>>
>>> Can this be fixed by adding a copy of devm_irq_of_parse_and_map() to
>>> arch/sparc/kernel/of_device_common.c ?
>>
>> Not a copy of the version in irq.c no. On SPARC, IRQ_DOMAIN is not
>> selected in general.
>>
>> However, there is no technical problem that I can see with having a
>> SPARC version of devm_irq_of_parse_and_map that just calls
>> irq_of_parse_and_map as there are no mappings that needs to be disposed
>> of. (The empty dummy for irq_dispose_mapping is used if any
>> irq_dispose_mapping calls are made from drivers).
>
> Ok, I will post an updated patchset that adds sparc
> devm_irq_of_parse_and_map() that just calls irq_of_parse_and_map(), and
> devm_irq_dispose_mapping() that does nothing.

You have already added the needed empty devm_irq_dispose_mapping in 
include/linux/irqdomain.h.

Note that the IRQ_DOMAIN *can* be used under SPARC (GPIO_GRGPIO is one 
example that selects it), but it is not used at the top level so to 
speak. There should not be a SPARC specific empty version of 
devm_irq_dispose_mapping - CONF_IRQ_DOMAIN or not takes care of that.


> Also, you mentioned that some drivers that my original patchset touches
> are sparc-only?  Then, maybe better not convert these to devm_? Could
> you please give a list of such drivers?

The drivers that I know of off hand is not necessarily SPARC only. Some 
are currently only found in SPARC environments, but that could change in 
the future. I personally don't see a problem with using 
devm_of_parse_and_map solution as long as there is a SPARC-specific one 
as discussed above.

Best regards,
Andreas Larsson

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 00/21] add and use devm_irq_of_parse_and_map()
@ 2014-06-16  9:29             ` Andreas Larsson
  0 siblings, 0 replies; 52+ messages in thread
From: Andreas Larsson @ 2014-06-16  9:29 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: lugovskoy, Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree, linux-kernel, sparclinux, davem

On 2014-06-16 10:36, Nikita Yushchenko wrote:
>>>> SPARC does not use OF_IRQ and has a different implementation of
>>>> irq_of_parse_and_map than the one in drivers/of/irq.c. All code
>>>> converted from irq_of_parse_and_map to devm_irq_of_parse_and_map in this
>>>> patch set will be unlinkable for SPARC. This includes SPI in general and
>>>> many drivers that are used for SPARC (of which several are currently
>>>> only used on SPARC platforms).
>>>
>>> Can this be fixed by adding a copy of devm_irq_of_parse_and_map() to
>>> arch/sparc/kernel/of_device_common.c ?
>>
>> Not a copy of the version in irq.c no. On SPARC, IRQ_DOMAIN is not
>> selected in general.
>>
>> However, there is no technical problem that I can see with having a
>> SPARC version of devm_irq_of_parse_and_map that just calls
>> irq_of_parse_and_map as there are no mappings that needs to be disposed
>> of. (The empty dummy for irq_dispose_mapping is used if any
>> irq_dispose_mapping calls are made from drivers).
>
> Ok, I will post an updated patchset that adds sparc
> devm_irq_of_parse_and_map() that just calls irq_of_parse_and_map(), and
> devm_irq_dispose_mapping() that does nothing.

You have already added the needed empty devm_irq_dispose_mapping in 
include/linux/irqdomain.h.

Note that the IRQ_DOMAIN *can* be used under SPARC (GPIO_GRGPIO is one 
example that selects it), but it is not used at the top level so to 
speak. There should not be a SPARC specific empty version of 
devm_irq_dispose_mapping - CONF_IRQ_DOMAIN or not takes care of that.


> Also, you mentioned that some drivers that my original patchset touches
> are sparc-only?  Then, maybe better not convert these to devm_? Could
> you please give a list of such drivers?

The drivers that I know of off hand is not necessarily SPARC only. Some 
are currently only found in SPARC environments, but that could change in 
the future. I personally don't see a problem with using 
devm_of_parse_and_map solution as long as there is a SPARC-specific one 
as discussed above.

Best regards,
Andreas Larsson

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 20/21] usb: use devm_irq_of_parse_and_map() where appropriate
@ 2014-06-16  9:35     ` Andreas Larsson
  0 siblings, 0 replies; 52+ messages in thread
From: Andreas Larsson @ 2014-06-16  9:35 UTC (permalink / raw)
  To: nyushchenko, Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy

On 2014-06-04 13:13, nyushchenko@dev.rtsoft.ru wrote:
> 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.
>
> Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
> ---
>   drivers/usb/gadget/gr_udc.c       |   17 +++++++++++------
>   drivers/usb/host/ehci-grlib.c     |   11 ++++-------
>   drivers/usb/host/ehci-orion.c     |    3 ++-
>   drivers/usb/host/ehci-ppc-of.c    |   11 ++++-------
>   drivers/usb/host/ehci-xilinx-of.c |    8 ++++----
>   drivers/usb/host/ohci-ppc-of.c    |    7 ++-----
>   6 files changed, 27 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
> index f984ee7..0a3e586 100644
> --- a/drivers/usb/gadget/gr_udc.c
> +++ b/drivers/usb/gadget/gr_udc.c
> @@ -2108,19 +2108,24 @@ static int gr_probe(struct platform_device *ofdev)
>   	if (IS_ERR(regs))
>   		return PTR_ERR(regs);
>
> -	dev->irq = irq_of_parse_and_map(dev->dev->of_node, 0);
> -	if (!dev->irq) {
> +	dev->irq = devm_irq_of_parse_and_map(dev->dev, dev->dev->of_node, 0);
> +	if (dev->irq <= 0) {
>   		dev_err(dev->dev, "No irq found\n");
>   		return -ENODEV;
>   	}
>
>   	/* Some core configurations has separate irqs for IN and OUT events */
> -	dev->irqi = irq_of_parse_and_map(dev->dev->of_node, 1);
> +	dev->irqi = devm_irq_of_parse_and_map(dev->dev, dev->dev->of_node, 1);
> +	if (dev->irqi < 0) {
> +		dev_err(dev->dev, "could not locate irq\n");
> +		return dev->irqi;
> +	}
>   	if (dev->irqi) {
> -		dev->irqo = irq_of_parse_and_map(dev->dev->of_node, 2);
> -		if (!dev->irqo) {
> +		dev->irqo = devm_irq_of_parse_and_map(dev->dev,
> +				dev->dev->of_node, 2);
> +		if (dev->irqo <= 0) {
>   			dev_err(dev->dev, "Found irqi but not irqo\n");
> -			return -ENODEV;
> +			return dev->irqo ? dev->irqo : -ENODEV;
>   		}
>   	}
>
> diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c
> index 495b6fb..666c03e 100644
> --- a/drivers/usb/host/ehci-grlib.c
> +++ b/drivers/usb/host/ehci-grlib.c
> @@ -111,11 +111,11 @@ static int ehci_hcd_grlib_probe(struct platform_device *op)
>   	hcd->rsrc_start = res.start;
>   	hcd->rsrc_len = resource_size(&res);
>
> -	irq = irq_of_parse_and_map(dn, 0);
> -	if (irq == NO_IRQ) {
> -		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
> +	irq = devm_irq_of_parse_and_map(&op->dev, dn, 0);
> +	if (irq <= 0) {
> +		dev_err(&op->dev, "%s: devm_irq_of_parse_and_map failed\n",
>   			__FILE__);
> -		rv = -EBUSY;
> +		rv = irq ? irq : -EINVAL;

Here and in more places below you change the return value from -EBUSY to 
-EINVAL when irq == 0. These changes and the reason for them is not 
something that is commented upon in the commit message. Maybe these 
changes were not intended or should be in a separate patch?

>   		goto err_irq;
>   	}
>
> @@ -145,7 +145,6 @@ static int ehci_hcd_grlib_probe(struct platform_device *op)
>   	return 0;
>
>   err_ioremap:
> -	irq_dispose_mapping(irq);
>   err_irq:
>   	usb_put_hcd(hcd);
>
> @@ -161,8 +160,6 @@ static int ehci_hcd_grlib_remove(struct platform_device *op)
>
>   	usb_remove_hcd(hcd);
>
> -	irq_dispose_mapping(hcd->irq);
> -
>   	usb_put_hcd(hcd);
>
>   	return 0;
> diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
> index 30d35e5..c88177b 100644
> --- a/drivers/usb/host/ehci-orion.c
> +++ b/drivers/usb/host/ehci-orion.c
> @@ -155,7 +155,8 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
>   	pr_debug("Initializing Orion-SoC USB Host Controller\n");
>
>   	if (pdev->dev.of_node)
> -		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);
>   	else
>   		irq = platform_get_irq(pdev, 0);
>   	if (irq <= 0) {
> diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c
> index 5479247..cc64210 100644
> --- a/drivers/usb/host/ehci-ppc-of.c
> +++ b/drivers/usb/host/ehci-ppc-of.c
> @@ -117,11 +117,11 @@ static int ehci_hcd_ppc_of_probe(struct platform_device *op)
>   	hcd->rsrc_start = res.start;
>   	hcd->rsrc_len = resource_size(&res);
>
> -	irq = irq_of_parse_and_map(dn, 0);
> -	if (irq == NO_IRQ) {
> -		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
> +	irq = devm_irq_of_parse_and_map(&op->dev, dn, 0);
> +	if (irq <= 0) {
> +		dev_err(&op->dev, "%s: devm_irq_of_parse_and_map failed\n",
>   			__FILE__);
> -		rv = -EBUSY;
> +		rv = irq ? irq : -EINVAL;
>   		goto err_irq;
>   	}
>
> @@ -174,7 +174,6 @@ static int ehci_hcd_ppc_of_probe(struct platform_device *op)
>   	return 0;
>
>   err_ioremap:
> -	irq_dispose_mapping(irq);
>   err_irq:
>   	usb_put_hcd(hcd);
>
> @@ -194,8 +193,6 @@ static int ehci_hcd_ppc_of_remove(struct platform_device *op)
>
>   	usb_remove_hcd(hcd);
>
> -	irq_dispose_mapping(hcd->irq);
> -
>   	/* use request_mem_region to test if the ohci driver is loaded.  if so
>   	 * ensure the ohci core is operational.
>   	 */
> diff --git a/drivers/usb/host/ehci-xilinx-of.c b/drivers/usb/host/ehci-xilinx-of.c
> index fe57710..6c6f8c7 100644
> --- a/drivers/usb/host/ehci-xilinx-of.c
> +++ b/drivers/usb/host/ehci-xilinx-of.c
> @@ -153,11 +153,11 @@ static int ehci_hcd_xilinx_of_probe(struct platform_device *op)
>   	hcd->rsrc_start = res.start;
>   	hcd->rsrc_len = resource_size(&res);
>
> -	irq = irq_of_parse_and_map(dn, 0);
> -	if (!irq) {
> -		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
> +	irq = devm_irq_of_parse_and_map(&op->dev, dn, 0);
> +	if (irq <= 0) {
> +		dev_err(&op->dev, "%s: devm_irq_of_parse_and_map failed\n",
>   			__FILE__);
> -		rv = -EBUSY;
> +		rv = irq ? irq : -EINVAL;
>   		goto err_irq;
>   	}
>
> diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c
> index 965e3e9..fcdd23a 100644
> --- a/drivers/usb/host/ohci-ppc-of.c
> +++ b/drivers/usb/host/ohci-ppc-of.c
> @@ -121,11 +121,11 @@ static int ohci_hcd_ppc_of_probe(struct platform_device *op)
>   		goto err_rmr;
>   	}
>
> -	irq = irq_of_parse_and_map(dn, 0);
> +	irq = devm_irq_of_parse_and_map(*op->dev, dn, 0);
>   	if (irq == NO_IRQ) {
>   		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
>   			__FILE__);
> -		rv = -EBUSY;
> +		rv = irq ? irq : -EINVAL;
>   		goto err_rmr;
>   	}
>
> @@ -170,7 +170,6 @@ static int ohci_hcd_ppc_of_probe(struct platform_device *op)
>   			pr_debug("%s: cannot get ehci offset from fdt\n", __FILE__);
>   	}
>
> -	irq_dispose_mapping(irq);
>   err_rmr:
>    	usb_put_hcd(hcd);
>
> @@ -185,8 +184,6 @@ static int ohci_hcd_ppc_of_remove(struct platform_device *op)
>
>   	usb_remove_hcd(hcd);
>
> -	irq_dispose_mapping(hcd->irq);
> -
>   	usb_put_hcd(hcd);
>
>   	return 0;
>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 20/21] usb: use devm_irq_of_parse_and_map() where appropriate
@ 2014-06-16  9:35     ` Andreas Larsson
  0 siblings, 0 replies; 52+ messages in thread
From: Andreas Larsson @ 2014-06-16  9:35 UTC (permalink / raw)
  To: nyushchenko-jFhMxQ4mL6a2X5qOxWx28w, Grant Likely, Rob Herring,
	Benjamin Herrenschmidt, Thomas Gleixner,
	devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, lugovskoy-jFhMxQ4mL6a2X5qOxWx28w

On 2014-06-04 13:13, nyushchenko-jFhMxQ4mL6a2X5qOxWx28w@public.gmane.org wrote:
> From: Nikita Yushchenko <nyushchenko-jFhMxQ4mL6a2X5qOxWx28w@public.gmane.org>
>
> 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.
>
> Signed-off-by: Nikita Yushchenko <nyushchenko-jFhMxQ4mL6a2X5qOxWx28w@public.gmane.org>
> ---
>   drivers/usb/gadget/gr_udc.c       |   17 +++++++++++------
>   drivers/usb/host/ehci-grlib.c     |   11 ++++-------
>   drivers/usb/host/ehci-orion.c     |    3 ++-
>   drivers/usb/host/ehci-ppc-of.c    |   11 ++++-------
>   drivers/usb/host/ehci-xilinx-of.c |    8 ++++----
>   drivers/usb/host/ohci-ppc-of.c    |    7 ++-----
>   6 files changed, 27 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
> index f984ee7..0a3e586 100644
> --- a/drivers/usb/gadget/gr_udc.c
> +++ b/drivers/usb/gadget/gr_udc.c
> @@ -2108,19 +2108,24 @@ static int gr_probe(struct platform_device *ofdev)
>   	if (IS_ERR(regs))
>   		return PTR_ERR(regs);
>
> -	dev->irq = irq_of_parse_and_map(dev->dev->of_node, 0);
> -	if (!dev->irq) {
> +	dev->irq = devm_irq_of_parse_and_map(dev->dev, dev->dev->of_node, 0);
> +	if (dev->irq <= 0) {
>   		dev_err(dev->dev, "No irq found\n");
>   		return -ENODEV;
>   	}
>
>   	/* Some core configurations has separate irqs for IN and OUT events */
> -	dev->irqi = irq_of_parse_and_map(dev->dev->of_node, 1);
> +	dev->irqi = devm_irq_of_parse_and_map(dev->dev, dev->dev->of_node, 1);
> +	if (dev->irqi < 0) {
> +		dev_err(dev->dev, "could not locate irq\n");
> +		return dev->irqi;
> +	}
>   	if (dev->irqi) {
> -		dev->irqo = irq_of_parse_and_map(dev->dev->of_node, 2);
> -		if (!dev->irqo) {
> +		dev->irqo = devm_irq_of_parse_and_map(dev->dev,
> +				dev->dev->of_node, 2);
> +		if (dev->irqo <= 0) {
>   			dev_err(dev->dev, "Found irqi but not irqo\n");
> -			return -ENODEV;
> +			return dev->irqo ? dev->irqo : -ENODEV;
>   		}
>   	}
>
> diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c
> index 495b6fb..666c03e 100644
> --- a/drivers/usb/host/ehci-grlib.c
> +++ b/drivers/usb/host/ehci-grlib.c
> @@ -111,11 +111,11 @@ static int ehci_hcd_grlib_probe(struct platform_device *op)
>   	hcd->rsrc_start = res.start;
>   	hcd->rsrc_len = resource_size(&res);
>
> -	irq = irq_of_parse_and_map(dn, 0);
> -	if (irq == NO_IRQ) {
> -		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
> +	irq = devm_irq_of_parse_and_map(&op->dev, dn, 0);
> +	if (irq <= 0) {
> +		dev_err(&op->dev, "%s: devm_irq_of_parse_and_map failed\n",
>   			__FILE__);
> -		rv = -EBUSY;
> +		rv = irq ? irq : -EINVAL;

Here and in more places below you change the return value from -EBUSY to 
-EINVAL when irq == 0. These changes and the reason for them is not 
something that is commented upon in the commit message. Maybe these 
changes were not intended or should be in a separate patch?

>   		goto err_irq;
>   	}
>
> @@ -145,7 +145,6 @@ static int ehci_hcd_grlib_probe(struct platform_device *op)
>   	return 0;
>
>   err_ioremap:
> -	irq_dispose_mapping(irq);
>   err_irq:
>   	usb_put_hcd(hcd);
>
> @@ -161,8 +160,6 @@ static int ehci_hcd_grlib_remove(struct platform_device *op)
>
>   	usb_remove_hcd(hcd);
>
> -	irq_dispose_mapping(hcd->irq);
> -
>   	usb_put_hcd(hcd);
>
>   	return 0;
> diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
> index 30d35e5..c88177b 100644
> --- a/drivers/usb/host/ehci-orion.c
> +++ b/drivers/usb/host/ehci-orion.c
> @@ -155,7 +155,8 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
>   	pr_debug("Initializing Orion-SoC USB Host Controller\n");
>
>   	if (pdev->dev.of_node)
> -		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);
>   	else
>   		irq = platform_get_irq(pdev, 0);
>   	if (irq <= 0) {
> diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c
> index 5479247..cc64210 100644
> --- a/drivers/usb/host/ehci-ppc-of.c
> +++ b/drivers/usb/host/ehci-ppc-of.c
> @@ -117,11 +117,11 @@ static int ehci_hcd_ppc_of_probe(struct platform_device *op)
>   	hcd->rsrc_start = res.start;
>   	hcd->rsrc_len = resource_size(&res);
>
> -	irq = irq_of_parse_and_map(dn, 0);
> -	if (irq == NO_IRQ) {
> -		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
> +	irq = devm_irq_of_parse_and_map(&op->dev, dn, 0);
> +	if (irq <= 0) {
> +		dev_err(&op->dev, "%s: devm_irq_of_parse_and_map failed\n",
>   			__FILE__);
> -		rv = -EBUSY;
> +		rv = irq ? irq : -EINVAL;
>   		goto err_irq;
>   	}
>
> @@ -174,7 +174,6 @@ static int ehci_hcd_ppc_of_probe(struct platform_device *op)
>   	return 0;
>
>   err_ioremap:
> -	irq_dispose_mapping(irq);
>   err_irq:
>   	usb_put_hcd(hcd);
>
> @@ -194,8 +193,6 @@ static int ehci_hcd_ppc_of_remove(struct platform_device *op)
>
>   	usb_remove_hcd(hcd);
>
> -	irq_dispose_mapping(hcd->irq);
> -
>   	/* use request_mem_region to test if the ohci driver is loaded.  if so
>   	 * ensure the ohci core is operational.
>   	 */
> diff --git a/drivers/usb/host/ehci-xilinx-of.c b/drivers/usb/host/ehci-xilinx-of.c
> index fe57710..6c6f8c7 100644
> --- a/drivers/usb/host/ehci-xilinx-of.c
> +++ b/drivers/usb/host/ehci-xilinx-of.c
> @@ -153,11 +153,11 @@ static int ehci_hcd_xilinx_of_probe(struct platform_device *op)
>   	hcd->rsrc_start = res.start;
>   	hcd->rsrc_len = resource_size(&res);
>
> -	irq = irq_of_parse_and_map(dn, 0);
> -	if (!irq) {
> -		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
> +	irq = devm_irq_of_parse_and_map(&op->dev, dn, 0);
> +	if (irq <= 0) {
> +		dev_err(&op->dev, "%s: devm_irq_of_parse_and_map failed\n",
>   			__FILE__);
> -		rv = -EBUSY;
> +		rv = irq ? irq : -EINVAL;
>   		goto err_irq;
>   	}
>
> diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c
> index 965e3e9..fcdd23a 100644
> --- a/drivers/usb/host/ohci-ppc-of.c
> +++ b/drivers/usb/host/ohci-ppc-of.c
> @@ -121,11 +121,11 @@ static int ohci_hcd_ppc_of_probe(struct platform_device *op)
>   		goto err_rmr;
>   	}
>
> -	irq = irq_of_parse_and_map(dn, 0);
> +	irq = devm_irq_of_parse_and_map(*op->dev, dn, 0);
>   	if (irq == NO_IRQ) {
>   		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
>   			__FILE__);
> -		rv = -EBUSY;
> +		rv = irq ? irq : -EINVAL;
>   		goto err_rmr;
>   	}
>
> @@ -170,7 +170,6 @@ static int ohci_hcd_ppc_of_probe(struct platform_device *op)
>   			pr_debug("%s: cannot get ehci offset from fdt\n", __FILE__);
>   	}
>
> -	irq_dispose_mapping(irq);
>   err_rmr:
>    	usb_put_hcd(hcd);
>
> @@ -185,8 +184,6 @@ static int ohci_hcd_ppc_of_remove(struct platform_device *op)
>
>   	usb_remove_hcd(hcd);
>
> -	irq_dispose_mapping(hcd->irq);
> -
>   	usb_put_hcd(hcd);
>
>   	return 0;
>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 20/21] usb: use devm_irq_of_parse_and_map() where appropriate
@ 2014-06-16  9:44       ` Nikita Yushchenko
  0 siblings, 0 replies; 52+ messages in thread
From: Nikita Yushchenko @ 2014-06-16  9:44 UTC (permalink / raw)
  To: Andreas Larsson, Grant Likely, Rob Herring,
	Benjamin Herrenschmidt, Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy

>> diff --git a/drivers/usb/host/ehci-grlib.c
>> b/drivers/usb/host/ehci-grlib.c
>> index 495b6fb..666c03e 100644
>> --- a/drivers/usb/host/ehci-grlib.c
>> +++ b/drivers/usb/host/ehci-grlib.c
>> @@ -111,11 +111,11 @@ static int ehci_hcd_grlib_probe(struct
>> platform_device *op)
>>       hcd->rsrc_start = res.start;
>>       hcd->rsrc_len = resource_size(&res);
>>
>> -    irq = irq_of_parse_and_map(dn, 0);
>> -    if (irq == NO_IRQ) {
>> -        dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
>> +    irq = devm_irq_of_parse_and_map(&op->dev, dn, 0);
>> +    if (irq <= 0) {
>> +        dev_err(&op->dev, "%s: devm_irq_of_parse_and_map failed\n",
>>               __FILE__);
>> -        rv = -EBUSY;
>> +        rv = irq ? irq : -EINVAL;
> 
> Here and in more places below you change the return value from -EBUSY to
> -EINVAL when irq == 0. These changes and the reason for them is not
> something that is commented upon in the commit message. Maybe these
> changes were not intended or should be in a separate patch?

Although errno codes are quite unspecific, I can't think a valid reason
to return -EBUSY on [devm_]irq_of_parse_and_map() failure. It could be
-EINVAL or -ENODEV, but not -EBUSY ...

Since changing line that sets error code anyway, I decided to change
-EBUST to -ENODEV.

But I agree that this is not the topic of the patch.

IS it better to remove this change from changeset alltogether, or to
mention it in commit's log message?

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 20/21] usb: use devm_irq_of_parse_and_map() where appropriate
@ 2014-06-16  9:44       ` Nikita Yushchenko
  0 siblings, 0 replies; 52+ messages in thread
From: Nikita Yushchenko @ 2014-06-16  9:44 UTC (permalink / raw)
  To: Andreas Larsson, Grant Likely, Rob Herring,
	Benjamin Herrenschmidt, Thomas Gleixner,
	devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, lugovskoy-jFhMxQ4mL6a2X5qOxWx28w

>> diff --git a/drivers/usb/host/ehci-grlib.c
>> b/drivers/usb/host/ehci-grlib.c
>> index 495b6fb..666c03e 100644
>> --- a/drivers/usb/host/ehci-grlib.c
>> +++ b/drivers/usb/host/ehci-grlib.c
>> @@ -111,11 +111,11 @@ static int ehci_hcd_grlib_probe(struct
>> platform_device *op)
>>       hcd->rsrc_start = res.start;
>>       hcd->rsrc_len = resource_size(&res);
>>
>> -    irq = irq_of_parse_and_map(dn, 0);
>> -    if (irq == NO_IRQ) {
>> -        dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
>> +    irq = devm_irq_of_parse_and_map(&op->dev, dn, 0);
>> +    if (irq <= 0) {
>> +        dev_err(&op->dev, "%s: devm_irq_of_parse_and_map failed\n",
>>               __FILE__);
>> -        rv = -EBUSY;
>> +        rv = irq ? irq : -EINVAL;
> 
> Here and in more places below you change the return value from -EBUSY to
> -EINVAL when irq == 0. These changes and the reason for them is not
> something that is commented upon in the commit message. Maybe these
> changes were not intended or should be in a separate patch?

Although errno codes are quite unspecific, I can't think a valid reason
to return -EBUSY on [devm_]irq_of_parse_and_map() failure. It could be
-EINVAL or -ENODEV, but not -EBUSY ...

Since changing line that sets error code anyway, I decided to change
-EBUST to -ENODEV.

But I agree that this is not the topic of the patch.

IS it better to remove this change from changeset alltogether, or to
mention it in commit's log message?
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 20/21] usb: use devm_irq_of_parse_and_map() where appropriate
@ 2014-06-16  9:54         ` Andreas Larsson
  0 siblings, 0 replies; 52+ messages in thread
From: Andreas Larsson @ 2014-06-16  9:54 UTC (permalink / raw)
  To: Nikita Yushchenko, Grant Likely, Rob Herring,
	Benjamin Herrenschmidt, Thomas Gleixner, devicetree
  Cc: linux-kernel, lugovskoy

On 2014-06-16 11:44, Nikita Yushchenko wrote:
>>> diff --git a/drivers/usb/host/ehci-grlib.c
>>> b/drivers/usb/host/ehci-grlib.c
>>> index 495b6fb..666c03e 100644
>>> --- a/drivers/usb/host/ehci-grlib.c
>>> +++ b/drivers/usb/host/ehci-grlib.c
>>> @@ -111,11 +111,11 @@ static int ehci_hcd_grlib_probe(struct
>>> platform_device *op)
>>>        hcd->rsrc_start = res.start;
>>>        hcd->rsrc_len = resource_size(&res);
>>>
>>> -    irq = irq_of_parse_and_map(dn, 0);
>>> -    if (irq == NO_IRQ) {
>>> -        dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
>>> +    irq = devm_irq_of_parse_and_map(&op->dev, dn, 0);
>>> +    if (irq <= 0) {
>>> +        dev_err(&op->dev, "%s: devm_irq_of_parse_and_map failed\n",
>>>                __FILE__);
>>> -        rv = -EBUSY;
>>> +        rv = irq ? irq : -EINVAL;
>>
>> Here and in more places below you change the return value from -EBUSY to
>> -EINVAL when irq == 0. These changes and the reason for them is not
>> something that is commented upon in the commit message. Maybe these
>> changes were not intended or should be in a separate patch?
>
> Although errno codes are quite unspecific, I can't think a valid reason
> to return -EBUSY on [devm_]irq_of_parse_and_map() failure. It could be
> -EINVAL or -ENODEV, but not -EBUSY ...
>
> Since changing line that sets error code anyway, I decided to change
> -EBUST to -ENODEV.
>
> But I agree that this is not the topic of the patch.
>
> IS it better to remove this change from changeset alltogether, or to
> mention it in commit's log message?

Given that there are a lot of -EBUSY being returned in drivers/usb/host 
- not just in these error cases, maybe it is better to not touch this in 
this patch set.

Best regards,
Andreas Larsson

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 20/21] usb: use devm_irq_of_parse_and_map() where appropriate
@ 2014-06-16  9:54         ` Andreas Larsson
  0 siblings, 0 replies; 52+ messages in thread
From: Andreas Larsson @ 2014-06-16  9:54 UTC (permalink / raw)
  To: Nikita Yushchenko, Grant Likely, Rob Herring,
	Benjamin Herrenschmidt, Thomas Gleixner,
	devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, lugovskoy-jFhMxQ4mL6a2X5qOxWx28w

On 2014-06-16 11:44, Nikita Yushchenko wrote:
>>> diff --git a/drivers/usb/host/ehci-grlib.c
>>> b/drivers/usb/host/ehci-grlib.c
>>> index 495b6fb..666c03e 100644
>>> --- a/drivers/usb/host/ehci-grlib.c
>>> +++ b/drivers/usb/host/ehci-grlib.c
>>> @@ -111,11 +111,11 @@ static int ehci_hcd_grlib_probe(struct
>>> platform_device *op)
>>>        hcd->rsrc_start = res.start;
>>>        hcd->rsrc_len = resource_size(&res);
>>>
>>> -    irq = irq_of_parse_and_map(dn, 0);
>>> -    if (irq == NO_IRQ) {
>>> -        dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
>>> +    irq = devm_irq_of_parse_and_map(&op->dev, dn, 0);
>>> +    if (irq <= 0) {
>>> +        dev_err(&op->dev, "%s: devm_irq_of_parse_and_map failed\n",
>>>                __FILE__);
>>> -        rv = -EBUSY;
>>> +        rv = irq ? irq : -EINVAL;
>>
>> Here and in more places below you change the return value from -EBUSY to
>> -EINVAL when irq == 0. These changes and the reason for them is not
>> something that is commented upon in the commit message. Maybe these
>> changes were not intended or should be in a separate patch?
>
> Although errno codes are quite unspecific, I can't think a valid reason
> to return -EBUSY on [devm_]irq_of_parse_and_map() failure. It could be
> -EINVAL or -ENODEV, but not -EBUSY ...
>
> Since changing line that sets error code anyway, I decided to change
> -EBUST to -ENODEV.
>
> But I agree that this is not the topic of the patch.
>
> IS it better to remove this change from changeset alltogether, or to
> mention it in commit's log message?

Given that there are a lot of -EBUSY being returned in drivers/usb/host 
- not just in these error cases, maybe it is better to not touch this in 
this patch set.

Best regards,
Andreas Larsson
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 11/21] mfd: use devm_irq_of_parse_and_map() where appropriate
  2014-06-04 11:13   ` nyushchenko-jFhMxQ4mL6a2X5qOxWx28w
  (?)
@ 2014-06-17 15:12   ` Lee Jones
  2014-06-17 15:36       ` Nikita Yushchenko
  -1 siblings, 1 reply; 52+ messages in thread
From: Lee Jones @ 2014-06-17 15:12 UTC (permalink / raw)
  To: nyushchenko
  Cc: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree, linux-kernel, lugovskoy

> 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.
> 
> Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
> ---
>  drivers/mfd/max8997.c |    4 +++-
>  drivers/mfd/max8998.c |    4 +++-
>  2 files changed, 6 insertions(+), 2 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
> index 8cf7a01..6ae0786 100644
> --- a/drivers/mfd/max8997.c
> +++ b/drivers/mfd/max8997.c
> @@ -153,7 +153,9 @@ static struct max8997_platform_data *max8997_i2c_parse_dt_pdata(
>  		return ERR_PTR(-ENOMEM);
>  	}
>  
> -	pd->ono = irq_of_parse_and_map(dev->of_node, 1);
> +	pd->ono = devm_irq_of_parse_and_map(dev, dev->of_node, 1);
> +	if (pd->ono < 0)
> +		return ERR_PTR(pd->ono);
>  
>  	/*
>  	 * ToDo: the 'wakeup' member in the platform data is more of a linux
> diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c
> index 592db06..6b62dd7 100644
> --- a/drivers/mfd/max8998.c
> +++ b/drivers/mfd/max8998.c
> @@ -159,7 +159,9 @@ static struct max8998_platform_data *max8998_i2c_parse_dt_pdata(
>  	if (!pd)
>  		return ERR_PTR(-ENOMEM);
>  
> -	pd->ono = irq_of_parse_and_map(dev->of_node, 1);
> +	pd->ono = devm_irq_of_parse_and_map(dev, dev->of_node, 1);
> +	if (pd->ono < 0)
> +		return ERR_PTR(pd->ono);
>  
>  	/*
>  	 * ToDo: the 'wakeup' member in the platform data is more of a linux

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 11/21] mfd: use devm_irq_of_parse_and_map() where appropriate
  2014-06-17 15:12   ` Lee Jones
@ 2014-06-17 15:36       ` Nikita Yushchenko
  0 siblings, 0 replies; 52+ messages in thread
From: Nikita Yushchenko @ 2014-06-17 15:36 UTC (permalink / raw)
  To: Lee Jones
  Cc: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree, linux-kernel, lugovskoy

17.06.2014 19:12, Lee Jones пишет:
>> 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.
>>
>> Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
>> ---
>>   drivers/mfd/max8997.c |    4 +++-
>>   drivers/mfd/max8998.c |    4 +++-
>>   2 files changed, 6 insertions(+), 2 deletions(-)
>
> Applied, thanks.

Hmm...  probably it was too early to apply this?  I was just going to 
prepare v2, based on discussion...

Also, applying only 11/21, without 01/21, will just cause build errors ...

Confused.

Nikita

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 11/21] mfd: use devm_irq_of_parse_and_map() where appropriate
@ 2014-06-17 15:36       ` Nikita Yushchenko
  0 siblings, 0 replies; 52+ messages in thread
From: Nikita Yushchenko @ 2014-06-17 15:36 UTC (permalink / raw)
  To: Lee Jones
  Cc: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	lugovskoy-jFhMxQ4mL6a2X5qOxWx28w

17.06.2014 19:12, Lee Jones пишет:
>> From: Nikita Yushchenko <nyushchenko-jFhMxQ4mL6a2X5qOxWx28w@public.gmane.org>
>>
>> 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.
>>
>> Signed-off-by: Nikita Yushchenko <nyushchenko-jFhMxQ4mL6a2X5qOxWx28w@public.gmane.org>
>> ---
>>   drivers/mfd/max8997.c |    4 +++-
>>   drivers/mfd/max8998.c |    4 +++-
>>   2 files changed, 6 insertions(+), 2 deletions(-)
>
> Applied, thanks.

Hmm...  probably it was too early to apply this?  I was just going to 
prepare v2, based on discussion...

Also, applying only 11/21, without 01/21, will just cause build errors ...

Confused.

Nikita
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 11/21] mfd: use devm_irq_of_parse_and_map() where appropriate
  2014-06-17 15:36       ` Nikita Yushchenko
  (?)
@ 2014-06-18  8:48       ` Lee Jones
  2014-06-18 11:31           ` Nikita Yushchenko
  -1 siblings, 1 reply; 52+ messages in thread
From: Lee Jones @ 2014-06-18  8:48 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree, linux-kernel, lugovskoy

On Tue, 17 Jun 2014, Nikita Yushchenko wrote:
> 17.06.2014 19:12, Lee Jones пишет:
> >>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.
> >>
> >>Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
> >>---
> >>  drivers/mfd/max8997.c |    4 +++-
> >>  drivers/mfd/max8998.c |    4 +++-
> >>  2 files changed, 6 insertions(+), 2 deletions(-)
> >
> >Applied, thanks.
> 
> Hmm...  probably it was too early to apply this?  I was just going
> to prepare v2, based on discussion...

Which discussion?

> Also, applying only 11/21, without 01/21, will just cause build errors ...

CC'ing me on this patch alone when you know you have build
dependencies on other patches in the set is a bad idea.  Failing to
mention that you wanted the patch to be handled in a special and/or
unconventional way is an even worse idea.

How are you expecting this patch(-set) to be handled?

> Confused.

Likewise!

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 11/21] mfd: use devm_irq_of_parse_and_map() where appropriate
  2014-06-18  8:48       ` Lee Jones
@ 2014-06-18 11:31           ` Nikita Yushchenko
  0 siblings, 0 replies; 52+ messages in thread
From: Nikita Yushchenko @ 2014-06-18 11:31 UTC (permalink / raw)
  To: Lee Jones
  Cc: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree, linux-kernel, lugovskoy

>> Hmm...  probably it was too early to apply this?  I was just going
>> to prepare v2, based on discussion...
>
> Which discussion?

One you are replying in?

https://lkml.org/lkml/2014/6/4/136

>> Also, applying only 11/21, without 01/21, will just cause build errors ...
>
> CC'ing me on this patch alone when you know you have build
> dependencies on other patches in the set is a bad idea.  Failing to
> mention that you wanted the patch to be handled in a special and/or
> unconventional way is an even worse idea.
>
> How are you expecting this patch(-set) to be handled?

Sorry but I did not CC you this patch.

I sent entire patchset to mailing lists and to maintainers of IRQ and 
device tree subsystems.
I used git send-email, and all mails went out to the same recipients.
Recipient addresses extracted using scripts/get_maintainer.pl applied to 
the "main" patch of the patchset.
I did not sent entire patchset to maintainers of individual changed 
drivers because this makes recipient address too big and too much looks 
like spamming.
I did not send individual patches to individual addresses to avoid cases 
of partially-applied patchset that will just break things (actually this 
is what happened with 11/21)

I'm quite sorry if I did things wrong, it was my first attempt to sent 
patchset with tree-wide fixes. However, I don't see what I've done 
wrong... any hints on that will be appreciated.

Nikita


^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 11/21] mfd: use devm_irq_of_parse_and_map() where appropriate
@ 2014-06-18 11:31           ` Nikita Yushchenko
  0 siblings, 0 replies; 52+ messages in thread
From: Nikita Yushchenko @ 2014-06-18 11:31 UTC (permalink / raw)
  To: Lee Jones
  Cc: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	lugovskoy-jFhMxQ4mL6a2X5qOxWx28w

>> Hmm...  probably it was too early to apply this?  I was just going
>> to prepare v2, based on discussion...
>
> Which discussion?

One you are replying in?

https://lkml.org/lkml/2014/6/4/136

>> Also, applying only 11/21, without 01/21, will just cause build errors ...
>
> CC'ing me on this patch alone when you know you have build
> dependencies on other patches in the set is a bad idea.  Failing to
> mention that you wanted the patch to be handled in a special and/or
> unconventional way is an even worse idea.
>
> How are you expecting this patch(-set) to be handled?

Sorry but I did not CC you this patch.

I sent entire patchset to mailing lists and to maintainers of IRQ and 
device tree subsystems.
I used git send-email, and all mails went out to the same recipients.
Recipient addresses extracted using scripts/get_maintainer.pl applied to 
the "main" patch of the patchset.
I did not sent entire patchset to maintainers of individual changed 
drivers because this makes recipient address too big and too much looks 
like spamming.
I did not send individual patches to individual addresses to avoid cases 
of partially-applied patchset that will just break things (actually this 
is what happened with 11/21)

I'm quite sorry if I did things wrong, it was my first attempt to sent 
patchset with tree-wide fixes. However, I don't see what I've done 
wrong... any hints on that will be appreciated.

Nikita

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 11/21] mfd: use devm_irq_of_parse_and_map() where appropriate
  2014-06-18 11:31           ` Nikita Yushchenko
  (?)
@ 2014-06-18 12:20           ` Lee Jones
  -1 siblings, 0 replies; 52+ messages in thread
From: Lee Jones @ 2014-06-18 12:20 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: Grant Likely, Rob Herring, Benjamin Herrenschmidt,
	Thomas Gleixner, devicetree, linux-kernel, lugovskoy

On Wed, 18 Jun 2014, Nikita Yushchenko wrote:

> >>Hmm...  probably it was too early to apply this?  I was just going
> >>to prepare v2, based on discussion...
> >
> >Which discussion?
> 
> One you are replying in?
> 
> https://lkml.org/lkml/2014/6/4/136

I only see what's in my mailbox.  If you didn't send me any other
patches, which were subsequently commented on, I wouldn't have seen
said comments/discussion.

> >>Also, applying only 11/21, without 01/21, will just cause build errors ...
> >
> >CC'ing me on this patch alone when you know you have build
> >dependencies on other patches in the set is a bad idea.  Failing to
> >mention that you wanted the patch to be handled in a special and/or
> >unconventional way is an even worse idea.
> >
> >How are you expecting this patch(-set) to be handled?
> 
> Sorry but I did not CC you this patch.
> 
> I sent entire patchset to mailing lists and to maintainers of IRQ
> and device tree subsystems.
> I used git send-email, and all mails went out to the same recipients.
> Recipient addresses extracted using scripts/get_maintainer.pl
> applied to the "main" patch of the patchset.
> I did not sent entire patchset to maintainers of individual changed
> drivers because this makes recipient address too big and too much
> looks like spamming.
> I did not send individual patches to individual addresses to avoid
> cases of partially-applied patchset that will just break things
> (actually this is what happened with 11/21)
> 
> I'm quite sorry if I did things wrong, it was my first attempt to
> sent patchset with tree-wide fixes. However, I don't see what I've
> done wrong... any hints on that will be appreciated.

This is quite tricky due to the size of the set and the number of
subsystems it touches.  The optimum method is to have the smallest
patch-set and touch only the very least amount of subsystems as
possible.  This is almost always feasible, however in the small cases
that it's not, the alternative is to let the maintainers know what
your plans are i.e. if you're only looking for Acks and that you (or
another maintainer) will send out a pull-request to all of the other
maintainers to suck into their trees.  This is required to prevent
conflicts during the merge-window.  If you want to send such messages
to all of the parties without spamming them with the rest of the set,
you can do so in the commit message (which you can then keep in Git
for subsequent revisions).

For example:

> 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.
>
> Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
> ---
> My intention is to take this entire set through the <SUBSYSTEM> tree.
> To facilitate this I'm collecting maintainer Acks.  Once applied to
> the <SUBSYSTEM> tree a pull-request will be sent out in order to avoid
> merge conflicts at pull-time.
> ---
>  drivers/mfd/max8997.c |    4 +++-
>  drivers/mfd/max8998.c |    4 +++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
> diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
> index 8cf7a01..6ae0786 100644
> --- a/drivers/mfd/max8997.c
> +++ b/drivers/mfd/max8997.c
> [...]

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2014-06-18 12:20 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 02/21] ata: use devm_irq_of_parse_and_map() where appropriate nyushchenko
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

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.