Skip to contentSkip to conversation

mfd: Support dynamic allocation of IRQ range for wm831x

PATCH In review Mark Brown 2 participants 2 messages Jun 1, 2011 – Jun 2, 2011

Subsystems (2)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 mfd: Support dynamic allocation of IRQ range for wm831x

Use irq_allocate_desc() to get the IRQ range, which turns into a noop on non-sparse systems. Since all existing users are non-sparse there should be no compatibility issues.

---
 drivers/mfd/wm831x-irq.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
drivers/mfd/wm831x-irq.c +12 -3
index b23d8d5..a25a7d5 100644
@@ -527,9 +527,18 @@ int wm831x_irq_init(struct wm831x *wm831x, int irq)
 				 0xffff);
 	}
 
-	if (!pdata || !pdata->irq_base) {
-		dev_err(wm831x->dev,
-			"No interrupt base specified, no interrupts\n");
+	/* Try to dynamically allocate IRQs if no base is specified */
+	if (!pdata || !pdata->irq_base)
+		wm831x->irq_base = -1;
+	else
+		wm831x->irq_base = pdata->irq_base;
+
+	wm831x->irq_base = irq_alloc_descs(wm831x->irq_base, 0,
+					   WM831X_NUM_IRQS, 0);
+	if (wm831x->irq_base < 0) {
+		dev_warn(wm831x->dev, "Failed to allocate IRQs: %d\n",
+			 wm831x->irq_base);
+		wm831x->irq_base = 0;
 		return 0;
 	}
 
Signature · 1 line
1.7.5.3
#1 lore raw

Hi Mark,

Quoted 24 lines · Mark Brown

Use irq_allocate_desc() to get the IRQ range, which turns into a noop on non-sparse systems. Since all existing users are non-sparse there should be no compatibility issues.

---
 drivers/mfd/wm831x-irq.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
drivers/mfd/wm831x-irq.c +4 -3
index b23d8d5..a25a7d5 100644
@@ -527,9 +527,18 @@ int wm831x_irq_init(struct wm831x *wm831x, int irq)
 				 0xffff);
 	}
 
-	if (!pdata || !pdata->irq_base) {
-		dev_err(wm831x->dev,
-			"No interrupt base specified, no interrupts\n");
+	/* Try to dynamically allocate IRQs if no base is specified */
+	if (!pdata || !pdata->irq_base)
+		wm831x->irq_base = -1;
+	else

drivers/mfd/wm831x-irq.c int wm831x_irq_init(struct wm831x *wm831x, int irq) · line 543

Quoted 10 lines
drivers/mfd/wm831x-irq.c +8 -0
+		wm831x->irq_base = pdata->irq_base;
+
+	wm831x->irq_base = irq_alloc_descs(wm831x->irq_base, 0,
+					   WM831X_NUM_IRQS, 0);
+	if (wm831x->irq_base < 0) {
+		dev_warn(wm831x->dev, "Failed to allocate IRQs: %d\n",
+			 wm831x->irq_base);
+		wm831x->irq_base = 0;
 		return 0;
 	}

The lines you remove made sure that the rest of this function is executed with valid pdata. At least on v3.0-rc1 pdata is used later without validity checks. So unless there are some patches in -next that I'm missing you need to update your patch.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |